index.vue 11 KB

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