king
2023-08-31 3a675efd3a8883f23208cefd39e0e871bf57a70b
src/menu/components/card/data-card/options.jsx
@@ -1,13 +1,12 @@
import { fromJS } from 'immutable'
import MenuUtils from '@/utils/utils-custom.js'
/**
 * @description Wrap表单配置信息
 */
export default function (wrap, subtype, columns = [], id = '', supNodes = [], setting) {
export default function (wrap, subtype, columns = [], id = '', supNodes = [], setting, buttons = []) {
  let appType = sessionStorage.getItem('appType')
  let MenuType = ''
  let menu = fromJS(window.GLOB.customMenu).toJS()
  let MenuType = sessionStorage.getItem('MenuType') || 'custom'
  let menu = window.GLOB.customMenu
  let laypage = setting && setting.laypage !== 'false'
  let interfaces = []
  if (subtype === 'propcard' && menu.interfaces) {
@@ -20,13 +19,16 @@
      }
    })
  }
  if (menu.parentId === 'BillPrintTemp') {
    MenuType = 'billPrint'
  }
  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')
@@ -97,9 +99,10 @@
      ],
      linkFields: ['priKeyType'],
      controlFields: [
        {field: 'goback', values: ['dynamic']},
        {field: 'goback', values: ['dynamic', 'public']},
        {field: 'empty', values: ['dynamic', 'public']},
        {field: 'jump', values: ['dynamic']},
        {field: 'jump', values: ['dynamic', 'public']},
        {field: 'broadcast', values: ['dynamic', 'public']},
        {field: 'supModule', values: ['static']},
        {field: 'publicId', values: ['public']},
      ],
@@ -112,7 +115,42 @@
      initval: wrap.publicId || '',
      required: true,
      options: interfaces,
      forbid: subtype !== 'propcard'
      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',
@@ -142,7 +180,7 @@
      options: [
        {value: 'page', label: '页码'},
        {value: 'switch', label: '左右切换', forbid: appType === 'mob' || subtype === 'tablecard'},
        {value: 'slide', label: '滑动加载', forbid: appType !== 'mob'},
        {value: 'slide', label: '滑动加载', forbid: appType !== 'mob' || sessionStorage.getItem('editMenuType') === 'popview'},
        {value: 'more', label: '查看更多'},
      ],
      controlFields: [
@@ -189,18 +227,33 @@
      forbid: subtype !== 'propcard'
    },
    {
      type: 'select',
      field: 'selected',
      label: '数据选中',
      initval: wrap.selected || 'false',
      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: '首行选中',
      label: '数据选中',
      initval: wrap.selected || 'false',
      tooltip: '当按钮执行完成并返回主键值时,默认选中主键值对应行。',
      tooltip: '初始化:数据加载时选中首行数据,仅执行一次。数据加载:每次数据加载时均选中首行。',
      required: false,
      options: [
        {value: 'false', label: '无'},
        {value: 'init', label: '初始化'},
        {value: 'always', label: '数据加载'},
      ],
      forbid: subtype === 'tablecard'
      forbid: subtype !== 'propcard'
    },
    {
      type: 'select',
@@ -215,22 +268,13 @@
        {value: 'backFont', label: '背景+文字'},
        {value: 'font', label: '文字'},
        {value: 'tabs', label: '标签页'},
        ...(subtype === 'datacard' && appType === 'mob' ? [{value: 'check', 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',
@@ -260,13 +304,26 @@
    },
    {
      type: 'radio',
      field: 'parity',
      label: '奇偶背景',
      initval: wrap.parity || 'false',
      tooltip: '偶数行会添加背景色。',
      required: false,
      options: [
        {value: 'false', label: '无'},
        {value: 'true', label: '有'},
      ],
      forbid: subtype === 'propcard'
    },
    {
      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: [
@@ -288,7 +345,7 @@
      field: 'broadcast',
      label: '语音播报',
      initval: wrap.broadcast || '',
      tooltip: '语音播报在移动端app中有效。注:使用语音播报时,数据源不要使用同步查询,添加定时器时,可循环播报',
      tooltip: '语音播报在移动端有效。注:在H5中请使用音频链接,添加定时器时,可循环播报',
      required: false,
      options: columns,
      forbid: !columns || appType !== 'mob' || subtype !== 'propcard'
@@ -296,15 +353,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',
@@ -318,6 +391,16 @@
        {value: 'show', label: '否'},
        {value: 'hidden', label: '是'},
      ],
    },
    {
      type: 'select',
      field: 'autoExec',
      label: '自动执行',
      initval: wrap.autoExec || '',
      tooltip: '数据更新时自动执行按钮。注:此按钮执行成功后谨慎选择刷新项,避免造成循环执行。',
      required: false,
      options: buttons,
      forbid: subtype !== 'propcard'
    },
    {
      type: 'radio',
@@ -334,6 +417,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']},
      ],
@@ -344,7 +428,7 @@
      field: 'jumpField',
      label: '控制字段',
      initval: wrap.jumpField || '',
      tooltip: '当字段值为true时',
      tooltip: '当字段值为true时触发跳转。',
      required: true,
      options: columns,
      forbid: subtype !== 'propcard' || appType !== 'mob'
@@ -377,6 +461,18 @@
      options: [
        {value: 'true', label: '是'},
        {value: 'false', label: '否'},
      ],
      forbid: subtype !== 'propcard' || appType !== 'mob'
    },
    {
      type: 'radio',
      field: 'open',
      label: '打开方式',
      initval: wrap.open || 'blank',
      required: false,
      options: [
        {value: 'blank', label: '新窗口'},
        {value: 'self', label: '当前窗口'},
      ],
      forbid: subtype !== 'propcard' || appType !== 'mob'
    },
@@ -446,13 +542,25 @@
      type: 'radio',
      field: 'permission',
      label: '权限验证',
      initval: wrap.permission || 'false',
      initval: wrap.permission || (!appType ? 'true' : 'false'),
      required: false,
      options: [
        {value: 'true', label: '启用'},
        {value: 'true', label: !appType ? '继承菜单' : '启用'},
        {value: 'false', label: '禁用'},
      ],
      forbid: !appType
      forbid: sessionStorage.getItem('editMenuType') === 'popview'
    },
    {
      type: 'radio',
      field: 'cacheLocal',
      label: '本地缓存',
      initval: wrap.cacheLocal || 'true',
      required: false,
      options: [
        {value: 'true', label: '继承菜单'},
        {value: 'false', label: '禁用'},
      ],
      forbid: sessionStorage.getItem('editMenuType') === 'popview'
    },
    {
      type: 'multiselect',