Vben
authored
|
1
|
<template>
|
Vben
authored
|
2
|
<PageWrapper dense contentFullHeight fixedHeight contentClass="flex">
|
sanmu
authored
|
3
4
|
<!-- <DeptTree class="w-1/4 xl:w-1/5" @select="handleSelect" /> -->
<BasicTable @register="registerTable" :searchInfo="searchInfo">
|
Vben
authored
|
5
|
<template #toolbar>
|
Vben
authored
|
6
|
<a-button type="primary" @click="handleCreate">新增账号</a-button>
|
Vben
authored
|
7
|
</template>
|
|
8
9
10
11
|
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'action'">
<TableAction
:actions="[
|
sanmu
authored
|
12
13
14
15
16
|
// {
// icon: 'clarity:info-standard-line',
// tooltip: '查看用户详情',
// onClick: handleView.bind(null, record),
// },
|
|
17
|
{
|
sanmu
authored
|
18
19
|
label: '编辑',
// tooltip: '编辑用户资料',
|
|
20
21
|
onClick: handleEdit.bind(null, record),
},
|
sanmu
authored
|
22
23
24
25
26
27
28
29
30
31
32
33
|
{
label: '重置密码',
// tooltip: '编辑用户资料',
popConfirm: {
title: '是否确认重置密码',
placement: 'left',
confirm: handleResetPassword.bind(null, record),
},
},
{
// icon: 'ant-design:delete-outlined',
color: 'error',
|
sanmu
authored
|
34
|
label: record.status === 10 ? '离职' : '启用',
|
sanmu
authored
|
35
|
popConfirm: {
|
sanmu
authored
|
36
37
38
39
|
title:
record.status === 10
? '是否确认离职该用户,离职用户无法通过忘记密码进行手机验证码修改密码。请管理员重置其账号密码并修改。'
: '是否确认启用',
|
sanmu
authored
|
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
placement: 'left',
confirm: handleForbid.bind(null, record),
},
},
{
// icon: 'ant-design:delete-outlined',
color: 'error',
label: '删除',
popConfirm: {
title: '是否确认删除',
placement: 'left',
confirm: handleDelete.bind(null, record),
},
},
|
|
54
55
56
|
]"
/>
</template>
|
Vben
authored
|
57
58
|
</template>
</BasicTable>
|
Vben
authored
|
59
|
<AccountModal @register="registerModal" @success="handleSuccess" />
|
Vben
authored
|
60
|
</PageWrapper>
|
Vben
authored
|
61
62
|
</template>
<script lang="ts">
|
|
63
|
import { defineComponent, reactive } from 'vue';
|
Vben
authored
|
64
65
|
import { BasicTable, useTable, TableAction } from '/@/components/Table';
|
sanmu
authored
|
66
67
68
69
70
71
72
|
import {
getUserList,
userAdd,
userEdit,
userOpt,
userResetPassword,
} from '/@/api/project/account';
|
Vben
authored
|
73
74
|
import { PageWrapper } from '/@/components/Page';
import DeptTree from './DeptTree.vue';
|
Vben
authored
|
75
76
77
78
79
|
import { useModal } from '/@/components/Modal';
import AccountModal from './AccountModal.vue';
import { columns, searchFormSchema } from './account.data';
|
|
80
|
import { useGo } from '/@/hooks/web/usePage';
|
Vben
authored
|
81
82
83
|
export default defineComponent({
name: 'AccountManagement',
|
Vben
authored
|
84
|
components: { BasicTable, PageWrapper, DeptTree, AccountModal, TableAction },
|
Vben
authored
|
85
|
setup() {
|
|
86
|
const go = useGo();
|
Vben
authored
|
87
|
const [registerModal, { openModal }] = useModal();
|
sanmu
authored
|
88
|
const searchInfo = reactive({});
|
sanmu
authored
|
89
|
const [registerTable, { reload }] = useTable({
|
Vben
authored
|
90
|
title: '账号列表',
|
sanmu
authored
|
91
|
api: getUserList,
|
|
92
|
rowKey: 'id',
|
Vben
authored
|
93
94
95
96
|
columns,
formConfig: {
labelWidth: 120,
schemas: searchFormSchema,
|
|
97
|
autoSubmitOnEnter: true,
|
Vben
authored
|
98
99
100
|
},
useSearchForm: true,
showTableSetting: true,
|
sanmu
authored
|
101
102
103
|
tableSetting: {
setting: false,
},
|
Vben
authored
|
104
|
bordered: true,
|
|
105
106
107
108
|
handleSearchInfoFn(info) {
console.log('handleSearchInfoFn', info);
return info;
},
|
Vben
authored
|
109
|
actionColumn: {
|
sanmu
authored
|
110
|
width: 280,
|
Vben
authored
|
111
112
|
title: '操作',
dataIndex: 'action',
|
|
113
|
// slots: { customRender: 'action' },
|
Vben
authored
|
114
115
116
|
},
});
|
Vben
authored
|
117
|
function handleCreate() {
|
Vben
authored
|
118
119
120
121
122
|
openModal(true, {
isUpdate: false,
});
}
|
sanmu
authored
|
123
|
function handleEdit(record) {
|
Vben
authored
|
124
|
console.log(record);
|
Vben
authored
|
125
126
127
128
129
130
|
openModal(true, {
record,
isUpdate: true,
});
}
|
sanmu
authored
|
131
132
133
|
async function handleDelete(record) {
await userOpt({ ids: [record.id], optType: 20 });
reload();
|
Vben
authored
|
134
135
|
}
|
sanmu
authored
|
136
|
async function handleSuccess({ isUpdate, values }) {
|
|
137
|
if (isUpdate) {
|
sanmu
authored
|
138
|
await userEdit({ ...values });
|
|
139
|
} else {
|
sanmu
authored
|
140
|
await userAdd({ ...values });
|
|
141
|
}
|
sanmu
authored
|
142
|
reload();
|
Vben
authored
|
143
144
|
}
|
sanmu
authored
|
145
146
147
148
149
150
151
152
153
154
|
async function handleForbid(record) {
await userOpt({ ids: [record.id], optType: record.status === 10 ? 30 : 10 });
reload();
}
async function handleResetPassword(record) {
await userResetPassword({ userId: record.id });
// reload();
}
|
Vben
authored
|
155
|
function handleSelect(deptId = '') {
|
|
156
157
|
searchInfo.deptId = deptId;
reload();
|
Vben
authored
|
158
159
|
}
|
sanmu
authored
|
160
|
function handleView(record) {
|
|
161
162
163
|
go('/system/account_detail/' + record.id);
}
|
Vben
authored
|
164
165
166
|
return {
registerTable,
registerModal,
|
Vben
authored
|
167
|
handleCreate,
|
Vben
authored
|
168
169
|
handleEdit,
handleDelete,
|
Vben
authored
|
170
|
handleSuccess,
|
Vben
authored
|
171
|
handleSelect,
|
|
172
|
handleView,
|
sanmu
authored
|
173
174
|
handleForbid,
handleResetPassword,
|
|
175
|
searchInfo,
|
Vben
authored
|
176
177
178
179
|
};
},
});
</script>
|