From f67bdea66fe7f653c57785bb388f789c2d7d36ba Mon Sep 17 00:00:00 2001 From: aixianling Date: Mon, 4 Jul 2022 15:13:36 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=9A=E5=88=B6=E9=A1=B9=E7=9B=AE=E6=8F=90?= =?UTF-8?q?=E4=BA=A4=E4=B8=80=E6=B3=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../oms/apps/develop/AppDeployCustom/list.vue | 77 ++++++++++++++++++- 1 file changed, 74 insertions(+), 3 deletions(-) diff --git a/project/oms/apps/develop/AppDeployCustom/list.vue b/project/oms/apps/develop/AppDeployCustom/list.vue index daa351e1..26949980 100644 --- a/project/oms/apps/develop/AppDeployCustom/list.vue +++ b/project/oms/apps/develop/AppDeployCustom/list.vue @@ -13,11 +13,18 @@ + + + @@ -46,7 +53,9 @@ export default { {prop: "version", label: "版本号", width: 120}, {prop: "customPath", label: "库项目根路径", width: 120}, {prop: "dist", label: "更新路径"}, + {slot: 'process'}, ], + timer: {} } }, methods: { @@ -55,7 +64,7 @@ export default { params: {...this.page, ...this.search} }).then(res => { if (res?.data) { - this.tableData = res.data.records + this.tableData = res.data.records.map(e => ({...e, count: 0})) this.page.total = res.data.total } }) @@ -95,9 +104,71 @@ export default { } }) }, + handleUpdate(row) { + let {id} = row, {timer} = this + this.instance.post("/node/custom/getZip", null, { + params: {id} + }).then(res => { + if (res?.code == 0) { + row.count = 1 + timer[id] = setInterval(() => { + if (row.count >= 100) { + clearInterval(timer[id]) + row.count = 0 + this.$message.error("打包失败!") + } else if (row.count % 2 == 0 && row.target) { + row.count++ + } else this.getRowById(row).then(v => { + if (v.error) { + clearInterval(timer[id]) + this.$message.error("打包失败!") + this.refreshRow(row, v) + row.count = 0 + } else if (v.download) { + clearInterval(timer[id]) + this.refreshRow(row, v) + row.count = 0 + } else row.count++ + }) + }, 6000) + } + }) + }, + refreshRow(row, v) { + row.error = v.error + row.download = v.download + row.zipTime = v.zipTime + }, + getProcessMsg(row) { + let time = row.zipTime ? this.$moment(row.download).diff(row.zipTime, 's', true) : "" + return row.error || (row.download ? `最近打包时间:${row.download}(用时:${time}秒)` : + row.zipTime ? `正在打包,开始于:${row.zipTime}` : `暂无打包`) + }, + handleCancelUpdate(row) { + let {id} = row + return this.instance.post("/node/custom/cancelZip", null, { + params: {id} + }).then(res => { + if (res?.code == 0) { + clearInterval(this.timer[id]) + row.count = 0 + this.getRowById(row).then(v => this.refreshRow(row, v)) + } + }) + }, + getRowById(id) { + return this.instance.post("/node/custom/detail", null, { + params: {id} + }).then(res => { + if (res?.data) return res.data + }) + } }, created() { this.getTableData() + }, + beforeDestroy() { + Object.values(this.timer).map(t => clearInterval(t)) } }