From 5df578ff69f6b02e821d59a8883bc75d78695a62 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期二, 10 十一月 2020 11:07:31 +0800
Subject: [PATCH] 2020-11-10

---
 src/templates/sharecomponent/fieldscomponent/index.jsx |   81 +++++++++++++++++++++++++++++++---------
 1 files changed, 62 insertions(+), 19 deletions(-)

diff --git a/src/templates/sharecomponent/fieldscomponent/index.jsx b/src/templates/sharecomponent/fieldscomponent/index.jsx
index 4ee3e20..2aefd5c 100644
--- a/src/templates/sharecomponent/fieldscomponent/index.jsx
+++ b/src/templates/sharecomponent/fieldscomponent/index.jsx
@@ -27,7 +27,7 @@
   queryField = () => {
     const { type, config, tableFields } = this.props
     // 鍒ゆ柇鏄惁宸查�夋嫨琛ㄥ悕
-    if (!config.tables || config.tables.length === 0) {
+    if (!tableFields || tableFields.length === 0) {
       notification.warning({
         top: 92,
         message: '璇烽�夋嫨琛ㄥ悕锛�',
@@ -54,6 +54,13 @@
       })
     } else if (type === 'columns') {
       // 娣诲姞鏄剧ず鍒楋紝瀛楁闆嗕腑瀛樺湪鏄剧ず鍒楀瓧娈碉紝浣跨敤鏄剧ず鍒楀璞℃浛鎹㈠瓧娈甸泦锛岃缃暟鎹被鍨�
+      config.columns.forEach(item => {
+        if (columns.has(item.field)) {
+          let _datatype = columns.get(item.field).datatype
+          columns.set(item.field, {...item, selected: true, datatype: _datatype})
+        }
+      })
+    } else if (type === 'fields') {
       config.columns.forEach(item => {
         if (columns.has(item.field)) {
           let _datatype = columns.get(item.field).datatype
@@ -138,11 +145,6 @@
             resourceType: '0',
             setAll: 'false',
             options: [],
-            dataSource: '',
-            linkField: '',
-            valueField: '',
-            valueText: '',
-            orderBy: '',
             orderType: 'asc',
             match: _match,
             display: 'dropdown'
@@ -180,6 +182,40 @@
             Width: 120
           }
 
+          if (item.type === 'number') {
+            newcard.decimal = item.decimal
+          } else {
+            newcard.fieldlength = item.length || 50
+          }
+
+          items.push(newcard)
+        }
+      })
+    } else if (type === 'fields') {
+      config.columns.forEach(item => {
+        if (columnsMap.has(item.field)) {
+          let cell = columnsMap.get(item.field)
+
+          if (cell.selected) {
+            items.push(item)
+          }
+          columnsMap.delete(item.field)
+        } else {
+          items.push(item)
+        }
+      })
+
+      let _columns = [...columnsMap.values()]
+
+      _columns.forEach(item => {
+        if (item.selected) {
+          let newcard = {
+            uuid: Utils.getuuid(),
+            label: item.label,
+            field: item.field,
+            datatype: item.type === 'number' ? 'Decimal(18,0)' : 'Nvarchar(50)'
+          }
+
           items.push(newcard)
         }
       })
@@ -189,12 +225,26 @@
 
     if (type === 'search') {
       _config = {...this.props.config, search: items}
+
+      this.props.updatefield(_config)
+
+      notification.success({
+        top: 92,
+        message: '鎿嶄綔鎴愬姛',
+        duration: 2
+      })
     } else if (type === 'columns') {
       _config = {...this.props.config, columns: items}
-    }
 
-    if (_config) {
       this.props.updatefield(_config)
+
+      notification.success({
+        top: 92,
+        message: '鎿嶄綔鎴愬姛',
+        duration: 2
+      })
+    } else if (type === 'fields') {
+      this.props.updatefield(items)
 
       notification.success({
         top: 92,
@@ -205,7 +255,7 @@
   }
 
   shouldComponentUpdate (nextProps, nextState) {
-    return !is(fromJS(this.props), fromJS(nextProps)) || !is(fromJS(this.state), fromJS(nextState))
+    return !is(fromJS(this.state), fromJS(nextState))
   }
 
   /**
@@ -221,16 +271,9 @@
     const { type } = this.props
     const { dict, fields } = this.state
 
-    let label = ''
-    if (type === 'search') {
-      label = dict['header.menu.search.add']
-    } else if (type === 'columns') {
-      label = dict['header.menu.column.add']
-    }
-
     return (
-      <div>
-        <Button type="primary" block onClick={this.queryField}>{label}</Button>
+      <div className="quickly-add">
+        <Button type="primary" block onClick={this.queryField}>{dict['model.batchAdd']}</Button>
         {/* 鏍规嵁瀛楁鍚嶆坊鍔犳樉绀哄垪鍙婃悳绱㈡潯浠� */}
         <Modal
           wrapClassName="model-table-fieldmanage-modal"
@@ -239,7 +282,7 @@
           width={'65vw'}
           maskClosable={false}
           style={{minWidth: '900px', maxWidth: '1200px'}}
-          cancelText={dict['header.close']}
+          cancelText={dict['model.close']}
           onOk={this.addFieldSubmit}
           onCancel={() => { // 鍙栨秷娣诲姞
             this.setState({

--
Gitblit v1.8.0