king
2022-12-06 91e232bb0b910f3670bdbccd65cc218d55e1eda9
src/menu/components/card/cardcomponent/options.jsx
@@ -1,23 +1,27 @@
/**
 * @description Setting表单配置信息
 */
export default function (setting, subtype, buttons = [], cardType, columns) {
export default function (setting, subtype, buttons = [], cardType, columns, menus = []) {
  let appType = sessionStorage.getItem('appType')
  let hasMenus = subtype === 'datacard' && cardType !== 'extendCard'
  let menulist = []
  let appmenulist = []
  if (appType) {
    appmenulist = sessionStorage.getItem('appMenus')
    if (appmenulist) {
    menulist = sessionStorage.getItem('appMenus')
    if (menulist) {
      try {
        appmenulist = JSON.parse(appmenulist)
        menulist = JSON.parse(menulist)
      } catch (e) {
        appmenulist = []
        menulist = []
      }
    } else {
      appmenulist = []
      menulist = []
    }
    if (appType === 'mob' && (subtype === 'datacard' || subtype === 'propcard') && cardType !== 'extendCard') { // 数据卡可打开即时通信
      menulist.push({
        value: 'IM', label: '即时通信(系统页)'
      })
    }
  } else {
    menulist = sessionStorage.getItem('fstMenuList')
@@ -35,6 +39,12 @@
  let ops = []
  if (hasMenus) {
    ops = [{value: 'menus', label: '菜单组'}]
  }
  let adapters = sessionStorage.getItem('adapter') || ''
  if (adapters.indexOf('wxmini') > -1) {
    ops.push({value: 'miniprogram', label: '小程序'})
  } else if (setting.click === 'miniprogram') {
    setting.click = ''
  }
  const cardSettingForm = [
@@ -86,18 +96,18 @@
    {
      type: 'text',
      field: 'primaryId',
      label: '主键值',
      label: '静态主键值',
      initval: setting.primaryId || '',
      tooltip: '设置一个属性卡静态ID,向其他组件传递的指定静态ID值',
      tooltip: '设置一个属性卡静态ID,向其他组件传递的指定静态ID值,主键为动态值时无效。',
      required: false,
      forbid: subtype !== 'propcard'
    },
    {
      type: !hasMenus ? 'radio' : 'select',
      type: ops.length === 0 ? 'radio' : 'select',
      field: 'click',
      label: '点击事件',
      initval: setting.click || '',
      tooltip: '当选择触发按钮时,只有当卡片中只存在一个按钮时有效。',
      // tooltip: '当绑定点击事件时,卡片的切换功能将失效。',
      required: false,
      options: [
        {value: '', label: '无'},
@@ -110,9 +120,13 @@
        {field: 'menu', values: ['menu']},
        {field: 'linkurl', values: ['link']},
        {field: 'open', values: ['menu', 'link', 'menus']},
        {field: 'joint', values: ['menu', 'link', 'menus']},
        {field: 'joint', values: ['menu', 'link', 'menus', 'miniprogram']},
        {field: 'linkbtn', values: ['button']},
        {field: 'clickType', values: ['button']},
        {field: 'menuType', values: ['menus']},
        {field: 'menus', values: ['menus']},
        {field: 'miniAppId', values: ['miniprogram']},
        {field: 'miniPath', values: ['miniprogram']},
      ]
    },
    {
@@ -129,7 +143,8 @@
      label: '关联菜单',
      initval: setting.menu || (appType ? '' : []),
      required: true,
      options: appType ? appmenulist : menulist,
      extendName: 'MenuNo',
      options: menulist,
    },
    {
      type: 'textarea',
@@ -141,16 +156,31 @@
      span: 24
    },
    {
      type: 'text',
      field: 'miniAppId',
      label: '小程序AppID',
      initval: setting.miniAppId || '',
      required: true
    },
    {
      type: 'text',
      field: 'miniPath',
      label: '页面路径',
      initval: setting.miniPath || '',
      tooltip: '可指定跳转小程序页面,为空时打开首页,注:参数拼接在指定页面时有效。',
      required: false
    },
    {
      type: 'radio',
      field: 'open',
      label: '打开方式',
      initval: setting.open || 'blank',
      required: false,
      options: [
        {value: 'blank', label: '新窗口'},
        {value: 'self', label: '当前窗口'},
        {value: 'blank', label: appType !== 'mob' ? '新窗口' : '新页面'},
        {value: 'self', label: appType !== 'mob' ? '当前窗口' : '当前页面'},
      ],
      forbid: appType !== 'pc'
      forbid: appType !== 'pc' && appType !== 'mob'
    },
    {
      type: 'radio',
@@ -170,6 +200,62 @@
      initval: setting.linkbtn || '',
      required: true,
      options: buttons
    },
    {
      type: 'radio',
      field: 'clickType',
      label: '触发方式',
      initval: setting.clickType || 'normal',
      required: false,
      options: [
        {value: 'normal', label: '单击'},
        {value: 'multi', label: '双击'},
      ],
      forbid: appType === 'mob'
    },
    {
      type: 'radio',
      field: 'btnControl',
      label: '按钮控制',
      initval: setting.btnControl || 'show',
      tooltip: '可设置按钮显示规则,一直显示或鼠标悬浮时显示。',
      required: false,
      options: [
        {value: 'show', label: '正常显示'},
        {value: 'hover', label: '悬浮显示'},
      ],
      forbid: appType === 'mob'
    },
    {
      type: 'table',
      field: 'menus',
      label: '菜单组',
      initval: menus,
      required: true,
      span: 24,
      actions: ['view'],
      columns: [
        {
          title: '标识',
          dataIndex: 'sign',
          inputType: 'input',
          editable: true,
          unique: true,
          required: false,
          width: '35%'
        },
        {
          title: '菜单',
          dataIndex: 'menu',
          inputType: !appType ? 'cascader' : 'select',
          editable: true,
          required: true,
          extends: !appType ? 'Menu' : [{key: 'label', value: 'label'}],
          width: '35%',
          render: (text, record) => record.label,
          options: menulist
        }
      ]
    }
  ]