ClientAccountSet.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. <template>
  2. <div class="client-account-set ">
  3. <div class="part-box-top">
  4. <Button type="success" icon="md-cloud-upload" @click="toEdit({})"
  5. >新增</Button
  6. >
  7. </div>
  8. <div class="part-box">
  9. <Table
  10. ref="TableList"
  11. :columns="columes"
  12. :data="users"
  13. disabled-hover
  14. border
  15. ></Table>
  16. <div class="part-page">
  17. <Page
  18. :current="current"
  19. :total="total"
  20. :page-size="size"
  21. show-total
  22. show-elevator
  23. @on-change="toPage"
  24. ></Page>
  25. </div>
  26. </div>
  27. <!-- modify-client-user -->
  28. <modify-client-user
  29. :instance="curUser"
  30. @modified="getList"
  31. ref="ModifyClientUser"
  32. ></modify-client-user>
  33. </div>
  34. </template>
  35. <script>
  36. import { clientUserPageList, deleteClientUser, uploadClientUser } from "@/api";
  37. import ModifyClientUser from "./components/ModifyClientUser";
  38. export default {
  39. name: "client-account-set",
  40. components: { ModifyClientUser },
  41. data() {
  42. return {
  43. workId: this.$route.params.workId,
  44. current: 1,
  45. size: this.GLOBAL.pageSize,
  46. total: 0,
  47. users: [],
  48. curUser: {},
  49. columes: [
  50. {
  51. type: "index",
  52. title: "序号",
  53. width: 100,
  54. align: "center",
  55. indexMethod: row => {
  56. return (this.current - 1) * this.size + row._index + 1;
  57. }
  58. },
  59. {
  60. title: "账号",
  61. key: "loginName"
  62. },
  63. {
  64. title: "密码",
  65. key: "password"
  66. },
  67. {
  68. title: "操作",
  69. key: "action",
  70. width: 240,
  71. align: "center",
  72. render: (h, param) => {
  73. let actions = [
  74. {
  75. name: param.row.enabled ? "禁用" : "启用",
  76. type: param.row.enabled ? "error" : "primary",
  77. action: () => {
  78. this.toAble(param.row);
  79. }
  80. },
  81. {
  82. name: "编辑",
  83. action: () => {
  84. this.toEdit(param.row);
  85. }
  86. },
  87. {
  88. name: "删除",
  89. type: "error",
  90. action: () => {
  91. this.toDelete(param.row);
  92. }
  93. }
  94. ];
  95. return h("div", this.$tableAction(h, actions));
  96. }
  97. }
  98. ]
  99. };
  100. },
  101. mounted() {
  102. this.getList();
  103. },
  104. methods: {
  105. async getList() {
  106. const datas = {
  107. workId: this.workId,
  108. page: this.current - 1,
  109. size: this.size
  110. };
  111. const data = await clientUserPageList(datas);
  112. this.users = data;
  113. this.total = 10;
  114. },
  115. toPage(page) {
  116. this.current = page;
  117. this.getList();
  118. },
  119. toEdit(row) {
  120. this.curUser = row;
  121. this.$refs.ModifyClientUser.open();
  122. },
  123. async toAble(row) {
  124. await uploadClientUser({
  125. id: row.id,
  126. loginName: row.loginName,
  127. enabled: !row.enabled
  128. });
  129. row.enabled = !row.enabled;
  130. },
  131. toDelete(row) {
  132. this.$Modal.confirm({
  133. title: "删除警告",
  134. content: "确定要删除当前账号吗?",
  135. onOk: () => {
  136. this.toDel(row.id);
  137. }
  138. });
  139. },
  140. async toDel(id) {
  141. await deleteClientUser(id);
  142. this.$Message.success("删除成功!");
  143. this.deletePageLastItem();
  144. }
  145. }
  146. };
  147. </script>