index.vue 5.1 KB

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