index.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. <template>
  2. <basic-container>
  3. <avue-crud :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. :search.sync="search"
  13. @row-save="rowSave"
  14. @saveColumn="saveColumn"
  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. @on-load="onLoad"
  22. @tree-load="treeLoad">
  23. <template slot="menuLeft" slot-scope="{size}">
  24. <el-button type="success" :size="size" @click="copyOrder" :disabled="single">复制新单</el-button>
  25. <el-button type="info" :size="size">导出报表</el-button>
  26. </template>
  27. <template slot-scope="scope" slot="menu">
  28. <el-button
  29. type="text"
  30. icon="el-icon-view"
  31. size="small"
  32. @click.stop="beforeOpenPage(scope.row,scope.index)"
  33. >查看
  34. </el-button>
  35. <el-button
  36. type="text"
  37. icon="el-icon-edit"
  38. size="small"
  39. @click.stop="editOpen(scope.row,scope.index)"
  40. >编辑
  41. </el-button>
  42. <el-button
  43. type="text"
  44. icon="el-icon-delete"
  45. size="small"
  46. @click.stop="rowDel(scope.row,scope.index)"
  47. >删除
  48. </el-button>
  49. </template>
  50. </avue-crud>
  51. </basic-container>
  52. </template>
  53. <script>
  54. import option from "./configuration/mainList.json";
  55. import {customerList, typeSave, deleteDetails} from "@/api/basicData/configuration"
  56. export default {
  57. name: "customerInformation",
  58. data() {
  59. return {
  60. form: {},
  61. option: option,
  62. parentId: 0,
  63. search:{},
  64. dataList: [],
  65. page: {
  66. pageSize: 10,
  67. pagerCount: 5,
  68. total: 0,
  69. },
  70. // 非单个禁用
  71. single: true,
  72. // 非多个禁用
  73. multiple: true,
  74. selection: [],
  75. }
  76. },
  77. created() {
  78. if (parseInt(this.option.column.length / 4) !== this.option.column.length / 4){
  79. this.option.searchMenuSpan = 6;
  80. this.option.searchMenuPosition = "center";
  81. }
  82. },
  83. methods: {
  84. //删除列表后面的删除按钮触发触发(row, index, done)
  85. rowDel(row, index, done) {
  86. this.$confirm("确定将选择数据删除?", {
  87. confirmButtonText: "确定",
  88. cancelButtonText: "取消",
  89. type: "warning"
  90. }).then(() => {
  91. return deleteDetails(row.id);
  92. }).then(() => {
  93. this.$message({
  94. type: "success",
  95. message: "操作成功!"
  96. });
  97. this.page.currentPage = 1;
  98. this.onLoad(this.page, {parentId: 0});
  99. });
  100. },
  101. //修改时的修改按钮点击触发
  102. rowUpdate(row, index, done, loading) {
  103. typeSave(row).then(() => {
  104. this.$message({
  105. type: "success",
  106. message: "操作成功!"
  107. });
  108. // 数据回调进行刷新
  109. done(row);
  110. }, error => {
  111. window.console.log(error);
  112. loading();
  113. });
  114. },
  115. //新增修改时保存触发
  116. rowSave(row, done, loading) {
  117. typeSave(row).then(res => {
  118. console.log(res)
  119. done()
  120. })
  121. },
  122. //列保存触发
  123. saveColumn(data){
  124. console.log(data.objectOption)
  125. },
  126. //查询全部
  127. initData() {
  128. customerList().then(res => {
  129. console.log(this.form);
  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. beforeOpenPage(row, index) {
  144. this.$router.push({
  145. path: "/salesOrder_detailsPageEdit",
  146. query: {id: JSON.stringify(row.id)},
  147. });
  148. },
  149. //新增跳转页面
  150. beforeOpen(row, index) {
  151. this.$router.push({
  152. path: "/salesOrder_detailsPageEdit",
  153. query: {id: JSON.stringify(row.id)},
  154. });
  155. },
  156. editOpen(row, index) {
  157. this.$router.push({
  158. path: "/salesOrder_detailsPageEdit",
  159. query: {id: JSON.stringify(row.id)},
  160. });
  161. },
  162. // 复制新单
  163. copyOrder() {
  164. const id = this.selection[0].id;
  165. this.$router.push({
  166. path: "/salesOrder_detailsPageEdit",
  167. query: {copyId: JSON.stringify(id)},
  168. });
  169. },
  170. //点击新增时触发
  171. beforeClose(done) {
  172. this.parentId = "";
  173. const column = this.findObject(this.option.column, "parentId");
  174. column.value = "";
  175. column.addDisabled = false;
  176. done();
  177. },
  178. //点击搜索按钮触发
  179. searchChange(params, done) {
  180. console.log(params)
  181. this.page.currentPage = 1;
  182. this.onLoad(this.page, params);
  183. done()
  184. },
  185. searchReset() {
  186. console.log('1')
  187. },
  188. // 选择框
  189. selectionChange(list) {
  190. this.selection = list;
  191. this.single = list.length !== 1;
  192. },
  193. currentChange() {
  194. console.log('1')
  195. },
  196. sizeChange() {
  197. console.log('1')
  198. },
  199. //列表刷新触发
  200. refreshChange() {
  201. console.log(this.form)
  202. this.page.currentPage = 1;
  203. this.onLoad(this.page,this.search);
  204. },
  205. onLoad(page, params = {parentId: 0}) {
  206. let queryParams = Object.assign({}, params, {
  207. size: page.pageSize,
  208. current: page.currentPage,
  209. billType:'XS',
  210. corpsTypeId: this.treeDeptId
  211. })
  212. customerList(queryParams).then(res => {
  213. this.dataList = res.data.data.records
  214. this.page.total = res.data.data.total
  215. })
  216. },
  217. //树桩列点击展开触发
  218. treeLoad(tree, treeNode, resolve) {
  219. const parentId = tree.id;
  220. customerList({parentId: parentId}).then(res => {
  221. resolve(res.data.data.records);
  222. });
  223. },
  224. }
  225. }
  226. </script>
  227. <style scoped>
  228. </style>