index.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. <template>
  2. <basic-container>
  3. <avue-crud :option="option"
  4. :data="dataList"
  5. ref="crud"
  6. v-model="form"
  7. @row-del="rowDel"
  8. @row-update="rowUpdate"
  9. :before-open="beforeOpen"
  10. :before-close="beforeClose"
  11. @row-save="rowSave"
  12. @search-change="searchChange"
  13. @search-reset="searchReset"
  14. @selection-change="selectionChange"
  15. @current-change="currentChange"
  16. @size-change="sizeChange"
  17. @refresh-change="refreshChange"
  18. @on-load="onLoad"
  19. @tree-load="treeLoad">
  20. <template slot-scope="scope" slot="menu">
  21. <el-button
  22. type="text"
  23. icon="el-icon-view"
  24. size="small"
  25. @click.stop="beforeOpenPage(scope.row,scope.index)"
  26. >查看
  27. </el-button>
  28. <el-button
  29. type="text"
  30. icon="el-icon-edit"
  31. size="small"
  32. @click.stop="editOpen(scope.row,scope.index)"
  33. >编辑
  34. </el-button>
  35. <el-button
  36. type="text"
  37. icon="el-icon-delete"
  38. size="small"
  39. @click.stop="rowDel(scope.row,scope.index)"
  40. >删除
  41. </el-button>
  42. </template>
  43. </avue-crud>
  44. </basic-container>
  45. </template>
  46. <script>
  47. import option from "./configuration/mainList.json";
  48. import {customerList, typeSave,detail,deleteDetails} from "@/api/basicData/customerInformation"
  49. export default {
  50. name: "customerInformation",
  51. data() {
  52. return {
  53. form: {},
  54. option: option,
  55. parentId:0,
  56. dataList: []
  57. }
  58. },
  59. created() {
  60. console.log('wangbadan')
  61. customerList({parentId:0}).then(res => {
  62. console.log(res.data.data.records)
  63. this.dataList = res.data.data.records
  64. })
  65. },
  66. methods: {
  67. //删除列表后面的删除按钮触发触发(row, index, done)
  68. rowDel(row, index, done) {
  69. this.$confirm("确定将选择数据删除?", {
  70. confirmButtonText: "确定",
  71. cancelButtonText: "取消",
  72. type: "warning"
  73. }).then(() => {
  74. return deleteDetails(row.id);
  75. }).then(() => {
  76. this.$message({
  77. type: "success",
  78. message: "操作成功!"
  79. });
  80. // 数据回调进行刷新
  81. done(row);
  82. });
  83. },
  84. //修改时的修改按钮点击触发
  85. rowUpdate(row, index, done, loading) {
  86. typeSave(row).then(() => {
  87. this.$message({
  88. type: "success",
  89. message: "操作成功!"
  90. });
  91. // 数据回调进行刷新
  92. done(row);
  93. }, error => {
  94. window.console.log(error);
  95. loading();
  96. });
  97. },
  98. //新增修改时保存触发
  99. rowSave(row, done, loading) {
  100. typeSave(row).then(res => {
  101. console.log(res)
  102. done()
  103. })
  104. },
  105. //查询全部
  106. initData(){
  107. customerList().then(res => {
  108. console.log(this.form);
  109. const column = this.findObject(this.option.column, "parentId");
  110. column.dicData = res.data.data.records;
  111. });
  112. },
  113. //新增子项触发
  114. handleAdd(row) {
  115. this.parentId = row.id;
  116. const column = this.findObject(this.option.column, "parentId");
  117. column.value = row.id;
  118. column.addDisabled = true;
  119. this.$refs.crud.rowAdd();
  120. },
  121. //查看跳转页面
  122. beforeOpenPage(row,index) {
  123. this.$router.push({
  124. path: "/detailsPage",
  125. query: { id: JSON.stringify(row.id) },
  126. });
  127. },
  128. //新增跳转页面
  129. beforeOpen(row,index) {
  130. this.$router.push({
  131. path: "/detailsPageEdit",
  132. query: { id: JSON.stringify(row.id) },
  133. });
  134. },
  135. editOpen(row,index){
  136. this.$router.push({
  137. path: "/detailsPageEdit",
  138. query: { id: JSON.stringify(row.id) },
  139. });
  140. },
  141. //点击新增时触发
  142. beforeClose(done) {
  143. this.parentId = "";
  144. const column = this.findObject(this.option.column, "parentId");
  145. column.value = "";
  146. column.addDisabled = false;
  147. done();
  148. },
  149. //点击搜索按钮触发
  150. searchChange() {
  151. console.log('1')
  152. },
  153. searchReset() {
  154. console.log('1')
  155. },
  156. selectionChange() {
  157. console.log('1')
  158. },
  159. currentChange() {
  160. console.log('1')
  161. },
  162. sizeChange() {
  163. console.log('1')
  164. },
  165. refreshChange() {
  166. console.log('1')
  167. },
  168. onLoad() {
  169. console.log('1')
  170. },
  171. //树桩列点击展开触发
  172. treeLoad(tree, treeNode, resolve) {
  173. const parentId = tree.id;
  174. customerList({parentId:parentId}).then(res => {
  175. resolve(res.data.data.records);
  176. });
  177. },
  178. }
  179. }
  180. </script>
  181. <style scoped>
  182. </style>