UserManagementList.vue 4.23 KB
<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>