fix(iot): 完善 thingmodel 的迁移
parent
ec796b8336
commit
b1bd32a89b
|
|
@ -1,73 +0,0 @@
|
||||||
<!-- dataType:array 数组类型 -->
|
|
||||||
<script lang="ts" setup>
|
|
||||||
import type { Ref } from 'vue';
|
|
||||||
|
|
||||||
import { useVModel } from '@vueuse/core';
|
|
||||||
import { Form, Input, Radio } from 'ant-design-vue';
|
|
||||||
|
|
||||||
import { ThingModelFormRules } from '#/api/iot/thingmodel';
|
|
||||||
import {
|
|
||||||
getDataTypeOptions,
|
|
||||||
IoTDataSpecsDataTypeEnum,
|
|
||||||
} from '#/views/iot/utils/constants';
|
|
||||||
|
|
||||||
import ThingModelStructDataSpecs from './thing-model-struct-data-specs.vue';
|
|
||||||
|
|
||||||
/** 数组型的 dataSpecs 配置组件 */
|
|
||||||
defineOptions({ name: 'ThingModelArrayDataSpecs' });
|
|
||||||
|
|
||||||
const props = defineProps<{ modelValue: any }>();
|
|
||||||
const emits = defineEmits(['update:modelValue']);
|
|
||||||
const dataSpecs = useVModel(props, 'modelValue', emits) as Ref<any>;
|
|
||||||
|
|
||||||
/** 元素类型改变时间。当值为 struct 时,对 dataSpecs 中的 dataSpecsList 进行初始化 */
|
|
||||||
function handleChange(val: any) {
|
|
||||||
if (val !== IoTDataSpecsDataTypeEnum.STRUCT) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
dataSpecs.value.dataSpecsList = [];
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<Form.Item
|
|
||||||
:name="['property', 'dataSpecs', 'childDataType']"
|
|
||||||
:rules="ThingModelFormRules.childDataType"
|
|
||||||
label="元素类型"
|
|
||||||
>
|
|
||||||
<Radio.Group v-model:value="dataSpecs.childDataType" @change="handleChange">
|
|
||||||
<template v-for="item in getDataTypeOptions()" :key="item.value">
|
|
||||||
<Radio
|
|
||||||
v-if="
|
|
||||||
!(
|
|
||||||
[
|
|
||||||
IoTDataSpecsDataTypeEnum.ENUM,
|
|
||||||
IoTDataSpecsDataTypeEnum.ARRAY,
|
|
||||||
IoTDataSpecsDataTypeEnum.DATE,
|
|
||||||
] as any[]
|
|
||||||
).includes(item.value)
|
|
||||||
"
|
|
||||||
:value="item.value"
|
|
||||||
class="w-1/3"
|
|
||||||
>
|
|
||||||
{{ `${item.value}(${item.label})` }}
|
|
||||||
</Radio>
|
|
||||||
</template>
|
|
||||||
</Radio.Group>
|
|
||||||
</Form.Item>
|
|
||||||
<Form.Item
|
|
||||||
:name="['property', 'dataSpecs', 'size']"
|
|
||||||
:rules="ThingModelFormRules.size"
|
|
||||||
label="元素个数"
|
|
||||||
>
|
|
||||||
<Input
|
|
||||||
v-model:value="dataSpecs.size"
|
|
||||||
placeholder="请输入数组中的元素个数"
|
|
||||||
/>
|
|
||||||
</Form.Item>
|
|
||||||
<!-- Struct 型配置-->
|
|
||||||
<ThingModelStructDataSpecs
|
|
||||||
v-if="dataSpecs.childDataType === IoTDataSpecsDataTypeEnum.STRUCT"
|
|
||||||
v-model="dataSpecs.dataSpecsList"
|
|
||||||
/>
|
|
||||||
</template>
|
|
||||||
|
|
@ -1,67 +0,0 @@
|
||||||
<!-- dataType:enum 数组类型 -->
|
|
||||||
<script lang="ts" setup>
|
|
||||||
import type { Ref } from 'vue';
|
|
||||||
|
|
||||||
import { useVModel } from '@vueuse/core';
|
|
||||||
import { Button, Form, Input, message } from 'ant-design-vue';
|
|
||||||
|
|
||||||
/** 枚举型的 dataSpecs 配置组件 */
|
|
||||||
defineOptions({ name: 'ThingModelEnumDataSpecs' });
|
|
||||||
|
|
||||||
const props = defineProps<{ modelValue: any }>();
|
|
||||||
const emits = defineEmits(['update:modelValue']);
|
|
||||||
const dataSpecsList = useVModel(props, 'modelValue', emits) as Ref<any[]>;
|
|
||||||
|
|
||||||
/** 添加枚举项 */
|
|
||||||
function addEnum() {
|
|
||||||
dataSpecsList.value.push({
|
|
||||||
name: '', // 枚举项的名称
|
|
||||||
value: '', // 枚举值
|
|
||||||
} as any);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 删除枚举项 */
|
|
||||||
function deleteEnum(index: number) {
|
|
||||||
if (dataSpecsList.value.length === 1) {
|
|
||||||
message.warning('至少需要一个枚举项');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
dataSpecsList.value.splice(index, 1);
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<Form.Item label="枚举项">
|
|
||||||
<div class="flex flex-col">
|
|
||||||
<div class="flex items-center">
|
|
||||||
<span class="flex-1"> 参数值 </span>
|
|
||||||
<span class="flex-1"> 参数描述 </span>
|
|
||||||
</div>
|
|
||||||
<div
|
|
||||||
v-for="(item, index) in dataSpecsList"
|
|
||||||
:key="index"
|
|
||||||
class="mb-5px flex items-center justify-between"
|
|
||||||
>
|
|
||||||
<div class="flex-1">
|
|
||||||
<Input v-model:value="item.value" placeholder="请输入枚举值,如'0'" />
|
|
||||||
</div>
|
|
||||||
<span class="mx-2">~</span>
|
|
||||||
<div class="flex-1">
|
|
||||||
<Input v-model:value="item.name" placeholder="对该枚举项的描述" />
|
|
||||||
</div>
|
|
||||||
<Button class="ml-10px" type="link" @click="deleteEnum(index)">
|
|
||||||
删除
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
<Button type="link" @click="addEnum">+添加枚举项</Button>
|
|
||||||
</div>
|
|
||||||
</Form.Item>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
|
||||||
:deep(.ant-form-item) {
|
|
||||||
.ant-form-item {
|
|
||||||
margin-bottom: 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
|
|
@ -175,6 +175,13 @@ const IOT_DICT = {
|
||||||
IOT_MODBUS_FRAME_FORMAT: 'iot_modbus_frame_format', // IoT Modbus 帧格式
|
IOT_MODBUS_FRAME_FORMAT: 'iot_modbus_frame_format', // IoT Modbus 帧格式
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
|
/** ========== MES - 制造执行模块 ========== */
|
||||||
|
const MES_DICT = {
|
||||||
|
MES_MD_ITEM_OR_PRODUCT: 'mes_md_item_or_product', // MES 物料/产品标识
|
||||||
|
MES_WM_BARCODE_BIZ_TYPE: 'mes_wm_barcode_biz_type', // MES 条码业务类型
|
||||||
|
MES_WM_BARCODE_FORMAT: 'mes_wm_barcode_format', // MES 条码格式
|
||||||
|
} as const;
|
||||||
|
|
||||||
/** ========== WMS - 仓储管理模块 ========== */
|
/** ========== WMS - 仓储管理模块 ========== */
|
||||||
const WMS_DICT = {
|
const WMS_DICT = {
|
||||||
WMS_MERCHANT_TYPE: 'merchant_type', // WMS 往来企业类型
|
WMS_MERCHANT_TYPE: 'merchant_type', // WMS 往来企业类型
|
||||||
|
|
@ -192,6 +199,7 @@ const DICT_TYPE = {
|
||||||
...ERP_DICT,
|
...ERP_DICT,
|
||||||
...INFRA_DICT,
|
...INFRA_DICT,
|
||||||
...IOT_DICT,
|
...IOT_DICT,
|
||||||
|
...MES_DICT,
|
||||||
...WMS_DICT,
|
...WMS_DICT,
|
||||||
...MEMBER_DICT,
|
...MEMBER_DICT,
|
||||||
...MP_DICT,
|
...MP_DICT,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue