king
2020-05-06 4e1938344ca46c0cbe699756ecaffa630e698aec
src/templates/zshare/formconfig.jsx
@@ -1310,14 +1310,14 @@
/**
 * @description 获取图表视图配置表单
 * @param {object} card       // 搜索条件对象
 * @param {object} card       // 图表对象
 * @param {Array}  columns    // 显示列
 * @param {String} type       // 图表类型
 * @param {String} setting    // 页面设置
 */
export function getChartOptionForm (card, columns, type) {
export function getChartOptionForm (card, columns, setting) {
  let shapes = []
  if (type === 'line') {
  if (card.chartType === 'line') {
    shapes = [
      { field: 'smooth', label: 'smooth' },
      { field: 'line', label: 'line' },
@@ -1328,7 +1328,7 @@
      { field: 'hvh', label: 'hvh' },
      { field: 'vhv', label: 'vhv' }
    ]
  } else if (type === 'bar') {
  } else if (card.chartType === 'bar') {
    shapes = [
      { field: 'rect', label: 'rect' },
      { field: 'hollow-rect', label: 'hollow-rect' },
@@ -1337,7 +1337,7 @@
      { field: 'funnel', label: 'funnel' },
      { field: 'pyramid', label: 'pyramid' }
    ]
  } else if (type === 'pie') {
  } else if (card.chartType === 'pie') {
    shapes = [
      { field: 'pie', label: '饼图' },
      { field: 'ring', label: '环图' }
@@ -1346,9 +1346,23 @@
  return [
    {
      type: 'radio',
      key: 'datatype',
      label: '数据类型',
      initVal: card.datatype || 'query',
      tooltip: '统计图表适用于表格不分页,且数据需要转换',
      required: false,
      readonly: !(setting.laypage === 'false'),
      forbid: !['line', 'bar'].includes(card.chartType),
      options: [
        { value: 'query', text: Formdict['header.form.query'] },
        { value: 'statistics', text: Formdict['header.form.statistics'] }
      ]
    },
    {
      type: 'select',
      key: 'Xaxis',
      label: type === 'pie' ? 'Text' : 'X-轴',
      label: card.chartType === 'pie' ? 'Text' : 'X-轴',
      initVal: card.Xaxis || '',
      required: true,
      options: columns.filter(col => col.type === 'text')
@@ -1356,9 +1370,30 @@
    {
      type: 'select',
      key: 'Yaxis',
      label: type === 'pie' ? 'Value' : 'Y-轴',
      initVal: type === 'pie' ? card.Yaxis || '' : card.Yaxis || [],
      multi: type !== 'pie',
      label: card.chartType === 'pie' ? 'Value' : 'Y-轴',
      initVal: card.chartType === 'pie' ? card.Yaxis || '' : card.Yaxis || [],
      multi: card.chartType !== 'pie',
      hidden: card.datatype === 'statistics',
      required: true,
      options: columns.filter(col => col.type === 'number')
    },
    {
      type: 'select',
      key: 'InfoType',
      label: '类型',
      initVal: card.InfoType || '',
      forbid: !['line', 'bar'].includes(card.chartType),
      hidden: card.datatype !== 'statistics',
      required: true,
      options: columns.filter(col => col.type === 'text')
    },
    {
      type: 'select',
      key: 'InfoValue',
      label: '值',
      initVal: card.InfoValue || '',
      forbid: !['line', 'bar'].includes(card.chartType),
      hidden: card.datatype !== 'statistics',
      required: true,
      options: columns.filter(col => col.type === 'number')
    },
@@ -1390,7 +1425,7 @@
      label: '形状',
      initVal: card.shape || (shapes[0] && shapes[0].field),
      required: false,
      hidden: !['line', 'bar', 'pie'].includes(type),
      forbid: !['line', 'bar', 'pie'].includes(card.chartType),
      options: shapes
    },
    {
@@ -1413,7 +1448,7 @@
      label: '坐标',
      initVal: card.coordinate || 'angle',
      required: false,
      hidden: !['line', 'bar'].includes(type),
      forbid: !['line', 'bar'].includes(card.chartType),
      options: [{
        value: 'angle',
        text: '二维坐标'
@@ -1428,7 +1463,7 @@
      label: '点图',
      initVal: card.point || 'false',
      required: false,
      hidden: !['line'].includes(type),
      forbid: !['line'].includes(card.chartType),
      options: [{
        value: 'true',
        text: '显示'
@@ -1443,7 +1478,7 @@
      label: '变换',
      initVal: card.transpose || 'false',
      required: false,
      hidden: !['line', 'bar'].includes(type),
      forbid: !['line', 'bar'].includes(card.chartType),
      options: [{
        value: 'true',
        text: Formdict['header.form.true']
@@ -1458,7 +1493,7 @@
      label: '显示值',
      initVal: card.pieshow || 'percent',
      required: false,
      hidden: !['pie'].includes(type),
      forbid: !['pie'].includes(card.chartType),
      options: [{
        value: 'percent',
        text: '百分比'
@@ -1471,9 +1506,9 @@
      type: 'radio',
      key: 'label',
      label: '文本标签',
      initVal: card.label || (type === 'pie' ? 'true' : 'false'),
      initVal: card.label || (card.chartType === 'pie' ? 'true' : 'false'),
      required: false,
      hidden: !['pie', 'line'].includes(type),
      forbid: !['pie', 'line'].includes(card.chartType),
      options: [{
        value: 'true',
        text: '显示'
@@ -1487,7 +1522,7 @@
      label: '标签布局',
      initVal: card.labelLayout || 'normal',
      required: false,
      hidden: !['pie'].includes(type),
      forbid: !['pie'].includes(card.chartType),
      options: [{
        value: 'normal',
        text: '常规'
@@ -1501,7 +1536,7 @@
      label: '多柱排列',
      initVal: card.adjust || 'dodge',
      required: false,
      hidden: !['bar'].includes(type),
      forbid: !['bar'].includes(card.chartType),
      options: [{
        value: 'dodge',
        text: '分组'
@@ -1509,7 +1544,36 @@
        value: 'stack',
        text: '堆叠'
      }]
    }
    }, {
      type: 'radio',
      key: 'repeat',
      label: '重复数据',
      initVal: card.repeat || 'unrepeat',
      required: false,
      // forbid: !['bar', 'pie', 'line'].includes(card.chartType),
      options: [{
        value: 'unrepeat',
        text: '去重'
      }, {
        value: 'average',
        text: '平均'
      }, {
        value: 'cumsum',
        text: '累加'
      }]
    }, {
      type: 'number',
      key: 'InfoDefNumber',
      label: '展示数',
      tooltip: '默认显示类型数量',
      min: 1,
      max: 50,
      decimal: 0,
      initVal: card.InfoDefNumber || 5,
      forbid: !['line', 'bar'].includes(card.chartType),
      hidden: card.datatype !== 'statistics',
      required: true
    },
  ]
}