1. 为CRUD.operation注入curd,免去属性传递 2. 表格界面零配置实现“表格列过滤显示”功能,弃用v-if方式 (#59)
⚡ CRUD优化
为CRUD.operation注入curd,免去属性传递
表格界面零配置实现“表格列过滤显示”功能,弃用v-if方式
This commit is contained in:
@@ -551,13 +551,6 @@ function mergeOptions(src, opts) {
|
||||
* crud主页
|
||||
*/
|
||||
function presenter(crud) {
|
||||
function obColumns(columns) {
|
||||
return {
|
||||
visible(col) {
|
||||
return !columns || !columns[col] ? true : columns[col].visible
|
||||
}
|
||||
}
|
||||
}
|
||||
return {
|
||||
inject: ['crud'],
|
||||
beforeCreate() {
|
||||
@@ -571,8 +564,7 @@ function presenter(crud) {
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
searchToggle: true,
|
||||
columns: obColumns()
|
||||
searchToggle: true
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
@@ -588,18 +580,21 @@ function presenter(crud) {
|
||||
this.crud.unregisterVM(this)
|
||||
},
|
||||
mounted() {
|
||||
const columns = {}
|
||||
this.$refs.table.columns.forEach(e => {
|
||||
const columns = []
|
||||
this.$refs.table.columns.forEach((e, index) => {
|
||||
if (!e.property || e.type !== 'default') {
|
||||
return
|
||||
}
|
||||
columns[e.property] = {
|
||||
e.__index = index
|
||||
columns.push({
|
||||
property: e.property,
|
||||
index,
|
||||
label: e.label,
|
||||
visible: true
|
||||
}
|
||||
})
|
||||
})
|
||||
this.columns = obColumns(columns)
|
||||
this.crud.updateProp('tableColumns', columns)
|
||||
this.crud.updateProp('table', this.$refs.table)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user