From 00ee233f14c2c13fe5d93ff4063f84d35b5a1770 Mon Sep 17 00:00:00 2001
From: haohao <1036606149@qq.com>
Date: Tue, 2 Dec 2025 16:17:00 +0800
Subject: [PATCH] =?UTF-8?q?refactor:=E3=80=90antd=E3=80=91=E3=80=90iot?=
=?UTF-8?q?=E3=80=91=E8=AE=BE=E5=A4=87=E5=88=86=E7=BB=84=E5=92=8C=E4=BA=A7?=
=?UTF-8?q?=E5=93=81=E5=88=86=E7=B1=BB=E8=A1=A8=E5=8D=95=E7=AE=80=E5=8C=96?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../src/views/iot/device/group/index.vue | 4 +-
.../{device-group-form.vue => form.vue} | 44 +++++--------------
.../src/views/iot/product/category/index.vue | 4 +-
.../{product-category-form.vue => form.vue} | 13 +-----
4 files changed, 17 insertions(+), 48 deletions(-)
rename apps/web-antd/src/views/iot/device/group/modules/{device-group-form.vue => form.vue} (64%)
rename apps/web-antd/src/views/iot/product/category/modules/{product-category-form.vue => form.vue} (88%)
diff --git a/apps/web-antd/src/views/iot/device/group/index.vue b/apps/web-antd/src/views/iot/device/group/index.vue
index d72341a6b..0d3f7b6ab 100644
--- a/apps/web-antd/src/views/iot/device/group/index.vue
+++ b/apps/web-antd/src/views/iot/device/group/index.vue
@@ -11,12 +11,12 @@ import { deleteDeviceGroup, getDeviceGroupPage } from '#/api/iot/device/group';
import { $t } from '#/locales';
import { useGridColumns, useGridFormSchema } from './data';
-import DeviceGroupForm from './modules/device-group-form.vue';
+import Form from './modules/form.vue';
defineOptions({ name: 'IoTDeviceGroup' });
const [FormModal, formModalApi] = useVbenModal({
- connectedComponent: DeviceGroupForm,
+ connectedComponent: Form,
destroyOnClose: true,
});
diff --git a/apps/web-antd/src/views/iot/device/group/modules/device-group-form.vue b/apps/web-antd/src/views/iot/device/group/modules/form.vue
similarity index 64%
rename from apps/web-antd/src/views/iot/device/group/modules/device-group-form.vue
rename to apps/web-antd/src/views/iot/device/group/modules/form.vue
index 90529de77..3e1a2d521 100644
--- a/apps/web-antd/src/views/iot/device/group/modules/device-group-form.vue
+++ b/apps/web-antd/src/views/iot/device/group/modules/form.vue
@@ -1,4 +1,4 @@
-
-
+
diff --git a/apps/web-antd/src/views/iot/product/category/index.vue b/apps/web-antd/src/views/iot/product/category/index.vue
index 05a56ee6d..3dc7201b7 100644
--- a/apps/web-antd/src/views/iot/product/category/index.vue
+++ b/apps/web-antd/src/views/iot/product/category/index.vue
@@ -14,12 +14,12 @@ import {
import { $t } from '#/locales';
import { useGridColumns, useGridFormSchema } from './data';
-import ProductCategoryForm from './modules/product-category-form.vue';
+import Form from './modules/form.vue';
defineOptions({ name: 'IoTProductCategory' });
const [FormModal, formModalApi] = useVbenModal({
- connectedComponent: ProductCategoryForm,
+ connectedComponent: Form,
destroyOnClose: true,
});
diff --git a/apps/web-antd/src/views/iot/product/category/modules/product-category-form.vue b/apps/web-antd/src/views/iot/product/category/modules/form.vue
similarity index 88%
rename from apps/web-antd/src/views/iot/product/category/modules/product-category-form.vue
rename to apps/web-antd/src/views/iot/product/category/modules/form.vue
index 792c7ddac..df2290639 100644
--- a/apps/web-antd/src/views/iot/product/category/modules/product-category-form.vue
+++ b/apps/web-antd/src/views/iot/product/category/modules/form.vue
@@ -17,8 +17,6 @@ import { $t } from '#/locales';
import { useFormSchema } from '../data';
-// TODO @haohao:应该是 form.vue,不用前缀;
-
const emit = defineEmits(['success']);
const formData = ref();
const getTitle = computed(() => {
@@ -40,7 +38,6 @@ const [Form, formApi] = useVbenForm({
showDefaultActions: false,
});
-// TODO @haohao:参考 apps/web-antd/src/views/system/dept/modules/form.vue 简化 useVbenModal 里的代码;
const [Modal, modalApi] = useVbenModal({
async onConfirm() {
const { valid } = await formApi.validate();
@@ -66,25 +63,19 @@ const [Modal, modalApi] = useVbenModal({
async onOpenChange(isOpen: boolean) {
if (!isOpen) {
formData.value = undefined;
- formApi.resetForm();
return;
}
-
- // 重置表单
- await formApi.resetForm();
-
+ // 加载数据
const data = modalApi.getData();
- // 如果没有数据或没有 id,表示是新增
if (!data || !data.id) {
- formData.value = undefined;
// 新增模式:设置默认值
+ formData.value = undefined;
await formApi.setValues({
sort: 0,
status: 1,
});
return;
}
-
// 编辑模式:加载数据
modalApi.lock();
try {