admin-vben5/apps/web-antd/src/views/property/resident/person/data.ts

425 lines
8.6 KiB
TypeScript
Raw Normal View History

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