king
2020-02-04 390c5026c78d2be9dca4357041f4a0ec8ac3668f
2020-02-04
4个文件已修改
2个文件已添加
249 ■■■■■ 已修改文件
src/tabviews/tableshare/actionList/index.jsx 18 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/templates/tableshare/verifycard/customscript/index.jsx 94 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/templates/tableshare/verifycard/customscript/index.scss 补丁 | 查看 | 原始文档 | blame | 历史
src/templates/tableshare/verifycard/index.jsx 94 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/templates/tableshare/verifycard/index.scss 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/utils/utils.js 32 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/tabviews/tableshare/actionList/index.jsx
@@ -226,14 +226,14 @@
        }
        
        Api.genericInterface(param).then((res) => {
          if (res.status) {
            this.execSuccess(btn, res)
          } else {
            this.execError(res, btn)
          }
          _resolve()
        })
        // Api.genericInterface(param).then((res) => {
        //   if (res.status) {
        //     this.execSuccess(btn, res)
        //   } else {
        //     this.execError(res, btn)
        //   }
        //   _resolve()
        // })
      } else if (btn.Ot === 'required' || (btn.Ot === 'requiredOnce' && btn.OpenType === 'pop')) {
        let deffers = data.map(cell => {
          let param = {
@@ -382,7 +382,7 @@
          _outParam = JSON.parse(JSON.stringify(res))
          res.appkey = window.GLOB.appkey || '' // 外部请求时,统一添加appkey
          return Api.genericInterface(res)
        }).then(response => {
          if (!response) return
src/templates/tableshare/verifycard/customscript/index.jsx
New file
@@ -0,0 +1,94 @@
import React, {Component} from 'react'
import PropTypes from 'prop-types'
import { Form, Row, Col, Input, Button } from 'antd'
import './index.scss'
const { TextArea } = Input
class CustomForm extends Component {
  static propTpyes = {
    dict: PropTypes.object,       // 字典项
    fields: PropTypes.array,      // 表单
    scriptsChange: PropTypes.func  // 表单
  }
  state = {
    editItem: null
  }
  edit = (record) => {
    this.setState({
      editItem: record
    })
    this.props.form.setFieldsValue({
      sql: record.sql
    })
  }
  handleConfirm = () => {
    // 表单提交时检查输入值是否正确
    this.props.form.validateFieldsAndScroll((err, values) => {
      if (!err) {
        values.uuid = this.state.editItem ? this.state.editItem.uuid : ''
        this.props.scriptsChange(values)
        this.setState({
          editItem: null
        })
        this.props.form.setFieldsValue({
          sql: ''
        })
      }
    })
  }
  render() {
    const { fields } = this.props
    const { getFieldDecorator } = this.props.form
    const formItemLayout = {
      labelCol: {
        xs: { span: 24 },
        sm: { span: 8 }
      },
      wrapperCol: {
        xs: { span: 24 },
        sm: { span: 16 }
      }
    }
    let _fields = fields.map(item => item.field)
    return (
      <Form {...formItemLayout} className="verify-form" id="verifycard2">
        <Row gutter={24}>
          {fields && fields.length > 0 ? <Col span={21} className="sqlfield">
            <Form.Item label={'表单字段'}>
              {_fields.join(', ')}
            </Form.Item>
          </Col> : null}
          <Col span={21} className="sql">
            <Form.Item label={'sql'}>
              {getFieldDecorator('sql', {
                initialValue: '',
                rules: [
                  {
                    required: true,
                    message: this.props.dict['form.required.input'] + 'sql!'
                  }
                ]
              })(<TextArea rows={2} />)}
            </Form.Item>
          </Col>
          <Col span={3} className="add">
            <Button onClick={this.handleConfirm} type="primary" className="add-row">
              确定
            </Button>
          </Col>
        </Row>
      </Form>
    )
  }
}
export default Form.create()(CustomForm)
src/templates/tableshare/verifycard/customscript/index.scss
src/templates/tableshare/verifycard/index.jsx
@@ -2,12 +2,15 @@
import PropTypes from 'prop-types'
import { Form, Tabs, Row, Col, Radio, Button, Table, Popconfirm, Icon, notification, Modal, message, InputNumber } from 'antd'
import moment from 'moment'
import Api from '@/api'
import Utils from '@/utils/utils.js'
import UniqueForm from './uniqueform'
import CustomForm from './customform'
import CustomScript from './customscript'
import BillcodeForm from './billcodeform'
import VoucherForm from './voucherform'
import Api from '@/api'
import './index.scss'
const { TabPane } = Tabs
@@ -91,6 +94,28 @@
          </div>)
      }
    ],
    scriptsColumns: [
      {
        title: 'SQL',
        dataIndex: 'sql',
        width: '80%'
      },
      {
        title: '操作',
        align: 'center',
        width: '20%',
        dataIndex: 'operation',
        render: (text, record) =>
          (<div>
            <span className="operation-btn" onClick={() => this.handleEdit(record, 'scripts')} style={{color: '#1890ff'}}><Icon type="edit" /></span>
            <Popconfirm title="确定删除吗?" onConfirm={() => this.handleDelete(record, 'scripts')}>
              <span className="operation-btn" style={{color: '#ff4d4f'}}><Icon type="delete" /></span>
            </Popconfirm>
            <span className="operation-btn" onClick={() => this.handleUpDown(record, 'scripts', 'up')} style={{color: '#1890ff'}}><Icon type="arrow-up" /></span>
            <span className="operation-btn" onClick={() => this.handleUpDown(record, 'scripts', 'down')} style={{color: '#ff4d4f'}}><Icon type="arrow-down" /></span>
          </div>)
      }
    ],
    orderColumns: [
      {
        title: '函数变量',
@@ -153,6 +178,7 @@
        customverifys: _verify.customverifys || [],
        billcodes: _verify.billcodes || [],
        voucher: _verify.voucher || {enabled: false},
        scripts: _verify.scripts || []
      }
    })
