companyadminperson.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320
  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" @row-save="rowSave" @search-change="searchChange"
  17. @search-reset="searchReset" @selection-change="selectionChange" @current-change="currentChange"
  18. @size-change="sizeChange" @refresh-change="refreshChange" @on-load="onLoad"
  19. @before-open="beforeOpen" @select-change="selectChange">
  20. <template slot="state" slot-scope="{ row }">
  21. <el-button type="text" @click="openConfig(row)"> 正常 </el-button>
  22. </template>
  23. <template slot-scope="{ row, index }" slot="menu">
  24. </template>
  25. <template slot="state" slot-scope="{ row }">
  26. <el-button type="text" @click="openConfig(row)"> 正常 </el-button>
  27. </template>
  28. </avue-crud>
  29. </basic-container>
  30. </el-col>
  31. </el-row>
  32. </div>
  33. </template>
  34. <script>
  35. import { getPage, getDetail, add, update, remove } from "@/api/baseinfo/serviceperson.js";
  36. export default {
  37. components: {
  38. },
  39. data() {
  40. return {
  41. id: "",
  42. editForm: {},
  43. editDialog: false,
  44. form: {},
  45. selectionList: [],
  46. query: {},
  47. loading: true,
  48. page: {
  49. pageSize: 10,
  50. currentPage: 1,
  51. total: 0,
  52. },
  53. option: {
  54. labelWidth: 140,
  55. viewLabelWidth: 140,
  56. searchLabelWidth: 140,
  57. height: "auto",
  58. calcHeight: 80,
  59. align: "center",
  60. headerAlign: "center",
  61. tip: false,
  62. simplePage: true,
  63. searchShow: true,
  64. searchMenuSpan: 6,
  65. border: true,
  66. index: true,
  67. selection: false,
  68. viewBtn: false,
  69. viewTitle: "运维人员信息",
  70. editBtn: true,
  71. delBtn: true,
  72. menuWidth: 220,
  73. dialogType: "drawer",
  74. dialogClickModal: false,
  75. addBtnText: "新增用户",
  76. columnBtn: false,
  77. column: [
  78. {
  79. label: "登录帐号",
  80. prop: "account",
  81. span: 24,
  82. tip: "密码默认为帐号+@8282",
  83. tipPlacement: 'right-end',
  84. editDisabled: true,
  85. rules: [
  86. {
  87. required: true,
  88. message: "请录入登录帐号",
  89. trigger: "click",
  90. },
  91. ],
  92. },
  93. {
  94. label: "用户名称",
  95. prop: "realName",
  96. search: true,
  97. span: 24,
  98. rules: [
  99. {
  100. required: true,
  101. message: "请录入用户名称",
  102. trigger: "click",
  103. },
  104. ],
  105. },
  106. {
  107. label: "联系电话",
  108. prop: "phone",
  109. search: true,
  110. span: 24,
  111. editDisplay: true,
  112. addDisplay: true,
  113. rules: [
  114. {
  115. required: true,
  116. message: "请录入联系电话",
  117. trigger: "click",
  118. },
  119. ],
  120. },
  121. {
  122. label: "邮箱",
  123. prop: "email",
  124. span: 24,
  125. editDisplay: true,
  126. addDisplay: true,
  127. },
  128. {
  129. label: "所属运维单位",
  130. prop: "deptName",
  131. span: 12,
  132. addDisplay: false,
  133. editDisabled: true,
  134. rules: [
  135. {
  136. required: true,
  137. message: "请录入单位名称",
  138. trigger: "click",
  139. },
  140. ],
  141. }
  142. ,
  143. {
  144. label: "所属运维单位",
  145. prop: "deptId",
  146. span: 12,
  147. hide: true,
  148. viewDisplay: false,
  149. editDisplay: false,
  150. type: "select",
  151. addDisabled: false,
  152. props: {
  153. label: "deptName",
  154. value: "id"
  155. },
  156. dicUrl: "/api/galaxy-business/baseinfo/org/list",
  157. rules: [
  158. {
  159. required: true,
  160. message: "请选择运维单位",
  161. trigger: "click",
  162. },
  163. ],
  164. },
  165. ],
  166. },
  167. data: [],
  168. };
  169. },
  170. computed: {
  171. // ...mapGetters(["userInfo", "permission"]),
  172. permissionList() {
  173. return {
  174. // addBtn: this.vaildData(this.permission.docCategory_add, false),
  175. // viewBtn: this.vaildData(this.permission.docCategory_view, false),
  176. // delBtn: this.vaildData(this.permission.docCategory_delete, false),
  177. // editBtn: this.vaildData(this.permission.docCategory_edit, false),
  178. };
  179. },
  180. ids() {
  181. let ids = [];
  182. this.selectionList.forEach((ele) => {
  183. ids.push(ele.id);
  184. });
  185. return ids.join(",");
  186. },
  187. },
  188. mounted() { },
  189. created() {
  190. },
  191. methods: {
  192. rowSave(row, done, loading) {
  193. add(row).then(
  194. () => {
  195. this.onLoad(this.page);
  196. this.$message({
  197. type: "success",
  198. message: "操作成功!",
  199. });
  200. done();
  201. },
  202. (error) => {
  203. window.console.log(error);
  204. loading();
  205. }
  206. );
  207. },
  208. rowUpdate(row, index, done, loading) {
  209. update(row).then(
  210. () => {
  211. this.onLoad(this.page);
  212. this.$message({
  213. type: "success",
  214. message: "操作成功!",
  215. });
  216. done();
  217. },
  218. (error) => {
  219. window.console.log(error);
  220. loading();
  221. }
  222. );
  223. },
  224. rowDel(row) {
  225. this.$confirm("确定将选择数据删除?", {
  226. confirmButtonText: "确定",
  227. cancelButtonText: "取消",
  228. type: "warning",
  229. })
  230. .then(() => {
  231. return remove(row.id);
  232. })
  233. .then(() => {
  234. this.onLoad(this.page);
  235. this.$message({
  236. type: "success",
  237. message: "操作成功!",
  238. });
  239. });
  240. },
  241. searchReset() {
  242. this.query = {};
  243. this.onLoad(this.page);
  244. },
  245. searchChange(params, done) {
  246. this.query = params;
  247. this.page.currentPage = 1;
  248. this.onLoad(this.page, params);
  249. done();
  250. },
  251. selectionChange(list) {
  252. this.selectionList = list;
  253. },
  254. selectChange(item) {
  255. console.log(item)
  256. },
  257. selectionClear() {
  258. this.selectionList = [];
  259. this.$refs.crud.toggleSelection();
  260. },
  261. handleDelete() {
  262. if (this.selectionList.length === 0) {
  263. this.$message.warning("请选择至少一条数据");
  264. return;
  265. }
  266. this.$confirm("确定将选择数据删除?", {
  267. confirmButtonText: "确定",
  268. cancelButtonText: "取消",
  269. type: "warning",
  270. })
  271. .then(() => {
  272. return remove(this.ids);
  273. })
  274. .then(() => {
  275. this.onLoad(this.page);
  276. this.$message({
  277. type: "success",
  278. message: "操作成功!",
  279. });
  280. this.$refs.crud.toggleSelection();
  281. });
  282. },
  283. beforeOpen(done, type) {
  284. if (["edit", "view"].includes(type)) {
  285. getDetail(this.form.id).then((res) => {
  286. this.form = res.data.data;
  287. });
  288. }
  289. done();
  290. },
  291. currentChange(currentPage) {
  292. this.page.currentPage = currentPage;
  293. },
  294. sizeChange(pageSize) {
  295. this.page.pageSize = pageSize;
  296. },
  297. refreshChange() {
  298. this.onLoad(this.page, this.query);
  299. },
  300. onLoad(page, params = {}) {
  301. this.loading = true;
  302. getPage(
  303. page.currentPage,
  304. page.pageSize,
  305. Object.assign(params, this.query)
  306. ).then((res) => {
  307. const data = res.data.data;
  308. this.page.total = data.total;
  309. this.data = data.records;
  310. this.loading = false;
  311. this.selectionClear();
  312. });
  313. },
  314. },
  315. };
  316. </script>