diff --git a/apps/web-antd/src/views/iot/ota/firmware/data.ts b/apps/web-antd/src/views/iot/ota/firmware/data.ts
index 19904b469..9d0801ca7 100644
--- a/apps/web-antd/src/views/iot/ota/firmware/data.ts
+++ b/apps/web-antd/src/views/iot/ota/firmware/data.ts
@@ -12,6 +12,14 @@ import { getRangePickerDefaultProps } from '#/utils';
let productList: IotProductApi.Product[] = [];
getSimpleProductList().then((data) => (productList = data));
+/** 根据产品 ID 取产品名称 */
+export function getProductName(productId?: number): string {
+ if (!productId) {
+ return '-';
+ }
+ return productList.find((p) => p.id === productId)?.name || '-';
+}
+
/** 固件详情的描述字段 */
export function useDetailSchema(): DescriptionItemSchema[] {
return [
@@ -58,6 +66,10 @@ export function useFormSchema(): VbenFormSchema[] {
placeholder: '请选择产品',
},
rules: 'required',
+ dependencies: {
+ triggerFields: ['id'],
+ show: (values) => !values.id,
+ },
},
{
fieldName: 'version',
@@ -67,6 +79,10 @@ export function useFormSchema(): VbenFormSchema[] {
placeholder: '请输入版本号',
},
rules: 'required',
+ dependencies: {
+ triggerFields: ['id'],
+ show: (values) => !values.id,
+ },
},
{
fieldName: 'description',
@@ -88,6 +104,10 @@ export function useFormSchema(): VbenFormSchema[] {
helpText: '支持上传 .bin、.hex、.zip 格式的固件文件,最大 50MB',
},
rules: 'required',
+ dependencies: {
+ triggerFields: ['id'],
+ show: (values) => !values.id,
+ },
},
];
}
@@ -131,7 +151,6 @@ export function useGridFormSchema(): VbenFormSchema[] {
/** 列表的字段 */
export function useGridColumns(): VxeTableGridOptions['columns'] {
return [
- { type: 'checkbox', width: 40 },
{
field: 'id',
title: '固件编号',
@@ -156,8 +175,7 @@ export function useGridColumns(): VxeTableGridOptions['columns'] {
field: 'productId',
title: '所属产品',
minWidth: 150,
- formatter: ({ cellValue }) =>
- productList.find((p) => p.id === cellValue)?.name || '-',
+ slots: { default: 'productName' },
},
{
field: 'fileUrl',
diff --git a/apps/web-antd/src/views/iot/ota/firmware/index.vue b/apps/web-antd/src/views/iot/ota/firmware/index.vue
index 70b73c316..912af9c61 100644
--- a/apps/web-antd/src/views/iot/ota/firmware/index.vue
+++ b/apps/web-antd/src/views/iot/ota/firmware/index.vue
@@ -13,7 +13,7 @@ import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
import { deleteOtaFirmware, getOtaFirmwarePage } from '#/api/iot/ota/firmware';
import { $t } from '#/locales';
-import { useGridColumns, useGridFormSchema } from './data';
+import { getProductName, useGridColumns, useGridFormSchema } from './data';
import OtaFirmwareForm from './modules/form.vue';
const { push } = useRouter();
@@ -60,6 +60,11 @@ function handleDetail(row: IoTOtaFirmwareApi.Firmware) {
push({ name: 'IoTOtaFirmwareDetail', params: { id: row.id } });
}
+/** 跳转到产品详情 */
+function handleOpenProductDetail(productId: number) {
+ push({ name: 'IoTProductDetail', params: { id: productId } });
+}
+
const [Grid, gridApi] = useVbenVxeGrid({
formOptions: {
schema: useGridFormSchema(),
@@ -108,6 +113,17 @@ const [Grid, gridApi] = useVbenVxeGrid({
]"
/>
+
+
+
+ {{ getProductName(row.productId) }}
+
+ -
+