From da64ab0923bf8817fc8599a6e37b953ce38f64c8 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期日, 27 八月 2023 18:37:36 +0800
Subject: [PATCH] 2023-08-27

---
 src/menu/components/chart/antv-G6/index.jsx |   65 ++++++++++++++------------------
 1 files changed, 28 insertions(+), 37 deletions(-)

diff --git a/src/menu/components/chart/antv-G6/index.jsx b/src/menu/components/chart/antv-G6/index.jsx
index 82d8bf3..658e69c 100644
--- a/src/menu/components/chart/antv-G6/index.jsx
+++ b/src/menu/components/chart/antv-G6/index.jsx
@@ -1,14 +1,14 @@
 import React, {Component} from 'react'
 import PropTypes from 'prop-types'
 import { is, fromJS } from 'immutable'
-import { Popover } from 'antd'
+import { Popover, message } from 'antd'
 import { ToolOutlined, DeleteOutlined, FontColorsOutlined } from '@ant-design/icons'
 import G6 from '@antv/g6'
 
 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 './index.scss'
 
 const { Util } = G6
@@ -17,7 +17,6 @@
 const ChartCompileForm = asyncIconComponent(() => import('./chartcompile'))
 const CopyComponent = asyncIconComponent(() => import('@/menu/components/share/copycomponent'))
 const NormalHeader = asyncComponent(() => import('@/menu/components/share/normalheader'))
-const UserComponent = asyncIconComponent(() => import('@/menu/components/share/usercomponent'))
 
 const MindData = [
   'Modeling Methods',
@@ -961,6 +960,7 @@
         width: card.width || 24,
         height: 400,
         subtype: card.subtype,
+        click: 'switch',
         name: card.name
       }
 
@@ -984,19 +984,6 @@
         search: [],
         action: [],
         plot: _plot,
-      }
-
-      if (card.config) {
-        let config = fromJS(card.config).toJS()
-
-        _card.plot = config.plot
-        _card.plot.name = card.name
-        _card.style = config.style
-        _card.headerStyle = config.headerStyle
-
-        _card.setting = config.setting
-        _card.columns = config.columns
-        _card.scripts = config.scripts
       }
 
       this.updateComponent(_card)
@@ -1137,7 +1124,7 @@
     const { card } = this.state
 
     if (card.plot.subtype === 'mindmap') {
-      this.ponitrender()
+      this.mindrender()
     } else if (card.plot.subtype === 'indentTree') {
       this.indentrender()
     } else if (card.plot.subtype === 'kapmap') {
@@ -1270,9 +1257,9 @@
   }
 
   /**
-   * @description 鏁g偣鍥�
+   * @description 鎬濈淮瀵煎浘
    */
-  ponitrender = () => {
+  mindrender = () => {
     const { card } = this.state
     const plot = card.plot
     const data = this.getdata()
@@ -1348,21 +1335,9 @@
     card.width = card.plot.width
     card.name = card.plot.name
     card.subtype = card.plot.subtype
-    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.errors = checkComponent(card)
 
     if (card.errors.length === 0) {
       card.$tables = getTables(card)
@@ -1370,6 +1345,15 @@
     
     if (!card.plot.valueField) {
       card.errors.push({ level: 0, detail: '鍥捐〃淇℃伅灏氭湭璁剧疆锛�'})
+    } else {
+      let columns = card.columns.map(c => c.field)
+      if (!columns.includes(card.plot.valueField)) {
+        card.errors.push({ level: 0, detail: '鍊煎瓧娈靛湪瀛楁闆嗕腑涓嶅瓨鍦�'})
+      } else if (!columns.includes(card.plot.labelField)) {
+        card.errors.push({ level: 0, detail: '鏂囨湰瀛楁鍦ㄥ瓧娈甸泦涓笉瀛樺湪'})
+      } else if (!columns.includes(card.plot.parentField)) {
+        card.errors.push({ level: 0, detail: '涓婄骇瀛楁鍦ㄥ瓧娈甸泦涓笉瀛樺湪'})
+      }
     }
 
     this.setState({
@@ -1407,13 +1391,12 @@
     let _style = resetStyle(card.style)
 
     return (
-      <div className="menu-scatter-chart-edit-box" style={_style} onClick={this.clickComponent} id={card.uuid}>
+      <div className="menu-g6-chart-edit-box" style={_style} onClick={this.clickComponent} id={card.uuid}>
         <Popover overlayClassName="mk-popover-control-wrap" mouseLeaveDelay={0.2} mouseEnterDelay={0.2} content={
           <div className="mk-popover-control">
             <ChartCompileForm config={card} plotchange={this.updateComponent}/>
             <CopyComponent type="antvG6" card={card}/>
             <FontColorsOutlined className="style" title="璋冩暣鏍峰紡" onClick={this.changeStyle}/>
-            <UserComponent config={card}/>
             <DeleteOutlined className="close" title="delete" onClick={() => this.props.deletecomponent(card.uuid)}/>
             <SettingComponent config={card} updateConfig={this.updateComponent}/>
           </div>
@@ -1421,10 +1404,18 @@
           <ToolOutlined/>
         </Popover>
         <NormalHeader config={card} updateComponent={this.updateComponent}/>
-        <div className="canvas" id={card.uuid + 'canvas'} ref={ref => this.wrap = ref}></div>
+        <div className="canvas" style={{minHeight: card.plot.height}} id={card.uuid + 'canvas'} ref={ref => this.wrap = ref}></div>
         <div className="component-name">
           <div className="center">
-            <div className="title">{card.name}</div>
+            <div className="title" onDoubleClick={() => {
+              let oInput = document.createElement('input')
+              oInput.value = 'anchor' + card.uuid
+              document.body.appendChild(oInput)
+              oInput.select()
+              document.execCommand('Copy')
+              document.body.removeChild(oInput)
+              message.success('澶嶅埗鎴愬姛銆�')
+            }}>{card.name}</div>
             <div className="content">
               {card.errors && card.errors.map((err, index) => {
                 if (err.level === 0) {

--
Gitblit v1.8.0