From 3bb266595fbfa9af6b97405737496ed61c6b7c55 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期二, 01 三月 2022 17:10:57 +0800
Subject: [PATCH] 2022-03-01

---
 src/templates/sharecomponent/searchcomponent/searchform/index.jsx |   41 ++++++++++++++++++++++++++++++++++++++---
 1 files changed, 38 insertions(+), 3 deletions(-)

diff --git a/src/templates/sharecomponent/searchcomponent/searchform/index.jsx b/src/templates/sharecomponent/searchcomponent/searchform/index.jsx
index 069c271..2a7e48b 100644
--- a/src/templates/sharecomponent/searchcomponent/searchform/index.jsx
+++ b/src/templates/sharecomponent/searchcomponent/searchform/index.jsx
@@ -385,6 +385,36 @@
     }
   }
 
+  handleEmpty = () => {
+    let field = this.props.form.getFieldValue('valueField')
+
+    if (!field) {
+      notification.warning({
+        top: 92,
+        message: '璇峰~鍐欏�悸峰瓧娈点��',
+        duration: 5
+      })
+      return
+    }
+
+    let text = this.props.form.getFieldValue('valueText')
+
+    if (!text) {
+      notification.warning({
+        top: 92,
+        message: '璇峰~鍐欐枃鏈峰瓧娈点��',
+        duration: 5
+      })
+      return
+    }
+
+    let resource = this.props.form.getFieldValue('dataSource') || ''
+
+    resource = `select '' as ${field},'鍏ㄩ儴' as ${text} union all \n${resource}`
+
+    this.props.form.setFieldsValue({dataSource: resource})
+  }
+
   getFields() {
     const { getFieldDecorator } = this.props.form
     const { dict } = this.props
@@ -398,6 +428,7 @@
       let rules = []
       let className = ''
       let content = null
+      let extra = null
       let initVal = item.initVal || ''
 
       if (item.type === 'text') { // 鏂囨湰鎼滅储
@@ -462,12 +493,16 @@
             )
           })}
         </Radio.Group>
-      } else if (item.type === 'textarea') {
+      } else if (item.type === 'codemirror') {
         rules = [
           { required: item.required, message: dict['form.required.input'] + item.label + '!' }
         ]
         span = 24
         className = 'text-area'
+
+        if (this.record.type === 'select' || this.record.type === 'link') {
+          extra = <span className="add-row-empty" onClick={this.handleEmpty}>鍏ㄩ儴</span>
+        }
 
         content = <CodeMirror />
       } else if (item.type === 'options') {
@@ -477,7 +512,7 @@
         let type = this.record.type
         
         if (type !== 'checkcard') {
-          content = <EditTable type={type} transfield={{}} linkSubFields={[]} onChange={this.changeOptions}/>
+          content = <EditTable type={type} module="search" transfield={{}} linkSubFields={[]} onChange={this.changeOptions}/>
         } else {
           if (this.record.linkField) {
             type = 'link'
@@ -514,7 +549,7 @@
 
       fields.push(
         <Col span={span} key={index}>
-          <Form.Item className={className} label={item.tooltip ?
+          <Form.Item className={className} extra={extra} label={item.tooltip ?
             <Tooltip placement="topLeft" title={item.tooltip}>
               <QuestionCircleOutlined className="mk-form-tip" />
               {item.label}

--
Gitblit v1.8.0