add file remove verify && show file transfer progress

This commit is contained in:
龚祖望 2023-09-26 17:00:49 +08:00
parent 3de94f60cb
commit e983f5ba1d
1 changed files with 66 additions and 17 deletions

View File

@ -84,7 +84,11 @@
</div> </div>
<div style="margin-left: 10px"> <div style="margin-left: 10px">
<img src="@/assets/images/ota_md5.png"> <img src="@/assets/images/ota_md5.png">
<el-tooltip :content="item.fileMd5" placement="top" effect="light"><span style="color: #724fe8">MD5</span></el-tooltip> <el-tooltip
:content="item.fileMd5"
placement="top"
effect="light"
><span style="color: #724fe8">MD5</span></el-tooltip>
</div> </div>
<div style="margin-left: 10px"> <div style="margin-left: 10px">
<img src="@/assets/images/ota_time.png"> <img src="@/assets/images/ota_time.png">
@ -114,7 +118,7 @@
backgroundColor: item.primaryColor, backgroundColor: item.primaryColor,
color: 'white', color: 'white',
}" }"
@click="showTask(item.fileName, item.fileVersion)" @click="showTask(item.fileName, item.fileVersion, item.fileSize)"
>升级</el-button> >升级</el-button>
</div> </div>
</div> </div>
@ -200,8 +204,21 @@
</div> </div>
<div v-for="(item, index) in taskList" :key="index" class="item"> <div v-for="(item, index) in taskList" :key="index" class="item">
<div class="head">{{ item.id }}</div> <div class="head">{{ item.id }}</div>
<p class="label">升级设备id<br><strong>{{ item.deviceId }}</strong></p> <p class="label">
<p class="label">创建时间<br><strong>{{ item.date + ' ' + item.time }}</strong></p> 升级设备id<br><strong>{{ item.deviceId }}</strong>
</p>
<p class="label">
创建时间<br><strong>{{
item.date + " " + item.time
}}</strong>
</p>
<el-progress
class="task_progress"
:text-inside="true"
:stroke-width="18"
:percentage="item.ratio"
status="success"
/>
<p style="margin-top: 0px"> <p style="margin-top: 0px">
<el-tag <el-tag
style="padding: 0 30px" style="padding: 0 30px"
@ -309,6 +326,7 @@ export default {
firmwareList: [], firmwareList: [],
currentFileName: '', currentFileName: '',
currentFileVersion: '', currentFileVersion: '',
currentFileSize: 0,
fileList: [], fileList: [],
newFile: { newFile: {
fileName: '', fileName: '',
@ -437,12 +455,18 @@ export default {
.catch((err) => {}) .catch((err) => {})
}, },
remove(id, fileName, fileVersion, event) { remove(id, fileName, fileVersion, event) {
this.$confirm(`确定删除固件${fileName}`, '提示').then(() => { this.$confirm(`确定删除固件${fileName}`, '提示').then(async() => {
remove({ id, fileName, fileVersion }).then((res) => { const response = await getTaskList({ fileName, fileVersion })
this.$message.success('删除成功') console.log('response', response)
event.target.blur() if (response.data && response.data.length > 0) {
this.getList() this.$message.error('该固件存在升级记录,无法删除')
}) } else {
remove({ id, fileName, fileVersion }).then((res) => {
this.$message.success('删除成功')
event.target.blur()
this.getList()
})
}
}) })
}, },
verify(id, index) { verify(id, index) {
@ -526,19 +550,38 @@ export default {
}) })
} }
}, },
showTask(fileName, fileVersion) { showTask(fileName, fileVersion, fileSize) {
clearInterval()
this.currentFileName = fileName this.currentFileName = fileName
this.currentFileVersion = fileVersion this.currentFileVersion = fileVersion
this.currentFileSize = fileSize
const statusList = ['失败', '成功', '进行中', '未开始']
getTaskList({ fileName, fileVersion }).then((res) => { getTaskList({ fileName, fileVersion }).then((res) => {
this.$message.success('升级任务查询成功') this.$message.success('升级任务查询成功')
this.taskList = res.data.map((task) => { this.taskList = res.data.map((task) => {
const statusList = ['失败', '成功', '进行中', '未开始']
task.statusDesc = statusList[task.status] task.statusDesc = statusList[task.status]
task.date = task.createTime.split(' ')[0] task.date = task.createTime.split(' ')[0]
task.time = task.createTime.split(' ')[1] task.time = task.createTime.split(' ')[1]
task.ratio = Math.round(
(task.currentProcess / this.currentFileSize) * 100
)
return task return task
}) })
}) })
setInterval(() => {
getTaskList({ fileName, fileVersion }).then((res) => {
this.taskList = this.taskList.map((task) => {
const temp = res.data.filter(
(resTask) => task.id === resTask.id
)[0]
task.statusDesc = statusList[temp.status]
task.ratio = Math.round(
(temp.currentProcess / this.currentFileSize) * 100
)
return task
})
})
}, 5 * 1000)
this.taskListVisible = true this.taskListVisible = true
}, },
retryTask(task) { retryTask(task) {
@ -567,14 +610,17 @@ export default {
endTask({ id }).then((res) => { endTask({ id }).then((res) => {
if (res.code === '200000') { if (res.code === '200000') {
this.$message.success('任务强制结束成功') this.$message.success('任务强制结束成功')
this.refresh() this.refresh(false)
} }
}) })
}) })
.catch((err) => {}) .catch((err) => {})
}, },
refresh(needMsg = true) { refresh(needMsg = true) {
getTaskList({ fileName: this.currentFileName, fileVersion: this.currentFileVersion }).then((res) => { getTaskList({
fileName: this.currentFileName,
fileVersion: this.currentFileVersion
}).then((res) => {
if (needMsg) { if (needMsg) {
this.$message.success('刷新成功') this.$message.success('刷新成功')
} }
@ -824,7 +870,7 @@ export default {
display: grid; display: grid;
justify-content: space-around; justify-content: space-around;
grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
grid-template-rows: repeat(auto-fill, 290px); grid-template-rows: repeat(auto-fill, 310px);
grid-gap: 0 20px; grid-gap: 0 20px;
height: 100%; height: 100%;
width: 100%; width: 100%;
@ -854,7 +900,7 @@ export default {
#fff 5px, #fff 5px,
#fff 10px #fff 10px
); );
div { .head {
position: absolute; position: absolute;
left: 50%; left: 50%;
top: 0; top: 0;
@ -877,7 +923,7 @@ export default {
font-family: Microsoft YaHei; font-family: Microsoft YaHei;
line-height: 30px; line-height: 30px;
color: #2e4765; color: #2e4765;
strong{ strong {
font-size: 18px; font-size: 18px;
} }
.success { .success {
@ -891,6 +937,9 @@ export default {
cursor: pointer; cursor: pointer;
} }
} }
.task_progress {
margin: 0px 10px 5px;
}
} }
} }
} }