king
2020-07-31 5ae8e447c55f61508546e00559f54eb623a5c803
src/templates/comtableconfig/index.jsx
@@ -1145,19 +1145,42 @@
      })
    }
    let charterr = ''
    config.charts.forEach(chart => {
      if (!charterr && ['line', 'bar', 'pie'].includes(chart.chartType) && !chart.Xaxis) {
        charterr = '图表' + (chart.title ? '《' + chart.title + '》' : '') + '坐标轴未设置,不可启用!'
      }
    })
    let hasKey = false
    let chartcols = []
    config.columns.forEach(col => {
      if (col.field) {
        chartcols.push(col.field)
      }
      if (config.setting.primaryKey === col.field) {
        hasKey = true
      }
    })
    let chartError = ''
    config.charts && config.charts.forEach((chart, index) => {
      if (chartError) return
      if (chart.Hide === 'true') return
      if (!['line', 'bar', 'pie'].includes(chart.chartType)) return
      if (!chart.Xaxis) {
        chartError = `图表${chart.title ? '《' + chart.title + '》' : index + 1}坐标轴字段尚未设置,不可启用!`
      } else if (['line', 'bar'].includes(chart.chartType) && chart.datatype !== 'statistics' && (!chart.Yaxis || chart.Yaxis.length === 0)) { // query 查询数据
        chartError = `图表${chart.title ? '《' + chart.title + '》' : index + 1}坐标轴字段尚未设置,不可启用!`
      } else if (['line', 'bar'].includes(chart.chartType) && chart.datatype === 'statistics' && (!chart.InfoType || !chart.InfoValue)) { // statistics 统计数据
        chartError = `图表${chart.title ? '《' + chart.title + '》' : index + 1}坐标轴字段尚未设置,不可启用!`
      } else if (chart.chartType === 'pie' && !chart.Yaxis) {
        chartError = `图表${chart.title ? '《' + chart.title + '》' : index + 1}坐标轴字段尚未设置,不可启用!`
      } else if (!chartcols.includes(chart.Xaxis)) {
        chartError = `图表${chart.title ? '《' + chart.title + '》' : index + 1}坐标轴字段在显示列中不存在,不可启用!`
      } else if (chart.chartType === 'pie' && !chartcols.includes(chart.Yaxis)) {
        chartError = `图表${chart.title ? '《' + chart.title + '》' : index + 1}坐标轴字段在显示列中不存在,不可启用!`
      } else if (['line', 'bar'].includes(chart.chartType) && chart.datatype === 'statistics' && (!chartcols.includes(chart.InfoType) || !chartcols.includes(chart.InfoValue))) { // statistics 统计数据
        chartError = `图表${chart.title ? '《' + chart.title + '》' : index + 1}坐标轴字段在显示列中不存在,不可启用!`
      } else if (['line', 'bar'].includes(chart.chartType) && chart.datatype !== 'statistics' && chart.Yaxis.filter(yaxis => !chartcols.includes(yaxis)).length > 0) {
        chartError = `图表${chart.title ? '《' + chart.title + '》' : index + 1}坐标轴字段在显示列中不存在,不可启用!`
      }
    })
    if (config.setting.interType === 'inner' && !config.setting.innerFunc && config.setting.default !== 'false' && !config.setting.dataresource) {
      return '菜单尚未设置数据源,不可启用!'
@@ -1167,8 +1190,8 @@
      return '显示列中不存在主键字段,不可启用!'
    } else if (!tabinvalid) {
      return '菜单标签页设置错误(存在多行标签时,行标签不可为空)!'
    } else if (charterr) {
      return charterr
    } else if (chartError) {
      return chartError
    } else {
      return true
    }