king
2020-04-01 2c0e07ad097eb692c9909efdc614cc40b8653de2
2020-04-01
8个文件已修改
2个文件已添加
473 ■■■■■ 已修改文件
src/tabviews/commontable/index.scss 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/tabviews/subtable/index.scss 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/templates/comtableconfig/index.jsx 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/templates/formtabconfig/index.jsx 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/templates/subtableconfig/index.jsx 48 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/templates/zshare/createinterface/index.jsx 18 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/templates/zshare/verifycardexcelin/index.jsx 141 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/templates/zshare/verifycardexcelin/uniqueform/index.jsx 148 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/templates/zshare/verifycardexcelin/uniqueform/index.scss 补丁 | 查看 | 原始文档 | blame | 历史
src/utils/utils.js 102 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/tabviews/commontable/index.scss
@@ -85,6 +85,9 @@
    width: 40px;
    height: 40px;
  }
  .ant-table-fixed-left, .ant-table-fixed-right {
    z-index: 1;
  }
}
.commontable.pick-control {
  .button-list {
src/tabviews/subtable/index.scss
@@ -44,4 +44,7 @@
      z-index: 10;
    }
  }
  .ant-table-fixed-left, .ant-table-fixed-right {
    z-index: 1;
  }
}
src/templates/comtableconfig/index.jsx
@@ -1086,6 +1086,15 @@
    this.menuformRef.handleConfirm().then(res => {
      this.actionFormRef.handleConfirm().then(result => {
        if (!['pop', 'exec', 'prompt'].includes(result) || result.funcType || result.intertype !== 'inner' || result.innerFunc ) {
          notification.warning({
            top: 92,
            message: '打开方式为 弹窗(表单)、提示框或直接执行,且使用系统函数时,才可以创建接口!',
            duration: 10
          })
          return
        }
        let _menu = {
          type: 'main',
          MenuID: menu.MenuID,
src/templates/formtabconfig/index.jsx
@@ -119,7 +119,6 @@
        })
      })
    }
    console.log(_config)
    if (menu && menu.LongParam && menu.LongParam.columns) {
      columns = menu.LongParam.columns
src/templates/subtableconfig/index.jsx
@@ -2015,6 +2015,35 @@
  }
  /**
   * @description 创建按钮接口(写入)
   */
  btnCreatInterface = () => {
    const { config } = this.state
    this.menuformRef.handleConfirm().then(res => {
      this.actionFormRef.handleConfirm().then(result => {
        if (!['pop', 'exec', 'prompt'].includes(result) || result.funcType || result.intertype !== 'inner' || result.innerFunc ) {
          notification.warning({
            top: 92,
            message: '打开方式为 弹窗(表单)、提示框或直接执行,且使用系统函数时,才可以创建接口!',
            duration: 10
          })
          return
        }
        let _menu = {
          type: 'subtable',
          MenuID: config.uuid,
          menuName: res.tabName,
          menuNo: res.tabNo
        }
        this.refs.btnCreatInterface.triggerInInterface(result, config, _menu)
      })
    })
  }
  /**
   * @description 创建表格接口
   */
  tableCreatInterface = () => {
@@ -2039,13 +2068,7 @@
          menuNo: res.tabNo
        }
  
        this.refs.tableCreatInterface.exec(_menu, _config).then(result => {
          if (result === 'success') {
            this.setState({
              config: _config
            })
          }
        })
        this.refs.tableCreatInterface.triggerOutInterface(_menu, _config)
      })
    })
  }
