index.vue 11 KB

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