import React, {Component} from 'react'
|
import PropTypes from 'prop-types'
|
import { Form, Tabs, Row, Col, Radio, Button, Table, Popconfirm, Icon, notification, Modal, message, InputNumber, Tooltip } from 'antd'
|
import moment from 'moment'
|
|
import Api from '@/api'
|
import Utils from '@/utils/utils.js'
|
|
import UniqueForm from './uniqueform'
|
import ContrastForm from './contrastform'
|
import CustomForm from './customform'
|
import CustomScript from './customscript'
|
import BillcodeForm from './billcodeform'
|
import VoucherForm from './voucherform'
|
import './index.scss'
|
|
const { TabPane } = Tabs
|
|
class VerifyCard extends Component {
|
static propTpyes = {
|
floor: PropTypes.any, // 是否为子表
|
btnTab: PropTypes.any, // 表单标签页(按钮)参数
|
config: PropTypes.any, // 表单标签页参数
|
dict: PropTypes.object, // 字典项
|
card: PropTypes.object,
|
columns: PropTypes.array
|
}
|
|
state = {
|
verify: {},
|
fields: [],
|
usefulfields: '',
|
orderModular: [],
|
orderModularDetail: [],
|
voucher: [],
|
voucherDetail: [],
|
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>)
|
}
|
],
|
contrastColumns: [
|
{
|
title: '内容1',
|
dataIndex: 'frontfield',
|
width: '13%'
|
},
|
{
|
title: '运算符',
|
dataIndex: 'operator',
|
width: '13%'
|
},
|
{
|
title: '内容2',
|
dataIndex: 'backfield',
|
width: '13%',
|
},
|
{
|
title: '提示信息',
|
dataIndex: 'errmsg',
|
width: '13%'
|
},
|
{
|
title: '报错编码',
|
dataIndex: 'errorCode',
|
width: '13%'
|
},
|
{
|
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: '20%',
|
dataIndex: 'operation',
|
render: (text, record) =>
|
(<div>
|
<span className="operation-btn" title={this.props.dict['header.edit']} onClick={() => this.handleEdit(record, 'contrast')} style={{color: '#1890ff'}}><Icon type="edit" /></span>
|
<span className="operation-btn" title={this.props.dict['header.form.up']} onClick={() => this.handleUpDown(record, 'contrast', 'up')} style={{color: '#1890ff'}}><Icon type="arrow-up" /></span>
|
<span className="operation-btn" title={this.props.dict['header.form.down']} onClick={() => this.handleUpDown(record, 'contrast', '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, 'contrast')} 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, 'contrast')
|
}>
|
<span className="operation-btn" style={{color: '#ff4d4f'}}><Icon type="delete" /></span>
|
</Popconfirm>
|
</div>)
|
}
|
],
|
customColumns: [
|
{
|
title: 'SQL',
|
dataIndex: 'sql',
|
width: '45%'
|
},
|
{
|
title: '结果处理',
|
dataIndex: 'resultName',
|
width: '9%'
|
},
|
{
|
title: '提示信息',
|
dataIndex: 'errmsg',
|
width: '13%'
|
},
|
{
|
title: '报错编码',
|
dataIndex: 'errorCode',
|
width: '9%'
|
},
|
{
|
title: '状态',
|
dataIndex: 'status',
|
width: '9%',
|
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: '15%',
|
dataIndex: 'operation',
|
render: (text, record) =>
|
(<div>
|
<span className="operation-btn" title={this.props.dict['header.edit']} onClick={() => this.handleEdit(record, 'customverify')} style={{color: '#1890ff'}}><Icon type="edit" /></span>
|
<span className="operation-btn" title={this.props.dict['header.form.up']} onClick={() => this.handleUpDown(record, 'customverify', 'up')} style={{color: '#1890ff'}}><Icon type="arrow-up" /></span>
|
<span className="operation-btn" title={this.props.dict['header.form.down']} onClick={() => this.handleUpDown(record, 'customverify', '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, 'customverify')} 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, 'customverify')
|
}>
|
<span className="operation-btn" style={{color: '#ff4d4f'}}><Icon type="delete" /></span>
|
</Popconfirm>
|
</div>)
|
}
|
],
|
scriptsColumns: [
|
{
|
title: 'SQL',
|
dataIndex: 'sql',
|
width: '70%'
|
},
|
{
|
title: '状态',
|
dataIndex: 'status',
|
width: '10%',
|
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: '20%',
|
dataIndex: 'operation',
|
render: (text, record) =>
|
(<div>
|
<span className="operation-btn" title={this.props.dict['header.edit']} onClick={() => this.handleEdit(record, 'scripts')} style={{color: '#1890ff'}}><Icon type="edit" /></span>
|
<span className="operation-btn" title={this.props.dict['header.form.up']} onClick={() => this.handleUpDown(record, 'scripts', 'up')} style={{color: '#1890ff'}}><Icon type="arrow-up" /></span>
|
<span className="operation-btn" title={this.props.dict['header.form.down']} onClick={() => this.handleUpDown(record, 'scripts', '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, 'scripts')} 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, 'scripts')
|
}>
|
<span className="operation-btn" style={{color: '#ff4d4f'}}><Icon type="delete" /></span>
|
</Popconfirm>
|
</div>)
|
}
|
],
|
orderColumns: [
|
{
|
title: this.props.dict['header.form.funcvar'],
|
dataIndex: 'fieldName',
|
width: '13%',
|
render: (text, record) => (`${record.fieldName || ''}(${record.field})`)
|
},
|
{
|
title: '类型',
|
dataIndex: 'billType',
|
width: '8%',
|
},
|
{
|
title: '凭证类型',
|
dataIndex: 'ModularCodeName',
|
width: '11%'
|
},
|
{
|
title: '凭证标识',
|
dataIndex: 'ModularDetailCode',
|
width: '11%'
|
},
|
{
|
title: '关联字段',
|
dataIndex: 'linkFieldName',
|
width: '12%',
|
render: (text, record) => (record.linkField ? `${record.linkFieldName || ''}(${record.linkField})` : '')
|
},
|
{
|
title: '位数',
|
dataIndex: 'Type',
|
width: '8%'
|
},
|
{
|
title: '示例',
|
dataIndex: 'example',
|
width: '13%',
|
render: (text, record) => {
|
let _text = ''
|
|
let _type = record.Type
|
if (_type && typeof(_type) === 'string') {
|
_type = parseInt(_type)
|
} else {
|
_type = 4
|
}
|
|
if (record.TypeCharOne === 'n') {
|
_text = record.ModularDetailCode + Array(_type).join('0') + '1'
|
} else if (record.TypeCharOne === 'Y') {
|
_text = record.ModularDetailCode + moment().format('YYYYMMDD') + Array(_type).join('0') + '1'
|
} else if (record.TypeCharOne === 'Lp') {
|
_text = Array(_type).join('0') + '10'
|
} else if (record.TypeCharOne === 'BN') {
|
_text = moment().format('YYYYMMDD') + Array(_type).join('0') + '1'
|
}
|
return _text
|
}
|
},
|
{
|
title: '状态',
|
dataIndex: 'status',
|
width: '9%',
|
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: '15%',
|
dataIndex: 'operation',
|
render: (text, record) =>
|
(<div>
|
<span className="operation-btn" title={this.props.dict['header.edit']} onClick={() => this.handleEdit(record, 'ordercode')} style={{color: '#1890ff'}}><Icon type="edit" /></span>
|
<span className="operation-btn" title={this.props.dict['header.form.up']} onClick={() => this.handleUpDown(record, 'ordercode', 'up')} style={{color: '#1890ff'}}><Icon type="arrow-up" /></span>
|
<span className="operation-btn" title={this.props.dict['header.form.down']} onClick={() => this.handleUpDown(record, 'ordercode', '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, 'ordercode')} 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, 'ordercode')
|
}>
|
<span className="operation-btn" style={{color: '#ff4d4f'}}><Icon type="delete" /></span>
|
</Popconfirm>
|
</div>)
|
}
|
]
|
}
|
|
UNSAFE_componentWillMount() {
|
const { columns, config } = this.props
|
let _verify = this.props.card.verify || {}
|
|
this.setState({
|
verify: {
|
..._verify,
|
default: _verify.default || 'true',
|
invalid: _verify.invalid || 'false',
|
uniques: _verify.uniques || [],
|
contrasts: _verify.contrasts || [],
|
accountdate: _verify.accountdate || 'false',
|
customverifys: _verify.customverifys || [],
|
billcodes: _verify.billcodes || [],
|
voucher: _verify.voucher || {enabled: false},
|
scripts: _verify.scripts || [],
|
}
|
})
|
|
if (this.props.card.btnType) { // 按钮-表单标签页
|
let _fields = []
|
|
config.groups.forEach(group => {
|
_fields.push(...group.sublist)
|
})
|
|
let _usefulfields = ['BID', 'ID', 'LoginUID', 'SessionUid', 'UserID', 'Appkey']
|
_fields.forEach(_f => {
|
if (_f.field) {
|
_usefulfields.push(_f.field)
|
}
|
})
|
|
if (columns && columns.length > 0 && this.props.btnTab.Ot !== 'notRequired') {
|
columns.forEach(_f => {
|
if (_f.field) {
|
_usefulfields.push(_f.field)
|
}
|
})
|
}
|
|
_usefulfields = Array.from(new Set(_usefulfields))
|
_usefulfields = _usefulfields.join(', ')
|
|
this.setState({
|
fields: _fields,
|
usefulfields: _usefulfields
|
})
|
return
|
}
|
if (this.props.card.OpenType === 'pop') {
|
Api.getSystemConfig({
|
func: 'sPC_Get_LongParam',
|
MenuID: this.props.card.uuid
|
}).then(res => {
|
if (res.status) {
|
let _LongParam = ''
|
if (res.LongParam) {
|
try {
|
_LongParam = JSON.parse(window.decodeURIComponent(window.atob(res.LongParam)))
|
} catch (e) {
|
console.warn('Parse Failure')
|
_LongParam = ''
|
}
|
}
|
|
if (!_LongParam) return
|
|
let _fields = []
|
if (_LongParam.groups.length > 0) {
|
_LongParam.groups.forEach(group => {
|
_fields.push(...group.sublist)
|
})
|
} else {
|
_fields = _LongParam.fields
|
}
|
|
let _usefulfields = ['BID', 'ID', 'LoginUID', 'SessionUid', 'UserID', 'Appkey', 'UserName', 'FullName']
|
let hasBid = false
|
|
_fields.forEach(_f => {
|
if (_f.field) {
|
_usefulfields.push(_f.field)
|
}
|
if (_f.field && _f.field.toLowerCase() === 'bid') {
|
hasBid = true
|
}
|
})
|
|
if (this.props.floor === 'subtable' && !hasBid) { // 子表表单中增加BID
|
_fields.unshift({
|
uuid: 'BID',
|
field: 'BID',
|
label: 'BID',
|
type: 'text'
|
})
|
}
|
|
if (columns && columns.length > 0 && this.props.card.Ot !== 'notRequired') {
|
columns.forEach(_f => {
|
if (_f.field) {
|
_usefulfields.push(_f.field)
|
}
|
})
|
}
|
|
_usefulfields = Array.from(new Set(_usefulfields))
|
_usefulfields = _usefulfields.join(', ')
|
|
|
this.setState({
|
fields: _fields,
|
usefulfields: _usefulfields
|
})
|
} else {
|
notification.warning({
|
top: 92,
|
message: res.message,
|
duration: 10
|
})
|
}
|
})
|
} else {
|
let _usefulfields = ['BID', 'ID', 'LoginUID', 'SessionUid', 'UserID', 'Appkey', 'UserName', 'FullName']
|
|
if (columns && columns.length > 0 && this.props.card.Ot !== 'notRequired') {
|
columns.forEach(_f => {
|
if (_f.field) {
|
_usefulfields.push(_f.field)
|
}
|
})
|
}
|
|
_usefulfields = Array.from(new Set(_usefulfields))
|
_usefulfields = _usefulfields.join(', ')
|
|
|
this.setState({
|
usefulfields: _usefulfields
|
})
|
}
|
}
|
|
componentDidMount() {
|
// 获取生成单号一级菜单
|
let defer1 = new Promise(resolve => {
|
let _orderSql = 'select ID,ModularCode+ModularName+ModularNo as NameNO from sModular where deleted=0 order by ID asc'
|
_orderSql = Utils.formatOptions(_orderSql)
|
|
let orderParam = {
|
func: 'sPC_Get_SelectedList',
|
LText: _orderSql,
|
obj_name: 'data',
|
arr_field: 'ID,NameNO'
|
}
|
|
orderParam.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000'
|
orderParam.secretkey = Utils.encrypt(orderParam.LText, orderParam.timestamp)
|
|
Api.getSystemConfig(orderParam).then(res => {
|
if (res.status) {
|
resolve(res)
|
} else {
|
notification.warning({
|
top: 92,
|
message: res.message,
|
duration: 10
|
})
|
}
|
})
|
})
|
|
// 获取生成单号二级菜单
|
let defer2 = new Promise(resolve => {
|
let _orderDetailSql = 'select ModularDetailCode,ModularDetailCode+ModularDetailName as CodeName,BID,Type from sModularDetail where Deleted=0'
|
_orderDetailSql = Utils.formatOptions(_orderDetailSql)
|
|
let orderDetailParam = {
|
func: 'sPC_Get_SelectedList',
|
LText: _orderDetailSql,
|
obj_name: 'data',
|
arr_field: 'ModularDetailCode,CodeName,BID,Type'
|
}
|
|
orderDetailParam.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000'
|
orderDetailParam.secretkey = Utils.encrypt(orderDetailParam.LText, orderDetailParam.timestamp)
|
|
Api.getSystemConfig(orderDetailParam).then(res => {
|
if (res.status) {
|
resolve(res)
|
} else {
|
notification.warning({
|
top: 92,
|
message: res.message,
|
duration: 10
|
})
|
}
|
})
|
})
|
|
Promise.all([defer1, defer2]).then(result => {
|
this.setState({
|
orderModular: result[0].data,
|
orderModularDetail: result[1].data
|
})
|
})
|
|
// 获取凭证二级菜单
|
let defer3 = new Promise(resolve => {
|
let _voucherSql = 'select ID,ModularCode+ModularName+ModularNo as NameNO,TypeCharOne from sModular where deleted=0'
|
_voucherSql = Utils.formatOptions(_voucherSql)
|
|
let voucherParam = {
|
func: 'sPC_Get_SelectedList',
|
LText: _voucherSql,
|
obj_name: 'data',
|
arr_field: 'ID,NameNO,TypeCharOne'
|
}
|
|
voucherParam.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000'
|
voucherParam.secretkey = Utils.encrypt(voucherParam.LText, voucherParam.timestamp)
|
|
Api.getSystemConfig(voucherParam).then(res => {
|
if (res.status) {
|
resolve(res)
|
} else {
|
notification.warning({
|
top: 92,
|
message: res.message,
|
duration: 10
|
})
|
}
|
})
|
})
|
|
// 获取凭证三级菜单
|
let defer4 = new Promise(resolve => {
|
let _voucherDetailSql = 'select ModularDetailCode,ModularDetailCode+ModularDetailName as CodeName,BID, VoucherTypeTwo, IDefine1 from sModularDetail where Deleted=0 and VoucherTypeTwo!=\'\''
|
_voucherDetailSql = Utils.formatOptions(_voucherDetailSql)
|
|
let voucherDetailParam = {
|
func: 'sPC_Get_SelectedList',
|
LText: _voucherDetailSql,
|
obj_name: 'data',
|
arr_field: 'ModularDetailCode,CodeName,BID,VoucherTypeTwo,IDefine1'
|
}
|
|
voucherDetailParam.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000'
|
voucherDetailParam.secretkey = Utils.encrypt(voucherDetailParam.LText, voucherDetailParam.timestamp)
|
|
Api.getSystemConfig(voucherDetailParam).then(res => {
|
if (res.status) {
|
resolve(res)
|
} else {
|
notification.warning({
|
top: 92,
|
message: res.message,
|
duration: 10
|
})
|
}
|
})
|
})
|
|
Promise.all([defer3, defer4]).then(result => {
|
this.setState({
|
voucher: result[0].data,
|
voucherDetail: result[1].data
|
})
|
})
|
}
|
|
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
|
})
|
}
|
|
contrastChange = (values) => {
|
let verify = JSON.parse(JSON.stringify(this.state.verify))
|
|
if (values.uuid) {
|
verify.contrasts = verify.contrasts.map(item => {
|
if (item.uuid === values.uuid) {
|
return values
|
} else {
|
return item
|
}
|
})
|
} else {
|
values.uuid = Utils.getuuid()
|
verify.contrasts.push(values)
|
}
|
|
this.setState({
|
verify: verify
|
})
|
}
|
|
customChange = (values) => {
|
let verify = JSON.parse(JSON.stringify(this.state.verify))
|
|
if (values.uuid) {
|
verify.customverifys = verify.customverifys.map(item => {
|
if (item.uuid === values.uuid) {
|
return values
|
} else {
|
return item
|
}
|
})
|
} else {
|
values.uuid = Utils.getuuid()
|
verify.customverifys.push(values)
|
}
|
|
this.setState({
|
verify: verify
|
})
|
}
|
|
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))
|
|
if (values.uuid) {
|
verify.billcodes = verify.billcodes.map(item => {
|
if (item.uuid === values.uuid) {
|
return values
|
} else {
|
return item
|
}
|
})
|
} else {
|
values.uuid = Utils.getuuid()
|
verify.billcodes.push(values)
|
}
|
|
this.setState({
|
verify: verify
|
})
|
}
|
|
onOptionChange = (e, key) => {
|
const { verify } = this.state
|
let value = e.target.value
|
|
this.setState({
|
verify: {...verify, [key]: value}
|
})
|
}
|
|
handleDelete = (record, type) => {
|
const { verify } = this.state
|
|
if (type === 'customverify') {
|
verify.customverifys = verify.customverifys.filter(item => item.uuid !== record.uuid)
|
} else if (type === 'unique') {
|
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)
|
} else if (type === 'contrast') {
|
verify.contrasts = verify.contrasts.filter(item => item.uuid !== record.uuid)
|
}
|
|
this.setState({ verify: verify })
|
}
|
|
handleEdit = (record, type) => {
|
if (type === 'customverify') {
|
this.customForm.edit(record)
|
} else if (type === 'unique') {
|
this.uniqueForm.edit(record)
|
} else if (type === 'ordercode') {
|
this.orderForm.edit(record)
|
} else if (type === 'scripts') {
|
this.scriptsForm.edit(record)
|
} else if (type === 'contrast') {
|
this.contrastForm.edit(record)
|
}
|
|
let node = document.getElementById('verify-card-box-tab').parentNode
|
|
if (node && node.scrollTop) {
|
let inter = Math.ceil(node.scrollTop / 10)
|
|
let timer = setInterval(() => {
|
if (node.scrollTop - inter > 0) {
|
node.scrollTop = node.scrollTop - inter
|
} else {
|
node.scrollTop = 0
|
clearInterval(timer)
|
}
|
}, 10)
|
}
|
}
|
|
handleStatus = (record, type) => {
|
let verify = JSON.parse(JSON.stringify(this.state.verify))
|
record.status = record.status === 'false' ? 'true' : 'false'
|
|
if (type === 'customverify') {
|
verify.customverifys = verify.customverifys.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 {
|
return item
|
}
|
})
|
} else if (type === 'contrast') {
|
verify.contrasts = verify.contrasts.map(item => {
|
if (item.uuid === record.uuid) {
|
return record
|
} else {
|
return item
|
}
|
})
|
} else if (type === 'ordercode') {
|
verify.billcodes = verify.billcodes.map(item => {
|
if (item.uuid === record.uuid) {
|
return record
|
} else {
|
return item
|
}
|
})
|
} else if (type === 'scripts') {
|
verify.scripts = verify.scripts.map(item => {
|
if (item.uuid === record.uuid) {
|
return record
|
} else {
|
return item
|
}
|
})
|
}
|
|
this.setState({
|
verify: verify
|
})
|
}
|
|
handleUpDown = (record, type, direction) => {
|
let verify = JSON.parse(JSON.stringify(this.state.verify))
|
let index = 0
|
|
if (type === 'customverify') {
|
verify.customverifys = verify.customverifys.filter((item, i) => {
|
if (item.uuid === record.uuid) {
|
index = i
|
}
|
|
return item.uuid !== record.uuid
|
})
|
if ((index === 0 && direction === 'up') || (index === verify.customverifys.length && direction === 'down')) {
|
return
|
}
|
|
if (direction === 'up') {
|
verify.customverifys.splice(index - 1, 0, record)
|
} else {
|
verify.customverifys.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 === 'contrast') {
|
verify.contrasts = verify.contrasts.filter((item, i) => {
|
if (item.uuid === record.uuid) {
|
index = i
|
}
|
|
return item.uuid !== record.uuid
|
})
|
if ((index === 0 && direction === 'up') || (index === verify.contrasts.length && direction === 'down')) {
|
return
|
}
|
|
if (direction === 'up') {
|
verify.contrasts.splice(index - 1, 0, record)
|
} else {
|
verify.contrasts.splice(index + 1, 0, record)
|
}
|
} else if (type === 'ordercode') {
|
verify.billcodes = verify.billcodes.filter((item, i) => {
|
if (item.uuid === record.uuid) {
|
index = i
|
}
|
|
return item.uuid !== record.uuid
|
})
|
if ((index === 0 && direction === 'up') || (index === verify.billcodes.length && direction === 'down')) {
|
return
|
}
|
|
if (direction === 'up') {
|
verify.billcodes.splice(index - 1, 0, record)
|
} else {
|
verify.billcodes.splice(index + 1, 0, record)
|
}
|
} 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
|
})
|
}
|
|
voucherChange = (voucher) => {
|
const { verify } = this.state
|
|
this.setState({
|
verify: {
|
...verify,
|
voucher: voucher
|
}
|
})
|
}
|
|
showError = (errorType) => {
|
if (errorType === 'S') {
|
notification.success({
|
top: 92,
|
message: '执行成功!',
|
duration: 2
|
})
|
} else if (errorType === 'Y') {
|
Modal.success({
|
title: '执行成功!'
|
})
|
} else if (errorType === 'F') {
|
notification.error({
|
className: 'notification-custom-error',
|
top: 92,
|
message: '执行失败!',
|
duration: 15
|
})
|
} else if (errorType === 'N') {
|
notification.error({
|
top: 92,
|
message: '执行失败!',
|
duration: 15
|
})
|
} else if (errorType === 'E') {
|
Modal.error({
|
title: '执行失败!'
|
})
|
} else if (errorType === 'NM') {
|
message.error('执行失败!')
|
}
|
}
|
|
timeChange = (val, type) => {
|
const { verify } = this.state
|
|
this.setState({
|
verify: {...verify, [type]: val}
|
})
|
}
|
|
render() {
|
const { verify, fields, uniqueColumns, contrastColumns, customColumns, orderColumns, scriptsColumns, orderModular, orderModularDetail, voucher, voucherDetail } = this.state
|
const formItemLayout = {
|
labelCol: {
|
xs: { span: 24 },
|
sm: { span: 8 }
|
},
|
wrapperCol: {
|
xs: { span: 24 },
|
sm: { span: 16 }
|
}
|
}
|
|
return (
|
<div id="verify-card-box-tab">
|
<Tabs defaultActiveKey="1" className="verify-card-box">
|
<TabPane tab="基础验证" key="1">
|
<Form {...formItemLayout}>
|
<Row gutter={24}>
|
<Col span={8}>
|
<Form.Item label={
|
<Tooltip placement="bottomLeft" title={'默认sql执行顺序为自定义脚本之前'}>
|
<Icon type="question-circle" style={{color: '#c49f47', marginRight: '5px'}} />
|
默认sql
|
</Tooltip>
|
}>
|
<Radio.Group value={verify.default} onChange={(e) => {this.onOptionChange(e, 'default')}}>
|
<Radio value="true">执行</Radio>
|
<Radio value="false">不执行</Radio>
|
</Radio.Group>
|
</Form.Item>
|
</Col>
|
<Col span={8}>
|
<Form.Item label={'账期验证'}>
|
<Radio.Group value={verify.accountdate} onChange={(e) => {this.onOptionChange(e, 'accountdate')}}>
|
<Radio value="true">开启</Radio>
|
<Radio value="false">不开启</Radio>
|
</Radio.Group>
|
</Form.Item>
|
</Col>
|
<Col span={8}>
|
<Form.Item label={'失效验证'}>
|
<Radio.Group value={verify.invalid} onChange={(e) => {this.onOptionChange(e, 'invalid')}}>
|
<Radio value="true">开启</Radio>
|
<Radio value="false">不开启</Radio>
|
</Radio.Group>
|
</Form.Item>
|
</Col>
|
</Row>
|
</Form>
|
</TabPane>
|
<TabPane tab="比较验证" key="2x">
|
<ContrastForm
|
dict={this.props.dict}
|
contrastChange={this.contrastChange}
|
wrappedComponentRef={(inst) => this.contrastForm = inst}
|
/>
|
<Table
|
bordered
|
rowKey="uuid"
|
className="custom-table"
|
dataSource={verify.contrasts}
|
columns={contrastColumns}
|
pagination={false}
|
/>
|
</TabPane>
|
<TabPane tab="唯一性验证" key="2">
|
<UniqueForm
|
fields={fields}
|
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>
|
<TabPane tab="自定义验证" key="3">
|
<CustomForm
|
dict={this.props.dict}
|
usefulfields={this.state.usefulfields}
|
customChange={this.customChange}
|
wrappedComponentRef={(inst) => this.customForm = inst}
|
/>
|
<Table
|
bordered
|
rowKey="uuid"
|
className="custom-table"
|
dataSource={verify.customverifys}
|
columns={customColumns}
|
pagination={false}
|
/>
|
</TabPane>
|
<TabPane tab="单号生成" key="4">
|
<BillcodeForm
|
fields={fields}
|
btn={this.props.card}
|
billcodes={verify.billcodes}
|
columns={this.props.columns}
|
dict={this.props.dict}
|
modular={orderModular}
|
modularDetail={orderModularDetail}
|
orderChange={this.orderChange}
|
wrappedComponentRef={(inst) => this.orderForm = inst}
|
/>
|
<Table
|
bordered
|
rowKey="uuid"
|
className="custom-table"
|
dataSource={verify.billcodes}
|
columns={orderColumns}
|
pagination={false}
|
/>
|
</TabPane>
|
<TabPane tab="创建凭证" key="5">
|
<VoucherForm
|
dict={this.props.dict}
|
voucher={voucher}
|
columns={this.props.columns}
|
voucherobj={verify.voucher}
|
voucherDetail={voucherDetail}
|
voucherChange={this.voucherChange}
|
wrappedComponentRef={(inst) => this.voucherForm = inst}
|
/>
|
</TabPane>
|
<TabPane tab="自定义脚本" key="6">
|
<CustomScript
|
usefulfields={this.state.usefulfields}
|
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}>
|
<Form.Item label={'提示编码'}>
|
<span className="errorval"> S </span>
|
<Button onClick={() => {this.showError('S')}} type="primary" size="small">
|
查看
|
</Button>
|
</Form.Item>
|
</Col>
|
<Col span={8}>
|
<Form.Item label={'停留时间'}>
|
<InputNumber defaultValue={verify.stime || 2} min={1} max={10000} precision={0} onChange={(val) => {this.timeChange(val, 'stime')}} />
|
</Form.Item>
|
</Col>
|
</Row>
|
<Row gutter={24}>
|
<Col offset={6} span={6}>
|
<Form.Item label={'提示编码'}>
|
<span className="errorval"> Y </span>
|
<Button onClick={() => {this.showError('Y')}} type="primary" size="small">
|
查看
|
</Button>
|
</Form.Item>
|
</Col>
|
</Row>
|
<Row gutter={24}>
|
<Col offset={6} span={6}>
|
<Form.Item label={'提示编码'}>
|
<span className="errorval"> N </span>
|
<Button onClick={() => {this.showError('N')}} type="primary" size="small">
|
查看
|
</Button>
|
</Form.Item>
|
</Col>
|
<Col span={8}>
|
<Form.Item label={'停留时间'}>
|
<InputNumber defaultValue={verify.ntime || 15} min={1} max={10000} precision={0} onChange={(val) => {this.timeChange(val, 'ntime')}} />
|
</Form.Item>
|
</Col>
|
</Row>
|
<Row gutter={24}>
|
<Col offset={6} span={6}>
|
<Form.Item label={'提示编码'}>
|
<span className="errorval"> F </span>
|
<Button onClick={() => {this.showError('F')}} type="primary" size="small">
|
查看
|
</Button>
|
</Form.Item>
|
</Col>
|
<Col span={8}>
|
<Form.Item label={'停留时间'}>
|
<InputNumber defaultValue={verify.ftime || 15} min={1} max={10000} precision={0} onChange={(val) => {this.timeChange(val, 'ftime')}} />
|
</Form.Item>
|
</Col>
|
</Row>
|
<Row gutter={24}>
|
<Col offset={6} span={6}>
|
<Form.Item label={'提示编码'}>
|
<span className="errorval"> E </span>
|
<Button onClick={() => {this.showError('E')}} type="primary" size="small">
|
查看
|
</Button>
|
</Form.Item>
|
</Col>
|
</Row>
|
<Row gutter={24}>
|
<Col offset={6} span={6}>
|
<Form.Item label={'提示编码'}>
|
<span className="errorval"> NM </span>
|
<Button onClick={() => {this.showError('NM')}} type="primary" size="small">
|
查看
|
</Button>
|
</Form.Item>
|
</Col>
|
</Row>
|
<Row gutter={24}>
|
<Col offset={6} span={6}>
|
<Form.Item label={'提示编码'}>
|
<span className="errorval"> -1 </span>
|
不提示
|
</Form.Item>
|
</Col>
|
</Row>
|
</Form>
|
</TabPane>
|
</Tabs>
|
</div>
|
)
|
}
|
}
|
|
export default Form.create()(VerifyCard)
|