king
2025-04-27 0173a5b8b4cb7d537f5e0d71c414ed1e6e92a725
src/menu/components/table/normal-table/options.jsx
@@ -1,9 +1,13 @@
import MenuUtils from '@/utils/utils-custom.js'
/**
 * @description Wrap表单配置信息
 */
export default function (wrap, action = [], columns = []) {
export default function (wrap, action = [], columns = [], toolBtns, supNodes, id = '') {
  let roleList = sessionStorage.getItem('sysRoles')
  let appType = sessionStorage.getItem('appType')
  let isprint = sessionStorage.getItem('MenuType') === 'billPrint'
  let ispop = sessionStorage.getItem('editMenuType') === 'popview'
  if (roleList) {
    try {
@@ -14,6 +18,9 @@
  } else {
    roleList = []
  }
  let menu = window.GLOB.customMenu
  let modules = MenuUtils.getSupModules(menu.components, id, menu.interfaces)
  const wrapForm = [
    {
@@ -45,10 +52,10 @@
    {
      type: 'number',
      field: 'height',
      label: '高度',
      label: '最大高度',
      initval: wrap.height || '',
      tooltip: '表格高度,空值时高度自适应。',
      min: 10,
      tooltip: '表格内容区的最大高度(不包含表头),空值时高度自适应。注:小于等于100大于0时为高度的百分比,小于0时为窗口高度减去此值。',
      min: -1000,
      max: 3000,
      precision: 0,
      required: false,
@@ -71,6 +78,17 @@
    },
    {
      type: 'radio',
      field: 'parity',
      label: '奇偶异色',
      initval: wrap.parity || 'false',
      required: false,
      options: [
        {value: 'true', label: '启用'},
        {value: 'false', label: '禁用'},
      ]
    },
    {
      type: 'radio',
      field: 'bordered',
      label: '边框',
      initval: wrap.bordered || 'true',
@@ -79,6 +97,30 @@
        {value: 'true', label: '有'},
        {value: 'false', label: '无'},
      ]
    },
    {
      type: 'radio',
      field: 'actionfixed',
      label: '固定按钮',
      initval: wrap.actionfixed !== 'true' ? 'false' : 'true',
      required: false,
      options: [
        {value: 'true', label: '是'},
        {value: 'false', label: '否'},
      ],
      forbid: appType === 'mob' || appType === 'pc'
    },
    {
      type: 'checkbox',
      field: 'colfixed',
      label: '固定列',
      initval: wrap.colfixed || [],
      required: false,
      options: [
        {value: 'first', label: '首列'},
        {value: 'last', label: '尾列'},
      ],
      forbid: appType === 'mob' || appType === 'pc'
    },
    {
      type: 'radio',
@@ -119,6 +161,19 @@
    },
    {
      type: 'radio',
      field: 'searchSize',
      label: '搜索样式',
      initval: wrap.searchSize === 'middle' ? '' : wrap.searchSize || '',
      required: false,
      options: [
        {value: '', label: '默认'},
        {value: 'small', label: '小间距'},
        {value: 'updown', label: '上下排列'},
      ],
      forbid: appType === 'mob'
    },
    {
      type: 'radio',
      field: 'mode',
      label: '模式',
      initval: wrap.mode || 'default',
@@ -129,31 +184,6 @@
      ]
    },
    {
      type: 'radio',
      field: 'selected',
      label: '首行选中',
      initval: wrap.selected || 'false',
      tooltip: '当按钮执行完成并返回主键值时,默认选中主键值对应行。',
      required: false,
      options: [
        {value: 'false', label: '无'},
        {value: 'init', label: '初始化'},
        {value: 'always', label: '数据加载'},
      ]
    },
    // {
    //   type: 'radio',
    //   field: 'show',
    //   label: '搜索按钮',
    //   initval: wrap.show || 'true',
    //   tooltip: '搜索条件存在时,可选择是否显示搜索按钮。',
    //   required: false,
    //   options: [
    //     {value: 'true', label: '显示'},
    //     {value: 'false', label: '隐藏'},
    //   ]
    // },
    {
      type: 'color',
      field: 'borderColor',
      label: '边框颜色',
@@ -161,36 +191,34 @@
      tooltip: '默认值 #e8e8e8。',
      required: false
    },
    // {
    //   type: 'color',
    //   field: 'color',
    //   label: '字体颜色',
    //   initval: wrap.color || 'rgba(0, 0, 0, 0.65)',
    //   tooltip: '默认值 rgba(0, 0, 0, 0.65)。',
    //   required: false
    // },
    // {
    //   type: 'number',
    //   field: 'fontSize',
    //   label: '字体大小',
    //   initval: wrap.fontSize || 14,
    //   min: 12,
    //   max: 30,
    //   precision: 0,
    //   required: false
    // },
    // {
    //   type: 'number',
    //   field: 'advanceWidth',
    //   label: '高级搜索',
    //   initval: wrap.advanceWidth || 1000,
    //   tooltip: '高级搜索弹窗的宽度,注:当宽度值小于100时表示占窗口的百分比,大于100时表示宽度的绝对值。',
    //   min: 10,
    //   max: 3000,
    //   precision: 0,
    //   required: false,
    //   forbid: appType === 'mob'
    // },
    {
      type: 'radio',
      field: 'vertical',
      label: '垂直对齐',
      initval: wrap.vertical || 'middle',
      tooltip: '单元格的垂直对齐方式。',
      required: false,
      options: [
        {value: 'top', label: '向上'},
        {value: 'middle', label: '居中'},
        {value: 'bottom', label: '向下'},
      ]
    },
    {
      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: '选中标记'},
        {value: 'local', label: '本地记录'},
      ],
    },
    {
      type: 'select',
      field: 'doubleClick',
@@ -199,8 +227,28 @@
      tooltip: '双击表格中行,触发的按钮。',
      required: false,
      allowClear: true,
      options: action.map(item => ({value: item.uuid, label: item.label})),
      options: [...toolBtns, ...action].map(item => ({value: item.uuid, label: item.label})),
      forbid: appType === 'mob'
    },
    {
      type: 'select',
      field: 'autoExec',
      label: '自动执行',
      initval: wrap.autoExec || '',
      tooltip: '初始化自动执行按钮。',
      required: false,
      options: toolBtns.map(item => ({value: item.uuid, label: item.label}))
    },
    {
      type: 'select',
      field: 'tipField',
      label: '信息提示',
      initval: wrap.tipField || '',
      tooltip: '鼠标悬浮于行上方时的提示信息。',
      required: false,
      allowClear: true,
      joint: true,
      options: columns
    },
    {
      type: 'select',
@@ -210,6 +258,7 @@
      tooltip: '用于控制行数据是否可选择。',
      required: false,
      allowClear: true,
      joint: true,
      options: columns,
      controlFields: [
        {field: 'controlVal', notNull: true},
@@ -224,6 +273,30 @@
      required: false
    },
    {
      type: 'number',
      field: 'btnlimit',
      label: '按钮限制',
      initval: wrap.btnlimit || '',
      tooltip: '按钮数量限制,超出的按钮会在更多中下拉显示,注:更多中的按钮不要绑定双击事件。',
      min: 3,
      max: 3000,
      precision: 0,
      required: false,
      forbid: appType !== '' || isprint
    },
    {
      type: 'number',
      field: 'maxPageSize',
      label: '每页最大数',
      initval: wrap.maxPageSize || '',
      tooltip: '分页时每页可显示的最大数量。',
      min: 10,
      max: 500,
      precision: 0,
      required: false,
      forbid: appType === 'mob'
    },
    {
      type: 'radio',
      field: 'empty',
      label: '空值隐藏',
@@ -233,6 +306,21 @@
      options: [
        {value: 'show', label: '否'},
        {value: 'hidden', label: '是'},
      ],
      controlFields: [
        {field: 'empSign', values: ['show']},
      ]
    },
    {
      type: 'radio',
      field: 'empSign',
      label: '空值图标',
      initval: wrap.empSign || 'show',
      tooltip: '当查询数据为空时,是否显示空值提示图标。',
      required: false,
      options: [
        {value: 'show', label: '显示'},
        {value: 'hidden', label: '隐藏'},
      ],
    },
    {
@@ -246,18 +334,121 @@
        {value: 'true', label: '验证'},
        {value: 'false', label: '忽略'},
      ],
      forbid: isprint
    },
    {
      type: 'radio',
      field: 'supType',
      label: '上级类型',
      initval: wrap.supType || 'single',
      tooltip: '上级组件为单一组件或多个组件。',
      required: false,
      forbid: appType === 'mob' || isprint,
      options: [
        {value: 'single', label: '单组件'},
        {value: 'multi', label: '多组件'},
      ],
      controlFields: [
        {field: 'supNodes', values: ['multi']},
      ]
    },
    {
      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: 'tree',
      label: '结构树',
      initval: wrap.tree || 'false',
      tooltip: '使用结构树时,显示列首列请使用文本类型。',
      required: false,
      options: [
        {value: 'true', label: '启用'},
        {value: 'false', label: '禁用'},
      ],
      controlFields: [
        {field: 'valueField', values: ['true']},
        {field: 'parentField', values: ['true']},
        {field: 'mark', values: ['true']},
        {field: 'defOpen', values: ['true']},
      ],
      forbid: appType === 'mob' || isprint
    },
    {
      type: 'select',
      field: 'valueField',
      label: '值字段',
      initval: wrap.valueField || '',
      tooltip: '数据值字段,结构树中节点ID值,与上级字段配合组织数据的上下级关系。',
      required: true,
      options: columns,
      forbid: appType === 'mob' || isprint
    },
    {
      type: 'select',
      field: 'parentField',
      label: '上级字段',
      initval: wrap.parentField || '',
      tooltip: '上级字段,用于组织数据的上下级关系。',
      required: true,
      options: columns,
      forbid: appType === 'mob' || isprint
    },
    {
      type: 'text',
      field: 'mark',
      label: '顶级标识',
      initval: wrap.mark || '',
      tooltip: '上级字段值与顶级标识相同时,视为顶级节点。',
      required: false,
      forbid: appType === 'mob' || isprint
    },
    {
      type: 'radio',
      field: 'defOpen',
      label: '默认展开',
      initval: wrap.defOpen || '',
      required: false,
      options: [
        {value: '', label: '无'},
        {value: 'topline', label: '首行'},
        {value: 'all', label: '全部'},
      ],
      forbid: appType === 'mob' || isprint
    },
    {
      type: 'multiselect',
@@ -266,8 +457,38 @@
      initval: wrap.blacklist || [],
      required: false,
      options: roleList,
      forbid: !!appType
      forbid: !!appType || isprint
    },
    {
      type: 'table',
      field: 'supNodes',
      label: '上级组件',
      initval: supNodes,
      required: true,
      forbid: appType === 'mob' || isprint,
      span: 24,
      actions: ['edit', 'del', 'add', 'move'],
      columns: [
        {
          title: '序号',
          dataIndex: '$index',
          editable: false,
          required: false,
          width: '20%'
        },
        {
          title: '组件',
          dataIndex: 'nodes',
          inputType: 'cascader',
          editable: true,
          required: true,
          extends: [{key: 'label', value: 'label'}],
          width: '50%',
          render: (text, record) => record.label,
          options: modules
        }
      ]
    }
  ]
  return wrapForm