index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395
  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 { companyParameter } 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: companyParameter.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"
  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 =
  215. 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. window.console.log(column);
  240. this.excelBox = false;
  241. this.$message.success("导入成功!");
  242. this.refreshChange();
  243. loading = false;
  244. done();
  245. },
  246. nodeClick(data) {
  247. this.treeDeptId = data.id;
  248. this.page.currentPage = 1;
  249. this.onLoad(this.page);
  250. },
  251. //删除列表后面的删除按钮触发触发(row, index, done)
  252. rowDel(row, index, done) {
  253. this.$confirm("确定将选择数据删除?", {
  254. confirmButtonText: "确定",
  255. cancelButtonText: "取消",
  256. type: "warning"
  257. })
  258. .then(() => {
  259. return deleteDetails(row.id);
  260. })
  261. .then(() => {
  262. this.$message({
  263. type: "success",
  264. message: "操作成功!"
  265. });
  266. this.page.currentPage = 1;
  267. this.onLoad(this.page, { parentId: 0 });
  268. });
  269. },
  270. //修改时的修改按钮点击触发
  271. rowUpdate(row, index, done, loading) {
  272. typeSave(row).then(
  273. () => {
  274. this.$message({
  275. type: "success",
  276. message: "操作成功!"
  277. });
  278. // 数据回调进行刷新
  279. done(row);
  280. },
  281. error => {
  282. window.console.log(error);
  283. loading();
  284. }
  285. );
  286. },
  287. //新增修改时保存触发
  288. rowSave(row, done, loading) {
  289. typeSave(row).then(res => {
  290. console.log(res);
  291. done();
  292. });
  293. },
  294. //查询全部
  295. initData() {
  296. customerList({ corpType: companyParameter.code }).then(res => {
  297. console.log(this.form);
  298. const column = this.findObject(this.option.column, "parentId");
  299. column.dicData = res.data.data.records;
  300. });
  301. },
  302. //新增子项触发
  303. handleAdd(row) {
  304. this.parentId = row.id;
  305. const column = this.findObject(this.option.column, "parentId");
  306. column.value = row.id;
  307. column.addDisabled = true;
  308. this.$refs.crud.rowAdd();
  309. },
  310. //查看跳转页面
  311. beforeOpenPage(row, index) {
  312. this.$router.push({
  313. path: "/basicData/customerManagement/companyMaterial/detailsPageEdit",
  314. query: { id: JSON.stringify(row.id) }
  315. });
  316. },
  317. //新增跳转页面
  318. beforeOpen(row, index) {
  319. this.$router.push({
  320. path: "/basicData/customerManagement/companyMaterial/detailsPageEdit",
  321. query: { id: JSON.stringify(row.id), treeDeptId: this.treeDeptId }
  322. });
  323. },
  324. editOpen(row, index) {
  325. this.$router.push({
  326. path: "/basicData/customerManagement/companyMaterial/detailsPageEdit",
  327. query: { id: JSON.stringify(row.id) }
  328. });
  329. },
  330. //点击新增时触发
  331. beforeClose(done) {
  332. this.parentId = "";
  333. const column = this.findObject(this.option.column, "parentId");
  334. column.value = "";
  335. column.addDisabled = false;
  336. done();
  337. },
  338. //点击搜索按钮触发
  339. searchChange(params, done) {
  340. console.log(params);
  341. this.page.currentPage = 1;
  342. this.onLoad(this.page, params);
  343. done();
  344. },
  345. //搜索重置按钮触发
  346. searchReset() {
  347. this.treeDeptId = "";
  348. this.onLoad(this.page);
  349. },
  350. selectionChange() {
  351. console.log("1");
  352. },
  353. currentChange() {
  354. console.log("1");
  355. },
  356. sizeChange() {
  357. console.log("1");
  358. },
  359. refreshChange() {
  360. this.onLoad(this.page);
  361. },
  362. onLoad(page, params = { parentId: 0 }) {
  363. let queryParams = Object.assign({}, params, {
  364. size: page.pageSize,
  365. current: page.currentPage,
  366. corpsTypeId: this.treeDeptId,
  367. corpType: companyParameter.code
  368. });
  369. customerList(queryParams).then(res => {
  370. this.dataList = res.data.data.records;
  371. this.page.total = res.data.data.total;
  372. });
  373. },
  374. //树桩列点击展开触发
  375. treeLoad(tree, treeNode, resolve) {
  376. const parentId = tree.id;
  377. customerList({
  378. parentId: parentId,
  379. corpType: companyParameter.code
  380. }).then(res => {
  381. resolve(res.data.data.records);
  382. });
  383. },
  384. openReport() {
  385. this.switchDialog = !this.switchDialog;
  386. },
  387. onClose(val) {
  388. this.switchDialog = val;
  389. }
  390. }
  391. };
  392. </script>
  393. <style scoped></style>