@@ -2077,10 +2100,16 @@
  }
  render () {
    const { modaltype, activeKey } = this.state
    const configAction = this.state.config.action.filter(_action =>
    const { modaltype, activeKey, config } = this.state
    const configAction = config.action.filter(_action =>
      !_action.origin && (_action.OpenType === 'pop' || _action.OpenType === 'popview' || _action.OpenType === 'blank' || _action.OpenType === 'tab')
    )
    let hasbtncrtinter = false
    if (modaltype === 'actionEdit' && config.setting.interType === 'inner' && !config.setting.innerFunc && config.setting.dataresource) {
      hasbtncrtinter = true
    }
    return (
      <div className="common-table-board">
@@ -2282,6 +2311,7 @@
          maskClosable={false}
          onCancel={this.editModalCancel}
          footer={[
            hasbtncrtinter ? <CreateInterface key="interface" dict={this.state.dict} ref="btnCreatInterface" trigger={this.btnCreatInterface}/> : null,
            modaltype === 'actionEdit' ? <CreateFunc key="create" dict={this.state.dict} ref="btnCreatFunc" trigger={this.creatFunc}/> : null,
            <Button key="cancel" onClick={this.editModalCancel}>{this.state.dict['header.cancel']}</Button>,
            <Button key="confirm" type="primary" onClick={this.handleSubmit}>{this.state.dict['header.confirm']}</Button>
src/templates/zshare/createinterface/index.jsx
@@ -704,10 +704,12 @@
        let _fieldValue = []                     // 表单键值对field=value
        let _value = []                          // 表单值,用于错误提示
        let _labels = item.fieldlabel.split(',') // 表单提示文字
        let arr = [] // 验证主键
        item.field.split(',').forEach((_field, index) => {
          _fieldValue.push(`${_field}=@${_field}@`)
          _value.push(`${_labels[index] || ''}:'+@${_field}@+'`)
          arr.push(_field.toLowerCase())
        })
        let _verifyType = ''
@@ -715,8 +717,12 @@
          _verifyType = ' and deleted=0'
        }
        if (!arr.includes(primaryKey.toLowerCase())) {
          _fieldValue.push(`${primaryKey} !=@${primaryKey}@`)
        }
        _sql += `select @tbid='', @ErrorCode='',@retmsg=''
          select @tbid='X' from ${btn.sql} where ${_fieldValue.join(' and ')} and ${primaryKey} !=@${primaryKey}@${_verifyType}
          select @tbid='X' from ${btn.sql} where ${_fieldValue.join(' and ')}${_verifyType}
          If @tbid!=''
          Begin
            select @ErrorCode='${item.errorCode}',@retmsg='${_value.join(', ')} 已存在'
@@ -820,8 +826,8 @@
      receiptKeys.push(item.key.toLowerCase())
    })
    if (!receiptKeys.includes(primaryKey)) {
      receiptKeys.push(primaryKey)
    if (!receiptKeys.includes(primaryKey.toLowerCase())) {
      receiptKeys.push(primaryKey.toLowerCase())
    }
    if (!receiptKeys.includes('bid') && BID) {
@@ -842,8 +848,8 @@
        values.push('@' + item.key + '@')
      })
      if (!keys.includes(primaryKey)) {
        keys.push(primaryKey)
      if (!keys.includes(primaryKey.toLowerCase())) {
        keys.push(primaryKey.toLowerCase())
        values.push(`@${primaryKey}@`)
      }
@@ -947,7 +953,7 @@
    _sql += `
      aaa: select @ErrorCode as ErrorCode,@retmsg as retmsg,'${_ltext}' as Ltext`
    console.log(_sql)
    return _sql
  }
src/templates/zshare/verifycardexcelin/index.jsx
@@ -4,6 +4,7 @@
import Utils from '@/utils/utils.js'
import UniqueForm from './uniqueform'
import ColumnForm from './columnform'
import CustomScript from './customscript'
import './index.scss'
@@ -73,10 +74,67 @@
                cancelText={this.props.dict['header.cancel']}
                onConfirm={() => this.handleDelete(record, 'columns')
              }>
                <span style={{color: '#1890ff', cursor: 'pointer'}}><Icon type="delete" /></span>
                <span className="operation-btn" style={{color: '#ff4d4f'}}><Icon type="delete" /></span>
              </Popconfirm>
            </div>
          )
      }
    ],
    uniqueColumns: [
      {
        title: '字段名',
        dataIndex: 'field',
        width: '35%'
      },
      {
        title: '报错编码',
        dataIndex: 'errorCode',
        width: '12%'
      },
      {
        title: '验证类型',
        dataIndex: 'verifyType',
        width: '13%',
        render: (text, record) => record.verifyType === 'logic' ? '逻辑验证' : '物理验证'
      },
      {
        title: '状态',
        dataIndex: 'status',
        width: '15%',
        render: (text, record) => record.status === 'false' ?
          (
            <div>
              {this.props.dict['header.form.status.forbidden']}
              <Icon style={{marginLeft: '5px'}} type="stop" theme="twoTone" twoToneColor="#ff4d4f" />
            </div>
          ) :
          (
            <div>
              {this.props.dict['header.form.status.open']}
              <Icon style={{marginLeft: '5px'}} type="check-circle" theme="twoTone" twoToneColor="#52c41a" />
            </div>
          )
      },
      {
        title: '操作',
        align: 'center',
        width: '25%',
        dataIndex: 'operation',
        render: (text, record) =>
          (<div>
            <span className="operation-btn" title={this.props.dict['header.edit']} onClick={() => this.handleEdit(record, 'unique')} style={{color: '#1890ff'}}><Icon type="edit" /></span>
            <span className="operation-btn" title={this.props.dict['header.form.up']} onClick={() => this.handleUpDown(record, 'unique', 'up')} style={{color: '#1890ff'}}><Icon type="arrow-up" /></span>
            <span className="operation-btn" title={this.props.dict['header.form.down']} onClick={() => this.handleUpDown(record, 'unique', 'down')} style={{color: '#ff4d4f'}}><Icon type="arrow-down" /></span>
            <span className="operation-btn" title={this.props.dict['header.form.status.change']} onClick={() => this.handleStatus(record, 'unique')} style={{color: '#8E44AD'}}><Icon type="swap" /></span>
            <Popconfirm
              title={this.props.dict['header.form.query.delete']}
              okText={this.props.dict['header.confirm']}
              cancelText={this.props.dict['header.cancel']}
              onConfirm={() => this.handleDelete(record, 'unique')
            }>
              <span className="operation-btn" style={{color: '#ff4d4f'}}><Icon type="delete" /></span>
            </Popconfirm>
          </div>)
      }
    ],
    scriptsColumns: [
@@ -153,7 +211,8 @@
        sheet: _verify.sheet || 'Sheet1',
        range: _verify.range || 0,
        columns: _columns,
        scripts: _verify.scripts || []
        scripts: _verify.scripts || [],
        uniques: _verify.uniques || []
      }
    })
  }
@@ -225,6 +284,27 @@
    })
  }
  uniqueChange = (values) => {
    let verify = JSON.parse(JSON.stringify(this.state.verify))
    if (values.uuid) {
      verify.uniques = verify.uniques.map(item => {
        if (item.uuid === values.uuid) {
          return values
        } else {
          return item
        }
      })
    } else {
      values.uuid = Utils.getuuid()
      verify.uniques.push(values)
    }
    this.setState({
      verify: verify
    })
  }
  scriptsChange = (values) => {
    let verify = JSON.parse(JSON.stringify(this.state.verify))
@@ -253,7 +333,10 @@
      verify.columns = verify.columns.filter(item => item.uuid !== record.uuid)
    } else if (type === 'scripts') {
      verify.scripts = verify.scripts.filter(item => item.uuid !== record.uuid)
    } else if (type === 'unique') {
      verify.uniques = verify.uniques.filter(item => item.uuid !== record.uuid)
    }
    this.setState({ verify: verify })
  }
@@ -262,6 +345,8 @@
      this.columnForm.edit(record)
    } else if (type === 'scripts') {
      this.scriptsForm.edit(record)
    } else if (type === 'unique') {
      this.uniqueForm.edit(record)
    }
    let node = document.getElementById('verify-excel-box-tab').parentNode
@@ -286,6 +371,14 @@
    if (type === 'scripts') {
      verify.scripts = verify.scripts.map(item => {
        if (item.uuid === record.uuid) {
          return record
        } else {
          return item
        }
      })
    } else if (type === 'unique') {
      verify.uniques = verify.uniques.map(item => {
        if (item.uuid === record.uuid) {
          return record
        } else {
@@ -319,6 +412,23 @@
        verify.columns.splice(index - 1, 0, record)
      } else {
        verify.columns.splice(index + 1, 0, record)
      }
    } else if (type === 'unique') {
      verify.uniques = verify.uniques.filter((item, i) => {
        if (item.uuid === record.uuid) {
          index = i
        }
        return item.uuid !== record.uuid
      })
      if ((index === 0 && direction === 'up') || (index === verify.uniques.length && direction === 'down')) {
        return
      }
      if (direction === 'up') {
        verify.uniques.splice(index - 1, 0, record)
      } else {
        verify.uniques.splice(index + 1, 0, record)
      }
    } else if (type === 'scripts') {
      verify.scripts = verify.scripts.filter((item, i) => {
@@ -444,8 +554,9 @@
  }
  render() {
    const { card } = this.props
    const { getFieldDecorator } = this.props.form
    const { verify, excelColumns, scriptsColumns } = this.state
    const { verify, excelColumns, scriptsColumns, uniqueColumns } = this.state
    const formItemLayout = {
      labelCol: {
        xs: { span: 24 },
@@ -483,14 +594,14 @@
                    })(<InputNumber min={0} max={100} precision={0} />)}
                  </Form.Item>
                </Col>
                <Col span={8}>
                {card.intertype === 'inner' && !card.innerFunc ? <Col span={8}>
                  <Form.Item label={'默认sql'}>
                    <Radio.Group value={verify.default} onChange={this.onOptionChange}>
                      <Radio value="true">执行</Radio>
                      <Radio value="false">不执行</Radio>
                    </Radio.Group>
                  </Form.Item>
                </Col>
                </Col> : null}
              </Row>
            </Form>
          </TabPane>
@@ -513,7 +624,23 @@
              pagination={false}
            />
          </TabPane>
          <TabPane tab="自定义脚本" key="6">
          {card.intertype === 'inner' && !card.innerFunc ? <TabPane tab="唯一性验证" key="3">
            <UniqueForm
              fields={verify.columns}
              dict={this.props.dict}
              uniqueChange={this.uniqueChange}
              wrappedComponentRef={(inst) => this.uniqueForm = inst}
            />
            <Table
              bordered
              rowKey="uuid"
              className="custom-table"
              dataSource={verify.uniques}
              columns={uniqueColumns}
              pagination={false}
            />
          </TabPane> : null}
          {card.intertype === 'inner' && !card.innerFunc ? <TabPane tab="自定义脚本" key="6">
            <CustomScript
              dict={this.props.dict}
              btn={this.props.card}
@@ -531,7 +658,7 @@
              columns={scriptsColumns}
              pagination={false}
            />
          </TabPane>
          </TabPane> : null}
          <TabPane tab="信息提示" key="7">
            <Form {...formItemLayout}>
              <Row gutter={24}>
src/templates/zshare/verifycardexcelin/uniqueform/index.jsx
New file
@@ -0,0 +1,148 @@
import React, {Component} from 'react'
import PropTypes from 'prop-types'
import { Form, Row, Col, Select, Button } from 'antd'
import './index.scss'
class UniqueForm extends Component {
  static propTpyes = {
    dict: PropTypes.object,       // 字典项
    fields: PropTypes.array,      // 表单字段
    uniqueChange: PropTypes.func  // 修改函数
  }
  state = {
    editItem: null // 编辑元素
  }
  edit = (record) => {
    this.setState({
      editItem: record
    })
    this.props.form.setFieldsValue({
      field: record.field.split(','),
      errorCode: record.errorCode,
      verifyType: record.verifyType || 'physical'
    })
  }
  handleConfirm = () => {
    const { fields } = this.props
    // 表单提交时检查输入值是否正确
    this.props.form.validateFieldsAndScroll((err, values) => {
      if (!err) {
        values.uuid = this.state.editItem ? this.state.editItem.uuid : ''
        values.fieldlabel = values.field.map(field => {
          let item = fields.filter(cell => cell.Column === field)[0]
          let label = ''
          if (item) {
            label = item.Text
          }
          return label
        })
        values.fieldlabel = values.fieldlabel.join(',')
        values.field = values.field.join(',')
        this.props.uniqueChange(values)
        this.setState({
          editItem: null
        })
        this.props.form.setFieldsValue({
          field: [],
        })
      }
    })
  }
  render() {
    const { getFieldDecorator } = this.props.form
    const { fields } = this.props
    const formItemLayout = {
      labelCol: {
        xs: { span: 24 },
        sm: { span: 8 }
      },
      wrapperCol: {
        xs: { span: 24 },
        sm: { span: 16 }
      }
    }
    return (
      <Form {...formItemLayout} className="verify-form" id="verifycard1">
        <Row gutter={24}>
          <Col span={10}>
            <Form.Item label={'列名'}>
              {getFieldDecorator('field', {
                initialValue: [],
                rules: [
                  {
                    required: true,
                    message: this.props.dict['form.required.select'] + '列名!'
                  }
                ]
              })(
                <Select
                  mode="multiple"
                >
                  {fields.map(item => (
                    <Select.Option key={item.uuid} value={item.Column}>{item.Text}</Select.Option>
                  ))}
                </Select>
              )}
            </Form.Item>
          </Col>
          <Col span={6}>
            <Form.Item label={'报错编码'}>
              {getFieldDecorator('errorCode', {
                initialValue: 'E',
                rules: [
                  {
                    required: true,
                    message: this.props.dict['form.required.select'] + '报错编码!'
                  }
                ]
              })(
                <Select>
                  <Select.Option value="E"> E </Select.Option>
                  <Select.Option value="N"> N </Select.Option>
                  <Select.Option value="F"> F </Select.Option>
                  <Select.Option value="NM"> NM </Select.Option>
                </Select>
              )}
            </Form.Item>
          </Col>
          <Col span={6}>
            <Form.Item label={'验证类型'}>
              {getFieldDecorator('verifyType', {
                initialValue: 'physical',
                rules: [
                  {
                    required: true,
                    message: this.props.dict['form.required.select'] + '验证类型!'
                  }
                ]
              })(
                <Select>
                  <Select.Option value="physical"> 物理验证 </Select.Option>
                  <Select.Option value="logic"> 逻辑验证 </Select.Option>
                </Select>
              )}
            </Form.Item>
          </Col>
          <Col span={2} className="add">
            <Button onClick={this.handleConfirm} type="primary" className="add-row">
              确定
            </Button>
          </Col>
        </Row>
      </Form>
    )
  }
}
export default Form.create()(UniqueForm)
src/templates/zshare/verifycardexcelin/uniqueform/index.scss
src/utils/utils.js
@@ -565,6 +565,48 @@
    let _sql = ''
    if (item.intertype === 'inner' && !item.innerFunc) {
      let _uniquesql = ''
      if (btn.uniques && btn.uniques.length > 0) {
        btn.uniques.forEach(unique => {
          if (unique.status === 'false') return
          let _fields = unique.field.split(',')
          let _fields_ = _fields.map(_field => {
            return `a.${_field}=b.${_field}`
          })
          _fields_ = _fields_.join(' and ')
          if (unique.verifyType !== 'physical') {
            _fields_ += ' and b.deleted=0'
          }
          _uniquesql += `
          Set @tbid=''
          Select top 1 @tbid=${_fields.join('+\' \'+')} from (select 1 as n,${unique.field} from @${item.sheet} ) a group by ${unique.field} having sum(n)>1
          If @tbid!=''
          Begin
            select @ErrorCode='${unique.errorCode}',@retmsg=@tbid+' 重复'
            goto aaa
          end
          Set @tbid=''
          Select top 1 @tbid=${_fields.join('+\' \'+')} from  @${item.sheet} a
          Inner join ${item.sheet} b on ${_fields_}
          If @tbid!=''
          Begin
            select @ErrorCode='${unique.errorCode}',@retmsg=@tbid+' 与已有数据重复'
            goto aaa
          end
          `
        })
        if (_uniquesql) {
          _uniquesql = 'Declare @tbid Nvarchar(512)' + _uniquesql
        }
      }
      let declarefields = []
      let fields = []
@@ -603,6 +645,7 @@
      
      Insert into  @${item.sheet} (${fields},jskey)
      ${_Ltext}
      ${_uniquesql}
      ${_insert}
      Delete @${item.sheet}
@@ -807,6 +850,7 @@
        let _fieldValue = []                     // 表单键值对field=value
        let _value = []                          // 表单值,用于错误提示
        let _labels = item.fieldlabel.split(',') // 表单提示文字
        let arr = [] // 验证主键
        item.field.split(',').forEach((_field, index) => {
          let _fval = `'${_formFieldValue[_field]}'`
@@ -816,6 +860,8 @@
          if (_field.toLowerCase() === 'bid' && !hasBid) { // 表单中没有bid则使用系统bid变量
            _fval = '@BID@'
          }
          arr.push(_field.toLowerCase())
          _fieldValue.push(`${_field}=${_fval}`)
          _value.push(`${_labels[index] || ''}:${_formFieldValue[_field] || ''}`)
        })
@@ -825,8 +871,12 @@
          _verifyType = ' and deleted=0'
        }
        if (!arr.includes(primaryKey.toLowerCase())) {
          _fieldValue.push(`${primaryKey} !='${primaryId}'`)
        }
        _sql += `select @tbid='', @ErrorCode='',@retmsg=''
          select @tbid='X' from ${btn.sql} where ${_fieldValue.join(' and ')} and ${primaryKey} !='${primaryId}'${_verifyType}
          select @tbid='X' from ${btn.sql} where ${_fieldValue.join(' and ')}${_verifyType}
          If @tbid!=''
          Begin
            select @ErrorCode='${item.errorCode}',@retmsg='${_value.join(', ')} 已存在'
@@ -950,8 +1000,8 @@
        }
      })
      if (!keys.includes(primaryKey)) {
        keys.push(primaryKey)
      if (!keys.includes(primaryKey.toLowerCase())) {
        keys.push(primaryKey.toLowerCase())
        values.push('\'' + primaryId + '\'')
      }
      if (!keys.includes('createuserid')) {
@@ -1359,6 +1409,50 @@
  static getexcelInfunc (param, btn, menu) {
    let _verify = btn.verify
    let _uniquesql = ''
    if (_verify.uniques && _verify.uniques.length > 0) {
      _verify.uniques.forEach(unique => {
        if (unique.status === 'false') return
        let _fields = unique.field.split(',')
        let _fields_ = _fields.map(_field => {
          return `a.${_field}=b.${_field}`
        })
        _fields_ = _fields_.join(' and ')
        if (unique.verifyType !== 'physical') {
          _fields_ += ' and b.deleted=0'
        }
        _uniquesql += `
        Set @tbid=''
        Select top 1 @tbid=${_fields.join('+\' \'+')} from (select 1 as n,${unique.field} from @${btn.sheet} ) a group by ${unique.field} having sum(n)>1
        If @tbid!=''
        Begin
          select @ErrorCode='${unique.errorCode}',@retmsg=@tbid+' 重复'
          goto aaa
        end
        Set @tbid=''
        Select top 1 @tbid=${_fields.join('+\' \'+')} from  @${btn.sheet} a
        Inner join ${btn.sheet} b on ${_fields_}
        If @tbid!=''
        Begin
          select @ErrorCode='${unique.errorCode}',@retmsg=@tbid+' 与已有数据重复'
          goto aaa
        end
        `
      })
      if (_uniquesql) {
        _uniquesql = `
        Declare @tbid Nvarchar(512)
        ${_uniquesql}`
      }
    }
    let declarefields = []
    let fields = []
@@ -1378,7 +1472,7 @@
      exec s_KeyWords_Replace
      @LText=@LText, @BID=@BID,@LoginUID=@LoginUID,@SessionUid=@SessionUid,@UserID=@UserID,@ID=@ID
      ${_uniquesql}
      Insert into ${btn.sheet} (${fields},createuserid,createuser,createstaff,bid) 
      Select ${fields},@userid,@username,@fullname,@BID From @${btn.sheet}