king
2024-05-16 b69b5f6329ca5f87932436b7a6c1ddfc3377e10f
src/menu/components/card/data-card/options.jsx
@@ -1,20 +1,35 @@
import { fromJS } from 'immutable'
import MenuUtils from '@/utils/utils-custom.js'
/**
 * @description Wrap表单配置信息
 */
export default function (wrap, subtype, columns = [], id = '', supNodes = []) {
export default function (wrap, subtype, columns = [], id = '', supNodes = [], setting, buttons = []) {
  let appType = sessionStorage.getItem('appType')
  let MenuType = ''
  let menu = fromJS(window.GLOB.customMenu).toJS()
  if (menu.parentId === 'BillPrintTemp') {
    MenuType = 'billPrint'
  let isprint = sessionStorage.getItem('MenuType') === 'billPrint'
  let ispop = sessionStorage.getItem('editMenuType') === 'popview'
  let menu = window.GLOB.customMenu
  let laypage = setting && setting.laypage !== 'false'
  let interfaces = []
  if (subtype === 'propcard' && menu.interfaces) {
    menu.interfaces.forEach(item => {
      if (item.status === 'true') {
        interfaces.push({
          value: item.uuid,
          label: item.name
        })
      }
    })
  }
  let modules = []
  if (subtype === 'propcard' || subtype === 'datacard') {
    modules = MenuUtils.getSupModules(menu.components, id) || []
    modules = MenuUtils.getSupModules(menu.components, id, menu.interfaces)
    if (subtype === 'propcard' && wrap.supModule && wrap.supModule.length > 0 && wrap.supModule[0] !== 'empty') {
      let has = MenuUtils.checkSupModules(modules, wrap.supModule.slice(-1)[0])
      if (!has) {
        wrap.supModule = ''
      }
    }
  }
  let roleList = sessionStorage.getItem('sysRoles')
@@ -43,6 +58,74 @@
      menulist = []
    }
  }
  let interaction = []
  let interOptions = []
  if (wrap.scale === 'true') {
    interaction.push('scale')
  }
  if (wrap.parity === 'true') {
    interaction.push('parity')
  }
  if (wrap.hover === 'true') {
    interaction.push('hover')
  }
  if (subtype === 'datacard') {
    interOptions = [
      {value: 'parity', label: '奇偶异色'},
    ]
    if (appType !== 'mob') {
      interOptions.push(
        {value: 'hover', label: '悬浮变色'},
        {value: 'scale', label: '悬浮放大'}
      )
    }
  } else if (subtype === 'propcard' && appType !== 'mob') {
    interOptions = [
      {value: 'scale', label: '悬浮放大'}
    ]
  } else if (subtype === 'tablecard') {
    interOptions = [
      {value: 'parity', label: '奇偶异色'},
    ]
    if (appType !== 'mob') {
      interOptions.push(
        {value: 'hover', label: '悬浮变色'}
      )
    }
  }
  if (interaction.length && interOptions.length) {
    interaction = interaction.filter(m => interOptions.findIndex(cell => cell.value === m) > -1)
  }
  // let interItem = null
  // if (interOptions.length === 1) {
  //   interItem = {
  //     type: 'radio',
  //     field: interOptions[0].value,
  //     label: interOptions[0].label,
  //     initval: interaction.length === 1 ? 'true' : 'false',
  //     required: false,
  //     options: [
  //       {value: 'true', label: '启用'},
  //       {value: 'false', label: '禁用'}
  //     ]
  //   }
  // } else {
  //   interItem = {
  //     type: 'checkbox',
  //     field: 'interaction',
  //     label: '交互效果',
  //     initval: interaction,
  //     required: false,
  //     options: interOptions,
  //     forbid: interOptions.length === 0
  //   }
  // }
  const cardWrapForm = [
    {
@@ -81,15 +164,63 @@
      options: [
        {value: 'dynamic', label: '动态', priKeyType: 'static'},
        {value: 'static', label: '静态', priKeyType: 'static'},
        {value: 'public', label: '公共数据源', priKeyType: 'static'},
      ],
      linkFields: ['priKeyType'],
      controlFields: [
        {field: 'goback', values: ['dynamic']},
        {field: 'empty', values: ['dynamic']},
        {field: 'jump', values: ['dynamic']},
        {field: 'goback', values: ['dynamic', 'public']},
        {field: 'empty', values: ['dynamic', 'public']},
        {field: 'jump', values: ['dynamic', 'public']},
        {field: 'broadcast', values: ['dynamic', 'public']},
        {field: 'supModule', values: ['static']},
        {field: 'publicId', values: ['public']},
        {field: 'emptyExec', values: ['dynamic', 'public']},
      ],
      forbid: subtype !== 'propcard'
    },
    {
      type: 'select',
      field: 'publicId',
      label: '数据源',
      initval: wrap.publicId || '',
      required: true,
      options: interfaces,
      reset_source: true,
      forbid: subtype !== 'propcard',
      callback: (map, record) => {
        if (!record.publicId) return
        let interfaces = window.GLOB.customMenu.interfaces || []
        let d = interfaces.filter(m => m.uuid === record.publicId && m.status === 'true')[0]
        if (!d || !d.columns) return
        let columns = JSON.parse(JSON.stringify(d.columns))
        let _broadcast = map.get('broadcast')
        if (_broadcast && !_broadcast.forbid) {
          _broadcast.options = columns
          _broadcast.oriOptions = columns
          map.set('broadcast', _broadcast)
        }
        let _jumpField = map.get('jumpField')
        if (_jumpField && !_jumpField.forbid) {
          _jumpField.options = columns
          _jumpField.oriOptions = columns
          map.set('jumpField', _jumpField)
        }
        let _link = map.get('link')
        if (_link && !_link.forbid) {
          _link.options = columns
          _link.oriOptions = columns
          map.set('link', _link)
        }
      }
    },
    {
      type: 'radio',
@@ -113,14 +244,20 @@
      field: 'pagestyle',
      label: '分页风格',
      initval: wrap.pagestyle || 'page',
      tooltip: '数据源选择分页时有效。注:滑动加载只有第一个有效',
      tooltip: '数据源选择分页时有效。注:弹性布局时固定为页码。',
      required: false,
      disabled: !laypage,
      options: [
        {value: 'page', label: '页码'},
        {value: 'switch', label: '左右切换', forbid: appType === 'mob'},
        {value: 'slide', label: '滑动加载', forbid: appType !== 'mob'},
        {value: 'switch', label: '左右切换', forbid: appType === 'mob' || subtype === 'tablecard'},
        {value: 'slide', label: '滑动加载', forbid: appType !== 'mob' || ispop},
        {value: 'more', label: '查看更多'},
      ],
      forbid: !(subtype === 'datacard' || (subtype === 'tablecard' && appType === 'mob'))
      controlFields: [
        {field: 'slidetip', values: ['slide']},
        {field: 'maxPageSize', values: ['page']},
      ],
      forbid: subtype === 'propcard'
    },
    {
      type: 'radio',
@@ -137,7 +274,7 @@
        {field: 'checkAll', values: ['checkbox']},
        {field: 'selected', values: ['radio', 'checkbox']},
        {field: 'selStyle', values: ['radio', 'checkbox']},
        // {field: 'priKeyType', values: ['radio', 'checkbox']},
        {field: 'pickup', values: ['radio', 'checkbox']},
      ],
      forbid: subtype === 'tablecard'
    },
@@ -154,21 +291,40 @@
        {ParentID: 'dynamic', value: 'static', label: '静态值'},
        {ParentID: 'dynamic', value: 'dynamic', label: '动态值'},
        {ParentID: 'dynamic', value: 'joint', label: '拼接值'},
        {ParentID: 'public', value: 'static', label: '静态值'},
        {ParentID: 'public', value: 'dynamic', label: '动态值'},
        {ParentID: 'public', value: 'joint', label: '拼接值'},
      ],
      forbid: subtype !== 'propcard'
    },
    {
      type: 'radio',
      type: 'select',
      field: 'selected',
      label: '首行选中',
      label: '数据选中',
      initval: wrap.selected || 'false',
      tooltip: '当按钮执行完成并返回主键值时,默认选中主键值对应行。',
      tooltip: '初始化:数据加载时选中首行数据,仅执行一次。数据加载:每次数据加载时均选中首行(当按钮执行完成并返回主键值时,默认选中主键值对应行)。选中标记:返回数据中存在 selected 字段,且值为 true 的数据被选中。',
      required: false,
      options: [
        {value: 'false', label: '无'},
        {value: 'init', label: '初始化'},
        {value: 'always', label: '数据加载'},
      ]
        {value: 'sign', label: '选中标记'}
      ],
      forbid: subtype !== 'datacard'
    },
    {
      type: 'radio',
      field: 'selected',
      label: '数据选中',
      initval: wrap.selected || 'false',
      tooltip: '初始化:数据加载时选中首行数据,仅执行一次。数据加载:每次数据加载时均选中首行。',
      required: false,
      options: [
        {value: 'false', label: '无'},
        {value: 'init', label: '初始化'},
        {value: 'always', label: '数据加载'},
      ],
      forbid: subtype !== 'propcard'
    },
    {
      type: 'select',
@@ -180,24 +336,17 @@
      options: [
        {value: 'none', label: '无'},
        {value: 'active', label: '外阴影'},
        {value: 'backFont', label: '背景+文字'},
        {value: 'backFont', label: '背景(浅)+文字(深)'},
        {value: 'deepBackFont', label: '背景(深)+文字(浅)'},
        {value: 'font', label: '文字'},
        ...(subtype === 'datacard' && appType === 'mob' ? [{value: 'check', label: '勾选'}] : [])
      ]
      // forbid: subtype !== 'propcard'
        {value: 'tabs', label: '标签页'},
        ...(subtype === 'datacard' ? [
          {value: 'check', label: '勾选(圆框)'},
          {value: 'check square', label: '勾选(方框)'}
        ] : [])
      ],
      forbid: subtype === 'tablecard'
    },
    // {
    //   type: 'radio',
    //   field: 'checkAll',
    //   label: '全选',
    //   initval: wrap.checkAll || 'hidden',
    //   required: false,
    //   options: [
    //     {value: 'hidden', label: '隐藏'},
    //     {value: 'show', label: '显示'},
    //   ],
    //   forbid: subtype !== 'datacard' || appType !== 'mob'
    // },
    {
      type: 'radio',
      field: 'cardFloat',
@@ -214,32 +363,54 @@
    },
    {
      type: 'radio',
      field: 'scale',
      label: '放大效果',
      initval: wrap.scale || 'false',
      tooltip: '鼠标悬浮于卡片上方时,卡片放大1.05倍。',
      field: 'pickup',
      label: '收起开关',
      initval: wrap.pickup || 'false',
      tooltip: '数据卡右上角会显示收起开关。',
      required: false,
      options: [
        {value: 'false', label: '无'},
        {value: 'true', label: '有'},
      ],
      forbid: subtype === 'tablecard' || appType === 'mob'
      forbid: subtype !== 'datacard' || appType === 'mob'
    },
    // {
    //   type: 'radio',
    //   field: 'scale',
    //   label: '放大效果',
    //   initval: wrap.scale || 'false',
    //   tooltip: '鼠标悬浮于卡片上方时,卡片放大1.05倍。',
    //   required: false,
    //   options: [
    //     {value: 'false', label: '无'},
    //     {value: 'true', label: '有'},
    //   ],
    //   forbid: subtype === 'tablecard' || appType === 'mob'
    // },
    {
      type: 'checkbox',
      field: 'interaction',
      label: '交互效果',
      initval: interaction,
      required: false,
      options: interOptions,
      forbid: interOptions.length === 0
    },
    {
      type: 'radio',
      field: 'printType',
      label: '组件类型',
      initval: wrap.printType || 'content',
      tooltip: '选择类型为《页眉/页脚》时,打印的每页里都会带有该组件。',
      tooltip: '选择类型为《页眉/页脚》时,打印的每页里都会带有该组件。注:页眉页脚中文本元素将替换 @pageIndex@(页码)、@total@(总数)、@date@(当前日期)、@datetime@(当前时间),使用分页参数时注意打印模板的页面布局使用分页。',
      required: false,
      options: [
        {value: 'content', label: '内容'},
        {value: 'content', label: '属性卡'},
        {value: 'headerOrfooter', label: '页眉/页脚'},
      ],
      controlFields: [
        {field: 'printHeight', values: ['content']},
      ],
      forbid: subtype !== 'propcard' || MenuType !== 'billPrint'
      forbid: subtype !== 'propcard' || !isprint
    },
    {
      type: 'number',
@@ -248,14 +419,14 @@
      initval: wrap.printHeight || '',
      tooltip: subtype !== 'propcard' ? '当前数据卡高度相当于几条数据。' : '当前属性卡高度相当于几条数据。',
      required: false,
      forbid: subtype === 'tablecard' || MenuType !== 'billPrint'
      forbid: subtype === 'tablecard' || !isprint
    },
    {
      type: 'select',
      field: 'broadcast',
      label: '语音播报',
      initval: wrap.broadcast || '',
      tooltip: '语音播报在移动端app中有效。注:使用语音播报时,数据源不要使用同步查询,添加定时器时,可循环播报',
      tooltip: '语音播报在移动端有效。注:在H5中请使用音频链接,添加定时器时,可循环播报',
      required: false,
      options: columns,
      forbid: !columns || appType !== 'mob' || subtype !== 'propcard'
@@ -263,15 +434,31 @@
    {
      type: 'radio',
      field: 'goback',
      label: '空值返回',
      label: appType === 'mob' ? '空值返回' : '空值关闭',
      initval: wrap.goback || 'false',
      tooltip: '当查询数据为空时,返回上一界面。',
      tooltip: appType === 'mob' ? '当查询数据为空时,返回上一界面。' : '当查询数据为空时,关闭当前标签页。',
      required: false,
      options: [
        {value: 'true', label: '是'},
        {value: 'false', label: '否'},
        {value: 'true', label: '是'},
      ],
      forbid: subtype !== 'propcard' || appType !== 'mob'
      forbid: subtype !== 'propcard' || appType === 'pc'
    },
    {
      type: 'radio',
      field: 'display',
      label: '显示控制',
      initval: wrap.display || 'normal',
      tooltip: '当使用属性卡进行某些业务操作,且不需要展示卡片信息时,可设置为不可见。',
      required: false,
      options: [
        {value: 'normal', label: '正常显示'},
        {value: 'hidden', label: '不可见'},
      ],
      controlFields: [
        {field: 'empty', values: ['normal']},
      ],
      forbid: subtype !== 'propcard'
    },
    {
      type: 'radio',
@@ -284,6 +471,32 @@
      options: [
        {value: 'show', label: '否'},
        {value: 'hidden', label: '是'},
      ],
    },
    {
      type: 'select',
      field: 'autoExec',
      label: '自动执行',
      initval: wrap.autoExec || '',
      tooltip: subtype === 'propcard' ? '数据更新时自动执行按钮。注:此按钮执行成功后谨慎选择刷新项,避免造成循环执行。' : '初始化自动执行按钮。',
      required: false,
      options: buttons,
      forbid: subtype !== 'propcard' && subtype !== 'datacard',
      controlFields: [
        {field: 'emptyExec', notNull: true},
      ]
    },
    {
      type: 'radio',
      field: 'emptyExec',
      label: '空值执行',
      initval: wrap.emptyExec || 'true',
      tooltip: '当查询数据为空时,自动执行按钮是否执行。',
      required: false,
      forbid: subtype !== 'propcard',
      options: [
        {value: 'true', label: '是'},
        {value: 'false', label: '否'},
      ],
    },
    {
@@ -300,7 +513,7 @@
      ],
      controlFields: [
        {field: 'jumpField', values: ['menu', 'link']},
        {field: 'joint', values: ['menu', 'link']},
        {field: 'open', values: ['menu', 'link']},
        {field: 'menu', values: ['menu']},
        {field: 'link', values: ['link']},
      ],
@@ -311,7 +524,7 @@
      field: 'jumpField',
      label: '控制字段',
      initval: wrap.jumpField || '',
      tooltip: '当字段值为true时',
      tooltip: '当字段值为true时触发跳转。',
      required: true,
      options: columns,
      forbid: subtype !== 'propcard' || appType !== 'mob'
@@ -337,13 +550,13 @@
    },
    {
      type: 'radio',
      field: 'joint',
      label: '参数拼接',
      initval: wrap.joint || 'true',
      field: 'open',
      label: '打开方式',
      initval: wrap.open || 'blank',
      required: false,
      options: [
        {value: 'true', label: '是'},
        {value: 'false', label: '否'},
        {value: 'blank', label: '新窗口'},
        {value: 'self', label: '当前窗口'},
      ],
      forbid: subtype !== 'propcard' || appType !== 'mob'
    },
