king
2023-08-31 47b9baefdeeb41f50a9b7abc1abcf5e90931a89d
src/menu/components/chart/antv-bar/chartcompile/formconfig.jsx
@@ -1,15 +1,12 @@
import zhCN from '@/locales/zh-CN/model.js'
import enUS from '@/locales/en-US/model.js'
const Formdict = sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS
/**
 * @description 获取图表视图配置表单
 * @param {object} card       // 图表对象
 */
export function getBaseForm (card) {
export function getBaseForm (card, columns = []) {
  let appType = sessionStorage.getItem('appType')
  let roleList = sessionStorage.getItem('sysRoles')
  let isprint = sessionStorage.getItem('MenuType') === 'billPrint'
  let ispop = sessionStorage.getItem('editMenuType') === 'popview'
  if (roleList) {
    try {
      roleList = JSON.parse(roleList)
@@ -18,6 +15,32 @@
    }
  } else {
    roleList = []
  }
  let menulist = []
  if (appType === 'pc') {
    menulist = sessionStorage.getItem('appMenus')
    if (menulist) {
      try {
        menulist = JSON.parse(menulist)
      } catch (e) {
        menulist = []
      }
    } else {
      menulist = []
    }
  } else if (appType === '') {
    menulist = sessionStorage.getItem('fstMenuList')
    if (menulist) {
      try {
        menulist = JSON.parse(menulist)
      } catch (e) {
        menulist = []
      }
    } else {
      menulist = []
    }
  }
  return [
@@ -48,14 +71,37 @@
      required: true
    },
    {
      type: 'number',
      type: 'styleInput',
      key: 'height',
      label: '高度',
      label: '图表高度',
      initVal: card.height,
      min: 100,
      max: 1000,
      decimal: 0,
      required: true
      tooltip: '图表绘图区域的高度,不包括标题及内外边距。',
      required: true,
      options: ['px', 'vh', 'vw']
    },
    {
      type: 'radio',
      key: 'permission',
      label: '权限验证',
      initVal: card.permission || 'false',
      required: false,
      options: [
        {value: 'true', text: '启用'},
        {value: 'false', text: '禁用'},
      ],
      forbid: !appType || ispop || isprint
    },
    {
      type: 'radio',
      key: 'cacheLocal',
      label: '本地缓存',
      initVal: card.cacheLocal || 'true',
      required: false,
      options: [
        {value: 'true', text: '继承菜单'},
        {value: 'false', text: '禁用'},
      ],
      forbid: ispop || isprint
    },
    {
      type: 'select',
@@ -65,40 +111,102 @@
      multi: true,
      required: false,
      options: roleList,
      forbid: !!appType
      forbid: !!appType || isprint
    },
    // {
    //   type: 'cascader',
    //   key: 'linkmenu',
    //   label: '关联菜单',
    //   initVal: card.linkmenu || [],
    //   tooltip: '在使用柱形图且未启用自定义设置时有效。',
    //   required: false,
    //   forbid: appType === 'pc' || appType === 'mob',
    //   options: menulist
    // },
    // {
    //   type: 'select',
    //   key: 'linkmenu',
    //   label: '关联菜单',
    //   initVal: card.linkmenu || '',
    //   tooltip: '双击柱状图,会打开关联的菜单。',
    //   required: false,
    //   forbid: appType !== 'pc',
    //   options: menulist
    // },
    // {
    //   type: 'radio',
    //   key: 'open',
    //   label: '打开方式',
    //   initVal: card.open || 'blank',
    //   required: false,
    //   forbid: appType !== 'pc',
    //   options: [
    //     { value: 'blank', text: '新窗口' },
    //     { value: 'self', text: '当前窗口' }
    //   ]
    // }
    {
      type: 'radio',
      key: 'click',
      label: '点击事件',
      initVal: card.click || '',
      tooltip: '点击柱子时触发的事件,启用自定义设置时无效。',
      required: false,
      forbid: appType === 'mob' || card.chartType !== 'bar',
      options: [
        {value: '', label: '数据切换'},
        {value: 'menu', label: '菜单'},
        {value: 'menus', label: '菜单组'}
      ]
    },
    {
      type: appType === '' ? 'cascader' : 'select',
      key: 'menu',
      label: '关联菜单',
      initVal: card.menu || (appType === '' ? [] : ''),
      tooltip: '在使用柱形图且未启用自定义设置时有效。',
      required: true,
      forbid: appType === 'mob' || card.chartType !== 'bar',
      hidden: card.click !== 'menu',
      options: menulist
    },
    {
      type: 'select',
      key: 'menuType',
      label: '菜单类型',
      initVal: card.menuType || '',
      required: true,
      forbid: appType === 'mob' || card.chartType !== 'bar',
      hidden: card.click !== 'menus',
      options: columns,
    },
    {
      type: 'radio',
      key: 'open',
      label: '打开方式',
      initVal: card.open || 'blank',
      required: false,
      options: [
        {value: 'blank', label: '新窗口'},
        {value: 'self', label: '当前窗口'},
      ],
      forbid: appType !== 'pc' || card.chartType !== 'bar',
      hidden: card.click !== 'menu' && card.click !== 'menus'
    },
    {
      type: 'radio',
      key: 'joint',
      label: '参数拼接',
      initVal: card.joint || 'true',
      required: false,
      options: [
        {value: 'true', label: '是'},
        {value: 'false', label: '否'},
      ],
      forbid: appType === 'mob' || card.chartType !== 'bar',
      hidden: card.click !== 'menu' && card.click !== 'menus'
    },
    {
      type: 'table',
      key: 'menus',
      label: '菜单组',
      initVal: card.menus || [],
      required: true,
      span: 24,
      actions: ['view'],
      forbid: appType === 'mob' || card.chartType !== 'bar',
      hidden: card.click !== 'menus',
      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
        }
      ]
    }
  ]
}
@@ -113,23 +221,23 @@
  if (card.chartType === 'line') {
    shapes = [
      { field: 'smooth', label: 'smooth' },
      { field: 'line', label: 'line' },
      { field: 'dot', label: 'dot' },
      { field: 'dash', label: 'dash' },
      { field: 'hv', label: 'hv' },
      { field: 'vh', label: 'vh' },
      { field: 'hvh', label: 'hvh' },
      { field: 'vhv', label: 'vhv' }
      { field: 'smooth', label: 'smooth(平滑线)' },
      { field: 'line', label: 'line(直线)' },
      { field: 'dot', label: 'dot(点状线)' },
      { field: 'dash', label: 'dash(虚线)' },
      { field: 'hv', label: 'hv(水平-垂直线)' },
      { field: 'vh', label: 'vh(垂直-水平线)' },
      { field: 'hvh', label: 'hvh(水平-垂直-水平线)' },
      { field: 'vhv', label: 'vhv(垂直-水平-垂直线)' }
    ]
  } else if (card.chartType === 'bar') {
    shapes = [
      { field: 'rect', label: 'rect' },
      { field: 'hollow-rect', label: 'hollow-rect' },
      { field: 'line', label: 'line' },
      { field: 'tick', label: 'tick' },
      { field: 'funnel', label: 'funnel' },
      { field: 'pyramid', label: 'pyramid' }
      { field: 'rect', label: 'rect(矩形)' },
      { field: 'hollow-rect', label: 'hollow-rect(空心矩形)' },
      { field: 'line', label: 'line(线条)' },
      { field: 'tick', label: 'tick(波动)' },
      // { field: 'funnel', label: 'funnel' },
      { field: 'pyramid', label: 'pyramid(角锥)' }
    ]
  }