@@ -369,6 +395,27 @@
    })
  }
  scriptsChange = (values) => {
    let verify = JSON.parse(JSON.stringify(this.state.verify))
    if (values.uuid) {
      verify.scripts = verify.scripts.map(item => {
        if (item.uuid === values.uuid) {
          return values
        } else {
          return item
        }
      })
    } else {
      values.uuid = Utils.getuuid()
      verify.scripts.push(values)
    }
    this.setState({
      verify: verify
    })
  }
  orderChange = (values) => {
    let verify = JSON.parse(JSON.stringify(this.state.verify))
@@ -408,6 +455,8 @@
      verify.uniques = verify.uniques.filter(item => item.uuid !== record.uuid)
    } else if (type === 'ordercode') {
      verify.billcodes = verify.billcodes.filter(item => item.uuid !== record.uuid)
    } else if (type === 'scripts') {
      verify.scripts = verify.scripts.filter(item => item.uuid !== record.uuid)
    }
    this.setState({ verify: verify })
@@ -420,6 +469,8 @@
      this.uniqueForm.edit(record)
    } else if (type === 'ordercode') {
      this.orderForm.edit(record)
    } else if (type === 'scripts') {
      this.scriptsForm.edit(record)
    }
  }
@@ -490,6 +541,27 @@
      this.setState({
        verify: verify
      })
    } else if (type === 'scripts') {
      verify.scripts = verify.scripts.filter((item, i) => {
        if (item.uuid === record.uuid) {
          index = i
        }
        return item.uuid !== record.uuid
      })
      if ((index === 0 && direction === 'up') || (index === verify.scripts.length && direction === 'down')) {
        return
      }
      if (direction === 'up') {
        verify.scripts.splice(index - 1, 0, record)
      } else {
        verify.scripts.splice(index + 1, 0, record)
      }
      this.setState({
        verify: verify
      })
    }
  }
