if参数支持传入一个字段名

This commit is contained in:
2022-08-08 15:04:54 +08:00
parent aee24d4f09
commit 4b15980445
2 changed files with 19 additions and 5 deletions

View File

@@ -83,6 +83,7 @@ define(["jquery", "easy-admin", "treetable", "iconPickerFa", "autocomplete"], fu
auth: 'edit',
class: 'layui-btn layui-btn-xs layui-btn-success',
extend: 'data-full="true"',
if:'status'
}, {
text: '删除',
method: 'none',

View File

@@ -746,10 +746,23 @@ define(["jquery", "tableSelect", "ckeditor", 'miniTheme', 'tableData', 'citypick
operat.text = operat.text || operat.title;
operat.if = operat.if || function () { return true };
if (operat.if(data, operat) !== true) {
return '';
if (typeof operat.if == 'function') {
if (operat.if(data, operat) !== true) {
return '';
}
} else if (typeof operat.if == 'string') {
var ifValue = admin.table.returnColumnValue(data,operat.if,false);
if(!ifValue){
return ''
}
}
var titleEndfix = '';
if (typeof operat.titleField == 'function') {
@@ -1096,13 +1109,13 @@ define(["jquery", "tableSelect", "ckeditor", 'miniTheme', 'tableData', 'citypick
return '0B'
},
// 统一列返回数据处理
returnColumnValue(data) {
returnColumnValue(data, field, defaultValue) {
if (!data.LAY_COL) {
return '';
}
var option = data.LAY_COL;
var field = option.field;
var defaultValue = option.defaultValue;
field = field || option.field;
defaultValue = defaultValue || option.defaultValue;
var value = defaultValue;
try {
value = eval("data." + field);