Browse Source

feat(user): 创建用户管理页面

- 添加用户管理页面的基本结构和样式
- 实现查询表单和数据表格的功能
- 添加新增和删除按钮
- 优化页面布局和样式
master
lizw-2015 6 months ago
parent
commit
9a644cf6d9
  1. 126
      src/views/user/users.vue

126
src/views/user/users.vue

@ -1,12 +1,128 @@
<script setup lang="ts">
import { reactive } from "vue";
import { ElButton } from "element-plus";
import { Delete, Plus, Search } from "@element-plus/icons-vue";
import DataForm from "@/components/data-form/DataForm.vue";
import type { FormField } from "@/components/data-form/DataFormTypes.ts";
import { AgGridVue } from "ag-grid-vue3";
import type { GridOptions } from "ag-grid-enterprise";
import type { GridApi, GridReadyEvent } from "ag-grid-community";
import { localeText as localeTextCn } from "@/components/yvTable/yv-aggrid-cn.locale";
// Props
interface ComponentProps {
}
// props
const props = withDefaults(defineProps<ComponentProps>(), {});
// State
interface ComponentState {
queryData: any;
grid1Data: Array<any>;
}
// state
const state = reactive<ComponentState>({
queryData: {},
grid1Data: [],
});
// Data
interface ComponentData {
formFields?: Array<FormField>;
gridSetting: Partial<GridOptions>;
api?: GridApi;
}
//
const data: ComponentData = {
formFields: [
{
dataPath: 'loginName', label: '用户登录名', input: 'Input',
inputProps: {
placeholder: '用户登录名',
clearable: true,
}
},
{
dataPath: 'isEnable', label: '是否启用', input: 'SelectV2',
inputProps: {
placeholder: "是否启用",
clearable: true,
options: [
{ value: "0", label: "禁用" },
{ value: "1", label: "启用" },
],
}
},
],
gridSetting: {
localeText: localeTextCn,
// suppressNoRowsOverlay: true,
// suppressLoadingOverlay: true,
//
rowSelection: "single",
columnDefs: [
{ field: 'id', headerName: 'id', editable: false, hide: true },
{ field: 'loginName', headerName: '登录名', editable: false },
{ field: 'password', headerName: '密码', editable: false, hide: true },
{ field: 'userName', headerName: '用户名', editable: false },
{ field: 'isEnable', headerName: '是否启用', editable: false },
{ field: 'createAt', headerName: '创建时间', editable: false },
{ field: 'createBy', headerName: '创建人', editable: false },
{ field: 'updateAt', headerName: '最后更新时间', editable: false },
{ field: 'updateBy', headerName: '更新人', editable: false },
],
pagination: true,
paginationPageSize: 50,
// suppressPaginationPanel
onGridReady(event: GridReadyEvent) {
data.api = event.api
},
},
};
</script>
<template> <template>
<div class="dashboard"> <div class="dashboard flex-column-container">
users <div class="tools flex-item-fixed">
<ElButton :icon="Search">查询</ElButton>
<ElButton :icon="Plus">新增</ElButton>
<ElButton :icon="Delete" type="danger" :plain="true">删除</ElButton>
</div>
<DataForm
class="query-form flex-item-fixed"
style="width: 500px;"
:data="state.queryData"
:formFields="data.formFields"
:columnCount="2"
layout="bothFixed"
labelWidth="85px"
inputWidth="200px"
/>
<AgGridVue
ref="gridRef"
:class="['ag-theme-alpine', 'yv-table', 'hi-light-selected-row','allow-vertical-line', 'flex-item-fill']"
v-bind="{...data.gridSetting}"
:modelValue="state.grid1Data"
>
</AgGridVue>
</div> </div>
</template> </template>
<script setup>
</script> <style scoped>
<style lang="less">
.dashboard { .dashboard {
height: 100%;
}
.tools {
margin-bottom: 8px;
}
.query-form {
height: unset;
} }
</style> </style>

Loading…
Cancel
Save