king
2023-12-14 0eb129a9beddbb86ae74d7106a8e60823206b8d5
src/menu/components/chart/antv-pie/chartcompile/formconfig.jsx
@@ -1,18 +1,31 @@
// 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
/**
 * @description 获取图表视图配置表单
 * @param {object} card       // 图表对象
 */
export function getBaseForm (card) {
  let menulist = sessionStorage.getItem('fstMenuList')
  let appType = sessionStorage.getItem('appType')
  let isApp = appType === 'pc' || appType === 'mob'
  let menulist = null
  let isprint = sessionStorage.getItem('MenuType') === 'billPrint'
  let ispop = sessionStorage.getItem('editMenuType') === 'popview'
  if (isApp) {
    menulist = sessionStorage.getItem('appMenus')
  } else {
    menulist = sessionStorage.getItem('fstMenuList')
  }
  if (menulist) {
    try {
      menulist = JSON.parse(menulist)
    } catch {
      if (isApp) {
        menulist = menulist.map(item => {
          item.value = item.MenuID
          item.text = item.MenuName
          return item
        })
      }
    } catch (e) {
      menulist = []
    }
  } else {
@@ -23,7 +36,7 @@
  if (roleList) {
    try {
      roleList = JSON.parse(roleList)
    } catch {
    } catch (e) {
      roleList = []
    }
  } else {
@@ -58,23 +71,13 @@
      required: true
    },
    {
      type: 'number',
      type: 'styleInput',
      key: 'height',
      label: '高度',
      label: '图表高度',
      initVal: card.height,
      min: 100,
      max: 1000,
      decimal: 0,
      required: true
    },
    {
      type: 'select',
      key: 'blacklist',
      label: '黑名单',
      initVal: card.blacklist || [],
      multi: true,
      required: false,
      options: roleList
      tooltip: '图表绘图区域的高度,不包括标题及内外边距。',
      required: true,
      options: ['px', 'vh', 'vw']
    },
    {
      type: 'cascader',
@@ -83,7 +86,64 @@
      initVal: card.linkmenu || [],
      tooltip: '双击饼图,会打开关联的菜单。',
      required: false,
      forbid: isApp,
      options: menulist
    },
    {
      type: 'select',
      key: 'linkmenu',
      label: '关联菜单',
      initVal: card.linkmenu || '',
      tooltip: '双击饼图,会打开关联的菜单。',
      required: false,
      forbid: !isApp,
      options: menulist
    },
    {
      type: 'radio',
      key: 'open',
      label: '打开方式',
      initVal: card.open || 'blank',
      required: false,
      forbid: !isApp,
      options: [
        { value: 'blank', text: '新窗口' },
        { value: 'self', text: '当前窗口' }
      ]
    },
    {
      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',
      key: 'blacklist',
      label: '黑名单',
      initVal: card.blacklist || [],
      multi: true,
      required: false,
      options: roleList,
      forbid: !!appType || isprint
    }
  ]
}
@@ -93,6 +153,7 @@
 * @param {Array}  columns    // 显示列
 */
export function getOptionForm (card, columns) {
  let appType = sessionStorage.getItem('appType')
  let xfields = columns.filter(item => /^Nvarchar/ig.test(item.datatype))
  let yfields = columns.filter(item => /^(Int|Decimal)/ig.test(item.datatype))
@@ -106,13 +167,14 @@
      options: [
        { value: 'pie', text: '饼图' },
        { value: 'ring', text: '环图' },
        { value: 'nest', text: '嵌套' },
        { value: 'nightingale', text: '南丁格尔图' }
      ]
    },
    {
      type: 'select',
      key: 'Xaxis',
      label: 'X-轴',
      label: '名称',
      initVal: card.Xaxis || '',
      required: true,
      options: xfields
@@ -120,10 +182,20 @@
    {
      type: 'select',
      key: 'Yaxis',
      label: 'Y-轴',
      label: '值',
      initVal: card.Yaxis || '',
      required: true,
      options: yfields
    },
    {
      type: 'select',
      key: 'type',
      label: '类型',
      initVal: card.type || '',
      tooltip: '内环的分类字段。',
      required: true,
      options: xfields,
      hidden: card.shape !== 'nest',
    },
    {
      type: 'select',
@@ -145,7 +217,8 @@
        { field: 'left-top', label: '左上' },
        { field: 'left-bottom', label: '左下' },
        { field: 'hidden', label: '隐藏' }
      ]
      ],
      hidden: card.shape === 'nest',
    },
    {
      type: 'number',
@@ -201,7 +274,7 @@
    {
      type: 'radio',
      key: 'label',
      label: '标注值',
      label: '标注',
      initVal: card.label || 'false',
      required: false,
      options: [{
@@ -212,38 +285,82 @@
        text: '内侧'
      }, {
        value: 'outer',
        text: '外侧'
        text: '蜘蛛'
      }, {
        value: 'normal',
        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: 'repeat',
      label: '重复数据',
      initVal: card.repeat || 'unrepeat',
      key: 'empty',
      label: '空值隐藏',
      initVal: card.empty || 'show',
      tooltip: '当查询数据为空时,隐藏该组件。',
      required: false,
      options: [{
        value: 'unrepeat',
        text: '去重'
      }, {
        value: 'average',
        text: '平均'
      }, {
        value: 'cumsum',
        text: '累加'
      }]
      options: [
        {value: 'show', text: '否'},
        {value: 'hidden', text: '是'},
      ],
    }, {
      type: 'number',
      key: 'splitLine',
      label: '分隔线',
      initVal: card.splitLine || '',
      tooltip: '分隔线的宽度。',
      min: 0,
      max: 20,
      decimal: 0,
      required: false
    }, {
      type: 'color',
      key: 'splitColor',
      label: '分隔色',
      initVal: card.splitColor || '#ffffff',
      tooltip: '分隔线的颜色,存在分隔线时有效。',
      required: false
    }, {
      type: 'color',
      key: 'color',
      label: '色系',
      initVal: card.color || 'rgba(0, 0, 0, 0.85)',
      tooltip: '坐标轴及示例等提示文字使用的颜色。',
      required: false
    }, {
      type: 'select',
      key: 'interaction',
      label: '交互效果',
      initVal: card.interaction || [],
      multi: true,
      required: false,
      options: [{
        value: 'black',
        text: '黑色'
      }, {
        value: 'white',
        text: '白色'
      }]
      forbid: appType === 'mob',
      options: [
        { value: 'element-active', label: '元素聚焦' },
        { value: 'element-selected', label: '元素选中(多选)' },
        { value: 'element-single-selected', label: '元素选中(单选)' },
        // { value: 'active-region', label: '背景框' },
        // { value: 'view-zoom', label: '视图缩放' },
        { value: 'element-highlight', label: '元素高亮' },
        // { value: 'element-highlight-by-color', label: '同色元素高亮' },
        // { value: 'element-highlight-by-x', label: '同X轴元素高亮' },
        { value: 'legend-filter', label: '图例过滤' },
        { value: 'legend-active', label: '图例聚焦' },
        { value: 'legend-highlight', label: '图例高亮' },
        // { value: 'brush', label: '选框过滤' },
      ]
    }
  ]
}