companyserviceperson.vue 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
  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. },
  130. data: [],
  131. };
  132. },
  133. computed: {
  134. // ...mapGetters(["userInfo", "permission"]),
  135. permissionList() {
  136. return {
  137. // addBtn: this.vaildData(this.permission.docCategory_add, false),
  138. // viewBtn: this.vaildData(this.permission.docCategory_view, false),
  139. // delBtn: this.vaildData(this.permission.docCategory_delete, false),
  140. // editBtn: this.vaildData(this.permission.docCategory_edit, false),
  141. };
  142. },
  143. ids() {
  144. let ids = [];
  145. this.selectionList.forEach((ele) => {
  146. ids.push(ele.id);
  147. });
  148. return ids.join(",");
  149. },
  150. },
  151. mounted() { },
  152. created() {
  153. },
  154. methods: {
  155. rowSave(row, done, loading) {
  156. add(row).then(
  157. () => {
  158. this.onLoad(this.page);
  159. this.$message({
  160. type: "success",
  161. message: "操作成功!",
  162. });
  163. done();
  164. },
  165. (error) => {
  166. window.console.log(error);
  167. loading();
  168. }
  169. );
  170. },
  171. rowUpdate(row, index, done, loading) {
  172. update(row).then(
  173. () => {
  174. this.onLoad(this.page);
  175. this.$message({
  176. type: "success",
  177. message: "操作成功!",
  178. });
  179. done();
  180. },
  181. (error) => {
  182. window.console.log(error);
  183. loading();
  184. }
  185. );
  186. },
  187. rowDel(row) {
  188. this.$confirm("确定将选择数据删除?", {
  189. confirmButtonText: "确定",
  190. cancelButtonText: "取消",
  191. type: "warning",
  192. })
  193. .then(() => {
  194. return remove(row.id);
  195. })
  196. .then(() => {
  197. this.onLoad(this.page);
  198. this.$message({
  199. type: "success",
  200. message: "操作成功!",
  201. });
  202. });
  203. },
  204. searchReset() {
  205. this.query = {};
  206. this.onLoad(this.page);
  207. },
  208. searchChange(params, done) {
  209. this.query = params;
  210. this.page.currentPage = 1;
  211. this.onLoad(this.page, params);
  212. done();
  213. },
  214. selectionChange(list) {
  215. this.selectionList = list;
  216. },
  217. selectChange(item) {
  218. console.log(item)
  219. },
  220. selectionClear() {
  221. this.selectionList = [];
  222. this.$refs.crud.toggleSelection();
  223. },
  224. handleDelete() {
  225. if (this.selectionList.length === 0) {
  226. this.$message.warning("请选择至少一条数据");
  227. return;
  228. }
  229. this.$confirm("确定将选择数据删除?", {
  230. confirmButtonText: "确定",
  231. cancelButtonText: "取消",
  232. type: "warning",
  233. })
  234. .then(() => {
  235. return remove(this.ids);
  236. })
  237. .then(() => {
  238. this.onLoad(this.page);
  239. this.$message({
  240. type: "success",
  241. message: "操作成功!",
  242. });
  243. this.$refs.crud.toggleSelection();
  244. });
  245. },
  246. beforeOpen(done, type) {
  247. if (["edit", "view"].includes(type)) {
  248. getDetail(this.form.id).then((res) => {
  249. this.form = res.data.data;
  250. });
  251. }
  252. done();
  253. },
  254. currentChange(currentPage) {
  255. this.page.currentPage = currentPage;
  256. },
  257. sizeChange(pageSize) {
  258. this.page.pageSize = pageSize;
  259. },
  260. refreshChange() {
  261. this.onLoad(this.page, this.query);
  262. },
  263. onLoad(page, params = {}) {
  264. this.loading = true;
  265. getPage(
  266. page.currentPage,
  267. page.pageSize,
  268. Object.assign(params, this.query)
  269. ).then((res) => {
  270. const data = res.data.data;
  271. this.page.total = data.total;
  272. this.data = data.records;
  273. this.loading = false;
  274. this.selectionClear();
  275. });
  276. },
  277. },
  278. };
  279. </script>