From 88ca0a326f0101a7713404909041003a512bb7e2 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期三, 08 六月 2022 17:19:41 +0800
Subject: [PATCH] 2022-06-08

---
 src/menu/components/table/normal-table/columns/editColumn/index.jsx |   13 +++++-
 src/templates/zshare/formconfig.jsx                                 |    5 +-
 src/menu/components/table/edit-table/columns/editColumn/index.jsx   |   13 +++++-
 src/templates/sharecomponent/searchcomponent/index.jsx              |    9 ++++
 src/templates/sharecomponent/searchcomponent/searchform/index.jsx   |   23 ++++++++++-
 5 files changed, 52 insertions(+), 11 deletions(-)

diff --git a/src/menu/components/table/edit-table/columns/editColumn/index.jsx b/src/menu/components/table/edit-table/columns/editColumn/index.jsx
index ca299fb..3997baa 100644
--- a/src/menu/components/table/edit-table/columns/editColumn/index.jsx
+++ b/src/menu/components/table/edit-table/columns/editColumn/index.jsx
@@ -85,7 +85,14 @@
   }
 
   editColumn = (column) => {
-    let formlist = getColumnForm(column, this.props.fields, this.props.columns)
+    let fields = fromJS(this.props.fields).toJS().map(item => {
+      if (item.label.toLowerCase() !== item.field.toLowerCase()) {
+        item.text = item.label + '锛�' + item.field + '锛�'
+      }
+      return item
+    })
+
+    let formlist = getColumnForm(column, fields, this.props.columns)
 
     this.column = fromJS(column).toJS()
     this.column.editType = this.column.editType || 'text'
@@ -132,7 +139,7 @@
         }
       })
     } else if (key === 'field') {
-      let values = {label: option.props.children}
+      let values = {label: option.props.label || option.props.children}
       if (/Decimal|int/ig.test(option.props.datatype)) {
         let decimal = 0
         if (/Decimal/ig.test(option.props.datatype)) {
@@ -270,7 +277,7 @@
           getPopupContainer={() => document.getElementById('edit-table-column-winter')}
         >
           {item.options.map((option, i) =>
-            <Select.Option key={i} datatype={option.datatype || ''} value={(option.value || option.field || option.MenuID)}>
+            <Select.Option key={i} datatype={option.datatype || ''} label={option.label || ''} value={(option.value || option.field || option.MenuID)}>
               {(option.text || option.label || option.MenuName)}
             </Select.Option>
           )}
diff --git a/src/menu/components/table/normal-table/columns/editColumn/index.jsx b/src/menu/components/table/normal-table/columns/editColumn/index.jsx
index 7aa7940..5a41606 100644
--- a/src/menu/components/table/normal-table/columns/editColumn/index.jsx
+++ b/src/menu/components/table/normal-table/columns/editColumn/index.jsx
@@ -44,7 +44,14 @@
   }
 
   editColumn = (column) => {
-    let formlist = getColumnForm(column, this.props.fields)
+    let fields = fromJS(this.props.fields).toJS().map(item => {
+      if (item.label.toLowerCase() !== item.field.toLowerCase()) {
+        item.text = item.label + '锛�' + item.field + '锛�'
+      }
+      return item
+    })
+    
+    let formlist = getColumnForm(column, fields)
     let _options = fromJS(columnTypeOptions[column.type]).toJS()
     if (column.type === 'text' || column.type === 'number') {
       if (column.perspective === 'linkmenu') {
@@ -96,7 +103,7 @@
         }
       })
     } else if (key === 'field') {
-      let values = {label: option.props.children}
+      let values = {label: option.props.label || option.props.children}
       if (/Decimal|int/ig.test(option.props.datatype)) {
         let decimal = 0
         if (/Decimal/ig.test(option.props.datatype)) {
@@ -231,7 +238,7 @@
                   getPopupContainer={() => document.getElementById('columnwinter')}
                 >
                   {item.options.map((option, index) =>
-                    <Select.Option key={index} datatype={option.datatype || ''} value={(option.value || option.field || option.MenuID)}>
+                    <Select.Option key={index} datatype={option.datatype || ''} label={option.label || ''} value={(option.value || option.field || option.MenuID)}>
                       {(option.text || option.label || option.MenuName)}
                     </Select.Option>
                   )}
diff --git a/src/templates/sharecomponent/searchcomponent/index.jsx b/src/templates/sharecomponent/searchcomponent/index.jsx
index 4f45d34..b461319 100644
--- a/src/templates/sharecomponent/searchcomponent/index.jsx
+++ b/src/templates/sharecomponent/searchcomponent/index.jsx
@@ -127,10 +127,17 @@
       })
     })
 
