|
|
@@ -41,6 +41,7 @@ import DB from '@/db';
|
|
|
import { useParams } from 'umi';
|
|
|
|
|
|
const Edit = () => {
|
|
|
+ const intl = useIntl();
|
|
|
const form = createForm({
|
|
|
initialValues: MetadataModel.item as Record<string, unknown>,
|
|
|
});
|
|
|
@@ -99,14 +100,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',
|
|
|
@@ -115,14 +122,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,
|
|
|
@@ -137,7 +150,10 @@ const Edit = () => {
|
|
|
},
|
|
|
},
|
|
|
scale: {
|
|
|
- title: '精度',
|
|
|
+ title: intl.formatMessage({
|
|
|
+ id: 'pages.device.productDetail.metadata.accuracy',
|
|
|
+ defaultMessage: '精度',
|
|
|
+ }),
|
|
|
'x-decorator': 'FormItem',
|
|
|
'x-component': 'NumberPicker',
|
|
|
'x-reactions': {
|
|
|
@@ -150,7 +166,10 @@ const Edit = () => {
|
|
|
},
|
|
|
},
|
|
|
booleanConfig: {
|
|
|
- title: '布尔值',
|
|
|
+ title: intl.formatMessage({
|
|
|
+ id: 'pages.device.productDetail.metadata.boolean',
|
|
|
+ defaultMessage: '布尔值',
|
|
|
+ }),
|
|
|
type: 'void',
|
|
|
'x-decorator': 'FormItem',
|
|
|
'x-component': 'BooleanEnum',
|
|
|
@@ -164,7 +183,10 @@ const Edit = () => {
|
|
|
},
|
|
|
},
|
|
|
format: {
|
|
|
- title: '时间格式',
|
|
|
+ title: intl.formatMessage({
|
|
|
+ id: 'pages.device.productDetail.metadata.timeFormat',
|
|
|
+ defaultMessage: '时间格式',
|
|
|
+ }),
|
|
|
'x-decorator': 'FormItem',
|
|
|
'x-component': 'Select',
|
|
|
enum: DateTypeList,
|
|
|
@@ -178,7 +200,10 @@ const Edit = () => {
|
|
|
},
|
|
|
},
|
|
|
enumConfig: {
|
|
|
- title: '枚举项',
|
|
|
+ title: intl.formatMessage({
|
|
|
+ id: 'pages.device.productDetail.metadata.enum',
|
|
|
+ defaultMessage: '枚举项',
|
|
|
+ }),
|
|
|
type: 'void',
|
|
|
'x-decorator': 'FormItem',
|
|
|
'x-component': 'EnumParam',
|
|
|
@@ -195,11 +220,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'],
|
|
|
@@ -213,7 +244,10 @@ const Edit = () => {
|
|
|
},
|
|
|
},
|
|
|
elementType: {
|
|
|
- title: '元素配置',
|
|
|
+ title: intl.formatMessage({
|
|
|
+ id: 'pages.device.productDetail.metadata.elementConfiguration',
|
|
|
+ defaultMessage: '元素配置',
|
|
|
+ }),
|
|
|
'x-decorator': 'FormItem',
|
|
|
'x-component': 'ArrayParam',
|
|
|
'x-reactions': {
|
|
|
@@ -226,7 +260,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',
|
|
|
@@ -240,7 +277,10 @@ const Edit = () => {
|
|
|
},
|
|
|
},
|
|
|
fileType: {
|
|
|
- title: '文件类型',
|
|
|
+ title: intl.formatMessage({
|
|
|
+ id: 'pages.device.productDetail.metadata.fileType',
|
|
|
+ defaultMessage: '文件类型',
|
|
|
+ }),
|
|
|
'x-decorator': 'FormItem',
|
|
|
'x-component': 'Select',
|
|
|
'x-visible': false,
|
|
|
@@ -260,24 +300,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,
|
|
|
},
|
|
|
],
|
|
|
@@ -285,7 +337,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',
|
|
|
@@ -295,7 +350,10 @@ const Edit = () => {
|
|
|
},
|
|
|
|
|
|
description: {
|
|
|
- title: '描述',
|
|
|
+ title: intl.formatMessage({
|
|
|
+ id: 'pages.device.productDetail.metadata.describe',
|
|
|
+ defaultMessage: '描述',
|
|
|
+ }),
|
|
|
'x-decorator': 'FormItem',
|
|
|
'x-component': 'Input.TextArea',
|
|
|
},
|
|
|
@@ -306,47 +364,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',
|
|
|
},
|
|
|
@@ -357,19 +439,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',
|
|
|
@@ -382,42 +473,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',
|
|
|
},
|
|
|
@@ -464,8 +576,6 @@ const Edit = () => {
|
|
|
});
|
|
|
}, [getUnits]);
|
|
|
|
|
|
- const intl = useIntl();
|
|
|
-
|
|
|
const saveMetadata = async (type: MetadataType, params: MetadataItem) => {
|
|
|
const product = productModel.current;
|
|
|
if (!product) return;
|
|
|
@@ -501,7 +611,7 @@ const Edit = () => {
|
|
|
defaultMessage: '新增',
|
|
|
})}-${intl.formatMessage({
|
|
|
id: `pages.device.metadata.${MetadataModel.type}`,
|
|
|
- defaultMessage: '',
|
|
|
+ defaultMessage: metadataTypeMapping[MetadataModel.type].name,
|
|
|
})}`}
|
|
|
onClose={() => {
|
|
|
MetadataModel.edit = false;
|
|
|
@@ -519,7 +629,10 @@ const Edit = () => {
|
|
|
await saveMetadata(type, data);
|
|
|
}}
|
|
|
>
|
|
|
- 保存数据
|
|
|
+ {intl.formatMessage({
|
|
|
+ id: 'pages.device.productDetail.metadata.saveData',
|
|
|
+ defaultMessage: '保存数据',
|
|
|
+ })}
|
|
|
</Button>
|
|
|
}
|
|
|
>
|