imageclassificationconfig.vue 8.1 KB

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