修复电池工序验证数据表格显示
This commit is contained in:
@@ -168,15 +168,32 @@ export default {
|
|||||||
syncProcessOptions () {
|
syncProcessOptions () {
|
||||||
this.form.processOptions = this.processOptions
|
this.form.processOptions = this.processOptions
|
||||||
},
|
},
|
||||||
|
normalizeProcessPayload (res) {
|
||||||
|
const payload = res && res.code !== undefined && res.data !== undefined ? res.data : res
|
||||||
|
if (
|
||||||
|
payload &&
|
||||||
|
!Array.isArray(payload) &&
|
||||||
|
payload.data &&
|
||||||
|
!Array.isArray(payload.data) &&
|
||||||
|
(payload.data.flow_process || payload.data.data)
|
||||||
|
) {
|
||||||
|
return payload.data
|
||||||
|
}
|
||||||
|
return payload || {}
|
||||||
|
},
|
||||||
|
normalizeProcessRows (payload) {
|
||||||
|
if (Array.isArray(payload)) return payload
|
||||||
|
return Array.isArray(payload.data) ? payload.data : []
|
||||||
|
},
|
||||||
verifyData () {
|
verifyData () {
|
||||||
if (!this.ensureBatteryInput()) return
|
if (!this.ensureBatteryInput()) return
|
||||||
this.loading = true
|
this.loading = true
|
||||||
verifyBatteryProcessInfo(this.form)
|
verifyBatteryProcessInfo(this.form)
|
||||||
.then(res => {
|
.then(res => {
|
||||||
const data = res && res.data ? res.data : res
|
const data = this.normalizeProcessPayload(res)
|
||||||
this.processOptions = data.flow_process || []
|
this.processOptions = data.flow_process || []
|
||||||
this.form.processOptions = this.processOptions
|
this.form.processOptions = this.processOptions
|
||||||
this.tableData = data.data || []
|
this.tableData = this.normalizeProcessRows(data)
|
||||||
this.showProcess = true
|
this.showProcess = true
|
||||||
})
|
})
|
||||||
.finally(() => {
|
.finally(() => {
|
||||||
@@ -192,8 +209,8 @@ export default {
|
|||||||
this.loading = true
|
this.loading = true
|
||||||
changeBatteryProcess(this.form)
|
changeBatteryProcess(this.form)
|
||||||
.then(res => {
|
.then(res => {
|
||||||
const data = res && res.data ? res.data : res
|
const data = this.normalizeProcessPayload(res)
|
||||||
this.tableData = Array.isArray(data) ? data : (data.data || [])
|
this.tableData = this.normalizeProcessRows(data)
|
||||||
})
|
})
|
||||||
.finally(() => {
|
.finally(() => {
|
||||||
this.loading = false
|
this.loading = false
|
||||||
|
|||||||
Reference in New Issue
Block a user