浏览代码

fix:【修复】产品跳转到设备列表时,productId 未传递的问题,对应 https://t.zsxq.com/jvXyq

YunaiV 4 月之前
父节点
当前提交
bdb42bb927

+ 8 - 2
src/views/iot/device/device/index.vue

@@ -384,6 +384,7 @@ defineOptions({ name: 'IoTDevice' })
 
 const message = useMessage() // 消息弹窗
 const { t } = useI18n() // 国际化
+const route = useRoute()
 
 const loading = ref(true) // 列表加载中
 const list = ref<DeviceVO[]>([]) // 列表的数据
@@ -392,7 +393,7 @@ const queryParams = reactive({
   pageNo: 1,
   pageSize: 10,
   deviceName: undefined,
-  productId: undefined,
+  productId: undefined as number | undefined,
   deviceType: undefined,
   nickname: undefined,
   status: undefined,
@@ -513,7 +514,12 @@ const handleImport = () => {
 
 /** 初始化 **/
 onMounted(async () => {
-  getList()
+  // 处理 productId 参数
+  const { productId } = route.query
+  if (productId) {
+    queryParams.productId = Number(productId)
+  }
+  await getList()
 
   // 获取产品列表
   products.value = await ProductApi.getSimpleProductList()

+ 1 - 1
src/views/iot/product/product/detail/ProductDetailsHeader.vue

@@ -72,7 +72,7 @@ const copyToClipboard = async (text: string) => {
 /** 路由跳转到设备管理 */
 const { push } = useRouter()
 const goToDeviceList = (productId: number) => {
-  push({ name: 'IoTDevice', params: { productId } })
+  push({ name: 'IoTDevice', query: { productId } })
 }
 
 /** 修改操作 */