From c41b93d4c5e2146a1d1568887fb8ce1e3144d7fb Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期二, 31 十二月 2019 18:24:36 +0800
Subject: [PATCH] 2019-12-31

---
 src/tabviews/tableshare/mutilform/index.jsx    |   34 +++++++++++
 src/tabviews/tableshare/topSearch/index.jsx    |   56 +++++++++++++++---
 src/templates/comtableconfig/index.jsx         |    3 
 src/templates/subtableconfig/index.jsx         |    2 
 src/templates/modalconfig/modalform/index.jsx  |   36 ++++++++----
 src/templates/modalconfig/index.jsx            |    5 +
 src/tabviews/subtable/index.jsx                |    2 
 src/templates/tableshare/searchform/index.jsx  |    6 +-
 src/tabviews/subtabtable/index.jsx             |    2 
 src/tabviews/commontable/index.jsx             |    6 +-
 src/templates/modalconfig/dragelement/card.jsx |    4 
 src/tabviews/tableshare/topSearch/index.scss   |    7 ++
 src/utils/utils.js                             |   14 ++++
 13 files changed, 139 insertions(+), 38 deletions(-)

diff --git a/src/tabviews/commontable/index.jsx b/src/tabviews/commontable/index.jsx
index 4c6607a..b15c39e 100644
--- a/src/tabviews/commontable/index.jsx
+++ b/src/tabviews/commontable/index.jsx
@@ -139,12 +139,11 @@
 
       let _actions = config.action.filter(item => item.position === 'toolbar') // 杩囨护宸ュ叿鏍忔寜閽紙鏈粡杩囨潈闄愯繃婊わ級
       let _tab = config.tabs.filter(tab => tab.supMenu === 'mainTable')        // 妫�鏌ユ槸鍚︽湁涓庝富琛ㄥ叧鑱旂殑瀛愯〃
