facilitymodel.vue 6.1 KB

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