Vben
authored
|
1
|
<template>
|
Vben
authored
|
2
3
|
<PageWrapper dense contentFullHeight fixedHeight contentClass="flex">
<DeptTree class="w-1/4 xl:w-1/5" @select="handleSelect" />
|
|
4
|
<BasicTable @register="registerTable" class="w-3/4 xl:w-4/5" :searchInfo="searchInfo">
|
Vben
authored
|
5
|
<template #toolbar>
|
Vben
authored
|
6
|
<a-button type="primary" @click="handleCreate">新增账号</a-button>
|
Vben
authored
|
7
8
9
10
11
|
</template>
<template #action="{ record }">
<TableAction
:actions="[
{
|
|
12
|
icon: 'clarity:info-standard-line',
|
|
13
|
tooltip: '查看用户详情',
|
|
14
15
16
|
onClick: handleView.bind(null, record),
},
{
|
Vben
authored
|
17
|
icon: 'clarity:note-edit-line',
|
|
18
|
tooltip: '编辑用户资料',
|
Vben
authored
|
19
20
21
|
onClick: handleEdit.bind(null, record),
},
{
|
Vben
authored
|
22
|
icon: 'ant-design:delete-outlined',
|
Vben
authored
|
23
|
color: 'error',
|
|
24
|
tooltip: '删除此账号',
|
Vben
authored
|
25
26
|
popConfirm: {
title: '是否确认删除',
|
Micah
authored
|
27
|
placement: 'left',
|
Vben
authored
|
28
29
30
31
32
33
34
|
confirm: handleDelete.bind(null, record),
},
},
]"
/>
</template>
</BasicTable>
|
Vben
authored
|
35
|
<AccountModal @register="registerModal" @success="handleSuccess" />
|
Vben
authored
|
36
|
</PageWrapper>
|
Vben
authored
|
37
38
|
</template>
<script lang="ts">
|
|
39
|
import { defineComponent, reactive } from 'vue';
|
Vben
authored
|
40
41
42
|
import { BasicTable, useTable, TableAction } from '/@/components/Table';
import { getAccountList } from '/@/api/demo/system';
|
Vben
authored
|
43
44
|
import { PageWrapper } from '/@/components/Page';
import DeptTree from './DeptTree.vue';
|
Vben
authored
|
45
46
47
48
49
|
import { useModal } from '/@/components/Modal';
import AccountModal from './AccountModal.vue';
import { columns, searchFormSchema } from './account.data';
|
|
50
|
import { useGo } from '/@/hooks/web/usePage';
|
Vben
authored
|
51
52
53
|
export default defineComponent({
name: 'AccountManagement',
|
Vben
authored
|
54
|
components: { BasicTable, PageWrapper, DeptTree, AccountModal, TableAction },
|
Vben
authored
|
55
|
setup() {
|
|
56
|
const go = useGo();
|
Vben
authored
|
57
|
const [registerModal, { openModal }] = useModal();
|
|
58
|
const searchInfo = reactive<Recordable>({});
|
|
59
|
const [registerTable, { reload, updateTableDataRecord }] = useTable({
|
Vben
authored
|
60
61
|
title: '账号列表',
api: getAccountList,
|
|
62
|
rowKey: 'id',
|
Vben
authored
|
63
64
65
66
|
columns,
formConfig: {
labelWidth: 120,
schemas: searchFormSchema,
|
|
67
|
autoSubmitOnEnter: true,
|
Vben
authored
|
68
69
70
|
},
useSearchForm: true,
showTableSetting: true,
|
Vben
authored
|
71
|
bordered: true,
|
|
72
73
74
75
|
handleSearchInfoFn(info) {
console.log('handleSearchInfoFn', info);
return info;
},
|
Vben
authored
|
76
|
actionColumn: {
|
|
77
|
width: 120,
|
Vben
authored
|
78
79
80
81
82
83
|
title: '操作',
dataIndex: 'action',
slots: { customRender: 'action' },
},
});
|
Vben
authored
|
84
|
function handleCreate() {
|
Vben
authored
|
85
86
87
88
89
90
|
openModal(true, {
isUpdate: false,
});
}
function handleEdit(record: Recordable) {
|
Vben
authored
|
91
|
console.log(record);
|
Vben
authored
|
92
93
94
95
96
97
98
99
100
101
|
openModal(true, {
record,
isUpdate: true,
});
}
function handleDelete(record: Recordable) {
console.log(record);
}
|
|
102
103
104
105
106
107
108
109
110
|
function handleSuccess({ isUpdate, values }) {
if (isUpdate) {
// 演示不刷新表格直接更新内部数据。
// 注意:updateTableDataRecord要求表格的rowKey属性为string并且存在于每一行的record的keys中
const result = updateTableDataRecord(values.id, values);
console.log(result);
} else {
reload();
}
|
Vben
authored
|
111
112
|
}
|
Vben
authored
|
113
|
function handleSelect(deptId = '') {
|
|
114
115
|
searchInfo.deptId = deptId;
reload();
|
Vben
authored
|
116
117
|
}
|
|
118
119
120
121
|
function handleView(record: Recordable) {
go('/system/account_detail/' + record.id);
}
|
Vben
authored
|
122
123
124
|
return {
registerTable,
registerModal,
|
Vben
authored
|
125
|
handleCreate,
|
Vben
authored
|
126
127
|
handleEdit,
handleDelete,
|
Vben
authored
|
128
|
handleSuccess,
|
Vben
authored
|
129
|
handleSelect,
|
|
130
|
handleView,
|
|
131
|
searchInfo,
|
Vben
authored
|
132
133
134
135
|
};
},
});
</script>
|