-
       let supmenus = {}
       config.tabgroups.forEach(group => {
         if (config[group] && config[group].length > 0) {
           config[group] = config[group].map(tab => {
-            if (tab.subtabs.length > 0) {
+            if (tab.subtabs && tab.subtabs.length > 0) {
               tab.subtabs.forEach(id => {
                 supmenus[id] = tab.uuid
               })
@@ -198,7 +197,7 @@
     let searchlist = JSON.parse(JSON.stringify(this.state.searchlist))
     let deffers = []
     searchlist.forEach(item => {
-      if (item.type !== 'select' && item.type !== 'link') return
+      if (item.type !== 'multiselect' && item.type !== 'select' && item.type !== 'link') return
       if (item.setAll === 'true') {
         item.options.unshift({
           key: Utils.getuuid(),
@@ -272,6 +271,7 @@
           })
         }
       })
+
       this.setState({searchlist})
     })
   }
diff --git a/src/tabviews/subtable/index.jsx b/src/tabviews/subtable/index.jsx
index 3f28a70..e861d00 100644
--- a/src/tabviews/subtable/index.jsx
+++ b/src/tabviews/subtable/index.jsx
@@ -180,7 +180,7 @@
     let searchlist = JSON.parse(JSON.stringify(this.state.searchlist))
     let deffers = []
     searchlist.forEach(item => {
-      if (item.type !== 'select' && item.type !== 'link') return
+      if (item.type !== 'multiselect' && item.type !== 'select' && item.type !== 'link') return
       if (item.setAll === 'true') {
         item.options.unshift({
           key: Utils.getuuid(),
diff --git a/src/tabviews/subtabtable/index.jsx b/src/tabviews/subtabtable/index.jsx
index 466ead3..a0b3714 100644
--- a/src/tabviews/subtabtable/index.jsx
+++ b/src/tabviews/subtabtable/index.jsx
@@ -162,7 +162,7 @@
     let searchlist = JSON.parse(JSON.stringify(this.state.searchlist))
     let deffers = []
     searchlist.forEach(item => {
-      if (item.type !== 'select' && item.type !== 'link') return
+      if (item.type !== 'multiselect' && item.type !== 'select' && item.type !== 'link') return
       if (item.setAll === 'true') {
         item.options.unshift({
           key: Utils.getuuid(),
diff --git a/src/tabviews/tableshare/mutilform/index.jsx b/src/tabviews/tableshare/mutilform/index.jsx
index 08adc5d..ca13bc6 100644
--- a/src/tabviews/tableshare/mutilform/index.jsx
+++ b/src/tabviews/tableshare/mutilform/index.jsx
@@ -272,6 +272,33 @@
             </Form.Item>
           </Col>
         )
+      } else if (item.type === 'multiselect') { // 澶氶��
+        let _initval = item.initval ? item.initval.split(',').filter(Boolean) : []
+        fields.push(
+          <Col span={24 / cols} key={index}>
+            <Form.Item label={item.label}>
+              {getFieldDecorator(item.field, {
+                initialValue: _initval,
+                rules: [
+                  {
+                    required: item.required === 'true',
+                    message: this.props.dict['form.required.select'] + item.label + '!'
+                  }
+                ]
+              })(
+                <Select
+                  showSearch
+                  mode="multiple"
+                  filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0}
+                >
+                  {item.options.map(option =>
+                    <Select.Option id={option.key} title={option.Text} key={option.key} value={option.Value}>{option.Text}</Select.Option>
+                  )}
+                </Select>
+              )}
+            </Form.Item>
+          </Col>
+        )
       } else if (item.type === 'date') { // 鏃堕棿鎼滅储
         let _initval = this.props.data ? this.props.data[item.field] : ''
         if (_initval) {
@@ -398,6 +425,13 @@
                 key: key,
                 value: values[key]
               })
+            } else if (this.state.datatype[key] === 'multiselect') {
+              search.push({
+                type: this.state.datatype[key],
+                readonly: this.state.readtype[key],
+                key: key,
+                value: values[key] ? values[key].join(',') : ''
+              })
             } else {
               search.push({
                 type: this.state.datatype[key],
diff --git a/src/tabviews/tableshare/topSearch/index.jsx b/src/tabviews/tableshare/topSearch/index.jsx
index 9c59994..6d98e20 100644
--- a/src/tabviews/tableshare/topSearch/index.jsx
+++ b/src/tabviews/tableshare/topSearch/index.jsx
@@ -2,6 +2,7 @@
 import PropTypes from 'prop-types'
 import { Form, Row, Col, Input, Button, Select, DatePicker, notification } from 'antd'
 import moment from 'moment'
+import Utils from '@/utils/utils.js'
 import './index.scss'
 
 const {MonthPicker, WeekPicker, RangePicker} = DatePicker
@@ -13,9 +14,10 @@
   }
 
   state = {
-    match: null, // 鎼滅储鏉′欢鍖归厤瑙勫垯
+    match: null,            // 鎼滅储鏉′欢鍖归厤瑙勫垯
     style: null,
-    searchlist: null
+    searchlist: null,
+    formId: Utils.getuuid()
   }
 
   UNSAFE_componentWillMount () {
@@ -72,8 +74,8 @@
     })
   }
 
-  UNSAFE_componentWillReceiveProps() {
-    let searchlist = JSON.parse(JSON.stringify(this.props.searchlist))
+  UNSAFE_componentWillReceiveProps(nextProps) {
+    let searchlist = JSON.parse(JSON.stringify(nextProps.searchlist))
     let _list = []
     let fieldMap = new Map()
 
@@ -170,7 +172,10 @@
   getFields() {
     const { getFieldDecorator } = this.props.form
     const fields = []
+
     this.state.searchlist.forEach((item, index) => {
+      if (item.hidden) return
+
       if (item.type === 'text') { // 鏂囨湰鎼滅储
         fields.push(
           <Col span={6} key={index}>
@@ -186,12 +191,33 @@
               {getFieldDecorator(item.field, {initialValue: item.initval })(
                 <Select
                   showSearch
-                  // onChange={this.searchChange}
                   onChange={(value) => {this.selectChange(item, value)}}
                   filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0}
+                  getPopupContainer={() => document.getElementById(this.state.formId)}
                 >
-                  {item.options.map(option =>
-                    <Select.Option id={option.key} title={option.Text} key={option.key} value={option.Value}>{option.Text}</Select.Option>
+                  {item.options.map((option, i) =>
+                    <Select.Option id={`${i}`} title={option.Text} key={`${i}`} value={option.Value}>{option.Text}</Select.Option>
+                  )}
+                </Select>
+              )}
+            </Form.Item>
+          </Col>
+        )
+      } else if (item.type === 'multiselect') { // 涓嬫媺澶氶��
+        let _initval = item.initval ? item.initval.split(',').filter(Boolean) : []
+        fields.push(
+          <Col span={6} key={index}>
+            <Form.Item label={item.label}>
+              {getFieldDecorator(item.field, {initialValue: _initval })(
+                <Select
+                  showSearch
+                  mode="multiple"
+                  // onChange={(value) => {this.selectChange(item, value)}}
+                  filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0}
+                  getPopupContainer={() => document.getElementById(this.state.formId)}
+                >
+                  {item.options.map((option, i) =>
+                    <Select.Option id={`${i}`} title={option.Text} key={`${i}`} value={option.Value}>{option.Text}</Select.Option>
                   )}
                 </Select>
               )}
@@ -203,7 +229,7 @@
           <Col span={6} key={index}>
             <Form.Item label={item.label}>
               {getFieldDecorator(item.field, {initialValue: item.initval ? moment().subtract(item.initval, 'days') : null })(
-                <DatePicker onChange={this.searchChange} />
+                <DatePicker onChange={this.searchChange} getCalendarContainer={() => document.getElementById(this.state.formId)} />
               )}
             </Form.Item>
           </Col>
@@ -213,7 +239,7 @@
           <Col span={6} key={index}>
             <Form.Item label={item.label}>
               {getFieldDecorator(item.field, {initialValue: item.initval ? moment().subtract(item.initval, 'month') : null })(
-                <MonthPicker onChange={this.searchChange} />
+                <MonthPicker onChange={this.searchChange} getCalendarContainer={() => document.getElementById(this.state.formId)} />
               )}
             </Form.Item>
           </Col>
@@ -223,7 +249,7 @@
           <Col span={6} key={index}>
             <Form.Item label={item.label}>
               {getFieldDecorator(item.field, {initialValue: item.initval ? moment().subtract(item.initval * 7, 'days') : null })(
-                <WeekPicker onChange={this.searchChange} />
+                <WeekPicker onChange={this.searchChange} getCalendarContainer={() => document.getElementById(this.state.formId)} />
               )}
             </Form.Item>
           </Col>
@@ -251,6 +277,7 @@
                   placeholder={['寮�濮嬫棩鏈�', '缁撴潫鏃ユ湡']}
                   renderExtraFooter={() => 'extra footer'}
                   onChange={this.searchChange}
+                  getCalendarContainer={() => document.getElementById(this.state.formId)}
                 />
               )}
             </Form.Item>
@@ -361,6 +388,13 @@
           value: _value,
           match: this.state.match[key]
         })
+      } else if (this.state.style[key] === 'multiselect') {
+        search.push({
+          type: this.state.style[key],
+          key: key.replace(/@tail@$/, ''),
+          value: values[key],
+          match: this.state.match[key]
+        })
       } else {
         search.push({
           type: this.state.style[key],
@@ -375,7 +409,7 @@
 
   render() {
     return (
-      <Form className="ant-advanced-search-form top-search" onSubmit={this.handleSearch}>
+      <Form className="ant-advanced-search-form top-search" id={this.state.formId} onSubmit={this.handleSearch}>
         <Row gutter={24}>{this.getFields()}</Row>
       </Form>
     )
diff --git a/src/tabviews/tableshare/topSearch/index.scss b/src/tabviews/tableshare/topSearch/index.scss
index 096775d..8854945 100644
--- a/src/tabviews/tableshare/topSearch/index.scss
+++ b/src/tabviews/tableshare/topSearch/index.scss
@@ -7,6 +7,7 @@
   }
   .ant-form-item-control-wrapper {
     flex: 1;
+    width: calc(100% - 100px);
   }
   .ant-form-item-label {
     width: 100px;
@@ -16,4 +17,10 @@
     padding: 4px 20px 4px 5px;
     font-size: 13px;
   }
+  .ant-select-dropdown {
+    z-index: 10 !important;
+  }
+  .ant-calendar-picker-container {
+    z-index: 10 !important;
+  }
 }
\ No newline at end of file
diff --git a/src/templates/comtableconfig/index.jsx b/src/templates/comtableconfig/index.jsx
index cde6d93..2d71a5c 100644
--- a/src/templates/comtableconfig/index.jsx
+++ b/src/templates/comtableconfig/index.jsx
@@ -1177,7 +1177,7 @@
         let isupdate = false
 
         if (res.type === 'search') {
-          if ((res.values.type === 'select' || res.values.type === 'link') && res.values.resourceType === '1') {
+          if ((res.values.type === 'multiselect' || res.values.type === 'select' || res.values.type === 'link') && res.values.resourceType === '1') {
             let _datasource = res.values.dataSource
 
             if (/\s/.test(_datasource)) {
@@ -2562,7 +2562,6 @@
    * @description 璁剧疆鍙厤缃寜閽�
    */
   setSubConfig = (btn, type) => {
-    console.log(btn)
     const { menu } = this.props
     const { config, originMenu } = this.state
 
diff --git a/src/templates/modalconfig/dragelement/card.jsx b/src/templates/modalconfig/dragelement/card.jsx
index 9546c1e..297921d 100644
--- a/src/templates/modalconfig/dragelement/card.jsx
+++ b/src/templates/modalconfig/dragelement/card.jsx
@@ -42,7 +42,7 @@
   }
 
   let selectval = ''
-  if (card.type === 'select' || card.type === 'link') {
+  if (card.type === 'multiselect' || card.type === 'select' || card.type === 'link') {
     if (card.initval) {
       let _option = card.options.filter(option => option.Value === card.initval)[0]
       if (_option) {
@@ -69,7 +69,7 @@
             {card.type === 'number' &&
               <InputNumber defaultValue={card.initval} precision={card.decimal} />
             }
-            {(card.type === 'select' || card.type === 'link') &&
+            {(card.type === 'multiselect' || card.type === 'select' || card.type === 'link') &&
               <Select defaultValue={selectval}></Select>
             }
             {card.type === 'date' &&
diff --git a/src/templates/modalconfig/index.jsx b/src/templates/modalconfig/index.jsx
index 732e7f8..e4299c5 100644
--- a/src/templates/modalconfig/index.jsx
+++ b/src/templates/modalconfig/index.jsx
@@ -350,6 +350,9 @@
             value: 'select',
             text: this.state.dict['header.form.select']
           }, {
+            value: 'multiselect',
+            text: this.state.dict['header.form.multiselect']
+          }, {
             value: 'link',
             text: this.state.dict['header.form.link']
           }, {
@@ -505,7 +508,7 @@
     this.formRef.handleConfirm().then(res => {
       let _config = JSON.parse(JSON.stringify(this.state.config))
 
-      if ((res.type === 'select' || res.type === 'link') && res.resourceType === '1') {
+      if ((res.type === 'multiselect' || res.type === 'select' || res.type === 'link') && res.resourceType === '1') {
         let _datasource = res.dataSource
 
         if (/\s/.test(_datasource)) {
diff --git a/src/templates/modalconfig/modalform/index.jsx b/src/templates/modalconfig/modalform/index.jsx
index 5a76b5f..6af5adc 100644
--- a/src/templates/modalconfig/modalform/index.jsx
+++ b/src/templates/modalconfig/modalform/index.jsx
@@ -27,12 +27,16 @@
     let resourceType = formlist.filter(cell => cell.key === 'resourceType')[0].initVal
     let _options = ['label', 'field', 'initval', 'type', 'readonly', 'required'] // 榛樿鏄剧ず椤�
 
-    if ((type === 'select' || type === 'link') && resourceType === '0') { // 閫夋嫨绫诲瀷銆佽嚜瀹氫箟璧勬簮
-      _options = [..._options, 'resourceType', 'setAll', 'options']
-    } else if ((type === 'select' || type === 'link') && resourceType === '1') { // 閫夋嫨绫诲瀷銆佹暟鎹簮
-      _options = [..._options, 'resourceType', 'setAll', 'dataSource', 'valueField', 'valueText', 'orderBy', 'orderType']
+    if ((type === 'multiselect' || type === 'select' || type === 'link') && resourceType === '0') { // 閫夋嫨绫诲瀷銆佽嚜瀹氫箟璧勬簮
+      _options = [..._options, 'resourceType', 'options']
+    } else if ((type === 'multiselect' || type === 'select' || type === 'link') && resourceType === '1') { // 閫夋嫨绫诲瀷銆佹暟鎹簮
+      _options = [..._options, 'resourceType', 'dataSource', 'valueField', 'valueText', 'orderBy', 'orderType']
     } else if (type === 'number') {
       _options = [..._options, 'decimal']
+    }
+
+    if (type === 'select' || type === 'link') {
+      _options.push('setAll')
     }
 
     if (type === 'link') { // 鍏宠仈绫诲瀷銆佸鍔犲叧鑱斿瓧娈�
@@ -73,12 +77,16 @@
     if (key === 'type') {
       let _options = ['label', 'field', 'initval', 'type', 'readonly', 'required']
 
-      if ((value === 'select' || value === 'link') && this.state.resourceType === '0') { // 閫夋嫨绫诲瀷銆佽嚜瀹氫箟璧勬簮
-        _options = [..._options, 'resourceType', 'setAll', 'options']
-      } else if ((value === 'select' || value === 'link') && this.state.resourceType === '1') { // 閫夋嫨绫诲瀷銆佹暟鎹簮
-        _options = [..._options, 'resourceType', 'setAll', 'dataSource', 'valueField', 'valueText', 'orderBy', 'orderType']
+      if ((value === 'multiselect' || value === 'select' || value === 'link') && this.state.resourceType === '0') { // 閫夋嫨绫诲瀷銆佽嚜瀹氫箟璧勬簮
+        _options = [..._options, 'resourceType', 'options']
+      } else if ((value === 'multiselect' || value === 'select' || value === 'link') && this.state.resourceType === '1') { // 閫夋嫨绫诲瀷銆佹暟鎹簮
+        _options = [..._options, 'resourceType', 'dataSource', 'valueField', 'valueText', 'orderBy', 'orderType']
       } else if (value === 'number') {
         _options = [..._options, 'decimal']
+      }
+
+      if (value === 'select' || value === 'link') {
+        _options.push('setAll')
       }
       
       if (value === 'link') {
@@ -122,11 +130,15 @@
     const { openType } = this.state
     let value = e.target.value
     if (key === 'resourceType') {
-      let _options = ['label', 'field', 'initval', 'type', 'resourceType', 'setAll', 'readonly', 'required']
+      let _options = ['label', 'field', 'initval', 'type', 'resourceType', 'readonly', 'required']
       if (value === '0') {
         _options = [..._options, 'options']
       } else if (value === '1') {
         _options = [..._options, 'dataSource', 'valueField', 'valueText', 'orderBy', 'orderType']
+      }
+
+      if (openType === 'select' || openType === 'link') {
+        _options.push('setAll')
       }
       
       if (openType === 'link') {
@@ -292,11 +304,11 @@
           values.id = this.props.card.id
           values.uuid = this.props.card.uuid
           // 涓嬫媺鑿滃崟鎴栧叧鑱旇彍鍗�
-          if ((values.type === 'select' || values.type === 'link') && values.resourceType === '0') {
+          if ((values.type === 'multiselect' || values.type === 'select' || values.type === 'link') && values.resourceType === '0') {
             values.options = this.refs.editTable.state.dataSource
             values.dataSource = ''
             let emptys = []
-            if (values.type === 'select') {
+            if (values.type === 'multiselect' || values.type === 'select') {
               emptys = values.options.filter(op => !(op.Value && op.Text))
             } else {
               emptys = values.options.filter(op => !(op.Value && op.Text && op.ParentID))
@@ -304,7 +316,7 @@
             if (emptys.length > 0) {
               isvalid = false
             }
-          } else if ((values.type === 'select' || values.type === 'link') && values.resourceType === '1') {
+          } else if ((values.type === 'multiselect' || values.type === 'select' || values.type === 'link') && values.resourceType === '1') {
             values.options = []
           }
 
diff --git a/src/templates/subtableconfig/index.jsx b/src/templates/subtableconfig/index.jsx
index 325f49a..44e2a93 100644
--- a/src/templates/subtableconfig/index.jsx
+++ b/src/templates/subtableconfig/index.jsx
@@ -995,7 +995,7 @@
         let isupdate = false
 
         if (res.type === 'search') {
-          if ((res.values.type === 'select' || res.values.type === 'link') && res.values.resourceType === '1') {
+          if ((res.values.type === 'multiselect' || res.values.type === 'select' || res.values.type === 'link') && res.values.resourceType === '1') {
             let _datasource = res.values.dataSource
 
             if (/\s/.test(_datasource)) {
diff --git a/src/templates/tableshare/searchform/index.jsx b/src/templates/tableshare/searchform/index.jsx
index df348b6..2585ba8 100644
--- a/src/templates/tableshare/searchform/index.jsx
+++ b/src/templates/tableshare/searchform/index.jsx
@@ -316,11 +316,11 @@
           values.id = this.props.card.id
           values.uuid = this.props.card.uuid
           // 涓嬫媺鑿滃崟鎴栧叧鑱旇彍鍗�
-          if ((values.type === 'select' || values.type === 'link') && values.resourceType === '0') {
+          if ((values.type === 'multiselect' || values.type === 'select' || values.type === 'link') && values.resourceType === '0') {
             values.options = this.refs.editTable.state.dataSource
             values.dataSource = ''
             let emptys = []
-            if (values.type === 'select') {
+            if (values.type === 'multiselect' || values.type === 'select') {
               emptys = values.options.filter(op => !(op.Value && op.Text))
             } else {
               emptys = values.options.filter(op => !(op.Value && op.Text && op.ParentID))
@@ -328,7 +328,7 @@
             if (emptys.length > 0) {
               isvalid = false
             }
-          } else if ((values.type === 'select' || values.type === 'link') && values.resourceType === '1') {
+          } else if ((values.type === 'multiselect' || values.type === 'select' || values.type === 'link') && values.resourceType === '1') {
             values.options = []
           }
 
diff --git a/src/utils/utils.js b/src/utils/utils.js
index 2503f10..8c61b92 100644
--- a/src/utils/utils.js
+++ b/src/utils/utils.js
@@ -227,6 +227,8 @@
         }
         item.value = _val ? [moment().subtract(_val[0], 'days').format('YYYY-MM-DD'),
           moment().subtract(_val[1], 'days').format('YYYY-MM-DD')] : ''
+      } else if (item.type === 'multiselect') {
+        item.value = item.value ? item.value.split(',').filter(Boolean) : []
       }
       newsearches.push(item)
     })
@@ -294,6 +296,8 @@
         item.key.split(',').forEach(field => { // 缁煎悎鎼滅储锛屾墍瀛楁鎷兼帴
           newsearches[field] = item.value
         })
+      } else if (item.type === 'multiselect') {
+        newsearches[item.key] = item.value.join(',')
       } else {
         newsearches[item.key] = item.value
       }
@@ -312,7 +316,8 @@
 
     let searchText = ''
     searches.forEach(item => {
-      if (!item.value) return
+      if (!item.value || (item.type === 'multiselect' && item.value.length === 0)) return
+      
       searchText += (searchText !== '' ? ' AND ' : '')
       if (item.type === 'text') {
         let str = item.match === '=' ? '' : '%'
@@ -325,6 +330,13 @@
         let str = item.match === '=' ? '' : '%'
 
         searchText += item.key + ' ' + item.match + ' \'' + str + item.value + str + '\''
+      } else if (item.type === 'multiselect') {
+        let str = item.match === '=' ? '' : '%'
+        let options = item.value.map(val => {
+          return item.key + ' ' + item.match + ' \'' + str + val + str + '\''
+        })
+
+        searchText += '(' + options.join(' OR ') + ')'
       } else if (item.type === 'date') {
         let _val = item.value
         let timetail = ' 00:00:00.000'

--
Gitblit v1.8.0