feat(iot):优化 IoT 请求的代码风格(thingmodel 界面调整引入)

pull/345/head
YunaiV 2026-05-18 12:27:37 +08:00
parent 5182cdbffa
commit cfb1f8401e
5 changed files with 13 additions and 13 deletions

View File

@ -2,7 +2,7 @@
import type { Ref } from 'vue';
import type { IotProductApi } from '#/api/iot/product/product';
import type { ThingModelData } from '#/api/iot/thingmodel';
import type { ThingModelApi } from '#/api/iot/thingmodel';
import { computed, inject } from 'vue';
@ -46,12 +46,12 @@ function handleCreate() {
}
/** 编辑物模型 */
function handleEdit(row: ThingModelData) {
function handleEdit(row: ThingModelApi.ThingModel) {
formModalApi.setData({ id: row.id }).open();
}
/** 删除物模型 */
async function handleDelete(row: ThingModelData) {
async function handleDelete(row: ThingModelApi.ThingModel) {
const hideLoading = message.loading({
content: $t('ui.actionMessage.deleting', [row.name]),
duration: 0,

View File

@ -1,5 +1,5 @@
<script lang="ts" setup>
import type { ThingModelData } from '#/api/iot/thingmodel';
import type { ThingModelApi } from '#/api/iot/thingmodel';
import { computed } from 'vue';
@ -27,7 +27,7 @@ const LIST_TYPES = new Set<string>([
IoTDataSpecsDataTypeEnum.ENUM,
]);
const props = defineProps<{ data: ThingModelData }>();
const props = defineProps<{ data: ThingModelApi.ThingModel }>();
const formattedDataSpecsList = computed(() => {
if (!props.data.property?.dataSpecsList?.length) {

View File

@ -2,7 +2,7 @@
<script lang="ts" setup>
import type { Ref } from 'vue';
import type { DataSpecsNumberData } from '#/api/iot/thingmodel';
import type { ThingModelApi } from '#/api/iot/thingmodel';
import { DICT_TYPE } from '@vben/constants';
import { getDictOptions } from '@vben/hooks';
@ -16,7 +16,7 @@ const dataSpecs = useVModel(
props,
'modelValue',
emits,
) as Ref<DataSpecsNumberData>;
) as Ref<ThingModelApi.DataSpecsNumberData>;
/** 单位下拉变化时,拆出 unitName 与 unit 回写 */
function unitChange(unitSpecs: any) {

View File

@ -2,7 +2,7 @@
import type { Ref } from 'vue';
import type { IotProductApi } from '#/api/iot/product/product';
import type { ThingModelData } from '#/api/iot/thingmodel';
import type { ThingModelApi } from '#/api/iot/thingmodel';
import { computed, inject, ref } from 'vue';
@ -35,7 +35,7 @@ const emit = defineEmits(['success']);
const product = inject<Ref<IotProductApi.Product>>(IOT_PROVIDE_KEY.PRODUCT);
const formRef = ref();
const formData = ref<ThingModelData>(buildEmptyFormData());
const formData = ref<ThingModelApi.ThingModel>(buildEmptyFormData());
const getTitle = computed(() =>
formData.value.id
@ -86,7 +86,7 @@ const [Modal, modalApi] = useVbenModal({
});
/** 构造空白表单数据 */
function buildEmptyFormData(): ThingModelData {
function buildEmptyFormData(): ThingModelApi.ThingModel {
return {
type: IoTThingModelTypeEnum.PROPERTY,
dataType: IoTDataSpecsDataTypeEnum.INT,
@ -107,7 +107,7 @@ function buildEmptyFormData(): ThingModelData {
}
/** 回显数据时,规整各分支字段确保子表单可绑定 */
function normalizeFormData(result: ThingModelData): ThingModelData {
function normalizeFormData(result: ThingModelApi.ThingModel): ThingModelApi.ThingModel {
const next: any = { ...result, type: Number(result.type) };
if (isEmpty(next.property)) {
next.dataType = IoTDataSpecsDataTypeEnum.INT;

View File

@ -2,7 +2,7 @@
<script lang="ts" setup>
import type { Ref } from 'vue';
import type { ThingModelProperty } from '#/api/iot/thingmodel';
import type { ThingModelApi } from '#/api/iot/thingmodel';
import { computed, watch } from 'vue';
@ -50,7 +50,7 @@ const property = useVModel(
props,
'modelValue',
emits,
) as Ref<ThingModelProperty>;
) as Ref<ThingModelApi.Property>;
const dataTypeOptions = computed(() =>
props.isStructDataSpecs ? STRUCT_CHILD_OPTIONS : getDataTypeOptions(),