静态数据兼容key和name作为列名项

This commit is contained in:
aixianling
2024-02-27 17:03:39 +08:00
parent 421d15e27e
commit ca9e65f0cf

View File

@@ -79,13 +79,13 @@ export default {
const columns = []
this.options.staticData.map((row, i) => {
const prop = `c${i || ""}`
this.colConfigs.push({label: row[columnProp], prop})
this.colConfigs.push({label: row[columnProp] || row.key, prop})
Object.entries(row).map(([k, v]) => {
if (/^v/.test(k)) {
const item = this.tableData[k.substring(1) || 0] || {}
item[prop] = v
this.tableData[k.substring(1) || 0] = item
} else if (k != columnProp) {
} else if (![columnProp, 'key'].includes(k)) {
const index = columns.findIndex(e => k == e)
if (index > -1) {
const item = this.tableData[index] || {}