refactor(components): 重构表单和表格组件并更新相关引用

feat(components): 新增scForm和scTable组件替代DynamicForm
feat(pages): 添加用户管理页面到auth模块
chore(deps): 调整package.json依赖项顺序并添加vue-eslint-parser
This commit is contained in:
2026-01-20 15:51:54 +08:00
parent 8c2d943dba
commit f877097398
7 changed files with 750 additions and 841 deletions
@@ -9,41 +9,28 @@
</template>
<div class="search-form">
<a-form :model="searchForm" layout="inline">
<a-form-item label="用户名">
<a-input v-model:value="searchForm.username" placeholder="请输入用户名" />
</a-form-item>
<a-form-item label="状态">
<a-select v-model:value="searchForm.status" placeholder="请选择状态" style="width: 120px">
<a-select-option value="">全部</a-select-option>
<a-select-option :value="1">正常</a-select-option>
<a-select-option :value="0">禁用</a-select-option>
</a-select>
</a-form-item>
<a-form-item>
<a-space>
<a-button type="primary" @click="handleSearch">查询</a-button>
<a-button @click="handleReset">重置</a-button>
</a-space>
</a-form-item>
</a-form>
<sc-form :form-items="formItems" :initial-values="searchForm" :show-actions="true" submit-text="查询"
reset-text="重置" @finish="handleSearch" @reset="handleReset" layout="inline" />
</div>
<a-table :columns="columns" :data-source="dataSource" :loading="loading" :pagination="pagination">
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'status'">
<a-tag :color="record.status === 1 ? 'green' : 'red'">
{{ record.status === 1 ? '正常' : '禁用' }}
</a-tag>
</template>
<template v-else-if="column.key === 'action'">
<a-space>
<a-button type="link" size="small" @click="handleEdit(record)">编辑</a-button>
<a-button type="link" size="small" danger @click="handleDelete(record)">删除</a-button>
</a-space>
</template>
<sc-table :columns="columns" :data-source="dataSource" :loading="loading" :pagination="pagination"
:show-action-column="true" :action-column="{
title: '操作',
key: 'action',
width: 150,
}">
<template #status="{ record }">
<a-tag :color="record.status === 1 ? 'green' : 'red'">
{{ record.status === 1 ? '正常' : '禁用' }}
</a-tag>
</template>
</a-table>
<template #action="{ record }">
<a-space>
<a-button type="link" size="small" @click="handleEdit(record)">编辑</a-button>
<a-button type="link" size="small" danger @click="handleDelete(record)">删除</a-button>
</a-space>
</template>
</sc-table>
</a-card>
</div>
</template>
@@ -52,45 +39,66 @@
import { ref, onMounted } from 'vue'
import { message } from 'ant-design-vue'
import { PlusOutlined } from '@ant-design/icons-vue'
import ScTable from '@/components/scTable/index.vue'
import ScForm from '@/components/scForm/index.vue'
const columns = [
{
title: 'ID',
dataIndex: 'id',
key: 'id',
width: 80
width: 80,
},
{
title: '用户名',
dataIndex: 'username',
key: 'username'
key: 'username',
},
{
title: '昵称',
dataIndex: 'nickname',
key: 'nickname'
key: 'nickname',
},
{
title: '状态',
dataIndex: 'status',
key: 'status',
width: 100
width: 100,
},
{
title: '创建时间',
dataIndex: 'createTime',
key: 'createTime'
key: 'createTime',
},
]
//
const formItems = [
{
field: 'username',
label: '用户名',
type: 'input',
placeholder: '请输入用户名',
allowClear: true,
},
{
title: '操作',
key: 'action',
width: 150
}
field: 'status',
label: '状态',
type: 'select',
placeholder: '请选择状态',
options: [
{ label: '全部', value: '' },
{ label: '正常', value: 1 },
{ label: '禁用', value: 0 },
],
allowClear: true,
style: 'width: 120px',
},
]
const searchForm = ref({
username: '',
status: ''
status: '',
})
const dataSource = ref([])
@@ -100,7 +108,7 @@ const pagination = ref({
pageSize: 10,
total: 0,
showSizeChanger: true,
showTotal: (total) => `${total}`
showTotal: (total) => `${total}`,
})
//
@@ -110,15 +118,15 @@ const mockData = [
username: 'admin',
nickname: '管理员',
status: 1,
createTime: '2024-01-01 10:00:00'
createTime: '2024-01-01 10:00:00',
},
{
id: 2,
username: 'user',
nickname: '普通用户',
status: 1,
createTime: '2024-01-02 10:00:00'
}
createTime: '2024-01-02 10:00:00',
},
]
const loadData = () => {
@@ -138,7 +146,7 @@ const handleSearch = () => {
const handleReset = () => {
searchForm.value = {
username: '',
status: ''
status: '',
}
loadData()
}
+2 -2
View File
@@ -1,12 +1,12 @@
<template>
<DynamicForm :form-items="formItems" :initial-values="initialValues" :loading="loading" @finish="handleFinish"
<scForm :form-items="formItems" :initial-values="initialValues" :loading="loading" @finish="handleFinish"
@reset="handleReset" />
</template>
<script setup>
import { ref, computed } from 'vue'
import { message } from 'ant-design-vue'
import DynamicForm from '@/components/DynamicForm.vue'
import scForm from '@/components/scForm/index.vue'
const props = defineProps({
userInfo: {
+2 -2
View File
@@ -1,12 +1,12 @@
<template>
<DynamicForm :form-items="formItems" :initial-values="initialValues" :loading="loading" submit-text="修改密码"
<scForm :form-items="formItems" :initial-values="initialValues" :loading="loading" submit-text="修改密码"
@finish="handleFinish" @reset="handleReset" />
</template>
<script setup>
import { ref } from 'vue'
import { message } from 'ant-design-vue'
import DynamicForm from '@/components/DynamicForm.vue'
import scForm from '@/components/scForm/index.vue'
const emit = defineEmits(['success'])