@@ -358,7 +571,7 @@
        {value: 'true', label: '验证'},
        {value: 'false', label: '忽略'},
      ],
      forbid: subtype !== 'datacard'
      forbid: subtype !== 'datacard' || isprint
    },
    {
      type: 'cascader',
@@ -368,7 +581,7 @@
      required: false,
      options: modules,
      allowClear: true,
      forbid: subtype !== 'propcard'
      forbid: subtype !== 'propcard' || isprint
    },
    {
      type: 'select',
@@ -387,9 +600,9 @@
    {
      type: 'text',
      field: 'controlVal',
      label: '控制值',
      label: '禁用值',
      initval: wrap.controlVal || '',
      tooltip: '当字段值与控制值相等时,行数据会禁用,多个值用逗号分隔。',
      tooltip: '当字段值与禁用值相等时,行数据会禁用,多个值用逗号分隔。',
      required: false,
      forbid: subtype !== 'datacard'
    },
@@ -400,7 +613,7 @@
      initval: wrap.supType || 'single',
      tooltip: '上级组件为单一组件或多个组件。',
      required: false,
      forbid: subtype !== 'datacard' || appType === 'mob',
      forbid: subtype !== 'datacard' || appType === 'mob' || isprint,
      options: [
        {value: 'single', label: '单组件'},
        {value: 'multi', label: '多组件'},
@@ -413,13 +626,76 @@
      type: 'radio',
      field: 'permission',
      label: '权限验证',
      initval: wrap.permission || 'false',
      initval: wrap.permission || (!appType ? 'true' : 'false'),
      required: false,
      options: [
        {value: 'true', label: !appType ? '继承菜单' : '启用'},
        {value: 'false', label: '禁用'},
      ],
      forbid: ispop || isprint
    },
    {
      type: 'radio',
      field: 'cacheLocal',
      label: '本地缓存',
      initval: wrap.cacheLocal || 'true',
      required: false,
      options: [
        {value: 'true', label: '继承菜单'},
        {value: 'false', label: '禁用'},
      ],
      forbid: ispop || isprint
    },
    {
      type: 'radio',
      field: 'cacheSearch',
      label: '搜索缓存',
      initval: wrap.cacheSearch || 'false',
      tooltip: '启用搜索条件缓存后,在菜单刷新时搜索条件不变。',
      required: false,
      options: [
        {value: 'true', label: '启用'},
        {value: 'false', label: '禁用'},
      ],
      forbid: !appType
      forbid: !!appType || isprint
    },
    {
      type: 'radio',
      field: 'searchBtn',
      label: '搜索按钮',
      initval: wrap.searchBtn || 'hidden',
      // tooltip: '启用搜索条件缓存后,在菜单刷新时搜索条件不变。',
      required: false,
      options: [
        {value: 'hidden', label: '隐藏'},
        {value: 'show', label: '显示'},
      ],
      forbid: appType === 'mob' || isprint,
    },
    {
      type: 'radio',
      field: 'shifting',
      label: '按钮偏移',
      initval: wrap.shifting || 'false',
      tooltip: '启用时,工具栏按钮将显示在标题栏右上角。',
      required: false,
      options: [
        {value: 'true', label: '启用'},
        {value: 'false', label: '禁用'},
      ],
      forbid: !!appType || subtype !== 'datacard' || isprint
    },
    {
      type: 'number',
      field: 'maxPageSize',
      label: '每页最大数',
      initval: wrap.maxPageSize || '',
      tooltip: '分页时每页可显示的最大数量。',
      min: 10,
      max: 500,
      precision: 0,
      required: false,
      forbid: !laypage || appType === 'mob' || subtype !== 'datacard'
    },
    {
      type: 'multiselect',
@@ -428,7 +704,16 @@
      initval: wrap.blacklist || [],
      required: false,
      options: roleList,
      forbid: !!appType
      forbid: !!appType || isprint
    },
    {
      type: 'text',
      field: 'slidetip',
      label: '底部提示',
      initval: wrap.slidetip || wrap.slidetip === '' ? wrap.slidetip : '没有更多了',
      tooltip: '滑动加载至底部时的提示信息。',
      required: false,
      forbid: !laypage || appType !== 'mob' || subtype === 'propcard'
    },
    {
      type: 'table',
@@ -436,8 +721,9 @@
      label: '上级组件',
      initval: supNodes,
      required: true,
      forbid: subtype !== 'datacard' || appType === 'mob',
      forbid: subtype !== 'datacard' || appType === 'mob' || isprint,
      span: 24,
      actions: ['edit', 'del', 'add', 'move'],
      columns: [
        {
          title: '序号',
@@ -447,7 +733,7 @@
          width: '20%'
        },
        {
          title: '菜单',
          title: '组件',
          dataIndex: 'nodes',
          inputType: 'cascader',
          editable: true,