|
|
@@ -38,6 +38,7 @@ import { lastValueFrom } from 'rxjs';
|
|
|
import type { DeviceMetadata } from '@/pages/device/Product/typings';
|
|
|
|
|
|
const Edit = () => {
|
|
|
+ const intl = useIntl();
|
|
|
const form = createForm({
|
|
|
initialValues: MetadataModel.item as Record<string, unknown>,
|
|
|
});
|
|
|
@@ -95,14 +96,20 @@ const Edit = () => {
|
|
|
type: 'object',
|
|
|
properties: {
|
|
|
id: {
|
|
|
- title: '标识',
|
|
|
+ title: intl.formatMessage({
|
|
|
+ id: 'pages.device.productDetail.metadata.key',
|
|
|
+ defaultMessage: '标识',
|
|
|
+ }),
|
|
|
required: true,
|
|
|
'x-decorator': 'FormItem',
|
|
|
'x-component': 'Input',
|
|
|
'x-disabled': MetadataModel.action === 'edit',
|
|
|
},
|
|
|
name: {
|
|
|
- title: '名称',
|
|
|
+ title: intl.formatMessage({
|
|
|
+ id: 'pages.table.name',
|
|
|
+ defaultMessage: '名称',
|
|
|
+ }),
|
|
|
required: true,
|
|
|
'x-decorator': 'FormItem',
|
|
|
'x-component': 'Input',
|
|
|
@@ -111,14 +118,20 @@ const Edit = () => {
|
|
|
type: 'object',
|
|
|
properties: {
|
|
|
type: {
|
|
|
- title: '数据类型',
|
|
|
+ title: intl.formatMessage({
|
|
|
+ id: 'pages.device.productDetail.metadata.dataType',
|
|
|
+ defaultMessage: '数据类型',
|
|
|
+ }),
|
|
|
required: true,
|
|
|
'x-decorator': 'FormItem',
|
|
|
'x-component': 'Select',
|
|
|
enum: DataTypeList,
|
|
|
},
|
|
|
unit: {
|
|
|
- title: '单位',
|
|
|
+ title: intl.formatMessage({
|
|
|
+ id: 'pages.device.instanceDetail.metadata.unit',
|
|
|
+ defaultMessage: '单位',
|
|
|
+ }),
|
|
|
'x-decorator': 'FormItem',
|
|
|
'x-component': 'Select',
|
|
|
'x-visible': false,
|
|
|
@@ -133,7 +146,10 @@ const Edit = () => {
|
|
|
},
|
|
|
},
|
|
|
scale: {
|
|
|
- title: '精度',
|
|
|
+ title: intl.formatMessage({
|
|
|
+ id: 'pages.device.productDetail.metadata.accuracy',
|
|
|
+ defaultMessage: '精度',
|
|
|
+ }),
|
|
|
'x-decorator': 'FormItem',
|
|
|
'x-component': 'NumberPicker',
|
|
|
'x-reactions': {
|
|
|
@@ -146,7 +162,10 @@ const Edit = () => {
|
|
|
},
|
|
|
},
|
|
|
booleanConfig: {
|
|
|
- title: '布尔值',
|
|
|
+ title: intl.formatMessage({
|
|
|
+ id: 'pages.device.productDetail.metadata.boolean',
|
|
|
+ defaultMessage: '布尔值',
|
|
|
+ }),
|
|
|
type: 'void',
|
|
|
'x-decorator': 'FormItem',
|
|
|
'x-component': 'BooleanEnum',
|
|
|
@@ -160,7 +179,10 @@ const Edit = () => {
|
|
|
},
|
|
|
},
|
|
|
format: {
|
|
|
- title: '时间格式',
|
|
|
+ title: intl.formatMessage({
|
|
|
+ id: 'pages.device.productDetail.metadata.timeFormat',
|
|
|
+ defaultMessage: '时间格式',
|
|
|
+ }),
|
|
|
'x-decorator': 'FormItem',
|
|
|
'x-component': 'Select',
|
|
|
enum: DateTypeList,
|
|
|
@@ -174,7 +196,10 @@ const Edit = () => {
|
|
|
},
|
|
|
},
|
|
|
enumConfig: {
|
|
|
- title: '枚举项',
|
|
|
+ title: intl.formatMessage({
|
|
|
+ id: 'pages.device.productDetail.metadata.enum',
|
|
|
+ defaultMessage: '枚举项',
|
|
|
+ }),
|
|
|
type: 'void',
|
|
|
'x-decorator': 'FormItem',
|
|
|
'x-component': 'EnumParam',
|
|
|
@@ -191,11 +216,17 @@ const Edit = () => {
|
|
|
type: 'object',
|
|
|
properties: {
|
|
|
maxLength: {
|
|
|
- title: '最大长度',
|
|
|
+ title: intl.formatMessage({
|
|
|
+ id: 'pages.device.productDetail.metadata.maxLength',
|
|
|
+ defaultMessage: '最大长度',
|
|
|
+ }),
|
|
|
'x-decorator': 'FormItem',
|
|
|
'x-component': 'NumberPicker',
|
|
|
'x-decorator-props': {
|
|
|
- tooltip: '字节',
|
|
|
+ tooltip: intl.formatMessage({
|
|
|
+ id: 'pages.device.productDetail.metadata.maxLength.byte',
|
|
|
+ defaultMessage: '字节',
|
|
|
+ }),
|
|
|
},
|
|
|
'x-reactions': {
|
|
|
dependencies: ['..type'],
|
|
|
@@ -209,7 +240,10 @@ const Edit = () => {
|
|
|
},
|
|
|
},
|
|
|
elementType: {
|
|
|
- title: '元素配置',
|
|
|
+ title: intl.formatMessage({
|
|
|
+ id: 'pages.device.productDetail.metadata.elementConfiguration',
|
|
|
+ defaultMessage: '元素配置',
|
|
|
+ }),
|
|
|
'x-decorator': 'FormItem',
|
|
|
'x-component': 'ArrayParam',
|
|
|
'x-reactions': {
|
|
|
@@ -222,7 +256,10 @@ const Edit = () => {
|
|
|
},
|
|
|
},
|
|
|
jsonConfig: {
|
|
|
- title: 'JSON对象',
|
|
|
+ title: intl.formatMessage({
|
|
|
+ id: 'pages.device.productDetail.metadata.jsonObject',
|
|
|
+ defaultMessage: 'JSON对象',
|
|
|
+ }),
|
|
|
type: 'void',
|
|
|
'x-decorator': 'FormItem',
|
|
|
'x-component': 'JsonParam',
|
|
|
@@ -236,7 +273,10 @@ const Edit = () => {
|
|
|
},
|
|
|
},
|
|
|
fileType: {
|
|
|
- title: '文件类型',
|
|
|
+ title: intl.formatMessage({
|
|
|
+ id: 'pages.device.productDetail.metadata.fileType',
|
|
|
+ defaultMessage: '文件类型',
|
|
|
+ }),
|
|
|
'x-decorator': 'FormItem',
|
|
|
'x-component': 'Select',
|
|
|
'x-visible': false,
|
|
|
@@ -256,24 +296,36 @@ const Edit = () => {
|
|
|
type: 'object',
|
|
|
properties: {
|
|
|
source: {
|
|
|
- title: '来源',
|
|
|
+ title: intl.formatMessage({
|
|
|
+ id: 'pages.device.productDetail.metadata.source',
|
|
|
+ defaultMessage: '来源',
|
|
|
+ }),
|
|
|
required: true,
|
|
|
'x-decorator': 'FormItem',
|
|
|
'x-component': 'Select',
|
|
|
enum: PropertySource,
|
|
|
},
|
|
|
readOnly: {
|
|
|
- title: '是否只读',
|
|
|
+ title: intl.formatMessage({
|
|
|
+ id: 'pages.device.productDetail.metadata.whetherReadOnly',
|
|
|
+ defaultMessage: '是否只读',
|
|
|
+ }),
|
|
|
required: true,
|
|
|
'x-decorator': 'FormItem',
|
|
|
'x-component': 'Radio.Group',
|
|
|
enum: [
|
|
|
{
|
|
|
- label: '是',
|
|
|
+ label: intl.formatMessage({
|
|
|
+ id: 'pages.device.productDetail.metadata.true',
|
|
|
+ defaultMessage: '是',
|
|
|
+ }),
|
|
|
value: true,
|
|
|
},
|
|
|
{
|
|
|
- label: '否',
|
|
|
+ label: intl.formatMessage({
|
|
|
+ id: 'pages.device.productDetail.metadata.false',
|
|
|
+ defaultMessage: '否',
|
|
|
+ }),
|
|
|
value: false,
|
|
|
},
|
|
|
],
|
|
|
@@ -281,7 +333,10 @@ const Edit = () => {
|
|
|
// 存储配置
|
|
|
configConfig: {
|
|
|
type: 'void',
|
|
|
- title: '其他配置',
|
|
|
+ title: intl.formatMessage({
|
|
|
+ id: 'pages.device.productDetail.metadata.otherConfiguration',
|
|
|
+ defaultMessage: '其他配置',
|
|
|
+ }),
|
|
|
'x-visible': false,
|
|
|
'x-decorator': 'FormItem',
|
|
|
'x-component': 'ConfigParam',
|
|
|
@@ -291,7 +346,10 @@ const Edit = () => {
|
|
|
},
|
|
|
|
|
|
description: {
|
|
|
- title: '描述',
|
|
|
+ title: intl.formatMessage({
|
|
|
+ id: 'pages.device.productDetail.metadata.describe',
|
|
|
+ defaultMessage: '描述',
|
|
|
+ }),
|
|
|
'x-decorator': 'FormItem',
|
|
|
'x-component': 'Input.TextArea',
|
|
|
},
|
|
|
@@ -302,47 +360,71 @@ const Edit = () => {
|
|
|
type: 'object',
|
|
|
properties: {
|
|
|
id: {
|
|
|
- title: '标识',
|
|
|
+ title: intl.formatMessage({
|
|
|
+ id: 'pages.device.productDetail.metadata.key',
|
|
|
+ defaultMessage: '标识',
|
|
|
+ }),
|
|
|
required: true,
|
|
|
'x-decorator': 'FormItem',
|
|
|
'x-component': 'Input',
|
|
|
},
|
|
|
name: {
|
|
|
- title: '名称',
|
|
|
+ title: intl.formatMessage({
|
|
|
+ id: 'pages.table.name',
|
|
|
+ defaultMessage: '名称',
|
|
|
+ }),
|
|
|
required: true,
|
|
|
'x-decorator': 'FormItem',
|
|
|
'x-component': 'Input',
|
|
|
},
|
|
|
async: {
|
|
|
- title: '是否异步',
|
|
|
+ title: intl.formatMessage({
|
|
|
+ id: 'pages.device.productDetail.metadata.whetherAsync',
|
|
|
+ defaultMessage: '是否异步',
|
|
|
+ }),
|
|
|
required: true,
|
|
|
'x-decorator': 'FormItem',
|
|
|
'x-component': 'Radio.Group',
|
|
|
enum: [
|
|
|
{
|
|
|
- label: '是',
|
|
|
+ label: intl.formatMessage({
|
|
|
+ id: 'pages.device.productDetail.metadata.true',
|
|
|
+ defaultMessage: '是',
|
|
|
+ }),
|
|
|
value: true,
|
|
|
},
|
|
|
{
|
|
|
- label: '否',
|
|
|
+ label: intl.formatMessage({
|
|
|
+ id: 'pages.device.productDetail.metadata.false',
|
|
|
+ defaultMessage: '否',
|
|
|
+ }),
|
|
|
value: false,
|
|
|
},
|
|
|
],
|
|
|
},
|
|
|
inputParams: {
|
|
|
- title: '输入参数',
|
|
|
+ title: intl.formatMessage({
|
|
|
+ id: 'pages.device.productDetail.metadata.inputParameter',
|
|
|
+ defaultMessage: '输入参数',
|
|
|
+ }),
|
|
|
required: true,
|
|
|
'x-decorator': 'FormItem',
|
|
|
'x-component': 'Input',
|
|
|
},
|
|
|
outputParams: {
|
|
|
- title: '输出参数',
|
|
|
+ title: intl.formatMessage({
|
|
|
+ id: 'pages.device.productDetail.metadata.outputParameters',
|
|
|
+ defaultMessage: '输出参数',
|
|
|
+ }),
|
|
|
required: true,
|
|
|
'x-decorator': 'FormItem',
|
|
|
'x-component': 'Input',
|
|
|
},
|
|
|
description: {
|
|
|
- title: '描述',
|
|
|
+ title: intl.formatMessage({
|
|
|
+ id: 'pages.device.productDetail.metadata.describe',
|
|
|
+ defaultMessage: '描述',
|
|
|
+ }),
|
|
|
'x-decorator': 'FormItem',
|
|
|
'x-component': 'Input.TextArea',
|
|
|
},
|
|
|
@@ -353,19 +435,28 @@ const Edit = () => {
|
|
|
type: 'object',
|
|
|
properties: {
|
|
|
id: {
|
|
|
- title: '标识',
|
|
|
+ title: intl.formatMessage({
|
|
|
+ id: 'pages.device.productDetail.metadata.key',
|
|
|
+ defaultMessage: '标识',
|
|
|
+ }),
|
|
|
required: true,
|
|
|
'x-decorator': 'FormItem',
|
|
|
'x-component': 'Input',
|
|
|
},
|
|
|
name: {
|
|
|
- title: '名称',
|
|
|
+ title: intl.formatMessage({
|
|
|
+ id: 'pages.table.name',
|
|
|
+ defaultMessage: '名称',
|
|
|
+ }),
|
|
|
required: true,
|
|
|
'x-decorator': 'FormItem',
|
|
|
'x-component': 'Input',
|
|
|
},
|
|
|
'expands.level': {
|
|
|
- title: '级别',
|
|
|
+ title: intl.formatMessage({
|
|
|
+ id: 'pages.device.productDetail.metadata.level',
|
|
|
+ defaultMessage: 'level',
|
|
|
+ }),
|
|
|
required: true,
|
|
|
'x-decorator': 'FormItem',
|
|
|
'x-component': 'Select',
|
|
|
@@ -378,42 +469,63 @@ const Edit = () => {
|
|
|
type: 'object',
|
|
|
properties: {
|
|
|
id: {
|
|
|
- title: '标识',
|
|
|
+ title: intl.formatMessage({
|
|
|
+ id: 'pages.device.productDetail.metadata.key',
|
|
|
+ defaultMessage: '标识',
|
|
|
+ }),
|
|
|
required: true,
|
|
|
'x-decorator': 'FormItem',
|
|
|
'x-component': 'Input',
|
|
|
},
|
|
|
name: {
|
|
|
- title: '名称',
|
|
|
+ title: intl.formatMessage({
|
|
|
+ id: 'pages.table.name',
|
|
|
+ defaultMessage: '名称',
|
|
|
+ }),
|
|
|
required: true,
|
|
|
'x-decorator': 'FormItem',
|
|
|
'x-component': 'Input',
|
|
|
},
|
|
|
'valueType.type': {
|
|
|
- title: '数据类型',
|
|
|
+ title: intl.formatMessage({
|
|
|
+ id: 'pages.device.productDetail.metadata.dataType',
|
|
|
+ defaultMessage: '数据类型',
|
|
|
+ }),
|
|
|
required: true,
|
|
|
'x-decorator': 'FormItem',
|
|
|
'x-component': 'Select',
|
|
|
enum: DataTypeList,
|
|
|
},
|
|
|
'expands.readOnly': {
|
|
|
- title: '是否只读',
|
|
|
+ title: intl.formatMessage({
|
|
|
+ id: 'pages.device.productDetail.metadata.whetherReadOnly',
|
|
|
+ defaultMessage: '是否只读',
|
|
|
+ }),
|
|
|
required: true,
|
|
|
'x-decorator': 'FormItem',
|
|
|
'x-component': 'Radio.Group',
|
|
|
enum: [
|
|
|
{
|
|
|
- label: '是',
|
|
|
+ label: intl.formatMessage({
|
|
|
+ id: 'pages.device.productDetail.metadata.true',
|
|
|
+ defaultMessage: '是',
|
|
|
+ }),
|
|
|
value: true,
|
|
|
},
|
|
|
{
|
|
|
- label: '否',
|
|
|
+ label: intl.formatMessage({
|
|
|
+ id: 'pages.device.productDetail.metadata.false',
|
|
|
+ defaultMessage: '否',
|
|
|
+ }),
|
|
|
value: false,
|
|
|
},
|
|
|
],
|
|
|
},
|
|
|
description: {
|
|
|
- title: '描述',
|
|
|
+ title: intl.formatMessage({
|
|
|
+ id: 'pages.device.productDetail.metadata.describe',
|
|
|
+ defaultMessage: '描述',
|
|
|
+ }),
|
|
|
'x-decorator': 'FormItem',
|
|
|
'x-component': 'Input.TextArea',
|
|
|
},
|
|
|
@@ -460,8 +572,6 @@ const Edit = () => {
|
|
|
});
|
|
|
}, [getUnits]);
|
|
|
|
|
|
- const intl = useIntl();
|
|
|
-
|
|
|
const saveMetadata = async (type: MetadataType, params: MetadataItem) => {
|
|
|
const product = productModel.current;
|
|
|
if (!product) return;
|
|
|
@@ -491,7 +601,7 @@ const Edit = () => {
|
|
|
defaultMessage: '新增',
|
|
|
})}-${intl.formatMessage({
|
|
|
id: `pages.device.metadata.${MetadataModel.type}`,
|
|
|
- defaultMessage: '',
|
|
|
+ defaultMessage: metadataTypeMapping[MetadataModel.type].name,
|
|
|
})}`}
|
|
|
onClose={() => {
|
|
|
MetadataModel.edit = false;
|
|
|
@@ -509,7 +619,10 @@ const Edit = () => {
|
|
|
await saveMetadata(type, data);
|
|
|
}}
|
|
|
>
|
|
|
- 保存数据
|
|
|
+ {intl.formatMessage({
|
|
|
+ id: 'pages.device.productDetail.metadata.saveData',
|
|
|
+ defaultMessage: '保存数据',
|
|
|
+ })}
|
|
|
</Button>
|
|
|
}
|
|
|
>
|