feat(iot):优化 ota 的代码风格(v4)

pull/345/head
YunaiV 2026-05-19 14:51:54 +08:00
parent 0bc1981675
commit b9a7eddb72
6 changed files with 5 additions and 24 deletions

View File

@ -1,5 +1,4 @@
<script setup lang="ts">
// TODO DONE @AI firmware/modules/form.vue alert/config/modules/form.vue
import type { IoTOtaFirmwareApi } from '#/api/iot/ota/firmware';
import { computed, ref } from 'vue';
@ -18,8 +17,6 @@ import { $t } from '#/locales';
import { useFormSchema } from '../data';
defineOptions({ name: 'IoTOtaFirmwareForm' });
const emit = defineEmits<{
success: [];
}>();

View File

@ -14,10 +14,6 @@ import OtaTaskRecordList from '../record/modules/list.vue';
import TaskInfo from './info.vue';
import UpgradeStatistics from './statistics.vue';
// TODO @AIdefineOptions
/** IoT OTA 升级任务详情 */
defineOptions({ name: 'IoTOtaTaskDetail' });
const emit = defineEmits(['success']);
const taskId = ref<number>();

View File

@ -12,10 +12,6 @@ import { $t } from '#/locales';
import { useFormSchema } from '../data';
// TODO @AIdefineOptions
/** IoT OTA 升级任务表单 */
defineOptions({ name: 'IoTOtaTaskForm' });
const emit = defineEmits(['success']);
const [Form, formApi] = useVbenForm({
@ -29,7 +25,6 @@ const [Form, formApi] = useVbenForm({
showDefaultActions: false,
});
// TODO @AI form
const [Modal, modalApi] = useVbenModal({
async onConfirm() {
const { valid } = await formApi.validate();
@ -37,9 +32,11 @@ const [Modal, modalApi] = useVbenModal({
return;
}
modalApi.lock();
//
const data = (await formApi.getValues()) as IoTOtaTaskApi.Task;
try {
const data = (await formApi.getValues()) as IoTOtaTaskApi.Task;
await createOtaTask(data);
//
await modalApi.close();
emit('success');
message.success($t('ui.actionMessage.operationSuccess'));
@ -51,6 +48,7 @@ const [Modal, modalApi] = useVbenModal({
if (!isOpen) {
return;
}
//
const data = modalApi.getData<{ firmwareId: number; productId: number }>();
if (!data?.firmwareId || !data?.productId) {
return;
@ -61,6 +59,7 @@ const [Modal, modalApi] = useVbenModal({
await formApi.setValues({ firmwareId: data.firmwareId });
//
const devices = (await getDeviceListByProductId(data.productId)) || [];
// deviceIds options
formApi.updateSchema([
{
fieldName: 'deviceIds',

View File

@ -7,10 +7,6 @@ import { useDescription } from '#/components/description';
import { useDetailSchema } from '../data';
// TODO @AI
/** IoT OTA 升级任务基本信息 */
defineOptions({ name: 'IoTOtaTaskInfo' });
defineProps<{
loading?: boolean;
task: IoTOtaTaskApi.Task;

View File

@ -1,5 +1,4 @@
<script setup lang="ts">
// TODO @AI statistics.vue
import { computed } from 'vue';
import { DICT_TYPE } from '@vben/constants';

View File

@ -15,10 +15,6 @@ import { IoTOtaTaskRecordStatusEnum } from '#/views/iot/utils/constants';
import { useGridColumns } from '../data';
/** IoT OTA 升级记录列表 */
// TODO @AIdefineOptions({ name: 'IoTOtaTaskRecordList' });
defineOptions({ name: 'IoTOtaTaskRecordList' });
const props = defineProps<{
taskId: number | undefined;
}>();
@ -48,7 +44,6 @@ async function handleTabChange(tabKey: number | string) {
}
/** 取消单条记录的升级 */
// TODO @AI
async function handleCancelUpgrade(record: IoTOtaTaskRecordApi.TaskRecord) {
await cancelOtaTaskRecord(record.id as number);
message.success('取消成功');
@ -77,7 +72,6 @@ const [Grid, gridApi] = useVbenVxeGrid({
pageNo: page.currentPage,
pageSize: page.pageSize,
taskId: props.taskId,
// TODO @AI formValues
status: activeTab.value === '' ? undefined : Number(activeTab.value),
});
},