import React, {Component} from 'react'
|
import PropTypes from 'prop-types'
|
import { is, fromJS } from 'immutable'
|
import { Form, Tabs, Row, Col, Button, Popconfirm, notification, Modal, message, InputNumber, Typography } from 'antd'
|
import { CheckCircleOutlined, StopOutlined, EditOutlined, SwapOutlined, DeleteOutlined, ExclamationOutlined } from '@ant-design/icons'
|
import Toast from 'antd-mobile/es/components/toast'
|
import Dialog from 'antd-mobile/es/components/dialog'
|
import moment from 'moment'
|
|
import Api from '@/api'
|
import Utils from '@/utils/utils.js'
|
import BaseForm from './baseform'
|
import UniqueForm from './uniqueform'
|
import ContrastForm from './contrastform'
|
import CustomForm from './customform'
|
import CustomScript from './customscript'
|
import CallBackCustomScript from './callbackcustomscript'
|
import BillcodeForm from './billcodeform'
|
import VoucherForm from './voucherform'
|
import asyncComponent from '@/utils/asyncComponent'
|
import { updateForm } from '@/utils/utils-update.js'
|
import MKEmitter from '@/utils/events.js'
|
import './index.scss'
|
|
const { TabPane } = Tabs
|
const { confirm } = Modal
|
const { Paragraph } = Typography
|
const EditTable = asyncComponent(() => import('@/templates/zshare/editTable'))
|
const FullScripts = asyncComponent(() => import('./fullScripts'))
|
|
class VerifyCard extends Component {
|
static propTpyes = {
|
btnTab: PropTypes.any, // 表单标签页(按钮)参数
|
config: PropTypes.any, // 表单标签页参数
|
card: PropTypes.object, // 按钮信息
|
columns: PropTypes.array
|
}
|
|
state = {
|
initsql: '', // sql验证时变量声明及赋值
|
verifyInter: 'system', // 接口类型
|
activeKey: 'base',
|
appType: sessionStorage.getItem('appType'),
|
notes: [], // 短信模板
|
setting: null,
|
verify: {},
|
fields: [],
|
usefulfields: '',
|
defaultsql: '', // 默认Sql
|
orderModular: [],
|
orderModularDetail: [],
|
voucher: [],
|
voucherDetail: [],
|
systemScripts: [],
|
columnsFields: [],
|
unionFields: [],
|
uniqueFields: [], // 唯一性验证,表单字段
|
uniqueColumns: [
|
{
|
title: '名称',
|
dataIndex: 'fieldlabel',
|
width: '20%'
|
},
|
{
|
title: '字段',
|
dataIndex: 'field',
|
width: '20%',
|
editable: true,
|
inputType: 'multiStr',
|
options: []
|
},
|
{
|
title: '报错编码',
|
dataIndex: 'errorCode',
|
width: '13%',
|
editable: true,
|
inputType: 'select',
|
options: [
|
{ value: 'E', text: 'E' },
|
{ value: 'N', text: 'N' },
|
{ value: 'F', text: 'F' },
|
{ value: 'NM', text: 'NM' }
|
]
|
},
|
{
|
title: '验证类型',
|
dataIndex: 'verifyType',
|
width: '14%',
|
render: (text, record) => record.verifyType === 'logic' ? '逻辑验证' : '物理验证',
|
inputType: 'select',
|
editable: true,
|
options: [
|
{ value: 'physical', text: '物理验证' },
|
{ value: 'logic', text: '逻辑验证' }
|
]
|
},
|
{
|
title: '是否启用',
|
dataIndex: 'status',
|
width: '14%',
|
editable: true,
|
required: false,
|
inputType: 'switch',
|
render: (text, record) => record.status === 'false' ?
|
(
|
<div style={{color: '#ff4d4f'}}>
|
禁用
|
<StopOutlined style={{marginLeft: '5px'}} />
|
</div>
|
) :
|
(
|
<div style={{color: '#26C281'}}>
|
启用
|
<CheckCircleOutlined style={{marginLeft: '5px'}}/>
|
</div>
|
)
|
}
|
],
|
onceUniqueColumns: [
|
{
|
title: '名称',
|
dataIndex: 'fieldlabel',
|
width: '30%'
|
},
|
{
|
title: '字段',
|
dataIndex: 'field',
|
width: '30%',
|
editable: true,
|
inputType: 'multiStr',
|
options: []
|
},
|
{
|
title: '是否启用',
|
dataIndex: 'status',
|
width: '20%',
|
editable: true,
|
required: false,
|
inputType: 'switch',
|
render: (text, record) => record.status === 'false' ?
|
(
|
<div style={{color: '#ff4d4f'}}>
|
禁用
|
<StopOutlined style={{marginLeft: '5px'}} />
|
</div>
|
) :
|
(
|
<div style={{color: '#26C281'}}>
|
启用
|
<CheckCircleOutlined style={{marginLeft: '5px'}}/>
|
</div>
|
)
|
},
|
],
|
contrastColumns: [
|
{
|
title: '内容1',
|
dataIndex: 'frontfield',
|
width: '14%',
|
inputType: 'input',
|
editable: true
|
},
|
{
|
title: '运算符',
|
dataIndex: 'operator',
|
width: '14%',
|
editable: true,
|
inputType: 'select',
|
options: [
|
{ value: '=', text: '=' },
|
{ value: '!=', text: '!=' },
|
{ value: '>', text: '>' },
|
{ value: '<', text: '<' },
|
{ value: '>=', text: '>=' },
|
{ value: '<=', text: '<=' },
|
{ value: 'in', text: 'in' },
|
{ value: 'like', text: 'like' }
|
]
|
},
|
{
|
title: '内容2',
|
dataIndex: 'backfield',
|
width: '14%',
|
inputType: 'input',
|
editable: true
|
},
|
{
|
title: '提示信息',
|
dataIndex: 'errmsg',
|
width: '14%',
|
inputType: 'input',
|
editable: true
|
},
|
{
|
title: '报错编码',
|
dataIndex: 'errorCode',
|
width: '14%',
|
editable: true,
|
inputType: 'select',
|
options: [
|
{ value: 'E', text: 'E' },
|
{ value: 'N', text: 'N' },
|
{ value: 'F', text: 'F' },
|
{ value: 'NM', text: 'NM' }
|
]
|
},
|
{
|
title: '是否启用',
|
dataIndex: 'status',
|
width: '13%',
|
editable: true,
|
required: false,
|
inputType: 'switch',
|
render: (text, record) => record.status === 'false' ?
|
(
|
<div style={{color: '#ff4d4f'}}>
|
禁用
|
<StopOutlined style={{marginLeft: '5px'}} />
|
</div>
|
) :
|
(
|
<div style={{color: '#26C281'}}>
|
启用
|
<CheckCircleOutlined style={{marginLeft: '5px'}}/>
|
</div>
|
)
|
}
|
],
|
customColumns: [
|
{
|
title: 'SQL',
|
dataIndex: 'sql',
|
width: '45%',
|
render: (text) => {
|
let title = text.match(/^\s*\/\*.+\*\//)
|
title = title && title[0] ? title[0] : ''
|
let _text = title ? text.replace(title, '') : text
|
|
return (
|
<div>
|
{title ? <span style={{color: '#a50'}}>{title}<span style={{fontSize: '12px', marginLeft: '5px'}}>{_text.length}</span></span> : null}
|
<Paragraph copyable={{ text: text }} ellipsis={{ rows: 4, expandable: true }}>{_text}</Paragraph>
|
</div>
|
)
|
}
|
},
|
{
|
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 style={{color: '#ff4d4f'}}>
|
禁用
|
<StopOutlined style={{marginLeft: '5px'}} />
|
</div>
|
) :
|
(
|
<div style={{color: '#26C281'}}>
|
启用
|
<CheckCircleOutlined style={{marginLeft: '5px'}}/>
|
</div>
|
)
|
},
|
{
|
title: '操作',
|
align: 'center',
|
width: '15%',
|
dataIndex: 'operation',
|
render: (text, record) =>
|
(<div style={{textAlign: 'center'}}>
|
<span className="operation-btn" title="编辑" onClick={() => this.handleEdit(record, 'customverify')} style={{color: '#1890ff'}}><EditOutlined /></span>
|
<span className="operation-btn" title="状态切换" onClick={() => this.handleStatus(record, 'customverify')} style={{color: '#8E44AD'}}><SwapOutlined /></span>
|
<Popconfirm
|
overlayClassName="popover-confirm"
|
title="确定删除吗?"
|
onConfirm={() => this.handleDelete(record, 'customverify')
|
}>
|
<span className="operation-btn" style={{color: '#ff4d4f'}}><DeleteOutlined /></span>
|
</Popconfirm>
|
</div>)
|
}
|
],
|
scriptsColumns: [
|
{
|
title: 'SQL',
|
dataIndex: 'sql',
|
width: '60%',
|
render: (text) => {
|
let title = text.match(/^\s*\/\*.+\*\//)
|
title = title && title[0] ? title[0] : ''
|
let _text = title ? text.replace(title, '') : text
|
|
return (
|
<div>
|
{title ? <span style={{color: '#a50'}}>{title}<span style={{fontSize: '12px', marginLeft: '5px'}}>{_text.length}</span></span> : null}
|
<Paragraph copyable={{ text: text }} ellipsis={{ rows: 4, expandable: true }}>{_text}</Paragraph>
|
</div>
|
)
|
}
|
},
|
{
|
title: '执行位置',
|
dataIndex: 'position',
|
width: '10%',
|
render: (text, record) => {
|
if (record.position === 'init') {
|
return <span style={{color: 'orange'}}>初始化</span>
|
} else if (record.position === 'front') {
|
return <span style={{color: '#26C281'}}>sql前</span>
|
} else {
|
return <span style={{color: '#1890ff'}}>sql后</span>
|
}
|
}
|
},
|
{
|
title: '状态',
|
dataIndex: 'status',
|
width: '10%',
|
render: (text, record) => record.status === 'false' ?
|
(
|
<div style={{color: '#ff4d4f'}}>
|
禁用
|
<StopOutlined style={{marginLeft: '5px'}} />
|
</div>
|
) :
|
(
|
<div style={{color: '#26C281'}}>
|
启用
|
<CheckCircleOutlined style={{marginLeft: '5px'}}/>
|
</div>
|
)
|
},
|
{
|
title: '操作',
|
align: 'center',
|
width: '140px',
|
dataIndex: 'operation',
|
render: (text, record) =>
|
(<div style={{textAlign: 'center'}}>
|
<span className="operation-btn" title="编辑" onClick={() => this.handleEdit(record, 'scripts')} style={{color: '#1890ff'}}><EditOutlined /></span>
|
<span className="operation-btn" title="状态切换" onClick={() => this.handleStatus(record, 'scripts')} style={{color: '#8E44AD'}}><SwapOutlined /></span>
|
<Popconfirm
|
overlayClassName="popover-confirm"
|
title="确定删除吗?"
|
onConfirm={() => this.handleDelete(record, 'scripts')
|
}>
|
<span className="operation-btn" style={{color: '#ff4d4f'}}><DeleteOutlined /></span>
|
</Popconfirm>
|
</div>)
|
}
|
],
|
cbScriptsColumns: [
|
{
|
title: 'SQL',
|
dataIndex: 'sql',
|
width: '60%',
|
render: (text) => {
|
let title = text.match(/^\s*\/\*.+\*\//)
|
title = title && title[0] ? title[0] : ''
|
let _text = title ? text.replace(title, '') : text
|
|
return (
|
<div>
|
{title ? <span style={{color: '#a50'}}>{title}<span style={{fontSize: '12px', marginLeft: '5px'}}>{_text.length}</span></span> : null}
|
<Paragraph copyable={{ text: text }} ellipsis={{ rows: 4, expandable: true }}>{_text}</Paragraph>
|
</div>
|
)
|
}
|
},
|
{
|
title: '执行位置',
|
dataIndex: 'position',
|
width: '10%',
|
render: (text, record) => {
|
if (record.position === 'front') {
|
return <span style={{color: '#26C281'}}>sql前</span>
|
} else {
|
return <span style={{color: '#1890ff'}}>sql后</span>
|
}
|
}
|
},
|
{
|
title: '状态',
|
dataIndex: 'status',
|
width: '10%',
|
render: (text, record) => record.status === 'false' ?
|
(
|
<div style={{color: '#ff4d4f'}}>
|
禁用
|
<StopOutlined style={{marginLeft: '5px'}} />
|
</div>
|
) :
|
(
|
<div style={{color: '#26C281'}}>
|
启用
|
<CheckCircleOutlined style={{marginLeft: '5px'}}/>
|
</div>
|
)
|
},
|
{
|
title: '操作',
|
align: 'center',
|
width: '20%',
|
dataIndex: 'operation',
|
render: (text, record) =>
|
(<div style={{textAlign: 'center'}}>
|
<span className="operation-btn" title="编辑" onClick={() => this.handleEdit(record, 'cbscripts')} style={{color: '#1890ff'}}><EditOutlined /></span>
|
<span className="operation-btn" title="状态切换" onClick={() => this.handleStatus(record, 'cbscripts')} style={{color: '#8E44AD'}}><SwapOutlined /></span>
|
<Popconfirm
|
overlayClassName="popover-confirm"
|
title="确定删除吗?"
|
onConfirm={() => this.handleDelete(record, 'cbscripts')
|
}>
|
<span className="operation-btn" style={{color: '#ff4d4f'}}><DeleteOutlined /></span>
|
</Popconfirm>
|
</div>)
|
}
|
],
|
orderColumns: [
|
{
|
title: '函数变量',
|
dataIndex: 'fieldName',
|
width: '12%',
|
render: (text, record) => (`${record.fieldName || ''}(${record.field})`)
|
},
|
{
|
title: '类型',
|
dataIndex: 'billType',
|
width: '6%',
|
},
|
{
|
title: '凭证类型',
|
dataIndex: 'ModularCodeName',
|
width: '11%'
|
},
|
{
|
title: '凭证标识',
|
dataIndex: 'ModularDetailCode',
|
width: '11%'
|
},
|
{
|
title: '关联字段',
|
dataIndex: 'linkFieldName',
|
width: '10%',
|
render: (text, record) => (record.linkField ? `${record.linkFieldName || ''}(${record.linkField})` : '')
|
},
|
{
|
title: '位数',
|
dataIndex: 'Type',
|
width: '6%'
|
},
|
{
|
title: '示例',
|
dataIndex: 'example',
|
width: '13%',
|
render: (text, record) => {
|
let _text = ''
|
|
let _type = record.Type
|
if (_type && typeof(_type) === 'string') {
|
_type = parseInt(_type)
|
} else if (!_type) {
|
_type = 4
|
}
|
|
if (record.TypeCharOne === 'n') {
|
_text = record.ModularDetailCode + Array(_type).join('0') + '1'
|
} else if (record.TypeCharOne === 'Y') {
|
_text = record.ModularDetailCode + moment().format('YYMMDD') + Array(_type).join('0') + '1'
|
} else if (record.TypeCharOne === 'Lp') {
|
_text = Array(_type).join('0') + '10'
|
} else if (record.TypeCharOne === 'BN') {
|
_text = moment().format('YYMMDD') + Array(_type).join('0') + '1'
|
}
|
return _text
|
}
|
},
|
{
|
title: '标识',
|
dataIndex: 'mark',
|
width: '8%'
|
},
|
{
|
title: '状态',
|
dataIndex: 'status',
|
width: '8%',
|
render: (text, record) => record.status === 'false' ?
|
(
|
<div style={{color: '#ff4d4f'}}>
|
禁用
|
<StopOutlined style={{marginLeft: '5px'}} />
|
</div>
|
) :
|
(
|
<div style={{color: '#26C281'}}>
|
启用
|
<CheckCircleOutlined style={{marginLeft: '5px'}}/>
|
</div>
|
)
|
},
|
{
|
title: '操作',
|
align: 'center',
|
width: '15%',
|
dataIndex: 'operation',
|
render: (text, record) =>
|
(<div style={{textAlign: 'center'}}>
|
<span className="operation-btn" title="编辑" onClick={() => this.handleEdit(record, 'ordercode')} style={{color: '#1890ff'}}><EditOutlined /></span>
|
<span className="operation-btn" title="状态切换" onClick={() => this.handleStatus(record, 'ordercode')} style={{color: '#8E44AD'}}><SwapOutlined /></span>
|
<Popconfirm
|
overlayClassName="popover-confirm"
|
title="确定删除吗?"
|
onConfirm={() => this.handleDelete(record, 'ordercode')
|
}>
|
<span className="operation-btn" style={{color: '#ff4d4f'}}><DeleteOutlined /></span>
|
</Popconfirm>
|
</div>)
|
}
|
]
|
}
|
|
UNSAFE_componentWillMount() {
|
const { columns, config, card, btnTab } = this.props
|
const { appType } = this.state
|
let _verify = fromJS(card.verify || {}).toJS()
|
|
let _invalid = _verify.invalid
|
|
if (!_invalid) { // 选择行时,失效验证默认开启
|
if (config.setting && config.setting.maxScript && config.setting.maxScript >= 300) {
|
_invalid = 'false'
|
} else {
|
_invalid = card.Ot !== 'notRequired' ? 'true' : 'false'
|
}
|
}
|
if (card.sqlType === 'custom') { // 自定义验证时,不使用默认sql
|
_verify.default = 'false'
|
}
|
|
_verify.default = _verify.default || 'true'
|
_verify.wxNote = _verify.wxNote || 'false' // 公众号消息推送是否开启
|
_verify.noteEnable = _verify.noteEnable || 'false' // 短信发送是否开启
|
_verify.printEnable = _verify.printEnable || 'false' // 单据打印是否开启
|
_verify.noteType = _verify.noteType || 'N' // 短信发送模式:Y(实时)、N(定时)
|
_verify.noteTemp = _verify.noteTemp || 'Y' // 短信发送模板:Y(相同)、N(不同)
|
_verify.invalid = _invalid
|
_verify.uniques = _verify.uniques || []
|
_verify.contrasts = _verify.contrasts || []
|
_verify.accountdate = _verify.accountdate || 'false'
|
_verify.accountfield = _verify.accountfield || ''
|
_verify.voucherdate = _verify.voucherdate || ''
|
_verify.customverifys = _verify.customverifys || []
|
_verify.billcodes = _verify.billcodes || []
|
_verify.voucher = _verify.voucher || {enabled: false}
|
_verify.scripts = _verify.scripts || []
|
_verify.cbScripts = _verify.cbScripts || []
|
|
if (appType === 'mob') {
|
_verify.printEnable = 'false'
|
_verify.printTempId = ''
|
}
|
|
if (window.GLOB.funcs && window.GLOB.funcs.length > 0) {
|
window.GLOB.funcs.forEach(m => {
|
let reg = new RegExp(`\\/\\*\\$ex@${m.func_code}-begin\\*\\/[\\s\\S]+\\/\\*@ex\\$-end\\*\\/`, 'ig')
|
_verify.customverifys.forEach(item => {
|
item.sql = item.sql.replace(reg, `$ex@${m.func_code}@ex$`)
|
})
|
_verify.scripts.forEach(item => {
|
item.sql = item.sql.replace(reg, `$ex@${m.func_code}@ex$`)
|
})
|
_verify.cbScripts.forEach(item => {
|
item.sql = item.sql.replace(reg, `$ex@${m.func_code}@ex$`)
|
})
|
})
|
}
|
|
_verify.customverifys.forEach((item, i) => {
|
item.$index = i + 1
|
})
|
_verify.scripts.forEach((item, i) => {
|
item.$index = i + 1
|
})
|
_verify.cbScripts.forEach((item, i) => {
|
item.$index = i + 1
|
})
|
|
let verifyInter = card.intertype === 'system' || card.procMode === 'system' ? 'system' : 'inner'
|
let activeKey = verifyInter === 'system' || card.intertype === 'inner' ? 'base' : 'tip'
|
|
if (card.callbackType === 'script') {
|
activeKey = 'cbScripts'
|
}
|
|
this.setState({
|
activeKey: activeKey,
|
verifyInter: verifyInter,
|
setting: config.setting || {},
|
verify: _verify,
|
oriVerify: fromJS(_verify).toJS()
|
})
|
|
if (config.Template !== 'FormTab' && card.intertype === 'inner') {
|
return
|
}
|
|
new Promise(resolve => {
|
let _fields = []
|
if (card.OpenType === 'form') {
|
_fields.push({
|
field: card.field,
|
label: card.label,
|
type: 'text'
|
})
|
resolve(_fields)
|
} else if (config.Template === 'FormTab') {
|
config.groups.forEach(group => {
|
_fields.push(...group.sublist)
|
})
|
resolve(_fields)
|
} else if (card.modal && (card.OpenType === 'pop' || !card.OpenType)) {
|
_fields = card.modal.fields || []
|
resolve(_fields)
|
} else if (card.OpenType === 'pop') {
|
Api.getCloudConfig({
|
func: 'sPC_Get_LongParam',
|
MenuID: 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) {
|
message.warning('未获取到表单信息,部分验证将无法设置!')
|
} else {
|
_LongParam = updateForm(_LongParam)
|
_fields = _LongParam.fields || []
|
}
|
} else {
|
notification.warning({
|
top: 92,
|
message: res.message,
|
duration: 5
|
})
|
}
|
resolve(_fields)
|
})
|
} else {
|
resolve(_fields)
|
}
|
}).then(_fields => {
|
let _usefulfields = ['UserName', 'FullName', 'RoleID', 'mk_departmentcode', 'mk_organization', 'mk_user_type', 'mk_nation', 'mk_province', 'mk_city', 'mk_district', 'mk_address', 'BillCode', 'BVoucher', 'FIBVoucherDate', 'FiYear', 'ModularDetailCode', 'tbid', 'mk_deleted']
|
let _declare = ['@UserName nvarchar(50)', '@FullName nvarchar(50)', '@RoleID nvarchar(512)', '@mk_departmentcode nvarchar(512)', '@mk_organization nvarchar(512)', '@mk_user_type nvarchar(20)', '@mk_nation nvarchar(50)', '@mk_province nvarchar(50)', '@mk_city nvarchar(50)', '@mk_district nvarchar(50)', '@mk_address nvarchar(100)', '@ErrorCode nvarchar(50)', '@retmsg nvarchar(4000)', '@BillCode nvarchar(50)', '@BVoucher nvarchar(50)', '@FIBVoucherDate nvarchar(50)', '@FiYear nvarchar(50)', '@ModularDetailCode nvarchar(50)', '@bid nvarchar(50)', '@tbid nvarchar(50)', '@mk_deleted int']
|
let _select = ['@UserName=\'\'', '@FullName=\'\'', '@RoleID=\'\'', '@mk_departmentcode=\'\'', '@mk_organization=\'\'', '@mk_user_type=\'\'', '@mk_nation=\'\'', '@mk_province=\'\'', '@mk_city=\'\'', '@mk_district=\'\'', '@mk_address=\'\'', '@ErrorCode=\'\'', '@retmsg=\'\'', '@BillCode=\'\'', '@BVoucher=\'\'', '@FIBVoucherDate=\'\'', '@FiYear=\'\'', '@ModularDetailCode=\'\'', '@bid=\'\'', '@mk_deleted=1']
|
let fieldArr = _usefulfields.map(_f => _f.toLowerCase())
|
let hasBid = false
|
|
_usefulfields = []
|
|
fieldArr.push('bid')
|
|
let verIndex = _fields.findIndex(item => item.type === 'vercode')
|
if (verIndex > -1) {
|
_fields = fromJS(_fields).toJS()
|
_fields.splice(verIndex, 0, {
|
type: 'text',
|
fieldlength: 50,
|
writein: 'false',
|
field: 'mk_timestamp'
|
}, {
|
type: 'text',
|
fieldlength: 50,
|
writein: 'false',
|
field: 'mk_send_type'
|
}, {
|
type: 'text',
|
fieldlength: 50,
|
writein: 'false',
|
field: 'mk_n_id'
|
})
|
}
|
|
_fields = _fields.filter(_f => _f.field)
|
_fields.forEach(_f => {
|
if (_f.field.toLowerCase() === 'bid') {
|
hasBid = true
|
}
|
|
if (fieldArr.includes(_f.field.toLowerCase())) return
|
|
fieldArr.push(_f.field.toLowerCase())
|
|
_usefulfields.push(_f.field)
|
|
let _fieldlen = _f.fieldlength || 50
|
|
if (_f.type === 'number') {
|
_fieldlen = _f.decimal ? _f.decimal : 0
|
}
|
|
if (_fieldlen > 2048) {
|
_fieldlen = 'max'
|
}
|
|
let _type = `nvarchar(${_fieldlen})`
|
|
if (_f.type.match(/date/ig)) {
|
_type = 'datetime'
|
_select.push(`@${_f.field}='1949-10-01'`)
|
} else if (_f.type === 'number') {
|
_type = `decimal(18,${_fieldlen})`
|
_select.push(`@${_f.field}=0`)
|
} else if (_f.type === 'rate') {
|
_type = `decimal(18,2)`
|
_select.push(`@${_f.field}=0`)
|
} else {
|
_select.push(`@${_f.field}=''`)
|
}
|
|
_declare.push(`@${_f.field} ${_type}`)
|
})
|
|
let uniqueFields = fromJS(_fields).toJS()
|
|
if (!hasBid) { // 唯一性验证添加BID
|
uniqueFields.unshift({ uuid: 'BID', field: 'BID', label: 'BID', type: 'text' })
|
_fields.unshift({ uuid: 'BID', field: 'BID', label: 'BID', type: 'text' })
|
}
|
|
let hasColumn = false
|
if (columns && columns.length > 0) {
|
if (btnTab) { // 表单标签
|
hasColumn = btnTab.Ot !== 'notRequired'
|
} else if (card.Ot !== 'notRequired') {
|
hasColumn = true
|
}
|
}
|
|
let unionFields = fromJS(_fields).toJS()
|
let formArr = _fields.map(_f => _f.field.toLowerCase())
|
|
if (hasColumn) {
|
columns.forEach(_f => {
|
if (_f.field && !formArr.includes(_f.field.toLowerCase())) {
|
formArr.push(_f.field.toLowerCase())
|
unionFields.push(_f)
|
}
|
if (!_f.field || fieldArr.includes(_f.field.toLowerCase())) return
|
|
fieldArr.push(_f.field.toLowerCase())
|
_usefulfields.push(_f.field)
|
|
if (_f.datatype) { // 自定义字段
|
if (/decimal/ig.test(_f.datatype)) {
|
_select.push(`@${_f.field}=0`)
|
} else {
|
_select.push(`@${_f.field}=''`)
|
}
|
|
_declare.push(`@${_f.field} ${_f.datatype}`)
|
return
|
}
|
|
let _fieldlen = _f.fieldlength || 50
|
|
if (_fieldlen > 2048) {
|
_fieldlen = 'max'
|
}
|
|
let _type = `nvarchar(${_fieldlen})`
|
|
if (_f.type === 'number') {
|
_type = `decimal(18,${_f.decimal ? _f.decimal : 0})`
|
} else if (_f.type === 'picture' || _f.type === 'textarea') {
|
_type = `nvarchar(${_fieldlen})`
|
}
|
|
if (_f.type === 'number') {
|
_select.push(`@${_f.field}=0`)
|
} else {
|
_select.push(`@${_f.field}=''`)
|
}
|
|
_declare.push(`@${_f.field} ${_type}`)
|
})
|
}
|
|
let _sql = `Declare ${_declare.join(', ')}
|
Select ${_select.join(', ')}
|
`
|
|
// 默认sql
|
let _defaultsql = ''
|
let _insertsql = ''
|
let _updatesql = ''
|
let _primaryKey = config.setting.primaryKey || 'id'
|
|
if (this.props.side === 'sub') {
|
_primaryKey = config.setting.subKey || 'id'
|
}
|
|
if (card.sqlType === 'insert' || card.sqlType === 'insertOrUpdate') {
|
let keys = []
|
let values = []
|
|
_fields.forEach(item => {
|
if (!item.field || item.writein === 'false') return
|
|
keys.push(item.field.toLowerCase())
|
|
if (item.field.toLowerCase() === 'bid' && item.uuid === 'BID') {
|
values.push('@BID@')
|
} else {
|
values.push('@' + item.field)
|
}
|
})
|
|
if (!keys.includes(_primaryKey.toLowerCase())) {
|
keys.push(_primaryKey.toLowerCase())
|
values.push('@ID@')
|
}
|
if (!keys.includes('createuserid')) {
|
keys.push('createuserid')
|
values.push('@userid@')
|
}
|
if (!keys.includes('createuser')) {
|
keys.push('createuser')
|
values.push('@username')
|
}
|
if (!keys.includes('createstaff')) {
|
keys.push('createstaff')
|
values.push('@fullname')
|
}
|
if (!keys.includes('bid')) {
|
keys.push('bid')
|
values.push('@BID@')
|
}
|
if (!keys.includes('typename')) {
|
keys.push('typename')
|
values.push('@typename@')
|
}
|
|
keys = keys.join(', ')
|
values = values.join(', ')
|
_insertsql = `insert into ${card.sql} (${keys}) select ${values};`
|
}
|
|
if (card.sqlType === 'update' || card.sqlType === 'audit' || card.sqlType === 'insertOrUpdate') {
|
let _form = []
|
let _arr = []
|
|
_fields.forEach(item => {
|
if (!item.field || item.writein === 'false' || item.uuid === 'BID') return
|
|
_arr.push(item.field.toLowerCase())
|
if (item.field.toLowerCase() === 'bid') {
|
_form.push(item.field + '=@BID@')
|
} else {
|
_form.push(item.field + '=@' + item.field)
|
}
|
})
|
|
if (this.props.card.sqlType === 'audit') {
|
if (!_arr.includes('submitdate')) {
|
_form.push('submitdate=getdate()')
|
}
|
if (!_arr.includes('submituser')) {
|
_form.push('submituser=@username')
|
}
|
if (!_arr.includes('submitstaff')) {
|
_form.push('submitstaff=@fullname')
|
}
|
if (!_arr.includes('submituserid')) {
|
_form.push('submituserid=@userid@')
|
}
|
if (!_arr.includes('typename')) {
|
_form.push(`typename=@typename@`)
|
}
|
} else {
|
if (!_arr.includes('modifydate')) {
|
_form.push('modifydate=getdate()')
|
}
|
if (!_arr.includes('modifyuser')) {
|
_form.push('modifyuser=@username')
|
}
|
if (!_arr.includes('modifystaff')) {
|
_form.push('modifystaff=@fullname')
|
}
|
if (!_arr.includes('modifyuserid')) {
|
_form.push('modifyuserid=@userid@')
|
}
|
if (!_arr.includes('typename')) {
|
_form.push(`typename=@typename@`)
|
}
|
}
|
|
if (_verify.voucher && _verify.voucher.enabled) {
|
if (!_arr.includes('bvoucher')) {
|
_form.push('BVoucher=@BVoucher')
|
}
|
if (!_arr.includes('fibvoucherdate')) {
|
_form.push('FIBVoucherDate=@FIBVoucherDate')
|
}
|
if (!_arr.includes('fiyear')) {
|
_form.push('FiYear=@FiYear')
|
}
|
}
|
|
_form = _form.join(', ')
|
_updatesql = `update ${card.sql} set ${_form} where ${_primaryKey}${card.Ot !== 'requiredOnce' ? '=@ID@' : ' in (select ID from dbo.SplitComma(@ID@))'};`
|
}
|
|
if (card.sqlType === 'insert') {
|
_defaultsql = _insertsql
|
} else if (card.sqlType === 'update' || card.sqlType === 'audit') {
|
_defaultsql = _updatesql
|
} else if (card.sqlType === 'insertOrUpdate') {
|
_defaultsql += `select @tbid=''
|
select @tbid='X' from ${card.sql} where ${_primaryKey}=@ID@
|
if @tbid=''
|
begin
|
${_insertsql}
|
end
|
else
|
begin
|
${_updatesql}
|
end
|
`
|
} else if (card.sqlType === 'LogicDelete' || card.sqlType === 'custom') {
|
let _voucher = ''
|
if (_verify.voucher && _verify.voucher.enabled) {
|
_voucher = ',BVoucher=@BVoucher,FIBVoucherDate=@FIBVoucherDate,FiYear=@FiYear'
|
}
|
_defaultsql = `update ${card.sql} set deleted=@mk_deleted,modifydate=getdate(),modifyuser=@username,modifystaff=@fullname,modifyuserid=@userid@${_voucher} where ${_primaryKey}${card.Ot !== 'requiredOnce' ? '=@ID@' : ' in (select ID from dbo.SplitComma(@ID@))'};`
|
} else if (card.sqlType === 'delete') {
|
let _msg = ''
|
if (columns && columns.length > 0 && card.Ot !== 'notRequired') {
|
let _index = 0
|
columns.forEach(col => {
|
if (!col.field || col.Hide === 'true' || _index >= 4) return
|
|
_msg += col.label + '=\'\','
|
_index++
|
})
|
}
|
_defaultsql += `insert into snote (remark,createuserid,CreateUser,CreateStaff,typename) select left('删除表:${card.sql} 数据: ${_msg}${_primaryKey}='+@ID@,200),@userid@,@username,@fullname,@typename@ delete ${card.sql} where ${_primaryKey}${card.Ot !== 'requiredOnce' ? '=@ID@' : ' in (select ID from dbo.SplitComma(@ID@))'};`
|
}
|
|
let _columns = []
|
if (columns) {
|
_columns = fromJS(columns).toJS()
|
let hasbid = false
|
_columns = _columns.filter(col => {
|
if (col.field && col.field.toLowerCase() === 'bid') {
|
hasbid = true
|
}
|
|
return !!col.field
|
})
|
|
if (!hasbid) {
|
_columns.unshift({ uuid: 'BID', field: 'BID', label: 'BID', type: 'text' })
|
}
|
}
|
|
this.setState({
|
fields: _fields,
|
columnsFields: _columns,
|
initsql: _sql,
|
defaultsql: _defaultsql,
|
usefulfields: _usefulfields.join(', '),
|
uniqueColumns: this.state.uniqueColumns.map(col => {
|
if (col.dataIndex === 'field') {
|
col.options = uniqueFields
|
}
|
return col
|
}),
|
onceUniqueColumns: this.state.onceUniqueColumns.map(col => {
|
if (col.dataIndex === 'field') {
|
col.options = _columns
|
}
|
return col
|
}),
|
unionFields,
|
uniqueFields
|
})
|
})
|
}
|
|
componentDidMount() {
|
let mutilForms = [
|
{
|
obj_name: 'modular',
|
arr_field: 'ID,NameNO',
|
LText: window.btoa(window.encodeURIComponent(`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`))
|
},
|
{
|
obj_name: 'modularDetail',
|
arr_field: 'ModularDetailCode,CodeName,BID,Type',
|
LText: window.btoa(window.encodeURIComponent(`select distinct ModularDetailCode,ModularDetailCode+ModularDetailName as CodeName,ModularCode as BID,Type from sModularDetail where Appkey= @Appkey@ and deleted=0 order by ModularDetailCode desc`))
|
},
|
{
|
obj_name: 'voucher',
|
arr_field: 'ID,NameNO,TypeCharOne',
|
LText: window.btoa(window.encodeURIComponent(`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`))
|
},
|
{
|
obj_name: 'voucherDetail',
|
arr_field: 'ModularDetailCode,CodeName,BID,VoucherTypeTwo,IDefine1',
|
LText: window.btoa(window.encodeURIComponent(`select distinct ModularDetailCode,ModularDetailCode+ModularDetailName as CodeName,ModularCode as BID, VoucherTypeTwo, IDefine1 from sModularDetail where Deleted=0 and VoucherTypeTwo!=''
|
and Appkey=@Appkey@ union
|
select distinct a.ModularDetailCode,a.ModularDetailCode+ModularDetailName as CodeName,ModularCode as BID, VoucherTypeTwo, IDefine1
|
from (select * from sModularDetail where Deleted=0 and VoucherTypeTwo!='' and Appkey='') a
|
left join (select distinct ModularDetailCode from sModularDetail where Deleted=0 and VoucherTypeTwo!=''
|
and Appkey=@Appkey@) m on a.ModularDetailCode=m.ModularDetailCode where m.ModularDetailCode is null order by ModularDetailCode desc`
|
))
|
},
|
{
|
obj_name: 'noteCodes',
|
arr_field: 'templatecode,describe,id',
|
LText: window.btoa(window.encodeURIComponent(`select t.id,templatecode,'['+SignName+']'+describe as describe from (select * from bd_msn_sms_temp where deleted=0 and TypeDesc='QX' and status=20 ) t inner join (select openid from susers where uid=@userid@) u on t.openid =t.openid`))
|
},
|
{
|
obj_name: 'scripts',
|
arr_field: 'funcname,longparam',
|
LText: window.btoa(window.encodeURIComponent(`Select distinct func+Remark as funcname,longparam, s.Sort from s_custom_script s inner join (select OpenID from sapp where ID=@Appkey@) p on s.openid = case when s.appkey='' then s.openid else p.OpenID end order by s.Sort`))
|
}
|
]
|
|
mutilForms = mutilForms.map(item => `select '${item.obj_name}' as obj_name,'${item.arr_field}' as arr_field,'${item.LText}' as LText`)
|
|
let mutilparam = {
|
func: 'sPC_Get_SelectedList',
|
LText: mutilForms.join(' union all '),
|
obj_name: '',
|
arr_field: '',
|
table_type: 'Y'
|
}
|
|
mutilparam.LText = Utils.formatOptions(mutilparam.LText)
|
mutilparam.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
|
mutilparam.secretkey = Utils.encrypt(mutilparam.LText, mutilparam.timestamp)
|
mutilparam.open_key = Utils.encryptOpenKey(mutilparam.secretkey, mutilparam.timestamp)
|
|
if (window.GLOB.cloudServiceApi) { // 云端请求
|
mutilparam.rduri = window.GLOB.cloudServiceApi
|
mutilparam.userid = sessionStorage.getItem('CloudUserID') || ''
|
mutilparam.LoginUID = sessionStorage.getItem('CloudLoginUID') || ''
|
}
|
|
Api.getSystemCacheConfig(mutilparam).then(res => {
|
if (res.status) {
|
this.setState({
|
orderModular: res.modular,
|
orderModularDetail: res.modularDetail,
|
voucher: res.voucher,
|
voucherDetail: res.voucherDetail,
|
notes: res.noteCodes.map(item => {
|
return {
|
name: item.describe,
|
value: item.templatecode,
|
id: item.id
|
}
|
}),
|
systemScripts: res.scripts.map(item => {
|
return {
|
name: item.funcname,
|
value: window.decodeURIComponent(window.atob(item.longparam))
|
}
|
})
|
})
|
} else {
|
notification.warning({
|
top: 92,
|
message: res.message,
|
duration: 5
|
})
|
}
|
})
|
}
|
|
uniqueChange = (values) => {
|
let verify = fromJS(this.state.verify).toJS()
|
|
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 })
|
}
|
|
contrastChange = (values) => {
|
let verify = fromJS(this.state.verify).toJS()
|
|
values.status = 'true'
|
values.uuid = Utils.getuuid()
|
verify.contrasts.push(values)
|
|
this.setState({ verify })
|
}
|
|
customChange = (values) => {
|
let verify = fromJS(this.state.verify).toJS()
|
|
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 })
|
}
|
|
scriptsChange = (values) => {
|
let verify = fromJS(this.state.verify).toJS()
|
|
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)
|
}
|
|
MKEmitter.emit('editLineId', values.uuid)
|
|
this.setState({ verify })
|
}
|
|
cbScriptsChange = (values) => {
|
let verify = fromJS(this.state.verify).toJS()
|
|
if (values.uuid) {
|
verify.cbScripts = verify.cbScripts.map(item => {
|
if (item.uuid === values.uuid) {
|
return values
|
} else {
|
return item
|
}
|
})
|
} else {
|
values.uuid = Utils.getuuid()
|
verify.cbScripts.push(values)
|
}
|
|
MKEmitter.emit('editLineId', values.uuid)
|
|
this.setState({ verify })
|
}
|
|
orderChange = (values) => {
|
let verify = fromJS(this.state.verify).toJS()
|
|
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 })
|
}
|
|
handleDelete = (record, type) => {
|
const { verify } = this.state
|
|
if (type === 'customverify') {
|
verify.customverifys = verify.customverifys.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 === 'cbscripts') {
|
verify.cbScripts = verify.cbScripts.filter(item => item.uuid !== record.uuid)
|
}
|
|
this.setState({ verify })
|
}
|
|
handleEdit = (record, type) => {
|
let node = null
|
|
if (type === 'customverify') {
|
this.customForm.edit(record)
|
node = document.getElementById('mk-custom-script')
|
} else if (type === 'ordercode') {
|
this.orderForm.edit(record)
|
} else if (type === 'scripts') {
|
this.scriptsForm.edit(record)
|
node = document.getElementById('mk-normal-script')
|
} else if (type === 'cbscripts') {
|
this.cbscriptsForm.edit(record)
|
node = document.getElementById('mk-callback-script')
|
}
|
|
// 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 = fromJS(this.state.verify).toJS()
|
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 === '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
|
}
|
})
|
} else if (type === 'cbscripts') {
|
verify.cbScripts = verify.cbScripts.map(item => {
|
if (item.uuid === record.uuid) {
|
return record
|
} else {
|
return item
|
}
|
})
|
}
|
|
this.setState({ verify })
|
}
|
|
voucherChange = (voucher) => {
|
const { verify } = this.state
|
|
this.setState({
|
verify: {
|
...verify,
|
voucher: voucher
|
}
|
})
|
}
|
|
showError = (errorType) => {
|
const { verify, appType } = this.state
|
|
if (errorType === 'S') {
|
let time = verify.stime || 2
|
if (appType === 'mob') {
|
Toast.show({ icon: 'success', content: '执行成功!', duration: time * 1000 })
|
} else {
|
notification.success({
|
top: 92,
|
message: '执行成功!',
|
duration: time
|
})
|
}
|
|
} else if (errorType === 'Y') {
|
if (appType === 'mob') {
|
Dialog.alert({content: '执行成功!', confirmText: '知道了'})
|
} else {
|
Modal.success({
|
title: '执行成功!'
|
})
|
}
|
} else if (errorType === 'F') {
|
if (appType === 'mob') {
|
let time = verify.ftime || 3
|
Toast.show({ icon: 'fail', content: '执行失败!', duration: time * 1000 })
|
} else {
|
notification.error({
|
className: 'notification-custom-error',
|
top: 92,
|
message: '执行失败!',
|
duration: verify.ftime || 10
|
})
|
}
|
} else if (errorType === 'N') {
|
if (appType === 'mob') {
|
let time = verify.ntime || 3
|
Toast.show({ content: '执行失败!', duration: time * 1000 })
|
} else {
|
notification.error({
|
top: 92,
|
message: '执行失败!',
|
duration: verify.ntime || 10
|
})
|
}
|
} else if (errorType === 'E') {
|
if (appType === 'mob') {
|
Dialog.alert({content: '执行失败!', confirmText: '知道了'})
|
} else {
|
Modal.error({
|
title: '执行失败!'
|
})
|
}
|
} else if (errorType === 'NM') {
|
if (appType === 'mob') {
|
let time = verify.ntime || 3
|
Toast.show({ content: '执行失败!', duration: time * 1000 })
|
} else {
|
message.error('执行失败!')
|
}
|
}
|
}
|
|
timeChange = (val, type) => {
|
const { verify } = this.state
|
|
this.setState({
|
verify: {...verify, [type]: val}
|
})
|
}
|
|
changeUniques = (uniques) => {
|
const { card } = this.props
|
const { verify, fields, columnsFields } = this.state
|
|
let _fields = []
|
let change = {}
|
if (card.Ot !== 'requiredOnce') {
|
_fields = fields
|
} else {
|
_fields = columnsFields
|
}
|
|
_fields.forEach(col => {
|
change[col.field] = col.label
|
})
|
|
uniques = uniques.map(item => {
|
item.status = item.status || 'true'
|
|
if (Array.isArray(item.field)) {
|
item.fieldlabel = item.field.map(field => {
|
return change[field] || ''
|
})
|
|
item.fieldlabel = item.fieldlabel.join(',')
|
item.field = item.field.join(',')
|
}
|
|
return item
|
})
|
|
this.setState({verify: {...verify, uniques}})
|
}
|
|
handleConfirm = () => {
|
const { card } = this.props
|
const { setting, activeKey } = this.state
|
let verify = fromJS(this.state.verify).toJS()
|
|
if (activeKey === 'base') {
|
let msg = this.baseForm.handleConfirm()
|
|
if (msg) {
|
notification.warning({
|
top: 92,
|
message: msg,
|
duration: 5
|
})
|
return Promise.reject()
|
}
|
}
|
|
// 表单提交时检查输入值是否正确
|
return new Promise((resolve, reject) => {
|
if ((card.sqlType === 'custom' || verify.default === 'false') && verify.scripts.length === 0) {
|
notification.warning({
|
top: 92,
|
message: '不执行默认sql时,必须设置自定义脚本!',
|
duration: 5
|
})
|
return
|
} else if (verify.invalid === 'true' && setting.maxScript && setting.maxScript >= 300) {
|
notification.warning({
|
top: 92,
|
message: '数据源中自定义脚本过于复杂,不能使用失效验证!',
|
duration: 5
|
})
|
return
|
}
|
|
let msg = ''
|
if (this.customForm && this.customForm.state.editItem) {
|
msg = '自定义验证'
|
} else if (this.customForm && this.customForm.props.form.getFieldValue('sql') && !/^\s+$/.test(this.customForm.props.form.getFieldValue('sql'))) {
|
msg = '自定义验证'
|
} else if (this.orderForm && this.orderForm.state.editItem) {
|
msg = '单号生成'
|
} else if (this.scriptsForm && this.scriptsForm.state.editItem) {
|
msg = '自定义脚本'
|
} else if (this.scriptsForm && this.scriptsForm.props.form.getFieldValue('sql') && !/^\s+$/.test(this.scriptsForm.props.form.getFieldValue('sql'))) {
|
msg = '自定义脚本'
|
}
|
|
if (window.GLOB.funcs && window.GLOB.funcs.length > 0) {
|
window.GLOB.funcs.forEach(m => {
|
let reg = new RegExp('\\$ex@' + m.func_code + '@ex\\$', 'ig')
|
verify.customverifys.forEach(item => {
|
item.sql = item.sql.replace(reg, `/*$ex@${m.func_code}-begin*/\n${m.key_sql}\n/*@ex$-end*/`)
|
})
|
verify.scripts.forEach(item => {
|
item.sql = item.sql.replace(reg, `/*$ex@${m.func_code}-begin*/\n${m.key_sql}\n/*@ex$-end*/`)
|
})
|
verify.cbScripts.forEach(item => {
|
item.sql = item.sql.replace(reg, `/*$ex@${m.func_code}-begin*/\n${m.key_sql}\n/*@ex$-end*/`)
|
})
|
})
|
}
|
|
if (msg) {
|
confirm({
|
content: msg + '未保存,确定提交吗?',
|
onOk() {
|
resolve(verify)
|
},
|
onCancel() {}
|
})
|
} else {
|
resolve(verify)
|
}
|
})
|
}
|
|
handleCancel = () => {
|
const { verify, oriVerify } = this.state
|
// 表单提交时检查输入值是否正确
|
return new Promise((resolve, reject) => {
|
if (!is(fromJS(verify), fromJS(oriVerify))) {
|
confirm({
|
content: '验证信息已修改,确定取消吗?',
|
onOk() {
|
resolve()
|
},
|
onCancel() {}
|
})
|
} else {
|
resolve()
|
}
|
})
|
}
|
|
changeTab = (val) => {
|
const { activeKey } = this.state
|
|
if (activeKey === 'base') {
|
let msg = this.baseForm.handleConfirm()
|
|
if (msg) {
|
notification.warning({
|
top: 92,
|
message: msg,
|
duration: 5
|
})
|
return
|
}
|
}
|
this.setState({
|
activeKey: val
|
})
|
}
|
|
/**
|
* @description 组件销毁,清除state更新
|
*/
|
componentWillUnmount () {
|
this.setState = () => {
|
return
|
}
|
}
|
|
render() {
|
const { card } = this.props
|
const { activeKey, verifyInter, setting, verify, fields, uniqueFields, uniqueColumns, unionFields, onceUniqueColumns, columnsFields, contrastColumns, customColumns, orderColumns, scriptsColumns, cbScriptsColumns, orderModular, orderModularDetail, voucher, voucherDetail, notes, appType } = this.state
|
const formItemLayout = {
|
labelCol: {
|
xs: { span: 24 },
|
sm: { span: 8 }
|
},
|
wrapperCol: {
|
xs: { span: 24 },
|
sm: { span: 16 }
|
}
|
}
|
|
return (
|
<div>
|
{card.label ? <div className="mk-com-name">{card.label} - 验证信息</div> : null}
|
<Tabs activeKey={activeKey} className="mk-verify-tabs" onChange={this.changeTab}>
|
{verifyInter === 'system' || card.intertype === 'inner' ? <TabPane tab={
|
<span>
|
基础验证
|
{verify.default === 'false' ? <span className="count-tip"><ExclamationOutlined style={{color: 'orange'}}/></span> : null}
|
</span>
|
} key="base">
|
<BaseForm card={card} appType={appType} unionFields={unionFields} setting={setting} verify={verify} notes={notes} onChange={(verify) => this.setState({verify})} wrappedComponentRef={(inst) => this.baseForm = inst}/>
|
</TabPane> : null}
|
{verifyInter === 'system' ? <TabPane tab={
|
<span>
|
比较验证
|
{verify.contrasts.length ? <span className="count-tip">{verify.contrasts.length}</span> : null}
|
</span>
|
} key="contrasts">
|
<ContrastForm contrastChange={this.contrastChange}/>
|
<EditTable actions={['edit', 'move', 'copy', 'del', 'status']} type="contrastverify" data={verify.contrasts} columns={contrastColumns} onChange={(contrasts) => this.setState({verify: {...verify, contrasts}})}/>
|
</TabPane> : null}
|
{verifyInter === 'system' ? <TabPane tab={
|
<span>
|
自定义验证
|
{verify.customverifys.length ? <span className="count-tip">{verify.customverifys.length}</span> : null}
|
</span>
|
} key="customverifys" id="mk-custom-script">
|
<CustomForm
|
btn={this.props.card}
|
initsql={this.state.initsql}
|
usefulfields={this.state.usefulfields}
|
customChange={this.customChange}
|
wrappedComponentRef={(inst) => this.customForm = inst}
|
/>
|
<EditTable actions={['move']} data={verify.customverifys} columns={customColumns} onChange={(customverifys) => {this.setState({verify: {...verify, customverifys}})}}/>
|
</TabPane> : null}
|
{verifyInter === 'system' ? <TabPane tab={
|
<span>
|
单号生成
|
{verify.billcodes.length ? <span className="count-tip">{verify.billcodes.length}</span> : null}
|
</span>
|
} key="billcodes">
|
<BillcodeForm
|
fields={fields}
|
btn={this.props.card}
|
billcodes={verify.billcodes}
|
columns={this.props.columns}
|
modular={orderModular}
|
modularDetail={orderModularDetail}
|
orderChange={this.orderChange}
|
wrappedComponentRef={(inst) => this.orderForm = inst}
|
/>
|
<EditTable actions={['move']} data={verify.billcodes} columns={orderColumns} onChange={(billcodes) => {this.setState({verify: {...verify, billcodes}})}}/>
|
</TabPane> : null}
|
{verifyInter === 'system' ? <TabPane tab={
|
<span>
|
{card.Ot !== 'requiredOnce' ? '唯一性验证' : '同类数据验证'}
|
{verify.uniques.length ? <span className="count-tip">{verify.uniques.length}</span> : null}
|
</span>
|
} key="uniques">
|
<UniqueForm
|
btn={card}
|
fields={card.Ot !== 'requiredOnce' ? uniqueFields : columnsFields}
|
uniqueChange={this.uniqueChange}
|
/>
|
<EditTable actions={['edit', 'move', 'del', 'status']} data={verify.uniques} columns={card.Ot !== 'requiredOnce' ? uniqueColumns : onceUniqueColumns} onChange={this.changeUniques}/>
|
</TabPane> : null}
|
{verifyInter === 'system' ? <TabPane tab={
|
<span>
|
创建凭证
|
{verify.voucher && verify.voucher.enabled ? <span className="count-tip">1</span> : null}
|
</span>
|
} key="voucher">
|
<VoucherForm
|
voucher={voucher}
|
columns={this.props.columns}
|
voucherobj={verify.voucher}
|
voucherDetail={voucherDetail}
|
voucherChange={this.voucherChange}
|
wrappedComponentRef={(inst) => this.voucherForm = inst}
|
/>
|
</TabPane> : null}
|
{verifyInter === 'system' ? <TabPane tab={
|
<span>
|
自定义脚本
|
{verify.scripts.length ? <span className="count-tip">{verify.scripts.length}</span> : null}
|
</span>
|
} key="scripts" id="mk-normal-script">
|
<FullScripts
|
verify={verify}
|
getScriptsFullForm={() => this.scriptsFullForm}
|
getScriptsForm={() => this.scriptsForm}
|
handleStatus={this.handleStatus}
|
handleDelete={this.handleDelete}
|
>
|
<CustomScript
|
type="fullscreen"
|
btn={this.props.card}
|
initsql={this.state.initsql}
|
customScripts={verify.scripts}
|
defaultsql={this.state.defaultsql}
|
usefulfields={this.state.usefulfields}
|
systemScripts={this.state.systemScripts}
|
scriptsChange={this.scriptsChange}
|
wrappedComponentRef={(inst) => this.scriptsFullForm = inst}
|
/>
|
</FullScripts>
|
<CustomScript
|
btn={this.props.card}
|
initsql={this.state.initsql}
|
customScripts={verify.scripts}
|
defaultsql={this.state.defaultsql}
|
usefulfields={this.state.usefulfields}
|
systemScripts={this.state.systemScripts}
|
scriptsChange={this.scriptsChange}
|
wrappedComponentRef={(inst) => this.scriptsForm = inst}
|
/>
|
<EditTable actions={['move']} data={verify.scripts} columns={scriptsColumns} onChange={(scripts) => {this.setState({verify: {...verify, scripts}})}}/>
|
</TabPane> : null}
|
{card.callbackType === 'script' ? <TabPane tab={
|
<span>
|
回调脚本
|
{verify.cbScripts.length ? <span className="count-tip">{verify.cbScripts.length}</span> : null}
|
</span>
|
} key="cbScripts" id="mk-callback-script">
|
<CallBackCustomScript
|
btn={this.props.card}
|
initsql={this.state.initsql}
|
customScripts={verify.cbScripts}
|
usefulfields={this.state.usefulfields}
|
systemScripts={this.state.systemScripts}
|
scriptsChange={this.cbScriptsChange}
|
wrappedComponentRef={(inst) => this.cbscriptsForm = inst}
|
/>
|
<EditTable actions={['move']} data={verify.cbScripts} columns={cbScriptsColumns} onChange={(cbScripts) => {this.setState({verify: {...verify, cbScripts}})}}/>
|
</TabPane> : null}
|
<TabPane tab="信息提示" key="tip">
|
<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"> -1 </span>
|
执行成功无提示。
|
</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 || (appType === 'mob' ? 3 : 10)} 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 || (appType === 'mob' ? 3 : 10)} 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"> -2 </span>
|
执行失败无提示
|
</Form.Item>
|
</Col>
|
</Row>
|
</Form>
|
</TabPane>
|
</Tabs>
|
</div>
|
)
|
}
|
}
|
|
export default Form.create()(VerifyCard)
|