| | |
| | | * @description 获取显示列表单配置信息 |
| | | * @param {object} card // 搜索条件对象 |
| | | */ |
| | | export function getColumnForm (card, fields = []) { |
| | | let appType = sessionStorage.getItem('appType') |
| | | export function getColumnForm (card, fields = [], columns = []) { |
| | | let roleList = sessionStorage.getItem('sysRoles') |
| | | if (roleList) { |
| | | try { |
| | |
| | | roleList = [] |
| | | } |
| | | |
| | | let menulist = [] |
| | | |
| | | if (appType === 'pc') { |
| | | menulist = sessionStorage.getItem('appMenus') |
| | | } else if (!appType) { |
| | | menulist = sessionStorage.getItem('fstMenuList') |
| | | } |
| | | |
| | | if (menulist) { |
| | | try { |
| | | menulist = JSON.parse(menulist) |
| | | } catch (e) { |
| | | menulist = [] |
| | | } |
| | | } else { |
| | | menulist = [] |
| | | if (['picture', 'link', 'colspan'].includes(card.type)) { |
| | | card.type = 'text' |
| | | } |
| | | |
| | | let options = [{ |
| | |
| | | value: 'number', |
| | | text: Formdict['model.form.number'] |
| | | }, { |
| | | value: 'picture', |
| | | text: Formdict['model.form.picture'] |
| | | }, { |
| | | value: 'link', |
| | | text: Formdict['model.form.href'] |
| | | }, { |
| | | value: 'textarea', |
| | | text: Formdict['model.form.textarea'] |
| | | }, { |
| | | value: 'custom', |
| | | text: '自定义列' |
| | | }, { |
| | | value: 'colspan', |
| | | text: '合并列' |
| | | value: 'action', |
| | | text: '操作' |
| | | }, { |
| | | value: 'formula', |
| | | text: '公式' |
| | | }, { |
| | | value: 'index', |
| | | text: '序号' |
| | | }] |
| | | |
| | | if (!card.isSub) { |
| | | options.push({ |
| | | value: 'action', |
| | | text: '操作' |
| | | }) |
| | | } |
| | | |
| | | if (!card.linkurl && (!card.linkmenu || card.linkmenu.length === 0)) { |
| | | card.perspective = '' |
| | | } |
| | | let editCols = [ |
| | | { |
| | | field: '$sub', |
| | | label: '提交' |
| | | }, |
| | | { |
| | | field: '$next', |
| | | label: '下一行' |
| | | }, |
| | | { |
| | | field: '$noAct', |
| | | label: '无动作' |
| | | } |
| | | ] |
| | | columns.forEach(col => { |
| | | if (col.editable === 'true' && col.uuid !== card.uuid) { |
| | | editCols.push({ |
| | | field: col.uuid, |
| | | label: col.label |
| | | }) |
| | | } |
| | | }) |
| | | |
| | | return [ |
| | | { |
| | |
| | | options: fields |
| | | }, |
| | | { |
| | | type: 'select', |
| | | key: 'nameField', |
| | | label: Formdict['model.name'] + Formdict['model.form.field'], |
| | | initVal: card.nameField || '', |
| | | required: false, |
| | | options: [{uuid: 'empty', field: '', label: '空'}, ...fields] |
| | | }, |
| | | { |
| | | type: 'number', |
| | | key: 'Width', |
| | | min: 20, |
| | | max: 1000, |
| | | decimal: 0, |
| | | precision: 0, |
| | | label: Formdict['model.form.columnWidth'], |
| | | initVal: card.Width || 120, |
| | | required: true |
| | | }, |
| | | { |
| | | type: 'radio', |
| | | key: 'joint', |
| | | label: Formdict['model.form.paramJoint'], |
| | | initVal: card.joint || 'true', |
| | | required: true, |
| | | options: [{ |
| | | value: 'true', |
| | | text: Formdict['model.true'] |
| | | }, { |
| | | value: 'false', |
| | | text: Formdict['model.false'] |
| | | }] |
| | | }, |
| | | { |
| | | type: 'radio', |
| | |
| | | type: 'radio', |
| | | key: 'IsSort', |
| | | label: Formdict['model.sort'], |
| | | initVal: card.IsSort || 'true', |
| | | initVal: card.IsSort || 'false', |
| | | required: true, |
| | | forbidden: card.isSub, |
| | | options: [{ |
| | | value: 'true', |
| | | text: Formdict['model.true'] |
| | |
| | | }, |
| | | { |
| | | type: 'radio', |
| | | key: 'rowspan', |
| | | label: '行合并', |
| | | initVal: card.rowspan || 'false', |
| | | tooltip: '相邻行信息相同时,单元格合并。', |
| | | required: false, |
| | | options: [{ |
| | | value: 'true', |
| | | text: Formdict['model.true'] |
| | | }, { |
| | | value: 'false', |
| | | text: Formdict['model.false'] |
| | | }] |
| | | }, |
| | | { |
| | | type: 'radio', |
| | | key: 'sum', |
| | | label: '显示合计', |
| | | initVal: card.sum || 'false', |
| | |
| | | }] |
| | | }, |
| | | { |
| | | type: 'radio', |
| | | key: 'editable', |
| | | label: '可编辑', |
| | | initVal: card.editable || 'false', |
| | | required: true, |
| | | options: [{ |
| | | value: 'false', |
| | | text: '否' |
| | | }, { |
| | | value: 'true', |
| | | text: '是' |
| | | }] |
| | | }, |
| | | { |
| | | type: 'radio', |
| | | key: 'editType', |
| | | label: '编辑类型', |
| | | initVal: card.editType || 'text', |
| | | required: true, |
| | | options: [{ |
| | | value: 'text', |
| | | text: '文本' |
| | | }, { |
| | | value: 'select', |
| | | text: '下拉' |
| | | }, { |
| | | value: 'switch', |
| | | text: '开关' |
| | | }] |
| | | }, |
| | | { |
| | | type: 'text', |
| | | key: 'initval', |
| | | label: '默认值', |
| | | initVal: card.initval, |
| | | tooltip: '使用$copy时,表示新增时复制上一行信息。', |
| | | required: false |
| | | }, |
| | | { |
| | | type: 'text', |
| | | key: 'openVal', |
| | | label: '开启值', |
| | | initVal: card.openVal || '', |
| | | required: false |
| | | }, |
| | | { |
| | | type: 'text', |
| | | key: 'closeVal', |
| | | label: '关闭值', |
| | | initVal: card.closeVal || '', |
| | | required: false |
| | | }, |
| | | { |
| | | type: 'text', |
| | | key: 'openText', |
| | | label: '开启提示', |
| | | initVal: card.openText || '', |
| | | required: false |
| | | }, |
| | | { |
| | | type: 'text', |
| | | key: 'closeText', |
| | | label: '关闭提示', |
| | | initVal: card.closeText || '', |
| | | required: false |
| | | }, |
| | | { |
| | | type: 'radio', |
| | | key: 'resourceType', |
| | | label: '选项来源', |
| | | initVal: card.resourceType || '0', |
| | | required: true, |
| | | options: [{ |
| | | value: '0', |
| | | text: '自定义' |
| | | }, { |
| | | value: '1', |
| | | text: '数据源' |
| | | }] |
| | | }, |
| | | { |
| | | type: 'select', |
| | | key: 'editField', |
| | | label: '编辑字段', |
| | | initVal: card.editField || '', |
| | | tooltip: '当值与提示文字不同时,可额外添加编辑字段,作为实际值的录入字段。', |
| | | allowClear: true, |
| | | required: false, |
| | | options: fields |
| | | }, |
| | | { |
| | | type: 'options', |
| | | key: 'options', |
| | | label: '选项', |
| | | initVal: card.options || [], |
| | | required: true, |
| | | }, |
| | | { |
| | | type: 'codemirror', |
| | | key: 'dataSource', |
| | | label: '数据源', |
| | | initVal: card.dataSource || '', |
| | | required: true, |
| | | }, |
| | | { |
| | | type: 'text', |
| | | key: 'valueField', |
| | | label: '值·字段', |
| | | initVal: card.valueField || '', |
| | | required: true, |
| | | }, |
| | | { |
| | | type: 'text', |
| | | key: 'valueText', |
| | | label: '文本·字段', |
| | | initVal: card.valueText || '', |
| | | required: true, |
| | | }, |
| | | { |
| | | type: 'text', |
| | | key: 'orderBy', |
| | | label: '排序·字段', |
| | | initVal: card.orderBy || '', |
| | | required: false, |
| | | }, |
| | | { |
| | | type: 'select', |
| | | key: 'orderType', |
| | | label: '排序方式', |
| | | initVal: card.orderType || 'asc', |
| | | options: [{ |
| | | value: 'asc', |
| | | text: Formdict['header.form.asc'] |
| | | }, { |
| | | value: 'desc', |
| | | text: Formdict['header.form.desc'] |
| | | }] |
| | | }, |
| | | { |
| | | type: 'text', |
| | | key: 'disableField', |
| | | label: '禁用·字段', |
| | | initVal: card.disableField || '', |
| | | tooltip: '设置禁用字段,且字段值为true时,选项不可选。', |
| | | required: false, |
| | | }, |
| | | { |
| | | type: 'radio', |
| | | key: 'dropdown', |
| | | label: '下拉宽度', |
| | | initVal: card.dropdown || 'flex', |
| | | required: false, |
| | | options: [{ |
| | | value: 'flex', |
| | | text: '自适应' |
| | | }, { |
| | | value: 'fixed', |
| | | text: '定宽' |
| | | }] |
| | | }, |
| | | { |
| | | type: 'radio', |
| | | key: 'required', |
| | | label: '必填', |
| | | initVal: card.required || 'false', |
| | | required: false, |
| | | options: [{ |
| | | value: 'false', |
| | | text: '否' |
| | | }, { |
| | | value: 'true', |
| | | text: '是' |
| | | }] |
| | | }, |
| | | { |
| | | type: 'radio', |
| | | key: 'database', |
| | | label: '数据库', |
| | | initVal: card.database || 'local', |
| | | options: [{ |
| | | value: 'local', |
| | | text: '本地' |
| | | }, { |
| | | value: 'sso', |
| | | text: '系统' |
| | | }] |
| | | }, |
| | | { |
| | | type: 'select', |
| | | key: 'enter', |
| | | label: '回车切换', |
| | | initVal: card.enter || '$next', |
| | | tooltip: '包括文本或数值回车事件、下拉菜单选中事件、开关切换事件。', |
| | | options: editCols |
| | | }, |
| | | // { |
| | | // type: 'radio', |
| | | // key: 'footEnter', |
| | | // label: '末行回车', |
| | | // initVal: card.footEnter || 'false', |
| | | // tooltip: '新增功能仅在表格可新增时有效。', |
| | | // options: [{ |
| | | // value: 'sub', |
| | | // text: '提交' |
| | | // }, { |
| | | // value: 'add', |
| | | // text: '新增' |
| | | // }, { |
| | | // value: 'false', |
| | | // text: '无动作' |
| | | // }] |
| | | // }, |
| | | { |
| | | type: 'number', |
| | | key: 'decimal', |
| | | min: 0, |
| | | max: 18, |
| | | decimal: 0, |
| | | precision: 0, |
| | | label: Formdict['header.form.decimal'], |
| | | initVal: card.decimal || 0, |
| | | required: true |
| | | }, |
| | | { |
| | | type: 'number', |
| | | key: 'min', |
| | | label: '最小值', |
| | | initVal: card.min, |
| | | unlimit: true, |
| | | required: false |
| | | }, |
| | | { |
| | | type: 'number', |
| | | key: 'max', |
| | | label: '最大值', |
| | | initVal: card.max, |
| | | unlimit: true, |
| | | required: false |
| | | }, |
| | | { |
| | | type: 'select', |
| | |
| | | text: Formdict['model.empty'] |
| | | }, { |
| | | value: 'thdSeparator', |
| | | text: Formdict['header.form.thdSeparator'] |
| | | text: '千分位' |
| | | }, { |
| | | value: 'percent', |
| | | text: '百分比' |
| | | }, { |
| | | value: 'abs', |
| | | text: '绝对值' |
| | | }], |
| | | required: false |
| | | }, |
| | |
| | | label: Formdict['header.form.prefix'], |
| | | initVal: card.prefix || '', |
| | | required: false, |
| | | readonly: false |
| | | }, |
| | | { |
| | | type: 'text', |
| | |
| | | label: Formdict['header.form.postfix'], |
| | | initVal: card.postfix || '', |
| | | required: false, |
| | | readonly: false |
| | | }, |
| | | { |
| | | type: 'select', |
| | | key: 'lenWidRadio', |
| | | label: '长宽比', |
| | | initVal: card.lenWidRadio || '1:1', |
| | | required: true, |
| | | type: 'radio', |
| | | key: 'eval', |
| | | label: '解析', |
| | | initVal: card.eval || 'true', |
| | | tooltip: '当公式内容涉及计算时请选择“是”,当公式内容为字段拼接时请选择“否”。', |
| | | required: false, |
| | | options: [ |
| | | { value: '1:1', text: '1:1' }, |
| | | { value: '4:3', text: '4:3' }, |
| | | { value: '3:2', text: '3:2' }, |
| | | { value: '16:9', text: '16:9' }, |
| | | { value: '2:1', text: '2:1' }, |
| | | { value: '3:1', text: '3:1' }, |
| | | { value: '4:1', text: '4:1' }, |
| | | { value: '5:1', text: '5:1' }, |
| | | { value: '6:1', text: '6:1' }, |
| | | { value: '7:1', text: '7:1' }, |
| | | { value: '8:1', text: '8:1' }, |
| | | { value: '9:1', text: '9:1' }, |
| | | { value: '10:1', text: '10:1' }, |
| | | { value: '3:4', text: '3:4' }, |
| | | { value: '2:3', text: '2:3' }, |
| | | { value: '9:16', text: '9:16' }, |
| | | { value: 'true', text: '是' }, |
| | | { value: 'false', text: '否' } |
| | | ] |
| | | }, |
| | | { |
| | | type: 'radio', |
| | | key: 'picSort', |
| | | label: '图片排列', |
| | | initVal: card.picSort || '1', |
| | | tooltip: '同一单元格内,含有多张图片时的列数。', |
| | | required: false, |
| | | options: [{ |
| | | value: '1', |
| | | text: '1' |
| | | }, { |
| | | value: '2', |
| | | text: '2' |
| | | }, { |
| | | value: '3', |
| | | text: '3' |
| | | }, { |
| | | value: '4', |
| | | text: '4' |
| | | }] |
| | | }, |
| | | { |
| | | type: 'radio', |
| | | key: 'scale', |
| | | label: Formdict['header.form.clickscale'], |
| | | initVal: card.scale || 'false', |
| | | required: false, |
| | | options: [{ |
| | | value: 'true', |
| | | text: Formdict['model.true'] |
| | | }, { |
| | | value: 'false', |
| | | text: Formdict['model.false'] |
| | | }] |
| | | }, |
| | | { |
| | | type: 'radio', |
| | | key: 'perspective', |
| | | label: '字段透视', |
| | | initVal: card.perspective || '', |
| | | options: [{ |
| | | value: '', |
| | | text: '无' |
| | | }, { |
| | | value: 'linkmenu', |
| | | text: '菜单' |
| | | }, { |
| | | value: 'linkurl', |
| | | text: '链接' |
| | | }], |
| | | forbidden: appType === 'mob' |
| | | }, |
| | | { |
| | | type: appType === 'pc' ? 'select' : 'cascader', |
| | | key: 'linkmenu', |
| | | label: Formdict['model.menu'], |
| | | initVal: card.linkmenu || (appType === 'pc' ? '' : []), |
| | | required: true, |
| | | options: menulist, |
| | | forbidden: appType === 'mob' |
| | | }, |
| | | { |
| | | type: 'textarea', |
| | | key: 'linkurl', |
| | | label: '链接地址', |
| | | initVal: card.linkurl || '', |
| | | required: true, |
| | | forbidden: appType === 'mob' |
| | | key: 'formula', |
| | | label: '公式', |
| | | initVal: card.formula || '', |
| | | tooltip: '执行时会使用查询到的数据替换相应的字段,展示获得的结果,在不使用解析时换行符或空格会替换为页面元素。可使用JS的一些语法,如:三元表达式 @field1@ > @field2@ ? 0 : 1;Math对象,取绝对值 Math.abs(@field@)、四舍五入 Math.round(@field@)等', |
| | | placeholder: '例如:@price@ * @number@', |
| | | required: true |
| | | }, |
| | | { |
| | | type: 'multiselect', |
| | | key: 'linkfields', |
| | | label: '关联字段', |
| | | initVal: card.linkfields || [], |
| | | required: false, |
| | | options: fields, |
| | | forbidden: appType === 'mob' |
| | | }, |
| | | { |
| | | type: 'radio', |
| | | key: 'open', |
| | | label: '打开方式', |
| | | initVal: card.open || 'blank', |
| | | required: false, |
| | | forbid: appType !== 'pc', |
| | | options: [ |
| | | { value: 'blank', text: '新窗口' }, |
| | | { value: 'self', text: '当前窗口' } |
| | | ] |
| | | key: 'linkSubField', |
| | | label: '填充表单', |
| | | tooltip: '在切换选项时会把信息自动填入关联的字段中。', |
| | | initVal: card.linkSubField || [], |
| | | options: fields |
| | | }, |
| | | { |
| | | type: 'multiselect', |