From 48a18736c461ad730bd264b0ac7b40b68a0e33a1 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期日, 28 六月 2020 20:30:20 +0800
Subject: [PATCH] 2020-06-28

---
 src/templates/sharecomponent/columncomponent/index.jsx |  142 +++++++++++++++++++++++++++++++++++++++++------
 1 files changed, 123 insertions(+), 19 deletions(-)

diff --git a/src/templates/sharecomponent/columncomponent/index.jsx b/src/templates/sharecomponent/columncomponent/index.jsx
index 10940fb..47ac705 100644
--- a/src/templates/sharecomponent/columncomponent/index.jsx
+++ b/src/templates/sharecomponent/columncomponent/index.jsx
@@ -13,11 +13,11 @@
 import ColspanForm from './colspanform'
 import GridBtnForm from './gridbtnform'
 import DragElement from './dragcolumn'
+import MarkColumn from './markcolumn'
 import './index.scss'
 
 const { confirm } = Modal
 
-// **鎮茶鑰呭線寰�姝g‘锛屼箰瑙傝�呭線寰�鎴愬姛
 class ColumnComponent extends Component {
   static propTpyes = {
     menu: PropTypes.object,          // 涓夌骇鑿滃崟淇℃伅
@@ -28,9 +28,9 @@
   }
 
   state = {
-    dict: (!localStorage.getItem('lang') || localStorage.getItem('lang') === 'zh-CN') ? zhCN : enUS,
+    dict: localStorage.getItem('lang') !== 'en-US' ? zhCN : enUS,
     columnlist: null,    // 鏄剧ず鍒�
-    loading: false,      // 鏌ヨ鏄剧ず鍒楀叧鑱旇彍鍗�
+    loading: false,      // 鏌ヨ鏄剧ず鍒楄仈鍔ㄨ彍鍗�
     showField: false,    // 鏄剧ず鍒楀瓧娈�
     modaltype: '',       // 妯℃�佹鎺у埗
     card: null           // 缂栬緫涓厓绱�
@@ -49,18 +49,22 @@
    * @description 鐩戝惉鍒版樉绀哄垪澶嶅埗鏃讹紝瑙﹀彂鏄剧ず鍒楃紪杈�
    */
   UNSAFE_componentWillReceiveProps (nextProps) {
+    const { config } = this.props
     const { columnlist } = this.state
 
     if (
       nextProps.pasteContent &&
-      columnlist.length === 0 &&
       nextProps.pasteContent.columns &&
       nextProps.pasteContent.copyType === 'columns' &&
       nextProps.pasteContent.columns.length > 0
     ) {
-      this.setState({columnlist: nextProps.pasteContent.columns})
-    } else if (!is(fromJS(nextProps.config.columns), fromJS(this.props.config.columns)) && !is(fromJS(nextProps.config.columns), fromJS(columnlist))) {
-      this.setState({columnlist: nextProps.config.columns})
+      if (columnlist.filter(col => !col.origin).length === 0) {
+        this.setState({columnlist: nextProps.pasteContent.columns}, () => {
+          this.props.updatecolumn({...config, columns: nextProps.pasteContent.columns})
+        })
+      }
+    } else if (!is(fromJS(nextProps.config.columns), fromJS(config.columns)) && !is(fromJS(nextProps.config.columns), fromJS(columnlist))) {
+      this.setState({columnlist: fromJS(nextProps.config.columns).toJS()})
     }
   }
 
@@ -74,8 +78,9 @@
       this.setState({columnlist: list})
       this.handleColumn(card)
     } else {
-      this.setState({columnlist: list})
-      this.props.updatecolumn({...config, search: list})
+      this.setState({columnlist: list}, ()=> {     
+        this.props.updatecolumn({...config, columns: list})
+      })
     }
   }
 
@@ -98,7 +103,7 @@
         let _param = {
           func: 'sPC_Get_FunMenu',
           ParentID: card.linkmenu[0],
-          systemType: options.systemType,
+          systemType: options.sysType,
           debug: 'Y'
         }
 
