feat(iot):优化 ota 的代码风格(v6)
parent
ab15c884bf
commit
8bcfa20577
|
|
@ -17,7 +17,7 @@ const route = useRoute();
|
||||||
|
|
||||||
const firmwareId = ref(Number(route.params.id));
|
const firmwareId = ref(Number(route.params.id));
|
||||||
const firmwareLoading = ref(false);
|
const firmwareLoading = ref(false);
|
||||||
const firmware = ref<IoTOtaFirmwareApi.Firmware>({} as IoTOtaFirmwareApi.Firmware);
|
const firmware = ref<IoTOtaFirmwareApi.Firmware>();
|
||||||
|
|
||||||
const firmwareStatisticsLoading = ref(false);
|
const firmwareStatisticsLoading = ref(false);
|
||||||
const firmwareStatistics = ref<Record<string, number>>({});
|
const firmwareStatistics = ref<Record<string, number>>({});
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ import { useDetailSchema } from '../../data';
|
||||||
|
|
||||||
/** IoT OTA 固件基本信息 */
|
/** IoT OTA 固件基本信息 */
|
||||||
defineProps<{
|
defineProps<{
|
||||||
firmware: IoTOtaFirmwareApi.Firmware;
|
firmware?: IoTOtaFirmwareApi.Firmware;
|
||||||
loading?: boolean;
|
loading?: boolean;
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,7 @@ async function handleDelete(row: IoTOtaFirmwareApi.Firmware) {
|
||||||
duration: 0,
|
duration: 0,
|
||||||
});
|
});
|
||||||
try {
|
try {
|
||||||
await deleteOtaFirmware(row.id as number);
|
await deleteOtaFirmware(row.id!);
|
||||||
message.success({
|
message.success({
|
||||||
content: $t('ui.actionMessage.deleteSuccess', [row.name]),
|
content: $t('ui.actionMessage.deleteSuccess', [row.name]),
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -97,7 +97,6 @@ export function useFormSchema(): VbenFormSchema[] {
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO DONE @AI:任务列表内嵌固件详情页,单字段搜索意义不大,已去掉搜索表单
|
|
||||||
/** 任务列表的字段 */
|
/** 任务列表的字段 */
|
||||||
export function useGridColumns(): VxeTableGridOptions['columns'] {
|
export function useGridColumns(): VxeTableGridOptions['columns'] {
|
||||||
return [
|
return [
|
||||||
|
|
@ -164,5 +163,3 @@ export function useGridColumns(): VxeTableGridOptions['columns'] {
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO DONE @AI:record schema 已挪到 task/record/data.ts;list 也独立成 task/record/modules/list.vue
|
|
||||||
|
|
|
||||||
|
|
@ -6,9 +6,7 @@ import { ref } from 'vue';
|
||||||
import { useVbenModal } from '@vben/common-ui';
|
import { useVbenModal } from '@vben/common-ui';
|
||||||
|
|
||||||
import { getOtaTask } from '#/api/iot/ota/task';
|
import { getOtaTask } from '#/api/iot/ota/task';
|
||||||
import {
|
import { getOtaTaskRecordStatusStatistics } from '#/api/iot/ota/task/record';
|
||||||
getOtaTaskRecordStatusStatistics,
|
|
||||||
} from '#/api/iot/ota/task/record';
|
|
||||||
|
|
||||||
import OtaTaskRecordList from '../record/modules/list.vue';
|
import OtaTaskRecordList from '../record/modules/list.vue';
|
||||||
import TaskInfo from './info.vue';
|
import TaskInfo from './info.vue';
|
||||||
|
|
@ -18,7 +16,7 @@ const emit = defineEmits(['success']);
|
||||||
|
|
||||||
const taskId = ref<number>();
|
const taskId = ref<number>();
|
||||||
const taskLoading = ref(false);
|
const taskLoading = ref(false);
|
||||||
const task = ref<IoTOtaTaskApi.Task>({} as IoTOtaTaskApi.Task);
|
const task = ref<IoTOtaTaskApi.Task>();
|
||||||
|
|
||||||
const taskStatisticsLoading = ref(false);
|
const taskStatisticsLoading = ref(false);
|
||||||
const taskStatistics = ref<Record<string, number>>({});
|
const taskStatistics = ref<Record<string, number>>({});
|
||||||
|
|
@ -53,7 +51,7 @@ async function getStatistics() {
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 单条记录取消后,刷新任务信息和统计 */
|
/** 单条记录取消后,刷新任务信息和统计 */
|
||||||
async function handleRecordCancelled() {
|
async function handleRecordSuccess() {
|
||||||
await getStatistics();
|
await getStatistics();
|
||||||
await getTaskInfo();
|
await getTaskInfo();
|
||||||
emit('success');
|
emit('success');
|
||||||
|
|
@ -92,7 +90,7 @@ const [Modal, modalApi] = useVbenModal({
|
||||||
</div>
|
</div>
|
||||||
<!-- 升级设备记录 -->
|
<!-- 升级设备记录 -->
|
||||||
<div class="mt-4">
|
<div class="mt-4">
|
||||||
<OtaTaskRecordList :task-id="taskId" @cancelled="handleRecordCancelled" />
|
<OtaTaskRecordList :task-id="taskId" @success="handleRecordSuccess" />
|
||||||
</div>
|
</div>
|
||||||
</Modal>
|
</Modal>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
||||||
|
|
@ -83,7 +83,7 @@ const [Modal, modalApi] = useVbenModal({
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<Modal class="w-3/5" title="新增升级任务">
|
<Modal class="w-3/5" :title="$t('ui.actionTitle.create', ['升级任务'])">
|
||||||
<Form class="mx-4" />
|
<Form class="mx-4" />
|
||||||
</Modal>
|
</Modal>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ import { useDetailSchema } from '../data';
|
||||||
|
|
||||||
defineProps<{
|
defineProps<{
|
||||||
loading?: boolean;
|
loading?: boolean;
|
||||||
task: IoTOtaTaskApi.Task;
|
task?: IoTOtaTaskApi.Task;
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
const [Description] = useDescription({
|
const [Description] = useDescription({
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@ import { Input, message } from 'ant-design-vue';
|
||||||
|
|
||||||
import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
|
import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||||
import { cancelOtaTask, getOtaTaskPage } from '#/api/iot/ota/task';
|
import { cancelOtaTask, getOtaTaskPage } from '#/api/iot/ota/task';
|
||||||
|
import { $t } from '#/locales';
|
||||||
import { IoTOtaTaskStatusEnum } from '#/views/iot/utils/constants';
|
import { IoTOtaTaskStatusEnum } from '#/views/iot/utils/constants';
|
||||||
|
|
||||||
import { useGridColumns } from '../data';
|
import { useGridColumns } from '../data';
|
||||||
|
|
@ -60,7 +61,7 @@ function handleDetail(row: IoTOtaTaskApi.Task) {
|
||||||
|
|
||||||
/** 取消任务 */
|
/** 取消任务 */
|
||||||
async function handleCancel(row: IoTOtaTaskApi.Task) {
|
async function handleCancel(row: IoTOtaTaskApi.Task) {
|
||||||
await cancelOtaTask(row.id as number);
|
await cancelOtaTask(row.id!);
|
||||||
message.success('取消成功');
|
message.success('取消成功');
|
||||||
await handleRefresh();
|
await handleRefresh();
|
||||||
}
|
}
|
||||||
|
|
@ -107,18 +108,18 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||||
allow-clear
|
allow-clear
|
||||||
style="width: 200px"
|
style="width: 200px"
|
||||||
@press-enter="handleSearch"
|
@press-enter="handleSearch"
|
||||||
@change="(e: any) => !e.target.value && handleSearch()"
|
@clear="handleSearch"
|
||||||
/>
|
/>
|
||||||
<TableAction
|
<TableAction
|
||||||
:actions="[
|
:actions="[
|
||||||
{
|
{
|
||||||
label: '搜索',
|
label: $t('common.search'),
|
||||||
type: 'default',
|
type: 'default',
|
||||||
icon: 'ant-design:search-outlined',
|
icon: 'ant-design:search-outlined',
|
||||||
onClick: handleSearch,
|
onClick: handleSearch,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: '新增',
|
label: $t('ui.actionTitle.create', ['升级任务']),
|
||||||
type: 'primary',
|
type: 'primary',
|
||||||
icon: ACTION_ICON.ADD,
|
icon: ACTION_ICON.ADD,
|
||||||
auth: ['iot:ota-task:create'],
|
auth: ['iot:ota-task:create'],
|
||||||
|
|
@ -132,14 +133,14 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||||
<TableAction
|
<TableAction
|
||||||
:actions="[
|
:actions="[
|
||||||
{
|
{
|
||||||
label: '详情',
|
label: $t('common.detail'),
|
||||||
type: 'link',
|
type: 'link',
|
||||||
icon: ACTION_ICON.VIEW,
|
icon: ACTION_ICON.VIEW,
|
||||||
auth: ['iot:ota-task:query'],
|
auth: ['iot:ota-task:query'],
|
||||||
onClick: handleDetail.bind(null, row),
|
onClick: handleDetail.bind(null, row),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: '取消',
|
label: $t('common.cancel'),
|
||||||
type: 'link',
|
type: 'link',
|
||||||
danger: true,
|
danger: true,
|
||||||
icon: ACTION_ICON.DELETE,
|
icon: ACTION_ICON.DELETE,
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ import {
|
||||||
cancelOtaTaskRecord,
|
cancelOtaTaskRecord,
|
||||||
getOtaTaskRecordPage,
|
getOtaTaskRecordPage,
|
||||||
} from '#/api/iot/ota/task/record';
|
} from '#/api/iot/ota/task/record';
|
||||||
|
import { $t } from '#/locales';
|
||||||
import { IoTOtaTaskRecordStatusEnum } from '#/views/iot/utils/constants';
|
import { IoTOtaTaskRecordStatusEnum } from '#/views/iot/utils/constants';
|
||||||
|
|
||||||
import { useGridColumns } from '../data';
|
import { useGridColumns } from '../data';
|
||||||
|
|
@ -19,7 +20,7 @@ const props = defineProps<{
|
||||||
taskId: number | undefined;
|
taskId: number | undefined;
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
const emit = defineEmits(['cancelled']);
|
const emit = defineEmits(['success']);
|
||||||
|
|
||||||
const activeTab = ref('');
|
const activeTab = ref('');
|
||||||
|
|
||||||
|
|
@ -43,10 +44,10 @@ async function handleTabChange(tabKey: number | string) {
|
||||||
|
|
||||||
/** 取消单条记录的升级 */
|
/** 取消单条记录的升级 */
|
||||||
async function handleCancelUpgrade(record: IoTOtaTaskRecordApi.TaskRecord) {
|
async function handleCancelUpgrade(record: IoTOtaTaskRecordApi.TaskRecord) {
|
||||||
await cancelOtaTaskRecord(record.id as number);
|
await cancelOtaTaskRecord(record.id!);
|
||||||
message.success('取消成功');
|
message.success('取消成功');
|
||||||
await gridApi.query();
|
await gridApi.query();
|
||||||
emit('cancelled');
|
emit('success');
|
||||||
}
|
}
|
||||||
|
|
||||||
const [Grid, gridApi] = useVbenVxeGrid({
|
const [Grid, gridApi] = useVbenVxeGrid({
|
||||||
|
|
@ -84,15 +85,13 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||||
/** taskId 变化时重新查询 */
|
/** taskId 变化时重新查询 */
|
||||||
watch(
|
watch(
|
||||||
() => props.taskId,
|
() => props.taskId,
|
||||||
(val) => {
|
async (val) => {
|
||||||
if (val) {
|
if (val) {
|
||||||
activeTab.value = '';
|
activeTab.value = '';
|
||||||
gridApi.query();
|
await gridApi.query();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
defineExpose({ refresh: () => gridApi.query() });
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
|
@ -113,7 +112,7 @@ defineExpose({ refresh: () => gridApi.query() });
|
||||||
<TableAction
|
<TableAction
|
||||||
:actions="[
|
:actions="[
|
||||||
{
|
{
|
||||||
label: '取消',
|
label: $t('common.cancel'),
|
||||||
type: 'link',
|
type: 'link',
|
||||||
danger: true,
|
danger: true,
|
||||||
icon: ACTION_ICON.DELETE,
|
icon: ACTION_ICON.DELETE,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue