| | |
| | | const { confirm } = Modal |
| | | const { Search } = Input |
| | | const { Paragraph } = Typography |
| | | |
| | | const EditTable = asyncComponent(() => import('@/templates/zshare/editTable')) |
| | | const CodeMirror = asyncComponent(() => import('@/templates/zshare/codemirror')) |
| | | const FullScripts = asyncComponent(() => import('@/templates/zshare/verifycard/fullScripts')) |
| | | |
| | | class VerifyCard extends Component { |
| | |
| | | width: '15%', |
| | | editable: true, |
| | | inputType: 'select', |
| | | keyCol: true, |
| | | options: [ |
| | | { value: 'Nvarchar(10)', text: 'Nvarchar(10)' }, |
| | | { value: 'Nvarchar(20)', text: 'Nvarchar(20)' }, |
| | |
| | | required: false, |
| | | inputType: 'number', |
| | | unlimit: true, |
| | | editable: true |
| | | editable: true, |
| | | keyVals: ['Int', 'Decimal(18,0)', 'Decimal(18,2)', 'Decimal(18,4)', 'Decimal(18,6)'], |
| | | render: (text, record) => /^Decimal/ig.test(record.type) || /^int/ig.test(record.type) ? text : '' |
| | | |
| | | }, |
| | | { |
| | | title: '最大值', |
| | |
| | | required: false, |
| | | inputType: 'number', |
| | | unlimit: true, |
| | | editable: true |
| | | editable: true, |
| | | keyVals: ['Int', 'Decimal(18,0)', 'Decimal(18,2)', 'Decimal(18,4)', 'Decimal(18,6)'], |
| | | render: (text, record) => /^Decimal/ig.test(record.type) || /^int/ig.test(record.type) ? text : '' |
| | | } |
| | | ], |
| | | uniqueColumns: [ |
| | |
| | | _verify.range = 1 |
| | | } |
| | | |
| | | _verify.excelHandle = _verify.excelHandle || 'false' |
| | | _verify.default = _verify.default || 'true' |
| | | _verify.sheet = _verify.sheet || 'Sheet1' |
| | | _verify.range = _verify.range || 0 |
| | | _verify.columns = _columns |
| | | _verify.scripts = _verify.scripts || [] |
| | | _verify.uniques = _verify.uniques || [] |
| | | |
| | | this.setState({ |
| | | searchKey: '', |
| | | verify: { |
| | | ..._verify, |
| | | default: _verify.default || 'true', |
| | | sheet: _verify.sheet || 'Sheet1', |
| | | range: _verify.range || 0, |
| | | columns: _columns, |
| | | scripts: _verify.scripts || [], |
| | | uniques: _verify.uniques || [] |
| | | } |
| | | verify: _verify |
| | | }, () => { |
| | | this.resetUniqueColumns() |
| | | }) |
| | |
| | | |
| | | let _scriptSql = `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` |
| | | |
| | | _scriptSql = Utils.formatOptions(_scriptSql) |
| | | _scriptSql = Utils.formatOptions(_scriptSql, 'x') |
| | | |
| | | let _sParam = { |
| | | func: 'sPC_Get_SelectedList', |
| | | LText: _scriptSql, |
| | | obj_name: 'data', |
| | | arr_field: 'funcname,longparam' |
| | | arr_field: 'funcname,longparam', |
| | | exec_type: 'x' |
| | | } |
| | | |
| | | _sParam.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') |
| | | _sParam.secretkey = Utils.encrypt(_sParam.LText, _sParam.timestamp) |
| | | _sParam.secretkey = Utils.encrypt('', _sParam.timestamp) |
| | | _sParam.open_key = Utils.encryptOpenKey(_sParam.secretkey, _sParam.timestamp) // 云端数据验证 |
| | | |
| | | Api.getCloudConfig(_sParam).then(res => { |
| | |
| | | }) |
| | | } |
| | | |
| | | columnChange = (values) => { |
| | | columnChange = (values, callback) => { |
| | | let verify = JSON.parse(JSON.stringify(this.state.verify)) |
| | | |
| | | let fields = verify.columns.map(item => item.Column) |
| | |
| | | duration: 5 |
| | | }) |
| | | return |
| | | } else { |
| | | callback() |
| | | } |
| | | |
| | | values.uuid = Utils.getuuid() |
| | |
| | | if (!err) { |
| | | let _verify = {...verify, ...values} |
| | | |
| | | if (_verify.excelHandle !== 'true') { |
| | | delete _verify.excel_func |
| | | } |
| | | if (_verify.default === 'false' && _verify.scripts.length === 0) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '不执行默认sql时,必须设置自定义脚本!', |
| | | duration: 5 |
| | | }) |
| | | return |
| | | } |
| | | |
| | | let cols = _verify.columns.map(col => col.Column.toLowerCase()) |
| | | cols = Array.from(new Set(cols)) |
| | | let error = '' |
| | | |
| | | if (_verify.columns.length === 0) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '请设置Excel列字段!', |
| | | duration: 5 |
| | | }) |
| | | return |
| | | error = '请设置Excel列字段!' |
| | | } else if (_verify.columns.length > cols.length) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: 'Excel列字段名,不可重复!', |
| | | duration: 5 |
| | | }) |
| | | return |
| | | error = 'Excel列字段名,不可重复!' |
| | | } else if (cols.includes('bid')) { |
| | | error = 'bid字段为保留字,不可使用!' |
| | | } else if (cols.includes('jskey')) { |
| | | error = 'jskey字段为保留字,不可使用!' |
| | | } else if (_verify.range === 1) { |
| | | let tEmptys = _verify.columns.filter(op => !op.Text) |
| | | if (tEmptys.length > 0) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '忽略首行时,会使用Text值校验Excel首行内容,Text值与Excel表首行内容相同,且均不可为空!', |
| | | duration: 5 |
| | | }) |
| | | return |
| | | error = '忽略首行时,会使用Text值校验Excel首行内容,Text值与Excel表首行内容相同,且均不可为空!' |
| | | } |
| | | } |
| | | |
| | | if (error) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: error, |
| | | duration: 5 |
| | | }) |
| | | return |
| | | } |
| | | |
| | | _verify.columns.sort((a, b) => { |
| | |
| | | resolve(_verify) |
| | | } |
| | | } else { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '请设置Excel表名!', |
| | | duration: 5 |
| | | }) |
| | | this.setState({activeKey: 'basemsg'}) |
| | | } |
| | | }) |
| | | }) |
| | | } |
| | | |
| | | onOptionChange = (e, key) => { |
| | | onOptionChange = (e) => { |
| | | const { verify } = this.state |
| | | let value = e.target.value |
| | | |
| | | this.setState({ |
| | | verify: {...verify, default: value} |
| | | }) |
| | | } |
| | | |
| | | onHandleChange = (e) => { |
| | | const { verify } = this.state |
| | | let value = e.target.value |
| | | |
| | | this.setState({ |
| | | verify: {...verify, excelHandle: value} |
| | | }) |
| | | } |
| | | |
| | |
| | | <TabPane tab="基础验证" key="basemsg"> |
| | | <Form {...formItemLayout}> |
| | | <Row gutter={24}> |
| | | {card.intertype === 'system' ? <Col span={8}> |
| | | <Form.Item label={'默认sql'}> |
| | | <Radio.Group value={verify.default} onChange={this.onOptionChange}> |
| | | <Radio value="true">执行</Radio> |
| | | <Radio value="false">不执行</Radio> |
| | | </Radio.Group> |
| | | </Form.Item> |
| | | </Col> : null} |
| | | <Col span={8}> |
| | | <Form.Item label={ |
| | | <Tooltip placement="topRight" title="自定义验证Excel格式,可用参数为 XLSX、workbook、btn、callback。"> |
| | | <QuestionCircleOutlined className="mk-form-tip" /> |
| | | 导入格式 |
| | | </Tooltip> |
| | | }> |
| | | {getFieldDecorator('excelHandle', { |
| | | initialValue: verify.excelHandle |
| | | })( |
| | | <Radio.Group onChange={this.onHandleChange}> |
| | | <Radio value="false">默认</Radio> |
| | | <Radio value="true">自定义</Radio> |
| | | </Radio.Group>)} |
| | | </Form.Item> |
| | | </Col> |
| | | {verify.excelHandle !== 'true' ? <Col span={8}> |
| | | <Form.Item label={ |
| | | <Tooltip placement="bottomLeft" title="导入时工作表名与excel中必须一致,注:工作表名为Sheet1且excel中仅有一个工作表时不进行表名验证。"> |
| | | <QuestionCircleOutlined className="mk-form-tip" /> |
| | |
| | | ] |
| | | })(<Input placeholder="" autoComplete="off" />)} |
| | | </Form.Item> |
| | | </Col> |
| | | </Col> : null} |
| | | <Col span={8}> |
| | | <Form.Item label={ |
| | | <Tooltip placement="bottomLeft" title="忽略首行时,会校验excel中表头名称与excel列设置是否一致。"> |
| | |
| | | })(<InputNumber min={0} max={100} precision={0} />)} |
| | | </Form.Item> |
| | | </Col> |
| | | {card.intertype === 'system' ? <Col span={8}> |
| | | <Form.Item label={'默认sql'}> |
| | | <Radio.Group value={verify.default} onChange={this.onOptionChange}> |
| | | <Radio value="true">执行</Radio> |
| | | <Radio value="false">不执行</Radio> |
| | | </Radio.Group> |
| | | {verify.excelHandle === 'true' ? <Col span={24} style={{paddingLeft: '30px'}}> |
| | | <Form.Item wrapperCol={ {xs: { span: 24 }, sm: { span: 24 }} } label=""> |
| | | {getFieldDecorator('excel_func', { |
| | | initialValue: verify.excel_func || '', |
| | | rules: [ |
| | | { |
| | | required: true, |
| | | message: '请填写自定义逻辑!' |
| | | } |
| | | ] |
| | | })(<CodeMirror mode="text/javascript" theme="cobalt" />)} |
| | | </Form.Item> |
| | | </Col> : null} |
| | | </Row> |