tenant.vue 5.5 KB

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