index.vue 11 KB

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