静态数据编辑器基本完成
This commit is contained in:
@@ -11,14 +11,7 @@
|
||||
</ai-dialog-btn>
|
||||
</div>
|
||||
<template v-else-if="source.dataType === 'staticData'">
|
||||
<config-item label="设置列" class="tableStyle">
|
||||
<div class="fill">
|
||||
<table-editor v-model="colConfigs" :configs="[{field:'field',headerName:'属性',width:100},{field:'headerName',headerName:'名称',width:100}]"/>
|
||||
</div>
|
||||
</config-item>
|
||||
<config-item label="设置数据" class="tableStyle" v-if="colConfigs.length>0">
|
||||
<table-editor v-model="content" :configs="colConfigs"/>
|
||||
</config-item>
|
||||
<table-editor label="设置数据" v-model="tableData" :configs.sync="colConfigs" @data="changeData"/>
|
||||
</template>
|
||||
<config-item v-else-if="source.dataType === 'dynamicData'" label="数据源">
|
||||
<ai-select v-model="source.sourceDataId" placeholder="请选择数据源" :instance="instance"
|
||||
@@ -57,6 +50,7 @@ export default {
|
||||
dataTypes: Object.entries(DvCompData.types).map(e => ({id: e[0], label: e[1]})),
|
||||
content: "",
|
||||
loading: false,
|
||||
tableData: [],
|
||||
colConfigs: []
|
||||
}
|
||||
},
|
||||
@@ -78,8 +72,27 @@ export default {
|
||||
new DvCompData(this.source.dataType, this.source, this.instance).getData().then(data => {
|
||||
this.source[this.source.dataType] = data
|
||||
})
|
||||
},
|
||||
initStaticDataProps() {
|
||||
const columnProp = "name"
|
||||
this.options.staticData.map((row, i) => {
|
||||
const prop = `c${i || ""}`
|
||||
this.colConfigs.push({label: row[columnProp], 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
|
||||
}
|
||||
})
|
||||
})
|
||||
this.tableData = this.tableData.map(e => ({...e, $cellEdit: false}))
|
||||
}
|
||||
},
|
||||
created() {
|
||||
//新版静态数据
|
||||
this.initStaticDataProps()
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<style scoped lang="scss">
|
||||
@@ -88,9 +101,5 @@ export default {
|
||||
position: relative;
|
||||
padding-left: 10px;
|
||||
}
|
||||
|
||||
.tableStyle {
|
||||
align-items: normal;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user