king
2022-09-22 c33ac9ddcdbed91bd2267bed2a96199441806a04
src/menu/components/chart/antv-dashboard/chartcompile/formconfig.jsx
@@ -8,11 +8,12 @@
 * @param {object} card       // 图表对象
 */
export function getBaseForm (card) {
  let appType = sessionStorage.getItem('appType')
  let roleList = sessionStorage.getItem('sysRoles')
  if (roleList) {
    try {
      roleList = JSON.parse(roleList)
    } catch {
    } catch (e) {
      roleList = []
    }
  } else {
@@ -57,13 +58,26 @@
      required: true
    },
    {
      type: 'radio',
      key: 'permission',
      label: '权限验证',
      initVal: card.permission || 'false',
      required: false,
      options: [
        {value: 'true', text: '启用'},
        {value: 'false', text: '禁用'},
      ],
      forbid: !appType
    },
    {
      type: 'select',
      key: 'blacklist',
      label: '黑名单',
      initVal: card.blacklist || [],
      multi: true,
      required: false,
      options: roleList
      options: roleList,
      forbid: !!appType
    }
  ]
}
@@ -73,6 +87,7 @@
 * @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 [
@@ -126,7 +141,33 @@
        value: 'false',
        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: 'color',
      key: 'tickColor',
@@ -143,3 +184,106 @@
    }
  ]
}
/**
 * @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',
      key: 'labelField',
      label: '指标',
      initVal: card.labelField || '',
      required: true,
      options: xfields
    },
    {
      type: 'select',
      key: 'valueField',
      label: '值',
      initVal: card.valueField || '',
      required: true,
      options: yfields
    },
    {
      type: 'number',
      key: 'maxValue',
      label: '最大值',
      initVal: card.maxValue || 100,
      min: 0,
      max: 999999,
      decimal: 1,
      required: true
    },
    {
      type: 'number',
      key: 'radius',
      label: '外环',
      initVal: card.radius || 75,
      tooltip: '图形所占区域的百分率。',
      min: 30,
      max: 100,
      decimal: 0,
      required: true
    },
    {
      type: 'number',
      key: 'fontSize',
      label: '字体大小',
      initVal: card.fontSize || 28,
      min: 12,
      max: 300,
      decimal: 0,
      required: true
    },
    {
      type: 'radio',
      key: 'percent',
      label: '百分率',
      initVal: card.percent || 'true',
      required: false,
      options: [{
        value: 'true',
        text: '使用'
      }, {
        value: 'false',
        text: '不使用'
      }]
    }, {
      type: 'radio',
      key: 'download',
      label: '导出图片',
      initVal: card.download || 'forbid',
      required: false,
      forbid: appType === 'mob',
      options: [{
        value: 'forbid',
        text: '禁用'
      }, {
        value: 'enable',
        text: '启用'
      }]
    },
    {
      type: 'color',
      key: 'backColor',
      label: '背景色',
      initVal: card.backColor || '#ebedf0',
      required: false
    },
    {
      type: 'color',
      key: 'labelColor',
      label: '字体颜色',
      initVal: card.labelColor || '#8c8c8c',
      required: false
    }
  ]
}