index.vue 11 KB

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