兼容更多打静态数据格式
This commit is contained in:
@@ -76,6 +76,7 @@ export default {
|
||||
initStaticDataProps() {
|
||||
const columnProp = "name"
|
||||
if (Array.isArray(this.options.staticData)) {
|
||||
const columns = []
|
||||
this.options.staticData.map((row, i) => {
|
||||
const prop = `c${i || ""}`
|
||||
this.colConfigs.push({label: row[columnProp], prop})
|
||||
@@ -84,6 +85,19 @@ export default {
|
||||
const item = this.tableData[k.substring(1) || 0] || {}
|
||||
item[prop] = v
|
||||
this.tableData[k.substring(1) || 0] = item
|
||||
} else if (k != columnProp) {
|
||||
const index = columns.findIndex(e => k == e)
|
||||
if (index > -1) {
|
||||
const item = this.tableData[index] || {}
|
||||
item[prop] = v
|
||||
this.tableData[index] = item
|
||||
} else {
|
||||
columns.push(k)
|
||||
const newIndex = columns.length - 1
|
||||
const item = this.tableData[newIndex] || {}
|
||||
item[prop] = v
|
||||
this.tableData[newIndex] = item
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user