|
@@ -463,6 +463,7 @@
|
|
|
if (tableHeadersRes.code == 200) {
|
|
if (tableHeadersRes.code == 200) {
|
|
|
this.parseAndDisplayTableHeaders(tableHeadersRes)
|
|
this.parseAndDisplayTableHeaders(tableHeadersRes)
|
|
|
this.parseAndDisplayTableData(tableDataRes)
|
|
this.parseAndDisplayTableData(tableDataRes)
|
|
|
|
|
+ await this.tryEchoUploadData()
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
@@ -485,6 +486,60 @@
|
|
|
// 处理表格数据
|
|
// 处理表格数据
|
|
|
if (tableDataRes.code == 200) {
|
|
if (tableDataRes.code == 200) {
|
|
|
this.parseAndDisplayTableData(tableDataRes)
|
|
this.parseAndDisplayTableData(tableDataRes)
|
|
|
|
|
+ await this.tryEchoUploadData()
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ // 根据已存在的上传数据进行回显(若有)
|
|
|
|
|
+ async tryEchoUploadData() {
|
|
|
|
|
+ try {
|
|
|
|
|
+ const uploadId = (this.auditForm && this.auditForm.uploadId) || ''
|
|
|
|
|
+ const auditedUnitId = this.auditedUnitId || ''
|
|
|
|
|
+ const taskId =
|
|
|
|
|
+ (this.selectedProject && this.selectedProject.taskId) || ''
|
|
|
|
|
+ // if (!uploadId || !auditedUnitId) return
|
|
|
|
|
+ const params = {
|
|
|
|
|
+ // uploadId,
|
|
|
|
|
+ // auditedUnitId,
|
|
|
|
|
+ type: '3',
|
|
|
|
|
+ taskId: taskId,
|
|
|
|
|
+ }
|
|
|
|
|
+ const res = await getSurveyDetail(params)
|
|
|
|
|
+ if (res && res.code === 200 && res.value) {
|
|
|
|
|
+ const triplets = Array.isArray(res.value)
|
|
|
|
|
+ ? res.value
|
|
|
|
|
+ : res.value.items || res.value.records || []
|
|
|
|
|
+ if (!Array.isArray(triplets) || triplets.length === 0) return
|
|
|
|
|
+ // 建立字段名映射:rkey(中文列名) -> fieldEname(表格prop)
|
|
|
|
|
+ const headerMap = {}
|
|
|
|
|
+ ;(this.tableHeadersRes || []).forEach((h) => {
|
|
|
|
|
+ if (h && h.fieldName && h.fieldEname)
|
|
|
|
|
+ headerMap[h.fieldName] = h.fieldEname
|
|
|
|
|
+ })
|
|
|
|
|
+ // 行索引:rowid -> 行对象
|
|
|
|
|
+ const rowMap = new Map()
|
|
|
|
|
+ ;(this.costAuditData || []).forEach((row) => {
|
|
|
|
|
+ if (row && row.rowid !== undefined && row.rowid !== null) {
|
|
|
|
|
+ rowMap.set(String(row.rowid), row)
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+ // 应用回显
|
|
|
|
|
+ triplets.forEach((item) => {
|
|
|
|
|
+ const rowid = item.rowid || item.rowId || item.ROWID
|
|
|
|
|
+ const rkey = item.rkey || item.rKey || item.RKEY
|
|
|
|
|
+ const rvalue = item.rvalue || item.rValue || item.RVALUE
|
|
|
|
|
+ if (!rowid || !rkey) return
|
|
|
|
|
+ const row = rowMap.get(String(rowid))
|
|
|
|
|
+ const prop = headerMap[rkey]
|
|
|
|
|
+ if (row && prop) {
|
|
|
|
|
+ row[prop] = rvalue != null ? String(rvalue) : ''
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+ // 强制刷新
|
|
|
|
|
+ this.costAuditData = [...this.costAuditData]
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch (e) {
|
|
|
|
|
+ // 静默失败即可
|
|
|
|
|
+ console.warn('回显上传数据失败: ', e)
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
parseAndDisplayTableHeaders(res) {
|
|
parseAndDisplayTableHeaders(res) {
|