+    let columns = null
+    if (this.props.config.type === 'table') {
+      columns = this.props.config.columns.map(item => {
+        return {key: item.uuid, text: item.field, value: item.field, label: item.label}
+      })
+    }
+
     this.setState({
       visible: true,
       card: card,
-      formlist: getSearchForm(card, linkableFields)
+      formlist: getSearchForm(card, linkableFields, columns)
     })
   }
 
diff --git a/src/templates/sharecomponent/searchcomponent/searchform/index.jsx b/src/templates/sharecomponent/searchcomponent/searchform/index.jsx
index 2b3e7fd..238c641 100644
--- a/src/templates/sharecomponent/searchcomponent/searchform/index.jsx
+++ b/src/templates/sharecomponent/searchcomponent/searchform/index.jsx
@@ -1,7 +1,7 @@
 import React, {Component} from 'react'
 import PropTypes from 'prop-types'
 import { fromJS } from 'immutable'
-import { Form, Row, Col, Input, Select, Radio, notification, Tooltip, InputNumber, Checkbox, Cascader } from 'antd'
+import { Form, Row, Col, Input, Select, Radio, notification, Tooltip, InputNumber, Checkbox, Cascader, AutoComplete } from 'antd'
 import { QuestionCircleOutlined } from '@ant-design/icons'
 
 import { dateOptions, matchReg, formRule } from '@/utils/option.js'
@@ -419,6 +419,12 @@
     this.props.form.setFieldsValue({dataSource: resource})
   }
 
+  complete = (key, option) => {
+    let label = option.props.label
+    
+    this.props.form.setFieldsValue({label: label})
+  }
+
   getFields() {
     const { getFieldDecorator } = this.props.form
     const { dict } = this.props
@@ -455,7 +461,20 @@
           })
         }
 
-        content = <Input placeholder="" autoComplete="off" onPressEnter={this.handleSubmit} />
+        if (item.key === 'field' && item.options && item.options.length > 0) {
+          content = <AutoComplete
+            dataSource={item.options.map((cell) => <AutoComplete.Option label={cell.label} key={cell.key}>
+              {cell.text}
+            </AutoComplete.Option>)}
+            filterOption={(input, option) => option.props.children.indexOf(input) > -1}
+            onSelect={this.complete}
+            placeholder=""
+          >
+            <Input placeholder="" autoComplete="off" onPressEnter={this.handleSubmit} />
+          </AutoComplete>
+        } else {
+          content = <Input placeholder="" autoComplete="off" onPressEnter={this.handleSubmit} />
+        }
       } else if (item.type === 'number') {
         rules = [
           { required: item.required, message: dict['form.required.input'] + item.label + '!' }
diff --git a/src/templates/zshare/formconfig.jsx b/src/templates/zshare/formconfig.jsx
index abcc74d..1f15a39 100644
--- a/src/templates/zshare/formconfig.jsx
+++ b/src/templates/zshare/formconfig.jsx
@@ -286,7 +286,7 @@
  * @param {object} card           // 鎼滅储鏉′欢瀵硅薄
  * @param {Array}  linkableFields // 鍙叧鑱斿瓧娈�
  */
-export function getSearchForm (card, linkableFields) {
+export function getSearchForm (card, linkableFields, columns) {
   let roleList = sessionStorage.getItem('sysRoles')
   let appType = sessionStorage.getItem('appType')
   if (roleList) {
@@ -396,7 +396,8 @@
       key: 'field',
       label: Formdict['model.form.field'],
       initVal: card.field || '',
-      required: true
+      required: true,
+      options: columns
     },
     {
       type: 'select',

--
Gitblit v1.8.0