diff --git a/src/api/iot/product/product/index.ts b/src/api/iot/product/product/index.ts
index 047dc716..0fa58d54 100644
--- a/src/api/iot/product/product/index.ts
+++ b/src/api/iot/product/product/index.ts
@@ -7,6 +7,7 @@ export interface ProductVO {
productKey: string // 产品标识
protocolId: number // 协议编号
categoryId: number // 产品所属品类标识符
+ categoryName?: string // 产品所属品类名称
description: string // 产品描述
validateType: number // 数据校验级别
status: number // 产品状态
@@ -29,6 +30,11 @@ export enum DeviceTypeEnum {
GATEWAY_SUB = 1, // 网关子设备
GATEWAY = 2 // 网关设备
}
+// IOT 数据格式枚举类
+export enum DataFormatEnum {
+ JSON = 0, // 标准数据格式(JSON)
+ CUSTOMIZE = 1 // 透传/自定义
+}
// IoT 产品 API
export const ProductApi = {
diff --git a/src/utils/index.ts b/src/utils/index.ts
index 2c2fbbd0..059571e7 100644
--- a/src/utils/index.ts
+++ b/src/utils/index.ts
@@ -116,6 +116,20 @@ export function toAnyString() {
return str
}
+/**
+ * 生成指定长度的随机字符串
+ *
+ * @param length 字符串长度
+ */
+export function generateRandomStr(length: number): string {
+ const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'
+ let result = ''
+ for (let i = 0; i < length; i++) {
+ result += chars.charAt(Math.floor(Math.random() * chars.length))
+ }
+ return result
+}
+
/**
* 首字母大写
*/
diff --git a/src/views/iot/product/product/detail/ProductDetailsHeader.vue b/src/views/iot/product/product/detail/ProductDetailsHeader.vue
index 528e174a..841aef9f 100644
--- a/src/views/iot/product/product/detail/ProductDetailsHeader.vue
+++ b/src/views/iot/product/product/detail/ProductDetailsHeader.vue
@@ -45,8 +45,8 @@
- {{ product.deviceCount }}
- 前往管理
+ {{ product.deviceCount ?? '加载中...' }}
+ 前往管理
@@ -73,16 +73,18 @@ const copyToClipboard = async (text: string) => {
/** 路由跳转到设备管理 */
const { push } = useRouter()
-const goToManagement = (productId: string) => {
- push({ name: 'IoTDevice', query: { productId } })
+const goToDeviceList = (productId: number) => {
+ push({ name: 'IoTDevice', params: { productId } })
}
-/** 操作修改 */
+/** 修改操作 */
const emit = defineEmits(['refresh']) // 定义 Emits
const formRef = ref()
const openForm = (type: string, id?: number) => {
formRef.value.open(type, id)
}
+
+/** 发布操作 */
const confirmPublish = async (id: number) => {
try {
await ProductApi.updateProductStatus(id, 1)
@@ -93,6 +95,8 @@ const confirmPublish = async (id: number) => {
message.error('发布失败')
}
}
+
+/** 撤销发布操作 */
const confirmUnpublish = async (id: number) => {
try {
await ProductApi.updateProductStatus(id, 0)
diff --git a/src/views/iot/product/product/detail/ProductDetailsInfo.vue b/src/views/iot/product/product/detail/ProductDetailsInfo.vue
index 3eaa5c14..2601fc85 100644
--- a/src/views/iot/product/product/detail/ProductDetailsInfo.vue
+++ b/src/views/iot/product/product/detail/ProductDetailsInfo.vue
@@ -3,6 +3,7 @@
{{ product.name }}
+ {{ product.categoryName }}
@@ -20,11 +21,14 @@
-
+
{{ product.description }}
@@ -34,7 +38,7 @@