king
2022-10-20 6de5ea0a0c6f06e0321ae41846473118fb85de48
src/menu/components/share/actioncomponent/formconfig.jsx
@@ -1,4 +1,4 @@
import { btnCustomClasses } from '@/utils/option.js'
import { btnCustomClasses, btnClasses } from '@/utils/option.js'
/**
@@ -1021,3 +1021,677 @@
  return forms
}
/**
 * @description 获取按钮表单配置信息
 * @param {*} card           编辑按钮
 * @param {*} functip        生成存储过程提示
 * @param {*} setting        组件配置
 * @param {*} usefulFields   存储过程可用的开始字段
 */
export function getBaseTableActionForm (card, functip, config, usefulFields) {
  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 modules = []
  let opentypes = [
    {
      value: 'pop',
      text: '弹窗(表单)'
    }, {
      value: 'prompt',
      text: '提示框'
    }, {
      value: 'exec',
      text: '直接执行'
    }, {
      value: 'excelIn',
      text: '导入Excel'
    }, {
      value: 'excelOut',
      text: '导出Excel'
    }, {
      value: 'popview',
      text: '弹窗(标签)'
    }, {
      value: 'tab',
      text: '标签页'
    }, {
      value: 'innerpage',
      text: '新页面'
    }, {
      value: 'funcbutton',
      text: '功能按钮'
    }
  ]
  let pageTemps = [
    { value: 'billprint', text: '单据打印' },
    { value: 'pay', text: '支付' },
    { value: 'custom', text: '自定义' }
  ]
  let funTypes = [
    { value: 'print', text: '标签打印' },
    { value: 'refund', text: '退款' },
    { value: 'closetab', text: '标签关闭' },
    { value: 'changeuser', text: '切换用户' },
    { value: 'megvii', text: '旷视面板机' },
    { value: 'filezip', text: '文件压缩包' },
  ]
  let menulist = sessionStorage.getItem('fstMenuList')
  if (menulist) {
    try {
      menulist = JSON.parse(menulist)
    } catch (e) {
      menulist = []
    }
  } else {
    menulist = []
  }
  let refresh = []
  if (viewType === 'popview') { // 弹窗标签
    opentypes = opentypes.filter(item => item.value !== 'popview' && item.value !== 'funcbutton')
    refresh.push({
      value: 'closepoptab', // 关闭弹窗标签
      text: '关闭弹窗'
    })
  }
  if (card.OpenType === 'form') { // 拖拽添加类型转换
    card.OpenType = 'pop'
  }
  let forms = [
    {
      type: 'select',
      key: 'OpenType',
      label: '打开方式',
      initVal: card.OpenType,
      required: true,
      options: opentypes
    },
    {
      type: 'text',
      key: 'label',
      label: '按钮名称',
      initVal: card.label,
      required: true,
    },
    {
      type: 'select',
      key: 'funcType',
      label: '功能类型',
      initVal: card.funcType || '',
      required: true,
      options: funTypes
    },
    {
      type: 'radio',
      key: 'subFunc',
      label: '接口名称',
      initVal: card.subFunc || 'addUser',
      required: true,
      options: [
        { value: 'addUser', text: '添加用户' },
      ]
    },
    {
      type: 'select',
      key: 'execMode',
      label: '执行方式',
      initVal: card.execMode || 'exec',
      required: true,
      options: [{
        value: 'exec',
        text: '直接执行'
      }, {
        value: 'prompt',
        text: '提示框'
      }, {
        value: 'pop',
        text: '弹窗(表单)'
      }]
    },
    {
      type: 'radio',
      key: 'intertype',
      label: '接口类型',
      initVal: card.intertype || 'system',
      required: true,
      options: []
    },
    {
      type: 'checkbox',
      key: 'payType',
      label: '支付方式',
      initVal: card.payType || [],
      required: true,
      options: [{
        value: 'wxpay',
        text: '微信'
      // }, {
      //   value: 'alipay',
      //   text: '支付宝'
      }]
    },
    {
      type: 'radio',
      key: 'procMode',
      label: '参数处理',
      initVal: card.procMode || (card.innerFunc ? 'inner' : 'system'),
      required: true,
      options: [{
        value: 'system',
        text: '系统函数'
      }, {
        value: 'inner',
        text: '内部函数'
      }, {
        value: 'none',
        text: '无'
      }]
    },
    {
      type: 'radio',
      key: 'sqlType',
      label: '操作类型',
      initVal: card.sqlType || '',
      required: true,
      options: []
    },
    {
      type: 'text',
      key: 'sql',
      label: '表名',
      initVal: card.sql || setting.tableName || '',
      required: true
    },
    {
      type: 'text',
      key: 'innerFunc',
      label: '内部函数',
      initVal: card.innerFunc || '',
      tooltip: functip,
      fields: usefulFields,
      required: false,
    },
    {
      type: 'text',
      key: 'urlkey',
      label: '地址字段',
      initVal: card.urlkey || '',
      tooltip: '图片(文件)链接的字段名。',
      required: false,
      readonly: false
    },
    {
      type: 'select',
      key: 'pageTemplate',
      label: '页面类型',
      initVal: card.pageTemplate || '',
      required: true,
      options: pageTemps
    },
    {
      type: 'select',
      key: 'printTemp',
      label: '打印模板',
      initVal: card.printTemp || '',
      required: true,
      options: printTemps
    },
    {
      type: 'cascader',
      key: 'linkmenu',
      label: '关联菜单',
      initVal: card.linkmenu || [],
      required: true,
      extendName: 'MenuNo',
      options: menulist
    },
    {
      type: 'textarea',
      key: 'url',
      label: '页面地址',
      initVal: card.url || '',
      required: true
    },
    {
      type: 'radio',
      key: 'sysInterface',
      label: '系统接口',
      initVal: card.sysInterface || 'false',
      required: true,
      options: [{
        value: 'true',
        text: '是'
      }, {
        value: 'false',
        text: '否'
      }]
    },
    {
      type: 'text',
      key: 'outerFunc',
      label: '外部函数',
      initVal: card.outerFunc || '',
      required: false,
    },
    {
      type: 'textarea',
      key: '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 || (card.callbackFunc ? 'func' : 'none'),
      tooltip: '使用后台脚本执行时,需要配合计划任务。',
      required: true,
      options: [{
        value: 'script',
        text: '自定义脚本'
      }, {
        value: 'default',
        text: '后台脚本'
      }, {
        value: 'func',
        text: '回调函数'
      }, {
        value: 'none',
        text: '无'
      }]
    },
    {
      type: 'text',
      key: 'cbTable',
      label: '回调表名',
      initVal: card.cbTable || '',
      required: true
    },
    {
      type: 'text',
      key: 'callbackFunc',
      label: '回调函数',
      initVal: card.callbackFunc || '',
      required: true
    },
    {
      type: 'select',
      key: 'Ot',
      label: '行设置',
      initVal: card.Ot || (card.sqlType === 'insert' ? 'notRequired' : 'requiredSgl'),
      required: true,
      options: []
    },
    {
      type: 'select',
      key: 'execSuccess',
      label: '成功后',
      initVal: card.execSuccess || 'grid',
      tooltip: refresh.length ? '执行刷新源组件时,请在源按钮中设置关闭后刷新那一项,注:此时会同步刷新当前组件和上级组件-行。' : '选择刷新行时,如果选择多条数据会刷新表格。注:上级组件在数据源中添加。',
      required: true,
      options: [{
        value: 'never',
        text: '不刷新'
      }, {
        value: 'line',
        text: '刷新行'
      }, {
        value: 'grid',
        text: '刷新当前组件'
      }, {
        value: 'mainline',
        text: '刷新上级组件 - 行'
      },
      ...refresh]
    },
    {
      type: 'select',
      key: 'execError',
      label: '失败后',
      initVal: card.execError || 'never',
      tooltip: refresh.length ? '执行刷新源组件时,请在源按钮中设置关闭后刷新那一项,注:此时会同步刷新当前组件和上级组件-行。' : '选择刷新行时,如果选择多条数据会刷新表格,注:上级组件在数据源中添加。',
      required: true,
      options: [{
        value: 'never',
        text: '不刷新'
      }, {
        value: 'line',
        text: '刷新行'
      }, {
        value: 'grid',
        text: '刷新当前组件'
      }, {
        value: 'mainline',
        text: '刷新上级组件 - 行'
      },
      ...refresh]
    },
    {
      type: 'select',
      key: 'popClose',
      label: '关闭后',
      initVal: card.popClose || 'never',
      required: true,
      options: [{
        value: 'never',
        text: '不刷新'
      }, {
        value: 'grid',
        text: '刷新当前组件'
      }, {
        value: 'mainline',
        text: '刷新上级组件 - 行'
      }]
    },
    {
      type: 'radio',
      key: 'resetPageIndex',
      label: '刷新时',
      initVal: card.resetPageIndex || 'true',
      required: false,
      options: [{
        value: 'true',
        text: '重置页码'
      }, {
        value: 'false',
        text: '不重置'
      }]
    },
    {
      type: 'icon',
      key: 'icon',
      label: '图标',
      initVal: card.icon,
      required: false,
      options: []
    },
    {
      type: 'select',
      key: 'class',
      label: '颜色',
      initVal: card.class,
      required: false,
      options: btnClasses
    },
    {
      type: 'radio',
      key: 'joint',
      label: '拼接参数',
      initVal: card.joint || 'true',
      required: false,
      options: [{
        value: 'true',
        text: '是'
      }, {
        value: 'false',
        text: '否'
      }]
    },
    {
      type: 'text',
      key: 'sheet',
      label: '表名',
      initVal: card.sheet || setting.tableName || '',
      required: true
    },
    {
      type: 'radio',
      key: 'pagination',
      label: '分页',
      initVal: card.pagination || 'false',
      required: false,
      options: [{
        value: 'true',
        text: '是'
      }, {
        value: 'false',
        text: '否'
      }]
    },
    {
      type: 'radio',
      key: 'search',
      label: '搜索条件',
      initVal: card.search || 'false',
      required: false,
      options: [{
        value: 'true',
        text: '必填'
      }, {
        value: 'false',
        text: '非必填'
      }]
    },
    {
      type: 'cascader',
      key: 'syncComponent',
      label: '刷新组件',
      initVal: card.syncComponent || [],
      tooltip: '执行成功后(或弹窗标签关闭时),需要同步刷新的组件。注:选择当前组件的上级组件无效,刷新上级组件请选择成功后“刷新上级组件 - 行”。',
      required: false,
      options: modules
    },
    {
      type: 'cascader',
      key: 'refreshTab',
      label: '刷新菜单',
      initVal: card.refreshTab || [],
      tooltip: '执行成功后(或功能按钮中标签关闭类型),需要同步刷新的菜单',
      required: false,
      forbid: viewType === 'popview',
      options: menulist
    },
    {
      type: 'cascader',
      key: 'openmenu',
      label: '打开菜单',
      tooltip: '执行成功后需要打开的菜单。',
      initVal: card.openmenu || [],
      extendName: 'MenuNo',
      required: false,
      allowClear: true,
      options: menulist,
      forbid: viewType === 'popview'
    },
    {
      type: 'text',
      key: 'output',
      label: '返回值',
      tooltip: '执行成功后的返回值。系统函数可指定返回的变量(以@符开头,返回id时可使用@id@);自定义函数可指定返回字段(如id)。',
      initVal: card.output || '',
      required: false,
      forbid: viewType === 'popview'
    },
    {
      type: 'text',
      key: 'tipTitle',
      label: '确认提示',
      initVal: card.tipTitle || '',
      tooltip: '注:弹窗(表单)在显示为是否框时有效。',
      required: false
    },
    {
      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: 3000,
      precision: 0,
      label: '比例',
      initVal: card.ratio || 85,
      tooltip: '模态框或抽屉的宽度,小于100为窗口宽度(或高度)百分比,大于100为像素值。',
      required: true
    },
    {
      type: 'radio',
      key: 'placement',
      label: '抽屉方向',
      initVal: card.placement || 'right',
      required: false,
      options: [{
        value: 'right',
        text: '右侧'
      }, {
        value: 'left',
        text: '左侧'
      }, {
        value: 'top',
        text: '上侧'
      }, {
        value: 'bottom',
        text: '下侧'
      }]
    },
    {
      type: 'radio',
      key: 'clickouter',
      label: '点击蒙层',
      initVal: card.clickouter || 'unclose',
      required: false,
      options: [{
        value: 'unclose',
        text: '不关闭'
      }, {
        value: 'close',
        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: 'text',
      key: 'reason',
      label: '禁用原因',
      initVal: card.reason || '',
      required: false
    },
    {
      type: 'radio',
      key: 'hidden',
      label: '隐藏',
      initVal: card.hidden || 'false',
      tooltip: '隐藏后按钮在页面中不显示,且不参与权限分配。',
      required: false,
      options: [{
        value: 'false',
        text: '否'
      }, {
        value: 'true',
        text: '是'
      }]
    },
    {
      type: 'radio',
      key: 'progress',
      label: '进度提示',
      initVal: card.progress || 'number',
      required: false,
      options: [{
        value: 'number',
        text: '剩余数'
      }, {
        value: 'progressbar',
        text: '进度条'
      }]
    }
  ]
  return forms
}