From c3b8d46e7ce323696c6aa462c595de86ef0a9a76 Mon Sep 17 00:00:00 2001 From: jackhoo_98 Date: Sat, 25 Feb 2023 21:44:23 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E8=BF=9C=E7=A8=8B=E5=8D=87=E7=BA=A7=20?= =?UTF-8?q?=E5=8D=87=E7=BA=A7=E4=BB=BB=E5=8A=A1=E8=AF=A6=E6=83=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/AIcon/index.tsx | 1 + .../device/Firmware/Task/Detail/Save.vue | 32 ++++ .../device/Firmware/Task/Detail/index.vue | 151 ++++++++---------- 3 files changed, 97 insertions(+), 87 deletions(-) create mode 100644 src/views/device/Firmware/Task/Detail/Save.vue diff --git a/src/components/AIcon/index.tsx b/src/components/AIcon/index.tsx index 366a7b1c..2c589ac5 100644 --- a/src/components/AIcon/index.tsx +++ b/src/components/AIcon/index.tsx @@ -57,6 +57,7 @@ const iconKeys = [ 'DownloadOutlined', 'PauseOutlined', 'ControlOutlined', + 'RedoOutlined', ] const Icon = (props: {type: string}) => { diff --git a/src/views/device/Firmware/Task/Detail/Save.vue b/src/views/device/Firmware/Task/Detail/Save.vue new file mode 100644 index 00000000..9aca484d --- /dev/null +++ b/src/views/device/Firmware/Task/Detail/Save.vue @@ -0,0 +1,32 @@ + + + + diff --git a/src/views/device/Firmware/Task/Detail/index.vue b/src/views/device/Firmware/Task/Detail/index.vue index 1ddc9b87..dc4f4d29 100644 --- a/src/views/device/Firmware/Task/Detail/index.vue +++ b/src/views/device/Firmware/Task/Detail/index.vue @@ -17,22 +17,27 @@
- - 批量重试 - - +
+ + 批量重试 + +
+ +
+ +
@@ -114,6 +119,7 @@ +
@@ -124,12 +130,14 @@ import { history, historyCount, queryProduct, + startTask, + startOneTask, } from '@/api/device/firmware'; import { message } from 'ant-design-vue'; import { getImage } from '@/utils/comm'; import moment from 'moment'; import { cloneDeep } from 'lodash-es'; - +import Save from './Save.vue'; const tableRef = ref>({}); const router = useRouter(); const route = useRoute(); @@ -276,22 +284,7 @@ const getActions = (data: Partial>): ActionsType[] => { if (!data) { return []; } - - const stop = data.waiting > 0 && data?.state?.value === 'processing'; - const pause = data?.state?.value === 'canceled'; - const Actions = [ - { - key: 'details', - text: '详情', - tooltip: { - title: '详情', - }, - icon: 'icon-details', - onClick: async () => { - handlDetails(data.id); - }, - }, { key: 'eye', text: '查看', @@ -300,45 +293,21 @@ const getActions = (data: Partial>): ActionsType[] => { }, icon: 'EyeOutlined', 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; }; @@ -347,28 +316,29 @@ const handlAdd = () => { visible.value = true; }; -const handlEye = (data: object) => { - current.value = toRaw({ ...data, view: true }); +const handlEye = (data: string) => { + current.value = data || ''; visible.value = true; }; -const handlDetails = (id: string) => { - // router.push({ - // path: `/iot/link/certificate/detail/${id}`, - // query: { view: false }, - // }); -}; -const saveChange = (value: boolean) => { - visible.value = false; - current.value = {}; - if (value) { +const handlTry = async (id: string) => { + const res = await startOneTask([id]); + if (res.success) { message.success('操作成功'); tableRef.value.reload(); } }; -const confirm = (e: MouseEvent) => { - console.log(e); - message.success('Click on Yes'); +const saveChange = (value: boolean) => { + visible.value = false; + 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) => { @@ -416,6 +386,7 @@ const handleSearch = (e: any) => { rgba(255, 255, 255, 0.86) 91.82% ); min-width: 185px; + max-width: 580px; flex: 1px; margin: 0 12px; .state-content { @@ -430,12 +401,18 @@ const handleSearch = (e: any) => { height: 22px; .state-title-right { z-index: 1; - img { - margin: 0 10px; + display: flex; + .img { width: 22px; - // margin-top: -12px; - margin-top: -5px; + margin: 0 10px; cursor: pointer; + img { + width: 22px; + margin-top: -5px; + } + } + .img:active { + border: 1px #40a9ff solid; } } }