king
2023-06-28 f07c42a322f41e14ef5b1bf8f2fd66fc5d338cdd
src/menu/components/share/actioncomponent/formconfig.jsx
@@ -1,4 +1,4 @@
import { btnCustomClasses, btnClasses } from '@/utils/option.js'
import { btnClasses } from '@/utils/option.js'
/**
@@ -9,13 +9,13 @@
 * @param {*} usefulFields   存储过程可用的开始字段
 * @param {*} type           按钮类型,用于区分可选的打开方式
 */
export function getActionForm (card, functip, config, usefulFields, modules = [], anchors = []) {
export function getActionForm (card, functip, config, usefulFields, modules = [], anchors = [], side) {
  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 columns = side === 'sub' && config.subColumns ? config.subColumns : (config.columns || [])
  let appMenus = []
  let menulist = []
  let type = ''
@@ -97,7 +97,6 @@
    { value: 'print', text: '标签打印' },
    { value: 'refund', text: '退款' },
    { value: 'closetab', text: '标签关闭' },
    { value: 'changeuser', text: '切换用户' },
    { value: 'megvii', text: '旷视面板机' },
    { value: 'filezip', text: '文件压缩包' },
  ]
@@ -113,6 +112,7 @@
    } else {
      appMenus = []
    }
    appMenus.push({value: 'goback', text: '返回(上一页)'})
  } else {
    menulist = sessionStorage.getItem('fstMenuList')
    if (menulist) {
@@ -137,6 +137,7 @@
      { value: 'mkUnBinding', text: '用户解绑' },
      { value: 'mkUnsubscribe', text: '注销账户' },
      { value: 'reAuth', text: '切换系统(清空缓存-小程序)' },
      { value: 'clearCache', text: '清空本地配置' },
      { value: 'copyurl', text: '复制链接地址' },
      { value: 'logout', text: '退出' },
      { value: 'goBack', text: '返回' },
@@ -149,7 +150,6 @@
    opentypes = opentypes.filter(item => item.value !== 'tab')
    funTypes = [
      { value: 'print', text: '标签打印' },
      { value: 'changeuser', text: '切换用户' },
    ]
    pageTemps = [
      { value: 'linkpage', text: '关联菜单' },
@@ -157,6 +157,25 @@
      { value: 'pay', text: '支付' },
      { value: 'custom', text: '链接' }
    ]
  } else {
    if (card.pageTemplate === 'print') { // 原类型支持
      pageTemps.unshift({ value: 'print', text: '标签打印模板' })
    } else if (card.pageTemplate === 'billprintTemp') { // 原类型支持
      pageTemps.unshift({ value: 'billprintTemp', text: '单据打印模板' })
    }
  }
  if (card.funcType === 'changeuser') { // 原类型支持
    funTypes.unshift({ value: 'changeuser', text: '切换用户' })
  }
  if (config.subtype === 'editable') { // 编辑表的添加、删除
    funTypes.push(
      { value: 'addline', text: '增加行(编辑表)' },
      { value: 'delline', text: '删除行(编辑表)' }
    )
  } else if (card.funcType === 'addline' || card.funcType === 'delline') {
    card.funcType = ''
  }
  
  if (type === 'chart' && appType !== 'mob') {
@@ -169,7 +188,10 @@
  let refresh = []
  if (viewType === 'popview') { // 弹窗标签
    opentypes = opentypes.filter(item => item.value !== 'popview' && item.value !== 'funcbutton')
    opentypes = opentypes.filter(item => item.value !== 'popview')
    funTypes = funTypes.filter(item => item.value !== 'print')
    refresh.push({
      value: 'closepoptab', // 关闭弹窗标签
      text: '关闭弹窗'
@@ -223,7 +245,7 @@
    {
      type: 'select',
      key: 'OpenType',
      label: '打开方式',
      label: '按钮类型',
      initVal: card.OpenType,
      required: true,
      options: opentypes
@@ -254,7 +276,7 @@
      ]
    },
    {
      type: 'radio',
      type: formTypes.length ? 'select' : 'radio',
      key: 'formType',
      label: '表单类型',
      initVal: card.formType || 'switch',
@@ -265,6 +287,12 @@
      }, {
        value: 'radio',
        text: '勾选框'
      }, {
        value: 'counter',
        text: '计数器'
      }, {
        value: 'count_line',
        text: '计数器(本地)'
      }, 
      ...formTypes]
    },
@@ -312,7 +340,7 @@
      key: 'procMode',
      label: '参数处理',
      initVal: card.procMode || (card.innerFunc ? 'inner' : 'system'),
      tooltip: '当返回值存在 mk_ex_invoke 且值为 false 时,不会调用外部接口。',
      tooltip: '当返回值存在 mk_ex_invoke 且值为 false 时,不会调用外部接口。注:当选“无”时,按钮选行时会传递主键,存在表单时会传递表单字段,存在BID时会传BID字段。',
      required: true,
      options: [{
        value: 'system',
@@ -384,11 +412,28 @@
      options: isApp ? appMenus : menulist
    },
    {
      type: 'text',
      key: 'prefix',
      label: '前缀',
      initVal: card.prefix || '',
      tooltip: '扫码信息将与前缀拼接后执行。注:跳转菜单需以mkbid开头。',
      required: false
    },
    {
      type: 'textarea',
      key: 'url',
      label: '页面地址',
      initVal: card.url || '',
      tooltip: appType === '' ? '地址格式为:http://******/admin/index.html#/iframe/menuId/loginuid/BID 会打开标签页。注:使用@loginuid@时自动替换为当前系统的loginuid;选择单行且拼接参数时会拼接BID。' : '',
      required: true
    },
    {
      type: 'textarea',
      key: 'proUrl',
      label: '正式地址',
      initVal: card.proUrl || '',
      tooltip: appType === '' ? '地址格式为:http://******/admin/index.html#/iframe/menuId/loginuid/BID 会打开标签页。注:使用@loginuid@时自动替换为当前系统的loginuid;选择单行且拼接参数时会拼接BID。' : '',
      required: false
    },
    {
      type: 'radio',
@@ -448,35 +493,6 @@
    },
    {
      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 || (card.callbackFunc ? 'func' : 'none'),
@@ -511,6 +527,52 @@
      required: true
    },
    {
      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: 'stringify',
      label: '序列化',
      initVal: card.stringify || 'text',
      required: false,
      options: [{
        value: 'text',
        text: 'Text'
      }, {
        value: 'JSON',
        text: 'JSON'
      }, {
        value: 'qs',
        text: 'qs'
      }]
    },
    {
      type: 'select',
      key: 'Ot',
      label: '行设置',
@@ -523,7 +585,7 @@
      key: 'execSuccess',
      label: '成功后',
      initVal: card.execSuccess || 'grid',
      tooltip: refresh.length ? '执行刷新源组件时,请在源按钮中设置关闭后刷新那一项,注:此时会同步刷新当前组件和上级组件-行。如需语音播报请以@speak@开头,播报内容或文件放置于<<>>中。' : '选择刷新行时,如果选择多条数据会刷新表格。注:上级组件在数据源中添加。如需语音播报请以@speak@开头,播报内容或文件放置于<<>>中。',
      tooltip: refresh.length ? '执行刷新源组件时,请在源按钮中设置关闭后刷新那一项,注:此时会同步刷新当前组件和上级组件-行。如需语音播报请以@speak@开头,播报内容或文件放置于<<>>中。返回信息中包含@close_tab@、@close_popup@、@goback@ 会执行(关闭标签-管理系统)、(关闭弹窗)、(返回上一页-子应用)等动作。' : '选择刷新行时,如果选择多条数据会刷新表格。注:上级组件在数据源中添加。如需语音播报请以@speak@开头,播报内容或文件放置于<<>>中。返回信息中包含@close_tab@、@close_popup@、@goback@ 会执行(关闭标签-管理系统)、(关闭弹窗)、(返回上一页-子应用)等动作。',
      required: true,
      options: [{
        value: 'never',
@@ -546,7 +608,7 @@
      key: 'execError',
      label: '失败后',
      initVal: card.execError || 'never',
      tooltip: refresh.length ? '执行刷新源组件时,请在源按钮中设置关闭后刷新那一项,注:此时会同步刷新当前组件和上级组件-行。如需语音播报请以@speak@开头,播报内容或文件放置于<<>>中。' : '选择刷新行时,如果选择多条数据会刷新表格,注:上级组件在数据源中添加。如需语音播报请以@speak@开头,播报内容或文件放置于<<>>中。',
      tooltip: refresh.length ? '执行刷新源组件时,请在源按钮中设置关闭后刷新那一项,注:此时会同步刷新当前组件和上级组件-行。如需语音播报请以@speak@开头,播报内容或文件放置于<<>>中。返回信息中包含@close_tab@、@close_popup@、@goback@ 会执行(关闭标签-管理系统)、(关闭弹窗)、(返回上一页-子应用)等动作。' : '选择刷新行时,如果选择多条数据会刷新表格,注:上级组件在数据源中添加。如需语音播报请以@speak@开头,播报内容或文件放置于<<>>中。返回信息中包含@close_tab@、@close_popup@、@goback@ 会执行(关闭标签-管理系统)、(关闭弹窗)、(返回上一页-子应用)等动作。',
      required: true,
      options: [{
        value: 'never',
@@ -659,7 +721,7 @@
      tooltip: '此颜色为按钮初始化颜色,可在样式调整中修改。',
      required: false,
      forbid: type === 'datacard' && appType === 'mob', // 移动端,滑动显示的按钮不设置通用颜色
      options: btnCustomClasses
      options: btnClasses
    },
    {
      type: 'radio',
@@ -683,6 +745,9 @@
      }, {
        value: 'light',
        text: '灰'
      }, {
        value: 'system',
        text: '系统'
      }]
    },
    {
@@ -713,7 +778,7 @@
      initVal: card.syncComponent || [],
      tooltip: '执行成功后(或弹窗标签关闭时),需要同步刷新的组件。注:选择当前组件的上级组件无效,刷新上级组件请选择成功后“刷新上级组件 - 行”。',
      required: false,
      options: modules
      options: modules.length ? [...modules, {value: 'multiComponent', label: '多组件'}] : []
    },
    {
      type: 'radio',
@@ -784,7 +849,7 @@
      extendName: 'MenuNo',
      required: false,
      allowClear: true,
      options: appType === 'mob' || appType === 'pc' ? [...appMenus, {value: 'goback', text: '返回(上一页)'}] : menulist,
      options: appType === 'mob' || appType === 'pc' ? appMenus : menulist,
      forbid: viewType === 'popview'
    },
    {
@@ -815,6 +880,19 @@
      options: [
        {value: 'blank', text: appType !== 'mob' ? '新窗口' : '新页面'},
        {value: 'self', text: appType !== 'mob' ? '当前窗口' : '当前页面'},
      ]
    },
    {
      type: 'radio',
      key: 'openTab',
      label: '打开方式',
      initVal: card.openTab || 'newtab',
      tooltip: '菜单打开方式。',
      forbid: appType !== '',
      options: [
        {value: 'newtab', text: '标签页'},
        // {value: 'newpage', text: '新页面(标签页)'},
        {value: 'view', text: '新页面(全屏)'}
      ]
    },
    {
@@ -939,6 +1017,15 @@
      }]
    },
    {
      type: 'text',
      key: 'preFunc',
      label: '前置函数',
      initVal: card.preFunc || '',
      tooltip: '前置函数执行完成后,结果会传入内部函数中,此时内部函数会异步执行;当前置函数返回中ErrCode等于-1时,将不再执行内部函数。',
      required: false,
      forbid: appType === 'mob'
    },
    {
      type: 'radio',
      key: 'control',
      label: '按钮控制',
@@ -1017,7 +1104,7 @@
    {
      type: 'radio',
      key: 'size',
      label: '开关尺寸',
      label: '尺寸',
      initVal: card.size || 'default',
      options: [{
        value: 'large',
@@ -1050,6 +1137,27 @@
      initVal: card.openVal === undefined ? '' : card.openVal + '',
      tooltip: '当开启与关闭值均为正整数时,默认转换为INT类型。',
      required: false
    },
    {
      type: 'number',
      key: 'min',
      label: '最小值',
      initVal: card.min,
      required: false
    },
    {
      type: 'number',
      key: 'max',
      label: '最大值',
      initVal: card.max,
      required: false
    },
    {
      type: 'number',
      key: 'decimal',
      label: '小数位',
      initVal: card.decimal || 0,
      required: true
    },
    {
      type: 'text',
@@ -1102,6 +1210,27 @@
        value: 'progressbar',
        text: '进度条'
      }]
    },
    {
      type: 'table',
      key: 'syncComponents',
      label: '组件列表',
      initVal: card.syncComponents || [],
      required: true,
      actions: [],
      columns: [
        {
          title: '组件',
          dataIndex: 'syncComId',
          inputType: 'cascader',
          editable: true,
          required: true,
          extends: [{key: 'label', value: 'label'}],
          width: '70%',
          render: (text, record) => record.label,
          options: modules
        }
      ]
    }
  ]
@@ -1161,14 +1290,23 @@
    { value: 'custom', text: '自定义' }
  ]
  if (card.pageTemplate === 'print') { // 原类型支持
    pageTemps.unshift({ value: 'print', text: '标签打印模板' })
  } else if (card.pageTemplate === 'billprintTemp') { // 原类型支持
    pageTemps.unshift({ value: 'billprintTemp', text: '单据打印模板' })
  }
  let funTypes = [
    { value: 'print', text: '标签打印' },
    { value: 'refund', text: '退款' },
    { value: 'closetab', text: '标签关闭' },
    { value: 'changeuser', text: '切换用户' },
    { value: 'megvii', text: '旷视面板机' },
    { value: 'filezip', text: '文件压缩包' },
  ]
  if (card.funcType === 'changeuser') { // 原类型支持
    funTypes.unshift({ value: 'changeuser', text: '切换用户' })
  }
  let menulist = sessionStorage.getItem('fstMenuList')
  if (menulist) {
@@ -1183,7 +1321,10 @@
  let refresh = []
  if (viewType === 'popview') { // 弹窗标签
    opentypes = opentypes.filter(item => item.value !== 'popview' && item.value !== 'funcbutton')
    opentypes = opentypes.filter(item => item.value !== 'popview')
    funTypes = funTypes.filter(item => item.value !== 'print')
    refresh.push({
      value: 'closepoptab', // 关闭弹窗标签
      text: '关闭弹窗'
@@ -1198,7 +1339,7 @@
    {
      type: 'select',
      key: 'OpenType',
      label: '打开方式',
      label: '按钮类型',
      initVal: card.OpenType,
      required: true,
      options: opentypes
@@ -1272,7 +1413,7 @@
      key: 'procMode',
      label: '参数处理',
      initVal: card.procMode || (card.innerFunc ? 'inner' : 'system'),
      tooltip: '当返回值存在 mk_ex_invoke 且值为 false 时,不会调用外部接口。',
      tooltip: '当返回值存在 mk_ex_invoke 且值为 false 时,不会调用外部接口。注:当选“无”时,按钮选行时会传递主键,存在表单时会传递表单字段,存在BID时会传BID字段。',
      required: true,
      options: [{
        value: 'system',
@@ -1348,7 +1489,16 @@
      key: 'url',
      label: '页面地址',
      initVal: card.url || '',
      tooltip: '地址格式为:http://******/admin/index.html#/iframe/menuId/loginuid/BID 会打开标签页。注:使用@loginuid@时自动替换为当前系统的loginuid;选择单行且拼接参数时会拼接BID。',
      required: true
    },
    {
      type: 'textarea',
      key: 'proUrl',
      label: '正式地址',
      initVal: card.proUrl || '',
      tooltip: '地址格式为:http://******/admin/index.html#/iframe/menuId/loginuid/BID 会打开标签页。注:使用@loginuid@时自动替换为当前系统的loginuid;选择单行且拼接参数时会拼接BID。',
      required: false
    },
    {
      type: 'radio',
@@ -1408,35 +1558,6 @@
    },
    {
      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 || (card.callbackFunc ? 'func' : 'none'),
@@ -1471,6 +1592,52 @@
      required: true
    },
    {
      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: 'stringify',
      label: '序列化',
      initVal: card.stringify || 'text',
      required: false,
      options: [{
        value: 'text',
        text: 'Text'
      }, {
        value: 'JSON',
        text: 'JSON'
      }, {
        value: 'qs',
        text: 'qs'
      }]
    },
    {
      type: 'select',
      key: 'Ot',
      label: '行设置',
@@ -1483,7 +1650,7 @@
      key: 'execSuccess',
      label: '成功后',
      initVal: card.execSuccess || 'grid',
      tooltip: refresh.length ? '执行刷新源组件时,请在源按钮中设置关闭后刷新那一项,注:此时会同步刷新当前组件和上级组件-行。如需语音播报请以@speak@开头,播报内容或文件放置于<<>>中。' : '选择刷新行时,如果选择多条数据会刷新表格。注:上级组件在数据源中添加。如需语音播报请以@speak@开头,播报内容或文件放置于<<>>中。',
      tooltip: refresh.length ? '执行刷新源组件时,请在源按钮中设置关闭后刷新那一项,注:此时会同步刷新当前组件和上级组件-行。如需语音播报请以@speak@开头,播报内容或文件放置于<<>>中。返回信息中包含@close_tab@、@close_popup@、@goback@ 会执行(关闭标签-管理系统)、(关闭弹窗)、(返回上一页-子应用)等动作。' : '选择刷新行时,如果选择多条数据会刷新表格。注:上级组件在数据源中添加。如需语音播报请以@speak@开头,播报内容或文件放置于<<>>中。返回信息中包含@close_tab@、@close_popup@、@goback@ 会执行(关闭标签-管理系统)、(关闭弹窗)、(返回上一页-子应用)等动作。',
      required: true,
      options: [{
        value: 'never',
@@ -1505,7 +1672,7 @@
      key: 'execError',
      label: '失败后',
      initVal: card.execError || 'never',
      tooltip: refresh.length ? '执行刷新源组件时,请在源按钮中设置关闭后刷新那一项,注:此时会同步刷新当前组件和上级组件-行。如需语音播报请以@speak@开头,播报内容或文件放置于<<>>中。' : '选择刷新行时,如果选择多条数据会刷新表格,注:上级组件在数据源中添加。如需语音播报请以@speak@开头,播报内容或文件放置于<<>>中。',
      tooltip: refresh.length ? '执行刷新源组件时,请在源按钮中设置关闭后刷新哪一项,注:此时会同步刷新当前组件和上级组件-行。如需语音播报请以@speak@开头,播报内容或文件放置于<<>>中。返回信息中包含@close_tab@、@close_popup@、@goback@ 会执行(关闭标签-管理系统)、(关闭弹窗)、(返回上一页-子应用)等动作。' : '选择刷新行时,如果选择多条数据会刷新表格,注:上级组件在数据源中添加。如需语音播报请以@speak@开头,播报内容或文件放置于<<>>中。返回信息中包含@close_tab@、@close_popup@、@goback@ 会执行(关闭标签-管理系统)、(关闭弹窗)、(返回上一页-子应用)等动作。',
      required: true,
      options: [{
        value: 'never',
@@ -1626,7 +1793,7 @@
      initVal: card.syncComponent || [],
      tooltip: '执行成功后(或弹窗标签关闭时),需要同步刷新的组件。注:选择当前组件的上级组件无效,刷新上级组件请选择成功后“刷新上级组件 - 行”。',
      required: false,
      options: modules
      options: modules.length ? [...modules, {value: 'multiComponent', label: '多组件'}] : []
    },
    {
      type: 'radio',
@@ -1698,6 +1865,18 @@
    },
    {
      type: 'radio',
      key: 'openTab',
      label: '打开方式',
      initVal: card.openTab || 'newtab',
      tooltip: '菜单打开方式。',
      options: [
        {value: 'newtab', text: '标签页'},
        // {value: 'newpage', text: '新页面(标签页)'},
        {value: 'view', text: '新页面(全屏)'}
      ]
    },
    {
      type: 'radio',
      key: 'display',
      label: '显示方式',
      initVal: card.display || 'modal',
@@ -1754,6 +1933,14 @@
        value: 'close',
        text: '关闭'
      }]
    },
    {
      type: 'text',
      key: 'preFunc',
      label: '前置函数',
      initVal: card.preFunc || '',
      tooltip: '前置函数执行完成后,结果会传入内部函数中,此时内部函数会异步执行;当前置函数返回中ErrCode等于-1时,将不再执行内部函数。',
      required: false
    },
    {
      type: 'radio',
@@ -1845,6 +2032,27 @@
        value: 'progressbar',
        text: '进度条'
      }]
    },
    {
      type: 'table',
      key: 'syncComponents',
      label: '组件列表',
      initVal: card.syncComponents || [],
      required: true,
      actions: [],
      columns: [
        {
          title: '组件',
          dataIndex: 'syncComId',
          inputType: 'cascader',
          editable: true,
          required: true,
          extends: [{key: 'label', value: 'label'}],
          width: '70%',
          render: (text, record) => record.label,
          options: modules
        }
      ]
    }
  ]