admin-vben5/apps/web-antd/src/views/property/resident/person/data.ts
zcxlsm 5494d206d4
Some checks are pending
Gitea Actions Demo / Explore-Gitea-Actions (push) Waiting to run
feat(property): 人员管理增加人员标签功能
2025-08-08 15:09:54 +08:00

425 lines
8.6 KiB
TypeScript

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 = () => [
{
component: 'ApiSelect',
fieldName: 'unitId',
label: '所属单位',
componentProps: {
api: getUnitList,
resultField: 'data',
labelField: 'label',
valueField: 'value',
immediate: true,
debounceTime: 500,
allowClear: true,
placeholder: '请选择所属单位',
filterOption: true,
},
},
{
component: 'Input',
fieldName: 'userName',
label: '员工名称',
},
{
component: 'Select',
componentProps: {
options: getDictOptions('wy_rzryzt'),
},
fieldName: 'state',
label: '状态',
},
]
export const columns: VxeGridProps['columns'] = [
{ type: 'checkbox', width: 60 },
// {
// title: '员工编号',
// field: 'id',
// width: 100,
// },
{
title: '员工名称',
field: 'userName',
width: 100,
},
{
title: '联系电话',
field: 'phone',
width: 120,
},
{
title: '性别',
field: 'gender',
slots: {
default: ({ row }) => {
return renderDict(row.gender, 'sys_user_sex')
},
},
width: 80,
},
{
field: 'img',
title: '人脸图片',
slots: { default: 'img' },
width: 100,
},
{
title: '所属单位',
field: 'unitName',
width: 160,
},
// {
// title: '入驻位置',
// field: 'locathon',
// },
{
title: '入驻时间',
field: 'time',
width: 100,
formatter: ({ cellValue }) => {
return cellValue ? new Date(cellValue).toLocaleDateString('zh-CN', { year: 'numeric', month: '2-digit', day: '2-digit' }).replace(/\//g, '-') : ''
}
},
{
title: '人员标签',
field: 'rosterType',
slots: {
default: ({ row }) => {
return renderDict(row.rosterType, 'roster_type')
},
},
width: 100,
},
{
title: '状态',
field: 'state',
slots: {
default: ({ row }) => {
return renderDict(row.state, 'wy_rzryzt')
},
},
width: 100,
},
{
title: '备注',
field: 'remark',
},
{
field: 'action',
fixed: 'right',
slots: { default: 'action' },
title: '操作',
width: 200,
},
]
let authGroupArr: AuthGroupVO[] = []
export const modalSchema: FormSchemaGetter = () => [
{
label: '主键id',
fieldName: 'id',
component: 'Input',
dependencies: {
show: () => false,
triggerFields: [''],
},
},
{
label: '员工名称',
fieldName: 'userName',
component: 'Input',
rules: 'required',
formItemClass: 'col-span-1',
},
{
label: '联系电话',
fieldName: 'phone',
component: 'Input',
rules: 'required',
formItemClass: 'col-span-1',
},
{
label: '性别',
fieldName: 'gender',
component: 'Select',
formItemClass: 'col-span-2',
componentProps: {
options: getDictOptions('sys_user_sex'),
},
rules: 'required',
},
{
label: '证件号',
fieldName: 'idCard',
component: 'Input',
rules: 'required',
formItemClass: 'col-span-1',
},
{
label: '邮箱',
fieldName: 'email',
component: 'Input',
formItemClass: 'col-span-1',
},
{
label: '人员状态',
fieldName: 'state',
component: 'Select',
componentProps: {
options: getDictOptions('wy_rzryzt')
},
rules: 'selectRequired',
formItemClass: 'col-span-2',
},
// {
// label: '入住员工',
// fieldName: 'userId',
// component: "Select",
// rules: 'selectRequired',
// formItemClass: 'col-span-2'
// },
{
label: '所属单位',
fieldName: 'unitId',
component: 'Select',
formItemClass: 'col-span-4',
rules: 'selectRequired',
},
// {
// label: '入驻位置',
// fieldName: 'locathon',
// component: 'Input',
// rules:'required',
// formItemClass: 'col-span-2',
// },
{
label: '入驻时间',
fieldName: 'time',
component: 'DatePicker',
componentProps: {
showTime: true,
format: 'YYYY-MM-DD HH:mm:ss',
valueFormat: 'YYYY-MM-DD HH:mm:ss',
},
rules: 'required',
formItemClass: 'col-span-1',
},
{
label: '车牌号码',
fieldName: 'carNumber',
component: 'Input',
formItemClass: 'col-span-3',
},
{
label: '修改权限',
fieldName: 'authSwitch',
component: 'Switch',
formItemClass: 'col-span-1',
componentProps: {
class: 'w-auto',
},
defaultValue: false,
dependencies: {
show: (values) => {
return typeof values.id !== 'undefined'
},
triggerFields: ['id'],
},
},
{
label: '人员标签',
fieldName: 'rosterType',
component: 'Select',
formItemClass: 'col-span-1',
componentProps: {
options: getDictOptions('roster_type')
},
dependencies: {
show: (values) => {
return typeof values.id !== 'undefined'
},
disabled: (values) => {
return !values.authSwitch
},
triggerFields: ['id', 'authSwitch'],
},
},
{
label: '授权期限',
fieldName: 'authTime',
component: 'RangePicker',
formItemClass: 'col-span-1',
componentProps: {
class: 'w-auto',
showTime: true,
format: 'YYYY-MM-DD HH:mm:ss',
valueFormat: 'YYYY-MM-DD HH:mm:ss',
},
dependencies: {
show: (values) => {
return typeof values.id !== 'undefined'
},
disabled: (values) => {
return !values.authSwitch
},
triggerFields: ['id', 'authSwitch'],
},
},
{
label: '通行权限组',
fieldName: 'authGroupId',
component: 'ApiSelect',
formItemClass: 'col-span-1',
dependencies: {
show: (values) => {
return typeof values.id !== 'undefined'
},
disabled: (values) => {
return !values.authSwitch
},
triggerFields: ['id', 'authSwitch'],
},
componentProps: {
allowClear: true,
resultField: 'list', // 根据API返回结构调整
labelField: 'name',
valueField: 'id',
// immediate: true,
api: async () => {
if (!authGroupArr || authGroupArr.length == 0) {
const params: AuthGroupQuery = {
pageNum: 1,
pageSize: 500,
}
const res = await authGroupList(params)
authGroupArr = res.rows
}
return authGroupArr
},
},
},
{
label: '人脸图片',
fieldName: 'img',
component: 'ImageUpload',
componentProps: {
// accept: 'image/*', // 可选拓展名或者mime类型 ,拼接
maxCount: 1, // 最大上传文件数 默认为1 为1会绑定为string而非string[]类型
},
formItemClass: 'col-span-3',
},
{
label: '备注',
fieldName: 'remark',
component: 'Textarea',
formItemClass: 'col-span-3',
},
]
//门禁记录
export const accessControlColumns: VxeGridProps['columns'] = [
{
title: '序号',
field: 'id',
},
{
title: '通过时间',
field: 'userId',
},
{
title: '进出类型',
field: 'userName',
},
{
title: '位置',
field: 'phone',
},
{
title: '设备名称',
field: 'gender',
},
{
title: '门禁类型',
field: 'img',
},
{
title: '识别类型',
field: 'unitName',
},
{
title: '状态',
field: 'locathon',
},
]
//车辆记录
export const carColumns: VxeGridProps['columns'] = [
{
title: '序号',
field: 'id',
},
{
title: '通过时间',
field: 'userId',
},
{
title: '进出类型',
field: 'userName',
},
{
title: '位置',
field: 'phone',
},
{
title: '设备名称',
field: 'gender',
},
{
title: '进出方式',
field: 'img',
},
{
title: '停车类型',
field: 'unitName',
},
{
title: '费用(元)',
field: 'locathon',
},
{
title: '状态',
field: 'state',
},
{
title: '备注',
field: 'remark',
},
]
export async function getUnitList(): Promise<
{ value: number; label: string }[]
> {
const queryParam = {
pageNum: 1,
pageSize: 1000,
}
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
}