From 0c94290767a88c913ed736e65970eafee9e41519 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期三, 22 七月 2020 15:49:16 +0800
Subject: [PATCH] 2020-07-22

---
 src/templates/sharecomponent/actioncomponent/verifyexcelin/index.jsx |   67 ++++++++++++++++++++++++++++-----
 1 files changed, 57 insertions(+), 10 deletions(-)

diff --git a/src/templates/sharecomponent/actioncomponent/verifyexcelin/index.jsx b/src/templates/sharecomponent/actioncomponent/verifyexcelin/index.jsx
index 1040b3b..a8626b0 100644
--- a/src/templates/sharecomponent/actioncomponent/verifyexcelin/index.jsx
+++ b/src/templates/sharecomponent/actioncomponent/verifyexcelin/index.jsx
@@ -1,6 +1,6 @@
 import React, {Component} from 'react'
 import PropTypes from 'prop-types'
-import { Form, Tabs, Row, Col, Input, Button, Table, Popconfirm, Icon, notification, Modal, message, InputNumber, Radio, Typography } from 'antd'
+import { Form, Tabs, Row, Col, Input, Button, Table, Popconfirm, Icon, Tooltip, notification, Modal, message, InputNumber, Radio, Typography } from 'antd'
 import moment from 'moment'
 
 import Api from '@/api'
@@ -25,6 +25,7 @@
   state = {
     verify: {},
     systemScripts: [],
+    activeKey: 'basemsg',
     excelColumns: [
       {
         title: this.props.dict['model.form.field'],
@@ -298,7 +299,7 @@
       if (col.field && !_cols.includes(col.field)) {
         let _type = 'Nvarchar(50)'
         let _limit = '50'
-        if (col.type === 'number' && col.decimal === 0) {
+        if (col.type === 'number' && !col.decimal) {
           _type = 'Int'
           _limit = ''
         } else if (col.type === 'number') {
@@ -330,6 +331,26 @@
         ...verify,
         columns: _columns
       }
+    })
+  }
+
+  clearField = () => {
+    const { verify } = this.state
+    const _this = this
+
+    confirm({
+      content: `纭畾娓呯┖Excel鍒楀悧锛焋,
+      okText: this.props.dict['model.confirm'],
+      cancelText: this.props.dict['model.cancel'],
+      onOk() {
+        _this.setState({
+          verify: {
+            ...verify,
+            columns: []
+          }
+        })
+      },
+      onCancel() {}
     })
   }
 
@@ -564,14 +585,18 @@
           let _loading = false
           if (this.columnForm && this.columnForm.state.editItem) {
             _loading = true
+            this.setState({activeKey: 'excelcolumn'})
           } else if (this.scriptsForm && this.scriptsForm.state.editItem) {
             _loading = true
+            this.setState({activeKey: 'scripts'})
           } else if (this.uniqueForm && this.uniqueForm.state.editItem) {
             _loading = true
+            this.setState({activeKey: 'unique'})
           }
 
           if (this.scriptsForm && this.scriptsForm.props.form.getFieldValue('sql')) {
             _loading = true
+            this.setState({activeKey: 'scripts'})
           }
 
           if (_loading) {
@@ -648,10 +673,24 @@
     })
   }
 
+  tabchange = (val) => {
+    const { activeKey } = this.state
+
+    if (activeKey === 'basemsg') {
+      this.props.form.validateFieldsAndScroll((err, values) => {
+        if (!err) {
+          this.setState({activeKey: val})
+        }
+      })
+    } else {
+      this.setState({activeKey: val})
+    }
+  }
+
   render() {
     const { card } = this.props
     const { getFieldDecorator } = this.props.form
-    const { verify, excelColumns, scriptsColumns, uniqueColumns } = this.state
+    const { verify, excelColumns, scriptsColumns, uniqueColumns, activeKey } = this.state
     const formItemLayout = {
       labelCol: {
         xs: { span: 24 },
@@ -665,8 +704,8 @@
 
     return (
       <div id="verify-excel-box-tab">
-        <Tabs defaultActiveKey="1" className="verify-card-box" onChange={this.tabchange}>
-          <TabPane tab="鍩虹楠岃瘉" key="1">
+        <Tabs activeKey={activeKey} className="verify-card-box" onChange={this.tabchange}>
+          <TabPane tab="鍩虹楠岃瘉" key="basemsg">
             <Form {...formItemLayout}>
               <Row gutter={24}>
                 <Col span={8}>
@@ -683,7 +722,12 @@
                   </Form.Item>
                 </Col>
                 <Col span={8}>
-                  <Form.Item label={'蹇界暐琛�'}>
+                  <Form.Item label={
+                    <Tooltip placement="bottomLeft" title="蹇界暐棣栬鏃讹紝浼氭牎楠宔xcel涓〃澶村悕绉颁笌excel鍒楄缃槸鍚︿竴鑷淬��">
+                      <Icon type="question-circle" style={{color: '#c49f47', marginRight: '5px'}}/>
+                      蹇界暐琛�
+                    </Tooltip>
+                  }>
                     {getFieldDecorator('range', {
                       initialValue: verify.range || 0
                     })(<InputNumber min={0} max={100} precision={0} />)}
@@ -700,7 +744,7 @@
               </Row>
             </Form>
           </TabPane>
-          <TabPane tab="Excel鍒楄缃�" key="2x">
+          <TabPane tab="Excel鍒楄缃�" key="excelcolumn">
             <ColumnForm
               dict={this.props.dict}
               columns={verify.columns}
@@ -709,6 +753,9 @@
             />
             <Button className="excel-col-add mk-green" title="娣诲姞鏄剧ず鍒楀瓧娈�" onClick={this.columnFieldInput}>
               鍚屾鏄剧ず鍒�
+            </Button>
+            <Button className="excel-col-add mk-red" title="娓呯┖Excel鍒�" onClick={this.clearField}>
+              娓呯┖Excel鍒�
             </Button>
             <Table
               bordered
@@ -719,7 +766,7 @@
               pagination={false}
             />
           </TabPane>
-          {card.intertype === 'inner' && !card.innerFunc ? <TabPane tab="鍞竴鎬ч獙璇�" key="3">
+          {card.intertype === 'inner' && !card.innerFunc ? <TabPane tab="鍞竴鎬ч獙璇�" key="unique">
             <UniqueForm
               fields={verify.columns}
               dict={this.props.dict}
@@ -735,7 +782,7 @@
               pagination={false}
             />
           </TabPane> : null}
-          {card.intertype === 'inner' && !card.innerFunc ? <TabPane tab="鑷畾涔夎剼鏈�" key="6">
+          {card.intertype === 'inner' && !card.innerFunc ? <TabPane tab="鑷畾涔夎剼鏈�" key="scripts">
             <CustomScript
               dict={this.props.dict}
               btn={this.props.card}
@@ -754,7 +801,7 @@
               pagination={false}
             />
           </TabPane> : null}
-          <TabPane tab="淇℃伅鎻愮ず" key="7">
+          <TabPane tab="淇℃伅鎻愮ず" key="tip">
             <Form {...formItemLayout}>
               <Row gutter={24}>
                 <Col offset={6} span={6}>

--
Gitblit v1.8.0