@@ -543,7 +615,7 @@
  render() {
    // const { getFieldDecorator } = this.props.form
    const { verify, fields, uniqueColumns, customColumns, orderColumns, orderModular, orderModularDetail, voucher, voucherDetail } = this.state
    const { verify, fields, uniqueColumns, customColumns, orderColumns, scriptsColumns, orderModular, orderModularDetail, voucher, voucherDetail } = this.state
    const formItemLayout = {
      labelCol: {
        xs: { span: 24 },
@@ -641,7 +713,23 @@
            wrappedComponentRef={(inst) => this.voucherForm = inst}
          />
        </TabPane>
        <TabPane tab="信息提示" key="6">
        <TabPane tab="自定义脚本" key="6">
          <CustomScript
            fields={fields}
            dict={this.props.dict}
            scriptsChange={this.scriptsChange}
            wrappedComponentRef={(inst) => this.scriptsForm = inst}
          />
          <Table
            bordered
            rowKey="uuid"
            className="custom-table"
            dataSource={verify.scripts}
            columns={scriptsColumns}
            pagination={false}
          />
        </TabPane>
        <TabPane tab="信息提示" key="7">
          <Form {...formItemLayout}>
            <Row gutter={24}>
              <Col offset={6} span={6}>
src/templates/tableshare/verifycard/index.scss
@@ -15,6 +15,17 @@
        padding-top: 4px;
      }
    }
    .sqlfield {
      .ant-form-item {
        margin-bottom: 5px;
      }
      .ant-col-sm-8 {
        width: 10.5%;
      }
      .ant-col-sm-16 {
        width: 89.5%;
      }
    }
    .add {
      padding-top: 4px;
    }
src/utils/utils.js
@@ -459,8 +459,17 @@
    let primaryKey = setting.primaryKey || 'id' // 主键字段
    // 系统变量声明与设置初始值
    let _sql = `Declare @tbid nvarchar(50), @ErrorCode nvarchar(50),@retmsg nvarchar(4000),@BillCode nvarchar(50),@BVoucher nvarchar(50),@FIBVoucherDate nvarchar(50), @FiYear nvarchar(50)
      Select @BVoucher='',@FIBVoucherDate='',@FiYear=''
    let _sql = `Declare @tbid nvarchar(50),@ErrorCode nvarchar(50),@retmsg nvarchar(4000),@BillCode nvarchar(50),@BVoucher nvarchar(50),@FIBVoucherDate nvarchar(50), @FiYear nvarchar(50)
      `
    if (verify && verify.scripts && verify.scripts.length > 0 && formdata) {
      let _formfields = formdata.filter(form => !['tbid', 'ErrorCode', 'retmsg', 'BillCode', 'BVoucher', 'FIBVoucherDate', 'FiYear'].includes(form.key))
      _formfields = _formfields.map(form => `@${form.key} nvarchar(50)`)
      _formfields = _formfields.join(',')
      _sql += `${_formfields}
        `
    }
    _sql += `Select @BVoucher='',@FIBVoucherDate='',@FiYear=''
      `
    if (verify && verify.accountdate === 'true') { // 启用账期验证
@@ -555,7 +564,7 @@
          let _val = ''
          if (item.linkField === 'BID' && BID) { // 替换bid
            _val = BID
          } else if (data.hasOwnProperty(item.linkField)) {
          } else if (data && data.hasOwnProperty(item.linkField)) {
            _val = data[item.linkField]
          }
          _ModularDetailCode = item.TypeCharOne + _val
@@ -582,7 +591,7 @@
    let _updateconfig = ''
    if (verify && verify.voucher && verify.voucher.enabled) { // 凭证-显示列中选取,必须选行
    if (verify && verify.voucher && verify.voucher.enabled && data) { // 凭证-显示列中选取,必须选行
      let _voucher = verify.voucher
      _updateconfig = ',BVoucher=@BVoucher,FIBVoucherDate=@FIBVoucherDate,FiYear=@FiYear'
@@ -643,9 +652,18 @@
    } else if ((btn.OpenType === 'prompt' || btn.OpenType === 'exec') && btn.sqlType === 'delete') {      // 物理删除
      _sql += `insert into snote (remark,createuserid) select '删除表:${btn.sql} 数据: ${primaryKey}='+@${primaryKey},@userid delete ${btn.sql} where ${primaryKey}=@${primaryKey}`
    }
    _sql += `
      aaa:
      select @ErrorCode as ErrorCode,@retmsg as retmsg
    if (verify && verify.scripts && verify.scripts.length > 0) {
      let _scripts = ''
      verify.scripts.forEach(item => {
        _scripts += `${item.sql}
        `
      })
      _sql += `
        ${_scripts}`
    }
    _sql += `aaa: select @ErrorCode as ErrorCode,@retmsg as retmsg
      `
    console.log(_sql)
    return _sql