imageclassificationconfig.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  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. @search-change="searchChange"
  15. @search-reset="searchReset"
  16. @selection-change="selectionChange"
  17. @current-change="currentChange"
  18. @size-change="sizeChange"
  19. @refresh-change="refreshChange"
  20. @on-load="onLoad">
  21. <template slot="menuLeft">
  22. <el-button type="danger"
  23. size="small"
  24. icon="el-icon-delete"
  25. plain
  26. v-if="permission.imageclassificationconfig_delete"
  27. @click="handleDelete">删 除
  28. </el-button>
  29. </template>
  30. </avue-crud>
  31. </basic-container>
  32. </template>
  33. <script>
  34. import {getList, getDetail, add, update, remove} from "@/api/manager/imageclassificationconfig";
  35. import {mapGetters} from "vuex";
  36. export default {
  37. data() {
  38. return {
  39. form: {},
  40. query: {},
  41. loading: true,
  42. page: {
  43. pageSize: 10,
  44. currentPage: 1,
  45. total: 0
  46. },
  47. selectionList: [],
  48. option: {
  49. height:'auto',
  50. calcHeight: 30,
  51. tip: false,
  52. searchShow: true,
  53. searchMenuSpan: 6,
  54. border: true,
  55. index: true,
  56. viewBtn: true,
  57. selection: true,
  58. dialogClickModal: false,
  59. column: [
  60. {
  61. label: "分类名称",
  62. prop: "classfName",
  63. rules: [{
  64. required: true,
  65. message: "请输入分类名称",
  66. trigger: "blur"
  67. }]
  68. },
  69. {
  70. label: "所属项目阶段",
  71. prop: "projectStage",
  72. rules: [{
  73. required: true,
  74. message: "请输入所属项目阶段",
  75. trigger: "blur"
  76. }]
  77. },
  78. {
  79. label: "所属方",
  80. prop: "affiliatedParty",
  81. rules: [{
  82. required: true,
  83. message: "请输入所属方",
  84. trigger: "blur"
  85. }]
  86. },
  87. {
  88. label: "文件类型",
  89. prop: "fileType",
  90. rules: [{
  91. required: true,
  92. message: "请输入文件类型",
  93. trigger: "blur"
  94. }]
  95. },
  96. {
  97. label: "存储目录格式",
  98. prop: "storageDirectoryFormat",
  99. rules: [{
  100. required: true,
  101. message: "请输入存储目录格式",
  102. trigger: "blur"
  103. }]
  104. },
  105. ]
  106. },
  107. data: []
  108. };
  109. },
  110. computed: {
  111. ...mapGetters(["permission"]),
  112. permissionList() {
  113. return {
  114. addBtn: this.vaildData(this.permission.imageclassificationconfig_add, false),
  115. viewBtn: this.vaildData(this.permission.imageclassificationconfig_view, false),
  116. delBtn: this.vaildData(this.permission.imageclassificationconfig_delete, false),
  117. editBtn: this.vaildData(this.permission.imageclassificationconfig_edit, false)
  118. };
  119. },
  120. ids() {
  121. let ids = [];
  122. this.selectionList.forEach(ele => {
  123. ids.push(ele.id);
  124. });
  125. return ids.join(",");
  126. }
  127. },
  128. methods: {
  129. rowSave(row, done, loading) {
  130. add(row).then(() => {
  131. this.onLoad(this.page);
  132. this.$message({
  133. type: "success",
  134. message: "操作成功!"
  135. });
  136. done();
  137. }, error => {
  138. loading();
  139. window.console.log(error);
  140. });
  141. },
  142. rowUpdate(row, index, done, loading) {
  143. update(row).then(() => {
  144. this.onLoad(this.page);
  145. this.$message({
  146. type: "success",
  147. message: "操作成功!"
  148. });
  149. done();
  150. }, error => {
  151. loading();
  152. console.log(error);
  153. });
  154. },
  155. rowDel(row) {
  156. this.$confirm("确定将选择数据删除?", {
  157. confirmButtonText: "确定",
  158. cancelButtonText: "取消",
  159. type: "warning"
  160. })
  161. .then(() => {
  162. return remove(row.id);
  163. })
  164. .then(() => {
  165. this.onLoad(this.page);
  166. this.$message({
  167. type: "success",
  168. message: "操作成功!"
  169. });
  170. });
  171. },
  172. handleDelete() {
  173. if (this.selectionList.length === 0) {
  174. this.$message.warning("请选择至少一条数据");
  175. return;
  176. }
  177. this.$confirm("确定将选择数据删除?", {
  178. confirmButtonText: "确定",
  179. cancelButtonText: "取消",
  180. type: "warning"
  181. })
  182. .then(() => {
  183. return remove(this.ids);
  184. })
  185. .then(() => {
  186. this.onLoad(this.page);
  187. this.$message({
  188. type: "success",
  189. message: "操作成功!"
  190. });
  191. this.$refs.crud.toggleSelection();
  192. });
  193. },
  194. beforeOpen(done, type) {
  195. if (["edit", "view"].includes(type)) {
  196. getDetail(this.form.id).then(res => {
  197. this.form = res.data.data;
  198. });
  199. }
  200. done();
  201. },
  202. searchReset() {
  203. this.query = {};
  204. this.onLoad(this.page);
  205. },
  206. searchChange(params, done) {
  207. this.query = params;
  208. this.page.currentPage = 1;
  209. this.onLoad(this.page, params);
  210. done();
  211. },
  212. selectionChange(list) {
  213. this.selectionList = list;
  214. },
  215. selectionClear() {
  216. this.selectionList = [];
  217. this.$refs.crud.toggleSelection();
  218. },
  219. currentChange(currentPage){
  220. this.page.currentPage = currentPage;
  221. },
  222. sizeChange(pageSize){
  223. this.page.pageSize = pageSize;
  224. },
  225. refreshChange() {
  226. this.onLoad(this.page, this.query);
  227. },
  228. onLoad(page, params = {}) {
  229. this.loading = true;
  230. getList(page.currentPage, page.pageSize, Object.assign(params, this.query)).then(res => {
  231. const data = res.data.data;
  232. this.page.total = data.total;
  233. this.data = data.records;
  234. this.loading = false;
  235. this.selectionClear();
  236. });
  237. }
  238. }
  239. };
  240. </script>
  241. <style>
  242. </style>