index.vue 5.6 KB

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