233 lines
6.2 KiB
TypeScript
233 lines
6.2 KiB
TypeScript
import { computed } from 'vue';
|
|
|
|
import { z } from '@vben/common-ui';
|
|
|
|
import dayjs from 'dayjs';
|
|
|
|
import { $t } from '#/locales';
|
|
|
|
export const querySchema = computed(() => [
|
|
{
|
|
component: 'Input',
|
|
fieldName: 'SearchKeyWords',
|
|
label: $t('common.keyword'),
|
|
},
|
|
]);
|
|
|
|
export const tableSchema = computed(() => [
|
|
{
|
|
field: 'filedType',
|
|
title: '物模型类型',
|
|
minWidth: 120,
|
|
showOverflow: 'tooltip',
|
|
formatter: ({ cellValue }: { cellValue: any }) => {
|
|
const typeMap: Record<string, string> = {
|
|
'Property': '属性',
|
|
'Service': '服务',
|
|
'Event': '事件',
|
|
};
|
|
return typeMap[cellValue] || cellValue;
|
|
},
|
|
},
|
|
{
|
|
field: 'ioTPlatformRawFieldName',
|
|
title: '平台原始字段名',
|
|
minWidth: 150,
|
|
showOverflow: 'tooltip',
|
|
},
|
|
{
|
|
field: 'standardFieldName',
|
|
title: '标准字段名',
|
|
minWidth: 150,
|
|
showOverflow: 'tooltip',
|
|
},
|
|
{
|
|
field: 'standardFieldDisplayName',
|
|
title: '标准字段显示名称',
|
|
minWidth: 150,
|
|
showOverflow: 'tooltip',
|
|
},
|
|
{
|
|
field: 'standardFieldValueType',
|
|
title: '标准字段值类型',
|
|
minWidth: 120,
|
|
showOverflow: 'tooltip',
|
|
formatter: ({ cellValue }: { cellValue: any }) => {
|
|
const typeMap: Record<string, string> = {
|
|
'String': '字符串',
|
|
'Int32': '整数',
|
|
'Int64': '长整数',
|
|
'Float': '浮点数',
|
|
'Double': '双精度',
|
|
'Boolean': '布尔值',
|
|
'DateTime': '日期时间',
|
|
'Object': 'JSON对象',
|
|
'Array': '数组',
|
|
};
|
|
return typeMap[cellValue] || cellValue;
|
|
},
|
|
},
|
|
{
|
|
field: 'isValueNeedConvert',
|
|
title: '需要值类型转换',
|
|
minWidth: 120,
|
|
slots: { default: 'isValueNeedConvert' },
|
|
},
|
|
{
|
|
field: 'creationTime',
|
|
title: $t('common.creationTime'),
|
|
minWidth: 180,
|
|
formatter: ({ cellValue }: { cellValue: any }) => {
|
|
return cellValue ? dayjs(cellValue).format('YYYY-MM-DD HH:mm:ss') : '-';
|
|
},
|
|
},
|
|
{
|
|
field: 'action',
|
|
title: $t('common.action'),
|
|
width: 200,
|
|
fixed: 'right',
|
|
slots: { default: 'action' },
|
|
},
|
|
]);
|
|
|
|
// 添加物模型表单schema
|
|
export const addThingModelFormSchema = computed(() => [
|
|
{
|
|
component: 'Select',
|
|
fieldName: 'filedType',
|
|
label: '物模型类型',
|
|
rules: z.string().min(1, $t('common.required')),
|
|
componentProps: {
|
|
options: [
|
|
{ label: '属性', value: 'Property' },
|
|
{ label: '服务', value: 'Service' },
|
|
{ label: '事件', value: 'Event' },
|
|
],
|
|
placeholder: '请选择物模型类型',
|
|
},
|
|
},
|
|
{
|
|
component: 'Input',
|
|
fieldName: 'ioTPlatformRawFieldName',
|
|
label: '平台原始字段名',
|
|
rules: z.string().min(1, $t('common.required')),
|
|
componentProps: {
|
|
placeholder: '请输入物联网平台中的原始字段名',
|
|
},
|
|
},
|
|
{
|
|
component: 'Input',
|
|
fieldName: 'standardFieldName',
|
|
label: '标准字段名',
|
|
rules: z.string().min(1, $t('common.required')),
|
|
componentProps: {
|
|
placeholder: '请输入管理后台产品标准的字段名',
|
|
},
|
|
},
|
|
{
|
|
component: 'Select',
|
|
fieldName: 'standardFieldValueType',
|
|
label: '标准字段值类型',
|
|
rules: z.string().min(1, $t('common.required')),
|
|
componentProps: {
|
|
options: [
|
|
{ label: '字符串', value: 'String' },
|
|
{ label: '整数', value: 'Int32' },
|
|
{ label: '长整数', value: 'Int64' },
|
|
{ label: '浮点数', value: 'Float' },
|
|
{ label: '双精度', value: 'Double' },
|
|
{ label: '布尔值', value: 'Boolean' },
|
|
{ label: '日期时间', value: 'DateTime' },
|
|
{ label: 'JSON对象', value: 'Object' },
|
|
{ label: '数组', value: 'Array' },
|
|
],
|
|
placeholder: '请选择标准字段值类型',
|
|
},
|
|
},
|
|
{
|
|
component: 'Input',
|
|
fieldName: 'standardFieldDisplayName',
|
|
label: '标准字段显示名称',
|
|
rules: z.string().min(1, $t('common.required')),
|
|
componentProps: {
|
|
placeholder: '请输入标准字段的显示名称',
|
|
},
|
|
},
|
|
{
|
|
component: 'Switch',
|
|
fieldName: 'isValueNeedConvert',
|
|
label: '是否需要值类型转换',
|
|
defaultValue: false,
|
|
},
|
|
]);
|
|
|
|
// 编辑物模型表单schema
|
|
export const editThingModelFormSchema = computed(() => [
|
|
{
|
|
component: 'Select',
|
|
fieldName: 'filedType',
|
|
label: '物模型类型',
|
|
rules: z.string().min(1, $t('common.required')),
|
|
componentProps: {
|
|
options: [
|
|
{ label: '属性', value: 'Property' },
|
|
{ label: '服务', value: 'Service' },
|
|
{ label: '事件', value: 'Event' },
|
|
],
|
|
placeholder: '请选择物模型类型',
|
|
},
|
|
},
|
|
{
|
|
component: 'Input',
|
|
fieldName: 'ioTPlatformRawFieldName',
|
|
label: '平台原始字段名',
|
|
rules: z.string().min(1, $t('common.required')),
|
|
componentProps: {
|
|
placeholder: '请输入物联网平台中的原始字段名',
|
|
},
|
|
},
|
|
{
|
|
component: 'Input',
|
|
fieldName: 'standardFieldName',
|
|
label: '标准字段名',
|
|
rules: z.string().min(1, $t('common.required')),
|
|
componentProps: {
|
|
placeholder: '请输入管理后台产品标准的字段名',
|
|
},
|
|
},
|
|
{
|
|
component: 'Select',
|
|
fieldName: 'standardFieldValueType',
|
|
label: '标准字段值类型',
|
|
rules: z.string().min(1, $t('common.required')),
|
|
componentProps: {
|
|
options: [
|
|
{ label: '字符串', value: 'String' },
|
|
{ label: '整数', value: 'Int32' },
|
|
{ label: '长整数', value: 'Int64' },
|
|
{ label: '浮点数', value: 'Float' },
|
|
{ label: '双精度', value: 'Double' },
|
|
{ label: '布尔值', value: 'Boolean' },
|
|
{ label: '日期时间', value: 'DateTime' },
|
|
{ label: 'JSON对象', value: 'Object' },
|
|
{ label: '数组', value: 'Array' },
|
|
],
|
|
placeholder: '请选择标准字段值类型',
|
|
},
|
|
},
|
|
{
|
|
component: 'Input',
|
|
fieldName: 'standardFieldDisplayName',
|
|
label: '标准字段显示名称',
|
|
rules: z.string().min(1, $t('common.required')),
|
|
componentProps: {
|
|
placeholder: '请输入标准字段的显示名称',
|
|
},
|
|
},
|
|
{
|
|
component: 'Switch',
|
|
fieldName: 'isValueNeedConvert',
|
|
label: '是否需要值类型转换',
|
|
},
|
|
]);
|