king
2022-01-21 46f79b491173d284a4900d19e7aecf7509481438
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 = []
@@ -82,7 +85,7 @@
  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: '标签关闭' },
  ]
@@ -98,7 +101,7 @@
    } else {
      appMenus = []
    }
  }
    if (appType === 'mob') {
      opentypes = opentypes.filter(item => ['pop', 'prompt', 'exec', 'innerpage', 'funcbutton'].includes(item.value))
      funTypes = [
@@ -111,21 +114,19 @@
      ]
      pageTemps = [
        { value: 'linkpage', text: '关联菜单' },
        // { value: 'pay', text: Formdict['model.pay'] },
        { value: 'custom', text: '链接' }
      ]
    } else {
  } 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: '链接' }
      ]
      funTypes = [
        { value: 'changeuser', text: Formdict['header.form.func.changeuser'] },
      ]
      opentypes = opentypes.filter(item => item.value !== 'tab')
    }
  }
  
  if (type === 'chart' && appType !== 'mob') {
@@ -136,13 +137,27 @@
  if (viewType === 'popview') { // 弹窗标签
    opentypes = opentypes.filter(item => item.value !== 'popview' && item.value !== 'funcbutton')
    refresh.push({
      value: 'popclose',
      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 = [
@@ -157,10 +172,24 @@
    {
      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',
@@ -193,7 +222,6 @@
      label: '按钮名称',
      initVal: card.label,
      required: true,
      readonly: false
    },
    {
      type: 'radio',
@@ -231,9 +259,7 @@
      initVal: card.innerFunc || '',
      tooltip: functip,
      fields: usefulFields,
      tooltipClass: 'middle',
      required: false,
      readonly: false
    },
    {
      type: 'select',
@@ -245,12 +271,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',
@@ -279,7 +312,6 @@
      label: Formdict['header.form.outerFunc'],
      initVal: card.outerFunc || '',
      required: false,
      readonly: false
    },
    {
      type: 'textarea',
@@ -354,7 +386,6 @@
      label: Formdict['header.form.callbackFunc'],
      initVal: card.callbackFunc || '',
      required: false,
      readonly: false
    },
    {
      type: 'select',
@@ -363,15 +394,6 @@
      initVal: card.Ot || (card.sqlType === 'insert' ? 'notRequired' : 'requiredSgl'),
      required: true,
      options: []
    },
    {
      type: 'cascader',
      key: 'linkmenu',
      label: Formdict['model.form.linkmenu'],
      initVal: card.linkmenu || [],
      required: true,
      forbid: isApp,
      options: menulist
    },
    {
      type: 'select',
@@ -394,7 +416,7 @@
        text: '刷新上级组件 - 行'
      }, {
        value: !appType ? 'closetab' : 'goback',
        text: !appType ? '关闭弹窗' : '返回(上一个页面)'
        text: !appType ? '关闭标签' : '返回(上一个页面)'
      },
      ...refresh]
    },
@@ -469,6 +491,7 @@
      label: '显示为',
      initVal: card.show || 'button',
      required: true,
      forbid: type === 'datacard' && appType === 'mob', // 移动端,滑动显示的按钮只显示文字
      options: [{
        value: 'icon',
        text: '图标'
@@ -484,13 +507,13 @@
      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: '左滑'
      }, {
@@ -504,6 +527,7 @@
      label: Formdict['model.icon'],
      initVal: card.icon,
      required: false,
      forbid: type === 'datacard' && appType === 'mob', // 移动端,滑动显示的按钮只显示文字
      options: []
    },
    {
@@ -513,7 +537,32 @@
      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',
@@ -539,7 +588,7 @@
    {
      type: 'radio',
      key: 'pagination',
      label: Formdict['header.form.pagination'],
      label: '分页',
      initVal: card.pagination || 'false',
      required: false,
      options: [{
@@ -590,15 +639,6 @@
      tooltip: '执行成功后(或功能按钮中标签关闭类型),需要同步刷新的菜单',
      required: false,
      forbid: isApp || viewType === 'popview',
      options: menulist
    },
    {
      type: 'cascader',
      key: 'linkmenu',
      label: Formdict['model.form.linkmenu'],
      initVal: card.linkmenu || [],
      required: true,
      forbid: isApp,
      options: menulist
    },
    {
@@ -654,7 +694,7 @@
      type: 'number',
      key: 'ratio',
      min: 1,
      max: 24,
      max: 3000,
      precision: 0,
      label: '比例',
      initVal: card.ratio || 85,
@@ -666,7 +706,6 @@
      key: 'placement',
      label: '抽屉方向',
      initVal: card.placement || 'right',
      tooltip: '使用抽屉时有效。',
      required: false,
      options: [{
        value: 'right',
@@ -684,10 +723,24 @@
    },
    {
      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中(应用模式为app)有效。',
      tooltip: '返回后是否刷新数据。注:在明科云APP或小程序中有效。',
      forbid: appType !== 'mob',
      options: [{
        value: 'false',
@@ -702,6 +755,7 @@
      key: 'control',
      label: '按钮控制',
      initVal: card.control || (card.controlField ? 'disabled' : ''),
      tooltip: '当选择禁用或隐藏,且字段值与控制值相等时,按钮会隐藏或禁用。当选择上级,主表字段值与控制值相等或主表字段值不存在时,按钮会隐藏。注:多个值用逗号分隔',
      required: false,
      options: [{
        value: '',
@@ -712,13 +766,15 @@
      }, {
        value: 'hidden',
        text: '隐藏'
      }, {
        value: 'parent',
        text: '上级'
      }]
    },
    {
      type: 'select',
      key: 'controlField',
      label: '控制字段',
      tooltip: '控制字段,可根据数据控制按钮的隐藏或禁用。',
      initVal: card.controlField || '',
      required: true,
      allowClear: true,
@@ -728,10 +784,66 @@
      type: 'text',
      key: 'controlVal',
      label: '控制值',
      tooltip: '当选择控制字段,且字段值与控制值相等时,按钮会隐藏或禁用,多个值用逗号分隔。',
      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