@@ -165,6 +170,16 @@
   }
 
   /**
+   * @description 璁剧疆鏍囧織
+   */
+  markElement = (card) => {
+    this.setState({
+      modaltype: 'mark',
+      card: card
+    })
+  }
+
+  /**
    * @description 鎿嶄綔鍒楃紪杈�
    */
   handleGridBtn = () => {
@@ -206,7 +221,7 @@
    */
   handleSubmit = () => {
     const { config } = this.props
-    const { modaltype } = this.state
+    const { modaltype, card } = this.state
 
     let _columnlist = fromJS(this.state.columnlist).toJS()
 
@@ -249,11 +264,30 @@
           return
         }
 
+        if (!card.focus && (card.type !== res.type || (res.field && card.field !== res.field))) {
+          let refers = []
+          _columnlist.forEach(column => {
+            if (column.marks && column.marks.filter(mark => mark.field === card.field || mark.contrastField === card.field).length > 0) {
+              refers.push(column.label)
+            }
+          })
+
+          if (refers.length > 0) {
+            notification.warning({
+              top: 92,
+              message: '鏄剧ず鍒椼��' + refers.join('銆�') + '銆嬫爣璁颁腑鍚湁璇ュ瓧娈碉紝姝ゆ淇敼浼氬鑷存爣璁板け鏁堬紝璇蜂慨鏀广��' + refers.join('銆�') + '銆嬫爣璁拌缃紒',
+              duration: 5
+            })
+          }
+        }
+
         this.setState({
+          card: null,
           columnlist: _columnlist,
           modaltype: ''
+        }, ()=> {
+          this.props.updatecolumn({...config, columns: _columnlist})
         })
-        this.props.updatecolumn({...config, columns: _columnlist})
       })
     } else if (modaltype === 'gridbtn') {
       this.gridBtnFormRef.handleConfirm().then(res => {
@@ -277,16 +311,34 @@
     confirm({
       content: dict['model.confirm'] + dict['model.delete'] + ` - ${card.label} 锛焋,
       okText: dict['model.confirm'],
-      cancelText: this.state.dict['header.cancel'],
+      cancelText: this.state.dict['model.cancel'],
       onOk() {
         let _columnlist = fromJS(_this.state.columnlist).toJS()
 
         _columnlist = _columnlist.filter(item => item.uuid !== card.uuid)
 
+        if (card.field) {
+          let refers = []
+          _columnlist.forEach(column => {
+            if (column.marks && column.marks.filter(mark => mark.field === card.field || mark.contrastField === card.field).length > 0) {
+              refers.push(column.label)
+            }
+          })
+
+          if (refers.length > 0) {
+            notification.warning({
+              top: 92,
+              message: '鏄剧ず鍒椼��' + refers.join('銆�') + '銆嬫爣璁颁腑鍚湁璇ュ瓧娈碉紝鍒犻櫎浼氬鑷存爣璁板け鏁堬紝璇蜂慨鏀广��' + refers.join('銆�') + '銆嬫爣璁拌缃紒',
+              duration: 5
+            })
+          }
+        }
+
         _this.setState({
           columnlist: _columnlist
+        }, ()=> {
+          _this.props.updatecolumn({...config, columns: _columnlist})
         })
-        _this.props.updatecolumn({...config, columns: _columnlist})
       },
       onCancel() {}
     })
@@ -350,6 +402,37 @@
     })
   }
 
+  markSubmit = () => {
+    const { config } = this.props
+    const { card } = this.state
+    let _columnlist = fromJS(this.state.columnlist).toJS()
+    let _marks = this.refs.markRef.state.marks
+
+    if (_marks.length === 0) {
+      _marks = ''
+    }
+
+    _columnlist = _columnlist.map(item => {
+      if (item.uuid === card.uuid) {
+        item.marks = _marks
+      }
+        
+      return item
+    })
+
+    this.setState({
+      card: null,
+      columnlist: _columnlist,
+      modaltype: ''
+    }, ()=> { 
+      this.props.updatecolumn({...config, columns: _columnlist})
+    })
+  }
+
+  shouldComponentUpdate (nextProps, nextState) {
+    return !is(fromJS(this.props), fromJS(nextProps)) || !is(fromJS(this.state), fromJS(nextState))
+  }
+
   /**
    * @description 缁勪欢閿�姣侊紝娓呴櫎state鏇存柊
    */
@@ -371,7 +454,7 @@
         {columnlist && columnlist.length > 0 ?
           <Icon className="column-copy" title="copy" type="copy" onClick={this.copycolumn} /> : null
         }
-        <Switch checkedChildren="寮�" unCheckedChildren="鍏�" defaultChecked={this.state.showField} onChange={this.onFieldChange} />
+        <Switch checkedChildren={dict['model.switch.open']} unCheckedChildren={dict['model.switch.close']} defaultChecked={this.state.showField} onChange={this.onFieldChange} />
         <DragElement
           list={columnlist}
           setting={config.setting}
@@ -379,6 +462,7 @@
           handleList={this.handleList}
           handleMenu={this.handleColumn}
           deleteMenu={this.deleteElement}
+          markMenu={this.markElement}
           handleGridBtn={this.handleGridBtn}
           showfield={this.state.showField}
           placeholder={this.state.dict['header.form.column.placeholder']}
@@ -387,7 +471,7 @@
         <Modal
           title={dict['header.modal.column.edit']}
           visible={modaltype === 'columns'}
-          width={750}
+          width={800}
           maskClosable={false}
           onOk={this.handleSubmit}
           onCancel={this.editModalCancel}
@@ -404,9 +488,9 @@
         </Modal>
         {/* 鍚堝苟鍒楃紪杈� */}
         <Modal
-          title={dict['header.modal.colspan.edit']}
+          title={dict['model.modal.colspan'] + '-' + dict['model.edit']}
           visible={modaltype === 'colspan'}
-          width={750}
+          width={800}
           maskClosable={false}
           onOk={this.handleSubmit}
           onCancel={this.editModalCancel}
@@ -424,7 +508,7 @@
         <Modal
           title={dict['header.modal.gridbtn.edit']}
           visible={modaltype === 'gridbtn'}
-          width={700}
+          width={800}
           maskClosable={false}
           onOk={this.handleSubmit}
           onCancel={this.editModalCancel}
@@ -437,6 +521,26 @@
             wrappedComponentRef={(inst) => this.gridBtnFormRef = inst}
           />
         </Modal>
+        {/* 鎸夐挳浣跨敤绯荤粺瀛樺偍杩囩▼鏃讹紝楠岃瘉淇℃伅妯℃�佹 */}
+        <Modal
+          wrapClassName="model-table-column-mark-modal"
+          title={'鏍囪璁剧疆'}
+          visible={modaltype === 'mark'}
+          width={'75vw'}
+          maskClosable={false}
+          style={{minWidth: '900px', maxWidth: '1200px'}}
+          okText={dict['model.submit']}
+          onOk={this.markSubmit}
+          onCancel={() => { this.setState({ modaltype: '' }) }}
+          destroyOnClose
+        >
+          <MarkColumn
+            ref="markRef"
+            card={card}
+            dict={dict}
+            columns={columnlist}
+          />
+        </Modal>
         {this.state.loading && <Spin size="large" />}
       </div>
     )

--
Gitblit v1.8.0