index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468
  1. <template>
  2. <div>
  3. <div v-show="show">
  4. <el-row>
  5. <el-col :span="5">
  6. <div class="box">
  7. <el-scrollbar>
  8. <basic-container>
  9. <avue-tree
  10. :option="treeOption"
  11. :data="treeData"
  12. @node-click="nodeClick"
  13. />
  14. </basic-container>
  15. </el-scrollbar>
  16. </div>
  17. </el-col>
  18. <el-col :span="19">
  19. <basic-container class="page-crad">
  20. <avue-crud
  21. :option="option"
  22. :data="dataList"
  23. ref="crud"
  24. v-model="form"
  25. :page.sync="page"
  26. @row-del="rowDel"
  27. @row-update="rowUpdate"
  28. :before-open="beforeOpen"
  29. :before-close="beforeClose"
  30. @row-save="rowSave"
  31. @search-change="searchChange"
  32. @search-reset="searchReset"
  33. @selection-change="selectionChange"
  34. @current-change="currentChange"
  35. @size-change="sizeChange"
  36. @refresh-change="refreshChange"
  37. @saveColumn="saveColumn"
  38. @resetColumn="resetColumn"
  39. @on-load="onLoad"
  40. @tree-load="treeLoad"
  41. @search-criteria-switch="searchCriteriaSwitch"
  42. >
  43. <template slot="menuLeft">
  44. <el-button
  45. type="primary"
  46. size="small"
  47. icon="el-icon-bottom"
  48. @click="excelBox = true"
  49. >导入
  50. </el-button>
  51. <el-button
  52. icon="el-icon-printer"
  53. size="small"
  54. type="primary"
  55. @click.stop="openReport()"
  56. >报表打印
  57. </el-button>
  58. </template>
  59. <template slot-scope="scope" slot="menu">
  60. <el-button
  61. type="text"
  62. icon="el-icon-view"
  63. size="small"
  64. @click.stop="editOpen(scope.row, 1)"
  65. >查看
  66. </el-button>
  67. <el-button
  68. type="text"
  69. icon="el-icon-edit"
  70. size="small"
  71. @click.stop="editOpen(scope.row, 1)"
  72. >编辑
  73. </el-button>
  74. <el-button
  75. type="text"
  76. icon="el-icon-delete"
  77. size="small"
  78. @click.stop="rowDel(scope.row, scope.index)"
  79. >删除
  80. </el-button>
  81. </template>
  82. <template slot="adminProfiles" slot-scope="{ row }">
  83. <span>{{ row.adminProfilesName | adminProfileFilter }}</span>
  84. </template>
  85. <template slot="belongtocompany" slot-scope="{ row }">
  86. <span>{{ row.belongCompany }}</span>
  87. </template>
  88. </avue-crud>
  89. <report-dialog
  90. :switchDialog="switchDialog"
  91. reportName="客户资料-客户资料"
  92. @onClose="onClose()"
  93. v-if="$store.getters.userInfo.tenant_id == '096359'"
  94. ></report-dialog>
  95. <report-dialog
  96. :switchDialog="switchDialog"
  97. reportName="客户信息"
  98. corpType="KH"
  99. @onClose="onClose()"
  100. v-else
  101. ></report-dialog>
  102. <el-dialog
  103. title="导入客户"
  104. append-to-body
  105. :visible.sync="excelBox"
  106. width="555px"
  107. :close-on-click-modal="false"
  108. v-dialog-drag
  109. >
  110. <avue-form
  111. :option="excelOption"
  112. v-model="excelForm"
  113. table-loading="excelLoading"
  114. :upload-before="uploadBefore"
  115. :upload-after="uploadAfter"
  116. >
  117. <template slot="excelTemplate">
  118. <el-button type="primary" @click="derivation">
  119. 点击下载<i class="el-icon-download el-icon--right"></i>
  120. </el-button>
  121. </template>
  122. </avue-form>
  123. <p style="text-align: center;color: #DC0505">
  124. 温馨提示 第一次导入时请先下载模板
  125. </p>
  126. </el-dialog>
  127. </basic-container>
  128. </el-col>
  129. </el-row>
  130. </div>
  131. <detail-page
  132. @goBack="goBack"
  133. :detailData="detailData"
  134. v-if="!show"
  135. ></detail-page>
  136. </div>
  137. </template>
  138. <script>
  139. import detailPage from "./detailsPageEdit";
  140. import option from "./configuration/mainList.json";
  141. import {
  142. customerList,
  143. typeSave,
  144. detail,
  145. deleteDetails,
  146. getDeptLazyTree
  147. } from "@/api/basicData/customerInformation";
  148. import { getToken } from "@/util/auth";
  149. import reportDialog from "@/components/report-dialog/main";
  150. import { customerParameter } from "@/enums/management-type";
  151. import { gainUser } from "@/api/basicData/customerInquiry";
  152. export default {
  153. name: "customerInformation",
  154. data() {
  155. return {
  156. show: true,
  157. detailData: {},
  158. reportQuery: {},
  159. switchDialog: false,
  160. treeDeptId: "",
  161. form: {},
  162. option: option,
  163. parentId: 0,
  164. dataList: [],
  165. treeOption: {
  166. nodeKey: "id",
  167. lazy: true,
  168. treeLoad: function(node, resolve) {
  169. const parentId = node.level === 0 ? 0 : node.data.id;
  170. getDeptLazyTree({
  171. parentId: parentId,
  172. corpType: customerParameter.code
  173. }).then(res => {
  174. resolve(
  175. res.data.data.map(item => {
  176. return {
  177. ...item,
  178. leaf: !item.hasChildren
  179. };
  180. })
  181. );
  182. });
  183. },
  184. addBtn: false,
  185. menu: false,
  186. size: "small",
  187. props: {
  188. labelText: "标题",
  189. label: "title",
  190. value: "value",
  191. children: "children"
  192. }
  193. },
  194. page: {
  195. pageSize: 20,
  196. currentPage: 1,
  197. total: 0,
  198. pageSizes: [10, 20, 30, 40, 50, 100, 200, 300, 400, 500]
  199. },
  200. excelBox: false,
  201. excelLoading: false,
  202. excelForm: {},
  203. excelOption: {
  204. submitBtn: false,
  205. emptyBtn: false,
  206. column: [
  207. {
  208. label: "模板下载",
  209. prop: "excelTemplate",
  210. formslot: true,
  211. span: 24
  212. },
  213. {
  214. label: "模板上传",
  215. prop: "excelFile",
  216. type: "upload",
  217. drag: true,
  218. loadText: "模板上传中,请稍等",
  219. span: 24,
  220. propsHttp: {
  221. res: "data"
  222. },
  223. tip: "请上传 .xls,.xlsx 标准格式文件",
  224. action: "/api/blade-client/corpsdesc/import-desc?corpType=KH"
  225. }
  226. ]
  227. }
  228. };
  229. },
  230. components: {
  231. reportDialog,
  232. detailPage
  233. },
  234. filters: {
  235. adminProfileFilter(row) {
  236. if (row) {
  237. return row.substr(0, row.length - 1);
  238. }
  239. }
  240. },
  241. async created() {
  242. this.option = await this.getColumnData(this.getColumnName(142), option);
  243. gainUser().then(res => {
  244. this.findObject(this.option.column, "adminProfiles").dicData =
  245. res.data.data;
  246. });
  247. },
  248. // watch:{
  249. // 'excelForm.isCovered'() {
  250. // if (this.excelForm.isCovered !== '') {
  251. // const column = this.findObject(this.excelOption.column, "excelFile");
  252. // column.action = `/api/blade-user/import-user?isCovered=${this.excelForm.isCovered}`;
  253. // }
  254. // }
  255. // },
  256. methods: {
  257. derivation() {
  258. window.open(
  259. `/api/blade-client/corpsdesc/export-template?${
  260. this.website.tokenHeader
  261. }=${getToken()}`
  262. );
  263. },
  264. uploadBefore(file, done, loading) {
  265. done();
  266. loading = true;
  267. },
  268. uploadAfter(res, done, loading, column) {
  269. this.excelBox = false;
  270. this.$message.success("导入成功!");
  271. this.refreshChange();
  272. loading = false;
  273. done();
  274. },
  275. nodeClick(data) {
  276. this.treeDeptId = data.id;
  277. this.page.currentPage = 1;
  278. this.onLoad(this.page);
  279. },
  280. //删除列表后面的删除按钮触发触发(row, index, done)
  281. rowDel(row, index, done) {
  282. this.$confirm("确定将选择数据删除?", {
  283. confirmButtonText: "确定",
  284. cancelButtonText: "取消",
  285. type: "warning"
  286. })
  287. .then(() => {
  288. return deleteDetails({
  289. id: row.id,
  290. corpsTypeId: row.corpsTypeId,
  291. corpType: "KH"
  292. });
  293. })
  294. .then(() => {
  295. this.$message({
  296. type: "success",
  297. message: "操作成功!"
  298. });
  299. this.page.currentPage = 1;
  300. this.onLoad(this.page, { parentId: 0 });
  301. });
  302. },
  303. //修改时的修改按钮点击触发
  304. rowUpdate(row, index, done, loading) {
  305. typeSave(row).then(
  306. () => {
  307. this.$message({
  308. type: "success",
  309. message: "操作成功!"
  310. });
  311. // 数据回调进行刷新
  312. done(row);
  313. },
  314. error => {
  315. window.console.log(error);
  316. loading();
  317. }
  318. );
  319. },
  320. //新增修改时保存触发
  321. rowSave(row, done, loading) {
  322. typeSave(row).then(res => {
  323. console.log(res);
  324. done();
  325. });
  326. },
  327. //查询全部
  328. initData() {
  329. customerList({ corpType: customerParameter.code }).then(res => {
  330. console.log(this.form);
  331. const column = this.findObject(this.option.column, "parentId");
  332. column.dicData = res.data.data.records;
  333. });
  334. },
  335. //新增子项触发
  336. handleAdd(row) {
  337. this.parentId = row.id;
  338. const column = this.findObject(this.option.column, "parentId");
  339. column.value = row.id;
  340. column.addDisabled = true;
  341. this.$refs.crud.rowAdd();
  342. },
  343. //新增跳转页面
  344. beforeOpen() {
  345. this.show = false;
  346. this.detailData = {
  347. treeDeptId: this.treeDeptId
  348. };
  349. },
  350. editOpen(row, status) {
  351. this.detailData = {
  352. id: row.id,
  353. status: status
  354. };
  355. this.show = false;
  356. },
  357. //点击新增时触发
  358. beforeClose(done) {
  359. this.parentId = "";
  360. const column = this.findObject(this.option.column, "parentId");
  361. column.value = "";
  362. column.addDisabled = false;
  363. done();
  364. },
  365. //点击搜索按钮触发
  366. searchChange(params, done) {
  367. console.log(params);
  368. this.page.currentPage = 1;
  369. this.onLoad(this.page, params);
  370. done();
  371. },
  372. //搜索重置按钮触发
  373. searchReset() {
  374. this.treeDeptId = "";
  375. this.onLoad(this.page);
  376. },
  377. selectionChange() {
  378. console.log("1");
  379. },
  380. currentChange() {
  381. console.log("1");
  382. },
  383. sizeChange() {
  384. console.log("1");
  385. },
  386. refreshChange() {
  387. this.onLoad(this.page);
  388. },
  389. onLoad(page, params = { parentId: 0 }) {
  390. let queryParams = Object.assign({}, params, {
  391. size: page.pageSize,
  392. current: page.currentPage,
  393. corpsTypeId: this.treeDeptId,
  394. corpType: customerParameter.code
  395. });
  396. customerList(queryParams).then(res => {
  397. this.dataList = res.data.data.records;
  398. this.page.total = res.data.data.total;
  399. if (this.page.total || this.page.total === 0) {
  400. this.option.height = window.innerHeight - 210;
  401. }
  402. });
  403. },
  404. searchCriteriaSwitch(type) {
  405. if (type) {
  406. this.option.height = this.option.height - 93;
  407. } else {
  408. this.option.height = this.option.height + 93;
  409. }
  410. this.$refs.crud.getTableHeight();
  411. },
  412. //树桩列点击展开触发
  413. treeLoad(tree, treeNode, resolve) {
  414. const parentId = tree.id;
  415. customerList({
  416. parentId: parentId,
  417. corpType: customerParameter.code
  418. }).then(res => {
  419. resolve(res.data.data.records);
  420. });
  421. },
  422. openReport() {
  423. this.switchDialog = !this.switchDialog;
  424. },
  425. onClose(val) {
  426. this.switchDialog = val;
  427. },
  428. async saveColumn() {
  429. const inSave = await this.saveColumnData(
  430. this.getColumnName(142),
  431. this.option
  432. );
  433. if (inSave) {
  434. this.$nextTick(() => {
  435. this.$refs.crud.doLayout();
  436. });
  437. this.$message.success("保存成功");
  438. //关闭窗口
  439. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  440. }
  441. },
  442. async resetColumn() {
  443. this.option = option;
  444. const inSave = await this.delColumnData(this.getColumnName(142), option);
  445. if (inSave) {
  446. this.$nextTick(() => {
  447. this.$refs.crud.doLayout();
  448. });
  449. this.$message.success("重置成功");
  450. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  451. }
  452. },
  453. goBack() {
  454. this.detailData = this.$options.data().detailData;
  455. this.show = true;
  456. this.onLoad(this.page, this.search);
  457. }
  458. }
  459. };
  460. </script>
  461. <style scoped>
  462. .page-crad ::v-deep .basic-container__card {
  463. height: 94.8vh;
  464. }
  465. </style>