feat(sis): 新增通行权限组功能
Some checks are pending
Gitea Actions Demo / Explore-Gitea-Actions (push) Waiting to run

This commit is contained in:
2025-07-23 14:12:02 +08:00
parent 2ad20e8ccb
commit 0d6259e335
10 changed files with 650 additions and 96 deletions

View File

@@ -1,70 +1,75 @@
import type { PageQuery, BaseEntity } from '#/api/common';
import type { PageQuery, BaseEntity } from '#/api/common'
export interface PersonVO {
/**
* 主键id
*/
id: string | number;
id: string | number
/**
* 用户id
*/
userId: string | number;
userId: string | number
/**
* 用户名称
*/
userName: string;
userName: string
/**
* 联系电话
*/
phone: string;
phone: string
/**
* 性别
*/
gender: number;
gender: number
/**
* 人脸图片
*/
img: string;
img: string
/**
* 所属单位id
*/
unitId: string | number;
unitId: string | number
/**
* 所属单位名称
*/
unitName: string;
unitName: string
/**
* 入驻位置
*/
locathon: string;
locathon: string
/**
* 入驻时间
*/
time: string;
time: string
/**
* 车牌号码
*/
carNumber: string;
carNumber: string
/**
* 状态
*/
state: number|string;
state: number | string
/**
* 备注
*/
remark: string;
remark: string
/**
* 权限组id
*/
authGroupId?: string | number
}
@@ -72,67 +77,72 @@ export interface PersonForm extends BaseEntity {
/**
* 主键id
*/
id?: string | number;
id?: string | number
/**
* 用户id
*/
userId?: string | number;
userId?: string | number
/**
* 用户名称
*/
userName?: string;
userName?: string
/**
* 联系电话
*/
phone?: string;
phone?: string
/**
* 性别
*/
gender?: number;
gender?: number
/**
* 人脸图片
*/
img?: string;
img?: string
/**
* 所属单位id
*/
unitId?: string | number;
unitId?: string | number
/**
* 所属单位名称
*/
unitName?: string;
unitName?: string
/**
* 入驻位置
*/
locathon?: string;
locathon?: string
/**
* 入驻时间
*/
time?: string;
time?: string
/**
* 车牌号码
*/
carNumber?: string;
carNumber?: string
/**
* 状态
*/
state?: number;
state?: number
/**
* 备注
*/
remark?: string;
remark?: string
/**
* 权限组id
*/
authGroupId?: string | number
}
@@ -140,128 +150,128 @@ export interface PersonQuery extends PageQuery {
/**
* 用户id
*/
userId?: string | number;
userId?: string | number
/**
* 用户名称
*/
userName?: string;
userName?: string
/**
* 联系电话
*/
phone?: string;
phone?: string
/**
* 性别
*/
gender?: number;
gender?: number
/**
* 人脸图片
*/
img?: string;
img?: string
/**
* 所属单位id
*/
unitId?: string | number;
unitId?: string | number
/**
* 所属单位名称
*/
unitName?: string;
unitName?: string
/**
* 入驻位置
*/
locathon?: string;
locathon?: string
/**
* 入驻时间
*/
time?: string;
time?: string
/**
* 车牌号码
*/
carNumber?: string;
carNumber?: string
/**
* 状态
*/
state?: number;
state?: number
/**
* 日期范围参数
*/
params?: any;
params?: any
}
export interface Person extends BaseEntity{
export interface Person extends BaseEntity {
/**
* 主键id
*/
id: string | number;
id: string | number
/**
* 用户id
*/
userId: string | number;
userId: string | number
/**
* 用户名称
*/
userName: string;
userName: string
/**
* 联系电话
*/
phone: string;
phone: string
/**
* 性别
*/
gender: number;
gender: number
/**
* 人脸图片
*/
img: string;
img: string
/**
* 所属单位id
*/
unitId: string | number;
unitId: string | number
/**
* 所属单位名称
*/
unitName: string;
unitName: string
/**
* 入驻位置
*/
locathon: string;
locathon: string
/**
* 入驻时间
*/
time: string;
time: string
/**
* 车牌号码
*/
carNumber: string;
carNumber: string
/**
* 状态
*/
state: number;
state: number
/**
* 备注
*/
remark: string;
remark: string
}

View File

@@ -56,6 +56,16 @@ export interface Resident_unitVO {
*/
remark: string;
/**
* 权限组id
*/
authGroupId?: string | number;
/**
* 权限组名称
*/
authGroupName?: string;
}
export interface Resident_unitForm extends BaseEntity {

View File

@@ -0,0 +1,61 @@
import type { AuthGroupVO, AuthGroupForm, AuthGroupQuery } from './model';
import type { ID, IDS } from '#/api/common';
import type { PageResult } from '#/api/common';
import { commonExport } from '#/api/helper';
import { requestClient } from '#/api/request';
/**
* 查询授权组列表
* @param params
* @returns 授权组列表
*/
export function authGroupList(params?: AuthGroupQuery) {
return requestClient.get<PageResult<AuthGroupVO>>('/sis/authGroup/list', { params });
}
/**
* 导出授权组列表
* @param params
* @returns 授权组列表
*/
export function authGroupExport(params?: AuthGroupQuery) {
return commonExport('/sis/authGroup/export', params ?? {});
}
/**
* 查询授权组详情
* @param id id
* @returns 授权组详情
*/
export function authGroupInfo(id: ID) {
return requestClient.get<AuthGroupVO>(`/sis/authGroup/${id}`);
}
/**
* 新增授权组
* @param data
* @returns void
*/
export function authGroupAdd(data: AuthGroupForm) {
return requestClient.postWithMsg<void>('/sis/authGroup', data);
}
/**
* 更新授权组
* @param data
* @returns void
*/
export function authGroupUpdate(data: AuthGroupForm) {
return requestClient.putWithMsg<void>('/sis/authGroup', data);
}
/**
* 删除授权组
* @param id id
* @returns void
*/
export function authGroupRemove(id: ID | IDS) {
return requestClient.deleteWithMsg<void>(`/sis/authGroup/${id}`);
}

View File

@@ -0,0 +1,69 @@
import type { PageQuery, BaseEntity } from '#/api/common';
export interface AuthGroupVO {
/**
* 主键id
*/
id: string | number;
/**
* 权限名称
*/
name: string;
/**
* 面向对象(1-单位、2-个人)
*/
groupType: number;
/**
* 是否启用(0禁用1启用)
*/
isEnable: boolean;
}
export interface AuthGroupForm extends BaseEntity {
/**
* 主键id
*/
id?: string | number;
/**
* 权限名称
*/
name?: string;
/**
* 面向对象(1-单位、2-个人)
*/
groupType?: number;
/**
* 是否启用(0禁用1启用)
*/
isEnable?: boolean;
}
export interface AuthGroupQuery extends PageQuery {
/**
* 权限名称
*/
name?: string;
/**
* 面向对象(1-单位、2-个人)
*/
groupType?: number;
/**
* 是否启用(0禁用1启用)
*/
isEnable?: boolean;
/**
* 日期范围参数
*/
params?: any;
}

View File

@@ -1,8 +1,10 @@
import type { FormSchemaGetter } from '#/adapter/form';
import type { VxeGridProps } from '#/adapter/vxe-table';
import {getDictOptions} from "#/utils/dict";
import {renderDict} from "#/utils/render";
import {resident_unitList} from "#/api/property/resident/unit";
import type { FormSchemaGetter } from '#/adapter/form'
import type { VxeGridProps } from '#/adapter/vxe-table'
import { getDictOptions } from "#/utils/dict"
import { renderDict } from "#/utils/render"
import { resident_unitList } from "#/api/property/resident/unit"
import { authGroupList } from '#/api/sis/authGroup'
import type { AuthGroupVO, AuthGroupQuery } from '#/api/sis/authGroup/model'
export const querySchema: FormSchemaGetter = () => [
@@ -19,7 +21,7 @@ export const querySchema: FormSchemaGetter = () => [
debounceTime: 500,
allowClear: true,
placeholder: '请选择所属单位',
filterOption:true
filterOption: true
},
},
{
@@ -35,7 +37,7 @@ export const querySchema: FormSchemaGetter = () => [
fieldName: 'state',
label: '状态',
},
];
]
export const columns: VxeGridProps['columns'] = [
{ type: 'checkbox', width: 60 },
@@ -66,9 +68,9 @@ export const columns: VxeGridProps['columns'] = [
{
title: '性别',
field: 'gender',
slots:{
default: ({row})=>{
return renderDict(row.gender,'sys_user_sex')
slots: {
default: ({ row }) => {
return renderDict(row.gender, 'sys_user_sex')
}
},
width: 100
@@ -101,9 +103,9 @@ export const columns: VxeGridProps['columns'] = [
{
title: '状态',
field: 'state',
slots:{
default: ({row})=>{
return renderDict(row.state,'wy_rzryzt')
slots: {
default: ({ row }) => {
return renderDict(row.state, 'wy_rzryzt')
}
},
width: 100
@@ -120,8 +122,9 @@ export const columns: VxeGridProps['columns'] = [
title: '操作',
minWidth: 180,
},
];
]
let authGroupArr: AuthGroupVO[] = []
export const modalSchema: FormSchemaGetter = () => [
{
label: '主键id',
@@ -144,7 +147,7 @@ export const modalSchema: FormSchemaGetter = () => [
fieldName: 'unitId',
component: 'Select',
formItemClass: 'col-span-2',
rules:'selectRequired',
rules: 'selectRequired',
},
// {
// label: '入驻位置',
@@ -162,7 +165,7 @@ export const modalSchema: FormSchemaGetter = () => [
format: 'YYYY-MM-DD HH:mm:ss',
valueFormat: 'YYYY-MM-DD HH:mm:ss',
},
rules:"required"
rules: "required"
},
{
label: '车牌号码',
@@ -186,7 +189,31 @@ export const modalSchema: FormSchemaGetter = () => [
componentProps: {
options: getDictOptions('wy_rzryzt'),
},
rules:'selectRequired'
rules: 'selectRequired'
},
{
label: '通行权限组',
fieldName: 'authGroupId',
component: 'ApiSelect',
componentProps: {
resultField: 'list', // 根据API返回结构调整
labelField: 'name',
valueField: 'id',
// immediate: true,
api: async () => {
if (!authGroupArr || authGroupArr.length == 0) {
const params: AuthGroupQuery = {
groupType: 2,
pageNum: 1,
pageSize: 500,
}
const res = await authGroupList(params)
authGroupArr = res.rows
}
return authGroupArr
},
},
rules: 'required',
},
{
label: '备注',
@@ -194,7 +221,7 @@ export const modalSchema: FormSchemaGetter = () => [
component: 'Textarea',
formItemClass: 'col-span-2',
},
];
]
//门禁记录
export const accessControlColumns: VxeGridProps['columns'] = [
@@ -231,7 +258,7 @@ export const accessControlColumns: VxeGridProps['columns'] = [
field: 'locathon',
},
];
]
//车辆记录
export const carColumns: VxeGridProps['columns'] = [
@@ -275,20 +302,20 @@ export const carColumns: VxeGridProps['columns'] = [
title: '备注',
field: 'remark',
},
];
]
export async function getUnitList(): Promise<{ value: number; label: string }[]> {
const queryParam = {
pageNum: 1000,
pageSize: 1,
};
const res = await resident_unitList(queryParam);
const data: { value: number; label: string }[] = [];
}
const res = await resident_unitList(queryParam)
const data: { value: number; label: string }[] = []
res.rows.forEach((r: any) => {
data.push({
value: r.id,
label: r.name,
});
});
return data;
})
})
return data
}

View File

@@ -1,8 +1,10 @@
import type {FormSchemaGetter} from '#/adapter/form';
import type {VxeGridProps} from '#/adapter/vxe-table';
import {getDictOptions} from "#/utils/dict";
import {renderDict} from "#/utils/render";
import {z} from "#/adapter/form";
import type { FormSchemaGetter } from '#/adapter/form'
import { authGroupList } from '#/api/sis/authGroup'
import type { AuthGroupVO, AuthGroupQuery } from '#/api/sis/authGroup/model'
import type { VxeGridProps } from '#/adapter/vxe-table'
import { getDictOptions } from "#/utils/dict"
import { renderDict } from "#/utils/render"
import { z } from "#/adapter/form"
export const querySchema: FormSchemaGetter = () => [
{
@@ -23,10 +25,10 @@ export const querySchema: FormSchemaGetter = () => [
fieldName: 'state',
label: '状态',
},
];
]
export const columns: VxeGridProps['columns'] = [
{type: 'checkbox', width: 60},
{ type: 'checkbox', width: 60 },
// {
// title: '序号',
// field: 'id',
@@ -40,10 +42,11 @@ export const columns: VxeGridProps['columns'] = [
{
title: '单位编号',
field: 'unitNumber',
slots:{
slots: {
default: ({ row }) => {
return row.id;
}},
return row.id
}
},
width: 100
},
{
@@ -56,7 +59,7 @@ export const columns: VxeGridProps['columns'] = [
field: 'type',
slots: {
default: ({ row }) => {
return renderDict(row.type, 'wy_qylx');
return renderDict(row.type, 'wy_qylx')
},
},
width: 100
@@ -84,7 +87,7 @@ export const columns: VxeGridProps['columns'] = [
{
title: '状态',
field: 'state',
slots: {default: 'state'},
slots: { default: 'state' },
width: 100,
},
// {
@@ -105,12 +108,13 @@ export const columns: VxeGridProps['columns'] = [
{
field: 'action',
fixed: 'right',
slots: {default: 'action'},
slots: { default: 'action' },
title: '操作',
minWidth: 180,
},
];
]
let authGroupArr: AuthGroupVO[] = []
export const modalSchema: FormSchemaGetter = () => [
{
label: 'id',
@@ -147,7 +151,7 @@ export const modalSchema: FormSchemaGetter = () => [
label: '联系电话',
fieldName: 'phone',
component: 'Input',
rules:z.union([
rules: z.union([
z.string().regex(/^1[3-9]\d{9}$/, { message: '手机号格式错误' }),
z.number().int().min(1000000000).max(19999999999, { message: '手机号格式错误' })
]).transform(val => val.toString()),
@@ -170,10 +174,34 @@ export const modalSchema: FormSchemaGetter = () => [
},
rules: 'required',
},
{
label: '通行权限组',
fieldName: 'authGroupId',
component: 'ApiSelect',
componentProps: {
resultField: 'list', // 根据API返回结构调整
labelField: 'name',
valueField: 'id',
// immediate: true,
api: async () => {
if (!authGroupArr || authGroupArr.length == 0) {
const params: AuthGroupQuery = {
groupType: 1,
pageNum: 1,
pageSize: 500,
}
const res = await authGroupList(params)
authGroupArr = res.rows
}
return authGroupArr
},
},
rules: 'required',
},
{
label: '备注',
fieldName: 'remark',
component: 'Textarea',
formItemClass: 'col-span-2'
},
];
]

View File

@@ -44,7 +44,7 @@ async function handleOpenChange(open: boolean) {
<template>
<BasicModal :footer="false" :fullscreen-button="false" title="入驻单位信息" class="w-[70%]">
<Descriptions v-if="unitDetail" size="small" :column="2" bordered :labelStyle="{width:'100px'}">
<Descriptions v-if="unitDetail" size="small" :column="2" bordered :labelStyle="{width:'110px'}">
<DescriptionsItem label="单位编号">
{{ unitDetail.id }}
</DescriptionsItem>
@@ -75,6 +75,9 @@ async function handleOpenChange(open: boolean) {
<component
:is="renderDict(unitDetail.state,'wy_state')"
/>
</DescriptionsItem>
<DescriptionsItem label="通行权限组">
{{ unitDetail.authGroupId ?? '-' }}
</DescriptionsItem>
<DescriptionsItem label="备注">
{{ unitDetail.remark ?? '-' }}

View File

@@ -0,0 +1,101 @@
<script setup lang="ts">
import { computed, ref } from 'vue';
import { useVbenModal } from '@vben/common-ui';
import { $t } from '@vben/locales';
import { cloneDeep } from '@vben/utils';
import { useVbenForm } from '#/adapter/form';
import { authGroupAdd, authGroupInfo, authGroupUpdate } from '#/api/sis/authGroup';
import { defaultFormValueGetter, useBeforeCloseDiff } from '#/utils/popup';
import { modalSchema } from './data';
const emit = defineEmits<{ reload: [] }>();
const isUpdate = ref(false);
const title = computed(() => {
return isUpdate.value ? $t('pages.common.edit') : $t('pages.common.add');
});
const [BasicForm, formApi] = useVbenForm({
commonConfig: {
// 默认占满两列
formItemClass: 'col-span-2',
// 默认label宽度 px
labelWidth: 80,
// 通用配置项 会影响到所有表单项
componentProps: {
class: 'w-full',
}
},
schema: modalSchema(),
showDefaultActions: false,
wrapperClass: 'grid-cols-2',
});
const { onBeforeClose, markInitialized, resetInitialized } = useBeforeCloseDiff(
{
initializedGetter: defaultFormValueGetter(formApi),
currentGetter: defaultFormValueGetter(formApi),
},
);
const [BasicModal, modalApi] = useVbenModal({
// 在这里更改宽度
class: 'w-[550px]',
fullscreenButton: false,
onBeforeClose,
onClosed: handleClosed,
onConfirm: handleConfirm,
onOpenChange: async (isOpen) => {
if (!isOpen) {
return null;
}
modalApi.modalLoading(true);
const { id } = modalApi.getData() as { id?: number | string };
isUpdate.value = !!id;
if (isUpdate.value && id) {
const record = await authGroupInfo(id);
await formApi.setValues(record);
}
await markInitialized();
modalApi.modalLoading(false);
},
});
async function handleConfirm() {
try {
modalApi.lock(true);
const { valid } = await formApi.validate();
if (!valid) {
return;
}
// getValues获取为一个readonly的对象 需要修改必须先深拷贝一次
const data = cloneDeep(await formApi.getValues());
await (isUpdate.value ? authGroupUpdate(data) : authGroupAdd(data));
resetInitialized();
emit('reload');
modalApi.close();
} catch (error) {
console.error(error);
} finally {
modalApi.lock(false);
}
}
async function handleClosed() {
await formApi.resetForm();
resetInitialized();
}
</script>
<template>
<BasicModal :title="title">
<BasicForm />
</BasicModal>
</template>

View File

@@ -0,0 +1,75 @@
import type { FormSchemaGetter } from '#/adapter/form'
import type { VxeGridProps } from '#/adapter/vxe-table'
export const querySchema: FormSchemaGetter = () => [
{
component: 'Input',
fieldName: 'name',
label: '权限名称',
},
{
label: '面向对象',
fieldName: 'groupType',
component: 'Select',
componentProps: {
options: [{ 'value': 1, 'label': '单位' }, { 'value': 2, 'label': '个人' }]
},
}
]
// 需要使用i18n注意这里要改成getter形式 否则切换语言不会刷新
// export const columns: () => VxeGridProps['columns'] = () => [
export const columns: VxeGridProps['columns'] = [
{ type: 'checkbox', width: 60 },
{
title: '权限名称',
field: 'name',
},
{
title: '面向对象',
field: 'groupType',
slots: { default: 'groupType' },
width: 180,
},
{
title: '是否启用',
field: 'isEnable',
slots: { default: 'isEnable' },
width: 180,
},
{
field: 'action',
fixed: 'right',
slots: { default: 'action' },
title: '操作',
width: 180,
},
]
export const modalSchema: FormSchemaGetter = () => [
{
label: '主键id',
fieldName: 'id',
component: 'Input',
dependencies: {
show: () => false,
triggerFields: [''],
},
},
{
label: '权限名称',
fieldName: 'name',
component: 'Input',
rules: 'required',
},
{
label: '面向对象',
fieldName: 'groupType',
component: 'Select',
componentProps: {
options: [{ 'value': 1, 'label': '单位' }, { 'value': 2, 'label': '个人' }]
},
rules: 'selectRequired',
},
]

View File

@@ -0,0 +1,170 @@
<script setup lang="ts">
import type { Recordable } from '@vben/types'
import { ref } from 'vue'
import { Page, useVbenModal, type VbenFormProps } from '@vben/common-ui'
import { getVxePopupContainer } from '@vben/utils'
import { Modal, Popconfirm, Space, Tag } from 'ant-design-vue'
import { TableSwitch } from "#/components/table"
import dayjs from 'dayjs'
import {
useVbenVxeGrid,
vxeCheckboxChecked,
type VxeGridProps
} from '#/adapter/vxe-table'
import {
authGroupExport,
authGroupList,
authGroupRemove,
} from '#/api/sis/authGroup'
import type { AuthGroupForm } from '#/api/sis/authGroup/model'
import { commonDownloadExcel } from '#/utils/file/download'
import authGroupModal from './authGroup-modal.vue'
import { columns, querySchema } from './data'
const formOptions: VbenFormProps = {
commonConfig: {
labelWidth: 80,
componentProps: {
allowClear: true,
},
},
schema: querySchema(),
wrapperClass: 'grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4',
// 处理区间选择器RangePicker时间格式 将一个字段映射为两个字段 搜索/导出会用到
// 不需要直接删除
// fieldMappingTime: [
// [
// 'createTime',
// ['params[beginTime]', 'params[endTime]'],
// ['YYYY-MM-DD 00:00:00', 'YYYY-MM-DD 23:59:59'],
// ],
// ],
}
const gridOptions: VxeGridProps = {
checkboxConfig: {
// 高亮
highlight: true,
// 翻页时保留选中状态
reserve: true,
// 点击行选中
// trigger: 'row',
},
// 需要使用i18n注意这里要改成getter形式 否则切换语言不会刷新
// columns: columns(),
columns,
height: 'auto',
keepSource: true,
pagerConfig: {},
proxyConfig: {
ajax: {
query: async ({ page }, formValues = {}) => {
return await authGroupList({
pageNum: page.currentPage,
pageSize: page.pageSize,
...formValues,
})
},
},
},
rowConfig: {
keyField: 'id',
},
// 表格全局唯一表示 保存列配置需要用到
id: 'sis-authGroup-index'
}
const [BasicTable, tableApi] = useVbenVxeGrid({
formOptions,
gridOptions,
})
const [AuthGroupModal, modalApi] = useVbenModal({
connectedComponent: authGroupModal,
})
function handleAdd() {
modalApi.setData({})
modalApi.open()
}
async function handleEdit(row: Required<AuthGroupForm>) {
modalApi.setData({ id: row.id })
modalApi.open()
}
async function handleDelete(row: Required<AuthGroupForm>) {
await authGroupRemove(row.id)
await tableApi.query()
}
function handleMultiDelete() {
const rows = tableApi.grid.getCheckboxRecords()
const ids = rows.map((row: Required<AuthGroupForm>) => row.id)
Modal.confirm({
title: '提示',
okType: 'danger',
content: `确认删除选中的${ids.length}条记录吗?`,
onOk: async () => {
await authGroupRemove(ids)
await tableApi.query()
},
})
}
function handleDownloadExcel() {
commonDownloadExcel(authGroupExport, '授权组数据', tableApi.formApi.form.values, {
fieldMappingTime: formOptions.fieldMappingTime,
})
}
</script>
<template>
<Page :auto-content-height="true">
<BasicTable table-title="授权组列表">
<template #toolbar-tools>
<Space>
<a-button v-access:code="['sis:authGroup:export']" @click="handleDownloadExcel">
{{ $t('pages.common.export') }}
</a-button>
<a-button :disabled="!vxeCheckboxChecked(tableApi)" danger type="primary"
v-access:code="['sis:authGroup:remove']" @click="handleMultiDelete">
{{ $t('pages.common.delete') }}
</a-button>
<a-button type="primary" v-access:code="['sis:authGroup:add']" @click="handleAdd">
{{ $t('pages.common.add') }}
</a-button>
</Space>
</template>
<template #action="{ row }">
<Space>
<ghost-button v-access:code="['sis:authGroup:edit']" @click.stop="handleEdit(row)">
{{ $t('pages.common.edit') }}
</ghost-button>
<Popconfirm :get-popup-container="getVxePopupContainer" placement="left" title="确认删除?"
@confirm="handleDelete(row)">
<ghost-button danger v-access:code="['sis:authGroup:remove']" @click.stop="">
{{ $t('pages.common.delete') }}
</ghost-button>
</Popconfirm>
</Space>
</template>
<template #isEnable="{ row }">
<TableSwitch :checkedValue=true :unCheckedValue=false :value="row.isEnable" @reload="() => tableApi.query()" />
</template>
<template #groupType="{ row }">
<Tag v-if="row.groupType === 1" color="processing">单位</Tag>
<Tag v-else color="warning">个人</Tag>
</template>
</BasicTable>
<AuthGroupModal @reload="tableApi.query()" />
</Page>
</template>