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="GYS"
  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 { supplierParameter } 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: supplierParameter.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-supplier-desc"
  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(146), 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-supplier-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. window.console.log(column);
  270. this.excelBox = false;
  271. this.$message.success("导入成功!");
  272. this.refreshChange();
  273. loading = false;
  274. done();
  275. },
  276. nodeClick(data) {
  277. this.treeDeptId = data.id;
  278. this.page.currentPage = 1;
  279. this.onLoad(this.page);
  280. },
  281. //删除列表后面的删除按钮触发触发(row, index, done)
  282. rowDel(row, index, done) {
  283. this.$confirm("确定将选择数据删除?", {
  284. confirmButtonText: "确定",
  285. cancelButtonText: "取消",
  286. type: "warning"
  287. })
  288. .then(() => {
  289. return deleteDetails({
  290. id: row.id,
  291. corpsTypeId: row.corpsTypeId,
  292. corpType: "GYS"
  293. });
  294. })
  295. .then(() => {
  296. this.$message({
  297. type: "success",
  298. message: "操作成功!"
  299. });
  300. this.page.currentPage = 1;
  301. this.onLoad(this.page, { parentId: 0 });
  302. });
  303. },
  304. //修改时的修改按钮点击触发
  305. rowUpdate(row, index, done, loading) {
  306. typeSave(row).then(
  307. () => {
  308. this.$message({
  309. type: "success",
  310. message: "操作成功!"
  311. });
  312. // 数据回调进行刷新
  313. done(row);
  314. },
  315. error => {
  316. window.console.log(error);
  317. loading();
  318. }
  319. );
  320. },
  321. //新增修改时保存触发
  322. rowSave(row, done, loading) {
  323. typeSave(row).then(res => {
  324. console.log(res);
  325. done();
  326. });
  327. },
  328. //查询全部
  329. initData() {
  330. customerList({ corpType: supplierParameter.code }).then(res => {
  331. console.log(this.form);
  332. const column = this.findObject(this.option.column, "parentId");
  333. column.dicData = res.data.data.records;
  334. });
  335. },
  336. //新增子项触发
  337. handleAdd(row) {
  338. this.parentId = row.id;
  339. const column = this.findObject(this.option.column, "parentId");
  340. column.value = row.id;
  341. column.addDisabled = true;
  342. this.$refs.crud.rowAdd();
  343. },
  344. //新增跳转页面
  345. beforeOpen() {
  346. this.show = false;
  347. this.detailData = {
  348. treeDeptId: this.treeDeptId
  349. };
  350. },
  351. editOpen(row, status) {
  352. this.detailData = {
  353. id: row.id,
  354. status: status
  355. };
  356. this.show = false;
  357. },
  358. //点击新增时触发
  359. beforeClose(done) {
  360. this.parentId = "";
  361. const column = this.findObject(this.option.column, "parentId");
  362. column.value = "";
  363. column.addDisabled = false;
  364. done();
  365. },
  366. //点击搜索按钮触发
  367. searchChange(params, done) {
  368. console.log(params);
  369. this.page.currentPage = 1;
  370. this.onLoad(this.page, params);
  371. done();
  372. },
  373. //搜索重置按钮触发
  374. searchReset() {
  375. this.treeDeptId = "";
  376. this.onLoad(this.page);
  377. },
  378. selectionChange() {
  379. console.log("1");
  380. },
  381. currentChange() {
  382. console.log("1");
  383. },
  384. sizeChange() {
  385. console.log("1");
  386. },
  387. refreshChange() {
  388. this.onLoad(this.page);
  389. },
  390. onLoad(page, params = { parentId: 0 }) {
  391. let queryParams = Object.assign({}, params, {
  392. size: page.pageSize,
  393. current: page.currentPage,
  394. corpsTypeId: this.treeDeptId,
  395. corpType: supplierParameter.code
  396. });
  397. customerList(queryParams).then(res => {
  398. this.dataList = res.data.data.records;
  399. this.page.total = res.data.data.total;
  400. if (this.page.total || this.page.total === 0) {
  401. this.option.height = window.innerHeight - 210;
  402. }
  403. });
  404. },
  405. searchCriteriaSwitch(type) {
  406. if (type) {
  407. this.option.height = this.option.height - 93;
  408. } else {
  409. this.option.height = this.option.height + 93;
  410. }
  411. this.$refs.crud.getTableHeight();
  412. },
  413. //树桩列点击展开触发
  414. treeLoad(tree, treeNode, resolve) {
  415. const parentId = tree.id;
  416. customerList({
  417. parentId: parentId,
  418. corpType: supplierParameter.code
  419. }).then(res => {
  420. resolve(res.data.data.records);
  421. });
  422. },
  423. openReport() {
  424. this.switchDialog = !this.switchDialog;
  425. },
  426. onClose(val) {
  427. this.switchDialog = val;
  428. },
  429. async saveColumn() {
  430. const inSave = await this.saveColumnData(
  431. this.getColumnName(146),
  432. this.option
  433. );
  434. if (inSave) {
  435. this.$nextTick(() => {
  436. this.$refs.crud.doLayout();
  437. });
  438. this.$message.success("保存成功");
  439. //关闭窗口
  440. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  441. }
  442. },
  443. async resetColumn() {
  444. this.option = option;
  445. const inSave = await this.delColumnData(this.getColumnName(146), option);
  446. if (inSave) {
  447. this.$nextTick(() => {
  448. this.$refs.crud.doLayout();
  449. });
  450. this.$message.success("重置成功");
  451. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  452. }
  453. },
  454. goBack() {
  455. this.detailData = this.$options.data().detailData;
  456. this.show = true;
  457. this.onLoad(this.page, this.search);
  458. }
  459. }
  460. };
  461. </script>
  462. <style scoped>
  463. .page-crad ::v-deep .basic-container__card {
  464. height: 94.8vh;
  465. }
  466. </style>