index.vue 14 KB

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