diff --git a/src/api/iot/device/index.ts b/src/api/iot/device/index.ts index 4f61d56d..2106e75a 100644 --- a/src/api/iot/device/index.ts +++ b/src/api/iot/device/index.ts @@ -91,6 +91,11 @@ export const DeviceApi = { return await request.get({ url: `/iot/device/count?productId=` + productId }) }, + // 获取设备的精简信息列表 + getSimpleDeviceList: async (deviceType?: number) => { + return await request.get({ url: `/iot/device/simple-list?`, params: { deviceType } }) + }, + // 获取设备属性最新数据 getDevicePropertiesLatestData: async (params: any) => { return await request.get({ url: `/iot/device/data/latest`, params }) diff --git a/src/views/iot/device/DeviceForm.vue b/src/views/iot/device/device/DeviceForm.vue similarity index 55% rename from src/views/iot/device/DeviceForm.vue rename to src/views/iot/device/device/DeviceForm.vue index 95eff822..138498b1 100644 --- a/src/views/iot/device/DeviceForm.vue +++ b/src/views/iot/device/device/DeviceForm.vue @@ -13,6 +13,7 @@ placeholder="请选择产品" :disabled="formType === 'update'" clearable + @change="handleProductChange" > + + + + + - - + + + + + + + + + + + + + + + + + + diff --git a/src/views/iot/device/detail/DeviceDataDetail.vue b/src/views/iot/device/device/detail/DeviceDataDetail.vue similarity index 100% rename from src/views/iot/device/detail/DeviceDataDetail.vue rename to src/views/iot/device/device/detail/DeviceDataDetail.vue diff --git a/src/views/iot/device/detail/DeviceDetailsHeader.vue b/src/views/iot/device/device/detail/DeviceDetailsHeader.vue similarity index 100% rename from src/views/iot/device/detail/DeviceDetailsHeader.vue rename to src/views/iot/device/device/detail/DeviceDetailsHeader.vue diff --git a/src/views/iot/device/detail/DeviceDetailsInfo.vue b/src/views/iot/device/device/detail/DeviceDetailsInfo.vue similarity index 100% rename from src/views/iot/device/detail/DeviceDetailsInfo.vue rename to src/views/iot/device/device/detail/DeviceDetailsInfo.vue diff --git a/src/views/iot/device/detail/DeviceDetailsModel.vue b/src/views/iot/device/device/detail/DeviceDetailsModel.vue similarity index 100% rename from src/views/iot/device/detail/DeviceDetailsModel.vue rename to src/views/iot/device/device/detail/DeviceDetailsModel.vue diff --git a/src/views/iot/device/detail/index.vue b/src/views/iot/device/device/detail/index.vue similarity index 100% rename from src/views/iot/device/detail/index.vue rename to src/views/iot/device/device/detail/index.vue diff --git a/src/views/iot/device/index.vue b/src/views/iot/device/device/index.vue similarity index 100% rename from src/views/iot/device/index.vue rename to src/views/iot/device/device/index.vue diff --git a/src/views/iot/product/product/ProductForm.vue b/src/views/iot/product/product/ProductForm.vue index f7fe4087..e4eec674 100644 --- a/src/views/iot/product/product/ProductForm.vue +++ b/src/views/iot/product/product/ProductForm.vue @@ -12,7 +12,13 @@ v-model="formData.productKey" placeholder="请输入 ProductKey" :readonly="formType === 'update'" - /> + > + + @@ -184,7 +190,7 @@ const open = async (type: string, id?: number) => { } } else { // 新增时,生成随机 productKey - formData.value.productKey = generateRandomStr(16) + generateProductKey() } // 加载分类列表 categoryList.value = await ProductCategoryApi.getSimpleProductCategoryList() @@ -231,4 +237,9 @@ const resetForm = () => { } formRef.value?.resetFields() } + +/** 生成 ProductKey */ +const generateProductKey = () => { + formData.value.productKey = generateRandomStr(16) +} diff --git a/src/views/iot/product/product/detail/ProductTopic.vue b/src/views/iot/product/product/detail/ProductTopic.vue index 1e95da5a..a691a614 100644 --- a/src/views/iot/product/product/detail/ProductTopic.vue +++ b/src/views/iot/product/product/detail/ProductTopic.vue @@ -3,9 +3,9 @@
() -// 定义列 -const columns1 = reactive([ +// TODO 芋艿:不确定未来会不会改,所以先写死 + +// 基础通信 Topic 列 +const basicColumn = reactive([ { label: '功能', field: 'function', width: 150 }, { label: 'Topic 类', field: 'topicClass', width: 800 }, { label: '操作权限', field: 'operationPermission', width: 100 }, { label: '描述', field: 'description' } ]) -const columns2 = reactive([ - { label: '功能', field: 'function', width: 150 }, - { label: 'Topic 类', field: 'topicClass', width: 800 }, - { label: '操作权限', field: 'operationPermission', width: 100 }, - { label: '描述', field: 'description' } -]) - -// TODO @haohao:这个,有没可能写到一个枚举里,方便后续维护? /Users/yunai/Java/yudao-ui-admin-vue3/src/views/ai/utils/constants.ts -const data1 = computed(() => { +// 基础通信 Topic 数据 +const basicData = computed(() => { if (!props.product || !props.product.productKey) return [] return [ { @@ -147,7 +142,16 @@ const data1 = computed(() => { ] }) -const data2 = computed(() => { +// 物模型通信 Topic 列 +const functionColumn = reactive([ + { label: '功能', field: 'function', width: 150 }, + { label: 'Topic 类', field: 'topicClass', width: 800 }, + { label: '操作权限', field: 'operationPermission', width: 100 }, + { label: '描述', field: 'description' } +]) + +// 物模型通信 Topic 数据 +const functionData = computed(() => { if (!props.product || !props.product.productKey) return [] return [ { diff --git a/src/views/iot/product/product/detail/index.vue b/src/views/iot/product/product/detail/index.vue index 5c4a32f6..baca1021 100644 --- a/src/views/iot/product/product/detail/index.vue +++ b/src/views/iot/product/product/detail/index.vue @@ -36,7 +36,7 @@ const message = useMessage() const id = Number(route.params.id) // 编号 const loading = ref(true) // 加载中 const product = ref({} as ProductVO) // 详情 -const activeTab = ref('info') // 默认激活的标签页 +const activeTab = ref('info') // 默认为 info 标签页 /** 获取详情 */ const getProductData = async (id: number) => { @@ -66,6 +66,11 @@ onMounted(async () => { return } await getProductData(id) + // 处理 tab 参数 + const { tab } = route.query + if (tab) { + activeTab.value = tab as string + } // 查询设备数量 if (product.value.id) { product.value.deviceCount = await getDeviceCount(product.value.id) diff --git a/src/views/iot/product/product/index.vue b/src/views/iot/product/product/index.vue index 09bd1773..1e48a594 100644 --- a/src/views/iot/product/product/index.vue +++ b/src/views/iot/product/product/index.vue @@ -63,96 +63,89 @@ -
- - -
- -
-
- + + + + +
+ +
+
+ +
+
{{ item.name }}
-
{{ item.name }}
-
- -
-
-
- 产品分类 - {{ item.categoryName }} + +
+
+
+ 产品分类 + {{ item.categoryName }} +
+
+ 产品类型 + +
+
+ 产品标识 + {{ item.productKey }} +
-
- 产品类型 - -
-
- 产品标识 - {{ item.productKey }} +
+
-
- + + + + + +
+ + + 编辑 + + + + 详情 + + + + 物模型 + +
+ + +
- - - - - -
- - - 编辑 - - - - 详情 - - - - 物模型 - -
- - - -
-
- -
+ + + @@ -251,8 +244,11 @@ defineOptions({ name: 'IoTProduct' }) const message = useMessage() // 消息弹窗 const { t } = useI18n() // 国际化 +const { push } = useRouter() +const route = useRoute() const loading = ref(true) // 列表的加载中 +const activeName = ref('info') // 当前激活的标签页 const list = ref([]) // 列表的数据 const total = ref(0) // 列表的总页数 const queryParams = reactive({ @@ -296,11 +292,19 @@ const openForm = (type: string, id?: number) => { } /** 打开详情 */ -const { push } = useRouter() const openDetail = (id: number) => { push({ name: 'IoTProductDetail', params: { id } }) } +/** 打开物模型 */ +const openObjectModel = (item: ProductVO) => { + push({ + name: 'IoTProductDetail', + params: { id: item.id }, + query: { tab: 'function' } + }) +} + /** 删除按钮操作 */ const handleDelete = async (id: number) => { try { @@ -332,5 +336,10 @@ const handleExport = async () => { /** 初始化 **/ onMounted(() => { getList() + // 处理 tab 参数 + const { tab } = route.query + if (tab) { + activeName.value = tab as string + } })