index.vue 12 KB

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