feat(iot):优化 ota 的代码风格(v4)
parent
0bc1981675
commit
b9a7eddb72
|
|
@ -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: [];
|
||||
}>();
|
||||
|
|
|
|||
|
|
@ -14,10 +14,6 @@ import OtaTaskRecordList from '../record/modules/list.vue';
|
|||
import TaskInfo from './info.vue';
|
||||
import UpgradeStatistics from './statistics.vue';
|
||||
|
||||
// TODO @AI:是不是defineOptions、升级任务详情 注释需要?
|
||||
/** IoT OTA 升级任务详情 */
|
||||
defineOptions({ name: 'IoTOtaTaskDetail' });
|
||||
|
||||
const emit = defineEmits(['success']);
|
||||
|
||||
const taskId = ref<number>();
|
||||
|
|
|
|||
|
|
@ -12,10 +12,6 @@ import { $t } from '#/locales';
|
|||
|
||||
import { useFormSchema } from '../data';
|
||||
|
||||
// TODO @AI:是不是defineOptions、升级任务表单 注释需要?
|
||||
/** 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',
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
<script setup lang="ts">
|
||||
// TODO @AI:是不是改成 statistics.vue 简化掉?
|
||||
import { computed } from 'vue';
|
||||
|
||||
import { DICT_TYPE } from '@vben/constants';
|
||||
|
|
|
|||
|
|
@ -15,10 +15,6 @@ import { IoTOtaTaskRecordStatusEnum } from '#/views/iot/utils/constants';
|
|||
|
||||
import { useGridColumns } from '../data';
|
||||
|
||||
/** IoT OTA 升级记录列表 */
|
||||
// TODO @AI:defineOptions({ 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),
|
||||
});
|
||||
},
|
||||
|
|
|
|||
Loading…
Reference in New Issue