| | |
| | | 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 { 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 BillcodeForm from './billcodeform' |
| | | import VoucherForm from './voucherform' |
| | | import asyncComponent from '@/utils/asyncComponent' |
| | | import { updateForm } from '@/utils/utils-update.js' |
| | | // import { updateForm } from '@/utils/utils-update.js' |
| | | import MKEmitter from '@/utils/events.js' |
| | | import './index.scss' |
| | | |
| | |
| | | |
| | | class VerifyCard extends Component { |
| | | static propTpyes = { |
| | | btnTab: PropTypes.any, // 表单标签页(按钮)参数 |
| | | config: PropTypes.any, // 表单标签页参数 |
| | | card: PropTypes.object, // 按钮信息 |
| | | columns: PropTypes.array |
| | |
| | | <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: [ |
| | |
| | | </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: '运算符', |
| | | dataIndex: 'operator', |
| | | width: '14%', |
| | | width: '13%', |
| | | editable: true, |
| | | inputType: 'select', |
| | | options: [ |
| | |
| | | { |
| | | title: '提示信息', |
| | | dataIndex: 'errmsg', |
| | | width: '14%', |
| | | width: '13%', |
| | | inputType: 'input', |
| | | editable: true |
| | | }, |
| | | { |
| | | title: '报错编码', |
| | | dataIndex: 'errorCode', |
| | | width: '14%', |
| | | width: '13%', |
| | | editable: true, |
| | | inputType: 'select', |
| | | options: [ |
| | |
| | | <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: [ |
| | |
| | | }> |
| | | <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, btnTab } = this.props |
| | | const { columns, config, card } = this.props |
| | | const { appType } = this.state |
| | | let _verify = fromJS(card.verify || {}).toJS() |
| | | |
| | |
| | | oriVerify: fromJS(_verify).toJS() |
| | | }) |
| | | |
| | | if (card.intertype === 'inner') { |
| | | return |
| | | } |
| | | if (card.intertype === 'inner') return |
| | | |
| | | new Promise(resolve => { |
| | | let _fields = [] |
| | | if (card.OpenType === 'form') { |
| | | _fields.push({ |
| | |
| | | label: card.label, |
| | | type: 'text' |
| | | }) |
| | | 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'] |
| | |
| | | } else if (_f.type === 'number') { |
| | | _type = `decimal(18,${_fieldlen})` |
| | | _select.push(`@${_f.field}=0`) |
| | | } else if (_f.declare === 'decimal') { |
| | | _type = `decimal(18,${_f.decimal || 0})` |
| | | _select.push(`@${_f.field}=0`) |
| | | } else if (_f.type === 'rate') { |
| | | _type = `decimal(18,2)` |
| | | _select.push(`@${_f.field}=0`) |
| | |
| | | _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) { |
| | | if (card.Ot !== 'notRequired' && columns) { |
| | | columns.forEach(_f => { |
| | | if (_f.field && !formArr.includes(_f.field.toLowerCase())) { |
| | | formArr.push(_f.field.toLowerCase()) |
| | | if (!_f.field) return |
| | | |
| | | let key = _f.field.toLowerCase() |
| | | |
| | | if (!formArr.includes(key)) { |
| | | formArr.push(key) |
| | | unionFields.push(_f) |
| | | } |
| | | if (!_f.field || fieldArr.includes(_f.field.toLowerCase())) return |
| | | |
| | | fieldArr.push(_f.field.toLowerCase()) |
| | | if (fieldArr.includes(key)) return |
| | | |
| | | fieldArr.push(key) |
| | | _usefulfields.push(_f.field) |
| | | |
| | | if (_f.datatype) { // 自定义字段 |
| | |
| | | unionFields, |
| | | uniqueFields |
| | | }) |
| | | }) |
| | | } |
| | | |
| | | componentDidMount() { |
| | |
| | | }) |
| | | } |
| | | |
| | | orderSql = (record) => { |
| | | let _ModularDetailCode = '' |
| | | 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)` |
| | | } |
| | | _ModularDetailCode = '@ModularDetailCode' |
| | | } else if (record.TypeCharOne === 'BN') { |
| | | _ModularDetailCode = `'${record.TypeCharOne}'` |
| | | } else { |
| | | _ModularDetailCode = `'${record.ModularDetailCode}'` |
| | | } |
| | | |
| | | let sql = `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() |
| | | |
| | |
| | | } |
| | | |
| | | scriptsChange = (values) => { |
| | | const { columns, card } = this.props |
| | | |
| | | let verify = fromJS(this.state.verify).toJS() |
| | | |
| | | if (values.uuid) { |
| | |
| | | } else { |
| | | values.uuid = Utils.getuuid() |
| | | verify.scripts.push(values) |
| | | } |
| | | |
| | | if (/@bvoucher(\s|\))/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 |
| | | }) |
| | | } |
| | | } |
| | | |
| | | MKEmitter.emit('editLineId', values.uuid) |
| | |
| | | </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}})}/> |
| | | <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> |
| | |
| | | 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}/> |
| | | <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> |