123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170 |
- <template>
- <div class="client-account-set">
- <Button
- class="account-add-btn"
- type="success"
- icon="recode-white icon"
- shape="circle"
- @click="toAdd"
- >添加账号</Button
- >
- <Table
- ref="TableList"
- :columns="columns"
- :data="users"
- :row-class-name="getRowClassName"
- disabled-hover
- border
- ></Table>
- <div class="part-page">
- <Page
- :current="current"
- :total="total"
- :page-size="size"
- show-total
- show-elevator
- @on-change="toPage"
- ></Page>
- </div>
- <!-- modify-client-user -->
- <modify-client-user
- :instance="curUser"
- @modified="getList"
- ref="ModifyClientUser"
- ></modify-client-user>
- </div>
- </template>
- <script>
- import { clientUserPageList, deleteClientUser, updateClientUser } from "@/api";
- import ModifyClientUser from "./components/ModifyClientUser";
- import { SYSTEM_ROLE_TYPE } from "@/constants/enumerate";
- export default {
- name: "client-account-set",
- components: { ModifyClientUser },
- data() {
- return {
- workId: this.$route.params.workId,
- current: 1,
- size: this.GLOBAL.pageSize,
- total: 0,
- users: [],
- curUser: {},
- columns: [
- {
- type: "index",
- title: "序号",
- width: 100,
- align: "center",
- indexMethod: row => {
- return (this.current - 1) * this.size + row._index + 1;
- }
- },
- {
- title: "账号",
- key: "loginName"
- },
- {
- title: "密码",
- key: "password"
- },
- {
- title: "操作",
- key: "action",
- width: 240,
- align: "center",
- className: "table-action",
- render: (h, param) => {
- let actions = [
- {
- icon: param.row.enabled ? "enable icon" : "disable icon",
- attrs: {
- title: param.row.enabled ? "禁用" : "启用"
- },
- action: () => {
- this.toAble(param.row);
- }
- },
- {
- icon: "md-create",
- classes: [param.row.enabled ? "" : "btn-disabled"],
- attrs: {
- title: "编辑"
- },
- action: () => {
- this.toEdit(param.row);
- }
- }
- ];
- return h("div", this.$tableIconAction(h, actions));
- }
- }
- ]
- };
- },
- mounted() {
- this.getList();
- },
- methods: {
- async getList() {
- const datas = {
- workId: this.workId,
- page: this.current - 1,
- size: this.size
- };
- const data = await clientUserPageList(datas);
- this.users = data.data.map(item => {
- item.roleName = SYSTEM_ROLE_TYPE[item.role];
- return item;
- });
- this.total = data.totalCount;
- },
- toPage(page) {
- this.current = page;
- this.getList();
- },
- getRowClassName(row) {
- return row.enabled ? "" : "row-disabled";
- },
- toAdd() {
- this.curUser = {
- role: "COLLECTOR",
- roleName: "采集员",
- workId: this.workId
- };
- this.$refs.ModifyClientUser.open();
- },
- toEdit(row) {
- if (!row.enabled) return;
- this.curUser = row;
- this.$refs.ModifyClientUser.open();
- },
- async toAble(row) {
- await updateClientUser({
- id: row.id,
- loginName: row.loginName,
- enabled: !row.enabled
- });
- this.users[row._index].enabled = !row.enabled;
- },
- toDelete(row) {
- this.$Modal.confirm({
- title: "删除警告",
- content: "确定要删除当前账号吗?",
- onOk: () => {
- this.toDel(row.id);
- }
- });
- },
- async toDel(id) {
- await deleteClientUser(id);
- this.$Message.success("删除成功!");
- this.deletePageLastItem();
- }
- }
- };
- </script>
|