index.vue 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  1. <template>
  2. <avue-crud
  3. :option="option"
  4. :data="dataList"
  5. ref="crud"
  6. v-model="form"
  7. :page.sync="page"
  8. @row-del="rowDel"
  9. @row-update="rowUpdate"
  10. :before-open="beforeOpen"
  11. :before-close="beforeClose"
  12. :table-loading="loading"
  13. @row-save="rowSave"
  14. :search.sync="search"
  15. @search-change="searchChange"
  16. @search-reset="searchReset"
  17. @selection-change="selectionChange"
  18. @current-change="currentChange"
  19. @size-change="sizeChange"
  20. @refresh-change="refreshChange"
  21. @saveColumn="saveColumn"
  22. @resetColumn="resetColumn"
  23. @on-load="onLoad"
  24. @tree-load="treeLoad"
  25. >
  26. <template slot-scope="scope" slot="menu">
  27. <el-button
  28. type="text"
  29. icon="el-icon-circle-plus-outline"
  30. size="small"
  31. @click.stop="handleAdd(scope.row, scope.index)"
  32. >新增子项
  33. </el-button>
  34. </template>
  35. </avue-crud>
  36. </template>
  37. <script>
  38. import option from "../configuration/mainList.json";
  39. import {
  40. customerList,
  41. typeSave,
  42. detail,
  43. deleteDetails
  44. } from "@/api/tirePartsMall/basicData/customerInformation/customerCategory";
  45. import {customerParameter} from "@/enums/management-type";
  46. export default {
  47. name: "customerInformation",
  48. data() {
  49. return {
  50. form: {},
  51. search: {},
  52. option: option,
  53. loading: false,
  54. parentId: 0,
  55. dataList: [],
  56. page: {
  57. pageSize: 20,
  58. currentPage: 1,
  59. total: 0,
  60. pageSizes: [10, 20, 30, 40, 50, 100, 200, 300, 400, 500]
  61. },
  62. query: {}
  63. };
  64. },
  65. props:{
  66. corpType:String
  67. },
  68. async created() {
  69. this.option = await this.getColumnData(this.getColumnName(141.2), option);
  70. this.option.height = window.innerHeight - 500;
  71. },
  72. methods: {
  73. //删除列表后面的删除按钮触发触发(row, index, done)
  74. rowDel(row, index, done) {
  75. this.$confirm("确定将选择数据删除?", {
  76. confirmButtonText: "确定",
  77. cancelButtonText: "取消",
  78. type: "warning"
  79. }).then(() => {
  80. return deleteDetails(row.id);
  81. }).then(() => {
  82. this.$message({
  83. type: "success",
  84. message: "操作成功!"
  85. });
  86. // 数据回调进行刷新
  87. done(row);
  88. });
  89. },
  90. //修改时的修改按钮点击触发
  91. rowUpdate(row, index, done, loading) {
  92. row.corpType = this.corpType?this.corpType:customerParameter.code;
  93. typeSave(row).then(
  94. () => {
  95. this.$message({
  96. type: "success",
  97. message: "操作成功!"
  98. });
  99. // 数据回调进行刷新
  100. done(row);
  101. this.onLoad(this.page);
  102. },
  103. error => {
  104. window.console.log(error);
  105. loading();
  106. }
  107. );
  108. },
  109. //新增修改时保存触发
  110. rowSave(row, done, loading) {
  111. row.corpType = this.corpType?this.corpType:customerParameter.code;
  112. typeSave(row).then(
  113. res => {
  114. this.$message({
  115. type: "success",
  116. message: "操作成功!"
  117. });
  118. done(row);
  119. this.onLoad(this.page);
  120. },
  121. error => {
  122. window.console.log(error);
  123. loading();
  124. }
  125. );
  126. },
  127. //查询全部
  128. initData() {
  129. // customerList({corpType: this.corpType?this.corpType:customerParameter.code}).then(res => {
  130. // const column = this.findObject(this.option.column, "parentId");
  131. // column.dicData = res.data.data.records;
  132. // });
  133. },
  134. //新增子项触发
  135. handleAdd(row) {
  136. // this.parentId = row.id;
  137. // const column = this.findObject(this.option.column, "parentId");
  138. // column.value = row.id;
  139. // column.addDisabled = true;
  140. this.$refs.crud.rowAdd();
  141. },
  142. //新增子项和新增触发查询所有
  143. beforeOpen(done, type) {
  144. if (["add", "edit"].includes(type)) {
  145. this.initData();
  146. }
  147. if (["edit", "view"].includes(type)) {
  148. detail(this.form.id).then(res => {
  149. this.form = res.data.data;
  150. });
  151. }
  152. done();
  153. },
  154. //点击新增时触发
  155. beforeClose(done) {
  156. // this.parentId = "";
  157. // const column = this.findObject(this.option.column, "parentId");
  158. // column.value = "";
  159. // column.addDisabled = false;
  160. done();
  161. },
  162. //点击搜索按钮触发
  163. searchChange(params, done) {
  164. this.query = params;
  165. this.page.currentPage = 1;
  166. params.parentId = 0;
  167. this.onLoad(this.page, params);
  168. done();
  169. },
  170. searchReset() {
  171. console.log("1");
  172. },
  173. selectionChange() {
  174. console.log("1");
  175. },
  176. currentChange() {
  177. console.log("1");
  178. },
  179. sizeChange() {
  180. console.log("1");
  181. },
  182. refreshChange() {
  183. console.log("1");
  184. },
  185. onLoad(page, params = {}) {
  186. console.log('sdkfkjndkfn');
  187. this.loading = true;
  188. const {createTimeA} = this.query;
  189. let values = {
  190. ...params,
  191. corpType: this.corpType?this.corpType:customerParameter.code,
  192. size: this.page.pageSize,
  193. current: this.page.currentPage
  194. };
  195. if (createTimeA) {
  196. values = {
  197. ...params,
  198. createTime: createTimeA[0] + " 00:00:00",
  199. endTime: createTimeA[1] + " 23:59:59",
  200. ...this.query,
  201. size: this.page.pageSize,
  202. current: this.page.currentPage
  203. };
  204. values.createTimeA = null;
  205. }
  206. values.parentId = 0;
  207. console.log(233324);
  208. customerList(values)
  209. .then(res => {
  210. console.log(res.data.data.records);
  211. this.dataList = res.data.data.records;
  212. this.page.total = res.data.data.total;
  213. })
  214. .finally(() => {
  215. this.loading = false;
  216. });
  217. },
  218. async saveColumn() {
  219. /**
  220. * 已定义全局方法,直接使用,saveColumnData保存列数据方法,参数传值(表格名称,当前表格的option数据)
  221. * 已定义全局方法,直接使用,getColumnName方法用来获取枚举值,参数根据自己定义的code值获取中文名
  222. * 一定要执行异步操作,要等接口成功返回,才能执行下一行代码
  223. */
  224. const inSave = await this.saveColumnData(
  225. this.getColumnName(141.2),
  226. this.option
  227. );
  228. if (inSave) {
  229. this.$nextTick(() => {
  230. this.$refs.crud.doLayout();
  231. });
  232. this.$message.success("保存成功");
  233. //关闭窗口
  234. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  235. }
  236. },
  237. async resetColumn() {
  238. this.option = option;
  239. const inSave = await this.delColumnData(this.getColumnName(141.2), option);
  240. if (inSave) {
  241. this.$nextTick(() => {
  242. this.$refs.crud.doLayout();
  243. });
  244. this.$message.success("重置成功");
  245. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  246. }
  247. },
  248. //树桩列点击展开触发
  249. treeLoad(tree, treeNode, resolve) {
  250. const parentId = tree.id;
  251. customerList({parentId: parentId}).then(res => {
  252. resolve(res.data.data.records);
  253. });
  254. }
  255. }
  256. };
  257. </script>
  258. <style scoped>
  259. .page-crad ::v-deep .basic-container__card {
  260. height: 94.8vh;
  261. }
  262. </style>