king
2020-04-09 2ff464f30d94235b3ad04475593b75a74a354de9
src/templates/zshare/verifycard/index.jsx
@@ -27,6 +27,8 @@
  }
  state = {
    updateloading: false, // 修改中
    initsql: '',          // sql验证时变量声明及赋值
    verify: {},
    fields: [],
    usefulfields: '',
@@ -268,13 +270,13 @@
      {
        title: this.props.dict['header.form.funcvar'],
        dataIndex: 'fieldName',
        width: '13%',
        width: '12%',
        render: (text, record) => (`${record.fieldName || ''}(${record.field})`)
      },
      {
        title: '类型',
        dataIndex: 'billType',
        width: '8%',
        width: '6%',
      },
      {
        title: '凭证类型',
@@ -289,13 +291,13 @@
      {
        title: '关联字段',
        dataIndex: 'linkFieldName',
        width: '12%',
        width: '10%',
        render: (text, record) => (record.linkField ? `${record.linkFieldName || ''}(${record.linkField})` : '')
      },
      {
        title: '位数',
        dataIndex: 'Type',
        width: '8%'
        width: '6%'
      },
      {
        title: '示例',
@@ -324,9 +326,14 @@
        }
      },
      {
        title: '标识',
        dataIndex: 'mark',
        width: '8%'
      },
      {
        title: '状态',
        dataIndex: 'status',
        width: '9%',
        width: '8%',
        render: (text, record) => record.status === 'false' ?
          (
            <div>
@@ -373,6 +380,9 @@
    if (!_invalid) { // 选择行时,失效验证默认开启
      _invalid = card.Ot !== 'notRequired' ? 'true' : 'false'
    }
    if (card.sqlType === 'custom') { // 自定义验证时,不使用默认sql
      _verify.default = 'false'
    }
    _verify.default = _verify.default || 'true'
@@ -448,11 +458,39 @@
          }
          let _usefulfields = ['BID', 'ID', 'LoginUID', 'SessionUid', 'UserID', 'Appkey', 'UserName', 'FullName']
          let _declare = ['@UserName nvarchar(50)', '@FullName nvarchar(50)']
          let _select = ['@UserName=\'\'', '@FullName=\'\'']
          let hasBid = false
          let fieldArr = _usefulfields.map(_f => _f.toLowerCase())
          _fields.forEach(_f => {
            if (_f.field) {
              if (fieldArr.includes(_f.field.toLowerCase())) return
              fieldArr.push(_f.field.toLowerCase())
              _usefulfields.push(_f.field)
              let _fieldlen = _f.fieldlength || 50
              if (['textarea', 'fileupload', 'multiselect'].includes(_f.type)) {
                _fieldlen = _f.fieldlength || 512
              } else if (_f.type === 'number') {
                _fieldlen = _f.decimal ? _f.decimal : 0
              }
              let _type = `nvarchar(${_fieldlen})`
              if (_f.type.match(/date/ig)) {
                _type = 'datetime'
                _select.push(`@${_f.field}='1900-01-01'`)
              } else if (_f.type === 'number') {
                _type = `decimal(18,${_fieldlen})`
                _select.push(`@${_f.field}=0`)
              } else {
                _select.push(`@${_f.field}=''`)
              }
              _declare.push(`@${_f.field} ${_type}`)
            }
            if (_f.field && _f.field.toLowerCase() === 'bid') {
              hasBid = true
@@ -470,18 +508,38 @@
          if (columns && columns.length > 0 && this.props.card.Ot !== 'notRequired') {
            columns.forEach(_f => {
              if (_f.field) {
                _usefulfields.push(_f.field)
              if (!_f.field || fieldArr.includes(_f.field.toLowerCase())) return
              fieldArr.push(_f.field.toLowerCase())
              _usefulfields.push(_f.field)
              let _type = `nvarchar(${_f.fieldlength || 50})`
              if (_f.type === 'number') {
                _type = `decimal(18,${_f.decimal ? _f.decimal : 0})`
              } else if (_f.type === 'picture' || _f.type === 'textarea') {
                _type = `nvarchar(${_f.fieldlength || 512})`
              }
              if (_f.type === 'number') {
                _select.push(`@${_f.field}=0`)
              } else {
                _select.push(`@${_f.field}=''`)
              }
              _declare.push(`@${_f.field} ${_type}`)
            })
          }
          _usefulfields = Array.from(new Set(_usefulfields))
          _usefulfields = _usefulfields.join(', ')
          let _sql = `Declare ${_declare.join(', ')}
            Select ${_select.join(', ')}
          `
          this.setState({
            fields: _fields,
            initsql: _sql,
            usefulfields: _usefulfields
          })
        } else {
@@ -494,20 +552,43 @@
      })
    } else {
      let _usefulfields = ['BID', 'ID', 'LoginUID', 'SessionUid', 'UserID', 'Appkey', 'UserName', 'FullName']
      let _declare = ['@UserName nvarchar(50)', '@FullName nvarchar(50)']
      let _select = ['@UserName=\'\'', '@FullName=\'\'']
      let fieldArr = _usefulfields.map(_f => _f.toLowerCase())
      if (columns && columns.length > 0 && this.props.card.Ot !== 'notRequired') {
        columns.forEach(_f => {
          if (_f.field) {
            _usefulfields.push(_f.field)
          if (!_f.field || fieldArr.includes(_f.field.toLowerCase())) return
          fieldArr.push(_f.field.toLowerCase())
          _usefulfields.push(_f.field)
          let _type = `nvarchar(${_f.fieldlength || 50})`
          if (_f.type === 'number') {
            _type = `decimal(18,${_f.decimal ? _f.decimal : 0})`
          } else if (_f.type === 'picture' || _f.type === 'textarea') {
            _type = `nvarchar(${_f.fieldlength || 512})`
          }
          if (_f.type === 'number') {
            _select.push(`@${_f.field}=0`)
          } else {
            _select.push(`@${_f.field}=''`)
          }
          _declare.push(`@${_f.field} ${_type}`)
        })
      }
      _usefulfields = Array.from(new Set(_usefulfields))
      _usefulfields = _usefulfields.join(', ')
      let _sql = `Declare ${_declare.join(', ')}
        Select ${_select.join(', ')}
      `
      this.setState({
        initsql: _sql,
        usefulfields: _usefulfields
      })
    }
@@ -516,7 +597,7 @@
  componentDidMount() {
    // 获取生成单号一级菜单
    let defer1 = new Promise(resolve => {
      let _orderSql = 'select ID,ModularCode+ModularName+ModularNo as NameNO from sModular where deleted=0 order by ID asc'
      let _orderSql = `select distinct ModularCode as ID,ModularCode+ModularName+ModularNo as NameNO from sModular where deleted=0 and Appkey=case when Appkey='' then '' else @Appkey@ end order by ID asc`
      _orderSql = Utils.formatOptions(_orderSql)
      let orderParam = {
@@ -544,7 +625,7 @@
    // 获取生成单号二级菜单
    let defer2 = new Promise(resolve => {
      let _orderDetailSql = 'select ModularDetailCode,ModularDetailCode+ModularDetailName as CodeName,BID,Type from sModularDetail where Deleted=0'
      let _orderDetailSql = `select distinct ModularDetailCode,ModularDetailCode+ModularDetailName as CodeName,ModularCode as BID,Type from sModularDetail where Deleted=0 and Appkey=case when Appkey='' then '' else @Appkey@ end order by ModularDetailCode`
      _orderDetailSql = Utils.formatOptions(_orderDetailSql)
      let orderDetailParam = {
@@ -579,7 +660,7 @@
    // 获取凭证二级菜单
    let defer3 = new Promise(resolve => {
      let _voucherSql = 'select ID,ModularCode+ModularName+ModularNo as NameNO,TypeCharOne from sModular where deleted=0'
      let _voucherSql = 'select distinct ModularCode as ID,ModularCode+ModularName+ModularNo as NameNO,TypeCharOne from sModular where deleted=0  and Appkey=case when Appkey=\'\' then \'\' else @Appkey@ end  order by ModularCode'
      _voucherSql = Utils.formatOptions(_voucherSql)
      let voucherParam = {
@@ -607,7 +688,7 @@
    // 获取凭证三级菜单
    let defer4 = new Promise(resolve => {
      let _voucherDetailSql = 'select ModularDetailCode,ModularDetailCode+ModularDetailName as CodeName,BID, VoucherTypeTwo, IDefine1 from sModularDetail where Deleted=0 and VoucherTypeTwo!=\'\''
      let _voucherDetailSql = 'select distinct ModularDetailCode,ModularDetailCode+ModularDetailName as CodeName,ModularCode as BID, VoucherTypeTwo, IDefine1 from sModularDetail where Deleted=0 and VoucherTypeTwo!=\'\' and Appkey=case when Appkey=\'\' then \'\' else @Appkey@ end  order by ModularDetailCode'
      _voucherDetailSql = Utils.formatOptions(_voucherDetailSql)
      let voucherDetailParam = {
@@ -641,6 +722,25 @@
    })
  }
  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))
@@ -659,6 +759,8 @@
    this.setState({
      verify: verify
    }, () => {
      this.updateChange()
    })
  }
@@ -680,6 +782,8 @@
    this.setState({
      verify: verify
    }, () => {
      this.updateChange()
    })
  }
@@ -701,6 +805,8 @@
    this.setState({
      verify: verify
    }, () => {
      this.updateChange()
    })
  }
@@ -722,6 +828,8 @@
    this.setState({
      verify: verify
    }, () => {
      this.updateChange()
    })
  }
@@ -743,6 +851,8 @@
    this.setState({
      verify: verify
    }, () => {
      this.updateChange()
    })
  }
@@ -800,6 +910,10 @@
        }
      }, 10)
    }
    this.setState({
      updateloading: true
    })
  }
  handleStatus = (record, type) => {
@@ -1034,7 +1148,7 @@
          <TabPane tab="基础验证" key="1">
            <Form {...formItemLayout}>
              <Row gutter={24}>
                <Col span={8}>
                {this.props.card.sqlType !== 'custom' ? <Col span={8}>
                  <Form.Item label={
                    <Tooltip placement="bottomLeft" title={'默认sql执行顺序为自定义脚本之前'}>
                      <Icon type="question-circle" style={{color: '#c49f47', marginRight: '5px'}} />
@@ -1046,7 +1160,7 @@
                      <Radio value="false">不执行</Radio>
                    </Radio.Group>
                  </Form.Item>
                </Col>
                </Col> : null}
                <Col span={8}>
                  <Form.Item label={'账期验证'}>
                    <Radio.Group value={verify.accountdate} onChange={(e) => {this.onOptionChange(e, 'accountdate')}}>
@@ -1100,6 +1214,7 @@
          <TabPane tab="自定义验证" key="3">
            <CustomForm
              dict={this.props.dict}
              initsql={this.state.initsql}
              usefulfields={this.state.usefulfields}
              customChange={this.customChange}
              wrappedComponentRef={(inst) => this.customForm = inst}
@@ -1148,6 +1263,7 @@
          <TabPane tab="自定义脚本" key="6">
            <CustomScript
              usefulfields={this.state.usefulfields}
              initsql={this.state.initsql}
              dict={this.props.dict}
              scriptsChange={this.scriptsChange}
              wrappedComponentRef={(inst) => this.scriptsForm = inst}