mallshoplabel.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  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.mallshoplabel_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/ldt/mallshoplabel";
  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: "商场店铺标签表id",
  62. prop: "id",
  63. rules: [{
  64. required: true,
  65. message: "请输入商场店铺标签表id",
  66. trigger: "blur"
  67. }]
  68. },
  69. {
  70. label: "标签名称",
  71. prop: "name",
  72. rules: [{
  73. required: true,
  74. message: "请输入标签名称",
  75. trigger: "blur"
  76. }]
  77. },
  78. {
  79. label: "标签说明",
  80. prop: "statement",
  81. rules: [{
  82. required: true,
  83. message: "请输入标签说明",
  84. trigger: "blur"
  85. }]
  86. },
  87. {
  88. label: "所属商场id",
  89. prop: "mallId",
  90. rules: [{
  91. required: true,
  92. message: "请输入所属商场id",
  93. trigger: "blur"
  94. }]
  95. },
  96. ]
  97. },
  98. data: []
  99. };
  100. },
  101. computed: {
  102. ...mapGetters(["permission"]),
  103. permissionList() {
  104. return {
  105. addBtn: this.vaildData(this.permission.mallshoplabel_add, false),
  106. viewBtn: this.vaildData(this.permission.mallshoplabel_view, false),
  107. delBtn: this.vaildData(this.permission.mallshoplabel_delete, false),
  108. editBtn: this.vaildData(this.permission.mallshoplabel_edit, false)
  109. };
  110. },
  111. ids() {
  112. let ids = [];
  113. this.selectionList.forEach(ele => {
  114. ids.push(ele.id);
  115. });
  116. return ids.join(",");
  117. }
  118. },
  119. methods: {
  120. rowSave(row, done, loading) {
  121. add(row).then(() => {
  122. this.onLoad(this.page);
  123. this.$message({
  124. type: "success",
  125. message: "操作成功!"
  126. });
  127. done();
  128. }, error => {
  129. loading();
  130. window.console.log(error);
  131. });
  132. },
  133. rowUpdate(row, index, done, loading) {
  134. update(row).then(() => {
  135. this.onLoad(this.page);
  136. this.$message({
  137. type: "success",
  138. message: "操作成功!"
  139. });
  140. done();
  141. }, error => {
  142. loading();
  143. console.log(error);
  144. });
  145. },
  146. rowDel(row) {
  147. this.$confirm("确定将选择数据删除?", {
  148. confirmButtonText: "确定",
  149. cancelButtonText: "取消",
  150. type: "warning"
  151. })
  152. .then(() => {
  153. return remove(row.id);
  154. })
  155. .then(() => {
  156. this.onLoad(this.page);
  157. this.$message({
  158. type: "success",
  159. message: "操作成功!"
  160. });
  161. });
  162. },
  163. handleDelete() {
  164. if (this.selectionList.length === 0) {
  165. this.$message.warning("请选择至少一条数据");
  166. return;
  167. }
  168. this.$confirm("确定将选择数据删除?", {
  169. confirmButtonText: "确定",
  170. cancelButtonText: "取消",
  171. type: "warning"
  172. })
  173. .then(() => {
  174. return remove(this.ids);
  175. })
  176. .then(() => {
  177. this.onLoad(this.page);
  178. this.$message({
  179. type: "success",
  180. message: "操作成功!"
  181. });
  182. this.$refs.crud.toggleSelection();
  183. });
  184. },
  185. beforeOpen(done, type) {
  186. if (["edit", "view"].includes(type)) {
  187. getDetail(this.form.id).then(res => {
  188. this.form = res.data.data;
  189. });
  190. }
  191. done();
  192. },
  193. searchReset() {
  194. this.query = {};
  195. this.onLoad(this.page);
  196. },
  197. searchChange(params, done) {
  198. this.query = params;
  199. this.page.currentPage = 1;
  200. this.onLoad(this.page, params);
  201. done();
  202. },
  203. selectionChange(list) {
  204. this.selectionList = list;
  205. },
  206. selectionClear() {
  207. this.selectionList = [];
  208. this.$refs.crud.toggleSelection();
  209. },
  210. currentChange(currentPage){
  211. this.page.currentPage = currentPage;
  212. },
  213. sizeChange(pageSize){
  214. this.page.pageSize = pageSize;
  215. },
  216. refreshChange() {
  217. this.onLoad(this.page, this.query);
  218. },
  219. onLoad(page, params = {}) {
  220. this.loading = true;
  221. getList(page.currentPage, page.pageSize, Object.assign(params, this.query)).then(res => {
  222. const data = res.data.data;
  223. this.page.total = data.total;
  224. this.data = data.records;
  225. this.loading = false;
  226. this.selectionClear();
  227. });
  228. }
  229. }
  230. };
  231. </script>
  232. <style>
  233. </style>