index.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394
  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. >
  38. <template slot="menuLeft">
  39. <el-button
  40. type="primary"
  41. size="small"
  42. icon="el-icon-bottom"
  43. @click="excelBox = true"
  44. >导入
  45. </el-button>
  46. <el-button
  47. icon="el-icon-printer"
  48. size="small"
  49. type="primary"
  50. @click.stop="openReport()"
  51. >报 表
  52. </el-button>
  53. </template>
  54. <template slot-scope="scope" slot="menu">
  55. <el-button
  56. type="text"
  57. icon="el-icon-view"
  58. size="small"
  59. @click.stop="beforeOpenPage(scope.row, scope.index)"
  60. >查看
  61. </el-button>
  62. <el-button
  63. type="text"
  64. icon="el-icon-edit"
  65. size="small"
  66. @click.stop="editOpen(scope.row, scope.index)"
  67. >编辑
  68. </el-button>
  69. <el-button
  70. type="text"
  71. icon="el-icon-delete"
  72. size="small"
  73. @click.stop="rowDel(scope.row, scope.index)"
  74. >删除
  75. </el-button>
  76. </template>
  77. <template slot="adminProfiles" slot-scope="{ row }">
  78. <span>{{ row.adminProfilesName | adminProfileFilter }}</span>
  79. </template>
  80. </avue-crud>
  81. <report-dialog
  82. :switchDialog="switchDialog"
  83. @onClose="onClose()"
  84. ></report-dialog>
  85. <el-dialog
  86. title="导入客户"
  87. append-to-body
  88. :visible.sync="excelBox"
  89. width="555px"
  90. v-dialog-drag
  91. >
  92. <avue-form
  93. :option="excelOption"
  94. v-model="excelForm"
  95. table-loading="excelLoading"
  96. :upload-before="uploadBefore"
  97. :upload-after="uploadAfter"
  98. >
  99. <template slot="excelTemplate">
  100. <el-button type="primary" @click="derivation">
  101. 点击下载<i class="el-icon-download el-icon--right"></i>
  102. </el-button>
  103. </template>
  104. </avue-form>
  105. <p style="text-align: center;color: #DC0505">
  106. 温馨提示 第一次导入时请先下载模板
  107. </p>
  108. </el-dialog>
  109. </basic-container>
  110. </el-col>
  111. </el-row>
  112. </template>
  113. <script>
  114. import option from "./configuration/mainList.json";
  115. import {
  116. customerList,
  117. typeSave,
  118. detail,
  119. deleteDetails,
  120. getDeptLazyTree
  121. } from "@/api/basicData/customerInformation";
  122. import { getToken } from "@/util/auth";
  123. import reportDialog from "@/components/report-dialog/main";
  124. import { customerParameter } from "@/enums/management-type";
  125. import { gainUser } from "@/api/basicData/customerInquiry";
  126. export default {
  127. name: "customerInformation",
  128. data() {
  129. return {
  130. reportQuery: {},
  131. switchDialog: false,
  132. treeDeptId: "",
  133. form: {},
  134. option: option,
  135. parentId: 0,
  136. dataList: [],
  137. treeOption: {
  138. nodeKey: "id",
  139. lazy: true,
  140. treeLoad: function(node, resolve) {
  141. const parentId = node.level === 0 ? 0 : node.data.id;
  142. getDeptLazyTree({
  143. parentId: parentId,
  144. corpType: customerParameter.code
  145. }).then(res => {
  146. resolve(
  147. res.data.data.map(item => {
  148. return {
  149. ...item,
  150. leaf: !item.hasChildren
  151. };
  152. })
  153. );
  154. });
  155. },
  156. addBtn: false,
  157. menu: false,
  158. size: "small",
  159. props: {
  160. labelText: "标题",
  161. label: "title",
  162. value: "value",
  163. children: "children"
  164. }
  165. },
  166. page: {
  167. pageSize: 10,
  168. pagerCount: 5,
  169. total: 0,
  170. pageSizes: [10, 50, 100, 200, 300]
  171. },
  172. excelBox: false,
  173. excelLoading: false,
  174. excelForm: {},
  175. excelOption: {
  176. submitBtn: false,
  177. emptyBtn: false,
  178. column: [
  179. {
  180. label: "模板下载",
  181. prop: "excelTemplate",
  182. formslot: true,
  183. span: 24
  184. },
  185. {
  186. label: "模板上传",
  187. prop: "excelFile",
  188. type: "upload",
  189. drag: true,
  190. loadText: "模板上传中,请稍等",
  191. span: 24,
  192. propsHttp: {
  193. res: "data"
  194. },
  195. tip: "请上传 .xls,.xlsx 标准格式文件",
  196. action: "/api/blade-client/corpsdesc/import-desc?corpType=KH"
  197. }
  198. ]
  199. }
  200. };
  201. },
  202. components: {
  203. reportDialog
  204. },
  205. filters: {
  206. adminProfileFilter(row) {
  207. if (row) {
  208. return row.substr(0, row.length - 1);
  209. }
  210. }
  211. },
  212. created() {
  213. gainUser().then(res => {
  214. this.findObject(this.option.column, "adminProfiles").dicData = res.data.data;
  215. });
  216. },
  217. // watch:{
  218. // 'excelForm.isCovered'() {
  219. // if (this.excelForm.isCovered !== '') {
  220. // const column = this.findObject(this.excelOption.column, "excelFile");
  221. // column.action = `/api/blade-user/import-user?isCovered=${this.excelForm.isCovered}`;
  222. // }
  223. // }
  224. // },
  225. methods: {
  226. derivation() {
  227. window.open(
  228. `/api/blade-client/corpsdesc/export-template?${
  229. this.website.tokenHeader
  230. }=${getToken()}`
  231. );
  232. },
  233. uploadBefore(file, done, loading) {
  234. done();
  235. loading = true;
  236. },
  237. uploadAfter(res, done, loading, column) {
  238. window.console.log(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. });
  372. },
  373. //树桩列点击展开触发
  374. treeLoad(tree, treeNode, resolve) {
  375. const parentId = tree.id;
  376. customerList({
  377. parentId: parentId,
  378. corpType: customerParameter.code
  379. }).then(res => {
  380. resolve(res.data.data.records);
  381. });
  382. },
  383. openReport() {
  384. this.switchDialog = !this.switchDialog;
  385. },
  386. onClose(val) {
  387. this.switchDialog = val;
  388. }
  389. }
  390. };
  391. </script>
  392. <style scoped></style>