index.vue 11 KB

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