king
2020-07-22 0c94290767a88c913ed736e65970eafee9e41519
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="忽略首行时,会校验excel中表头名称与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}>