InspectionAccountSet.vue 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <template>
  2. <div class="client-account-set ">
  3. <div class="part-box">
  4. <table class="table">
  5. <tr>
  6. <th>序号</th>
  7. <th>角色</th>
  8. <th>账号</th>
  9. <th>操作</th>
  10. </tr>
  11. <tr v-for="(user, index) in users" :key="index">
  12. <td style="width: 60px;">{{ index + 1 }}</td>
  13. <td>{{ user.roleName }}</td>
  14. <td style="width: 200px;">
  15. {{ user.loginName }}
  16. </td>
  17. <td>
  18. <Button size="small" type="primary" @click="toResetPwd(user)"
  19. >重置</Button
  20. >
  21. </td>
  22. </tr>
  23. </table>
  24. </div>
  25. </div>
  26. </template>
  27. <script>
  28. import { inspectionUserPageList, resetPwd } from "@/api";
  29. const initModalForm = {
  30. id: "",
  31. roleName: "纪检",
  32. loginName: "",
  33. password: ""
  34. };
  35. export default {
  36. name: "client-account-set",
  37. data() {
  38. return {
  39. workId: this.$route.params.workId,
  40. users: [],
  41. curUser: {}
  42. };
  43. },
  44. mounted() {
  45. this.getList();
  46. },
  47. methods: {
  48. async getList() {
  49. const datas = {
  50. workId: this.workId
  51. };
  52. const data = await inspectionUserPageList(datas);
  53. this.users = data.map(item => {
  54. return {
  55. id: item.id,
  56. loginName: item.loginName,
  57. password: item.password,
  58. roleName: "纪检"
  59. };
  60. });
  61. if (!this.users.length) this.toAdd();
  62. },
  63. toAdd() {
  64. this.users.push({ ...initModalForm });
  65. },
  66. async toResetPwd(user) {
  67. let result = true;
  68. await resetPwd({ userId: user.id, password: "123456" }).catch(() => {
  69. result = false;
  70. });
  71. if (!result) return;
  72. this.$Message.success("重置密码成功!");
  73. }
  74. }
  75. };
  76. </script>