index.vue 13 KB

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