index.vue 16 KB

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