king
2021-09-01 31ec63f0419895876cbaba99637a884a32d33d0d
src/menu/components/share/actioncomponent/formconfig.jsx
@@ -1,7 +1,7 @@
import zhCN from '@/locales/zh-CN/model.js'
import enUS from '@/locales/en-US/model.js'
const Formdict = localStorage.getItem('lang') !== 'en-US' ? zhCN : enUS
const Formdict = sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS
/**
 * @description 获取按钮表单配置信息
@@ -11,7 +11,11 @@
 * @param {*} usefulFields   存储过程可用的开始字段
 * @param {*} type           按钮类型,用于区分可选的打开方式
 */
export function getActionForm (card, functip, setting, usefulFields, type, menulist = [], modules = []) {
export function getActionForm (card, functip, config, usefulFields, type, menulist = [], modules = []) {
  let appType = sessionStorage.getItem('appType')
  let setting = config.setting || {}
  let columns = config.columns || []
  let appMenus = []
  let opentypes = [
    {
      value: 'pop',
@@ -43,7 +47,55 @@
    }
  ]
  if (type === 'chart') {
  let pageTemps = [
    { value: 'billprint', text: '单据打印' },
    { value: 'pay', text: Formdict['model.pay'] },
    { value: 'custom', text: Formdict['header.form.custom'] }
  ]
  const isApp = ['pc', 'mob'].includes(appType)
  let funTypes = [
    { value: 'changeuser', text: Formdict['header.form.func.changeuser'] },
    { 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 {
        appMenus = JSON.parse(appMenus)
      } catch (e) {
        appMenus = []
      }
    } 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 (type === 'chart' && appType !== 'mob') {
    opentypes = opentypes.filter(item => item.value === 'excelIn' || item.value === 'excelOut')
  }
@@ -69,15 +121,9 @@
      type: 'select',
      key: 'funcType',
      label: Formdict['header.form.funcType'],
      initVal: card.funcType || 'print',
      initVal: card.funcType || '',
      required: true,
      options: [{
        value: 'changeuser',
        text: Formdict['header.form.func.changeuser']
      }, {
        value: 'print',
        text: '标签打印'
      }]
      options: funTypes
    },
    {
      type: 'select',
@@ -102,23 +148,6 @@
      label: Formdict['header.form.intertype'],
      initVal: card.intertype || 'system',
      required: true,
      options: [{
        value: 'system',
        text: '系统'
      }, {
        value: 'inner',
        text: Formdict['model.interface.inner']
      }, {
        value: 'outer',
        text: Formdict['model.interface.outer']
      }]
    },
    {
      type: 'select',
      key: 'sqlType',
      label: Formdict['header.form.action.type'],
      initVal: card.sqlType || '',
      required: true,
      options: []
    },
    {
@@ -128,6 +157,28 @@
      initVal: card.label,
      required: true,
      readonly: false
    },
    {
      type: 'radio',
      key: 'procMode',
      label: '参数处理',
      initVal: card.procMode || 'system',
      required: true,
      options: [{
        value: 'system',
        text: '系统函数'
      }, {
        value: 'inner',
        text: '内部函数'
      }]
    },
    {
      type: 'radio',
      key: 'sqlType',
      label: Formdict['header.form.action.type'],
      initVal: card.sqlType || '',
      required: true,
      options: []
    },
    {
      type: 'text',
@@ -153,21 +204,21 @@
      label: Formdict['model.form.newpage.type'],
      initVal: card.pageTemplate || '',
      required: true,
      options: [{
        value: 'billprint',
        text: '单据打印'
      }, {
        value: 'pay',
        text: Formdict['model.pay']
      }, {
        value: 'custom',
        text: Formdict['header.form.custom']
      }]
      options: pageTemps
    },
    {
      type: 'text',
      type: 'select',
      key: 'linkmenu',
      label: '关联菜单',
      initVal: card.linkmenu || '',
      required: true,
      forbid: !isApp,
      options: appMenus
    },
    {
      type: 'textarea',
      key: 'url',
      label: Formdict['model.form.newpage.url'],
      label: Formdict['model.pageUrl'],
      initVal: card.url || '',
      required: true
    },
@@ -194,12 +245,71 @@
      readonly: false
    },
    {
      type: 'text',
      type: 'textarea',
      key: 'interface',
      label: Formdict['header.form.interface'],
      label: '测试地址',
      initVal: card.sysInterface === 'true' ? (window.GLOB.mainSystemApi || '') : (card.interface || ''),
      required: true,
      readonly: card.sysInterface === 'true'
    },
    {
      type: 'textarea',
      key: 'proInterface',
      label: '正式地址',
      initVal: card.proInterface || '',
      tooltip: '正式系统所使用的接口地址。',
      required: false
    },
    {
      type: 'radio',
      key: 'method',
      label: '请求方式',
      initVal: card.method || 'post',
      required: true,
      options: [{
        value: 'get',
        text: 'GET'
      }, {
        value: 'post',
        text: 'POST'
      }]
    },
    {
      type: 'radio',
      key: 'cross',
      label: '跨域请求',
      initVal: card.cross || 'true',
      tooltip: '如果自定义接口不支持跨域请求,会通过当前系统转发。',
      required: false,
      options: [{
        value: 'true',
        text: '支持'
      }, {
        value: 'false',
        text: '不支持'
      }]
    },
    {
      type: 'radio',
      key: 'callbackType',
      label: '回调方式',
      initVal: card.callbackType || 'script',
      tooltip: '使用后台脚本执行时,需要配合计划任务。',
      required: true,
      options: [{
        value: 'script',
        text: '自定义脚本'
      }, {
        value: 'default',
        text: '后台脚本'
      }]
    },
    {
      type: 'text',
      key: 'cbTable',
      label: '回调表名',
      initVal: card.cbTable || '',
      required: true
    },
    {
      type: 'text',
@@ -224,6 +334,16 @@
      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
    },
    {
@@ -308,24 +428,42 @@
      required: true
    },
    {
      type: 'select',
      type: 'radio',
      key: 'show',
      label: "显示为",
      initVal: card.show || 'icon',
      label: '显示为',
      initVal: card.show || 'button',
      required: true,
      options: [{
        value: 'icon',
        text: '图标'
      }, {
        value: 'button',
        text: '按钮'
        text: '图标+文字'
      }, {
        value: 'link',
        text: '链接'
        text: '文字+图标'
      }]
    },
    {
      type: 'select',
      type: 'radio',
      key: 'swipe',
      label: "滑动显示",
      initVal: card.swipe || 'false',
      required: false,
      forbid: (type !== 'datacard' || appType !== 'mob'),
      options: [{
        value: 'false',
        text: '否'
      }, {
        value: 'left',
        text: '左滑'
      }, {
        value: 'right',
        text: '右滑'
      }]
    },
    {
      type: 'icon',
      key: 'icon',
      label: Formdict['model.icon'],
      initVal: card.icon,
@@ -337,6 +475,7 @@
      key: 'class',
      label: Formdict['model.form.color'],
      initVal: card.class,
      tooltip: '此颜色为按钮初始化颜色,可在样式调整中修改。',
      required: false,
      options: []
    },
@@ -396,7 +535,106 @@
      initVal: card.syncComponent || [],
      required: false,
      options: modules
    }
    },
    {
      type: 'select',
      key: 'controlField',
      label: '控制字段',
      tooltip: '禁用控制字段,可根据数据控制按钮是否禁用。',
      initVal: card.controlField || '',
      required: false,
      allowClear: true,
      options: columns
    },
    {
      type: 'text',
      key: 'controlVal',
      label: '控制值',
      tooltip: '当选择控制字段,且字段值与控制值相等时,按钮会禁用,多个值用逗号分隔。',
      initVal: card.controlVal || '',
      required: false
    },
    {
      type: 'select',
      key: 'openmenu',
      label: '打开菜单',
      tooltip: '执行成功后需要打开的菜单。',
      initVal: card.openmenu || '',
      forbid: appType !== 'pc' && appType !== 'mob',
      required: false,
      allowClear: true,
      options: appMenus
    },
    {
      type: 'text',
      key: 'output',
      label: '返回值',
      tooltip: '执行成功后的返回值。',
      initVal: card.output || '',
      forbid: appType !== 'pc' && appType !== 'mob',
      required: false
    },
    {
      type: 'radio',
      key: 'open',
      label: '打开方式',
      initVal: card.open || 'blank',
      required: true,
      forbid: appType !== 'pc',
      options: [{
        value: 'blank',
        text: '新窗口'
      }, {
        value: 'self',
        text: '当前窗口'
      }]
    },
    {
      type: 'radio',
      key: 'display',
      label: '显示方式',
      initVal: card.display || 'modal',
      required: true,
      options: [{
        value: 'modal',
        text: '模态框'
      }, {
        value: 'drawer',
        text: '抽屉'
      }]
    },
    {
      type: 'number',
      key: 'ratio',
      min: 1,
      max: 24,
      precision: 0,
      label: '比例',
      initVal: card.ratio || 85,
      tooltip: '小于100为宽度(或高度)百分比,大于100为像素值。',
      required: true
    },
    {
      type: 'radio',
      key: 'placement',
      label: '抽屉方向',
      initVal: card.placement || 'right',
      tooltip: '使用抽屉时有效。',
      required: false,
      options: [{
        value: 'right',
        text: '右侧'
      }, {
        value: 'left',
        text: '左侧'
      }, {
        value: 'top',
        text: '上侧'
      }, {
        value: 'bottom',
        text: '下侧'
      }]
    },
  ]
  return forms