优化已办流程界面

master
Harry Yang 2023-01-04 20:08:02 +08:00
parent 8299173d46
commit e045626b5c
1 changed files with 70 additions and 40 deletions

View File

@ -189,6 +189,21 @@
return !isBlank(obj) return !isBlank(obj)
} }
function checkStatus(response) {
if (response.status >= 200 && response.status < 300) {
return response
}
else {
const error = new Error(response.statusText);
error.response = response
throw error
}
}
function parseJSON(response) {
return response.json()
}
const data = () => { const data = () => {
return { return {
auditForm: { auditForm: {
@ -228,22 +243,23 @@
fetch("${base}/process/" + row.id, { fetch("${base}/process/" + row.id, {
method: 'DELETE', // or 'PUT' method: 'DELETE', // or 'PUT'
}).then(response => { }).then(checkStatus).then(response => {
if (response.ok) { this.queryTable()
this.queryTable() this.$message({
this.$message({ showClose: true,
showClose: true, message: '删除成功',
message: '删除成功', type: 'success'
type: 'success' })
}) }).catch(({ response }) => {
if (response) {
parseJSON(response)
.then(json => {
this.$message.error(json.message || "删除失败")
})
} }
else { else {
return Promise.reject(response) this.$message.error("删除失败")
} }
}).catch(res => {
res.json().then(json => {
this.$message.error(json.message || "删除失败");
})
}).finally(() => loading.close()) }).finally(() => loading.close())
}).catch(() => { }).catch(() => {
this.$message({ this.$message({
@ -267,20 +283,23 @@
fetch("${base}/process/revoke/" + row.id, { fetch("${base}/process/revoke/" + row.id, {
method: 'POST', // or 'PUT' method: 'POST', // or 'PUT'
}).then(response => { }).then(checkStatus).then(response => {
if (response.ok) { this.queryTable()
this.queryTable() this.$message({
this.$message({ showClose: true,
showClose: true, message: '撤销成功',
message: '撤销成功', type: 'success'
type: 'success' })
}) }).catch(({ response }) => {
if (response) {
parseJSON(response)
.then(json => {
this.$message.error(json.message || "撤销失败")
})
} }
else { else {
return Promise.reject(response) this.$message.error("撤销失败")
} }
}).catch(err => {
this.$message.error("撤销失败");
}).finally(() => loading.close()) }).finally(() => loading.close())
}).catch(() => { }).catch(() => {
this.$message({ this.$message({
@ -297,22 +316,25 @@
background: 'rgba(0, 0, 0, 0.7)' background: 'rgba(0, 0, 0, 0.7)'
}) })
fetch("${base}/process/audits/" + row.id).then(response => { fetch("${base}/process/audits/" + row.id)
if (response.ok) { .then(checkStatus)
// 展示弹窗 .then(parseJSON)
response.json().then(json => { .then(json => {
// 展示弹窗
this.auditDetailVisible = true this.auditDetailVisible = true
this.auditDetails = json this.auditDetails = json
}) })
} .catch(({ response }) => {
else { if (response) {
return Promise.reject(response) parseJSON(response)
} .then(json => {
}).catch(res => { this.$message.error(json.message || "数据获取失败")
res.json().then(json => { })
this.$message.error(json.message || "数据获取失败"); }
}) else {
}).finally(() => loading.close()) this.$message.error("数据获取失败")
}
}).finally(() => loading.close())
}, },
@ -334,7 +356,7 @@
'Content-Type': 'application/json', 'Content-Type': 'application/json',
}, },
body: JSON.stringify(form), body: JSON.stringify(form),
}).then(response => { }).then(checkStatus).then(response => {
this.$message({ this.$message({
showClose: true, showClose: true,
message: '审核成功', message: '审核成功',
@ -342,8 +364,16 @@
}) })
// 关闭对话框 // 关闭对话框
this.auditFormVisible = false this.auditFormVisible = false
}).catch(err => { }).catch(({ response }) => {
this.$message.error("审核失败"); if (response) {
parseJSON(response)
.then(json => {
this.$message.error(json.message || "审核失败")
})
}
else {
this.$message.error("审核失败")
}
}).finally(() => loading.close()) }).finally(() => loading.close())
} }
else { else {