index.vue 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361
  1. <template>
  2. <basic-container class="page-crad" v-if="flag">
  3. <avue-crud :option="option" :data="dataList" ref="crud" v-model="form" :page.sync="page" @row-del="rowDel"
  4. @row-update="rowUpdate" :before-open="beforeOpen" :before-close="beforeClose" @row-save="rowSave"
  5. @search-change="searchChange" @search-reset="searchReset" @on-load="onLoad"
  6. @resetColumn="resetColumnTwo('crud', 'option', 'optionBack', 264)"
  7. @saveColumn="saveColumnTwo('crud', 'option', 'optionBack', 264)" @search-criteria-switch="searchCriteriaSwitch"
  8. @tree-load="treeLoad">
  9. </avue-crud>
  10. </basic-container>
  11. </template>
  12. <script>
  13. import {
  14. customerList,
  15. typeSave,
  16. detail,
  17. deleteDetails
  18. } from "@/api/tirePartsMall/basicData/warehouse";
  19. import {
  20. customerListAll
  21. } from "@/api/tirePartsMall/basicData/warehouse";
  22. export default {
  23. name: "customerInformation",
  24. data() {
  25. return {
  26. form: {},
  27. option: {},
  28. optionBack: {
  29. headerAlign: "center",
  30. align: "center",
  31. border: true,
  32. index: true,
  33. // lazy: true,
  34. stripe: true,
  35. height: "auto",
  36. tip: false,
  37. simplePage: true,
  38. searchShow: true,
  39. tree: true,
  40. searchMenuSpan: 16,
  41. searchSpan: 8,
  42. searchIcon: true,
  43. searchIndex: 2,
  44. selection: true,
  45. viewBtn: false,
  46. menuWidth: 140,
  47. column: [{
  48. label: "仓库编码",
  49. prop: "code",
  50. search: true,
  51. overHidden: true,
  52. // width: 120,
  53. rules: [
  54. {
  55. required: true,
  56. message: " ",
  57. trigger: "blur"
  58. }
  59. ]
  60. }, {
  61. label: "仓库名称",
  62. prop: "cname",
  63. search: true,
  64. overHidden: true,
  65. // width: 120,
  66. rules: [
  67. {
  68. required: true,
  69. message: " ",
  70. trigger: "blur"
  71. }
  72. ]
  73. }, {
  74. label: "联系人",
  75. prop: "contacts",
  76. search: true,
  77. overHidden: true,
  78. // width: 120,
  79. rules: [
  80. {
  81. required: true,
  82. message: " ",
  83. trigger: "blur"
  84. }
  85. ]
  86. }, {
  87. label: "联系电话",
  88. prop: "tel",
  89. search: true,
  90. overHidden: true,
  91. // width: 120,
  92. rules: [
  93. {
  94. required: true,
  95. message: " ",
  96. trigger: "blur"
  97. }
  98. ]
  99. }, {
  100. label: "是否计费",
  101. prop: "chargeOrNot",
  102. search: true,
  103. overHidden: true,
  104. // width: 120,
  105. type: "select",
  106. dicData: [{
  107. label: "是",
  108. value: 0
  109. }, {
  110. label: "否",
  111. value: 1
  112. }],
  113. rules: [
  114. {
  115. required: true,
  116. message: " ",
  117. trigger: "blur"
  118. }
  119. ]
  120. }, {
  121. label: "库容",
  122. prop: "storageCapacity",
  123. search: true,
  124. overHidden: true,
  125. // width: 120,
  126. rules: [
  127. {
  128. required: true,
  129. message: " ",
  130. trigger: "blur"
  131. }
  132. ]
  133. }, {
  134. label: "所属公司",
  135. prop: "salesCompanyId",
  136. search: true,
  137. overHidden: true,
  138. // width: 120,
  139. type: 'select',
  140. props: {
  141. label: 'cname',
  142. value: 'id'
  143. },
  144. dicUrl: '/api/blade-sales-part/storageDesc/listAll',
  145. rules: [
  146. {
  147. required: true,
  148. message: " ",
  149. trigger: "blur"
  150. }
  151. ]
  152. }, {
  153. label: "共享公司",
  154. prop: "sharedCompany",
  155. search: true,
  156. overHidden: true,
  157. // width: 120,
  158. type: 'select',
  159. props: {
  160. label: 'cname',
  161. value: 'id'
  162. },
  163. dicUrl: '/api/blade-sales-part/storageDesc/listAll',
  164. rules: [
  165. {
  166. required: true,
  167. message: " ",
  168. trigger: "blur"
  169. }
  170. ]
  171. }, {
  172. label: "备注",
  173. prop: "remarks",
  174. type: "textarea",
  175. minRows: 3,
  176. span: 24,
  177. overHidden: true,
  178. // width: 200
  179. }]
  180. },
  181. parentId: 0,
  182. dataList: [],
  183. page: {
  184. pageSize: 20,
  185. currentPage: 1,
  186. total: 0,
  187. pageSizes: [10, 20, 30, 40, 50, 100, 200, 300, 400, 500]
  188. },
  189. treeDeptId: "",
  190. corpTypeListCk: [],
  191. flag:false,
  192. };
  193. },
  194. async created() {
  195. this.option = await this.getColumnData(this.getColumnName(264), this.optionBack);
  196. this.key++
  197. let i = 0;
  198. this.option.column.forEach(item => {
  199. if (item.search) i++
  200. })
  201. if (i % 3 !== 0) {
  202. const num = 3 - Number(i % 3)
  203. this.option.searchMenuSpan = num * 8;
  204. this.option.searchMenuPosition = "right";
  205. }
  206. setTimeout(()=>{
  207. this.flag = true
  208. },200)
  209. },
  210. methods: {
  211. //删除列表后面的删除按钮触发触发(row, index, done)
  212. rowDel(row, index, done) {
  213. this.$confirm("确定将选择数据删除?", {
  214. confirmButtonText: "确定",
  215. cancelButtonText: "取消",
  216. type: "warning"
  217. })
  218. .then(() => {
  219. return deleteDetails(row.id);
  220. })
  221. .then(() => {
  222. this.$message({
  223. type: "success",
  224. message: "操作成功!"
  225. });
  226. // 数据回调进行刷新
  227. done(row);
  228. });
  229. },
  230. //修改时的修改按钮点击触发
  231. rowUpdate(row, index, done, loading) {
  232. typeSave(row).then(
  233. () => {
  234. this.$message({
  235. type: "success",
  236. message: "操作成功!"
  237. });
  238. // 数据回调进行刷新
  239. done(row);
  240. },
  241. error => {
  242. window.console.log(error);
  243. loading();
  244. }
  245. );
  246. },
  247. //新增修改时保存触发
  248. rowSave(row, done, loading) {
  249. console.log(row);
  250. typeSave(row).then(
  251. res => {
  252. console.log(res);
  253. this.page.currentPage = 1;
  254. this.onLoad(this.page, {});
  255. done();
  256. },
  257. error => {
  258. window.console.log(error);
  259. loading();
  260. }
  261. );
  262. },
  263. //新增子项触发
  264. handleAdd(row) {
  265. this.parentId = row.id;
  266. // const column = this.findObject(this.option.column, "parentId");
  267. // column.value = row.id;
  268. // column.addDisabled = true;
  269. this.$refs.crud.rowAdd();
  270. },
  271. //新增子项和新增触发查询所有
  272. beforeOpen(done, type) {
  273. if (["add", "edit"].includes(type)) {
  274. this.option.column.forEach(e => {
  275. if (e.prop == "storageTypeId") {
  276. this.$set(this.option.column, 3, { ...e, value: this.treeDeptId });
  277. }
  278. });
  279. }
  280. if (["edit", "view"].includes(type)) {
  281. detail(this.form.id).then(res => {
  282. this.form = res.data.data;
  283. });
  284. }
  285. done();
  286. },
  287. //点击新增时触发
  288. beforeClose(done) {
  289. this.parentId = "";
  290. // const column = this.findObject(this.option.column, "parentId");
  291. // column.value = "";
  292. // column.addDisabled = false;
  293. done();
  294. },
  295. //点击搜索按钮触发
  296. searchChange(params, done) {
  297. this.page.currentPage = 1;
  298. this.onLoad(this.page, params);
  299. done();
  300. },
  301. searchReset() {
  302. this.query = {};
  303. this.treeDeptId = "";
  304. this.onLoad(this.page);
  305. },
  306. onLoad(page, params = { parentId: 0 }) {
  307. let queryParams = Object.assign({}, params, {
  308. size: page.pageSize,
  309. current: page.currentPage,
  310. parentId: 0,
  311. storageTypeId: this.treeDeptId
  312. });
  313. customerList(queryParams).then(res => {
  314. this.dataList = res.data.data.records;
  315. this.page.total = res.data.data.total;
  316. });
  317. },
  318. searchCriteriaSwitch(type) {
  319. this.$refs.crud.doLayout();
  320. this.$refs.crud.getTableHeight();
  321. },
  322. //树桩列点击展开触发
  323. treeLoad(tree, treeNode, resolve) {
  324. const parentId = tree.id;
  325. customerList({ parentId: parentId }).then(res => {
  326. resolve(res.data.data.records);
  327. });
  328. },
  329. //自定义列保存
  330. async saveColumnTwo(ref, option, optionBack, code) {
  331. /**
  332. * 已定义全局方法,直接使用,saveColumnData保存列数据方法,参数传值(表格名称,当前表格的option数据)
  333. * 已定义全局方法,直接使用,getColumnName方法用来获取枚举值,参数根据自己定义的code值获取中文名
  334. * 一定要执行异步操作,要等接口成功返回,才能执行下一行代码
  335. */
  336. const inSave = await this.saveColumnData(this.getColumnName(code), this[option]);
  337. if (inSave) {
  338. this.$message.success("保存成功");
  339. //关闭窗口
  340. this.$refs[ref].$refs.dialogColumn.columnBox = false;
  341. }
  342. },
  343. //自定义列重置
  344. async resetColumnTwo(ref, option, optionBack, code) {
  345. this[option] = this[optionBack];
  346. const inSave = await this.delColumnData(this.getColumnName(code), this[optionBack]);
  347. if (inSave) {
  348. this.$message.success("重置成功");
  349. this.$refs[ref].$refs.dialogColumn.columnBox = false;
  350. }
  351. }
  352. }
  353. };
  354. </script>
  355. <style scoped>
  356. .page-crad ::v-deep .basic-container__card {
  357. height: 94.8vh;
  358. }
  359. </style>