index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431
  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({
  277. id:row.id,
  278. corpsTypeId:row.corpsTypeId,
  279. corpType:'CD'
  280. });
  281. })
  282. .then(() => {
  283. this.$message({
  284. type: "success",
  285. message: "操作成功!"
  286. });
  287. this.page.currentPage = 1;
  288. this.onLoad(this.page, { parentId: 0 });
  289. });
  290. },
  291. //修改时的修改按钮点击触发
  292. rowUpdate(row, index, done, loading) {
  293. typeSave(row).then(
  294. () => {
  295. this.$message({
  296. type: "success",
  297. message: "操作成功!"
  298. });
  299. // 数据回调进行刷新
  300. done(row);
  301. },
  302. error => {
  303. window.console.log(error);
  304. loading();
  305. }
  306. );
  307. },
  308. //新增修改时保存触发
  309. rowSave(row, done, loading) {
  310. typeSave(row).then(res => {
  311. console.log(res);
  312. done();
  313. });
  314. },
  315. //查询全部
  316. initData() {
  317. customerList({ corpType: CDParameter.code }).then(res => {
  318. console.log(this.form);
  319. const column = this.findObject(this.option.column, "parentId");
  320. column.dicData = res.data.data.records;
  321. });
  322. },
  323. //新增子项触发
  324. handleAdd(row) {
  325. this.parentId = row.id;
  326. const column = this.findObject(this.option.column, "parentId");
  327. column.value = row.id;
  328. column.addDisabled = true;
  329. this.$refs.crud.rowAdd();
  330. },
  331. //新增跳转页面
  332. beforeOpen() {
  333. this.show = false;
  334. this.detailData = {
  335. treeDeptId: this.treeDeptId
  336. }
  337. },
  338. editOpen(row, status) {
  339. this.detailData = {
  340. id: row.id,
  341. status: status
  342. };
  343. this.show = false;
  344. },
  345. //点击新增时触发
  346. beforeClose(done) {
  347. this.parentId = "";
  348. const column = this.findObject(this.option.column, "parentId");
  349. column.value = "";
  350. column.addDisabled = false;
  351. done();
  352. },
  353. //点击搜索按钮触发
  354. searchChange(params, done) {
  355. console.log(params);
  356. this.page.currentPage = 1;
  357. this.onLoad(this.page, params);
  358. done();
  359. },
  360. //搜索重置按钮触发
  361. searchReset() {
  362. this.treeDeptId = "";
  363. this.onLoad(this.page);
  364. },
  365. selectionChange() {
  366. console.log("1");
  367. },
  368. currentChange() {
  369. console.log("1");
  370. },
  371. sizeChange() {
  372. console.log("1");
  373. },
  374. refreshChange() {
  375. this.onLoad(this.page);
  376. },
  377. onLoad(page, params = { parentId: 0 }) {
  378. let queryParams = Object.assign({}, params, {
  379. size: page.pageSize,
  380. current: page.currentPage,
  381. corpsTypeId: this.treeDeptId,
  382. corpType: CDParameter.code,
  383. });
  384. customerList(queryParams).then(res => {
  385. this.dataList = res.data.data.records;
  386. this.page.total = res.data.data.total;
  387. if (this.page.total || this.page.total === 0) {
  388. this.option.height = window.innerHeight - 210;
  389. }
  390. });
  391. },
  392. searchCriteriaSwitch(type) {
  393. if (type) {
  394. this.option.height = this.option.height - 93;
  395. } else {
  396. this.option.height = this.option.height + 93;
  397. }
  398. this.$refs.crud.getTableHeight();
  399. },
  400. //树桩列点击展开触发
  401. treeLoad(tree, treeNode, resolve) {
  402. const parentId = tree.id;
  403. customerList({
  404. parentId: parentId,
  405. corpType: CDParameter.code
  406. }).then(res => {
  407. resolve(res.data.data.records);
  408. });
  409. },
  410. openReport() {
  411. this.switchDialog = !this.switchDialog;
  412. },
  413. onClose(val) {
  414. this.switchDialog = val;
  415. },
  416. goBack() {
  417. this.detailData = this.$options.data().detailData;
  418. this.show = true;
  419. this.onLoad(this.page, this.search);
  420. }
  421. }
  422. };
  423. </script>
  424. <style scoped>
  425. .page-crad ::v-deep .basic-container__card {
  426. height: 94.8vh;
  427. }
  428. </style>