From d59f518f466274b2caeb2e01c10c92deafe7c93b Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期三, 09 二月 2022 11:48:29 +0800
Subject: [PATCH] 2022-02-09

---
 src/templates/sharecomponent/columncomponent/index.jsx |   63 +++++++++++++++++++++----------
 1 files changed, 42 insertions(+), 21 deletions(-)

diff --git a/src/templates/sharecomponent/columncomponent/index.jsx b/src/templates/sharecomponent/columncomponent/index.jsx
index c8061d3..2648a81 100644
--- a/src/templates/sharecomponent/columncomponent/index.jsx
+++ b/src/templates/sharecomponent/columncomponent/index.jsx
@@ -1,7 +1,8 @@
 import React, {Component} from 'react'
 import PropTypes from 'prop-types'
 import { is, fromJS } from 'immutable'
-import { Icon, Tooltip, Modal, notification, Switch, message } from 'antd'
+import { Tooltip, Modal, notification, Switch, message } from 'antd'
+import { QuestionCircleOutlined, CopyOutlined } from '@ant-design/icons'
 
 import zhCN from '@/locales/zh-CN/model.js'
 import enUS from '@/locales/en-US/model.js'
@@ -12,6 +13,7 @@
 import GridBtnForm from './gridbtnform'
 import DragElement from './dragcolumn'
 import MarkColumn from './markcolumn'
+import MKEmitter from '@/utils/events.js'
 import './index.scss'
 
 const { confirm } = Modal
@@ -26,7 +28,7 @@
   state = {
     dict: sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS,
     columnlist: null,    // 鏄剧ず鍒�
-    showField: false,    // 鏄剧ず鍒楀瓧娈�
+    showField: true,     // 鏄剧ず鍒楀瓧娈�
     modaltype: '',       // 妯℃�佹鎺у埗
     card: null           // 缂栬緫涓厓绱�
   }
@@ -38,18 +40,6 @@
     this.setState({
       columnlist: fromJS(this.props.config.columns).toJS()
     })
-  }
-
-  /**
-   * @description 鐩戝惉鍒版樉绀哄垪澶嶅埗鏃讹紝瑙﹀彂鏄剧ず鍒楃紪杈�
-   */
-  UNSAFE_componentWillReceiveProps (nextProps) {
-    const { config } = this.props
-    const { columnlist } = this.state
-
-    if (!is(fromJS(nextProps.config.columns), fromJS(config.columns)) && !is(fromJS(nextProps.config.columns), fromJS(columnlist))) {
-      this.setState({columnlist: fromJS(nextProps.config.columns).toJS()})
-    }
   }
 
   /**
@@ -186,7 +176,7 @@
         _columnlist = _columnlist.filter(item => !item.origin || item.uuid === res.uuid) // 鍘婚櫎鍒濆鍒�
         _columnlist = _columnlist.map(item => {
           if (item.uuid !== res.uuid && res.field && item.field) {
-            if (item.field === res.field) {
+            if (item.field.toLowerCase() === res.field.toLowerCase()) {
               fieldrepet = true
             }
           }
@@ -460,8 +450,38 @@
     })
   }
 
+  plusColumns = (MenuId, items) => {
+    const { config } = this.props
+    const { columnlist } = this.state
+
+    if (MenuId !== config.uuid) return
+
+    let list = [...columnlist, ...items]
+
+    if (list[0] && list[0].origin) {
+      list = list.filter(col => !col.origin)
+    }
+
+    this.setState({
+      columnlist: list
+    }, () => {
+      this.props.updatecolumn({...config, columns: list})
+    })
+  }
+
+  revert = () => {
+    this.setState({
+      columnlist: fromJS(this.props.config.columns).toJS()
+    })
+  }
+
   shouldComponentUpdate (nextProps, nextState) {
     return !is(fromJS(this.props), fromJS(nextProps)) || !is(fromJS(this.state), fromJS(nextState))
+  }
+
+  componentDidMount () {
+    MKEmitter.addListener('revert', this.revert)
+    MKEmitter.addListener('plusColumns', this.plusColumns)
   }
 
   /**
@@ -471,6 +491,8 @@
     this.setState = () => {
       return
     }
+    MKEmitter.removeListener('revert', this.revert)
+    MKEmitter.removeListener('plusColumns', this.plusColumns)
   }
 
   render() {
@@ -479,11 +501,11 @@
 
     return (
       <div className="model-table-column-list">
-        <Tooltip placement="bottomLeft" overlayClassName="middle" title={dict['model.tooltip.column.guide']}>
-          <Icon type="question-circle" />
+        <Tooltip placement="bottomLeft" overlayClassName="middle" title="鍦ㄥ乏渚у伐鍏锋爮銆婃樉绀哄垪銆嬩腑锛岄�夋嫨瀵瑰簲绫诲瀷鐨勬樉绀哄垪鎷栬嚦姝ゅ娣诲姞锛涙垨鐐瑰嚮銆婃坊鍔犳樉绀哄垪銆嬫寜閽壒閲忔坊鍔狅紝閫夋嫨鎵归噺娣诲姞鏃讹紝闇�鎻愬墠閫夋嫨浣跨敤琛ㄣ�傛敞锛氭坊鍔犲悎骞跺垪鏃讹紝闇�璁剧疆鍙�夊垪銆�">
+          <QuestionCircleOutlined style={{color: '#c49f47', position: 'relative', left: '-15px', top: '5px'}} />
         </Tooltip>
         {columnlist && columnlist.length > 0 ?
-          <Icon className="column-copy" title="copy" type="copy" onClick={this.copycolumn} /> : null
+          <CopyOutlined className="column-copy" title="copy" onClick={this.copycolumn} /> : null
         }
         <Switch checkedChildren={dict['model.switch.open']} unCheckedChildren={dict['model.switch.close']} defaultChecked={this.state.showField} onChange={this.onFieldChange} />
         <DragElement
@@ -496,11 +518,10 @@
           markMenu={this.markElement}
           handleGridBtn={this.handleGridBtn}
           showfield={this.state.showField}
-          placeholder={this.state.dict['header.form.column.placeholder']}
         />
         {/* 鏄剧ず鍒楃紪杈� */}
         <Modal
-          title={dict['header.modal.column.edit']}
+          title="鏄剧ず鍒�-缂栬緫"
           visible={modaltype === 'columns'}
           width={800}
           maskClosable={false}
@@ -537,7 +558,7 @@
         </Modal>
         {/* 鎿嶄綔鍒楃紪杈� */}
         <Modal
-          title={dict['header.modal.gridbtn.edit']}
+          title="鎿嶄綔鍒�-缂栬緫"
           visible={modaltype === 'gridbtn'}
           width={800}
           maskClosable={false}

--
Gitblit v1.8.0