Skip to content

Commit

Permalink
Merge pull request #175 from quickapicn/feat/columns-boolvar
Browse files Browse the repository at this point in the history
columns的部分boolean类型属性支持Function类型
  • Loading branch information
kanyxmo authored Jun 17, 2024
2 parents 48f3529 + 6abba2c commit e1a1d6f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
12 changes: 6 additions & 6 deletions src/components/ma-crud/components/form.vue
Original file line number Diff line number Diff line change
Expand Up @@ -327,19 +327,19 @@ const settingFormLayout = (layout) => {

const formItemShow = (item) => {
if (currentAction.value === 'add') {
return item.addDisplay !== false
return isFunction(item.addDisplay) ? (item.addDisplay() !== false) : (item.addDisplay !== false)
}
if (currentAction.value === 'edit' || currentAction.value === 'see') {
return item.editDisplay !== false
return isFunction(item.editDisplay) ? (item.editDisplay(form.value) !== false) : (item.editDisplay !== false)
}
return item.display !== false
}
const formItemDisabled = (item) => {
if (currentAction.value === 'add' && ! isUndefined(item.addDisabled)) {
return item.addDisabled
return isFunction(item.addDisabled) ? item.addDisabled() : item.addDisabled
}
if (currentAction.value === 'edit' && ! isUndefined(item.editDisabled)) {
return item.editDisabled
return isFunction(item.editDisabled) ? item.editDisabled(form.value) : item.editDisabled
}
if (currentAction.value === 'see') {
return true
Expand All @@ -351,10 +351,10 @@ const formItemDisabled = (item) => {
}
const formItemReadonly = (item) => {
if (currentAction.value === 'add' && ! isUndefined(item.addReadonly)) {
return item.addReadonly
return isFunction(item.addReadonly) ? item.addReadonly() : item.addReadonly
}
if (currentAction.value === 'edit' && ! isUndefined(item.editReadonly)) {
return item.editReadonly
return isFunction(item.editReadonly) ? item.editReadonly(form.value) : item.editReadonly
}
if (! isUndefined(item.readonly)) {
return item.readonly
Expand Down
12 changes: 6 additions & 6 deletions src/components/ma-crud/types/columns.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,21 +74,21 @@ export interface BasicColumn {
// 编辑|创建 通用是否显示字段
display?: boolean;
// 添加弹窗是否显示字段
addDisplay?: boolean;
addDisplay?: boolean | (() => boolean);
// 编辑弹窗是否显示字段
editDisplay?: boolean;
editDisplay?: boolean | ((record) => boolean);
// 编辑|创建 通用是否禁用字段
disabled?: boolean;
// 添加弹窗是否禁用字段
addDisabled?: boolean;
addDisabled?: boolean | (() => boolean);
// 编辑弹窗是否禁用字段
editDisabled?: boolean;
editDisabled?: boolean | ((record) => boolean);
// 编辑|创建 通用是否只读字段
readonly?: boolean;
// 添加弹窗是否只读字段
addReadonly?: boolean;
addReadonly?: boolean | (() => boolean);
// 编辑弹窗是否只读字段
editReadonly?: boolean;
editReadonly?: boolean | ((record) => boolean);
// 自定义渲染
customRender?:
| (({ record, column, rowIndex }) => VNodeChild | JSX.Element)
Expand Down

0 comments on commit e1a1d6f

Please sign in to comment.