testcollect.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. <template>
  2. <basic-container>
  3. <avue-crud :option="option"
  4. :table-loading="loading"
  5. :data="data"
  6. :page.sync="page"
  7. :permission="permissionList"
  8. :before-open="beforeOpen"
  9. v-model="form"
  10. ref="crud"
  11. @row-update="rowUpdate"
  12. @row-save="rowSave"
  13. @row-del="rowDel"
  14. @selection-change="selectionChange"
  15. @current-change="currentChange"
  16. @size-change="sizeChange"
  17. @refresh-change="refreshChange"
  18. @on-load="onLoad">
  19. <template slot-scope="{type,size,row}" slot="menu">
  20. <el-button icon="el-icon-setting" :size="size" :type="type" @click="configurationClick">配置划分</el-button>
  21. <el-button icon="el-icon-close" :size="size" :type="type" @click="associatedClick">关联清表</el-button>
  22. </template>
  23. </avue-crud>
  24. </basic-container>
  25. </template>
  26. <script>
  27. import {getList, getDetail, add, update, remove} from "@/api/tentative/testcollect";
  28. import {mapGetters} from "vuex";
  29. export default {
  30. data() {
  31. return {
  32. form: {},
  33. query: {},
  34. loading: true,
  35. page: {
  36. pageSize: 20,
  37. currentPage: 1,
  38. total: 0
  39. },
  40. search:{},
  41. selectionList: [],
  42. option: {
  43. menuWidth:330,
  44. height:'auto',
  45. calcHeight: 30,
  46. tip: false,
  47. searchShow: false,
  48. searchMenuSpan: 0,
  49. border: true,
  50. index: true,
  51. viewBtn: true,
  52. selection: false,
  53. dialogClickModal: false,
  54. labelWidth:150,
  55. column: [
  56. {
  57. label: "分类名称",
  58. prop: "className",
  59. rules: [{
  60. required: true,
  61. message: "请输入分类名称",
  62. trigger: "blur"
  63. }]
  64. }
  65. ]
  66. },
  67. data: [],
  68. };
  69. },
  70. computed: {
  71. ...mapGetters(["permission"]),
  72. permissionList() {
  73. return {
  74. viewBtn: false,
  75. //addBtn: this.vaildData(this.permission.imageclassificationconfig_add, false),
  76. //viewBtn: this.vaildData(this.permission.imageclassificationconfig_view, false),
  77. //delBtn: this.vaildData(this.permission.imageclassificationconfig_delete, false),
  78. // editBtn: this.vaildData(this.permission.imageclassificationconfig_edit, false)
  79. };
  80. },
  81. ids() {
  82. let ids = [];
  83. this.selectionList.forEach(ele => {
  84. ids.push(ele.id);
  85. });
  86. return ids.join(",");
  87. }
  88. },
  89. methods: {
  90. rowSave(row, done, loading) {
  91. add(row).then(() => {
  92. this.onLoad(this.page);
  93. this.$message({
  94. type: "success",
  95. message: "操作成功!"
  96. });
  97. done();
  98. }, error => {
  99. loading();
  100. window.console.log(error);
  101. });
  102. },
  103. rowUpdate(row, index, done, loading) {
  104. update(row).then(() => {
  105. this.onLoad(this.page);
  106. this.$message({
  107. type: "success",
  108. message: "操作成功!"
  109. });
  110. done();
  111. }, error => {
  112. loading();
  113. console.log(error);
  114. });
  115. },
  116. rowDel(row) {
  117. this.$confirm("确定将选择数据删除?", {
  118. confirmButtonText: "确定",
  119. cancelButtonText: "取消",
  120. type: "warning"
  121. })
  122. .then(() => {
  123. return remove(row.id);
  124. })
  125. .then(() => {
  126. this.onLoad(this.page);
  127. this.$message({
  128. type: "success",
  129. message: "操作成功!"
  130. });
  131. });
  132. },
  133. beforeOpen(done, type) {
  134. if (["edit", "view"].includes(type)) {
  135. getDetail(this.form.id).then(res => {
  136. this.form = res.data.data;
  137. });
  138. }
  139. done();
  140. },
  141. searchReset() {
  142. this.query = {};
  143. this.onLoad(this.page);
  144. },
  145. searchChange(params, done) {
  146. this.query = params;
  147. this.page.currentPage = 1;
  148. this.onLoad(this.page, params);
  149. done();
  150. },
  151. selectionChange(list) {
  152. this.selectionList = list;
  153. },
  154. selectionClear() {
  155. this.selectionList = [];
  156. this.$refs.crud.toggleSelection();
  157. },
  158. currentChange(currentPage){
  159. this.page.currentPage = currentPage;
  160. },
  161. sizeChange(pageSize){
  162. this.page.pageSize = pageSize;
  163. },
  164. refreshChange() {
  165. this.onLoad(this.page, this.query);
  166. },
  167. onLoad(page, params = {}) {
  168. this.loading = true;
  169. getList(page.currentPage, page.pageSize, Object.assign(params, this.query)).then(res => {
  170. const data = res.data.data;
  171. this.page.total = data.total;
  172. this.data = data.records;
  173. this.loading = false;
  174. this.selectionClear();
  175. });
  176. },
  177. configurationClick(){
  178. this.$message({
  179. type: "warning",
  180. message: "暂无相关接口"
  181. });
  182. },
  183. associatedClick() {
  184. this.$message({
  185. type: "warning",
  186. message: "暂无相关接口"
  187. });
  188. }
  189. }
  190. };
  191. </script>
  192. <style>
  193. </style>