mirror of
http://git.xinwangdao.com/cnnc-embedded-parts-detect/detect-embeded.git
synced 2025-06-24 13:34:13 +08:00
381 lines
9.6 KiB
TypeScript
381 lines
9.6 KiB
TypeScript
/**
|
||
* 项目:视频监控平台
|
||
* 模型分组:用户管理
|
||
* 模型名称:设备表
|
||
* @Author: xiongwei
|
||
* @Date: 2024-09-26 11:50:00
|
||
*/
|
||
|
||
import { BasicColumn } from '@/components/Table';
|
||
import { FormSchema } from '@/components/Table';
|
||
import * as RegionApi from "@/api/system/regionApi";
|
||
|
||
const colProps = { xs: { span: 24 }, sm: { span: 24 }, lg: { span: 6 } };
|
||
const colPropsInDrawer = { span: 24 };
|
||
|
||
export const schema = {
|
||
model: 'Device',
|
||
viewInPage: true,
|
||
properties: [
|
||
{
|
||
field: 'id',
|
||
label: 'ID系统自动生成',
|
||
defaultValue: undefined,
|
||
form: {
|
||
componentProps: {
|
||
allowClear: false,
|
||
placeholder: 'ID系统自动生成',
|
||
},
|
||
colProps,
|
||
component: 'InputNumber',
|
||
rules: [{ required: true, message: '请输入ID系统自动生成!' }],
|
||
},
|
||
table: {
|
||
},
|
||
},
|
||
{
|
||
field: 'regionId',
|
||
label: '区域',
|
||
defaultValue: undefined,
|
||
form: {
|
||
colProps,
|
||
component: 'ApiSelect',
|
||
componentProps: {
|
||
allowClear: true,
|
||
placeholder: '请选择区域',
|
||
api: (_) => RegionApi.all(),
|
||
labelField: 'name',
|
||
valueField: 'id',
|
||
},
|
||
rules: [{ required: true, message: '请选择区域!' }],
|
||
},
|
||
table: {
|
||
customRender: ({ text, record }) => record.region ? record.region.name : text,
|
||
},
|
||
},
|
||
{
|
||
field: 'name',
|
||
label: '设备名称',
|
||
defaultValue: undefined,
|
||
form: {
|
||
componentProps: {
|
||
allowClear: true,
|
||
placeholder: '设备名称',
|
||
},
|
||
colProps,
|
||
component: 'Input',
|
||
rules: [{ required: true, message: '请输入设备名称!' }],
|
||
},
|
||
table: {
|
||
},
|
||
},
|
||
{
|
||
field: 'deviceIp',
|
||
label: '设备IP',
|
||
defaultValue: undefined,
|
||
form: {
|
||
componentProps: {
|
||
allowClear: true,
|
||
placeholder: '设备IP地址',
|
||
},
|
||
colProps,
|
||
component: 'Input',
|
||
},
|
||
table: {
|
||
},
|
||
},
|
||
{
|
||
field: 'devicePort',
|
||
label: '设备端口',
|
||
defaultValue: undefined,
|
||
form: {
|
||
componentProps: {
|
||
allowClear: true,
|
||
placeholder: '设备端口',
|
||
},
|
||
colProps,
|
||
component: 'Input',
|
||
},
|
||
table: {
|
||
},
|
||
},
|
||
{
|
||
field: 'deviceUsername',
|
||
label: '用户名',
|
||
defaultValue: undefined,
|
||
form: {
|
||
componentProps: {
|
||
allowClear: true,
|
||
placeholder: '用户名',
|
||
},
|
||
colProps,
|
||
component: 'Input',
|
||
},
|
||
table: {
|
||
},
|
||
},
|
||
{
|
||
field: 'devicePassword',
|
||
label: '密码',
|
||
defaultValue: undefined,
|
||
form: {
|
||
componentProps: {
|
||
allowClear: true,
|
||
placeholder: '密码',
|
||
},
|
||
colProps,
|
||
component: 'InputPassword',
|
||
},
|
||
table: {
|
||
},
|
||
},
|
||
{
|
||
field: 'deviceType',
|
||
label: '设备类型',
|
||
defaultValue: undefined,
|
||
form: {
|
||
componentProps: {
|
||
allowClear: true,
|
||
placeholder: '设备类型',
|
||
},
|
||
colProps,
|
||
component: 'Input',
|
||
},
|
||
table: {
|
||
},
|
||
},
|
||
{
|
||
field: 'softwareVersion',
|
||
label: '软件版本',
|
||
defaultValue: undefined,
|
||
form: {
|
||
componentProps: {
|
||
allowClear: true,
|
||
placeholder: '软件版本',
|
||
},
|
||
colProps,
|
||
component: 'Input',
|
||
},
|
||
table: {
|
||
},
|
||
},
|
||
{
|
||
field: 'firmwareVersion',
|
||
label: '固件版本',
|
||
defaultValue: undefined,
|
||
form: {
|
||
componentProps: {
|
||
allowClear: true,
|
||
placeholder: '固件版本',
|
||
},
|
||
colProps,
|
||
component: 'Input',
|
||
},
|
||
table: {
|
||
},
|
||
},
|
||
{
|
||
field: 'algorithmVersion',
|
||
label: '算法版本',
|
||
defaultValue: undefined,
|
||
form: {
|
||
componentProps: {
|
||
allowClear: true,
|
||
placeholder: '算法版本',
|
||
},
|
||
colProps,
|
||
component: 'Input',
|
||
},
|
||
table: {
|
||
},
|
||
},
|
||
{
|
||
field: 'modelVersion',
|
||
label: '模型版本',
|
||
defaultValue: undefined,
|
||
form: {
|
||
componentProps: {
|
||
allowClear: true,
|
||
placeholder: '模型版本',
|
||
},
|
||
colProps,
|
||
component: 'Input',
|
||
},
|
||
table: {
|
||
},
|
||
},
|
||
{
|
||
field: 'cameraIp',
|
||
label: '相机IP地址',
|
||
defaultValue: undefined,
|
||
form: {
|
||
componentProps: {
|
||
allowClear: true,
|
||
placeholder: '相机IP地址',
|
||
},
|
||
colProps,
|
||
component: 'Input',
|
||
},
|
||
table: {
|
||
},
|
||
},
|
||
{
|
||
field: 'cameraUsername',
|
||
label: '相机用户名',
|
||
defaultValue: undefined,
|
||
form: {
|
||
componentProps: {
|
||
allowClear: true,
|
||
placeholder: '相机用户名',
|
||
},
|
||
colProps,
|
||
component: 'Input',
|
||
},
|
||
table: {
|
||
},
|
||
},
|
||
{
|
||
field: 'cameraPassword',
|
||
label: '相机密码',
|
||
defaultValue: undefined,
|
||
form: {
|
||
componentProps: {
|
||
allowClear: true,
|
||
placeholder: '相机密码',
|
||
},
|
||
colProps,
|
||
component: 'InputPassword',
|
||
},
|
||
table: {
|
||
},
|
||
},
|
||
{
|
||
field: 'cameraRtsp',
|
||
label: '相机rtsp完整地址',
|
||
defaultValue: undefined,
|
||
form: {
|
||
componentProps: {
|
||
allowClear: true,
|
||
placeholder: '相机rtsp完整地址',
|
||
},
|
||
colProps,
|
||
component: 'Input',
|
||
},
|
||
table: {
|
||
},
|
||
},
|
||
{
|
||
field: 'createTime',
|
||
label: '创建时间',
|
||
defaultValue: undefined,
|
||
form: {
|
||
colProps,
|
||
componentProps: {
|
||
allowClear: false,
|
||
placeholder: ['开始时间', '结束时间'],
|
||
format: 'YYYY-MM-DD',
|
||
valueFormat: 'YYYY-MM-DD',
|
||
showTime: false,
|
||
},
|
||
component: 'RangePicker',
|
||
rules: [{ required: true, message: '请输入CreateTime!' }],
|
||
},
|
||
table: {
|
||
},
|
||
},
|
||
{
|
||
field: 'updateTime',
|
||
label: '更新时间',
|
||
defaultValue: undefined,
|
||
form: {
|
||
colProps,
|
||
componentProps: {
|
||
allowClear: false,
|
||
placeholder: ['开始时间', '结束时间'],
|
||
format: 'YYYY-MM-DD',
|
||
valueFormat: 'YYYY-MM-DD',
|
||
showTime: false,
|
||
},
|
||
component: 'RangePicker',
|
||
rules: [{ required: true, message: '请输入UpdateTime!' }],
|
||
},
|
||
table: {
|
||
},
|
||
},
|
||
],
|
||
};
|
||
|
||
const queryFields = ['regionId','name','deviceIp'];
|
||
const editFields = ['regionId','name','deviceIp','devicePort','deviceUsername','devicePassword','deviceType','softwareVersion','firmwareVersion','algorithmVersion','modelVersion','cameraIp','cameraUsername','cameraPassword','cameraRtsp'];
|
||
const tableFields = ['regionId','name','deviceIp','devicePort','deviceUsername','devicePassword','deviceType','softwareVersion','firmwareVersion','algorithmVersion','modelVersion','cameraIp','cameraUsername','cameraPassword','cameraRtsp','createTime','updateTime'];
|
||
const descriptionFields = ['regionId','name','deviceIp','devicePort','deviceUsername','devicePassword','deviceType','softwareVersion','firmwareVersion','algorithmVersion','modelVersion','cameraIp','cameraUsername','cameraPassword','cameraRtsp','createTime','updateTime'];
|
||
|
||
const queryFieldsIndexMap = new Map(queryFields.map((field, index) => [field, index]));
|
||
export const searchFormSchema: FormSchema[] = schema.properties.filter(item => queryFields.includes(item.field))
|
||
.map(
|
||
({ field, label, form: { ...formProps } }) =>
|
||
({
|
||
field,
|
||
label,
|
||
defaultValue: undefined,
|
||
...formProps,
|
||
required: false,
|
||
rules: [{ required: false }],
|
||
} as FormSchema),
|
||
)
|
||
.sort((a, b) => {
|
||
const indexA = queryFieldsIndexMap.get(a.field) as number;
|
||
const indexB = queryFieldsIndexMap.get(b.field) as number;
|
||
return indexA - indexB;
|
||
});
|
||
|
||
const editFieldsIndexMap = new Map(editFields.map((field, index) => [field, index]));
|
||
export const formSchema: FormSchema[] = schema.properties.filter(item => editFields.includes(item.field))
|
||
.map(
|
||
({ field, label, defaultValue, form }) =>
|
||
({
|
||
field,
|
||
label,
|
||
defaultValue,
|
||
...form,
|
||
colProps: colPropsInDrawer,
|
||
} as FormSchema),
|
||
)
|
||
.sort((a, b) => {
|
||
const indexA = editFieldsIndexMap.get(a.field) as number;
|
||
const indexB = editFieldsIndexMap.get(b.field) as number;
|
||
return indexA - indexB;
|
||
});
|
||
|
||
const tableFieldsIndexMap = new Map(tableFields.map((field, index) => [field, index]));
|
||
export const columns: BasicColumn[] = schema.properties.filter(item => tableFields.includes(item.field))
|
||
.map(
|
||
({ field, label, table }) =>
|
||
({
|
||
dataIndex: field,
|
||
title: label,
|
||
...table,
|
||
} as BasicColumn)
|
||
)
|
||
.sort((a, b) => {
|
||
const indexA = tableFieldsIndexMap.get(a.dataIndex as string) as number;
|
||
const indexB = tableFieldsIndexMap.get(b.dataIndex as string) as number;
|
||
return indexA - indexB;
|
||
});
|
||
|
||
const descriptionFieldsIndexMap = new Map(descriptionFields.map((field, index) => [field, index]));
|
||
export const descriptionColumns: BasicColumn[] = schema.properties.filter(item => descriptionFields.includes(item.field))
|
||
.map(
|
||
({ field, label, table }) =>
|
||
({
|
||
dataIndex: field,
|
||
title: label,
|
||
...table,
|
||
} as BasicColumn),
|
||
)
|
||
.sort((a, b) => {
|
||
const indexA = descriptionFieldsIndexMap.get(a.dataIndex as string) as number;
|
||
const indexB = descriptionFieldsIndexMap.get(b.dataIndex as string) as number;
|
||
return indexA - indexB;
|
||
});
|