king
2021-06-02 e543372cc70a19ff2630c79d8421c2c593e54e5f
src/menu/components/chart/antv-bar/chartcompile/formconfig.jsx
@@ -1,15 +1,52 @@
import zhCN from '@/locales/zh-CN/model.js'
import enUS from '@/locales/en-US/model.js'
const Formdict = localStorage.getItem('lang') !== 'en-US' ? zhCN : enUS
const Formdict = sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS
/**
 * @description 获取图表视图配置表单
 * @param {object} card       // 图表对象
 * @param {Array}  columns    // 显示列
 */
export function getBaseForm (card, sysRoles = [], MenuType) {
  let _sysRoles = sysRoles.map(item => ({...item, field: item.value, label: item.text}))
export function getBaseForm (card) {
  let appType = sessionStorage.getItem('appType')
  let menulist = null
  if (appType === 'pc') {
    menulist = sessionStorage.getItem('appMenus')
    if (Array.isArray(card.linkmenu)) {
      card.linkmenu = ''
    }
  } else {
    menulist = sessionStorage.getItem('fstMenuList')
  }
  if (menulist) {
    try {
      menulist = JSON.parse(menulist)
      if (appType === 'pc') {
        menulist = menulist.map(item => {
          item.value = item.MenuID
          item.text = item.MenuName
          return item
        })
      }
    } catch {
      menulist = []
    }
  } else {
    menulist = []
  }
  let roleList = sessionStorage.getItem('sysRoles')
  if (roleList) {
    try {
      roleList = JSON.parse(roleList)
    } catch {
      roleList = []
    }
  } else {
    roleList = []
  }
  return [
    {
@@ -55,8 +92,39 @@
      initVal: card.blacklist || [],
      multi: true,
      required: false,
      forbid: MenuType === 'billPrint',
      options: _sysRoles
      options: roleList
    },
    {
      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: '当前窗口' }
      ]
    }
  ]
}
@@ -66,7 +134,7 @@
 * @param {object} card       // 图表对象
 * @param {Array}  columns    // 显示列
 */
export function getOptionForm (card, columns, MenuType) {
export function getOptionForm (card, columns) {
  let shapes = []
  if (card.chartType === 'line') {
@@ -100,22 +168,20 @@
      key: 'datatype',
      label: '数据类型',
      initVal: card.datatype || 'query',
      tooltip: '统计图表适用于表格不分页,且数据需要转换',
      tooltip: '统计图表适用于展示数据类型为动态值。',
      required: false,
      options: [
        { value: 'query', text: Formdict['header.form.query'] },
        { value: 'statistics', text: Formdict['header.form.statistics'] }
      ]
    },
    {
    }, {
      type: 'select',
      key: 'Xaxis',
      label: 'X-轴',
      initVal: card.Xaxis || '',
      required: true,
      options: xfields
    },
    {
    }, {
      type: 'select',
      key: 'InfoType',
      label: '类型',
@@ -123,8 +189,7 @@
      hidden: card.datatype !== 'statistics',
      required: true,
      options: xfields
    },
    {
    }, {
      type: 'select',
      key: 'InfoValue',
      label: '值',
@@ -132,8 +197,7 @@
      hidden: card.datatype !== 'statistics',
      required: true,
      options: yfields
    },
    {
    }, {
      type: 'select',
      key: 'legend',
      label: '图例位置',
@@ -154,8 +218,7 @@
        { field: 'left-bottom', label: '左下' },
        { field: 'hidden', label: '隐藏' }
      ]
    },
    {
    }, {
      type: 'select',
      key: 'Yaxis',
      label: 'Y-轴',
@@ -164,16 +227,14 @@
      hidden: card.datatype === 'statistics',
      required: true,
      options: yfields
    },
    {
    }, {
      type: 'select',
      key: 'shape',
      label: '形状',
      initVal: card.shape || (shapes[0] && shapes[0].field),
      required: false,
      options: shapes
    },
    {
    }, {
      type: 'radio',
      key: 'tooltip',
      label: '悬浮提示',
@@ -186,8 +247,7 @@
        value: 'false',
        text: '隐藏'
      }]
    },
    {
    }, {
      type: 'radio',
      key: 'point',
      label: '点图',
@@ -201,8 +261,7 @@
        value: 'false',
        text: '隐藏'
      }]
    },
    {
    }, {
      type: 'radio',
      key: 'transpose',
      label: '变换',
@@ -216,8 +275,7 @@
        value: 'false',
        text: Formdict['model.false']
      }]
    },
    {
    }, {
      type: 'radio',
      key: 'show',
      label: '格式化',
@@ -230,8 +288,7 @@
        value: 'percent',
        text: '百分比'
      }]
    },
    {
    }, {
      type: 'radio',
      key: 'label',
      label: '标注值',
@@ -244,6 +301,20 @@
        value: 'false',
        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: 'adjust',
@@ -289,17 +360,6 @@
      }]
    }, {
      type: 'number',
      key: 'InfoDefNumber',
      label: '展示数',
      tooltip: '默认显示类型数量',
      min: 1,
      max: 50,
      decimal: 0,
      initVal: card.InfoDefNumber || 5,
      hidden: card.datatype !== 'statistics',
      required: true
    }, {
      type: 'number',
      key: 'barSize',
      label: '柱形宽度',
      tooltip: '空值时,宽度自适应。',
@@ -310,19 +370,23 @@
      forbid: !['bar'].includes(card.chartType),
      required: false
    }, {
      type: 'number',
      key: 'barRadius',
      label: '柱形圆角',
      tooltip: '柱形图上端圆角。',
      min: 0,
      max: 200,
      decimal: 0,
      initVal: card.barRadius || 0,
      forbid: !['bar'].includes(card.chartType),
      required: false
    }, {
      type: 'color',
      key: 'color',
      label: '色系',
      initVal: card.color || 'rgba(0, 0, 0, 0.85)',
      tooltip: '坐标轴及示例等提示文字使用的颜色。',
      required: false,
      options: [{
        value: 'black',
        text: '黑色'
      }, {
        value: 'white',
        text: '白色'
      }]
      initVal: card.color || 'rgba(0, 0, 0, 0.65)',
      tooltip: '坐标轴提示文字及示例的颜色。',
      required: false
    }
  ]
}