index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427
  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. @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 { CDParameter } 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: CDParameter.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: 20,
  185. currentPage: 1,
  186. total: 0,
  187. pageSizes: [10,20,30,40,50, 100, 200, 300, 400, 500]
  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-fleet-data"
  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/import-fleet-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: CDParameter.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. this.detailData = {
  331. treeDeptId: this.treeDeptId
  332. }
  333. },
  334. editOpen(row, status) {
  335. this.detailData = {
  336. id: row.id,
  337. status: status
  338. };
  339. this.show = false;
  340. },
  341. //点击新增时触发
  342. beforeClose(done) {
  343. this.parentId = "";
  344. const column = this.findObject(this.option.column, "parentId");
  345. column.value = "";
  346. column.addDisabled = false;
  347. done();
  348. },
  349. //点击搜索按钮触发
  350. searchChange(params, done) {
  351. console.log(params);
  352. this.page.currentPage = 1;
  353. this.onLoad(this.page, params);
  354. done();
  355. },
  356. //搜索重置按钮触发
  357. searchReset() {
  358. this.treeDeptId = "";
  359. this.onLoad(this.page);
  360. },
  361. selectionChange() {
  362. console.log("1");
  363. },
  364. currentChange() {
  365. console.log("1");
  366. },
  367. sizeChange() {
  368. console.log("1");
  369. },
  370. refreshChange() {
  371. this.onLoad(this.page);
  372. },
  373. onLoad(page, params = { parentId: 0 }) {
  374. let queryParams = Object.assign({}, params, {
  375. size: page.pageSize,
  376. current: page.currentPage,
  377. corpsTypeId: this.treeDeptId,
  378. corpType: CDParameter.code,
  379. });
  380. customerList(queryParams).then(res => {
  381. this.dataList = res.data.data.records;
  382. this.page.total = res.data.data.total;
  383. if (this.page.total || this.page.total === 0) {
  384. this.option.height = window.innerHeight - 210;
  385. }
  386. });
  387. },
  388. searchCriteriaSwitch(type) {
  389. if (type) {
  390. this.option.height = this.option.height - 93;
  391. } else {
  392. this.option.height = this.option.height + 93;
  393. }
  394. this.$refs.crud.getTableHeight();
  395. },
  396. //树桩列点击展开触发
  397. treeLoad(tree, treeNode, resolve) {
  398. const parentId = tree.id;
  399. customerList({
  400. parentId: parentId,
  401. corpType: CDParameter.code
  402. }).then(res => {
  403. resolve(res.data.data.records);
  404. });
  405. },
  406. openReport() {
  407. this.switchDialog = !this.switchDialog;
  408. },
  409. onClose(val) {
  410. this.switchDialog = val;
  411. },
  412. goBack() {
  413. this.detailData = this.$options.data().detailData;
  414. this.show = true;
  415. this.onLoad(this.page, this.search);
  416. }
  417. }
  418. };
  419. </script>
  420. <style scoped>
  421. .page-crad ::v-deep .basic-container__card {
  422. height: 94.8vh;
  423. }
  424. </style>