| | |
| | | import React, {Component} from 'react' |
| | | import PropTypes from 'prop-types' |
| | | import { is, fromJS } from 'immutable' |
| | | import { Form, Tabs, Row, Col, Radio, Button, Select, Popconfirm, notification, Modal, message, InputNumber, Tooltip, Typography } from 'antd' |
| | | import { QuestionCircleOutlined, CheckCircleOutlined, StopOutlined, EditOutlined, SwapOutlined, DeleteOutlined, ExclamationOutlined, BorderOutlined } from '@ant-design/icons' |
| | | import { Form, Tabs, Row, Col, Button, Popconfirm, notification, Modal, message, InputNumber, Typography } from 'antd' |
| | | import { CheckCircleOutlined, StopOutlined, EditOutlined, SwapOutlined, DeleteOutlined, ExclamationOutlined, BorderOutlined } 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 options from '@/store/options.js' |
| | | import BaseForm from './baseform' |
| | | import UniqueForm from './uniqueform' |
| | | import ContrastForm from './contrastform' |
| | | import CustomForm from './customform' |
| | |
| | | |
| | | state = { |
| | | initsql: '', // sql验证时变量声明及赋值 |
| | | verifyInter: 'system', // 接口类型 |
| | | activeKey: 'base', |
| | | appType: sessionStorage.getItem('appType'), |
| | | notes: [], // 短信模板 |
| | | setting: null, |
| | |
| | | } |
| | | |
| | | _verify.default = _verify.default || 'true' |
| | | _verify.wxNote = _verify.wxNote || 'false' // 公众号消息推送是否开启 |
| | | _verify.noteEnable = _verify.noteEnable || 'false' // 短信发送是否开启 |
| | | _verify.noteType = _verify.noteType || 'N' // 短信发送模式:Y(实时)、N(定时) |
| | | _verify.noteTemp = _verify.noteTemp || 'Y' // 短信发送模板:Y(相同)、N(不同) |
| | |
| | | item.$index = i + 1 |
| | | }) |
| | | |
| | | let verifyInter = card.intertype === 'system' || (card.intertype === 'custom' && card.procMode === 'system') ? 'system' : 'inner' |
| | | |
| | | this.setState({ |
| | | activeKey: verifyInter === 'system' ? 'base' : 'tip', |
| | | verifyInter: verifyInter, |
| | | setting: config.setting || {}, |
| | | verify: _verify, |
| | | oriVerify: fromJS(_verify).toJS() |
| | |
| | | this.setState({ verify }) |
| | | } |
| | | |
| | | onNoteCodeChange = (val, option) => { |
| | | const { verify } = this.state |
| | | |
| | | this.setState({ |
| | | verify: {...verify, noteCode: val, noteId: option.props.id} |
| | | }) |
| | | } |
| | | |
| | | onOptionChange = (e, key) => { |
| | | const { verify } = this.state |
| | | let value = e.target.value |
| | | |
| | | this.setState({ |
| | | verify: {...verify, [key]: value} |
| | | }) |
| | | } |
| | | |
| | | changeAccField = (val) => { |
| | | const { verify } = this.state |
| | | |
| | | this.setState({ |
| | | verify: {...verify, accountfield: val} |
| | | }) |
| | | } |
| | | |
| | | changeAccDate = (val) => { |
| | | const { verify } = this.state |
| | | |
| | | this.setState({ |
| | | verify: {...verify, voucherdate: val} |
| | | }) |
| | | } |
| | | |
| | | handleDelete = (record, type) => { |
| | | const { verify } = this.state |
| | | |
| | |
| | | |
| | | handleConfirm = () => { |
| | | const { card } = this.props |
| | | const { setting } = this.state |
| | | const { setting, activeKey } = this.state |
| | | let verify = fromJS(this.state.verify).toJS() |
| | | |
| | | if (activeKey === 'base') { |
| | | let msg = this.baseForm.handleConfirm() |
| | | |
| | | if (msg) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: msg, |
| | | duration: 5 |
| | | }) |
| | | return Promise.reject() |
| | | } |
| | | } |
| | | |
| | | // 表单提交时检查输入值是否正确 |
| | | return new Promise((resolve, reject) => { |
| | |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '不执行默认sql时,必须设置自定义脚本!', |
| | | duration: 5 |
| | | }) |
| | | return |
| | | } else if (verify.accountdate === 'true' && !verify.accountfield) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '开启账期时,需要选择验证公司!', |
| | | duration: 5 |
| | | }) |
| | | return |
| | |
| | | msg = '自定义脚本' |
| | | } else if (this.scriptsForm && this.scriptsForm.props.form.getFieldValue('sql') && !/^\s+$/.test(this.scriptsForm.props.form.getFieldValue('sql'))) { |
| | | msg = '自定义脚本' |
| | | } |
| | | |
| | | if (verify.noteEnable === 'true' && !verify.noteCode) { // 开启短信时,需要模板编码 |
| | | verify.noteEnable = 'false' |
| | | } else if (verify.noteEnable !== 'true' && verify.noteCode) { |
| | | verify.noteCode = '' |
| | | } |
| | | |
| | | if (window.GLOB.funcs && window.GLOB.funcs.length > 0) { |
| | |
| | | }) |
| | | } |
| | | |
| | | 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更新 |
| | | */ |
| | |
| | | |
| | | render() { |
| | | const { card } = this.props |
| | | const { verify, fields, visible, uniqueFields, uniqueColumns, unionFields, onceUniqueColumns, columnsFields, contrastColumns, customColumns, orderColumns, scriptsColumns, cbScriptsColumns, orderModular, orderModularDetail, voucher, voucherDetail, notes, appType } = this.state |
| | | const { activeKey, verifyInter, verify, fields, visible, uniqueFields, uniqueColumns, unionFields, onceUniqueColumns, columnsFields, contrastColumns, customColumns, orderColumns, scriptsColumns, cbScriptsColumns, orderModular, orderModularDetail, voucher, voucherDetail, notes, appType } = this.state |
| | | const formItemLayout = { |
| | | labelCol: { |
| | | xs: { span: 24 }, |
| | |
| | | |
| | | return ( |
| | | <div id="verify-card-box-tab"> |
| | | <Tabs defaultActiveKey="1" className="verify-card-box"> |
| | | {card.intertype === 'system' || (card.intertype === 'custom' && card.procMode === 'system') ? <TabPane tab={ |
| | | <Tabs activeKey={activeKey} className="verify-card-box" onChange={this.changeTab}> |
| | | {verifyInter === 'system' ? <TabPane tab={ |
| | | <span> |
| | | 基础验证 |
| | | {verify.default === 'false' ? <span className="count-tip"><ExclamationOutlined style={{color: 'orange'}}/></span> : null} |
| | | </span> |
| | | } key="1"> |
| | | <Form {...formItemLayout}> |
| | | <Row gutter={24}> |
| | | {this.props.card.sqlType !== 'custom' ? <Col span={8}> |
| | | <Form.Item label={ |
| | | <Tooltip placement="bottomLeft" title={'默认sql执行顺序为自定义脚本之前'}> |
| | | <QuestionCircleOutlined className="mk-form-tip" /> |
| | | 默认sql |
| | | </Tooltip> |
| | | }> |
| | | <Radio.Group value={verify.default} onChange={(e) => {this.onOptionChange(e, 'default')}}> |
| | | <Radio value="true">执行</Radio> |
| | | <Radio value="false">不执行</Radio> |
| | | </Radio.Group> |
| | | </Form.Item> |
| | | </Col> : null} |
| | | <Col span={8}> |
| | | <Form.Item label={'账期验证'}> |
| | | <Radio.Group value={verify.accountdate} onChange={(e) => {this.onOptionChange(e, 'accountdate')}}> |
| | | <Radio value="true">开启</Radio> |
| | | <Radio value="false">不开启</Radio> |
| | | </Radio.Group> |
| | | </Form.Item> |
| | | </Col> |
| | | {verify.accountdate === 'true' ? <Col span={8}> |
| | | <Form.Item label={'验证公司'} required> |
| | | <Select defaultValue={verify.accountfield || ''} onChange={this.changeAccField}> |
| | | {unionFields.map(option => |
| | | <Select.Option key={option.uuid} value={option.field}> |
| | | {option.label} |
| | | </Select.Option> |
| | | )} |
| | | </Select> |
| | | </Form.Item> |
| | | </Col> : null} |
| | | {verify.accountdate === 'true' ? <Col span={8}> |
| | | <Form.Item label={ |
| | | <Tooltip placement="bottomLeft" title={'验证日期为空时,默认为当天。'}> |
| | | <QuestionCircleOutlined className="mk-form-tip" /> |
| | | 验证日期 |
| | | </Tooltip> |
| | | }> |
| | | <Select allowClear defaultValue={verify.voucherdate || ''} onChange={this.changeAccDate}> |
| | | {unionFields.map(option => |
| | | <Select.Option key={option.uuid} value={option.field}> |
| | | {option.label} |
| | | </Select.Option> |
| | | )} |
| | | </Select> |
| | | </Form.Item> |
| | | </Col> : null} |
| | | <Col span={8}> |
| | | <Form.Item label={'失效验证'}> |
| | | <Radio.Group value={verify.invalid} onChange={(e) => {this.onOptionChange(e, 'invalid')}}> |
| | | <Radio value="true">开启</Radio> |
| | | <Radio value="false">不开启</Radio> |
| | | </Radio.Group> |
| | | </Form.Item> |
| | | </Col> |
| | | <Col span={24}></Col> |
| | | <Col span={8}> |
| | | <Form.Item label={ |
| | | <Tooltip placement="bottomLeft" title={'选择发送短信时,需完善短信设置。'}> |
| | | <QuestionCircleOutlined className="mk-form-tip" /> |
| | | 发送短信 |
| | | </Tooltip> |
| | | }> |
| | | <Radio.Group value={verify.noteEnable} onChange={(e) => {this.onOptionChange(e, 'noteEnable')}}> |
| | | <Radio value="true">开启</Radio> |
| | | <Radio value="false">不开启</Radio> |
| | | </Radio.Group> |
| | | </Form.Item> |
| | | </Col> |
| | | {verify.noteEnable === 'true' ? <Col span={8}> |
| | | <Form.Item label={ |
| | | <Tooltip placement="bottomLeft" title={<span>短信模板添加地址:<a target="_blank" rel="noopener noreferrer" href="https://cloud.mk9h.cn/admin/index.html">云中心</a>->应用服务->开发者中心->短信模板。</span>}> |
| | | <QuestionCircleOutlined className="mk-form-tip" /> |
| | | 短信模板 |
| | | </Tooltip> |
| | | }> |
| | | <Select value={verify.noteCode} onSelect={this.onNoteCodeChange}> |
| | | {notes.map(option => |
| | | <Select.Option key={option.value} id={option.id} value={option.value}> |
| | | {option.name} |
| | | </Select.Option> |
| | | )} |
| | | </Select> |
| | | </Form.Item> |
| | | </Col> : null} |
| | | {verify.noteEnable === 'true' ? <Col span={8}> |
| | | <Form.Item label={ |
| | | <Tooltip placement="bottomLeft" title={'实时发送最多同时发送5个用户,定时发送最多同时发送100个用户。'}> |
| | | <QuestionCircleOutlined className="mk-form-tip" /> |
| | | 发送方式 |
| | | </Tooltip> |
| | | }> |
| | | <Radio.Group value={verify.noteType} onChange={(e) => {this.onOptionChange(e, 'noteType')}}> |
| | | <Radio value="Y">实时</Radio> |
| | | <Radio value="N">定时</Radio> |
| | | </Radio.Group> |
| | | </Form.Item> |
| | | </Col> : null} |
| | | {verify.noteEnable === 'true' ? <Col span={8}> |
| | | <Form.Item label={ |
| | | <Tooltip placement="bottomLeft" title={'当向多个用户发送短信时,短信内容是否相同。'}> |
| | | <QuestionCircleOutlined className="mk-form-tip" /> |
| | | 短信内容 |
| | | </Tooltip> |
| | | }> |
| | | <Radio.Group value={verify.noteTemp} onChange={(e) => {this.onOptionChange(e, 'noteTemp')}}> |
| | | <Radio value="Y">相同</Radio> |
| | | <Radio value="N">不同</Radio> |
| | | </Radio.Group> |
| | | </Form.Item> |
| | | </Col> : null} |
| | | {/* <Col span={24}></Col> |
| | | <Col span={8}> |
| | | <Form.Item label={ |
| | | <Tooltip placement="bottomLeft" title={'选择发送短信时,需完善短信设置。'}> |
| | | <QuestionCircleOutlined className="mk-form-tip" /> |
| | | 公众号消息 |
| | | </Tooltip> |
| | | }> |
| | | <Radio.Group value={verify.wxEnable} onChange={(e) => {this.onOptionChange(e, 'noteEnable')}}> |
| | | <Radio value="true">开启</Radio> |
| | | <Radio value="false">不开启</Radio> |
| | | </Radio.Group> |
| | | </Form.Item> |
| | | </Col> |
| | | {verify.noteEnable === 'true' ? <Col span={8}> |
| | | <Form.Item label={ |
| | | <Tooltip placement="bottomLeft" title={<span>短信模板添加地址:<a target="_blank" rel="noopener noreferrer" href="https://cloud.mk9h.cn/admin/index.html">云中心</a>->应用服务->开发者中心->短信模板。</span>}> |
| | | <QuestionCircleOutlined className="mk-form-tip" /> |
| | | 短信模板 |
| | | </Tooltip> |
| | | }> |
| | | <Select value={verify.noteCode} onSelect={this.onNoteCodeChange}> |
| | | {notes.map(option => |
| | | <Select.Option key={option.value} id={option.id} value={option.value}> |
| | | {option.name} |
| | | </Select.Option> |
| | | )} |
| | | </Select> |
| | | </Form.Item> |
| | | </Col> : null} |
| | | {verify.noteEnable === 'true' ? <Col span={8}> |
| | | <Form.Item label={ |
| | | <Tooltip placement="bottomLeft" title={'实时发送最多同时发送5个用户,定时发送最多同时发送100个用户。'}> |
| | | <QuestionCircleOutlined className="mk-form-tip" /> |
| | | 发送方式 |
| | | </Tooltip> |
| | | }> |
| | | <Radio.Group value={verify.noteType} onChange={(e) => {this.onOptionChange(e, 'noteType')}}> |
| | | <Radio value="Y">实时</Radio> |
| | | <Radio value="N">定时</Radio> |
| | | </Radio.Group> |
| | | </Form.Item> |
| | | </Col> : null} |
| | | {verify.noteEnable === 'true' ? <Col span={8}> |
| | | <Form.Item label={ |
| | | <Tooltip placement="bottomLeft" title={'当向多个用户发送短信时,短信内容是否相同。'}> |
| | | <QuestionCircleOutlined className="mk-form-tip" /> |
| | | 短信内容 |
| | | </Tooltip> |
| | | }> |
| | | <Radio.Group value={verify.noteTemp} onChange={(e) => {this.onOptionChange(e, 'noteTemp')}}> |
| | | <Radio value="Y">相同</Radio> |
| | | <Radio value="N">不同</Radio> |
| | | </Radio.Group> |
| | | </Form.Item> |
| | | </Col> : null} */} |
| | | </Row> |
| | | </Form> |
| | | } key="base"> |
| | | <BaseForm card={card} unionFields={unionFields} verify={verify} notes={notes} onChange={(verify) => this.setState({verify})} wrappedComponentRef={(inst) => this.baseForm = inst}/> |
| | | </TabPane> : null} |
| | | {card.intertype === 'system' || (card.intertype === 'custom' && card.procMode === 'system') ? <TabPane tab={ |
| | | {verifyInter === 'system' ? <TabPane tab={ |
| | | <span> |
| | | 比较验证 |
| | | {verify.contrasts.length ? <span className="count-tip">{verify.contrasts.length}</span> : null} |
| | | </span> |
| | | } key="2x"> |
| | | } key="contrasts"> |
| | | <ContrastForm dict={this.props.dict} contrastChange={this.contrastChange}/> |
| | | <EditTable actions={['edit', 'move', 'copy', 'del', 'status']} type="contrastverify" data={verify.contrasts} columns={contrastColumns} onChange={(contrasts) => this.setState({verify: {...verify, contrasts}})}/> |
| | | </TabPane> : null} |
| | | {card.intertype === 'system' || (card.intertype === 'custom' && card.procMode === 'system') ? <TabPane tab={ |
| | | {verifyInter === 'system' ? <TabPane tab={ |
| | | <span> |
| | | 自定义验证 |
| | | {verify.customverifys.length ? <span className="count-tip">{verify.customverifys.length}</span> : null} |
| | | </span> |
| | | } key="3"> |
| | | } key="customverifys"> |
| | | <CustomForm |
| | | dict={this.props.dict} |
| | | btn={this.props.card} |
| | |
| | | /> |
| | | <EditTable actions={['move']} data={verify.customverifys} columns={customColumns} onChange={(customverifys) => {this.setState({verify: {...verify, customverifys}})}}/> |
| | | </TabPane> : null} |
| | | {card.intertype === 'system' || (card.intertype === 'custom' && card.procMode === 'system') ? <TabPane tab={ |
| | | {verifyInter === 'system' ? <TabPane tab={ |
| | | <span> |
| | | 单号生成 |
| | | {verify.billcodes.length ? <span className="count-tip">{verify.billcodes.length}</span> : null} |
| | | </span> |
| | | } key="4"> |
| | | } key="billcodes"> |
| | | <BillcodeForm |
| | | fields={fields} |
| | | btn={this.props.card} |
| | |
| | | /> |
| | | <EditTable actions={['move']} data={verify.billcodes} columns={orderColumns} onChange={(billcodes) => {this.setState({verify: {...verify, billcodes}})}}/> |
| | | </TabPane> : null} |
| | | {card.intertype === 'system' || (card.intertype === 'custom' && card.procMode === 'system') ? <TabPane tab={ |
| | | {verifyInter === 'system' ? <TabPane tab={ |
| | | <span> |
| | | {card.Ot !== 'requiredOnce' ? '唯一性验证' : '同类数据验证'} |
| | | {verify.uniques.length ? <span className="count-tip">{verify.uniques.length}</span> : null} |
| | | </span> |
| | | } key="2"> |
| | | } key="uniques"> |
| | | <UniqueForm |
| | | btn={card} |
| | | fields={card.Ot !== 'requiredOnce' ? uniqueFields : columnsFields} |
| | |
| | | /> |
| | | <EditTable actions={['edit', 'move', 'del', 'status']} data={verify.uniques} columns={card.Ot !== 'requiredOnce' ? uniqueColumns : onceUniqueColumns} onChange={this.changeUniques}/> |
| | | </TabPane> : null} |
| | | {card.intertype === 'system' || (card.intertype === 'custom' && card.procMode === 'system') ? <TabPane tab={ |
| | | {verifyInter === 'system' ? <TabPane tab={ |
| | | <span> |
| | | 创建凭证 |
| | | {verify.voucher && verify.voucher.enabled ? <span className="count-tip">1</span> : null} |
| | | </span> |
| | | } key="5"> |
| | | } key="voucher"> |
| | | <VoucherForm |
| | | dict={this.props.dict} |
| | | voucher={voucher} |
| | |
| | | wrappedComponentRef={(inst) => this.voucherForm = inst} |
| | | /> |
| | | </TabPane> : null} |
| | | {card.intertype === 'system' || (card.intertype === 'custom' && card.procMode === 'system') ? <TabPane tab={ |
| | | {verifyInter === 'system' ? <TabPane tab={ |
| | | <span> |
| | | 自定义脚本 |
| | | {verify.scripts.length ? <span className="count-tip">{verify.scripts.length}</span> : null} |
| | | </span> |
| | | } key="6"> |
| | | } key="scripts"> |
| | | <BorderOutlined className="full-scripts" onClick={() => { |
| | | if (this.scriptsForm && (this.scriptsForm.state.editItem || (this.scriptsForm.props.form.getFieldValue('sql') && !/^\s+$/.test(this.scriptsForm.props.form.getFieldValue('sql'))))) { |
| | | notification.warning({ |
| | |
| | | 回调脚本 |
| | | {verify.cbScripts.length ? <span className="count-tip">{verify.cbScripts.length}</span> : null} |
| | | </span> |
| | | } key="6a"> |
| | | } key="cbScripts"> |
| | | <CallBackCustomScript |
| | | btn={this.props.card} |
| | | dict={this.props.dict} |
| | |
| | | /> |
| | | <EditTable actions={['move']} data={verify.cbScripts} columns={cbScriptsColumns} onChange={(cbScripts) => {this.setState({verify: {...verify, cbScripts}})}}/> |
| | | </TabPane> : null} |
| | | <TabPane tab="信息提示" key="7"> |
| | | <TabPane tab="信息提示" key="tip"> |
| | | <Form {...formItemLayout}> |
| | | <Row gutter={24}> |
| | | <Col offset={6} span={6}> |