orgadminlist.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  1. <!--
  2. * @Title:
  3. * @Description: 盟市管理员用户管理
  4. * @Author: swp
  5. * @Date: 2022-08-24 10:49:21
  6. * @LastEditors:
  7. * @LastEditTime: 2022-08-24 10:49:21
  8. -->
  9. <template>
  10. <div>
  11. <el-row>
  12. <el-col :span="24">
  13. <basic-container>
  14. <avue-crud :option="option" :table-loading="loading" :data="data" :page.sync="page"
  15. :before-open="beforeOpen" ref="crud" v-model="form" :permission="permissionList" @row-del="rowDel"
  16. @row-update="rowUpdate" @search-change="searchChange" @search-reset="searchReset"
  17. @selection-change="selectionChange" @current-change="currentChange" @size-change="sizeChange"
  18. @refresh-change="refreshChange" @on-load="onLoad" @before-open="beforeOpen"
  19. @select-change="selectChange">
  20. </avue-crud>
  21. </basic-container>
  22. </el-col>
  23. </el-row>
  24. </div>
  25. </template>
  26. <script>
  27. import { getPage, getDetail, update, remove } from "@/api/baseinfo/serviceperson.js";
  28. import { mapGetters } from "vuex";
  29. export default {
  30. components: {
  31. },
  32. data() {
  33. return {
  34. id: "",
  35. editForm: {},
  36. editDialog: false,
  37. form: {},
  38. selectionList: [],
  39. query: {},
  40. loading: true,
  41. page: {
  42. pageSize: 10,
  43. currentPage: 1,
  44. total: 0,
  45. },
  46. option: {
  47. labelWidth: 120,
  48. viewLabelWidth: 100,
  49. searchlabelWidth: 140,
  50. height: "auto",
  51. calcHeight: 80,
  52. align: "center",
  53. headerAlign: "center",
  54. tip: false,
  55. simplePage: true,
  56. searchShow: true,
  57. searchMenuSpan: 6,
  58. border: true,
  59. index: true,
  60. selection: false,
  61. viewBtn: false,
  62. viewTitle: "管理员列表",
  63. menuWidth: 220,
  64. dialogType: "drawer",
  65. dialogClickModal: false,
  66. columnBtn: false,
  67. column: [
  68. {
  69. label: "登录帐号",
  70. prop: "account",
  71. span: 24,
  72. editDisabled: true,
  73. rules: [
  74. {
  75. required: true,
  76. message: "请录入登录帐号",
  77. trigger: "click",
  78. },
  79. ],
  80. },
  81. {
  82. label: "用户名称",
  83. prop: "realName",
  84. span: 24,
  85. rules: [
  86. {
  87. required: true,
  88. message: "请录入用户名称",
  89. trigger: "click",
  90. },
  91. ],
  92. },
  93. {
  94. label: "联系电话",
  95. prop: "phone",
  96. span: 24,
  97. rules: [
  98. {
  99. required: true,
  100. message: "请录入联系电话",
  101. trigger: "click",
  102. },
  103. ],
  104. },
  105. ],
  106. },
  107. data: [],
  108. };
  109. },
  110. computed: {
  111. ...mapGetters(["userInfo", "permission"]),
  112. permissionList() {
  113. return {
  114. addBtn: false,
  115. viewBtn: false,
  116. delBtn: true,
  117. editBtn: true,
  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. mounted() { },
  129. props: {
  130. visible: {
  131. type: [Boolean],
  132. default: false,
  133. },
  134. orgId: {
  135. type: [String],
  136. required: true
  137. },
  138. },
  139. name: 'orgAdminListView',
  140. created() {
  141. this.init();
  142. },
  143. methods: {
  144. init() {
  145. },
  146. rowUpdate(row, index, done, loading) {
  147. update(row).then(
  148. () => {
  149. this.onLoad(this.page);
  150. this.$message({
  151. type: "success",
  152. message: "操作成功!",
  153. });
  154. done();
  155. },
  156. (error) => {
  157. window.console.log(error);
  158. loading();
  159. }
  160. );
  161. },
  162. rowDel(row) {
  163. this.$confirm("确定将选择数据删除?", {
  164. confirmButtonText: "确定",
  165. cancelButtonText: "取消",
  166. type: "warning",
  167. })
  168. .then(() => {
  169. return remove(row.id);
  170. })
  171. .then(() => {
  172. this.onLoad(this.page);
  173. this.$message({
  174. type: "success",
  175. message: "操作成功!",
  176. });
  177. });
  178. },
  179. searchReset() {
  180. this.query = {};
  181. this.onLoad(this.page);
  182. },
  183. searchChange(params, done) {
  184. this.query = params;
  185. this.page.currentPage = 1;
  186. this.onLoad(this.page, params);
  187. done();
  188. },
  189. selectionChange(list) {
  190. this.selectionList = list;
  191. },
  192. selectChange(item) {
  193. console.log(item);
  194. },
  195. selectionClear() {
  196. this.selectionList = [];
  197. this.$refs.crud.toggleSelection();
  198. },
  199. handleDelete() {
  200. if (this.selectionList.length === 0) {
  201. this.$message.warning("请选择至少一条数据");
  202. return;
  203. }
  204. this.$confirm("确定将选择数据删除?", {
  205. confirmButtonText: "确定",
  206. cancelButtonText: "取消",
  207. type: "warning",
  208. })
  209. .then(() => {
  210. return remove(this.ids);
  211. })
  212. .then(() => {
  213. this.onLoad(this.page);
  214. this.$message({
  215. type: "success",
  216. message: "操作成功!",
  217. });
  218. this.$refs.crud.toggleSelection();
  219. });
  220. },
  221. beforeOpen(done, type) {
  222. if (["edit", "view"].includes(type)) {
  223. getDetail(this.form.id).then((res) => {
  224. this.form = res.data.data;
  225. });
  226. }
  227. done();
  228. },
  229. currentChange(currentPage) {
  230. this.page.currentPage = currentPage;
  231. },
  232. sizeChange(pageSize) {
  233. this.page.pageSize = pageSize;
  234. },
  235. refreshChange() {
  236. this.onLoad(this.page, this.query);
  237. },
  238. onLoad(page, params = {}) {
  239. this.loading = true;
  240. params['deptId'] = this.orgId;
  241. getPage(
  242. page.currentPage,
  243. page.pageSize,
  244. Object.assign(params, this.query)
  245. ).then((res) => {
  246. const data = res.data.data;
  247. this.page.total = data.total;
  248. this.data = data.records;
  249. this.loading = false;
  250. this.selectionClear();
  251. });
  252. },
  253. },
  254. };
  255. </script>