(function () { var simpleEntityName = 'config'; var entityName = 'Config'; var primaryKeyField = 'id'; var fieldMeta = dedupeFieldMeta([ { field: 'id', columnName: 'id', label: 'ID', tableProp: 'id', exportField: 'id', kind: 'text', valueType: 'number', required: true, primaryKey: true, sortable: true, textarea: false, minWidth: 90, enumOptions: [], foreignQuery: '', checkboxActiveRaw: '1', checkboxInactiveRaw: '0' }, { field: 'name', columnName: 'name', label: '名称', tableProp: 'name', exportField: 'name', kind: 'text', valueType: 'string', required: false, primaryKey: false, sortable: false, textarea: false, minWidth: 110, enumOptions: [], foreignQuery: '', checkboxActiveRaw: 'Y', checkboxInactiveRaw: 'N' }, { field: 'code', columnName: 'code', label: '编码', tableProp: 'code', exportField: 'code', kind: 'text', valueType: 'string', required: false, primaryKey: false, sortable: false, textarea: false, minWidth: 110, enumOptions: [], foreignQuery: '', checkboxActiveRaw: 'Y', checkboxInactiveRaw: 'N' }, { field: 'value', columnName: 'value', label: '对应值', tableProp: 'value', exportField: 'value', kind: 'text', valueType: 'string', required: false, primaryKey: false, sortable: false, textarea: false, minWidth: 110, enumOptions: [], foreignQuery: '', checkboxActiveRaw: 'Y', checkboxInactiveRaw: 'N' }, { field: 'type', columnName: 'type', label: '类型', tableProp: 'type', exportField: 'type', kind: 'text', valueType: 'number', required: false, primaryKey: false, sortable: false, textarea: false, minWidth: 110, enumOptions: [], foreignQuery: '', checkboxActiveRaw: '1', checkboxInactiveRaw: '0' }, { field: 'status', columnName: 'status', label: '状态', tableProp: 'status', exportField: 'status', kind: 'text', valueType: 'number', required: false, primaryKey: false, sortable: false, textarea: false, minWidth: 110, enumOptions: [], foreignQuery: '', checkboxActiveRaw: '1', checkboxInactiveRaw: '0' }, { field: 'id', columnName: 'id', label: 'ID', tableProp: 'id', exportField: 'id', kind: 'text', valueType: 'number', required: true, primaryKey: true, sortable: true, textarea: false, minWidth: 90, enumOptions: [], foreignQuery: '', checkboxActiveRaw: '1', checkboxInactiveRaw: '0' }, { field: 'name', columnName: 'name', label: '名称', tableProp: 'name', exportField: 'name', kind: 'text', valueType: 'string', required: false, primaryKey: false, sortable: false, textarea: false, minWidth: 110, enumOptions: [], foreignQuery: '', checkboxActiveRaw: 'Y', checkboxInactiveRaw: 'N' }, { field: 'code', columnName: 'code', label: '编码', tableProp: 'code', exportField: 'code', kind: 'text', valueType: 'string', required: false, primaryKey: false, sortable: false, textarea: false, minWidth: 110, enumOptions: [], foreignQuery: '', checkboxActiveRaw: 'Y', checkboxInactiveRaw: 'N' }, { field: 'value', columnName: 'value', label: '对应值', tableProp: 'value', exportField: 'value', kind: 'text', valueType: 'string', required: false, primaryKey: false, sortable: false, textarea: false, minWidth: 110, enumOptions: [], foreignQuery: '', checkboxActiveRaw: 'Y', checkboxInactiveRaw: 'N' }, { field: 'type', columnName: 'type', label: '类型', tableProp: 'type', exportField: 'type', kind: 'text', valueType: 'number', required: false, primaryKey: false, sortable: false, textarea: false, minWidth: 110, enumOptions: [], foreignQuery: '', checkboxActiveRaw: '1', checkboxInactiveRaw: '0' }, { field: 'status', columnName: 'status', label: '状态', tableProp: 'status', exportField: 'status', kind: 'text', valueType: 'number', required: false, primaryKey: false, sortable: false, textarea: false, minWidth: 110, enumOptions: [], foreignQuery: '', checkboxActiveRaw: '1', checkboxInactiveRaw: '0' }, { field: 'selectType', columnName: 'select_type', label: '筛选类型', tableProp: 'selectType', exportField: 'selectType', kind: 'text', valueType: 'string', required: false, primaryKey: false, sortable: false, textarea: false, minWidth: 110, enumOptions: [], foreignQuery: '', checkboxActiveRaw: 'Y', checkboxInactiveRaw: 'N' }, { field: 'id', columnName: 'id', label: 'I D', tableProp: 'id', exportField: 'id', kind: 'text', valueType: 'number', required: true, primaryKey: true, sortable: true, textarea: false, minWidth: 90, enumOptions: [], foreignQuery: '', checkboxActiveRaw: '1', checkboxInactiveRaw: '0' }, { field: 'uuid', columnName: 'uuid', label: '编 号', tableProp: 'uuid', exportField: 'uuid', kind: 'text', valueType: 'string', required: false, primaryKey: false, sortable: false, textarea: false, minWidth: 110, enumOptions: [], foreignQuery: '', checkboxActiveRaw: 'Y', checkboxInactiveRaw: 'N' }, { field: 'name', columnName: 'name', label: '名 称', tableProp: 'name', exportField: 'name', kind: 'text', valueType: 'string', required: false, primaryKey: false, sortable: false, textarea: false, minWidth: 110, enumOptions: [], foreignQuery: '', checkboxActiveRaw: 'Y', checkboxInactiveRaw: 'N' }, { field: 'flag', columnName: 'flag', label: '标 识', tableProp: 'flag', exportField: 'flag', kind: 'text', valueType: 'string', required: false, primaryKey: false, sortable: false, textarea: false, minWidth: 110, enumOptions: [], foreignQuery: '', checkboxActiveRaw: 'Y', checkboxInactiveRaw: 'N' }, { field: 'type', columnName: 'type', label: '类 型', tableProp: 'type$', exportField: 'type$', kind: 'enum', valueType: 'number', required: false, primaryKey: false, sortable: false, textarea: false, minWidth: 120, enumOptions: [{ rawValue: '1', label: 'boolean' }, { rawValue: '2', label: 'number' }, { rawValue: '3', label: 'string' }, { rawValue: '4', label: 'json' }, { rawValue: '5', label: 'date' }], foreignQuery: '', checkboxActiveRaw: '1', checkboxInactiveRaw: '0' }, { field: 'val', columnName: 'val', label: '字 典 值', tableProp: 'val', exportField: 'val', kind: 'text', valueType: 'string', required: false, primaryKey: false, sortable: false, textarea: false, minWidth: 116, enumOptions: [], foreignQuery: '', checkboxActiveRaw: 'Y', checkboxInactiveRaw: 'N' }, { field: 'content', columnName: 'content', label: '字典文本', tableProp: 'content', exportField: 'content', kind: 'text', valueType: 'string', required: false, primaryKey: false, sortable: false, textarea: true, minWidth: 180, enumOptions: [], foreignQuery: '', checkboxActiveRaw: 'Y', checkboxInactiveRaw: 'N' }, { field: 'status', columnName: 'status', label: '状 态', tableProp: 'status$', exportField: 'status$', kind: 'enum', valueType: 'number', required: true, primaryKey: false, sortable: false, textarea: false, minWidth: 120, enumOptions: [{ rawValue: '1', label: '正常' }, { rawValue: '0', label: '冻结' }], foreignQuery: '', checkboxActiveRaw: '1', checkboxInactiveRaw: '0' }, { field: 'deleted', columnName: 'deleted', label: '是否删除', tableProp: 'deleted$', exportField: 'deleted$', kind: 'enum', valueType: 'number', required: true, primaryKey: false, sortable: false, textarea: false, minWidth: 120, enumOptions: [{ rawValue: '1', label: '是' }, { rawValue: '0', label: '否' }], foreignQuery: '', checkboxActiveRaw: '1', checkboxInactiveRaw: '0' }, { field: 'tenantId', columnName: 'tenant_id', label: '租 户', tableProp: 'tenantId$', exportField: 'tenantId$', kind: 'foreign', valueType: 'number', required: false, primaryKey: false, sortable: false, textarea: false, minWidth: 110, enumOptions: [], foreignQuery: 'tenant', checkboxActiveRaw: '1', checkboxInactiveRaw: '0' }, { field: 'createBy', columnName: 'create_by', label: '添加人员', tableProp: 'createBy$', exportField: 'createBy$', kind: 'foreign', valueType: 'number', required: false, primaryKey: false, sortable: false, textarea: false, minWidth: 110, enumOptions: [], foreignQuery: 'user', checkboxActiveRaw: '1', checkboxInactiveRaw: '0' }, { field: 'createTime', columnName: 'create_time', label: '添加时间', tableProp: 'createTime$', exportField: 'createTime$', kind: 'date', valueType: 'string', required: true, primaryKey: false, sortable: false, textarea: false, minWidth: 168, enumOptions: [], foreignQuery: '', checkboxActiveRaw: 'Y', checkboxInactiveRaw: 'N' }, { field: 'updateBy', columnName: 'update_by', label: '修改人员', tableProp: 'updateBy$', exportField: 'updateBy$', kind: 'foreign', valueType: 'number', required: false, primaryKey: false, sortable: false, textarea: false, minWidth: 110, enumOptions: [], foreignQuery: 'user', checkboxActiveRaw: '1', checkboxInactiveRaw: '0' }, { field: 'updateTime', columnName: 'update_time', label: '修改时间', tableProp: 'updateTime$', exportField: 'updateTime$', kind: 'date', valueType: 'string', required: false, primaryKey: false, sortable: false, textarea: false, minWidth: 168, enumOptions: [], foreignQuery: '', checkboxActiveRaw: 'Y', checkboxInactiveRaw: 'N' }, { field: 'memo', columnName: 'memo', label: '备 注', tableProp: 'memo', exportField: 'memo', kind: 'text', valueType: 'string', required: false, primaryKey: false, sortable: false, textarea: true, minWidth: 180, enumOptions: [], foreignQuery: '', checkboxActiveRaw: 'Y', checkboxInactiveRaw: 'N' }, { field: 'id', columnName: 'id', label: 'ID', tableProp: 'id', exportField: 'id', kind: 'text', valueType: 'number', required: true, primaryKey: true, sortable: true, textarea: false, minWidth: 90, enumOptions: [], foreignQuery: '', checkboxActiveRaw: '1', checkboxInactiveRaw: '0' }, { field: 'name', columnName: 'name', label: '名称', tableProp: 'name', exportField: 'name', kind: 'text', valueType: 'string', required: false, primaryKey: false, sortable: false, textarea: false, minWidth: 110, enumOptions: [], foreignQuery: '', checkboxActiveRaw: 'Y', checkboxInactiveRaw: 'N' }, { field: 'code', columnName: 'code', label: '编码', tableProp: 'code', exportField: 'code', kind: 'text', valueType: 'string', required: false, primaryKey: false, sortable: false, textarea: false, minWidth: 110, enumOptions: [], foreignQuery: '', checkboxActiveRaw: 'Y', checkboxInactiveRaw: 'N' }, { field: 'value', columnName: 'value', label: '对应值', tableProp: 'value', exportField: 'value', kind: 'text', valueType: 'string', required: false, primaryKey: false, sortable: false, textarea: false, minWidth: 110, enumOptions: [], foreignQuery: '', checkboxActiveRaw: 'Y', checkboxInactiveRaw: 'N' }, { field: 'type', columnName: 'type', label: '类型', tableProp: 'type', exportField: 'type', kind: 'text', valueType: 'number', required: false, primaryKey: false, sortable: false, textarea: false, minWidth: 110, enumOptions: [], foreignQuery: '', checkboxActiveRaw: '1', checkboxInactiveRaw: '0' }, { field: 'status', columnName: 'status', label: '状态', tableProp: 'status', exportField: 'status', kind: 'text', valueType: 'number', required: false, primaryKey: false, sortable: false, textarea: false, minWidth: 110, enumOptions: [], foreignQuery: '', checkboxActiveRaw: '1', checkboxInactiveRaw: '0' }, { field: 'variable', columnName: 'variable', label: '', tableProp: 'variable', exportField: 'variable', kind: 'text', valueType: 'string', required: true, primaryKey: true, sortable: true, textarea: false, minWidth: 90, enumOptions: [], foreignQuery: '', checkboxActiveRaw: 'Y', checkboxInactiveRaw: 'N' }, { field: 'value', columnName: 'value', label: '对应值', tableProp: 'value', exportField: 'value', kind: 'text', valueType: 'string', required: false, primaryKey: false, sortable: false, textarea: false, minWidth: 110, enumOptions: [], foreignQuery: '', checkboxActiveRaw: 'Y', checkboxInactiveRaw: 'N' }, { field: 'setTime', columnName: 'set_time', label: '', tableProp: 'setTime$', exportField: 'setTime$', kind: 'date', valueType: 'string', required: true, primaryKey: false, sortable: false, textarea: false, minWidth: 168, enumOptions: [], foreignQuery: '', checkboxActiveRaw: 'Y', checkboxInactiveRaw: 'N' }, { field: 'setBy', columnName: 'set_by', label: '', tableProp: 'setBy', exportField: 'setBy', kind: 'text', valueType: 'string', required: false, primaryKey: false, sortable: false, textarea: false, minWidth: 110, enumOptions: [], foreignQuery: '', checkboxActiveRaw: 'Y', checkboxInactiveRaw: 'N' }, { field: 'id', columnName: 'id', label: 'ID', tableProp: 'id', exportField: 'id', kind: 'text', valueType: 'number', required: true, primaryKey: true, sortable: true, textarea: false, minWidth: 90, enumOptions: [], foreignQuery: '', checkboxActiveRaw: '1', checkboxInactiveRaw: '0' }, { field: 'name', columnName: 'name', label: '名称', tableProp: 'name', exportField: 'name', kind: 'text', valueType: 'string', required: false, primaryKey: false, sortable: false, textarea: false, minWidth: 110, enumOptions: [], foreignQuery: '', checkboxActiveRaw: 'Y', checkboxInactiveRaw: 'N' }, { field: 'code', columnName: 'code', label: '编码', tableProp: 'code', exportField: 'code', kind: 'text', valueType: 'string', required: false, primaryKey: false, sortable: false, textarea: false, minWidth: 110, enumOptions: [], foreignQuery: '', checkboxActiveRaw: 'Y', checkboxInactiveRaw: 'N' }, { field: 'value', columnName: 'value', label: '对应值', tableProp: 'value', exportField: 'value', kind: 'text', valueType: 'string', required: false, primaryKey: false, sortable: false, textarea: false, minWidth: 110, enumOptions: [], foreignQuery: '', checkboxActiveRaw: 'Y', checkboxInactiveRaw: 'N' }, { field: 'type', columnName: 'type', label: '类型', tableProp: 'type', exportField: 'type', kind: 'text', valueType: 'number', required: false, primaryKey: false, sortable: false, textarea: false, minWidth: 110, enumOptions: [], foreignQuery: '', checkboxActiveRaw: '1', checkboxInactiveRaw: '0' }, { field: 'status', columnName: 'status', label: '状态', tableProp: 'status', exportField: 'status', kind: 'text', valueType: 'number', required: false, primaryKey: false, sortable: false, textarea: false, minWidth: 110, enumOptions: [], foreignQuery: '', checkboxActiveRaw: '1', checkboxInactiveRaw: '0' }, { field: 'selectType', columnName: 'select_type', label: '筛选类型', tableProp: 'selectType', exportField: 'selectType', kind: 'text', valueType: 'string', required: false, primaryKey: false, sortable: false, textarea: false, minWidth: 110, enumOptions: [], foreignQuery: '', checkboxActiveRaw: 'Y', checkboxInactiveRaw: 'N' } ]); function formatFieldLabel(field) { var raw = field && field.label ? String(field.label).trim() : ''; if (raw) { return raw; } raw = field && field.columnName ? field.columnName : (field && field.field ? field.field : ''); if (!raw) { return ''; } raw = String(raw) .replace(/\$/g, '') .replace(/([a-z0-9])([A-Z])/g, '$1_$2') .replace(/_/g, ' ') .replace(/\s+/g, ' ') .trim(); return raw.replace(/\b[a-z]/g, function (letter) { return letter.toUpperCase(); }); } function dedupeFieldMeta(list) { var result = []; var seen = {}; (list || []).forEach(function (field) { if (!field || !field.field || seen[field.field]) { return; } field.label = formatFieldLabel(field); seen[field.field] = true; result.push(field); }); return result; } function isEmptyValue(value) { return value === null || value === undefined || value === ''; } function stringValue(value) { return isEmptyValue(value) ? '' : String(value); } function valueOrDash(value) { return isEmptyValue(value) ? '--' : value; } function normalizeOptionValue(field, rawValue) { if (rawValue === null || rawValue === undefined) { return null; } if (rawValue === '') { return ''; } if (field && field.valueType === 'number') { var numberVal = Number(rawValue); return isNaN(numberVal) ? rawValue : numberVal; } return String(rawValue); } function isSearchableField(field) { return !!field && field.kind !== 'image' && !field.textarea; } function isSortableField(field) { if (!field) { return false; } if (field.primaryKey) { return true; } return field.kind !== 'image' && !field.textarea && field.kind !== 'foreign'; } function defaultFieldValue(field) { if (field.primaryKey) { return null; } if (field.kind === 'checkbox') { return normalizeOptionValue(field, field.checkboxInactiveRaw); } return ''; } function defaultSearchFieldValue(field) { if (field.kind === 'date') { return []; } if (field.kind === 'enum' || field.kind === 'checkbox') { return null; } return ''; } function createSearchDefaults() { var result = { condition: '' }; fieldMeta.forEach(function (field) { if (!isSearchableField(field)) { return; } result[field.field] = defaultSearchFieldValue(field); }); return result; } function createSearchDisplayDefaults() { var result = {}; fieldMeta.forEach(function (field) { if (field.kind === 'foreign' && isSearchableField(field)) { result[field.field] = ''; } }); return result; } function createDefaultVisibleColumnKeys() { return fieldMeta.map(function (field) { return field.field; }); } function createFormDefaults() { var result = {}; fieldMeta.forEach(function (field) { result[field.field] = defaultFieldValue(field); }); return result; } function createDisplayDefaults() { var result = {}; fieldMeta.forEach(function (field) { if (field.kind === 'foreign') { result[field.field] = ''; } }); return result; } function createFormRules() { var rules = {}; fieldMeta.forEach(function (field) { if (field.primaryKey || !field.required) { return; } rules[field.field] = [{ required: true, message: (field.kind === 'date' || field.kind === 'enum' ? '请选择' : '请输入') + field.label, trigger: (field.kind === 'date' || field.kind === 'enum') ? 'change' : 'blur' }]; }); return rules; } function getTableValue(row, field) { var prop = field.tableProp || field.field; if (row && !isEmptyValue(row[prop])) { return row[prop]; } return row ? row[field.field] : ''; } function isCheckboxChecked(row, field) { var value = row ? row[field.field] : null; var activeValue = normalizeOptionValue(field, field.checkboxActiveRaw); return String(value) === String(activeValue); } function exportCell(value) { return stringValue(value).replace(/\t/g, ' ').replace(/\r?\n/g, ' '); } function escapeHtml(value) { return exportCell(value) .replace(/&/g, '&') .replace(//g, '>') .replace(/"/g, '"') .replace(/'/g, '''); } function buildPayload(form) { var payload = {}; fieldMeta.forEach(function (field) { var value = form[field.field]; if (field.primaryKey) { if (!isEmptyValue(value)) { payload[field.field] = value; } return; } if (field.kind === 'foreign' && isEmptyValue(value)) { value = null; } if (field.kind === 'enum' && value === '') { value = null; } if (field.kind === 'checkbox' && isEmptyValue(value)) { value = normalizeOptionValue(field, field.checkboxInactiveRaw); } if (field.valueType === 'number' && !isEmptyValue(value)) { value = Number(value); } if (field.valueType === 'number' && value === '') { value = null; } payload[field.field] = value; }); return payload; } function fillFormFromRow(row, form, display) { fieldMeta.forEach(function (field) { if (field.primaryKey) { form[field.field] = row[field.field]; return; } if (field.kind === 'date') { form[field.field] = row[field.tableProp] || row[field.field] || ''; return; } if (field.kind === 'foreign') { form[field.field] = isEmptyValue(row[field.field]) ? '' : normalizeOptionValue(field, row[field.field]); if (display) { display[field.field] = row[field.tableProp] || (isEmptyValue(row[field.field]) ? '' : String(row[field.field])); } return; } if (field.kind === 'enum') { form[field.field] = isEmptyValue(row[field.field]) ? '' : normalizeOptionValue(field, row[field.field]); return; } if (field.kind === 'checkbox') { form[field.field] = isEmptyValue(row[field.field]) ? normalizeOptionValue(field, field.checkboxInactiveRaw) : normalizeOptionValue(field, row[field.field]); return; } form[field.field] = isEmptyValue(row[field.field]) ? '' : (field.valueType === 'number' ? String(row[field.field]) : row[field.field]); }); } function resolveSearchParam(field) { if (field.kind === 'date' && field.columnName) { return field.columnName; } return field.field; } function createDownloadFile(filename, titles, rows) { var html = [ '', '
| ' + escapeHtml(title) + ' | '; }).join(''), '
|---|
| ' + escapeHtml(value) + ' | '; }).join('') + '