king
2022-03-03 cadfd4ed559fb170bb81d5bafbb6ae9775ba1ddc
src/menu/components/share/actioncomponent/formconfig.jsx
@@ -1,5 +1,6 @@
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
@@ -14,6 +15,8 @@
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 = []
@@ -60,17 +63,17 @@
    })
  }
  if (type === 'editable') {
    opentypes = [
      {
        value: 'excelIn',
        text: Formdict['model.form.excelIn']
      }, {
        value: 'excelOut',
        text: Formdict['model.form.excelOut']
      }
    ]
  }
  // 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)))
@@ -98,34 +101,33 @@
    } else {
      appMenus = []
    }
    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: 'reAuth', text: '切换系统(清空缓存-小程序)' },
        { value: 'goBack', text: '返回' },
      ]
      pageTemps = [
        { value: 'linkpage', text: '关联菜单' },
        // { value: 'pay', text: Formdict['model.pay'] },
        { value: 'custom', text: '链接' }
      ]
    } else {
      pageTemps = [
        { value: 'linkpage', text: '关联菜单' },
        { value: 'billprint', text: '单据打印' },
        { value: 'pay', text: Formdict['model.pay'] },
        { value: 'custom', text: '链接' }
      ]
      funTypes = [
        { value: 'changeuser', text: '切换用户' },
      ]
      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') {
@@ -145,8 +147,18 @@
    })
  }
  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 = [
@@ -165,6 +177,20 @@
      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',
@@ -197,7 +223,6 @@
      label: '按钮名称',
      initVal: card.label,
      required: true,
      readonly: false
    },
    {
      type: 'radio',
@@ -235,9 +260,7 @@
      initVal: card.innerFunc || '',
      tooltip: functip,
      fields: usefulFields,
      tooltipClass: 'middle',
      required: false,
      readonly: false
    },
    {
      type: 'select',
@@ -249,12 +272,19 @@
    },
    {
      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',
@@ -283,7 +313,6 @@
      label: Formdict['header.form.outerFunc'],
      initVal: card.outerFunc || '',
      required: false,
      readonly: false
    },
    {
      type: 'textarea',
@@ -358,7 +387,6 @@
      label: Formdict['header.form.callbackFunc'],
      initVal: card.callbackFunc || '',
      required: false,
      readonly: false
    },
    {
      type: 'select',
@@ -369,19 +397,10 @@
      options: []
    },
    {
      type: 'cascader',
      key: 'linkmenu',
      label: Formdict['model.form.linkmenu'],
      initVal: card.linkmenu || [],
      required: true,
      forbid: isApp,
      options: menulist
    },
    {
      type: 'select',
      key: 'execSuccess',
      label: Formdict['model.form.afterSuccess'],
      initVal: card.execSuccess || 'never',
      initVal: card.execSuccess || 'grid',
      tooltip: refresh.length ? '执行刷新源组件时,请在源按钮中设置关闭后刷新那一项,注:此时会同步刷新当前组件和上级组件-行。' : '刷新上级组件-行时,会同步刷新当前组件,注:上级组件在数据源中添加。',
      required: true,
      options: [{
@@ -520,7 +539,7 @@
      tooltip: '此颜色为按钮初始化颜色,可在样式调整中修改。',
      required: false,
      forbid: type === 'datacard' && appType === 'mob', // 移动端,滑动显示的按钮不设置通用颜色
      options: []
      options: btnCustomClasses
    },
    {
      type: 'radio',
@@ -624,15 +643,6 @@
      options: menulist
    },
    {
      type: 'cascader',
      key: 'linkmenu',
      label: Formdict['model.form.linkmenu'],
      initVal: card.linkmenu || [],
      required: true,
      forbid: isApp,
      options: menulist
    },
    {
      type: !appType ? 'cascader' : 'select',
      key: 'openmenu',
      label: '打开菜单',
@@ -651,6 +661,14 @@
      initVal: card.output || '',
      required: false,
      forbid: viewType === 'popview'
    },
    {
      type: 'text',
      key: 'tipTitle',
      label: '确认提示',
      initVal: card.tipTitle || '',
      tooltip: '注:弹窗(表单)在显示为是否框时有效。',
      required: false
    },
    {
      type: 'radio',
@@ -685,7 +703,7 @@
      type: 'number',
      key: 'ratio',
      min: 1,
      max: 24,
      max: 3000,
      precision: 0,
      label: '比例',
      initVal: card.ratio || 85,
@@ -729,9 +747,9 @@
    {
      type: 'radio',
      key: 'reload',
      label: '返回后',
      label: '上一页',
      initVal: card.reload || 'false',
      tooltip: '按钮成功后返回上一页面或使用功能按钮-返回功能时,返回后是否刷新数据。注:在明科云app中(应用模式为app)有效。',
      tooltip: '成功后是否刷新上页的数据。注:在明科云APP或小程序中有效。',
      forbid: appType !== 'mob',
      options: [{
        value: 'false',
@@ -743,9 +761,26 @@
    },
    {
      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: '',
@@ -756,16 +791,15 @@
      }, {
        value: 'hidden',
        text: '隐藏'
      // }, {
      //   value: 'parent',
      //   text: '上级'
      }, {
        value: 'parent',
        text: '上级'
      }]
    },
    {
      type: 'select',
      key: 'controlField',
      label: '控制字段',
      tooltip: '控制字段,可根据数据控制按钮的隐藏或禁用。',
      initVal: card.controlField || '',
      required: true,
      allowClear: true,
@@ -775,10 +809,66 @@
      type: 'text',
      key: 'controlVal',
      label: '控制值',
      tooltip: '当选择禁用或隐藏,且字段值与控制值相等时,按钮会隐藏或禁用,多个值用逗号分隔。当选择上级时,默认隐藏,只有主表行信息符合条件时显示,格式为@field@:values,field为主表字段名,values为值多个可用逗号拼接',
      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