feat(iot):优化 IoT 请求的代码风格(device 界面调整引入)
parent
d649a617ac
commit
5182cdbffa
|
|
@ -1,7 +1,7 @@
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import type { IotDeviceApi } from '#/api/iot/device/device';
|
import type { IotDeviceApi } from '#/api/iot/device/device';
|
||||||
import type { IotProductApi } from '#/api/iot/product/product';
|
import type { IotProductApi } from '#/api/iot/product/product';
|
||||||
import type { ThingModelData } from '#/api/iot/thingmodel';
|
import type { ThingModelApi } from '#/api/iot/thingmodel';
|
||||||
|
|
||||||
import { onMounted, ref } from 'vue';
|
import { onMounted, ref } from 'vue';
|
||||||
import { useRoute, useRouter } from 'vue-router';
|
import { useRoute, useRouter } from 'vue-router';
|
||||||
|
|
@ -34,7 +34,7 @@ const loading = ref(true);
|
||||||
const product = ref<IotProductApi.Product>({} as IotProductApi.Product);
|
const product = ref<IotProductApi.Product>({} as IotProductApi.Product);
|
||||||
const device = ref<IotDeviceApi.Device>({} as IotDeviceApi.Device);
|
const device = ref<IotDeviceApi.Device>({} as IotDeviceApi.Device);
|
||||||
const activeTab = ref('info');
|
const activeTab = ref('info');
|
||||||
const thingModelList = ref<ThingModelData[]>([]);
|
const thingModelList = ref<ThingModelApi.ThingModel[]>([]);
|
||||||
|
|
||||||
/** 获取设备详情 */
|
/** 获取设备详情 */
|
||||||
async function getDeviceData(deviceId: number) {
|
async function getDeviceData(deviceId: number) {
|
||||||
|
|
@ -113,11 +113,11 @@ onMounted(async () => {
|
||||||
</Tabs.TabPane>
|
</Tabs.TabPane>
|
||||||
<Tabs.TabPane
|
<Tabs.TabPane
|
||||||
v-if="product.deviceType === DeviceTypeEnum.GATEWAY"
|
v-if="product.deviceType === DeviceTypeEnum.GATEWAY"
|
||||||
key="sub-device"
|
key="subDevice"
|
||||||
tab="子设备管理"
|
tab="子设备管理"
|
||||||
>
|
>
|
||||||
<DeviceDetailsSubDevice
|
<DeviceDetailsSubDevice
|
||||||
v-if="activeTab === 'sub-device' && device.id"
|
v-if="activeTab === 'subDevice' && device.id"
|
||||||
:device-id="device.id"
|
:device-id="device.id"
|
||||||
/>
|
/>
|
||||||
</Tabs.TabPane>
|
</Tabs.TabPane>
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ import type { IotDeviceApi } from '#/api/iot/device/device';
|
||||||
import type { IotDeviceModbusConfigApi } from '#/api/iot/device/modbus/config';
|
import type { IotDeviceModbusConfigApi } from '#/api/iot/device/modbus/config';
|
||||||
import type { IotDeviceModbusPointApi } from '#/api/iot/device/modbus/point';
|
import type { IotDeviceModbusPointApi } from '#/api/iot/device/modbus/point';
|
||||||
import type { IotProductApi } from '#/api/iot/product/product';
|
import type { IotProductApi } from '#/api/iot/product/product';
|
||||||
import type { ThingModelData } from '#/api/iot/thingmodel';
|
import type { ThingModelApi } from '#/api/iot/thingmodel';
|
||||||
import type { DescriptionItemSchema } from '#/components/description';
|
import type { DescriptionItemSchema } from '#/components/description';
|
||||||
|
|
||||||
import { computed, h, onMounted, ref } from 'vue';
|
import { computed, h, onMounted, ref } from 'vue';
|
||||||
|
|
@ -35,7 +35,7 @@ defineOptions({ name: 'DeviceModbusConfig' });
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
device: IotDeviceApi.Device;
|
device: IotDeviceApi.Device;
|
||||||
product: IotProductApi.Product;
|
product: IotProductApi.Product;
|
||||||
thingModelList: ThingModelData[];
|
thingModelList: ThingModelApi.ThingModel[];
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
// ======================= 连接配置 =======================
|
// ======================= 连接配置 =======================
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import type { VbenFormSchema } from '#/adapter/form';
|
import type { VbenFormSchema } from '#/adapter/form';
|
||||||
import type { IotDeviceModbusPointApi } from '#/api/iot/device/modbus/point';
|
import type { IotDeviceModbusPointApi } from '#/api/iot/device/modbus/point';
|
||||||
import type { ThingModelData } from '#/api/iot/thingmodel';
|
import type { ThingModelApi } from '#/api/iot/thingmodel';
|
||||||
|
|
||||||
import { computed, h, ref } from 'vue';
|
import { computed, h, ref } from 'vue';
|
||||||
|
|
||||||
|
|
@ -35,7 +35,7 @@ const getTitle = computed(() => {
|
||||||
return formData.value?.id ? '编辑点位' : '新增点位';
|
return formData.value?.id ? '编辑点位' : '新增点位';
|
||||||
});
|
});
|
||||||
const deviceId = ref<number>(0);
|
const deviceId = ref<number>(0);
|
||||||
const thingModelList = ref<ThingModelData[]>([]);
|
const thingModelList = ref<ThingModelApi.ThingModel[]>([]);
|
||||||
|
|
||||||
/** 筛选属性类型的物模型 */
|
/** 筛选属性类型的物模型 */
|
||||||
const propertyList = computed(() => {
|
const propertyList = computed(() => {
|
||||||
|
|
@ -289,7 +289,7 @@ const [Modal, modalApi] = useVbenModal({
|
||||||
const data = modalApi.getData<{
|
const data = modalApi.getData<{
|
||||||
deviceId: number;
|
deviceId: number;
|
||||||
id?: number;
|
id?: number;
|
||||||
thingModelList: ThingModelData[];
|
thingModelList: ThingModelApi.ThingModel[];
|
||||||
}>();
|
}>();
|
||||||
if (!data) {
|
if (!data) {
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ import type { TableColumnType } from 'ant-design-vue';
|
||||||
|
|
||||||
import type { IotDeviceApi } from '#/api/iot/device/device';
|
import type { IotDeviceApi } from '#/api/iot/device/device';
|
||||||
import type { IotProductApi } from '#/api/iot/product/product';
|
import type { IotProductApi } from '#/api/iot/product/product';
|
||||||
import type { ThingModelData } from '#/api/iot/thingmodel';
|
import type { ThingModelApi } from '#/api/iot/thingmodel';
|
||||||
|
|
||||||
import { computed, ref } from 'vue';
|
import { computed, ref } from 'vue';
|
||||||
|
|
||||||
|
|
@ -36,7 +36,7 @@ import DeviceDetailsMessage from './message.vue';
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
device: IotDeviceApi.Device;
|
device: IotDeviceApi.Device;
|
||||||
product: IotProductApi.Product;
|
product: IotProductApi.Product;
|
||||||
thingModelList: ThingModelData[];
|
thingModelList: ThingModelApi.ThingModel[];
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
// 消息弹窗
|
// 消息弹窗
|
||||||
|
|
@ -224,7 +224,7 @@ async function handlePropertyPost() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// 事件上报
|
// 事件上报
|
||||||
async function handleEventPost(row: ThingModelData) {
|
async function handleEventPost(row: ThingModelApi.ThingModel) {
|
||||||
try {
|
try {
|
||||||
const valueStr = formData.value[row.identifier!];
|
const valueStr = formData.value[row.identifier!];
|
||||||
let params: any = {};
|
let params: any = {};
|
||||||
|
|
@ -306,7 +306,7 @@ async function handlePropertySet() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// 服务调用
|
// 服务调用
|
||||||
async function handleServiceInvoke(row: ThingModelData) {
|
async function handleServiceInvoke(row: ThingModelApi.ThingModel) {
|
||||||
try {
|
try {
|
||||||
const valueStr = formData.value[row.identifier!];
|
const valueStr = formData.value[row.identifier!];
|
||||||
let params: any = {};
|
let params: any = {};
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
<!-- 设备事件管理 -->
|
<!-- 设备事件管理 -->
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||||
import type { ThingModelData } from '#/api/iot/thingmodel';
|
import type { ThingModelApi } from '#/api/iot/thingmodel';
|
||||||
|
|
||||||
import { computed, onMounted, reactive, watch } from 'vue';
|
import { computed, onMounted, reactive, watch } from 'vue';
|
||||||
|
|
||||||
|
|
@ -21,7 +21,7 @@ import {
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
deviceId: number;
|
deviceId: number;
|
||||||
thingModelList: ThingModelData[];
|
thingModelList: ThingModelApi.ThingModel[];
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
/** 查询参数 */
|
/** 查询参数 */
|
||||||
|
|
@ -33,7 +33,7 @@ const queryParams = reactive({
|
||||||
/** 事件类型的物模型数据 */
|
/** 事件类型的物模型数据 */
|
||||||
const eventThingModels = computed(() => {
|
const eventThingModels = computed(() => {
|
||||||
return props.thingModelList.filter(
|
return props.thingModelList.filter(
|
||||||
(item: ThingModelData) =>
|
(item: ThingModelApi.ThingModel) =>
|
||||||
String(item.type) === String(IoTThingModelTypeEnum.EVENT),
|
String(item.type) === String(IoTThingModelTypeEnum.EVENT),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
@ -123,7 +123,7 @@ function resetQuery() {
|
||||||
function getEventName(identifier: string | undefined) {
|
function getEventName(identifier: string | undefined) {
|
||||||
if (!identifier) return '-';
|
if (!identifier) return '-';
|
||||||
const event = eventThingModels.value.find(
|
const event = eventThingModels.value.find(
|
||||||
(item: ThingModelData) => item.identifier === identifier,
|
(item: ThingModelApi.ThingModel) => item.identifier === identifier,
|
||||||
);
|
);
|
||||||
return event?.name || identifier;
|
return event?.name || identifier;
|
||||||
}
|
}
|
||||||
|
|
@ -132,7 +132,7 @@ function getEventName(identifier: string | undefined) {
|
||||||
function getEventType(identifier: string | undefined) {
|
function getEventType(identifier: string | undefined) {
|
||||||
if (!identifier) return '-';
|
if (!identifier) return '-';
|
||||||
const event = eventThingModels.value.find(
|
const event = eventThingModels.value.find(
|
||||||
(item: ThingModelData) => item.identifier === identifier,
|
(item: ThingModelApi.ThingModel) => item.identifier === identifier,
|
||||||
);
|
);
|
||||||
if (!event?.event?.type) return '-';
|
if (!event?.event?.type) return '-';
|
||||||
return getEventTypeLabel(event.event.type) || '-';
|
return getEventTypeLabel(event.event.type) || '-';
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
<!-- 设备服务调用 -->
|
<!-- 设备服务调用 -->
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||||
import type { ThingModelData } from '#/api/iot/thingmodel';
|
import type { ThingModelApi } from '#/api/iot/thingmodel';
|
||||||
|
|
||||||
import { computed, onMounted, reactive, watch } from 'vue';
|
import { computed, onMounted, reactive, watch } from 'vue';
|
||||||
|
|
||||||
|
|
@ -21,7 +21,7 @@ import {
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
deviceId: number;
|
deviceId: number;
|
||||||
thingModelList: ThingModelData[];
|
thingModelList: ThingModelApi.ThingModel[];
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
/** 查询参数 */
|
/** 查询参数 */
|
||||||
|
|
@ -33,7 +33,7 @@ const queryParams = reactive({
|
||||||
/** 服务类型的物模型数据 */
|
/** 服务类型的物模型数据 */
|
||||||
const serviceThingModels = computed(() => {
|
const serviceThingModels = computed(() => {
|
||||||
return props.thingModelList.filter(
|
return props.thingModelList.filter(
|
||||||
(item: ThingModelData) =>
|
(item: ThingModelApi.ThingModel) =>
|
||||||
String(item.type) === String(IoTThingModelTypeEnum.SERVICE),
|
String(item.type) === String(IoTThingModelTypeEnum.SERVICE),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
@ -136,7 +136,7 @@ function resetQuery() {
|
||||||
function getServiceName(identifier: string | undefined) {
|
function getServiceName(identifier: string | undefined) {
|
||||||
if (!identifier) return '-';
|
if (!identifier) return '-';
|
||||||
const service = serviceThingModels.value.find(
|
const service = serviceThingModels.value.find(
|
||||||
(item: ThingModelData) => item.identifier === identifier,
|
(item: ThingModelApi.ThingModel) => item.identifier === identifier,
|
||||||
);
|
);
|
||||||
return service?.name || identifier;
|
return service?.name || identifier;
|
||||||
}
|
}
|
||||||
|
|
@ -145,7 +145,7 @@ function getServiceName(identifier: string | undefined) {
|
||||||
function getCallType(identifier: string | undefined) {
|
function getCallType(identifier: string | undefined) {
|
||||||
if (!identifier) return '-';
|
if (!identifier) return '-';
|
||||||
const service = serviceThingModels.value.find(
|
const service = serviceThingModels.value.find(
|
||||||
(item: ThingModelData) => item.identifier === identifier,
|
(item: ThingModelApi.ThingModel) => item.identifier === identifier,
|
||||||
);
|
);
|
||||||
if (!service?.service?.callType) return '-';
|
if (!service?.service?.callType) return '-';
|
||||||
return getThingModelServiceCallTypeLabel(service.service.callType) || '-';
|
return getThingModelServiceCallTypeLabel(service.service.callType) || '-';
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
<!-- 设备物模型:设备属性、事件管理、服务调用 -->
|
<!-- 设备物模型:设备属性、事件管理、服务调用 -->
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import type { ThingModelData } from '#/api/iot/thingmodel';
|
import type { ThingModelApi } from '#/api/iot/thingmodel';
|
||||||
|
|
||||||
import { ref } from 'vue';
|
import { ref } from 'vue';
|
||||||
|
|
||||||
|
|
@ -14,7 +14,7 @@ import DeviceDetailsThingModelService from './thing-model-service.vue';
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
deviceId: number;
|
deviceId: number;
|
||||||
thingModelList: ThingModelData[];
|
thingModelList: ThingModelApi.ThingModel[];
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
const activeTab = ref('property'); // 默认选中设备属性
|
const activeTab = ref('property'); // 默认选中设备属性
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue