king
2020-04-15 0c1c59933e95c4c691d6ba3d11bf4aef98fe9e8d
src/templates/zshare/verifycard/index.jsx
@@ -15,6 +15,7 @@
import './index.scss'
const { TabPane } = Tabs
const { confirm } = Modal
class VerifyCard extends Component {
  static propTpyes = {
@@ -27,7 +28,6 @@
  }
  state = {
    updateloading: false, // 修改中
    initsql: '',          // sql验证时变量声明及赋值
    verify: {},
    fields: [],
@@ -772,25 +772,6 @@
    })
  }
  updateChange = () => {
    let _loading = false
    if (this.customForm && this.customForm.state.editItem) {
      _loading = true
    } else if (this.uniqueForm && this.uniqueForm.state.editItem) {
      _loading = true
    } else if (this.orderForm && this.orderForm.state.editItem) {
      _loading = true
    } else if (this.scriptsForm && this.scriptsForm.state.editItem) {
      _loading = true
    } else if (this.contrastForm && this.contrastForm.state.editItem) {
      _loading = true
    }
    this.setState({
      updateloading: _loading
    })
  }
  uniqueChange = (values) => {
    let verify = JSON.parse(JSON.stringify(this.state.verify))
@@ -809,8 +790,6 @@
    this.setState({
      verify: verify
    }, () => {
      this.updateChange()
    })
  }
@@ -832,8 +811,6 @@
    this.setState({
      verify: verify
    }, () => {
      this.updateChange()
    })
  }
@@ -855,8 +832,6 @@
    this.setState({
      verify: verify
    }, () => {
      this.updateChange()
    })
  }
@@ -878,8 +853,6 @@
    this.setState({
      verify: verify
    }, () => {
      this.updateChange()
    })
  }
@@ -901,8 +874,6 @@
    this.setState({
      verify: verify
    }, () => {
      this.updateChange()
    })
  }
@@ -960,10 +931,6 @@
        }
      }, 10)
    }
    this.setState({
      updateloading: true
    })
  }
  handleStatus = (record, type) => {
@@ -1165,6 +1132,55 @@
    })
  }
  handleConfirm = () => {
    let verify = JSON.parse(JSON.stringify(this.state.verify))
    // 表单提交时检查输入值是否正确
    return new Promise((resolve, reject) => {
      if (verify.default === 'false' && verify.scripts.length === 0) {
        notification.warning({
          top: 92,
          message: '不执行默认sql时,必须设置自定义脚本!',
          duration: 10
        })
        return
      }
      let _loading = false
      if (this.customForm && this.customForm.state.editItem) {
        _loading = true
      } else if (this.uniqueForm && this.uniqueForm.state.editItem) {
        _loading = true
      } else if (this.orderForm && this.orderForm.state.editItem) {
        _loading = true
      } else if (this.scriptsForm && this.scriptsForm.state.editItem) {
        _loading = true
      } else if (this.contrastForm && this.contrastForm.state.editItem) {
        _loading = true
      }
      if (this.scriptsForm && this.scriptsForm.props.form.getFieldValue('sql')) {
        _loading = true
      } else if (this.customForm && this.customForm.props.form.getFieldValue('sql')) {
        _loading = true
      }
      if (_loading) {
        confirm({
          content: `存在未保存项,确定提交吗?`,
          okText: this.props.dict['header.confirm'],
          cancelText: this.props.dict['header.cancel'],
          onOk() {
            resolve(verify)
          },
          onCancel() {}
        })
      } else {
        resolve(verify)
      }
    })
  }
  /**
   * @description 组件销毁,清除state更新
   */