tenant.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  1. <template>
  2. <basic-container>
  3. <avue-crud :option="option"
  4. :table-loading="loading"
  5. :data="data"
  6. ref="crud"
  7. v-model="form"
  8. :page="page"
  9. :permission="permissionList"
  10. @row-del="rowDel"
  11. @row-update="rowUpdate"
  12. @row-save="rowSave"
  13. @search-change="searchChange"
  14. @search-reset="searchReset"
  15. @selection-change="selectionChange"
  16. @current-change="currentChange"
  17. @size-change="sizeChange"
  18. @on-load="onLoad">
  19. <template slot="menuLeft">
  20. <el-button type="danger"
  21. size="small"
  22. icon="el-icon-delete"
  23. v-if="permission.tenant_delete"
  24. plain
  25. @click="handleDelete">删 除
  26. </el-button>
  27. </template>
  28. </avue-crud>
  29. </basic-container>
  30. </template>
  31. <script>
  32. import {getList, remove, update, add} from "@/api/system/tenant";
  33. import {mapGetters} from "vuex";
  34. export default {
  35. data() {
  36. return {
  37. form: {},
  38. selectionList: [],
  39. query: {},
  40. loading: true,
  41. page: {
  42. pageSize: 10,
  43. currentPage: 1,
  44. total: 0
  45. },
  46. option: {
  47. height:'auto',
  48. calcHeight:'350',
  49. tip: false,
  50. border: true,
  51. index: true,
  52. selection: true,
  53. viewBtn: true,
  54. dialogWidth: 300,
  55. dialogHeight: 400,
  56. column: [
  57. {
  58. label: "租户ID",
  59. prop: "tenantId",
  60. search: true,
  61. addDisplay: false,
  62. editDisplay: false,
  63. span: 24,
  64. rules: [{
  65. required: true,
  66. message: "请输入租户ID",
  67. trigger: "blur"
  68. }]
  69. },
  70. {
  71. label: "租户名称",
  72. prop: "tenantName",
  73. search: true,
  74. span: 24,
  75. rules: [{
  76. required: true,
  77. message: "请输入参数名称",
  78. trigger: "blur"
  79. }]
  80. },
  81. {
  82. label: "联系人",
  83. prop: "linkman",
  84. search: true,
  85. span: 24,
  86. rules: [{
  87. required: true,
  88. message: "请输入联系人",
  89. trigger: "blur"
  90. }]
  91. },
  92. {
  93. label: "联系电话",
  94. prop: "contactNumber",
  95. span: 24,
  96. },
  97. {
  98. label: "联系地址",
  99. prop: "address",
  100. span: 24,
  101. minRows: 6,
  102. type: "textarea",
  103. }
  104. ]
  105. },
  106. data: []
  107. };
  108. },
  109. computed: {
  110. ...mapGetters(["permission"]),
  111. permissionList() {
  112. return {
  113. addBtn: this.vaildData(this.permission.tenant_add, false),
  114. viewBtn: this.vaildData(this.permission.tenant_view, false),
  115. delBtn: this.vaildData(this.permission.tenant_delete, false),
  116. editBtn: this.vaildData(this.permission.tenant_edit, false)
  117. };
  118. },
  119. ids() {
  120. let ids = [];
  121. this.selectionList.forEach(ele => {
  122. ids.push(ele.id);
  123. });
  124. return ids.join(",");
  125. }
  126. },
  127. methods: {
  128. rowSave(row, loading, done) {
  129. add(row).then(() => {
  130. loading();
  131. this.onLoad(this.page);
  132. this.$message({
  133. type: "success",
  134. message: "操作成功!"
  135. });
  136. }, error => {
  137. done();
  138. console.log(error);
  139. });
  140. },
  141. rowUpdate(row, index, loading, done) {
  142. update(row).then(() => {
  143. loading();
  144. this.onLoad(this.page);
  145. this.$message({
  146. type: "success",
  147. message: "操作成功!"
  148. });
  149. }, error => {
  150. done();
  151. console.log(error);
  152. });
  153. },
  154. rowDel(row) {
  155. this.$confirm("确定将选择数据删除?", {
  156. confirmButtonText: "确定",
  157. cancelButtonText: "取消",
  158. type: "warning"
  159. })
  160. .then(() => {
  161. return remove(row.id);
  162. })
  163. .then(() => {
  164. this.onLoad(this.page);
  165. this.$message({
  166. type: "success",
  167. message: "操作成功!"
  168. });
  169. });
  170. },
  171. searchReset() {
  172. this.query = {};
  173. this.onLoad(this.page);
  174. },
  175. searchChange(params) {
  176. this.query = params;
  177. this.onLoad(this.page, params);
  178. },
  179. selectionChange(list) {
  180. this.selectionList = list;
  181. },
  182. handleDelete() {
  183. if (this.selectionList.length === 0) {
  184. this.$message.warning("请选择至少一条数据");
  185. return;
  186. }
  187. this.$confirm("确定将选择数据删除?", {
  188. confirmButtonText: "确定",
  189. cancelButtonText: "取消",
  190. type: "warning"
  191. })
  192. .then(() => {
  193. return remove(this.ids);
  194. })
  195. .then(() => {
  196. this.onLoad(this.page);
  197. this.$message({
  198. type: "success",
  199. message: "操作成功!"
  200. });
  201. this.$refs.crud.toggleSelection();
  202. });
  203. },
  204. currentChange(currentPage){
  205. this.page.currentPage = currentPage;
  206. },
  207. sizeChange(pageSize){
  208. this.page.pageSize = pageSize;
  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. });
  218. }
  219. }
  220. };
  221. </script>
  222. <style>
  223. </style>