feat: 远程升级 升级任务详情

This commit is contained in:
jackhoo_98 2023-02-25 21:44:23 +08:00
parent d226d8758f
commit c3b8d46e7c
3 changed files with 97 additions and 87 deletions

View File

@ -57,6 +57,7 @@ const iconKeys = [
'DownloadOutlined', 'DownloadOutlined',
'PauseOutlined', 'PauseOutlined',
'ControlOutlined', 'ControlOutlined',
'RedoOutlined',
] ]
const Icon = (props: {type: string}) => { const Icon = (props: {type: string}) => {

View File

@ -0,0 +1,32 @@
<template lang="">
<a-modal
title="查看"
ok-text="确认"
cancel-text="取消"
:visible="true"
width="500px"
@cancel="handleCancel"
@ok="handleOk"
>
<span>失败原因{{ data }}</span>
</a-modal>
</template>
<script lang="ts" setup name="TaskDetailSavePage">
const props = defineProps({
data: {
type: Object,
default: () => {},
},
});
const emit = defineEmits(['change']);
const handleOk = () => {
handleCancel();
};
const handleCancel = () => {
emit('change', false);
};
</script>
<style lang="less" scoped></style>

View File

@ -17,22 +17,27 @@
</div> </div>
<div class="state-title-right"> <div class="state-title-right">
<a-popconfirm <div>
title="确定批量重试?" <a-popconfirm
ok-text="确定" title="确定批量重试?"
cancel-text="取消" ok-text="确定"
@confirm="confirm" cancel-text="取消"
v-if=" @confirm="confirm"
item.key === 'failed' && v-if="
stateInfo?.mode?.value === 'push' item.key === 'failed' &&
" stateInfo?.mode?.value === 'push'
> "
<a href="#">批量重试</a> >
</a-popconfirm> <a href="#">批量重试</a>
<img </a-popconfirm>
:src="buttonImg" </div>
@click="handleRefresh(item.key)"
/> <div class="img">
<img
:src="buttonImg"
@click="handleRefresh(item.key)"
/>
</div>
</div> </div>
</div> </div>
<div class="state-box"> <div class="state-box">
@ -114,6 +119,7 @@
</a-space> </a-space>
</template> </template>
</JTable> </JTable>
<Save :data="current" v-if="visible" @change="saveChange" />
</div> </div>
</page-container> </page-container>
</template> </template>
@ -124,12 +130,14 @@ import {
history, history,
historyCount, historyCount,
queryProduct, queryProduct,
startTask,
startOneTask,
} from '@/api/device/firmware'; } from '@/api/device/firmware';
import { message } from 'ant-design-vue'; import { message } from 'ant-design-vue';
import { getImage } from '@/utils/comm'; import { getImage } from '@/utils/comm';
import moment from 'moment'; import moment from 'moment';
import { cloneDeep } from 'lodash-es'; import { cloneDeep } from 'lodash-es';
import Save from './Save.vue';
const tableRef = ref<Record<string, any>>({}); const tableRef = ref<Record<string, any>>({});
const router = useRouter(); const router = useRouter();
const route = useRoute(); const route = useRoute();
@ -276,22 +284,7 @@ const getActions = (data: Partial<Record<string, any>>): ActionsType[] => {
if (!data) { if (!data) {
return []; return [];
} }
const stop = data.waiting > 0 && data?.state?.value === 'processing';
const pause = data?.state?.value === 'canceled';
const Actions = [ const Actions = [
{
key: 'details',
text: '详情',
tooltip: {
title: '详情',
},
icon: 'icon-details',
onClick: async () => {
handlDetails(data.id);
},
},
{ {
key: 'eye', key: 'eye',
text: '查看', text: '查看',
@ -300,45 +293,21 @@ const getActions = (data: Partial<Record<string, any>>): ActionsType[] => {
}, },
icon: 'EyeOutlined', icon: 'EyeOutlined',
onClick: async () => { onClick: async () => {
handlEye(data); handlEye(data.errorReason);
},
},
{
key: 'try',
text: '重试',
tooltip: {
title: '重试',
},
icon: 'RedoOutlined',
onClick: async () => {
handlTry(data.id);
}, },
}, },
]; ];
if (stop) {
Actions.push({
key: 'actions',
text: '停止',
tooltip: {
title: '停止',
},
onClick: async () => {
const res = await stopTask(data.id);
if (res.success) {
message.success('操作成功');
tableRef.value.reload();
}
},
icon: 'StopOutlined',
});
} else if (pause) {
Actions.push({
key: 'actions',
text: '继续升级',
tooltip: {
title: '继续升级',
},
onClick: async () => {
const res = await startTask(data.id, ['canceled']);
if (res.success) {
message.success('操作成功');
tableRef.value.reload();
}
},
icon: 'ControlOutlined',
});
}
return Actions; return Actions;
}; };
@ -347,28 +316,29 @@ const handlAdd = () => {
visible.value = true; visible.value = true;
}; };
const handlEye = (data: object) => { const handlEye = (data: string) => {
current.value = toRaw({ ...data, view: true }); current.value = data || '';
visible.value = true; visible.value = true;
}; };
const handlDetails = (id: string) => { const handlTry = async (id: string) => {
// router.push({ const res = await startOneTask([id]);
// path: `/iot/link/certificate/detail/${id}`, if (res.success) {
// query: { view: false },
// });
};
const saveChange = (value: boolean) => {
visible.value = false;
current.value = {};
if (value) {
message.success('操作成功'); message.success('操作成功');
tableRef.value.reload(); tableRef.value.reload();
} }
}; };
const confirm = (e: MouseEvent) => { const saveChange = (value: boolean) => {
console.log(e); visible.value = false;
message.success('Click on Yes'); current.value = {};
};
const confirm = async (e: MouseEvent) => {
const res = await startTask(taskId, ['failed']);
if (res.success) {
message.success('操作成功');
handleRefresh('failed');
tableRef.value.reload();
}
}; };
const handleRefresh = async (key: string) => { const handleRefresh = async (key: string) => {
@ -416,6 +386,7 @@ const handleSearch = (e: any) => {
rgba(255, 255, 255, 0.86) 91.82% rgba(255, 255, 255, 0.86) 91.82%
); );
min-width: 185px; min-width: 185px;
max-width: 580px;
flex: 1px; flex: 1px;
margin: 0 12px; margin: 0 12px;
.state-content { .state-content {
@ -430,12 +401,18 @@ const handleSearch = (e: any) => {
height: 22px; height: 22px;
.state-title-right { .state-title-right {
z-index: 1; z-index: 1;
img { display: flex;
margin: 0 10px; .img {
width: 22px; width: 22px;
// margin-top: -12px; margin: 0 10px;
margin-top: -5px;
cursor: pointer; cursor: pointer;
img {
width: 22px;
margin-top: -5px;
}
}
.img:active {
border: 1px #40a9ff solid;
} }
} }
} }