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, ConsoleSqlOutlined } 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 = {
|
config: PropTypes.any, // 表单标签页参数
|
card: PropTypes.object, // 按钮信息
|
columns: PropTypes.array
|
}
|
|
state = {
|
verifyInter: 'system', // 接口类型
|
activeKey: 'base',
|
appType: sessionStorage.getItem('appType'),
|
notes: [], // 短信模板
|
emailCodes: [], // 邮箱模板
|
verify: {},
|
fields: [],
|
formfields: '',
|
colfields: '',
|
orderModular: [],
|
orderModularDetail: [],
|
voucher: [],
|
voucherDetail: [],
|
systemScripts: [],
|
columnsFields: [],
|
unionFields: [],
|
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) => text === '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>
|
)
|
},
|
{
|
dataIndex: 'sqlRender',
|
render: (record) => {
|
let _fieldValue = []
|
let _value = []
|
let _labels = record.fieldlabel.split(',')
|
|
record.field.split(',').forEach((_field, index) => {
|
let _key = _field.toLowerCase()
|
_fieldValue.push(`${_key}=${_key === 'bid' ? '@BID@' : `''`}`)
|
_value.push(`${_labels[index] || ''}:xxx`)
|
})
|
|
let _verifyType = ''
|
if (record.verifyType === 'logic') {
|
_verifyType = ' and deleted=0'
|
}
|
|
let sql = `select @tbid='', @ErrorCode='',@retmsg=''
|
select @tbid='X' from ${this.props.card.sql} where ${_fieldValue.join(' and ')}${_verifyType}
|
If @tbid!=''
|
Begin
|
select @ErrorCode='${record.errorCode}',@retmsg='${_value.join(', ')} 已存在'
|
goto aaa
|
end`
|
return sql.split(/\n\s{10}/ig).map(n => n.replace(/^\s{2}/ig, ' '))
|
}
|
}
|
],
|
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>
|
)
|
},
|
{
|
dataIndex: 'sqlRender',
|
render: (record) => {
|
let primaryKey = 'id'
|
|
if (this.props.config && this.props.config.setting && this.props.config.setting.primaryKey) {
|
primaryKey = this.props.config.setting.primaryKey
|
}
|
|
let sql = `Set @tbid=''
|
Select top 1 @tbid='X' from (select distinct ${record.field},1 as n from (数据源) tb inner join (select ID from dbo.SplitComma(@ID@)) sp on tb.${primaryKey}=sp.ID ) a having sum(n)>1
|
|
If @tbid!=''
|
Begin
|
Set @ErrorCode='E' Set @retmsg='${record.fieldlabel} 值不唯一'
|
goto aaa
|
end`
|
|
return sql.split(/\n\s{10}/ig).map(n => n.replace(/^\s{2}/ig, ' '))
|
}
|
}
|
],
|
contrastColumns: [
|
{
|
title: '内容1',
|
dataIndex: 'frontfield',
|
width: '14%',
|
inputType: 'input',
|
editable: true
|
},
|
{
|
title: '运算符',
|
dataIndex: 'operator',
|
width: '13%',
|
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: '13%',
|
inputType: 'input',
|
editable: true
|
},
|
{
|
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: '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>
|
)
|
},
|
{
|
dataIndex: 'sqlRender',
|
render: (record) => {
|
let sql = `If ${record.frontfield} ${record.operator} ${record.backfield}
|
Begin
|
select @ErrorCode='${record.errorCode}',@retmsg='${record.errmsg}'
|
goto aaa
|
end`
|
|
return sql.split(/\n\s{10}/ig).map(n => n.replace(/^\s{2}/ig, ' '))
|
}
|
}
|
],
|
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>
|
<span className="anticon operation-btn" style={{color: '#4D6BFE'}} onClick={() => {
|
if (record.sql) {
|
sessionStorage.setItem('deepseek_sql', `对以下sql server脚本,编写注释,不能用--,只能用/**/ ,@bid@是上级组件id,@id@是当前行数据id,@userid@为当前登录用户id,所有字段不要用..来省略,不要增加过多的回车改变原有格式,这样会影响代码的可读性,如果代码太长一条回复不完,就回复多条信息完成\n${record.sql}`)
|
|
window.open('#/ai')
|
|
setTimeout(() => {
|
sessionStorage.removeItem('deepseek_sql')
|
}, 0)
|
}
|
}}>
|
<svg viewBox="0 0 1391 1024" width="20px" fill="currentColor">
|
<path d="M1361.92 83.136c-14.272-7.04-20.416 6.272-28.736 12.992-2.816 2.24-5.248 5.12-7.68 7.68-20.8 22.336-45.056 36.864-76.8 35.136-46.464-2.56-86.08 12.032-121.152 47.616-7.552-43.904-32.256-70.08-69.888-86.912-19.712-8.768-39.68-17.472-53.376-36.48-9.664-13.44-12.288-28.48-17.216-43.264-3.008-8.96-6.08-18.112-16.32-19.712-11.2-1.728-15.552 7.68-19.968 15.424-17.536 32.128-24.32 67.52-23.68 103.296 1.6 80.448 35.52 144.576 103.04 190.144 7.68 5.312 9.6 10.56 7.168 18.176-4.608 15.68-10.048 30.976-14.912 46.592-3.072 10.112-7.68 12.352-18.304 8a308.224 308.224 0 0 1-97.28-66.176c-48-46.4-91.392-97.664-145.472-137.792a655.36 655.36 0 0 0-38.528-26.432c-55.232-53.76 7.232-97.792 21.632-103.04 15.104-5.376 5.312-24.128-43.52-23.936C652.032 24.704 607.36 41.024 550.4 62.72a156.8 156.8 0 0 1-26.048 7.68 542.016 542.016 0 0 0-161.408-5.696c-105.6 11.904-189.888 61.824-251.904 147.2C36.608 314.24 19.072 430.848 40.512 552.32c22.528 128 87.808 234.048 188.16 316.992 104 85.888 223.808 128 360.512 120 82.944-4.864 175.424-16 279.68-104.32 26.368 13.056 53.888 18.24 99.712 22.272 35.2 3.328 69.184-1.792 95.424-7.232 41.216-8.704 38.4-46.848 23.424-53.888-120.576-56.32-94.208-33.408-118.272-51.84 61.376-72.768 153.792-148.224 189.952-392.768 2.816-19.392 0.384-31.552 0-47.36-0.256-9.536 1.92-13.312 12.8-14.4a231.04 231.04 0 0 0 86.592-26.56c78.272-42.88 109.696-113.024 117.184-197.184 1.088-12.928-0.256-26.24-13.76-32.96z m-681.408 757.76c-116.928-92.096-173.696-122.368-197.12-120.96-21.888 1.152-17.984 26.304-13.184 42.624 5.12 16.128 11.648 27.328 20.8 41.408 6.464 9.408 10.752 23.424-6.272 33.92-37.76 23.424-103.232-7.872-106.24-9.472-76.288-44.8-140.032-104.192-184.96-185.344-43.264-78.08-68.48-161.92-72.576-251.328-1.152-21.632 5.184-29.312 26.688-33.152a265.6 265.6 0 0 1 85.696-2.24c119.296 17.472 220.928 71.04 306.048 155.52 48.768 48.32 85.504 105.92 123.392 162.176 40.256 59.776 83.648 116.672 138.88 163.392 19.392 16.32 35.072 28.8 49.92 37.952-44.928 5.056-119.872 6.08-171.008-34.496z m56.064-361.024a17.152 17.152 0 1 1 2.752 9.6 16.896 16.896 0 0 1-2.752-9.664z m174.08 89.472a102.72 102.72 0 0 1-33.024 8.96 70.528 70.528 0 0 1-44.736-14.272c-15.296-12.8-26.176-19.968-30.848-42.496a99.264 99.264 0 0 1 0.832-32.96c4.032-18.368-0.384-30.08-13.248-40.768-10.624-8.768-23.872-11.072-38.592-11.072a31.168 31.168 0 0 1-14.272-4.416c-6.144-3.072-11.136-10.752-6.336-20.16 1.536-3.008 8.96-10.304 10.752-11.712 19.84-11.328 42.88-7.68 64.192 0.896 19.712 8.064 34.56 22.848 56 43.776 21.952 25.28 25.792 32.384 38.4 51.328 9.856 14.848 18.816 30.208 24.96 47.616 3.776 10.88-1.152 19.776-14.08 25.28z"></path>
|
</svg>
|
</span>
|
</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>
|
<span className="anticon operation-btn" style={{color: '#4D6BFE'}} onClick={() => {
|
if (record.sql) {
|
sessionStorage.setItem('deepseek_sql', `对以下sql server脚本,编写注释,不能用--,只能用/**/ ,@bid@是上级组件id,@id@是当前行数据id,@userid@为当前登录用户id,所有字段不要用..来省略,不要增加过多的回车改变原有格式,这样会影响代码的可读性,如果代码太长一条回复不完,就回复多条信息完成\n${record.sql}`)
|
|
window.open('#/ai')
|
|
setTimeout(() => {
|
sessionStorage.removeItem('deepseek_sql')
|
}, 0)
|
}
|
}}>
|
<svg viewBox="0 0 1391 1024" width="20px" fill="currentColor">
|
<path d="M1361.92 83.136c-14.272-7.04-20.416 6.272-28.736 12.992-2.816 2.24-5.248 5.12-7.68 7.68-20.8 22.336-45.056 36.864-76.8 35.136-46.464-2.56-86.08 12.032-121.152 47.616-7.552-43.904-32.256-70.08-69.888-86.912-19.712-8.768-39.68-17.472-53.376-36.48-9.664-13.44-12.288-28.48-17.216-43.264-3.008-8.96-6.08-18.112-16.32-19.712-11.2-1.728-15.552 7.68-19.968 15.424-17.536 32.128-24.32 67.52-23.68 103.296 1.6 80.448 35.52 144.576 103.04 190.144 7.68 5.312 9.6 10.56 7.168 18.176-4.608 15.68-10.048 30.976-14.912 46.592-3.072 10.112-7.68 12.352-18.304 8a308.224 308.224 0 0 1-97.28-66.176c-48-46.4-91.392-97.664-145.472-137.792a655.36 655.36 0 0 0-38.528-26.432c-55.232-53.76 7.232-97.792 21.632-103.04 15.104-5.376 5.312-24.128-43.52-23.936C652.032 24.704 607.36 41.024 550.4 62.72a156.8 156.8 0 0 1-26.048 7.68 542.016 542.016 0 0 0-161.408-5.696c-105.6 11.904-189.888 61.824-251.904 147.2C36.608 314.24 19.072 430.848 40.512 552.32c22.528 128 87.808 234.048 188.16 316.992 104 85.888 223.808 128 360.512 120 82.944-4.864 175.424-16 279.68-104.32 26.368 13.056 53.888 18.24 99.712 22.272 35.2 3.328 69.184-1.792 95.424-7.232 41.216-8.704 38.4-46.848 23.424-53.888-120.576-56.32-94.208-33.408-118.272-51.84 61.376-72.768 153.792-148.224 189.952-392.768 2.816-19.392 0.384-31.552 0-47.36-0.256-9.536 1.92-13.312 12.8-14.4a231.04 231.04 0 0 0 86.592-26.56c78.272-42.88 109.696-113.024 117.184-197.184 1.088-12.928-0.256-26.24-13.76-32.96z m-681.408 757.76c-116.928-92.096-173.696-122.368-197.12-120.96-21.888 1.152-17.984 26.304-13.184 42.624 5.12 16.128 11.648 27.328 20.8 41.408 6.464 9.408 10.752 23.424-6.272 33.92-37.76 23.424-103.232-7.872-106.24-9.472-76.288-44.8-140.032-104.192-184.96-185.344-43.264-78.08-68.48-161.92-72.576-251.328-1.152-21.632 5.184-29.312 26.688-33.152a265.6 265.6 0 0 1 85.696-2.24c119.296 17.472 220.928 71.04 306.048 155.52 48.768 48.32 85.504 105.92 123.392 162.176 40.256 59.776 83.648 116.672 138.88 163.392 19.392 16.32 35.072 28.8 49.92 37.952-44.928 5.056-119.872 6.08-171.008-34.496z m56.064-361.024a17.152 17.152 0 1 1 2.752 9.6 16.896 16.896 0 0 1-2.752-9.664z m174.08 89.472a102.72 102.72 0 0 1-33.024 8.96 70.528 70.528 0 0 1-44.736-14.272c-15.296-12.8-26.176-19.968-30.848-42.496a99.264 99.264 0 0 1 0.832-32.96c4.032-18.368-0.384-30.08-13.248-40.768-10.624-8.768-23.872-11.072-38.592-11.072a31.168 31.168 0 0 1-14.272-4.416c-6.144-3.072-11.136-10.752-6.336-20.16 1.536-3.008 8.96-10.304 10.752-11.712 19.84-11.328 42.88-7.68 64.192 0.896 19.712 8.064 34.56 22.848 56 43.776 21.952 25.28 25.792 32.384 38.4 51.328 9.856 14.848 18.816 30.208 24.96 47.616 3.776 10.88-1.152 19.776-14.08 25.28z"></path>
|
</svg>
|
</span>
|
</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>
|
<span className="operation-btn" title="SQL" onClick={() => this.orderSql(record)} style={{color: '#1890ff'}}><ConsoleSqlOutlined /></span>
|
</div>)
|
}
|
]
|
}
|
|
UNSAFE_componentWillMount() {
|
const { columns, config, card } = this.props
|
const { appType } = this.state
|
let _verify = fromJS(card.verify || {}).toJS()
|
|
let _invalid = _verify.invalid || 'true'
|
|
_verify.limitInvalid = false
|
if (config.wrap && config.wrap.datatype === 'public') {
|
_verify.limitInvalid = true
|
_verify.limitText = '公共数据源,不可使用失效验证'
|
_invalid = 'false'
|
} else if (config.wrap && config.wrap.datatype === 'static') {
|
_verify.limitInvalid = true
|
_verify.limitText = '静态数据源,不可使用失效验证'
|
_invalid = 'false'
|
} else if (!config.setting || config.setting.interType !== 'system') {
|
_verify.limitInvalid = true
|
_verify.limitText = '数据源未使用系统接口,不能使用失效验证!'
|
_invalid = 'false'
|
} else if (config.setting.execute !== 'true' || !config.setting.dataresource) {
|
_verify.limitInvalid = true
|
_verify.limitText = '尚未添加数据源,不能使用失效验证!'
|
_invalid = 'false'
|
} else if (config.setting.maxScript && config.setting.maxScript >= 300) {
|
_verify.limitInvalid = true
|
_verify.limitText = '数据源中自定义脚本过于复杂,不能使用失效验证!'
|
_invalid = 'false'
|
} else if (card.sqlType === 'insert') {
|
_verify.limitInvalid = true
|
_verify.limitText = '按钮操作类型为《添加》时,不能使用失效验证!'
|
_invalid = 'false'
|
} else if (card.Ot === 'notRequired') {
|
_verify.limitInvalid = true
|
_verify.limitText = '按钮《不选择行》时,不能使用失效验证!'
|
_invalid = '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.DeepSeekable = _verify.DeepSeekable || 'false'// DeepSeek是否开启
|
_verify.emailEnable = _verify.emailEnable || 'false' // 邮件发送是否开启
|
_verify.printEnable = _verify.printEnable || 'false' // 单据打印是否开启
|
_verify.preHandle = _verify.preHandle || 'false' // 按钮预处理是否开启
|
_verify.invalid = _invalid
|
_verify.uniques = _verify.uniques || []
|
_verify.contrasts = _verify.contrasts || []
|
_verify.accountdate = _verify.accountdate || 'false'
|
_verify.customverifys = _verify.customverifys || []
|
_verify.billcodes = _verify.billcodes || []
|
_verify.voucher = _verify.voucher || {enabled: false}
|
_verify.scripts = _verify.scripts || []
|
_verify.cbScripts = _verify.cbScripts || []
|
|
if (window.GLOB.process && card.intertype !== 'inner') {
|
_verify.workFlow = _verify.workFlow || 'false'
|
_verify.flowType = _verify.flowType || (card.sqlType === 'insert' ? 'start' : 'approval')
|
_verify.flowSql = _verify.flowSql || 'true'
|
} else {
|
delete _verify.workFlow
|
delete _verify.flowRemark
|
delete _verify.flowType
|
delete _verify.flowSql
|
}
|
|
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'
|
}
|
|
let oriVerify = fromJS(_verify).toJS()
|
|
if (_verify.wxAppId) {
|
if (!window.GLOB.WXApps || window.GLOB.WXApps.filter(app => app.appType === 'public').length === 0) {
|
delete _verify.wxAppId
|
}
|
}
|
|
this.setState({
|
activeKey: activeKey,
|
verifyInter: verifyInter,
|
verify: _verify,
|
oriVerify: oriVerify
|
})
|
|
if (card.intertype === 'inner') return
|
|
let _fields = []
|
if (card.OpenType === 'form') {
|
let item = {
|
field: card.field,
|
label: card.label,
|
type: 'text',
|
writein: true,
|
fieldlen: 50
|
}
|
|
if (card.formType === 'counter') {
|
item.type = 'number'
|
item.fieldlen = 0
|
} else if (card.formType === 'switch' || card.formType === 'radio') {
|
if (typeof(card.openVal) === 'number') {
|
item.type = 'number'
|
item.fieldlen = 0
|
}
|
}
|
|
_fields.push(item)
|
} else if (card.modal && (card.OpenType === 'pop' || !card.OpenType)) {
|
_fields = fromJS(card.modal.fields || []).toJS()
|
_fields = _fields.filter(_f => {
|
if (!_f.field) return false
|
|
_f.writein = _f.writein !== 'false'
|
_f.fieldlen = _f.fieldlength || 50
|
|
if (_f.type === 'linkMain' && _f.verifyVal === 'true') {
|
_f.$verify = true
|
}
|
|
if (_f.type === 'datemonth') {
|
_f.type = 'text'
|
} else if (_f.type === 'number' || _f.type === 'rate') {
|
_f.fieldlen = _f.decimal || 0
|
} else if (_f.type === 'date') {
|
_f.type = _f.declareType === 'nvarchar(50)' ? 'text' : 'date'
|
} else if (_f.type === 'datetime') {
|
_f.type = 'date'
|
} else if (_f.declare === 'decimal') {
|
_f.type = 'number'
|
_f.fieldlen = _f.decimal || 0
|
}
|
|
return true
|
})
|
}
|
|
let verIndex = _fields.findIndex(item => item.type === 'vercode')
|
if (verIndex > -1) {
|
_fields = fromJS(_fields).toJS()
|
_fields.splice(verIndex, 0, {
|
type: 'text',
|
fieldlen: 50,
|
writein: false,
|
field: 'mk_timestamp'
|
}, {
|
type: 'text',
|
fieldlen: 50,
|
writein: false,
|
field: 'mk_send_type'
|
}, {
|
type: 'text',
|
fieldlen: 50,
|
writein: false,
|
field: 'mk_n_id'
|
})
|
}
|
|
let sysfields = ['tbid', 'errorcode', 'retmsg', 'billcode', 'bvoucher', 'fibvoucherdate', 'fiyear', 'username', 'fullname', 'modulardetailcode', 'roleid', 'mk_departmentcode', 'mk_organization', 'mk_user_type', 'mk_nation', 'mk_province', 'mk_city', 'mk_district', 'mk_address', 'mk_deleted', 'bid', 'mk_submit_type']
|
let hasBid = false
|
|
let formfields = []
|
_fields.forEach(_f => {
|
let key = _f.field.toLowerCase()
|
if (key === 'bid') {
|
hasBid = true
|
}
|
|
if (sysfields.includes(key)) return
|
|
formfields.push(_f.field)
|
})
|
|
if (!hasBid) {
|
_fields.unshift({ uuid: 'BID', field: 'BID', label: 'BID', type: 'text', writein: false, fieldlen: 50 })
|
}
|
|
let unionFields = fromJS(_fields).toJS()
|
let formArr = _fields.map(_f => _f.field.toLowerCase())
|
let fieldArr = [...sysfields, ...formArr]
|
|
let colfields = []
|
if (card.Ot !== 'notRequired' && columns) {
|
columns.forEach(_f => {
|
if (!_f.field) return
|
|
let key = _f.field.toLowerCase()
|
|
if (formArr.includes(key)) return
|
|
unionFields.push(_f)
|
|
if (fieldArr.includes(key)) return
|
|
colfields.push(_f.field)
|
})
|
}
|
|
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,
|
formfields: formfields.join(', '),
|
colfields: colfields.join(', '),
|
uniqueColumns: this.state.uniqueColumns.map(col => {
|
if (col.dataIndex === 'field') {
|
col.options = fromJS(unionFields).toJS().map(n => {
|
n.label = `${n.label}(${n.field})`
|
return n
|
})
|
}
|
return col
|
}),
|
onceUniqueColumns: this.state.onceUniqueColumns.map(col => {
|
if (col.dataIndex === 'field') {
|
col.options = fromJS(_columns).toJS().map(n => {
|
n.label = `${n.label}(${n.field})`
|
return n
|
})
|
}
|
return col
|
}),
|
unionFields
|
})
|
}
|
|
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 =u.openid`))
|
},
|
{
|
obj_name: 'emailCodes',
|
arr_field: 'msn_email_temp_no,remark,id',
|
LText: window.btoa(window.encodeURIComponent(`select t.id,t.msn_email_temp_no,t.remark from (select * from bd_msn_email_temp where deleted=0) t inner join (select openid from susers where uid=@userid@) u on t.openid=u.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',
|
exec_type: 'x'
|
}
|
|
mutilparam.LText = Utils.formatOptions(mutilparam.LText, 'x')
|
mutilparam.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
|
mutilparam.secretkey = Utils.encrypt('', 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
|
}
|
}),
|
emailCodes: res.emailCodes.map(item => {
|
return {
|
name: item.remark,
|
value: item.msn_email_temp_no,
|
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
|
})
|
}
|
})
|
}
|
|
getSysExecSql = (verify, retmsg) => {
|
const { columns, config, card } = this.props
|
const { fields } = this.state
|
|
let btn = card
|
let primaryId = Utils.getuuid()
|
let BID = Utils.getuuid()
|
let _actionType = null
|
let setting = config.setting || {}
|
|
if (verify.uniques && verify.uniques.length > 0 && btn.Ot === 'requiredOnce') {
|
if (config.wrap && (config.wrap.datatype === 'static' || config.wrap.datatype === 'public')) {
|
verify.uniques = []
|
}
|
}
|
|
if (verify.default !== 'false') { // 判断是否使用默认sql
|
_actionType = btn.sqlType
|
}
|
|
let _initCustomScript = '' // 初始化脚本
|
let _prevCustomScript = '' // 默认sql前执行脚本
|
let _backCustomScript = '' // 默认sql后执行脚本
|
|
verify.scripts && verify.scripts.forEach(item => {
|
if (item.status === 'false') return
|
|
if (item.position === 'init') {
|
_initCustomScript += `
|
/* 自定义脚本 */
|
${item.sql}
|
`
|
} else if (item.position === 'front') {
|
_prevCustomScript += `
|
/* 自定义脚本 */
|
${item.sql}
|
`
|
} else {
|
_backCustomScript += `
|
/* 自定义脚本 */
|
${item.sql}
|
`
|
}
|
})
|
|
// 需要声明的变量集
|
let _vars = ['tbid', 'errorcode', 'retmsg', 'billcode', 'bvoucher', 'fibvoucherdate', 'fiyear', 'username', 'fullname', 'modulardetailcode', 'roleid', 'mk_departmentcode', 'mk_organization', 'mk_user_type', 'mk_nation', 'mk_province', 'mk_city', 'mk_district', 'mk_address', 'mk_deleted', 'bid', 'mk_submit_type']
|
|
// 主键字段
|
let primaryKey = setting.primaryKey || 'id'
|
|
if (this.props.side === 'sub') {
|
primaryKey = setting.subKey || 'id'
|
}
|
|
// sql语句
|
let _sql = ''
|
|
let _initvars = [] // 已赋值字段集
|
let _initFormfields = []
|
let _initColfields = []
|
let _declarefields = []
|
|
let formdata = fields.filter(item => item.uuid !== 'BID')
|
|
formdata = formdata.length ? formdata : null
|
|
let verifyValSql = ''
|
// 获取字段键值对
|
formdata && formdata.forEach(form => {
|
if (form.$verify) {
|
verifyValSql += `
|
if @${form.field}=${form.type === 'number' ? 0 : `''`}
|
begin
|
select @errorcode='E',@retmsg='${form.label},关联主表失效'
|
goto aaa
|
end
|
`
|
}
|
|
let _key = form.field.toLowerCase()
|
if (!_initvars.includes(_key)) {
|
_initvars.push(_key)
|
if (form.type === 'number' || form.type === 'rate') {
|
_initFormfields.push(`@${form.field}=1`)
|
} else if (form.type === 'date') {
|
_initFormfields.push(`@${form.field}='1949-10-01'`)
|
} else if (form.type === 'select' || form.type === 'link' || form.type === 'radio') {
|
_initFormfields.push(`@${form.field}='1'`)
|
} else {
|
_initFormfields.push(`@${form.field}='mk'`)
|
}
|
}
|
|
if (!_vars.includes(_key)) {
|
_vars.push(_key)
|
|
if (form.fieldlen && form.fieldlen > 4000) {
|
form.fieldlen = 'max'
|
}
|
|
let _type = `nvarchar(${form.fieldlen})`
|
|
if (form.type.match(/date/ig)) {
|
_type = 'datetime'
|
} else if (form.type === 'number') {
|
_type = `decimal(18,${form.fieldlen})`
|
} else if (form.type === 'rate') {
|
_type = `decimal(18,2)`
|
}
|
|
if (['appkey'].includes(_key)) return
|
|
_declarefields.push(`@${form.field} ${_type}`)
|
}
|
})
|
|
// 添加数据中字段,表单值优先(按钮不选行或多行拼接时跳过)
|
if (btn.Ot !== 'notRequired' && columns.length > 0) {
|
columns.forEach(col => {
|
if (!col.field) return
|
let _key = col.field.toLowerCase()
|
|
if (!_initvars.includes(_key)) {
|
_initvars.push(_key)
|
|
if (col.datatype && /^date/ig.test(col.datatype)) {
|
_initColfields.push(`@${col.field}='1949-10-01'`)
|
} else if (col.type === 'number') {
|
_initColfields.push(`@${col.field}=1`)
|
} else {
|
_initColfields.push(`@${col.field}='mk'`)
|
}
|
}
|
|
if (!_vars.includes(_key) && !['appkey'].includes(_key)) {
|
_vars.push(_key)
|
_declarefields.push(`@${col.field} ${col.datatype || 'nvarchar(50)'}`)
|
}
|
})
|
}
|
|
// 变量声明
|
_declarefields = _declarefields.join(',')
|
if (_declarefields) {
|
_declarefields = ',' + _declarefields
|
}
|
_sql = `Declare @tbid nvarchar(50),@ErrorCode nvarchar(50),@retmsg nvarchar(4000),@BillCode nvarchar(50),@BVoucher nvarchar(50),@FIBVoucherDate nvarchar(50), @FiYear nvarchar(50),@ModularDetailCode nvarchar(50), @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),@mk_deleted int,@bid nvarchar(50),@mk_submit_type nvarchar(50)${_declarefields}
|
`
|
|
let userName = 'User_Name'
|
let fullName = 'Full_Name'
|
let RoleID = 'role_id'
|
let departmentcode = 'departmentcode'
|
let organization = 'organization'
|
let mk_user_type = 'mk_user_type'
|
let nation = 'nation'
|
let province = 'province'
|
let city = 'city'
|
let district = 'district'
|
let address = 'address'
|
|
// 初始化凭证及用户信息字段
|
_sql += `
|
/* 凭证及用户信息初始化赋值 */
|
select @BVoucher='',@FIBVoucherDate='',@FiYear='',@ErrorCode='',@retmsg='',@UserName='${userName}', @FullName='${fullName}', @RoleID='${RoleID}', @mk_departmentcode='${departmentcode}', @mk_organization='${organization}', @mk_user_type='${mk_user_type}', @mk_nation='${nation}', @mk_province='${province}', @mk_city='${city}', @mk_district='${district}', @mk_address='${address}', @mk_deleted=1, @bid='${BID}', @mk_submit_type='', @BillCode='', @ModularDetailCode=''
|
`
|
|
// 表单变量赋值
|
if (_initFormfields.length > 0) {
|
_sql += `
|
/* 表单变量赋值 */
|
select ${_initFormfields.join(',')}
|
`
|
}
|
// 显示列变量赋值
|
if (_initColfields.length > 0) {
|
_sql += `
|
/* 显示列变量赋值 */
|
select ${_initColfields.join(',')}
|
`
|
}
|
|
if (retmsg) {
|
return _sql
|
}
|
|
// 去除禁用的验证
|
if (verify.contrasts) {
|
verify.contrasts = verify.contrasts.filter(item => item.status !== 'false')
|
}
|
if (verify.uniques) {
|
verify.uniques = verify.uniques.filter(item => item.status !== 'false')
|
}
|
if (verify.customverifys) {
|
verify.customverifys = verify.customverifys.filter(item => item.status !== 'false')
|
}
|
if (verify.billcodes) {
|
verify.billcodes = verify.billcodes.filter(item => item.status !== 'false')
|
}
|
|
if (_initCustomScript) {
|
_sql += _initCustomScript
|
}
|
|
// 启用账期验证
|
if (verify.accountdate === 'true') {
|
let orgcode = `''`
|
let date = `''`
|
if (verify.accountfield && _initvars.includes(verify.accountfield.toLowerCase())) {
|
orgcode = '@' + verify.accountfield
|
}
|
if (verify.voucherdate && _initvars.includes(verify.voucherdate.toLowerCase())) {
|
date = '@' + verify.voucherdate
|
}
|
|
_sql += `
|
/* 账期验证 */
|
exec s_FIBVoucherDateCheck @OrgCode=${orgcode},@FIBVoucherDate=${date},@ErrorCode=@ErrorCode OUTPUT,@retmsg=@retmsg OUTPUT
|
if @ErrorCode!=''
|
GOTO aaa
|
`
|
}
|
|
// 失效验证,添加数据时不用
|
if (verify.invalid === 'true') {
|
let datasource = setting.dataresource
|
let customScript = ''
|
|
config.scripts && config.scripts.forEach(script => {
|
if (script.status === 'false' || script.position === 'back') return
|
customScript += `
|
${script.sql}
|
`
|
})
|
|
if (/\s/.test(datasource)) {
|
datasource = '(' + datasource + ') tb'
|
}
|
|
let regoptions = [{
|
reg: new RegExp('@userName@', 'ig'),
|
value: `'${userName}'`
|
}, {
|
reg: new RegExp('@fullName@', 'ig'),
|
value: `'${fullName}'`
|
}, {
|
reg: new RegExp('@orderBy@', 'ig'),
|
value: setting.order || primaryKey
|
}, {
|
reg: new RegExp('@pageSize@', 'ig'),
|
value: 1
|
}, {
|
reg: new RegExp('@pageIndex@', 'ig'),
|
value: 1
|
}]
|
|
regoptions.forEach(item => {
|
datasource = datasource.replace(item.reg, item.value)
|
customScript = customScript.replace(item.reg, item.value)
|
})
|
|
if (customScript) {
|
_sql += `
|
/* 数据源自定义脚本,请注意变量定义是否重复 */
|
${customScript}
|
`
|
}
|
|
if (btn.Ot === 'requiredOnce') {
|
_sql += `
|
/* 失效验证 */
|
select @tbid='', @ErrorCode='',@retmsg=''
|
select @tbid='X' from ${datasource} right join (select ID from dbo.SplitComma(@ID@)) sp
|
on tb.${primaryKey} =sp.id where tb.${primaryKey} is null
|
|
If @tbid!=''
|
Begin
|
select @ErrorCode='E',@retmsg='数据已失效'
|
goto aaa
|
end
|
`
|
} else {
|
_sql += `
|
/* 失效验证 */
|
select @tbid='', @ErrorCode='',@retmsg=''
|
select @tbid=${primaryKey} from ${datasource} where ${primaryKey}=@ID@
|
If @tbid=''
|
Begin
|
select @ErrorCode='E',@retmsg='数据已失效'
|
goto aaa
|
end
|
`
|
}
|
}
|
|
// 比较验证
|
if (verify.contrasts && verify.contrasts.length > 0) {
|
verify.contrasts.forEach(item => {
|
_sql += `
|
/* 比较验证 */
|
If ${item.frontfield} ${item.operator} ${item.backfield}
|
Begin
|
select @ErrorCode='${item.errorCode}',@retmsg='${item.errmsg}'
|
goto aaa
|
end
|
`
|
})
|
}
|
|
// 自定义验证
|
verify.customverifys && verify.customverifys.forEach(item => {
|
_sql += `
|
/* 自定义验证 */
|
select @tbid='', @ErrorCode='',@retmsg=''
|
select top 1 @tbid='X' from (${item.sql}) a
|
If @tbid ${item.result === 'true' ? '!=' : '='}''
|
Begin
|
select @ErrorCode='${item.errorCode}',@retmsg='${item.errmsg}'
|
goto aaa
|
end
|
`
|
})
|
|
// 单号生成,使用上级id(BID)或列表数据,声明变量(检验)
|
let _billcodesSql = ''
|
if (formdata && verify.billcodes && verify.billcodes.length > 0) {
|
let keys = formdata.map(item => item.field.toLowerCase()) // 表单字段
|
|
verify.billcodes.forEach(item => {
|
let _key = item.field.toLowerCase()
|
|
if (!keys.includes(_key)) return // 表单中不含单号生成字段
|
|
let _lpline = ''
|
if (item.TypeCharOne === 'Lp') {
|
if (/^BID$/ig.test(item.linkField)) {
|
_lpline = `set @ModularDetailCode= 'Lp'+ right('${item.mark || btn.uuid}'+@BID@,48)`
|
} else {
|
_lpline = `set @ModularDetailCode= 'Lp'+ right('${item.mark || btn.uuid}'+@${item.linkField},48)`
|
}
|
} else if (item.TypeCharOne === 'BN') {
|
if (/^BID$/ig.test(item.linkField)) {
|
_lpline = `set @ModularDetailCode= 'BN'+ right(@BID@,48)`
|
} else {
|
_lpline = `set @ModularDetailCode= 'BN'+ right(@${item.linkField},48)`
|
}
|
} else {
|
_lpline = `set @ModularDetailCode= right('${item.ModularDetailCode}',50)`
|
}
|
|
_billcodesSql += `
|
/* 单号生成 */
|
select @BillCode='', @${_key}='', @ModularDetailCode=''
|
${_lpline}
|
exec s_get_BillCode
|
@ModularDetailCode=@ModularDetailCode,
|
@Type=${item.Type},
|
@TypeCharOne='${item.TypeCharOne}',
|
@TypeCharTwo ='${item.TypeCharTwo}',
|
@BillCode =@BillCode output,
|
@ErrorCode =@ErrorCode output,
|
@retmsg=@retmsg output
|
if @ErrorCode!=''
|
goto aaa
|
set @${_key}=@BillCode
|
`
|
})
|
|
if (_actionType !== 'insertOrUpdate') {
|
_sql += _billcodesSql
|
}
|
}
|
|
// 唯一性验证,必须存在表单(表单存在时,主键均为单值),必须填写数据源,多行拼接时不可用
|
if (formdata && verify.uniques && verify.uniques.length > 0 && btn.Ot !== 'requiredOnce') {
|
let dateForms = []
|
let numForms = []
|
formdata.forEach(form => {
|
let _key = form.field.toLowerCase()
|
if (form.type === 'date') {
|
dateForms.push(_key)
|
} else if (form.type === 'number' || form.type === 'rate') {
|
numForms.push(_key)
|
}
|
})
|
|
verify.uniques.forEach(item => {
|
let _fieldValue = [] // 表单键值对field=value
|
let _value = [] // 表单值,用于错误提示
|
let _labels = item.fieldlabel.split(',') // 表单提示文字
|
let arr = [] // 验证主键
|
|
item.field.split(',').forEach((_field, index) => {
|
let _key = _field.toLowerCase()
|
let _val = ''
|
let _val2 = ''
|
|
arr.push(_key)
|
if (_key === 'bid') {
|
_val = `'${BID}'`
|
} else {
|
_val = `@${_field}`
|
}
|
|
if (_key === 'bid') {
|
_val2 = BID
|
} else {
|
_val2 = `' + @${_field} + '`
|
}
|
|
_fieldValue.push(`${_key}=${_val}`)
|
_value.push(`${_labels[index] || ''}:${_val2}`)
|
})
|
|
if (!arr.includes(primaryKey.toLowerCase()) && btn.Ot !== 'notRequired') {
|
_fieldValue.push(`${primaryKey} !='${primaryId}'`)
|
}
|
|
_sql += `
|
/* 唯一性验证 */
|
select @tbid='', @ErrorCode='',@retmsg=''
|
select @tbid='X' from ${btn.sql} where ${_fieldValue.join(' and ')}${item.verifyType === 'logic' ? ' and deleted=0' : ''}
|
If @tbid!=''
|
Begin
|
select @ErrorCode='${item.errorCode}',@retmsg='${_value.join(', ')} 已存在'
|
goto aaa
|
end
|
`
|
})
|
} else if (verify.uniques && verify.uniques.length > 0 && btn.Ot === 'requiredOnce' && setting.dataresource) {
|
let datasource = setting.dataresource
|
if (/\s/.test(datasource)) { // 拼接别名
|
if (!/tb$/.test(datasource)) {
|
datasource = '(' + datasource + ') tb'
|
}
|
} else {
|
datasource = datasource + ' tb'
|
}
|
|
if (setting.customScript) {
|
_sql += `
|
/* 数据源自定义脚本,请注意变量定义是否重复 */
|
${setting.customScript}
|
`
|
}
|
|
verify.uniques.forEach(item => {
|
_sql += `
|
/* 同类数据验证 */
|
Set @tbid=''
|
|
Select top 1 @tbid='X' from (select distinct ${item.field},1 as n from ${datasource} inner join (select ID from dbo.SplitComma(@ID@)) sp on tb.${primaryKey}=sp.ID ) a having sum(n)>1
|
|
If @tbid!=''
|
Begin
|
Set @ErrorCode='E' Set @retmsg='${item.fieldlabel} 值不唯一'
|
goto aaa
|
end
|
`
|
})
|
}
|
|
let hasvoucher = false
|
|
// 凭证-显示列中选取,必须选行
|
if (verify.voucher && verify.voucher.enabled) {
|
let _voucher = verify.voucher
|
let linkField = `@${_voucher.linkField}`
|
|
if (/^BID$/ig.test(_voucher.linkField)) {
|
linkField = `'${BID}'`
|
}
|
|
hasvoucher = true
|
|
_sql += `
|
/* 创建凭证 */
|
exec s_BVoucher_Create
|
@Bill = ${linkField},
|
@BVoucherType ='${_voucher.BVoucherType}',
|
@VoucherTypeOne ='${_voucher.VoucherTypeOne}',
|
@VoucherTypeTwo ='${_voucher.VoucherTypeTwo}',
|
@Type =${_voucher.Type},
|
@UserID=@UserID@,
|
@Username=@Username,
|
@FullName=@FullName,
|
@BVoucher =@BVoucher OUTPUT ,
|
@FIBVoucherDate =@FIBVoucherDate OUTPUT ,
|
@FiYear =@FiYear OUTPUT ,
|
@ErrorCode =@ErrorCode OUTPUT,
|
@retmsg=@retmsg OUTPUT
|
if @ErrorCode!=''
|
GOTO aaa
|
`
|
}
|
|
let _insertsql = ''
|
if (_actionType === 'insert' || _actionType === 'insertOrUpdate') { // 添加语句
|
let keys = []
|
let values = []
|
|
formdata.forEach(item => {
|
if (item.writein === false) return
|
let _key = item.field.toLowerCase()
|
|
keys.push(_key)
|
values.push('@' + _key)
|
})
|
|
if (!keys.includes(primaryKey.toLowerCase())) {
|
keys.push(primaryKey.toLowerCase())
|
values.push('\'' + primaryId + '\'')
|
}
|
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 ${btn.sql} (${keys}) select ${values};`
|
}
|
|
let _updatesql = ''
|
if (_actionType === 'update' || _actionType === 'audit' || _actionType === 'insertOrUpdate') { // 修改语句
|
let _form = []
|
let _arr = []
|
|
formdata.forEach(item => {
|
if (item.writein === false) return
|
let _key = item.field.toLowerCase()
|
|
_arr.push(_key)
|
_form.push(_key + '=@' + _key)
|
})
|
|
if (_actionType === '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@')
|
}
|
} 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 (hasvoucher) {
|
if (!_arr.includes('bvoucher')) {
|
_form.push('BVoucher=@BVoucher')
|
}
|
if (!_arr.includes('fibvoucherdate')) {
|
_form.push('FIBVoucherDate=@FIBVoucherDate')
|
}
|
if (!_arr.includes('fiyear')) {
|
_form.push('FiYear=@FiYear')
|
}
|
}
|
if (!_arr.includes('typename')) {
|
_form.push('typename=@typename@')
|
}
|
_form = _form.join(',')
|
|
let _ID = '=@ID@'
|
if (btn.Ot === 'requiredOnce') {
|
_ID = ' in (select ID from dbo.SplitComma(@ID@))'
|
}
|
|
_updatesql = `update ${btn.sql} set ${_form} where ${primaryKey}${_ID};`
|
}
|
|
if (_prevCustomScript) {
|
_sql += _prevCustomScript
|
}
|
|
// 添加、修改、逻辑删除、物理删除
|
if (_actionType === 'insert') {
|
_sql += `
|
/* 默认sql */
|
${_insertsql}`
|
} else if (_actionType === 'update' || _actionType === 'audit') {
|
_sql += `
|
/* 默认sql */
|
${_updatesql}`
|
} else if (_actionType === 'LogicDelete') { // 逻辑删除
|
let _ID = '=@ID@'
|
if (btn.Ot === 'requiredOnce') {
|
_ID = ' in (select ID from dbo.SplitComma(@ID@))'
|
}
|
|
_sql += `
|
/* 默认sql */
|
update ${btn.sql} set deleted=@mk_deleted,modifydate=getdate(),modifyuser=@username,modifystaff=@fullname,modifyuserid=@userid@ where ${primaryKey}${_ID};`
|
} else if (_actionType === 'delete') { // 物理删除
|
let _msg = ''
|
if (columns && columns.length > 0 && btn.Ot !== 'notRequired') {
|
let _index = 0
|
columns.forEach(col => {
|
if (!col.field || col.Hide === 'true' || _index >= 4 || col.field === primaryKey) return
|
_msg += col.label + '=0,'
|
_index++
|
})
|
}
|
|
let _ID = '=@ID@'
|
if (btn.Ot === 'requiredOnce') {
|
_ID = ' in (select ID from dbo.SplitComma(@ID@))'
|
}
|
|
_sql += `
|
/* 默认sql */
|
insert into snote (remark,createuserid,CreateUser,CreateStaff,typename) select left('删除表:${btn.sql} 数据: ${_msg}${primaryKey}='+@ID@,200),@userid@,@username,@fullname,@typename@
|
delete ${btn.sql} where ${primaryKey}${_ID};`
|
} else if (_actionType === 'insertOrUpdate') {
|
_sql += `
|
/* 默认sql */
|
select @tbid=''
|
select @tbid='X' from ${btn.sql} where ${primaryKey}=@ID@
|
if @tbid=''
|
begin
|
${_billcodesSql}
|
${_insertsql}
|
end
|
else
|
begin
|
${_updatesql}
|
end
|
`
|
}
|
|
if (verify.workFlow === 'true' && window.GLOB.process) {
|
let status = 888
|
let statusName = '结束'
|
let detailId = '0'
|
|
if (verify.flowSql === 'true') {
|
if (verify.flowType === 'start') {
|
_sql += `
|
/* 工作流默认sql */
|
insert into s_my_works_flow (works_flow_id,works_flow_code,works_flow_name,works_flow_param,status,statusname,work_group,works_flow_detail_id,work_grade,bid,createuserid,CreateUser,CreateStaff,upid)
|
select @ID@,@works_flow_code@,@works_flow_name@,@works_flow_param@,@status@,@statusname@,@work_group@,@works_flow_detail_id@,@work_grade@,@bid@,@UserID@,@UserName,@FullName,@time_id@
|
insert into s_my_works_flow_log (works_flow_id,works_flow_code,works_flow_name,works_flow_param,status,statusname,works_flow_detail_id,work_group,work_grade,bid,createuserid,CreateUser,CreateStaff,upid)
|
select @ID@,@works_flow_code@,@works_flow_name@ ,@works_flow_param@,@status@,@statusname@,@works_flow_detail_id@,@work_group@,@work_grade@,@bid@,@UserID@,@UserName,@FullName,@time_id@
|
insert into s_my_works_flow_notice (works_flow_id,works_flow_code,works_flow_detail_id,userid,notice_type,createuserid,CreateUser,CreateStaff,upid)
|
select @ID@,@works_flow_code@,@works_flow_detail_id@,@userid@,@start_type@,@userid@,@UserName,@FullName,@time_id@
|
insert into s_my_works_flow_role (works_flow_id,works_flow_code,userid,works_flow_detail_id,createuserid,CreateUser,CreateStaff,upid,typecharone)
|
select @ID@,@works_flow_code@,@userid@,@works_flow_detail_id@,@userid@,@UserName,@FullName,@time_id@,'begin'
|
`
|
} else {
|
_sql += `
|
/* 工作流默认sql */
|
update s_my_works_flow set status=@status@,statusname=@statusname@,works_flow_param=@works_flow_param@,works_flow_detail_id=@works_flow_detail_id@,modifydate=getdate(),upid=@time_id@,modifyuserid=@userid@,modifyuser=@username,modifystaff=@fullname${verify.flowRemark ? ',remark=@' + verify.flowRemark : ''}
|
where works_flow_id=@ID@ and works_flow_code=@works_flow_code@ and deleted=0
|
insert into s_my_works_flow_log (works_flow_id,works_flow_code,works_flow_name,works_flow_param,status,statusname,works_flow_detail_id,work_group,work_grade,bid,createuserid,CreateUser,CreateStaff,upid${verify.flowRemark ? ',remark' : ''})
|
select @ID@,@works_flow_code@,@works_flow_name@ ,@works_flow_param@,@status@,@statusname@,@works_flow_detail_id@,@work_group@,@work_grade@,@bid@,@UserID@,@UserName,@FullName,@time_id@${verify.flowRemark ? ',@' + verify.flowRemark : ''}
|
|
update s_my_works_flow_role set deleted=10,modifydate=getdate(),upid=@time_id@,modifyuserid=@userid@,modifyuser=@username,modifystaff=@fullname
|
where works_flow_id=@ID@ and works_flow_code=@works_flow_code@ and deleted=0
|
|
if @check_userids@ != ''
|
begin
|
insert into s_my_works_flow_role (works_flow_id,works_flow_code,userid,works_flow_detail_id,createuserid,CreateUser,CreateStaff,upid)
|
select @ID@,@works_flow_code@,ID,@works_flow_detail_id@,@userid@,@UserName,@FullName,@time_id@ from dbo.SplitComma(@check_userids@)
|
insert into s_my_works_flow_notice (works_flow_id,works_flow_code,works_flow_detail_id,userid,notice_type,createuserid,CreateUser,CreateStaff,upid)
|
select @ID@,@works_flow_code@,@works_flow_detail_id@,ID,@check_type@,@userid@,@UserName,@FullName,@time_id@ from dbo.SplitComma(@check_userids@)
|
end
|
if @notice_userids@ != ''
|
begin
|
update n
|
set deleted=10,modifydate=getdate(),upid=@time_id@,modifyuserid=@userid@,modifyuser=@username,modifystaff=@fullname
|
from (select * from s_my_works_flow_notice where works_flow_id=@ID@ and works_flow_code=@works_flow_code@ and deleted=0) n
|
inner join (select ID from dbo.SplitComma(@notice_userids@)) s
|
on n.userid = s.id
|
insert into s_my_works_flow_notice (works_flow_id,works_flow_code,works_flow_detail_id,userid,notice_type,createuserid,CreateUser,CreateStaff,upid)
|
select @ID@,@works_flow_code@,@works_flow_detail_id@,ID,@notice_type@,@userid@,@UserName,@FullName,@time_id@ from dbo.SplitComma(@notice_userids@)
|
end
|
`
|
}
|
}
|
|
if (_backCustomScript) {
|
_sql += _backCustomScript
|
}
|
|
_sql = _sql.replace(/@works_flow_code@/ig, `'mk'`)
|
_sql = _sql.replace(/@works_flow_name@/ig, `'mk'`)
|
_sql = _sql.replace(/@works_flow_param@/ig, `''`)
|
_sql = _sql.replace(/@works_flow_detail_id@/ig, `'${detailId}'`)
|
_sql = _sql.replace(/@status@/ig, `'${status}'`)
|
_sql = _sql.replace(/@statusname@/ig, `'${statusName}'`)
|
_sql = _sql.replace(/@work_group@/ig, `'mk'`)
|
_sql = _sql.replace(/@work_grade@/ig, `'0'`)
|
|
if (verify.flowType === 'start') {
|
_sql = _sql.replace(/@start_type@/ig, `'开始'`)
|
} else {
|
_sql = _sql.replace(/@check_type@/ig, `'审核'`)
|
_sql = _sql.replace(/@notice_type@/ig, `'抄送'`)
|
|
_sql = _sql.replace(/@check_userids@/ig, `''`)
|
_sql = _sql.replace(/@notice_userids@/ig, `''`)
|
|
_sql = _sql.replace(/@works_flow_sign@/ig, `''`)
|
}
|
} else if (_backCustomScript) {
|
_sql += _backCustomScript
|
}
|
|
if (verifyValSql) {
|
_sql += verifyValSql
|
}
|
|
if (btn.procMode === 'system') {
|
_sql += `
|
aaa: if @ErrorCode!=''
|
insert into tmp_err_retmsg (ID, ErrorCode, retmsg, CreateUserID) select @time_id@,@ErrorCode, @retmsg,@UserID@`
|
} else if (btn.output) {
|
_sql += `
|
aaa: select @ErrorCode as ErrorCode,@retmsg as retmsg,${btn.output} as mk_b_id`
|
} else {
|
_sql += `
|
aaa: select @ErrorCode as ErrorCode,@retmsg as retmsg`
|
}
|
|
_sql = _sql.replace(/@ID@/ig, `'${primaryId || ''}'`)
|
_sql = _sql.replace(/@BID@/ig, `'${BID}'`)
|
_sql = _sql.replace(/@typename@/ig, `'typename'`)
|
_sql = _sql.replace(/@\$|\$@/ig, '').replace(/@datam@/ig, `''`)
|
_sql = _sql.replace(/\$check@|@check\$/ig, '')
|
|
return _sql
|
}
|
|
getSysBackSql = (scripts, cbTable) => {
|
let _prev = ''
|
let _back = ''
|
|
scripts.forEach(script => {
|
if (script.status === 'false') return
|
|
if (script.position === 'front') {
|
_prev += `
|
/* 自定义脚本 */
|
${script.sql}
|
`
|
} else {
|
_back += `
|
/* 自定义脚本 */
|
${script.sql}
|
`
|
}
|
})
|
|
if (!_prev) return _back
|
|
let tbs = []
|
_prev.replace(/\/\*[^/*]+\*\//g, '').replace(/\n|\r/g, ' ').split(/\sdeclare\s+|\screate\s+table\s+/ig).forEach(line => {
|
if (/^\s*(@|#)[a-zA-Z0-9_]+\s+table\s+\(/ig.test(line)) {
|
line = line.replace(/\s+table\s+\(/, '(')
|
}
|
if (!/^\s*(@|#)[a-zA-Z0-9_]+\s*\(/ig.test(line)) return
|
let tb = line.match(/(@|#)[a-zA-Z0-9_]+\s*\(.+(\)|date|datetime)\s*\)/ig)
|
|
if (tb && tb.length === 1) {
|
tbs.push(tb[0])
|
}
|
})
|
|
tbs.forEach(tb => {
|
let tbName = tb.match(/(@|#)[a-zA-Z0-9_]+/ig)[0]
|
|
if (!tbName) return
|
|
let content = tb.replace(/(@|#)[a-zA-Z0-9_]+\s*\(\s*/, '').replace(/\s*\)$/, '')
|
content = content.replace(/decimal\(\s*\d+\s*,\s*\d+\s*\)/ig, 'decimal')
|
|
let keys = []
|
let vals = []
|
let error = false
|
let istop = new RegExp(cbTable + '$', 'ig').test(tbName)
|
let id = tbName.replace(/@|#/, '')
|
|
content.split(/\s*,\s*/).forEach(m => {
|
let ms = m.split(/\s+/)
|
if (ms.length > 1) {
|
keys.push(ms[0])
|
if (/^mk_level$/i.test(ms[0])) {
|
vals.push(istop ? `'1'` : `'2'`)
|
} else if (/^mk_id$/i.test(ms[0])) {
|
vals.push(istop ? `'${cbTable}'` : `'${id}'`)
|
} else if (/^mk_bid$/i.test(ms[0])) {
|
vals.push(istop ? `''` : `'${cbTable}'`)
|
} else if (/nvarchar/i.test(ms[1])) {
|
vals.push(`'mk'`)
|
} else if (/date/i.test(ms[1])) {
|
vals.push(`'1949-10-01'`)
|
} else if (/int|decimal/i.test(ms[1])) {
|
vals.push('0')
|
} else {
|
error = true
|
}
|
} else {
|
error = true
|
}
|
})
|
|
if (error || vals.length === 0) return
|
|
_prev += `
|
Insert into ${tbName} (${keys.join(',')})
|
Select ${vals.join(',')}
|
`
|
})
|
|
return _prev + _back
|
}
|
|
getSysDefSql = () => {
|
const { columns, config, card } = this.props
|
const { fields, verify } = this.state
|
|
let btn = card
|
let _actionType = btn.sqlType
|
let setting = config.setting || {}
|
|
// 主键字段
|
let primaryKey = setting.primaryKey || 'id'
|
|
if (this.props.side === 'sub') {
|
primaryKey = setting.subKey || 'id'
|
}
|
|
let _sql = ''
|
|
let _insertsql = ''
|
if (_actionType === 'insert' || _actionType === 'insertOrUpdate') { // 添加语句
|
let keys = []
|
let values = []
|
|
fields.forEach(item => {
|
if (item.writein === false) return
|
let _key = item.field.toLowerCase()
|
|
keys.push(_key)
|
values.push('@' + _key)
|
})
|
|
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 ${btn.sql} (${keys}) select ${values};`
|
}
|
|
let _updatesql = ''
|
if (_actionType === 'update' || _actionType === 'audit' || _actionType === 'insertOrUpdate') { // 修改语句
|
let _form = []
|
let _arr = []
|
|
fields.forEach(item => {
|
if (item.writein === false) return
|
let _key = item.field.toLowerCase()
|
|
_arr.push(_key)
|
_form.push(_key + '=@' + _key)
|
})
|
|
if (_actionType === '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@')
|
}
|
} 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@')
|
}
|
}
|
|
let hasvoucher = false
|
|
// 凭证-显示列中选取,必须选行
|
if (verify.voucher && verify.voucher.enabled) {
|
hasvoucher = true
|
}
|
if (hasvoucher) {
|
if (!_arr.includes('bvoucher')) {
|
_form.push('BVoucher=@BVoucher')
|
}
|
if (!_arr.includes('fibvoucherdate')) {
|
_form.push('FIBVoucherDate=@FIBVoucherDate')
|
}
|
if (!_arr.includes('fiyear')) {
|
_form.push('FiYear=@FiYear')
|
}
|
}
|
if (!_arr.includes('typename')) {
|
_form.push('typename=@typename@')
|
}
|
_form = _form.join(', ')
|
|
let _ID = '=@ID@'
|
if (btn.Ot === 'requiredOnce') {
|
_ID = ' in (select ID from dbo.SplitComma(@ID@))'
|
}
|
|
_updatesql = `update ${btn.sql} set ${_form} where ${primaryKey}${_ID};`
|
}
|
|
// 添加、修改、逻辑删除、物理删除
|
if (_actionType === 'insert') {
|
_sql = _insertsql
|
} else if (_actionType === 'update' || _actionType === 'audit') {
|
_sql = _updatesql
|
} else if (_actionType === 'LogicDelete' || _actionType === 'custom') { // 逻辑删除
|
let _ID = '=@ID@'
|
if (btn.Ot === 'requiredOnce') {
|
_ID = ' in (select ID from dbo.SplitComma(@ID@))'
|
}
|
|
_sql = `update ${btn.sql} set deleted=@mk_deleted,modifydate=getdate(),modifyuser=@username,modifystaff=@fullname,modifyuserid=@userid@ where ${primaryKey}${_ID};`
|
} else if (_actionType === 'delete') { // 物理删除
|
let _msg = ''
|
if (columns && columns.length > 0 && btn.Ot !== 'notRequired') {
|
let _index = 0
|
columns.forEach(col => {
|
if (!col.field || col.Hide === 'true' || _index >= 4 || col.field === primaryKey) return
|
_msg += col.label + '=0,'
|
_index++
|
})
|
}
|
|
let _ID = '=@ID@'
|
if (btn.Ot === 'requiredOnce') {
|
_ID = ' in (select ID from dbo.SplitComma(@ID@))'
|
}
|
|
_sql = `insert into snote (remark,createuserid,CreateUser,CreateStaff,typename) select left('删除表:${btn.sql} 数据: ${_msg}${primaryKey}='+@ID@,200),@userid@,@username,@fullname,@typename@
|
delete ${btn.sql} where ${primaryKey}${_ID};`
|
} else if (_actionType === 'insertOrUpdate') {
|
_sql = `
|
/* 默认sql */
|
select @tbid=''
|
select @tbid='X' from ${btn.sql} where ${primaryKey}=@ID@
|
if @tbid=''
|
begin
|
${_insertsql}
|
end
|
else
|
begin
|
${_updatesql}
|
end
|
`
|
}
|
|
return _sql
|
}
|
|
orderSql = (record) => {
|
let _lpline = ''
|
if (record.TypeCharOne === 'Lp') {
|
if (record.linkField.toLowerCase() === 'bid') {
|
_lpline = `set @ModularDetailCode= 'Lp'+ right('${record.mark || this.props.card.uuid}'+@BID@,48)`
|
} else {
|
_lpline = `set @ModularDetailCode= 'Lp'+ right('${record.mark || this.props.card.uuid}'+@${record.linkField.toLowerCase()},48)`
|
}
|
} else if (record.TypeCharOne === 'BN') {
|
if (record.linkField.toLowerCase() === 'bid') {
|
_lpline = `set @ModularDetailCode= 'BN'+ right(@BID@,48)`
|
} else {
|
_lpline = `set @ModularDetailCode= 'BN'+ right(@${record.linkField.toLowerCase()},48)`
|
}
|
} else {
|
_lpline = `set @ModularDetailCode= right('${record.ModularDetailCode}',50)`
|
}
|
|
let sql = `Declare @BillCode nvarchar(50),@ModularDetailCode nvarchar(50)
|
select @BillCode='', @${record.field}='', @ModularDetailCode=''
|
${_lpline}
|
exec s_get_BillCode
|
@ModularDetailCode=@ModularDetailCode,
|
@Type=${record.Type},
|
@TypeCharOne='${record.TypeCharOne}',
|
@TypeCharTwo ='${record.TypeCharTwo}',
|
@BillCode =@BillCode output,
|
@ErrorCode =@ErrorCode output,
|
@retmsg=@retmsg output
|
if @ErrorCode!=''
|
goto aaa
|
set @${record.field}=@BillCode`
|
|
Modal.info({
|
title: '',
|
width: 500,
|
className: 'sql-example',
|
icon: null,
|
content: sql.split(/\n\s{4}/ig).map((n, index) => <div key={index} dangerouslySetInnerHTML={{ __html: n.replace(/\s/ig, ' ') }} style={{whiteSpace: 'nowrap'}}></div>)
|
})
|
}
|
|
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, resolve, reject) => {
|
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)
|
}
|
|
if (resolve) {
|
let sql = this.getSysExecSql(verify, false)
|
|
Api.sDebug(sql).then(res => {
|
if (res.status || res.ErrCode === '-2') {
|
resolve()
|
|
this.setState({ verify })
|
} else {
|
reject()
|
|
Modal.error({
|
title: res.message
|
})
|
}
|
})
|
} else {
|
let sql = this.getSysExecSql(verify, false)
|
|
Api.sDebug(sql, true)
|
|
this.setState({ verify })
|
}
|
}
|
|
scriptsChange = (values, resolve, reject) => {
|
const { columns, card } = this.props
|
|
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)
|
}
|
|
if (/@bvoucher(\s|\))/ig.test(values.sql) && !/s_BVoucher_Create/ig.test(values.sql)) {
|
if (verify.voucher && verify.voucher.enabled) {
|
|
} else if (card.Ot !== 'notRequired' && columns) {
|
let hasvoucher = false
|
columns.forEach(_f => {
|
if (!_f.field) return
|
|
if (_f.field.toLowerCase() === 'bvoucher') {
|
hasvoucher = true
|
}
|
})
|
|
if (!hasvoucher) {
|
notification.warning({
|
top: 92,
|
message: '未启用创建凭证,且字段集中不存在凭证字段(bvoucher)。',
|
duration: 5
|
})
|
}
|
} else {
|
notification.warning({
|
top: 92,
|
message: '未启用创建凭证,且字段集中不存在凭证字段(bvoucher)。',
|
duration: 5
|
})
|
}
|
}
|
|
if (resolve) {
|
let sql = this.getSysExecSql(verify, false)
|
|
Api.sDebug(sql).then(res => {
|
if (res.status || res.ErrCode === '-2') {
|
resolve()
|
values && MKEmitter.emit('editLineId', values.uuid)
|
|
this.setState({ verify })
|
} else {
|
reject()
|
|
Modal.error({
|
title: res.message
|
})
|
}
|
})
|
} else {
|
let sql = this.getSysExecSql(verify, false)
|
|
Api.sDebug(sql, true)
|
|
MKEmitter.emit('editLineId', values.uuid)
|
|
this.setState({ verify })
|
}
|
}
|
|
cbScriptsChange = (values, resolve, reject) => {
|
const { card } = this.props
|
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)
|
}
|
|
if (resolve) {
|
let sql = this.getSysBackSql(verify.cbScripts, card.cbTable)
|
|
if (sql) {
|
let defSql = this.getSysExecSql(verify, true)
|
|
sql = `${defSql}
|
${sql}
|
`
|
|
if (card.output) {
|
sql += `
|
aaa: select @ErrorCode as ErrorCode,@retmsg as retmsg,${card.output} as mk_b_id`
|
} else {
|
sql += `
|
aaa: select @ErrorCode as ErrorCode,@retmsg as retmsg`
|
}
|
|
sql = sql.replace(/@typename@/ig, `'typename'`)
|
sql = sql.replace(/@\$|\$@/ig, '').replace(/@datam@/ig, `''`)
|
|
Api.sDebug(sql).then(res => {
|
if (res.status || res.ErrCode === '-2') {
|
resolve()
|
|
MKEmitter.emit('editLineId', values.uuid)
|
|
this.setState({ verify })
|
} else {
|
reject()
|
|
Modal.error({
|
title: res.message
|
})
|
}
|
})
|
} else {
|
MKEmitter.emit('editLineId', values.uuid)
|
|
this.setState({ verify })
|
}
|
} else {
|
let sql = this.getSysBackSql(verify.cbScripts, card.cbTable)
|
|
if (sql) {
|
let defSql = this.getSysExecSql(verify, true)
|
|
sql = `${defSql}
|
${sql}
|
`
|
|
if (card.output) {
|
sql += `
|
aaa: select @ErrorCode as ErrorCode,@retmsg as retmsg,${card.output} as mk_b_id`
|
} else {
|
sql += `
|
aaa: select @ErrorCode as ErrorCode,@retmsg as retmsg`
|
}
|
|
sql = sql.replace(/@typename@/ig, `'typename'`)
|
sql = sql.replace(/@\$|\$@/ig, '').replace(/@datam@/ig, `''`)
|
|
Api.sDebug(sql, true)
|
}
|
|
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, unionFields, columnsFields } = this.state
|
|
let _fields = []
|
let change = {}
|
if (card.Ot !== 'requiredOnce') {
|
_fields = unionFields
|
} 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 { 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.workFlow === 'true' && verify.flowSql === 'true') && verify.scripts.length === 0) {
|
notification.warning({
|
top: 92,
|
message: '不执行默认sql时,必须设置自定义脚本!',
|
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*/`)
|
// })
|
// })
|
// }
|
|
delete verify.limitInvalid
|
delete verify.limitText
|
|
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, columns } = this.props
|
const { activeKey, verifyInter, verify, fields, uniqueColumns, unionFields, onceUniqueColumns, columnsFields, contrastColumns, customColumns, orderColumns, scriptsColumns, cbScriptsColumns, orderModular, orderModularDetail, voucher, voucherDetail, notes, emailCodes, appType, formfields, colfields } = 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} fields={fields} columns={columns} unionFields={unionFields} verify={verify} notes={notes} emailCodes={emailCodes} 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', 'sql']} 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}
|
formfields={formfields}
|
colfields={colfields}
|
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' && (['form', 'pop'].includes(card.OpenType) || !card.OpenType) ? <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={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' && (card.Ot === 'requiredOnce' || (['form', 'pop'].includes(card.OpenType) || !card.OpenType)) ? <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' ? unionFields : columnsFields}
|
uniqueChange={this.uniqueChange}
|
/>
|
<EditTable actions={['edit', 'move', 'del', 'status', 'sql']} 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={unionFields}
|
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
|
scripts={verify.scripts}
|
getScriptsFullForm={() => this.scriptsFullForm}
|
getScriptsForm={() => this.scriptsForm}
|
handleStatus={this.handleStatus}
|
handleDelete={this.handleDelete}
|
>
|
<CustomScript
|
type="fullscreen"
|
btn={this.props.card}
|
workFlow={verify.workFlow}
|
flowRemark={verify.flowRemark}
|
flowType={verify.flowType}
|
flowSql={verify.flowSql}
|
formfields={formfields}
|
colfields={colfields}
|
systemScripts={this.state.systemScripts}
|
scriptsChange={this.scriptsChange}
|
wrappedComponentRef={(inst) => this.scriptsFullForm = inst}
|
/>
|
</FullScripts>
|
<CustomScript
|
btn={this.props.card}
|
workFlow={verify.workFlow}
|
flowRemark={verify.flowRemark}
|
flowType={verify.flowType}
|
flowSql={verify.flowSql}
|
getSysDefSql={this.getSysDefSql}
|
formfields={formfields}
|
colfields={colfields}
|
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">
|
<FullScripts
|
scripts={verify.cbScripts}
|
getScriptsFullForm={() => this.cbscriptsFullForm}
|
getScriptsForm={() => this.cbscriptsForm}
|
handleStatus={(item) => this.handleStatus(item, 'cbscripts')}
|
handleDelete={(item) => this.handleDelete(item, 'cbscripts')}
|
>
|
<CallBackCustomScript
|
type="fullscreen"
|
btn={this.props.card}
|
formfields={formfields}
|
colfields={colfields}
|
systemScripts={this.state.systemScripts}
|
cbScriptsChange={this.cbScriptsChange}
|
wrappedComponentRef={(inst) => this.cbscriptsFullForm = inst}
|
/>
|
</FullScripts>
|
<CallBackCustomScript
|
btn={this.props.card}
|
formfields={formfields}
|
colfields={colfields}
|
systemScripts={this.state.systemScripts}
|
cbScriptsChange={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)
|