index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467
  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. @search-criteria-switch="searchCriteriaSwitch"
  42. @tree-load="treeLoad"
  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. </avue-crud>
  87. <report-dialog
  88. :switchDialog="switchDialog"
  89. reportName="客户资料-客户资料"
  90. @onClose="onClose()"
  91. v-if="$store.getters.userInfo.tenant_id == '096359'"
  92. ></report-dialog>
  93. <report-dialog
  94. :switchDialog="switchDialog"
  95. reportName="客户信息"
  96. corpType="GS"
  97. @onClose="onClose()"
  98. v-else
  99. ></report-dialog>
  100. <el-dialog
  101. title="导入所属公司"
  102. append-to-body
  103. :visible.sync="excelBox"
  104. width="555px"
  105. :close-on-click-modal="false"
  106. v-dialog-drag
  107. >
  108. <avue-form
  109. :option="excelOption"
  110. v-model="excelForm"
  111. table-loading="excelLoading"
  112. :upload-before="uploadBefore"
  113. :upload-after="uploadAfter"
  114. >
  115. <template slot="excelTemplate">
  116. <el-button type="primary" @click="derivation">
  117. 点击下载<i class="el-icon-download el-icon--right"></i>
  118. </el-button>
  119. </template>
  120. </avue-form>
  121. <p style="text-align: center;color: #DC0505">
  122. 温馨提示 第一次导入时请先下载模板
  123. </p>
  124. </el-dialog>
  125. </basic-container>
  126. </el-col>
  127. </el-row>
  128. </div>
  129. <detail-page
  130. @goBack="goBack"
  131. :detailData="detailData"
  132. v-if="!show"
  133. ></detail-page>
  134. </div>
  135. </template>
  136. <script>
  137. import detailPage from "./detailsPageEdit";
  138. import option from "./configuration/mainList.json";
  139. import {
  140. customerList,
  141. typeSave,
  142. detail,
  143. deleteDetails,
  144. getDeptLazyTree
  145. } from "@/api/basicData/customerInformation";
  146. import { getToken } from "@/util/auth";
  147. import reportDialog from "@/components/report-dialog/main";
  148. import { companyParameter } from "@/enums/management-type";
  149. import { gainUser } from "@/api/basicData/customerInquiry";
  150. export default {
  151. name: "customerInformation",
  152. data() {
  153. return {
  154. show: true,
  155. detailData: {},
  156. reportQuery: {},
  157. switchDialog: false,
  158. treeDeptId: "",
  159. form: {},
  160. search:{},
  161. option: option,
  162. parentId: 0,
  163. dataList: [],
  164. treeOption: {
  165. nodeKey: "id",
  166. lazy: true,
  167. treeLoad: function(node, resolve) {
  168. const parentId = node.level === 0 ? 0 : node.data.id;
  169. getDeptLazyTree({
  170. parentId: parentId,
  171. corpType: companyParameter.code
  172. }).then(res => {
  173. resolve(
  174. res.data.data.map(item => {
  175. return {
  176. ...item,
  177. leaf: !item.hasChildren
  178. };
  179. })
  180. );
  181. });
  182. },
  183. addBtn: false,
  184. menu: false,
  185. size: "small",
  186. props: {
  187. labelText: "标题",
  188. label: "title",
  189. value: "value",
  190. children: "children"
  191. }
  192. },
  193. page: {
  194. pageSize: 20,
  195. currentPage: 1,
  196. total: 0,
  197. pageSizes: [10, 20, 30, 40, 50, 100, 200, 300, 400, 500]
  198. },
  199. excelBox: false,
  200. excelLoading: false,
  201. excelForm: {},
  202. excelOption: {
  203. submitBtn: false,
  204. emptyBtn: false,
  205. column: [
  206. {
  207. label: "模板下载",
  208. prop: "excelTemplate",
  209. formslot: true,
  210. span: 24
  211. },
  212. {
  213. label: "模板上传",
  214. prop: "excelFile",
  215. type: "upload",
  216. drag: true,
  217. loadText: "模板上传中,请稍等",
  218. span: 24,
  219. propsHttp: {
  220. res: "data"
  221. },
  222. tip: "请上传 .xls,.xlsx 标准格式文件",
  223. action: "/api/blade-client/corpsdesc/import-company-desc"
  224. }
  225. ]
  226. }
  227. };
  228. },
  229. components: {
  230. reportDialog,
  231. detailPage
  232. },
  233. filters: {
  234. adminProfileFilter(row) {
  235. if (row) {
  236. return row.substr(0, row.length - 1);
  237. }
  238. }
  239. },
  240. async created() {
  241. this.option = await this.getColumnData(this.getColumnName(150), option);
  242. gainUser().then(res => {
  243. this.findObject(this.option.column, "adminProfiles").dicData =
  244. res.data.data;
  245. });
  246. },
  247. // watch:{
  248. // 'excelForm.isCovered'() {
  249. // if (this.excelForm.isCovered !== '') {
  250. // const column = this.findObject(this.excelOption.column, "excelFile");
  251. // column.action = `/api/blade-user/import-user?isCovered=${this.excelForm.isCovered}`;
  252. // }
  253. // }
  254. // },
  255. methods: {
  256. derivation() {
  257. window.open(
  258. `/api/blade-client/corpsdesc/export-company-template?${
  259. this.website.tokenHeader
  260. }=${getToken()}`
  261. );
  262. },
  263. uploadBefore(file, done, loading) {
  264. done();
  265. loading = true;
  266. },
  267. uploadAfter(res, done, loading, column) {
  268. window.console.log(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: "GS"
  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: companyParameter.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: companyParameter.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. async saveColumn() {
  413. const inSave = await this.saveColumnData(
  414. this.getColumnName(150),
  415. this.option
  416. );
  417. if (inSave) {
  418. this.$nextTick(() => {
  419. this.$refs.crud.doLayout();
  420. });
  421. this.$message.success("保存成功");
  422. //关闭窗口
  423. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  424. }
  425. },
  426. async resetColumn() {
  427. this.option = option;
  428. const inSave = await this.delColumnData(this.getColumnName(150), option);
  429. if (inSave) {
  430. this.$nextTick(() => {
  431. this.$refs.crud.doLayout();
  432. });
  433. this.$message.success("重置成功");
  434. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  435. }
  436. },
  437. //树桩列点击展开触发
  438. treeLoad(tree, treeNode, resolve) {
  439. const parentId = tree.id;
  440. customerList({
  441. parentId: parentId,
  442. corpType: companyParameter.code
  443. }).then(res => {
  444. resolve(res.data.data.records);
  445. });
  446. },
  447. openReport() {
  448. this.switchDialog = !this.switchDialog;
  449. },
  450. onClose(val) {
  451. this.switchDialog = val;
  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>