king
2023-06-14 08cce3334a2dc81d690b518136b0aaea64e48b0b
src/menu/components/chart/antv-bar/index.jsx
@@ -9,7 +9,7 @@
import MKEmitter from '@/utils/events.js'
import asyncComponent from '@/utils/asyncComponent'
import asyncIconComponent from '@/utils/asyncIconComponent'
import { resetStyle, getTables, getHeight } from '@/utils/utils-custom.js'
import { resetStyle, getTables, getHeight, checkComponent } from '@/utils/utils-custom.js'
import Utils from '@/utils/utils.js'
import { chartColors } from '@/utils/option.js'
import './index.scss'
@@ -1220,48 +1220,37 @@
    card.width = card.plot.width
    card.name = card.plot.name
    card.errors = []
    let columns = card.columns.map(c => c.field)
    if (card.setting.interType === 'system' && card.setting.execute !== 'false' && !card.setting.dataresource) {
      card.errors.push({ level: 0, detail: '未设置数据源!'})
    } else if (card.setting.interType === 'system' && card.setting.execute === 'false' && card.scripts.filter(script => script.status !== 'false').length === 0) {
      card.errors.push({ level: 0, detail: '数据源中无可用脚本!'})
    } else if (!card.setting.primaryKey) {
      card.errors.push({ level: 0, detail: '未设置主键!'})
    } else if (!columns.includes(card.setting.primaryKey)) {
      card.errors.push({ level: 0, detail: '主键已失效!'})
    } else if (!card.setting.supModule) {
      card.errors.push({ level: 0, detail: '未设置上级组件!'})
    }
    card.$c_ds = true
    card.$c_ac = this.state.appType !== 'mob'
    card.errors = checkComponent(card)
    if (card.errors.length === 0) {
      card.$tables = getTables(card)
    }
    let columns = card.columns.map(c => c.field)
    if (!card.plot.Xaxis) {
      card.errors.push({ level: 0, detail: '坐标轴尚未设置!'})
    } else if (card.plot.datatype === 'query') {
      if (!columns.includes(card.plot.Xaxis)) {
        card.errors.push({ level: 1, detail: 'X轴在字段集中不存在'})
        card.errors.push({ level: 0, detail: 'X轴在字段集中不存在'})
      }
      if (card.plot.Yaxis) {
        card.plot.Yaxis.forEach(m => {
          if (!columns.includes(m)) {
            card.errors.push({ level: 1, detail: `Y轴中字段“${m}”已失效`})
            card.errors.push({ level: 0, detail: `Y轴中字段“${m}”已失效`})
          }
        })
      }
    } else if (card.plot.datatype === 'statistics') {
      if (!columns.includes(card.plot.Xaxis)) {
        card.errors.push({ level: 1, detail: 'X轴在字段集中不存在'})
      }
      if (!columns.includes(card.plot.InfoType)) {
        card.errors.push({ level: 1, detail: '图表中统计类型字段已失效'})
      }
      if (!columns.includes(card.plot.InfoValue)) {
        card.errors.push({ level: 1, detail: '图表中统计值字段已失效'})
        card.errors.push({ level: 0, detail: 'X轴在字段集中不存在'})
      } else if (!columns.includes(card.plot.InfoType)) {
        card.errors.push({ level: 0, detail: '图表中统计类型字段已失效'})
      } else if (!columns.includes(card.plot.InfoValue)) {
        card.errors.push({ level: 0, detail: '图表中统计值字段已失效'})
      }
    }
@@ -1377,7 +1366,7 @@
          <ToolOutlined/>
        </Popover>
        <NormalHeader config={card} updateComponent={this.updateComponent}/>
        <div className="canvas" id={card.uuid + 'canvas'}></div>
        <div className="canvas" style={{minHeight: card.plot.height}} id={card.uuid + 'canvas'}></div>
        {appType !== 'mob' ? <ActionComponent
          config={card}
          updateaction={this.updateComponent}
@@ -1386,7 +1375,7 @@
          <div className="center">
            <div className="title" onDoubleClick={() => {
              let oInput = document.createElement('input')
              oInput.value = card.uuid
              oInput.value = 'anchor' + card.uuid
              document.body.appendChild(oInput)
              oInput.select()
              document.execCommand('Copy')