| | |
| | | import zhCN from '@/locales/zh-CN/model.js' |
| | | import enUS from '@/locales/en-US/model.js' |
| | | import { btnCustomClasses } from '@/utils/option.js' |
| | | |
| | | const Formdict = sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS |
| | | |
| | |
| | | */ |
| | | export function getActionForm (card, functip, config, usefulFields, type, menulist = [], modules = []) { |
| | | let appType = sessionStorage.getItem('appType') |
| | | let viewType = sessionStorage.getItem('editMenuType') // 弹窗 popview |
| | | let printTemps = sessionStorage.getItem('printTemps') |
| | | printTemps = printTemps ? JSON.parse(printTemps) : [] |
| | | let setting = config.setting || {} |
| | | let columns = config.columns || [] |
| | | let appMenus = [] |
| | |
| | | } |
| | | ] |
| | | |
| | | let getTabs = (list) => { |
| | | return list.filter(item => { |
| | | if (item.type !== 'tabs') return false |
| | | |
| | | item.children = item.children.map(cell => { |
| | | cell.children = getTabs(cell.children) |
| | | return cell |
| | | }) |
| | | return item |
| | | }) |
| | | } |
| | | |
| | | // if (type === 'editable') { |
| | | // opentypes = [ |
| | | // { |
| | | // value: 'excelIn', |
| | | // text: Formdict['model.form.excelIn'] |
| | | // }, { |
| | | // value: 'excelOut', |
| | | // text: Formdict['model.form.excelOut'] |
| | | // } |
| | | // ] |
| | | // } |
| | | |
| | | let tabs = getTabs(JSON.parse(JSON.stringify(modules))) |
| | | |
| | | let pageTemps = [ |
| | | { value: 'billprint', text: '单据打印' }, |
| | | { value: 'pay', text: Formdict['model.pay'] }, |
| | |
| | | const isApp = ['pc', 'mob'].includes(appType) |
| | | |
| | | let funTypes = [ |
| | | { value: 'changeuser', text: Formdict['header.form.func.changeuser'] }, |
| | | { value: 'changeuser', text: '切换用户' }, |
| | | { value: 'print', text: '标签打印' }, |
| | | { value: 'closetab', text: '标签关闭' }, |
| | | ] |
| | | |
| | | if (isApp) { |
| | | pageTemps = [ |
| | | // { value: 'page', text: '菜单' }, |
| | | { value: 'linkpage', text: '关联菜单' }, |
| | | { value: 'billprint', text: '单据打印' }, |
| | | { value: 'pay', text: Formdict['model.pay'] }, |
| | | { value: 'custom', text: '链接' } |
| | | ] |
| | | funTypes = [ |
| | | { value: 'changeuser', text: Formdict['header.form.func.changeuser'] }, |
| | | ] |
| | | appMenus = sessionStorage.getItem('appMenus') |
| | | if (appMenus) { |
| | | try { |
| | |
| | | } else { |
| | | appMenus = [] |
| | | } |
| | | |
| | | if (appType === 'mob') { |
| | | opentypes = opentypes.filter(item => ['pop', 'prompt', 'exec', 'innerpage', 'funcbutton'].includes(item.value)) |
| | | funTypes = [ |
| | | { value: 'mkBinding', text: '开通扫码登录' }, |
| | | { value: 'mkUnBinding', text: '用户解绑' }, |
| | | // { value: 'scan', text: '扫一扫' }, |
| | | { value: 'reAuth', text: '重新授权' }, |
| | | ] |
| | | } else { |
| | | opentypes = opentypes.filter(item => item.value !== 'tab') |
| | | } |
| | | } |
| | | if (appType === 'mob') { |
| | | opentypes = opentypes.filter(item => ['pop', 'prompt', 'exec', 'innerpage', 'funcbutton'].includes(item.value)) |
| | | funTypes = [ |
| | | { value: 'scan', text: '扫码' }, |
| | | { value: 'logout', text: '退出' }, |
| | | { value: 'mkBinding', text: '开通扫码登录' }, |
| | | { value: 'mkUnBinding', text: '用户解绑' }, |
| | | { value: 'mkUnsubscribe', text: '注销账户' }, |
| | | { value: 'reAuth', text: '切换系统(清空缓存-小程序)' }, |
| | | { value: 'goBack', text: '返回' }, |
| | | ] |
| | | pageTemps = [ |
| | | { value: 'linkpage', text: '关联菜单' }, |
| | | { value: 'custom', text: '链接' } |
| | | ] |
| | | } else if (appType === 'pc') { |
| | | opentypes = opentypes.filter(item => item.value !== 'tab') |
| | | funTypes = [ |
| | | { value: 'changeuser', text: '切换用户' }, |
| | | ] |
| | | pageTemps = [ |
| | | { value: 'linkpage', text: '关联菜单' }, |
| | | { value: 'billprint', text: '单据打印' }, |
| | | { value: 'pay', text: Formdict['model.pay'] }, |
| | | { value: 'custom', text: '链接' } |
| | | ] |
| | | } |
| | | |
| | | if (type === 'chart' && appType !== 'mob') { |
| | |
| | | } |
| | | |
| | | let refresh = [] |
| | | if (sessionStorage.getItem('editMenuType') === 'popview') { // 弹窗标签 |
| | | if (viewType === 'popview') { // 弹窗标签 |
| | | opentypes = opentypes.filter(item => item.value !== 'popview' && item.value !== 'funcbutton') |
| | | refresh.push({ |
| | | value: 'popclose', |
| | | text: '标签刷新' |
| | | value: 'closepoptab', // 关闭弹窗标签 |
| | | text: '关闭弹窗' |
| | | }) |
| | | refresh.push({ |
| | | value: 'popclose', // 执行弹窗关闭时的刷新 |
| | | text: '刷新源组件' |
| | | }) |
| | | } |
| | | |
| | | if (type === 'card') { |
| | | opentypes.push({ |
| | | value: 'form', |
| | | text: '表单' |
| | | }) |
| | | } |
| | | |
| | | if (!card.control && card.controlField) { |
| | | card.control = 'disabled' |
| | | } |
| | | if (appType === 'mob' && card.control === 'parent') { |
| | | card.control = '' |
| | | } |
| | | |
| | | let forms = [ |
| | |
| | | { |
| | | type: 'select', |
| | | key: 'funcType', |
| | | label: Formdict['header.form.funcType'], |
| | | label: '功能类型', |
| | | initVal: card.funcType || '', |
| | | required: true, |
| | | options: funTypes |
| | | }, |
| | | { |
| | | type: 'radio', |
| | | key: 'formType', |
| | | label: '表单类型', |
| | | initVal: card.formType || 'switch', |
| | | required: true, |
| | | options: [{ |
| | | value: 'switch', |
| | | text: '开关' |
| | | }, { |
| | | value: 'radio', |
| | | text: '勾选框' |
| | | }] |
| | | }, |
| | | { |
| | | type: 'select', |
| | |
| | | label: '按钮名称', |
| | | initVal: card.label, |
| | | required: true, |
| | | readonly: false |
| | | }, |
| | | { |
| | | type: 'radio', |
| | |
| | | initVal: card.innerFunc || '', |
| | | tooltip: functip, |
| | | fields: usefulFields, |
| | | tooltipClass: 'middle', |
| | | required: false, |
| | | readonly: false |
| | | }, |
| | | { |
| | | type: 'select', |
| | |
| | | }, |
| | | { |
| | | type: 'select', |
| | | key: 'printTemp', |
| | | label: '打印模板', |
| | | initVal: card.printTemp || '', |
| | | required: true, |
| | | options: printTemps |
| | | }, |
| | | { |
| | | type: isApp ? 'select' : 'cascader', |
| | | key: 'linkmenu', |
| | | label: '关联菜单', |
| | | initVal: card.linkmenu || '', |
| | | initVal: card.linkmenu || (isApp ? '' : []), |
| | | required: true, |
| | | forbid: !isApp, |
| | | options: appMenus |
| | | options: isApp ? appMenus : menulist |
| | | }, |
| | | { |
| | | type: 'textarea', |
| | |
| | | label: Formdict['header.form.outerFunc'], |
| | | initVal: card.outerFunc || '', |
| | | required: false, |
| | | readonly: false |
| | | }, |
| | | { |
| | | type: 'textarea', |
| | |
| | | label: Formdict['header.form.callbackFunc'], |
| | | initVal: card.callbackFunc || '', |
| | | required: false, |
| | | readonly: false |
| | | }, |
| | | { |
| | | type: 'select', |
| | | key: 'Ot', |
| | | label: Formdict['header.form.isRequired'], |
| | | initVal: card.Ot || 'requiredSgl', |
| | | initVal: card.Ot || (card.sqlType === 'insert' ? 'notRequired' : 'requiredSgl'), |
| | | required: true, |
| | | forbid: card.$type === 'tableButton', |
| | | options: [] |
| | | }, |
| | | { |
| | | type: 'cascader', |
| | | key: 'linkmenu', |
| | | label: Formdict['model.form.linkmenu'], |
| | | initVal: card.linkmenu || [], |
| | | required: true, |
| | | forbid: isApp, |
| | | options: menulist |
| | | }, |
| | | { |
| | | type: 'cascader', |
| | | key: 'refreshTab', |
| | | label: '刷新标签', |
| | | initVal: card.refreshTab || [], |
| | | required: false, |
| | | forbid: isApp, |
| | | options: menulist |
| | | }, |
| | | { |
| | | type: 'select', |
| | | key: 'execSuccess', |
| | | label: Formdict['model.form.afterSuccess'], |
| | | initVal: card.execSuccess || 'never', |
| | | tooltip: refresh.length ? '执行标签刷新时,会同步刷新当前组件和上级组件-行。' : '刷新上级组件-行时,会同步刷新当前组件,注:上级组件在数据源中添加。', |
| | | initVal: card.execSuccess || 'grid', |
| | | tooltip: refresh.length ? '执行刷新源组件时,请在源按钮中设置关闭后刷新那一项,注:此时会同步刷新当前组件和上级组件-行。' : '刷新上级组件-行时,会同步刷新当前组件,注:上级组件在数据源中添加。', |
| | | required: true, |
| | | options: [{ |
| | | value: 'never', |
| | |
| | | value: 'grid', |
| | | text: '刷新当前组件' |
| | | }, { |
| | | value: 'line', |
| | | text: '刷新行' |
| | | }, { |
| | | value: 'mainline', |
| | | text: '刷新上级组件 - 行' |
| | | }, { |
| | | value: !appType ? 'closetab' : 'goback', |
| | | text: !appType ? '关闭标签' : '返回(上一个页面)' |
| | | }, |
| | | ...refresh] |
| | | }, |
| | |
| | | key: 'execError', |
| | | label: Formdict['model.form.afterError'], |
| | | initVal: card.execError || 'never', |
| | | tooltip: refresh.length ? '执行标签关闭刷新时,会同步刷新当前组件和上级组件-行。' : '刷新上级组件-行时,会同步刷新当前组件,注:上级组件在数据源中添加。', |
| | | tooltip: refresh.length ? '执行刷新源组件时,请在源按钮中设置关闭后刷新那一项,注:此时会同步刷新当前组件和上级组件-行。' : '刷新上级组件-行时,会同步刷新当前组件,注:上级组件在数据源中添加。', |
| | | required: true, |
| | | options: [{ |
| | | value: 'never', |
| | |
| | | }, { |
| | | value: 'grid', |
| | | text: '刷新当前组件' |
| | | }, { |
| | | value: 'line', |
| | | text: '刷新行' |
| | | }, { |
| | | value: 'mainline', |
| | | text: '刷新上级组件 - 行' |
| | |
| | | label: '显示为', |
| | | initVal: card.show || 'button', |
| | | required: true, |
| | | forbid: type === 'datacard' && appType === 'mob', // 移动端,滑动显示的按钮只显示文字 |
| | | options: [{ |
| | | value: 'icon', |
| | | text: '图标' |
| | |
| | | type: 'radio', |
| | | key: 'swipe', |
| | | label: "滑动显示", |
| | | initVal: card.swipe || 'false', |
| | | initVal: card.swipe === 'false' ? 'left' : (card.swipe || 'left'), // 移动端仅保留滑动显示按钮 |
| | | required: false, |
| | | forbid: (type !== 'datacard' || appType !== 'mob'), |
| | | options: [{ |
| | | value: 'false', |
| | | text: '否' |
| | | }, { |
| | | // value: 'false', |
| | | // text: '否' |
| | | // }, { |
| | | value: 'left', |
| | | text: '左滑' |
| | | }, { |
| | |
| | | label: Formdict['model.icon'], |
| | | initVal: card.icon, |
| | | required: false, |
| | | forbid: type === 'datacard' && appType === 'mob', // 移动端,滑动显示的按钮只显示文字 |
| | | options: [] |
| | | }, |
| | | { |
| | |
| | | initVal: card.class, |
| | | tooltip: '此颜色为按钮初始化颜色,可在样式调整中修改。', |
| | | required: false, |
| | | options: [] |
| | | forbid: type === 'datacard' && appType === 'mob', // 移动端,滑动显示的按钮不设置通用颜色 |
| | | options: btnCustomClasses |
| | | }, |
| | | { |
| | | type: 'radio', |
| | | key: 'color', |
| | | label: Formdict['model.form.color'], |
| | | initVal: card.color || 'primary', |
| | | required: false, |
| | | forbid: (type !== 'datacard' || appType !== 'mob'), // 移动端,滑动显示的按钮只可设置固定颜色 |
| | | options: [{ |
| | | value: 'primary', |
| | | text: '蓝' |
| | | }, { |
| | | value: 'danger', |
| | | text: '红' |
| | | }, { |
| | | value: 'warning', |
| | | text: '橙' |
| | | }, { |
| | | value: 'success', |
| | | text: '绿' |
| | | }, { |
| | | value: 'light', |
| | | text: '灰' |
| | | }] |
| | | }, |
| | | { |
| | | type: 'radio', |
| | |
| | | { |
| | | type: 'radio', |
| | | key: 'pagination', |
| | | label: Formdict['header.form.pagination'], |
| | | label: '分页', |
| | | initVal: card.pagination || 'false', |
| | | required: false, |
| | | options: [{ |
| | |
| | | }] |
| | | }, |
| | | { |
| | | type: 'mcascader', |
| | | type: 'cascader', |
| | | key: 'syncComponent', |
| | | label: '同步刷新', |
| | | label: '刷新组件', |
| | | initVal: card.syncComponent || [], |
| | | tooltip: '执行成功后(或弹窗标签关闭时),需要同步刷新的组件', |
| | | required: false, |
| | | options: modules |
| | | }, |
| | | { |
| | | type: 'select', |
| | | key: 'controlField', |
| | | label: '控制字段', |
| | | tooltip: '禁用控制字段,可根据数据控制按钮是否禁用。', |
| | | initVal: card.controlField || '', |
| | | type: 'cascader', |
| | | key: 'switchTab', |
| | | label: '切换标签', |
| | | initVal: card.switchTab || [], |
| | | tooltip: '执行成功后,需要切换的标签页', |
| | | required: false, |
| | | allowClear: true, |
| | | options: columns |
| | | options: tabs |
| | | }, |
| | | { |
| | | type: 'text', |
| | | key: 'controlVal', |
| | | label: '控制值', |
| | | tooltip: '当选择控制字段,且字段值与控制值相等时,按钮会禁用,多个值用逗号分隔。', |
| | | initVal: card.controlVal || '', |
| | | required: false |
| | | type: 'cascader', |
| | | key: 'refreshTab', |
| | | label: '刷新菜单', |
| | | initVal: card.refreshTab || [], |
| | | tooltip: '执行成功后(或功能按钮中标签关闭类型),需要同步刷新的菜单', |
| | | required: false, |
| | | forbid: isApp || viewType === 'popview', |
| | | options: menulist |
| | | }, |
| | | { |
| | | type: 'select', |
| | | type: !appType ? 'cascader' : 'select', |
| | | key: 'openmenu', |
| | | label: '打开菜单', |
| | | tooltip: '执行成功后需要打开的菜单。', |
| | | initVal: card.openmenu || '', |
| | | forbid: appType !== 'pc' && appType !== 'mob', |
| | | initVal: card.openmenu || (!appType ? [] : ''), |
| | | required: false, |
| | | allowClear: true, |
| | | options: appType !== 'mob' ? appMenus : [...appMenus, {value: 'goback', text: '返回'}] |
| | | options: appType === 'mob' ? [...appMenus, {value: 'goback', text: '返回'}] : (appType === 'pc' ? appMenus : menulist), |
| | | forbid: viewType === 'popview' |
| | | }, |
| | | { |
| | | type: 'text', |
| | |
| | | label: '返回值', |
| | | tooltip: '执行成功后的返回值。', |
| | | initVal: card.output || '', |
| | | forbid: appType !== 'pc' && appType !== 'mob', |
| | | required: false, |
| | | forbid: viewType === 'popview' |
| | | }, |
| | | { |
| | | type: 'text', |
| | | key: 'tipTitle', |
| | | label: '确认提示', |
| | | initVal: card.tipTitle || '', |
| | | tooltip: '注:弹窗(表单)在显示为是否框时有效。', |
| | | required: false |
| | | }, |
| | | { |
| | |
| | | type: 'number', |
| | | key: 'ratio', |
| | | min: 1, |
| | | max: 24, |
| | | max: 3000, |
| | | precision: 0, |
| | | label: '比例', |
| | | initVal: card.ratio || 85, |
| | |
| | | key: 'placement', |
| | | label: '抽屉方向', |
| | | initVal: card.placement || 'right', |
| | | tooltip: '使用抽屉时有效。', |
| | | required: false, |
| | | options: [{ |
| | | value: 'right', |
| | |
| | | text: '下侧' |
| | | }] |
| | | }, |
| | | { |
| | | type: 'radio', |
| | | key: 'clickouter', |
| | | label: '点击蒙层', |
| | | initVal: card.clickouter || 'unclose', |
| | | required: false, |
| | | options: [{ |
| | | value: 'unclose', |
| | | text: '不关闭' |
| | | }, { |
| | | value: 'close', |
| | | text: '关闭' |
| | | }] |
| | | }, |
| | | { |
| | | type: 'radio', |
| | | key: 'reload', |
| | | label: '上一页', |
| | | initVal: card.reload || 'false', |
| | | tooltip: '成功后是否刷新上页的数据。注:在明科云APP或小程序中有效。', |
| | | forbid: appType !== 'mob', |
| | | options: [{ |
| | | value: 'false', |
| | | text: '不刷新' |
| | | }, { |
| | | value: 'true', |
| | | text: '刷新' |
| | | }] |
| | | }, |
| | | { |
| | | type: 'radio', |
| | | key: 'position', |
| | | label: '显示位置', |
| | | initVal: card.position || 'middle', |
| | | tooltip: '注:弹窗(表单)在显示为是否框时有效。', |
| | | required: false, |
| | | forbid: appType !== 'mob', |
| | | options: [{ |
| | | value: 'middle', |
| | | text: '中部' |
| | | }, { |
| | | value: 'bottom', |
| | | text: '底部' |
| | | }] |
| | | }, |
| | | { |
| | | type: 'radio', |
| | | key: 'control', |
| | | label: '按钮控制', |
| | | initVal: card.control || (card.controlField ? 'disabled' : ''), |
| | | tooltip: '当选择禁用或隐藏,且字段值与控制值相等时,按钮会隐藏或禁用。当选择上级,主表字段值与控制值相等或主表字段值不存在时,按钮会隐藏。注:多个值用逗号分隔', |
| | | required: false, |
| | | options: [{ |
| | | value: '', |
| | | text: '无' |
| | | }, { |
| | | value: 'disabled', |
| | | text: '禁用' |
| | | }, { |
| | | value: 'hidden', |
| | | text: '隐藏' |
| | | }, { |
| | | value: 'parent', |
| | | text: '上级' |
| | | }] |
| | | }, |
| | | { |
| | | type: 'select', |
| | | key: 'controlField', |
| | | label: '控制字段', |
| | | initVal: card.controlField || '', |
| | | required: true, |
| | | allowClear: true, |
| | | options: columns |
| | | }, |
| | | { |
| | | type: 'text', |
| | | key: 'controlVal', |
| | | label: '控制值', |
| | | initVal: card.controlVal || '', |
| | | required: false |
| | | }, |
| | | { |
| | | type: 'splitLine', |
| | | key: 'title', |
| | | label: '表单', |
| | | initVal: '' |
| | | }, |
| | | { |
| | | type: 'text', |
| | | key: 'field', |
| | | label: Formdict['model.form.field'], |
| | | initVal: card.field || '', |
| | | required: true, |
| | | readonly: false |
| | | }, |
| | | { |
| | | type: 'radio', |
| | | key: 'size', |
| | | label: '开关尺寸', |
| | | initVal: card.size || 'default', |
| | | options: [{ |
| | | value: 'default', |
| | | text: '大' |
| | | }, { |
| | | value: 'small', |
| | | text: '小' |
| | | }] |
| | | }, |
| | | { |
| | | type: 'text', |
| | | key: 'openVal', |
| | | label: '开启值', |
| | | initVal: card.openVal === undefined ? '' : card.openVal + '', |
| | | tooltip: '当开启与关闭值均为正整数时,默认转换为INT类型。', |
| | | required: false |
| | | }, |
| | | { |
| | | type: 'text', |
| | | key: 'closeVal', |
| | | label: '关闭值', |
| | | initVal: card.closeVal === undefined ? '' : card.closeVal + '', |
| | | tooltip: '当开启与关闭值均为正整数时,默认转换为INT类型。', |
| | | required: false |
| | | }, |
| | | { |
| | | type: 'text', |
| | | key: 'openText', |
| | | label: '开启提示', |
| | | initVal: card.openText || '', |
| | | required: false, |
| | | }, |
| | | { |
| | | type: 'text', |
| | | key: 'closeText', |
| | | label: '关闭提示', |
| | | initVal: card.closeText || '', |
| | | required: false, |
| | | }, |
| | | ] |
| | | |
| | | return forms |