king
2024-05-25 10f5efae1624c89d9a8f04ac331e07c895ea282a
src/menu/components/chart/antv-dashboard/chartcompile/formconfig.jsx
@@ -1,18 +1,16 @@
// 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) {
  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)
    } catch {
    } catch (e) {
      roleList = []
    }
  } else {
@@ -22,24 +20,24 @@
  return [
    {
      type: 'text',
      key: 'title',
      field: 'title',
      label: '标题',
      initVal: card.title,
      initval: card.title,
      required: false
    },
    {
      type: 'text',
      key: 'name',
      field: 'name',
      label: '组件名称',
      initVal: card.name,
      initval: card.name,
      tooltip: '用于组件间的区分。',
      required: true
    },
    {
      type: 'number',
      key: 'width',
      field: 'width',
      label: '宽度',
      initVal: card.width,
      initval: card.width,
      tooltip: '栅格布局,每行等分为24列。',
      min: 1,
      max: 24,
@@ -47,23 +45,46 @@
      required: true
    },
    {
      type: 'number',
      key: 'height',
      label: '高度',
      initVal: card.height,
      min: 100,
      max: 1000,
      decimal: 0,
      required: true
      type: 'styleInput',
      field: 'height',
      label: '图表高度',
      initval: card.height,
      tooltip: '图表绘图区域的高度,不包括标题及内外边距。',
      required: true,
      options: ['px', 'vh', 'vw']
    },
    {
      type: 'select',
      key: 'blacklist',
      label: '黑名单',
      initVal: card.blacklist || [],
      multi: true,
      type: 'radio',
      field: 'permission',
      label: '权限验证',
      initval: card.permission || 'false',
      required: false,
      options: roleList
      options: [
        {value: 'true', label: '启用'},
        {value: 'false', label: '禁用'},
      ],
      forbid: !appType || ispop || isprint
    },
    {
      type: 'radio',
      field: 'cacheLocal',
      label: '本地缓存',
      initval: card.cacheLocal || 'true',
      required: false,
      options: [
        {value: 'true', label: '继承菜单'},
        {value: 'false', label: '禁用'},
      ],
      forbid: ispop || isprint
    },
    {
      type: 'multiselect',
      field: 'blacklist',
      label: '黑名单',
      initval: card.blacklist || [],
      required: false,
      options: roleList,
      forbid: !!appType || isprint
    }
  ]
}
@@ -73,29 +94,30 @@
 * @param {Array}  columns    // 显示列
 */
export function getOptionForm (card, columns) {
  // let appType = sessionStorage.getItem('appType')
  let yfields = columns.filter(item => /^(Int|Decimal)/ig.test(item.datatype))
  return [
    {
      type: 'text',
      key: 'label',
      field: 'label',
      label: '指标名称',
      initVal: card.label || '',
      initval: card.label || '',
      required: false
    },
    {
      type: 'select',
      key: 'valueField',
      field: 'valueField',
      label: '显示值',
      initVal: card.valueField || '',
      initval: card.valueField || '',
      required: true,
      options: yfields
    },
    {
      type: 'number',
      key: 'maxValue',
      field: 'maxValue',
      label: '最大值',
      initVal: card.maxValue || 100,
      initval: card.maxValue || 100,
      tooltip: '仪表盘最大刻度值',
      min: 0,
      max: 999999,
@@ -104,9 +126,9 @@
    },
    {
      type: 'number',
      key: 'tickInterval',
      field: 'tickInterval',
      label: '间隔',
      initVal: card.tickInterval || 10,
      initval: card.tickInterval || 10,
      tooltip: '仪表盘刻度间隔值。',
      min: 0,
      max: 999999,
@@ -115,30 +137,163 @@
    },
    {
      type: 'radio',
      key: 'percent',
      field: 'percent',
      label: '百分率',
      initVal: card.percent || 'true',
      initval: card.percent || 'true',
      required: false,
      options: [{
        value: 'true',
        text: '使用'
        label: '使用'
      }, {
        value: 'false',
        text: '不使用'
        label: '不使用'
      }]
    // }, {
    //   type: 'radio',
    //   field: 'download',
    //   label: '导出图片',
    //   initval: card.download || 'forbid',
    //   required: false,
    //   forbid: appType === 'mob',
    //   options: [{
    //     value: 'forbid',
    //     label: '禁用'
    //   }, {
    //     value: 'enable',
    //     label: '启用'
    //   }]
    },
    // {
    //   type: 'radio',
    //   field: 'empty',
    //   label: '空值隐藏',
    //   initval: card.empty || 'show',
    //   tooltip: '当查询数据为空时,隐藏该组件。',
    //   required: false,
    //   options: [
    //     {value: 'show', label: '否'},
    //     {value: 'hidden', label: '是'},
    //   ],
    // },
    {
      type: 'color',
      key: 'tickColor',
      field: 'tickColor',
      label: '刻度线',
      initVal: card.tickColor || '#CBCBCB',
      initval: card.tickColor || '',
      allowClear: true,
      required: false
    },
    {
      type: 'color',
      key: 'labelColor',
      field: 'labelColor',
      label: '指标颜色',
      initVal: card.labelColor || '#545454',
      initval: card.labelColor || '',
      allowClear: true,
      required: false
    }
  ]
}
/**
 * @description 获取图表视图配置表单
 * @param {object} card       // 图表对象
 * @param {Array}  columns    // 显示列
 */
export function getRadioOptionForm (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))
  return [
    {
      type: 'select',
      field: 'labelField',
      label: '指标',
      initval: card.labelField || '',
      required: true,
      options: xfields
    },
    {
      type: 'select',
      field: 'valueField',
      label: '值',
      initval: card.valueField || '',
      required: true,
      options: yfields
    },
    {
      type: 'number',
      field: 'maxValue',
      label: '最大值',
      initval: card.maxValue || 100,
      min: 0,
      max: 999999,
      decimal: 1,
      required: true
    },
    {
      type: 'number',
      field: 'radius',
      label: '外环',
      initval: card.radius || 75,
      tooltip: '图形所占区域的百分率。',
      min: 30,
      max: 100,
      decimal: 0,
      required: true
    },
    {
      type: 'number',
      field: 'fontSize',
      label: '字体大小',
      initval: card.fontSize || 28,
      min: 12,
      max: 300,
      decimal: 0,
      required: true
    },
    {
      type: 'radio',
      field: 'percent',
      label: '百分率',
      initval: card.percent || 'true',
      required: false,
      options: [{
        value: 'true',
        label: '使用'
      }, {
        value: 'false',
        label: '不使用'
      }]
    // }, {
    //   type: 'radio',
    //   field: 'download',
    //   label: '导出图片',
    //   initval: card.download || 'forbid',
    //   required: false,
    //   forbid: appType === 'mob',
    //   options: [{
    //     value: 'forbid',
    //     label: '禁用'
    //   }, {
    //     value: 'enable',
    //     label: '启用'
    //   }]
    },
    {
      type: 'color',
      field: 'backColor',
      label: '背景色',
      initval: card.backColor || '',
      allowClear: true,
      required: false
    },
    {
      type: 'color',
      field: 'labelColor',
      label: '字体颜色',
      initval: card.labelColor || '',
      allowClear: true,
      required: false
    }
  ]