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
27
28
29
30
31
32
33
|
popConfirm: {
title: '是否确认删除',
confirm: handleDelete.bind(null, record),
},
},
]"
/>
</template>
</BasicTable>
|
Vben
authored
|
34
|
<AccountModal @register="registerModal" @success="handleSuccess" />
|
Vben
authored
|
35
|
</PageWrapper>
|
Vben
authored
|
36
37
|
</template>
<script lang="ts">
|
|
38
|
import { defineComponent, reactive } from 'vue';
|
Vben
authored
|
39
40
41
|
import { BasicTable, useTable, TableAction } from '/@/components/Table';
import { getAccountList } from '/@/api/demo/system';
|
Vben
authored
|
42
43
|
import { PageWrapper } from '/@/components/Page';
import DeptTree from './DeptTree.vue';
|
Vben
authored
|
44
45
46
47
48
|
import { useModal } from '/@/components/Modal';
import AccountModal from './AccountModal.vue';
import { columns, searchFormSchema } from './account.data';
|
|
49
|
import { useGo } from '/@/hooks/web/usePage';
|
Vben
authored
|
50
51
52
|
export default defineComponent({
name: 'AccountManagement',
|
Vben
authored
|
53
|
components: { BasicTable, PageWrapper, DeptTree, AccountModal, TableAction },
|
Vben
authored
|
54
|
setup() {
|
|
55
|
const go = useGo();
|
Vben
authored
|
56
|
const [registerModal, { openModal }] = useModal();
|
|
57
|
const searchInfo = reactive<Recordable>({});
|
|
58
|
const [registerTable, { reload, updateTableDataRecord }] = useTable({
|
Vben
authored
|
59
60
|
title: '账号列表',
api: getAccountList,
|
|
61
|
rowKey: 'id',
|
Vben
authored
|
62
63
64
65
|
columns,
formConfig: {
labelWidth: 120,
schemas: searchFormSchema,
|
|
66
|
autoSubmitOnEnter: true,
|
Vben
authored
|
67
68
69
|
},
useSearchForm: true,
showTableSetting: true,
|
Vben
authored
|
70
|
bordered: true,
|
|
71
72
73
74
|
handleSearchInfoFn(info) {
console.log('handleSearchInfoFn', info);
return info;
},
|
Vben
authored
|
75
|
actionColumn: {
|
|
76
|
width: 120,
|
Vben
authored
|
77
78
79
80
81
82
|
title: '操作',
dataIndex: 'action',
slots: { customRender: 'action' },
},
});
|
Vben
authored
|
83
|
function handleCreate() {
|
Vben
authored
|
84
85
86
87
88
89
|
openModal(true, {
isUpdate: false,
});
}
function handleEdit(record: Recordable) {
|
Vben
authored
|
90
|
console.log(record);
|
Vben
authored
|
91
92
93
94
95
96
97
98
99
100
|
openModal(true, {
record,
isUpdate: true,
});
}
function handleDelete(record: Recordable) {
console.log(record);
}
|
|
101
102
103
104
105
106
107
108
109
|
function handleSuccess({ isUpdate, values }) {
if (isUpdate) {
// 演示不刷新表格直接更新内部数据。
// 注意:updateTableDataRecord要求表格的rowKey属性为string并且存在于每一行的record的keys中
const result = updateTableDataRecord(values.id, values);
console.log(result);
} else {
reload();
}
|
Vben
authored
|
110
111
|
}
|
Vben
authored
|
112
|
function handleSelect(deptId = '') {
|
|
113
114
|
searchInfo.deptId = deptId;
reload();
|
Vben
authored
|
115
116
|
}
|
|
117
118
119
120
|
function handleView(record: Recordable) {
go('/system/account_detail/' + record.id);
}
|
Vben
authored
|
121
122
123
|
return {
registerTable,
registerModal,
|
Vben
authored
|
124
|
handleCreate,
|
Vben
authored
|
125
126
|
handleEdit,
handleDelete,
|
Vben
authored
|
127
|
handleSuccess,
|
Vben
authored
|
128
|
handleSelect,
|
|
129
|
handleView,
|
|
130
|
searchInfo,
|
Vben
authored
|
131
132
133
134
|
};
},
});
</script>
|