From 7ea1c5f53702951fc4df60e969fc67ef5d7af4dd Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期二, 14 一月 2020 10:13:05 +0800
Subject: [PATCH] 2020-01-14

---
 src/templates/formtabconfig/index.jsx |  201 ++++++++++++++++++++++++++++++++++++--------------
 1 files changed, 145 insertions(+), 56 deletions(-)

diff --git a/src/templates/formtabconfig/index.jsx b/src/templates/formtabconfig/index.jsx
index c8e43f2..e8a15df 100644
--- a/src/templates/formtabconfig/index.jsx
+++ b/src/templates/formtabconfig/index.jsx
@@ -11,7 +11,7 @@
 import TabForm from './tabform'
 import TabDragElement from './tabdragelement'
 import Api from '@/api'
-import SearchForm from '@/templates/tableshare/searchform'
+import SearchForm from './modalform'
 import DragElement from './dragelement'
 import EditCard from '@/templates/tableshare/editcard'
 import VerifyCard from '@/templates/tableshare/verifycard'
@@ -52,7 +52,6 @@
     card: null,              // 缂栬緫鍏冪礌
     searchloading: false,    // 鎼滅储鏉′欢鍔犺浇涓�
     actionloading: false,    // 鎸夐挳鍔犺浇涓�
-    columnsloading: false,   // 鏄剧ず鍒楀姞杞戒腑
     tabloading: false,       // 鏍囩椤靛姞杞戒腑
     menuloading: false,      // 鑿滃崟淇濆瓨涓�
     menucloseloading: false, // 鑿滃崟鍏抽棴鏃讹紝閫夋嫨淇濆瓨
@@ -76,9 +75,6 @@
   UNSAFE_componentWillMount () {
     const { menu, editAction, config } = this.props
 
-    console.log(menu)
-    console.log(editAction)
-    console.log(config)
     let _config = ''
 
     if (!config) {
@@ -240,8 +236,8 @@
     }
   }
 
-  handleList = (type, list, card, groupId) => {
-    const { config } = this.state
+  handleList = (type, list, card, groupId, elementId) => {
+    let config = JSON.parse(JSON.stringify(this.state.config))
 
     if (type === 'tabs') { // 鏍囩椤佃皟鏁撮『搴忔垨娣诲姞鍏冪礌
       if (list.length > config[card.groupId].length) {
@@ -278,14 +274,77 @@
       } else {
         this.setState({config: {...config, action: list}})
       }
+    } else if (type === 'search') {
+      let _group = config.groups.filter(group => group.uuid === groupId)[0]
+      let isChange = list.length > _group.length
+      let isAdd = !elementId && list.length > _group.length
+
+      if (isAdd) {
+        _group.sublist = list.filter(item => !item.origin)
+        this.handleSearch(card)
+      } else if (elementId) {
+        // 淇敼宸叉湁鍏冪礌鐨勫垎缁�
+        let element = null
+        config.groups.forEach(item => {
+          item.sublist = item.sublist.filter(cell => {
+            if (cell.uuid !== elementId) {
+              return true
+            } else {
+              element = cell
+              return false
+            }
+          })
+        })
+        _group.sublist.push(element)
+      } else {
+        _group.sublist = list
+      }
+
+      config.groups = config.groups.map(item => {
+        if (item.uuid === _group.uuid) {
+          return _group
+        } else {
+          return item
+        }
+      })
+
+      if (isChange) {
+        this.setState({
+          searchloading: true,
+          config: config
+        }, () => {
+          // 鍒锋柊瀵瑰簲鐨勯厤缃俊鎭�
+          this.setState({
+            searchloading: false
+          })
+        })
+      } else {
+        this.setState({
+          config: config
+        })
+      }
     }
   }
 
   handleSearch = (card) => {
+    const { config } = this.state
+    let _inputfields = []
+
+    // 璁剧疆涓嬫媺鑿滃崟鍙叧鑱斿瓧娈�
+    config.groups.forEach(group => {
+      let sublist = group.sublist.filter(item => item.type === 'text' || item.type === 'number')
+      _inputfields = [..._inputfields, ...sublist]
+    })
+    
+    if (card.linkSubField && card.linkSubField.length > 0) {
+      let fields = _inputfields.map(item => item.field)
+      card.linkSubField = card.linkSubField.filter(item => fields.includes(item))
+    }
+
     this.setState({
       visible: true,
       formtemp: 'search',
-      modalTitle: '缂栬緫-鎼滅储鏉′欢',
+      modalTitle: '缂栬緫-琛ㄥ崟',
       card: card,
       formlist: [
         {
@@ -301,8 +360,6 @@
           key: 'field',
           label: this.state.dict['header.form.field'],
           initVal: card.field,
-          tooltip: '瀛楁鍚嶅彲浠ヤ娇鐢ㄩ�楀彿鍒嗛殧锛岃繘琛屽瀛楁缁煎悎鎼滅储锛屾敞锛氱患鍚堟悳绱粎鍦ㄦ枃鏈被鍨嬫椂鏈夋晥',
-          tooltipClass: 'middle',
           required: true,
           readonly: false
         },
@@ -316,6 +373,9 @@
             value: 'text',
             text: this.state.dict['header.form.text']
           }, {
+            value: 'number',
+            text: this.state.dict['header.form.number']
+          }, {
             value: 'select',
             text: this.state.dict['header.form.select']
           }, {
@@ -325,17 +385,20 @@
             value: 'link',
             text: this.state.dict['header.form.link']
           }, {
+            value: 'fileupload',
+            text: this.state.dict['header.form.fileupload']
+          }, {
             value: 'date',
             text: this.state.dict['header.form.dateday']
-          }, {
-            value: 'dateweek',
-            text: this.state.dict['header.form.dateweek']
           }, {
             value: 'datemonth',
             text: this.state.dict['header.form.datemonth']
           }, {
-            value: 'daterange',
-            text: this.state.dict['header.form.daterange']
+            value: 'datetime',
+            text: this.state.dict['header.form.datetime']
+          }, {
+            value: 'textarea',
+            text: this.state.dict['header.form.textarea']
           }]
         },
         {
@@ -434,41 +497,58 @@
           }]
         },
         {
-          type: 'select',
-          key: 'match',
-          label: this.state.dict['header.form.match'],
-          initVal: card.match || 'like',
-          required: true,
+          type: 'number',
+          key: 'decimal',
+          label: this.state.dict['header.form.decimal'],
+          initVal: card.decimal || 0,
+          required: false
+        },
+        {
+          type: 'number',
+          key: 'min',
+          label: '鏈�灏忓��',
+          initVal: card.min || '',
+          required: false
+        },
+        {
+          type: 'number',
+          key: 'max',
+          label: '鏈�澶у��',
+          initVal: card.max || '',
+          required: false
+        },
+        {
+          type: 'radio',
+          key: 'readonly',
+          label: this.state.dict['header.form.readonly'],
+          initVal: card.readonly || 'false',
           options: [{
-            value: 'like',
-            text: 'like'
+            value: 'true',
+            text: this.state.dict['header.form.true']
           }, {
-            value: 'equal',
-            text: 'equal'
-          }, {
-            value: 'greater',
-            text: '>'
-          }, {
-            value: 'less',
-            text: '<'
-          }, {
-            value: 'greaterequal',
-            text: '>='
+            value: 'false',
+            text: this.state.dict['header.form.false']
           }]
         },
         {
-          type: 'select',
-          key: 'display',
-          label: this.state.dict['header.form.display'],
-          initVal: card.display || 'dropdown',
-          required: true,
+          type: 'radio',
+          key: 'required',
+          label: this.state.dict['header.form.field.required'],
+          initVal: card.required || 'false',
           options: [{
-            value: 'dropdown',
-            text: this.state.dict['header.form.dropdown']
+            value: 'true',
+            text: this.state.dict['header.form.true']
           }, {
-            value: 'button',
-            text: this.state.dict['header.form.button']
+            value: 'false',
+            text: this.state.dict['header.form.false']
           }]
+        },
+        {
+          type: 'multiselect',
+          key: 'linkSubField',
+          label: this.state.dict['header.form.linkForm'],
+          initVal: card.linkSubField || [],
+          options: _inputfields
         }
       ]
     })
