UserManagementList.vue
4.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
<script setup lang="ts">
import { reactive, ref } from "vue";
import { VButton, VDialog, VInput, VSelect, VTable } from "@vui/vue";
const statusOptions = [
{ label: "启用", value: "active" },
{ label: "停用", value: "inactive" },
];
const filters = reactive({
keyword: "",
status: "",
});
const dialogState = reactive({
title: "",
visible: false,
});
const tableColumns = [
{ key: "name", label: "姓名" },
{ key: "status", label: "状态" },
{ key: "department", label: "部门" },
{ key: "actions", label: "操作", width: 220 },
];
const rows = ref([
{ id: 1, name: "张三", status: "启用", department: "平台研发" },
{ id: 2, name: "李四", status: "停用", department: "运营支持" },
]);
function handleFilterAction(actionId: "reset" | "search") {
if (actionId === "reset") {
filters.keyword = "";
filters.status = "";
return;
}
console.log("search-users", { ...filters });
}
function openDialog(title: string) {
dialogState.title = title;
dialogState.visible = true;
}
function handleRowAction(actionId: "edit" | "view", row: { name: string }) {
openDialog(actionId === "edit" ? `编辑 ${row.name}` : `查看 ${row.name}`);
}
</script>
<template>
<div class="user-management-page">
<header class="page-header">
<div>
<h1>用户管理</h1>
<p>用于演示 AI 主线生成页面接入真实项目后的最小闭环。</p>
</div>
<VButton @click="openDialog('新增用户')">
新增用户
</VButton>
</header>
<section class="page-card">
<h2>筛选条件</h2>
<div class="filter-row">
<VInput v-model="filters.keyword"
clearable
placeholder="请输入姓名或账号" />
<VSelect v-model="filters.status"
clearable
:options="statusOptions"
placeholder="请选择状态" />
<VButton @click="handleFilterAction('search')">
查询
</VButton>
<VButton plain @click="handleFilterAction('reset')">
重置
</VButton>
</div>
</section>
<section class="page-card">
<div class="section-header">
<h2>用户列表</h2>
<span class="section-tip">当前为演示数据,后续可接入真实接口与 store。</span>
</div>
<VTable :columns="tableColumns" :data="rows">
<template #actions="{ row }">
<div class="action-row">
<VButton plain @click="handleRowAction('view', row)">
查看
</VButton>
<VButton plain @click="handleRowAction('edit', row)">
编辑
</VButton>
</div>
</template>
</VTable>
</section>
<VDialog v-model="dialogState.visible"
:title="dialogState.title"
width="520px">
<p>这里保留为最小占位内容,后续可替换成 schema 驱动的表单或详情区域。</p>
<template #footer>
<div class="action-row">
<VButton plain @click="dialogState.visible = false">
取消
</VButton>
<VButton @click="dialogState.visible = false">
确认
</VButton>
</div>
</template>
</VDialog>
</div>
</template>
<style scoped>
.user-management-page {
display: grid;
gap: 16px;
padding: 16px;
}
.page-header {
display: flex;
gap: 16px;
align-items: center;
justify-content: space-between;
}
.page-card {
display: grid;
gap: 12px;
padding: 16px;
background: #fff;
border: 1px solid #e5e7eb;
border-radius: 12px;
}
.filter-row,
.section-header,
.action-row {
display: flex;
gap: 12px;
align-items: center;
}
.filter-row {
flex-wrap: wrap;
}
.section-header {
justify-content: space-between;
}
.section-tip {
font-size: 13px;
color: #6b7280;
}
</style>