@@ -158,6 +266,8 @@
    }])
  }
  let _label = card.label || 'false'
  return [
    {
      type: 'radio',
@@ -167,8 +277,8 @@
      tooltip: '统计图表适用于展示数据类型为动态值。',
      required: false,
      options: [
        { value: 'query', text: Formdict['header.form.query'] },
        { value: 'statistics', text: Formdict['header.form.statistics'] }
        { value: 'query', text: '查询' },
        { value: 'statistics', text: '统计' }
      ]
    }, {
      type: 'select',
@@ -266,20 +376,21 @@
      required: false,
      options: [{
        value: 'true',
        text: Formdict['model.true']
        text: '是'
      }, {
        value: 'false',
        text: Formdict['model.false']
        text: '否'
      }]
    }, {
      type: 'radio',
      key: 'show',
      label: '格式化',
      label: '显示',
      initVal: card.show || 'value',
      tooltip: '当使用自定义设置时,可在显示(值/%)处单独设置显示类型。注:自定义为空时使用此处设置。',
      required: false,
      options: [{
        value: 'value',
        text: '无'
        text: '数值'
      }, {
        value: 'percent',
        text: '百分比'
@@ -287,17 +398,19 @@
    }, {
      type: labelOptions.length > 20 ? 'select' : 'radio',
      key: 'label',
      label: '标签',
      initVal: card.label || 'false',
      label: '标注',
      initVal: _label,
      tooltip: '图形节点处的数值。',
      required: false,
      options: labelOptions
    }, {
      type: 'radio',
      key: 'labelColor',
      label: '标签颜色',
      label: '标注颜色',
      initVal: card.labelColor || 'system',
      tooltip: '使用系统色时,使用色系选项设置的系统颜色,使用自定义为颜色设置中定义的图形颜色。',
      required: false,
      hidden: _label !== 'true',
      options: [{
        value: 'system',
        text: '系统'
@@ -305,20 +418,21 @@
        value: 'custom',
        text: '自定义'
      }]
    // }, {
    //   type: 'radio',
    //   key: 'offset',
    //   label: '标注位置',
    //   initVal: card.offset || 'outer',
    //   required: false,
    //   options: [{
    //     value: 'outer',
    //     text: '外部'
    //   }, {
    //     value: 'inner',
    //     text: '内部'
    //   }],
    //   forbid: card.chartType !== 'bar'
    }, {
      type: 'radio',
      key: 'labelValue',
      label: '标注值',
      initVal: card.labelValue || 'default',
      tooltip: '标注值的显示规则。',
      required: false,
      hidden: _label === 'false',
      options: [{
        value: 'default',
        text: '默认'
      }, {
        value: 'zero',
        text: '隐藏 0 值'
      }],
    }, {
      type: 'radio',
      key: 'adjust',
@@ -405,6 +519,31 @@
        text: '隐藏'
      }]
    }, {
      type: 'radio',
      key: 'download',
      label: '导出图片',
      initVal: card.download || 'forbid',
      required: false,
      forbid: appType === 'mob',
      options: [{
        value: 'forbid',
        text: '禁用'
      }, {
        value: 'enable',
        text: '启用'
      }]
    }, {
      type: 'radio',
      key: 'empty',
      label: '空值隐藏',
      initVal: card.empty || 'show',
      tooltip: '当查询数据为空时,隐藏该组件。',
      required: false,
      options: [
        {value: 'show', text: '否'},
        {value: 'hidden', text: '是'},
      ],
    }, {
      type: 'number',
      key: 'barSize',
      label: '柱形宽度',
@@ -441,6 +580,15 @@
      initVal: card.max,
      required: false
    }, {
      type: 'number',
      key: 'XLimit',
      min: 2,
      label: '字符限制',
      tooltip: 'X轴最大字符限制。',
      initVal: card.XLimit || 11,
      forbid: appType === 'mob',
      required: false
    }, {
      type: 'color',
      key: 'color',
      label: '色系',
@@ -460,7 +608,7 @@
      key: 'selectColor',
      label: '选中颜色',
      initVal: card.selectColor || '',
      tooltip: '选中柱形图的颜色,在交互效果《元素选中(多选)》和《元素选中(单选)》中有效,自定义设置中无效。',
      tooltip: '选中柱形图的颜色,在交互效果《元素选中(多选)》和《元素选中(单选)》中有效,启用自定义设置时无效。',
      forbid: !['bar'].includes(card.chartType),
      allowClear: true,
      required: false