@@ -809,8 +889,9 @@
         })
       }
 
-      if (res.type !== 'tabs') {
-        _config[res.type] = _config[res.type].map(item => {
+      
+      if (res.type === 'action') {
+        _config.action = _config.action.map(item => {
           if (item.uuid === res.values.uuid) {
             isupdate = true
             return res.values
@@ -818,11 +899,25 @@
             return item
           }
         })
-        _config[res.type] = _config[res.type].filter(item => !item.origin)
+        _config.action = _config.action.filter(item => !item.origin)
   
         if (!isupdate) { // 鎿嶄綔涓嶆槸淇敼锛屾坊鍔犲厓绱犺嚦鍒楄〃
-          _config[res.type].push(res.values)
+          _config.action.push(res.values)
         }
+      } else if (res.type === 'search') {
+        _config.groups = _config.groups.map(item => {
+          item.sublist = item.sublist.map(cell => {
+            if (cell.uuid === res.values.uuid) {
+              return res.values
+            } else {
+              return cell
+            }
+          })
+          if (item.isDefault) {
+            item.sublist = item.sublist.filter(cell => !cell.origin)
+          }
+          return item
+        })
       } else { // 鏍囩椤电殑娣诲姞涓庝慨鏀�
         _config[res.values.groupId] = _config[res.values.groupId].map(item => {
           if (item.uuid === res.values.uuid) {
@@ -843,14 +938,12 @@
         config: _config,
         searchloading: true,
         actionloading: true,
-        columnsloading: true,
         tabloading: true,
         visible: false
       }, () => {
         this.setState({
           searchloading: false,
           actionloading: false,
-          columnsloading: false,
           tabloading: false
         })
       })
@@ -1564,13 +1657,11 @@
               ParentID: res.parentId
             },
             searchloading: true,
-            actionloading: true,
-            columnsloading: true
+            actionloading: true
           }, () => {
             this.setState({
               searchloading: false,
-              actionloading: false,
-              columnsloading: false
+              actionloading: false
             })
           })
 
@@ -2004,11 +2095,9 @@
       this.setState({
         config: {...config, setting: res},
         settingVisible: false,
-        columnsloading: true,
         tabloading: true
       }, () => {
         this.setState({
-          columnsloading: false,
           tabloading: false
         })
       })
@@ -2269,13 +2358,13 @@
                 />}
               </Panel>
               {/* 鎼滅储鏉′欢娣诲姞 */}
-              <Panel header={this.state.dict['header.menu.search']} key="1">
+              <Panel header={this.state.dict['header.menu.form']} key="1">
                 <div className="search-element">
                   {Source.searchItems.map((item, index) => {
                     return (<SourceElement key={index} content={item}/>)
                   })}
                 </div>
-                <Button type="primary" block onClick={() => this.queryField('search')}>{this.state.dict['header.menu.search.add']}</Button>
+                <Button type="primary" block onClick={() => this.queryField('search')}>{this.state.dict['header.menu.form.add']}</Button>
               </Panel>
               {/* 鎸夐挳娣诲姞 */}
               <Panel header={this.state.dict['header.menu.action']} key="2">

--
Gitblit v1.8.0