| | |
| | | } |
| | | |
| | | _url = window.btoa(_url) |
| | | |
| | | params.url = '/trans/redirect?rd=' + _url + '&method=' + method |
| | | |
| | | return axios(params) |
| | |
| | | console.warn('websql 初始化错误!') |
| | | }) |
| | | }, 1000) |
| | | |
| | | // Api.directRequest('https://www.sogou.com/suggnew/ajajjson', 'get', {type: 'web', key: '#content#'}).then(res => { |
| | | // }, (e) => { |
| | | // }) |
| | | } |
| | | |
| | | shouldComponentUpdate (nextProps, nextState) { |
| | |
| | | 'model.tooltip.action.guide': '在左侧工具栏《按钮》中,选择对应类型的按钮拖至此处添加,如选择按钮类型为表单、新标签页等含有配置页面的按钮,可在左侧工具栏-按钮-可配置按钮处,点击按钮完成相关配置。注:当设置按钮显示位置为表格时,显示列会增加操作列。', |
| | | 'model.tooltip.column.guide': '在左侧工具栏《显示列》中,选择对应类型的显示列拖至此处添加;或点击《添加显示列》按钮批量添加,选择批量添加时,需提前选择使用表。注:添加合并列时,需设置可选列。', |
| | | 'model.tooltip.tabs.guide': '在左侧工具栏《标签页》中,选择对应类型的标签页拖至此处添加。', |
| | | 'model.tooltip.func.innerface': '内部接口: 可自定义数据处理函数,函数名称需以@ableField等字符开始;', |
| | | 'model.tooltip.func.outface': '外部接口: 可自定义数据处理函数,提交数据经过内部函数处理后,传入外部接口,未设置时,数据会直接传入外部接口。', |
| | | 'model.tooltip.func.innerface': '内部函数名称需以@ableField等字符开始;', |
| | | } |
| | |
| | | 'model.tooltip.action.guide': '在左侧工具栏《按钮》中,选择对应类型的按钮拖至此处添加,如选择按钮类型为表单、新标签页等含有配置页面的按钮,可在左侧工具栏-按钮-可配置按钮处,点击按钮完成相关配置。注:当设置按钮显示位置为表格时,显示列会增加操作列。', |
| | | 'model.tooltip.column.guide': '在左侧工具栏《显示列》中,选择对应类型的显示列拖至此处添加;或点击《添加显示列》按钮批量添加,选择批量添加时,需提前选择使用表。注:添加合并列时,需设置可选列。', |
| | | 'model.tooltip.tabs.guide': '在左侧工具栏《标签页》中,选择对应类型的标签页拖至此处添加。', |
| | | 'model.tooltip.func.innerface': '内部接口: 可自定义数据处理函数,函数名称需以@ableField等字符开始;', |
| | | 'model.tooltip.func.outface': '外部接口: 可自定义数据处理函数,提交数据经过内部函数处理后,传入外部接口,未设置时,数据会直接传入外部接口。', |
| | | 'model.tooltip.func.innerface': '内部函数名称需以@ableField等字符开始;', |
| | | } |
| | |
| | | let ableField = usefulFields.join(', ') |
| | | let functip = <div> |
| | | <p style={{marginBottom: '5px'}}>{this.state.dict['model.tooltip.func.innerface'].replace('@ableField', ableField)}</p> |
| | | <p>{this.state.dict['model.tooltip.func.outface']}</p> |
| | | </div> |
| | | |
| | | let menulist = sessionStorage.getItem('fstMenuList') |
| | |
| | | openType: null, // 打开方式 |
| | | interType: null, // 接口类型:内部、外部 |
| | | funcType: null, // 功能类型 |
| | | procMode: null, // 参数方式 |
| | | requireOptions: [{ |
| | | value: 'notRequired', |
| | | text: this.props.dict['header.form.notRequired'] |
| | |
| | | }, { |
| | | value: 'custom', |
| | | text: this.props.dict['header.form.custom'] |
| | | }], |
| | | interTypeOptions: [{ |
| | | value: 'system', |
| | | text: this.props.dict['model.interface.system'] |
| | | }, { |
| | | value: 'inner', |
| | | text: this.props.dict['model.interface.inner'] |
| | | }, { |
| | | value: 'outer', |
| | | text: this.props.dict['model.interface.outer'] |
| | | }, { |
| | | value: 'custom', |
| | | text: '自定义' |
| | | }] |
| | | } |
| | | |
| | |
| | | let _opentype = card.OpenType // 打开方式 |
| | | let _intertype = card.intertype || 'system' // 接口类型 |
| | | let _funcType = card.funcType || 'print' // 功能按钮默认类型 |
| | | let _procMode = card.procMode || 'system' // 参数请求方式 |
| | | |
| | | let _options = this.getOptions(_opentype, _intertype, _funcType, card.pageTemplate) |
| | | let _options = this.getOptions(_opentype, _intertype, _funcType, card.pageTemplate, _procMode) |
| | | |
| | | this.setState({ |
| | | openType: _opentype, |
| | | interType: _intertype, |
| | | procMode: _procMode, |
| | | funcType: _funcType, |
| | | formlist: this.props.formlist.map(item => { |
| | | if (item.key === 'class') { |
| | | item.options = btnCustomClasses |
| | | } else if (item.key === 'innerFunc' && _procMode === 'inner') { |
| | | item.required = true |
| | | } else if (item.key === 'intertype') { |
| | | let iscustom = ['pop', 'prompt', 'exec'].includes(_opentype) |
| | | item.options = this.state.interTypeOptions.filter(op => (iscustom || op.value !== 'custom')) |
| | | } else if (item.key === 'icon') { |
| | | item.options = btnIcons |
| | | } else if (item.key === 'Ot') { |
| | |
| | | }) |
| | | } |
| | | |
| | | getOptions = (_opentype, _intertype, _funcType, _pageTemplate) => { |
| | | getOptions = (_opentype, _intertype, _funcType, _pageTemplate, _procMode) => { |
| | | let _options = fromJS(actionTypeOptions[_opentype]).toJS() // 选项列表 |
| | | |
| | | if (_opentype === 'innerpage') { // 新页面,可选模板(自定义时,可填入外部链接) |
| | |
| | | } |
| | | } |
| | | } else if (_opentype !== 'popview' && _opentype !== 'tab') { |
| | | if (_intertype === 'outer') { |
| | | if (_intertype === 'custom') { |
| | | _options.push('procMode', 'interface', 'callbackType', 'cbTable', 'proInterface', 'method') |
| | | if (_procMode === 'system') { |
| | | _options.push('sql', 'sqlType') |
| | | } else { |
| | | _options.push('innerFunc') |
| | | } |
| | | } else if (_intertype === 'outer') { |
| | | _options.push('innerFunc', 'sysInterface', 'interface', 'outerFunc', 'callbackFunc') |
| | | } else if (_intertype === 'inner') { |
| | | _options.push('innerFunc') |
| | |
| | | * 2、显示位置切换,重置选择行 |
| | | * 3、切换标签类型,重置可选标签 |
| | | */ |
| | | openTypeChange = (key, value) => { |
| | | optionChange = (key, value) => { |
| | | const { card, type } = this.props |
| | | const { openType, procMode } = this.state |
| | | |
| | | if (key === 'OpenType') { |
| | | let _options = this.getOptions(value, this.state.interType, this.state.funcType, card.pageTemplate) |
| | | let _options = this.getOptions(value, 'system', this.state.funcType, card.pageTemplate, 'system') |
| | | |
| | | let _fieldval = {} |
| | | |
| | | let _formlist = this.state.formlist.map(item => { |
| | | item.hidden = !_options.includes(item.key) |
| | | |
| | | if (item.key === 'intertype') { |
| | | let iscustom = ['pop', 'prompt', 'exec'].includes(value) |
| | | item.options = this.state.interTypeOptions.filter(op => (iscustom || op.value !== 'custom')) |
| | | } |
| | | |
| | | if (item.hidden) return item |
| | | |
| | | if (item.key === 'intertype') { |
| | | _fieldval.intertype = this.state.interType |
| | | _fieldval.intertype = 'system' |
| | | } else if (item.key === 'Ot') { |
| | | if (type === 'card') { |
| | | item.options = this.state.requireOptions.filter(op => ['notRequired', 'requiredSgl'].includes(op.value)) |
| | |
| | | |
| | | this.setState({ |
| | | openType: value, |
| | | intertype: 'system', |
| | | procMode: 'system', |
| | | formlist: _formlist |
| | | }, () => { |
| | | if (value === 'excelIn') { |
| | |
| | | this.props.form.setFieldsValue(_fieldval) |
| | | }) |
| | | } else if (key === 'funcType') { |
| | | let _options = this.getOptions(this.state.openType, this.state.interType, value, card.pageTemplate) |
| | | let _options = this.getOptions(this.state.openType, this.state.interType, value, card.pageTemplate, procMode) |
| | | let _fieldval = {} |
| | | |
| | | this.setState({ |
| | |
| | | }) |
| | | } else if (key === 'pageTemplate') { |
| | | let _fieldval = {} |
| | | let _options = this.getOptions(this.state.openType, this.state.interType, this.state.funcType, value) |
| | | let _options = this.getOptions(this.state.openType, this.state.interType, this.state.funcType, value, procMode) |
| | | |
| | | this.setState({ |
| | | openType: value, |
| | |
| | | }, () => { |
| | | this.props.form.setFieldsValue(_fieldval) |
| | | }) |
| | | } |
| | | } |
| | | |
| | | onChange = (e, key) => { |
| | | const { type } = this.props |
| | | const { openType } = this.state |
| | | let value = e.target.value |
| | | |
| | | if (key === 'intertype') { |
| | | let _options = this.getOptions(openType, value, this.state.funcType) |
| | | } else if (key === 'intertype') { |
| | | let _options = this.getOptions(openType, value, this.state.funcType, '', procMode) |
| | | |
| | | this.setState({ |
| | | interType: value, |
| | |
| | | } |
| | | return item |
| | | }) |
| | | }, () => { |
| | | if (this.props.form.getFieldValue('sqlType') !== undefined) { |
| | | this.props.form.setFieldsValue({sqlType: ''}) |
| | | } |
| | | }) |
| | | } else if (key === 'procMode') { |
| | | let _options = this.getOptions(openType, this.state.interType, this.state.funcType, '', value) |
| | | |
| | | this.setState({ |
| | | procMode: value, |
| | | formlist: this.state.formlist.map(item => { |
| | | item.hidden = !_options.includes(item.key) |
| | | |
| | | if (item.key === 'innerFunc') { |
| | | item.required = true |
| | | } |
| | | return item |
| | | }) |
| | | }) |
| | | } else if (key === 'sysInterface') { |
| | | if (value === 'true') { |
| | |
| | | <Select |
| | | showSearch |
| | | filterOption={(input, option) => option.props.children[2].toLowerCase().indexOf(input.toLowerCase()) >= 0} |
| | | onChange={(value) => {this.openTypeChange(item.key, value)}} |
| | | onChange={(value) => {this.optionChange(item.key, value)}} |
| | | getPopupContainer={() => document.getElementById('winter')} |
| | | > |
| | | {item.options.map((option, index) => |
| | |
| | | } |
| | | ] |
| | | })( |
| | | <Radio.Group onChange={(e) => {this.onChange(e, item.key)}} disabled={item.readonly}> |
| | | <Radio.Group onChange={(e) => {this.optionChange(item.key, e.target.value)}} disabled={item.readonly}> |
| | | { |
| | | item.options.map(option => { |
| | | return ( |
| | |
| | | <Form.Item label={item.label} className="textarea"> |
| | | {getFieldDecorator(item.key, { |
| | | initialValue: item.initVal |
| | | })(<TextArea rows={4} />)} |
| | | })(<TextArea rows={2} />)} |
| | | </Form.Item> |
| | | </Col> |
| | | ) |
| | |
| | | width: 86%; |
| | | } |
| | | } |
| | | .ant-radio-group { |
| | | white-space: nowrap; |
| | | .ant-radio-wrapper { |
| | | margin-right: 4px; |
| | | } |
| | | } |
| | | .ant-input-number { |
| | | width: 100%; |
| | | } |
| | |
| | | options: opentypes |
| | | }, |
| | | { |
| | | type: 'select', |
| | | type: 'radio', |
| | | key: 'funcType', |
| | | label: Formdict['header.form.funcType'], |
| | | initVal: card.funcType || 'print', |
| | |
| | | label: Formdict['header.form.intertype'], |
| | | initVal: card.intertype || 'system', |
| | | required: true, |
| | | options: [{ |
| | | value: 'system', |
| | | text: '系统' |
| | | }, { |
| | | value: 'inner', |
| | | text: Formdict['model.interface.inner'] |
| | | }, { |
| | | value: 'outer', |
| | | text: Formdict['model.interface.outer'] |
| | | }] |
| | | }, |
| | | { |
| | | type: 'select', |
| | | key: 'sqlType', |
| | | label: Formdict['header.form.action.type'], |
| | | initVal: card.sqlType || '', |
| | | required: true, |
| | | options: [] |
| | | }, |
| | | { |
| | |
| | | initVal: card.label, |
| | | required: true, |
| | | readonly: false |
| | | }, |
| | | { |
| | | type: 'radio', |
| | | key: 'procMode', |
| | | label: '参数处理', |
| | | initVal: card.procMode || 'system', |
| | | required: true, |
| | | options: [{ |
| | | value: 'system', |
| | | text: '系统函数' |
| | | }, { |
| | | value: 'inner', |
| | | text: '内部函数' |
| | | }] |
| | | }, |
| | | { |
| | | type: 'radio', |
| | | key: 'sqlType', |
| | | label: Formdict['header.form.action.type'], |
| | | initVal: card.sqlType || '', |
| | | required: true, |
| | | options: [] |
| | | }, |
| | | { |
| | | type: 'text', |
| | |
| | | readonly: false |
| | | }, |
| | | { |
| | | type: 'text', |
| | | type: 'textarea', |
| | | key: 'interface', |
| | | label: Formdict['header.form.interface'], |
| | | initVal: card.sysInterface === 'true' ? (window.GLOB.mainSystemApi || '') : (card.interface || ''), |
| | | required: true, |
| | | readonly: card.sysInterface === 'true' |
| | | }, |
| | | { |
| | | type: 'textarea', |
| | | key: 'proInterface', |
| | | label: '正式地址', |
| | | initVal: card.proInterface || '', |
| | | tooltip: '正式系统所使用的接口地址。', |
| | | required: false |
| | | }, |
| | | { |
| | | type: 'radio', |
| | | key: 'method', |
| | | label: '请求方式', |
| | | initVal: card.method || 'post', |
| | | required: true, |
| | | options: [{ |
| | | value: 'get', |
| | | text: 'GET' |
| | | }, { |
| | | value: 'post', |
| | | text: 'POST' |
| | | }] |
| | | }, |
| | | { |
| | | type: 'radio', |
| | | key: 'callbackType', |
| | | label: '回调方式', |
| | | initVal: card.callbackType || 'script', |
| | | tooltip: '使用默认方式执行时,需要配合计划任务。', |
| | | required: true, |
| | | options: [{ |
| | | value: 'default', |
| | | text: '默认脚本' |
| | | }, { |
| | | value: 'script', |
| | | text: '自定义脚本' |
| | | }] |
| | | }, |
| | | { |
| | | type: 'text', |
| | | key: 'cbTable', |
| | | label: '回调表名', |
| | | initVal: card.cbTable || '', |
| | | required: true |
| | | }, |
| | | { |
| | | type: 'text', |
| | |
| | | required: true |
| | | }, |
| | | { |
| | | type: 'select', |
| | | type: 'radio', |
| | | key: 'show', |
| | | label: "显示为", |
| | | initVal: card.show || 'icon', |
| | |
| | | let ableField = usefulFields.join(', ') |
| | | let functip = <div> |
| | | <p style={{marginBottom: '5px'}}>{this.state.dict['model.tooltip.func.innerface'].replace('@ableField', ableField)}</p> |
| | | <p>{this.state.dict['model.tooltip.func.outface']}</p> |
| | | </div> |
| | | |
| | | let menulist = sessionStorage.getItem('fstMenuList') |
| | |
| | | <Modal |
| | | title={dict['model.action'] + '-' + (card && card.copyType === 'action' ? dict['model.copy'] : dict['model.edit'])} |
| | | visible={visible} |
| | | width={800} |
| | | width={850} |
| | | maskClosable={false} |
| | | onCancel={this.editModalCancel} |
| | | footer={[ |
| | |
| | | res.data.forEach(item => { |
| | | let _item = { |
| | | name: item.funcname, |
| | | value: Utils.UnformatOptions(item.longparam) |
| | | value: window.decodeURIComponent(window.atob(item.longparam)) |
| | | // value: Utils.UnformatOptions(item.longparam) |
| | | } |
| | | |
| | | _scripts.push(_item) |
| | |
| | | res.data.forEach(item => { |
| | | let _item = { |
| | | name: item.funcname, |
| | | value: Utils.UnformatOptions(item.longparam) |
| | | value: window.decodeURIComponent(window.atob(item.longparam)) |
| | | // value: Utils.UnformatOptions(item.longparam) |
| | | } |
| | | |
| | | _scripts.push(_item) |
| | |
| | | LText: values.LongParam |
| | | } |
| | | |
| | | param.LText = window.btoa(window.encodeURIComponent(JSON.stringify(param.LText))) |
| | | |
| | | if (btn.sqlType === 'delete') { |
| | | param.LText = window.GLOB.appkey || '' |
| | | param.Remark = '' |
| | |
| | | {"label":"函数","field":"func","type":"text","initval":"","readonly":"false","required":"true","hidden":"false","readin":"true","fieldlength":50,"regular":"funcname","supField":"","blacklist":[],"uuid":"1587006164634l397q15t49u2pfq02f5"}, |
| | | {"label":"排序","field":"Sort","type":"number","initval":0,"decimal":0,"min":"","max":"","readonly":"false","hidden":"false","readin":"true","supField":"","blacklist":[],"uuid":"15870101796149403f2pqfpviuo415m2"}, |
| | | {"label":"描述","field":"Remark","type":"textarea","initval":"","readonly":"false","required":"false","hidden":"false","readin":"true","fieldlength":512,"maxRows":6,"supField":"","blacklist":[],"uuid":"1587006199263k8hm45cmtomgu6hd881"}, |
| | | {"label":"脚本","field":"LongParam","type":"textarea","initval":"","readonly":"false","required":"true","encryption":"true","hidden":"false","readin":"true","fieldlength":8000,"maxRows":20,"supField":"","blacklist":[],"uuid":"1587006209935qbkle15h4d9i9lg9tcu"} |
| | | {"label":"脚本","field":"LongParam","type":"textarea","initval":"","readonly":"false","required":"true","encryption":"true","hidden":"false","readin":"true","fieldlength":12000,"maxRows":20,"supField":"","blacklist":[],"uuid":"1587006209935qbkle15h4d9i9lg9tcu"} |
| | | ] |
| | | }, |
| | | '1587007258155ut4nbggg4r66t9uhut2': { |
| | |
| | | {"label":"函数","field":"func","type":"text","initval":"","readonly":"false","required":"true","hidden":"false","readin":"true","fieldlength":50,"regular":"funcname","supField":"","blacklist":[],"uuid":"1587006164634l397q15t49u2pfq02f5"}, |
| | | {"label":"排序","field":"Sort","type":"number","initval":0,"decimal":0,"min":"","max":"","readonly":"false","hidden":"false","readin":"true","supField":"","blacklist":[],"uuid":"1587010196675i9m6ie3tv9kg2rhgfi0"}, |
| | | {"label":"描述","field":"Remark","type":"textarea","initval":"","readonly":"false","required":"false","hidden":"false","readin":"true","fieldlength":512,"maxRows":6,"supField":"","blacklist":[],"uuid":"1587006199263k8hm45cmtomgu6hd881"}, |
| | | {"label":"脚本","field":"LongParam","type":"textarea","initval":"","readonly":"false","required":"true","encryption":"true","hidden":"false","readin":"true","fieldlength":8000,"maxRows":20,"supField":"","blacklist":[],"uuid":"1587006209935qbkle15h4d9i9lg9tcu"} |
| | | {"label":"脚本","field":"LongParam","type":"textarea","initval":"","readonly":"false","required":"true","encryption":"true","hidden":"false","readin":"true","fieldlength":12000,"maxRows":20,"supField":"","blacklist":[],"uuid":"1587006209935qbkle15h4d9i9lg9tcu"} |
| | | ] |
| | | } |
| | | } |
| | |
| | | if (result.status) { |
| | | this.setState({ |
| | | data: result.data.map((item, index) => { |
| | | item.LongParam = Utils.UnformatOptions(item.LongParam) |
| | | // item.LongParam = Utils.UnformatOptions(item.LongParam) |
| | | item.key = index |
| | | return item |
| | | }), |
| | |
| | | return |
| | | } |
| | | } else if (btn.intertype === 'custom') { |
| | | if (!btn.innerFunc && (!btn.sql || !btn.sqlType)) { |
| | | if (btn.callbackType === 'script' && (!btn.verify || !btn.verify.cbScripts || !btn.verify.cbScripts.filter(item => item.status !== 'false').length === 0)) { |
| | | this.actionSettingError() |
| | | return |
| | | } else if (!btn.innerFunc && data.length === 0 && btn.verify && btn.verify.voucher && btn.verify.voucher.enabled) { |
| | | } else if (btn.procMode === 'system' && data.length === 0 && btn.verify && btn.verify.voucher && btn.verify.voucher.enabled) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '使用创建凭证函数,需要选择行!', |
| | | duration: 5 |
| | | }) |
| | | return |
| | | } else if (window.GLOB.systemType === 'production' && !btn.proInterface) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '尚未设置正式系统接口地址!', |
| | | duration: 5 |
| | | }) |
| | | return |
| | |
| | | } else if (btn.intertype === 'custom') { // 系统接口 |
| | | let params = [] |
| | | |
| | | if (!btn.innerFunc) { |
| | | if (btn.procMode === 'system') { |
| | | params = this.getSystemParam(data, formdata, true) |
| | | params = params.map(item => { |
| | | item.script_type = 'Y' |
| | |
| | | url = btn.interface |
| | | } |
| | | |
| | | let mkey = result.mk_api_key || '' |
| | | |
| | | delete result.mk_ex_invoke |
| | | delete result.status |
| | | delete result.message |
| | | delete result.ErrCode |
| | | delete result.ErrMesg |
| | | delete result.mk_api_key |
| | | |
| | | let param = {} |
| | | |
| | |
| | | }) |
| | | |
| | | Api.directRequest(url, btn.method, param).then(res => { |
| | | if (typeof(res) !== 'object' || Array.isArray(res)) { |
| | | this.execError({ErrCode: 'E', message: '未知的返回结果!'}) |
| | | _resolve() |
| | | } else { |
| | | res.mk_api_key = mkey |
| | | this.customCallbackRequest(params, res, _resolve) |
| | | } |
| | | }, () => { |
| | | this.updateStatus('over') |
| | | _resolve() |
| | | }) |
| | | } |
| | | |
| | | /** |
| | | * @description 回调请求循环执行 |
| | | */ |
| | | customCallbackRequest = (params, result, _resolve) => { |
| | | const { btn } = this.props |
| | | let lines = [] |
| | | let pre = btn.callbackType === 'script' ? '@' : '' |
| | | |
| | | let getDefaultSql = (obj, tb, bid, level) => { |
| | | let keys = [] |
| | | let vals = [] |
| | | let subObjs = [] |
| | | let id = Utils.getuuid() |
| | | |
| | | delete obj.$$key |
| | | |
| | | Object.keys(obj).forEach(key => { |
| | | let val = obj[key] |
| | | if (typeof(val) === 'object') { |
| | | if (Array.isArray(val)) { |
| | | val.forEach(item => { |
| | | if (typeof(item) !== 'object' || Array.isArray(item)) return |
| | | if (Object.keys(item).length > 0) { |
| | | item.$$key = tb + '_' + key |
| | | subObjs.push(item) |
| | | } |
| | | }) |
| | | } else if (Object.keys(val).length > 0) { |
| | | val.$$key = tb + '_' + key |
| | | subObjs.push(val) |
| | | } |
| | | } else if (val !== null && val !== undefined) { |
| | | keys.push(key) |
| | | vals.push(`'${val}'`) |
| | | } |
| | | }) |
| | | |
| | | lines.push({ |
| | | table: tb, |
| | | insert: `Insert into ${pre}${tb} (${keys.join(',')},mk_level,mk_id,mk_bid)`, |
| | | select: `Select ${vals.join(',')},'${level}','${id}','${bid}'` |
| | | }) |
| | | |
| | | subObjs.forEach(item => { |
| | | getDefaultSql(item, item.$$key, id, level + 1) |
| | | }) |
| | | } |
| | | |
| | | getDefaultSql(result, btn.cbTable, '', 1) |
| | | |
| | | let lineMap = new Map() |
| | | lines.forEach(line => { |
| | | if (lineMap.has(line.table)) { |
| | | let _line = lineMap.get(line.table) |
| | | _line.selects.push(line.select) |
| | | lineMap.set(line.table, _line) |
| | | } else { |
| | | lineMap.set(line.table, { |
| | | table: line.table, |
| | | insert: line.insert, |
| | | selects: [line.select] |
| | | }) |
| | | } |
| | | }) |
| | | |
| | | let param = {} |
| | | |
| | | if (btn.callbackType === 'script') { // 使用自定义脚本 |
| | | param.func = 'sPC_TableData_InUpDe' |
| | | |
| | | if (this.props.BID) { |
| | | param.BID = this.props.BID |
| | | } |
| | | |
| | | let _prevCustomScript = '' // 默认sql前执行脚本 |
| | | let _backCustomScript = '' // 默认sql后执行脚本 |
| | | |
| | | btn.verify.cbScripts.forEach(script => { |
| | | if (script.status === 'false') return |
| | | |
| | | if (script.position === 'front') { |
| | | _prevCustomScript += ` |
| | | /* 自定义脚本 */ |
| | | ${script.sql} |
| | | ` |
| | | } else { |
| | | _backCustomScript += ` |
| | | /* 自定义脚本 */ |
| | | ${script.sql} |
| | | ` |
| | | } |
| | | }) |
| | | |
| | | let sql = [...lineMap.values()].map(item => (` |
| | | ${item.insert} |
| | | ${item.selects.join(` union all |
| | | `)} |
| | | `)) |
| | | sql = sql.join('') |
| | | sql = _prevCustomScript + sql |
| | | sql = sql + _backCustomScript |
| | | |
| | | if ((window.GLOB.systemType !== 'production' && options.sysType !== 'cloud') || window.debugger === true) { |
| | | console.info(sql.replace(/\n\s{8}/ig, '\n')) |
| | | } |
| | | |
| | | param.LText = sql |
| | | |
| | | if (sessionStorage.getItem('dataM') === 'true') { // 数据权限 |
| | | param.LText = param.LText.replace(/\$@/ig, '/*') |
| | | param.LText = param.LText.replace(/@\$/ig, '*/') |
| | | } else { |
| | | param.LText = param.LText.replace(/@\$|\$@/ig, '') |
| | | } |
| | | param.LText = param.LText.replace(/\$check@|@check\$/ig, '') |
| | | |
| | | param.exec_type = 'y' // 后台解码 |
| | | param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') |
| | | param.secretkey = Utils.encrypt('', param.timestamp) |
| | | param.LText = Utils.formatOptions(param.LText) |
| | | param.menuname = btn.logLabel |
| | | |
| | | if (this.props.menuType === 'HS') { // 函数 sPC_TableData_InUpDe 云端验证 |
| | | param.open_key = Utils.encryptOpenKey(param.secretkey, param.timestamp) |
| | | } |
| | | } else { |
| | | param.func = 's_ex_result_back' |
| | | param.s_ex_result = [...lineMap.values()].map((item, index) => ({ |
| | | MenuID: btn.uuid, |
| | | MenuName: btn.logLabel, |
| | | TableName: item.table, |
| | | LongText: window.btoa(window.encodeURIComponent(`${item.insert} ${item.selects.join(` union all `)}`)), |
| | | Sort: index + 1 |
| | | })) |
| | | |
| | | if ((window.GLOB.systemType !== 'production' && options.sysType !== 'cloud') || window.debugger === true) { |
| | | let sql = [...lineMap.values()].map(item => (` |
| | | ${item.insert} |
| | | ${item.selects.join(` union all |
| | | `)} |
| | | `)) |
| | | sql = sql.join('') |
| | | console.info(sql.replace(/\n\s{10}/ig, '\n')) |
| | | } |
| | | } |
| | | |
| | | Api.genericInterface(param).then(res => { |
| | | if (res.status) { |
| | | if (params.length === 0) { |
| | | this.execSuccess(res) |
| | | _resolve() |
| | | } else { |
| | | this.customLoopRequest(params, btn, _resolve) |
| | | this.customLoopRequest(params, _resolve) |
| | | } |
| | | } else { |
| | | this.execError(res) |
| | |
| | | }) |
| | | } |
| | | } |
| | | if (btn.intertype === 'custom' && btn.callbackType === 'script' && (!btn.verify || !btn.verify.cbScripts || !btn.verify.cbScripts.filter(item => item.status !== 'false').length === 0)) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: `按钮《${btn.label}》未设置回调脚本, 将不会生效!`, |
| | | duration: 5 |
| | | }) |
| | | } |
| | | }) |
| | | |
| | | if (config.setting.interType === 'system' && config.setting.default !== 'false' && !config.setting.dataresource) { |
| | |
| | | let ableField = usefulFields.join(', ') |
| | | let functip = <div> |
| | | <p style={{marginBottom: '5px'}}>{this.state.dict['model.tooltip.func.innerface'].replace('@ableField', ableField)}</p> |
| | | <p>{this.state.dict['model.tooltip.func.outface']}</p> |
| | | </div> |
| | | |
| | | this.setState({ |
| | |
| | | interType: null, // 接口类型:内部、外部 |
| | | funcType: null, // 功能类型 |
| | | position: null, // 按钮位置 |
| | | procMode: null, // 外部接口参数处理方式 |
| | | pageTemplate: null, |
| | | requireOptions: [{ |
| | | value: 'notRequired', |
| | |
| | | let _opentype = card.OpenType // 打开方式 |
| | | // let _tabType = card.tabType || 'SubTable' // 按钮为弹窗(标签)时,标签的类型 |
| | | let _intertype = card.intertype || 'system' // 接口类型 |
| | | let _procMode = card.procMode || 'system' // 参数处理方式 |
| | | let _funcType = card.funcType || '' // 功能按钮默认类型 |
| | | let _tabTemplate = card.tabTemplate // 按钮为标签页时,标签类型:三级菜单或表单标签页 |
| | | let _pageTemplate = card.pageTemplate // 新页面类型 |
| | |
| | | } |
| | | |
| | | let _tabs = this.props.tabs.filter(tab => tab.type === 'SubTable') |
| | | let _options = this.getOptions(_opentype, _intertype, _funcType, _pageTemplate, _tabTemplate) |
| | | let _options = this.getOptions(_opentype, _intertype, _funcType, _pageTemplate, _tabTemplate, _procMode) |
| | | |
| | | this.setState({ |
| | | openType: _opentype, |
| | | pageTemplate: _pageTemplate, |
| | | interType: _intertype, |
| | | procMode: _procMode, |
| | | position: card.position || 'toolbar', |
| | | funcType: _funcType, |
| | | formlist: this.props.formlist.map(item => { |
| | | if (item.key === 'class') { |
| | | item.options = btnClasses |
| | | } else if (item.key === 'innerFunc' && _procMode === 'inner') { |
| | | item.required = true |
| | | } else if (item.key === 'icon') { |
| | | item.options = btnIcons |
| | | } else if (item.key === 'intertype') { |
| | |
| | | } |
| | | } |
| | | |
| | | getOptions = (_opentype, _intertype, _funcType, _pageTemplate, _tabTemplate) => { |
| | | getOptions = (_opentype, _intertype, _funcType, _pageTemplate, _tabTemplate, _procMode) => { |
| | | let _options = fromJS(actionTypeOptions[_opentype]).toJS() // 选项列表 |
| | | |
| | | if (_opentype === 'innerpage') { // 新页面,可选模板(自定义时,可填入外部链接) |
| | |
| | | } |
| | | } else if (_opentype !== 'popview') { // 打开方式不是弹窗页面时 |
| | | if (_intertype === 'custom') { |
| | | _options.push('sql', 'sqlType', 'innerFunc', 'interface', 'callbackType', 'cbTable', 'proInterface', 'method') |
| | | _options.push('procMode', 'interface', 'callbackType', 'cbTable', 'proInterface', 'method') |
| | | if (_procMode === 'system') { |
| | | _options.push('sql', 'sqlType') |
| | | } else { |
| | | _options.push('innerFunc') |
| | | } |
| | | } else if (_intertype === 'outer') { |
| | | _options.push('innerFunc', 'sysInterface', 'interface', 'outerFunc', 'callbackFunc') |
| | | } else if (_intertype === 'inner') { |
| | |
| | | * @description 切换 |
| | | */ |
| | | optionChange = (key, value) => { |
| | | const { openType, funcType } = this.state |
| | | const { openType, funcType, procMode } = this.state |
| | | const { card } = this.props |
| | | |
| | | if (key === 'OpenType') { |
| | | let _options = this.getOptions(value, 'system', '', this.state.pageTemplate, card.tabTemplate) |
| | | let _options = this.getOptions(value, 'system', '', this.state.pageTemplate, card.tabTemplate, 'system') |
| | | let _fieldval = {} |
| | | let _formlist = this.state.formlist.map(item => { |
| | | item.hidden = !_options.includes(item.key) |
| | |
| | | openType: value, |
| | | funcType: '', |
| | | intertype: 'system', |
| | | procMode: 'system', |
| | | formlist: _formlist |
| | | }, () => { |
| | | if (value === 'excelIn') { |
| | |
| | | // this.props.form.setFieldsValue(_fieldval) |
| | | // }) |
| | | } else if (key === 'funcType') { |
| | | let _options = this.getOptions('funcbutton', this.state.interType, value, card.pageTemplate, card.tabTemplate) |
| | | let _options = this.getOptions('funcbutton', this.state.interType, value, card.pageTemplate, card.tabTemplate, procMode) |
| | | let _fieldval = {} |
| | | |
| | | this.setState({ |
| | |
| | | this.props.form.setFieldsValue(_fieldval) |
| | | }) |
| | | } else if (key === 'pageTemplate') { |
| | | let _options = this.getOptions('innerpage', this.state.interType, this.state.funcType, value, card.tabTemplate) |
| | | let _options = this.getOptions('innerpage', this.state.interType, this.state.funcType, value, card.tabTemplate, procMode) |
| | | let _fieldval = {} |
| | | |
| | | this.setState({ |
| | |
| | | }) |
| | | }) |
| | | } else if (key === 'intertype') { |
| | | let _options = this.getOptions(openType, value, funcType, '', '') |
| | | let _options = this.getOptions(openType, value, funcType, '', '', procMode) |
| | | |
| | | this.setState({ |
| | | interType: value, |
| | |
| | | } |
| | | return item |
| | | }) |
| | | }, () => { |
| | | if (this.props.form.getFieldValue('sqlType') !== undefined) { |
| | | this.props.form.setFieldsValue({sqlType: ''}) |
| | | } |
| | | }) |
| | | } else if (key === 'procMode') { |
| | | let _options = this.getOptions(openType, this.state.interType, funcType, '', '', value) |
| | | |
| | | this.setState({ |
| | | procMode: value, |
| | | formlist: this.state.formlist.map(item => { |
| | | item.hidden = !_options.includes(item.key) |
| | | |
| | | if (item.key === 'innerFunc') { |
| | | item.required = true |
| | | } |
| | | return item |
| | | }) |
| | | }) |
| | | } else if (key === 'sysInterface') { |
| | | if (value === 'true') { |
| | |
| | | <Form.Item label={item.label} className="textarea"> |
| | | {getFieldDecorator(item.key, { |
| | | initialValue: item.initVal |
| | | })(<TextArea rows={4} />)} |
| | | })(<TextArea rows={2} />)} |
| | | </Form.Item> |
| | | </Col> |
| | | ) |
| | |
| | | let ableField = usefulFields.join(', ') |
| | | let functip = <div> |
| | | <p style={{marginBottom: '5px'}}>{this.state.dict['model.tooltip.func.innerface'].replace('@ableField', ableField)}</p> |
| | | <p>{this.state.dict['model.tooltip.func.outface']}</p> |
| | | </div> |
| | | |
| | | let menulist = [] |
| | |
| | | {/* 编辑按钮:复制、编辑 */} |
| | | <Modal |
| | | title={dict['model.action'] + '-' + (card && card.copyType === 'action' ? dict['model.copy'] : dict['model.edit'])} |
| | | wrapClassName="model-table-action-edit-modal" |
| | | visible={visible} |
| | | width={850} |
| | | maskClosable={false} |
| | |
| | | } |
| | | } |
| | | |
| | | .model-table-action-edit-modal { |
| | | .ant-modal { |
| | | top: 60px; |
| | | padding-bottom: 5px; |
| | | } |
| | | } |
| | | .model-table-action-verify-modal { |
| | | .ant-modal { |
| | | top: 50px; |
| | |
| | | systemScripts: res.data.map(item => { |
| | | return { |
| | | name: item.funcname, |
| | | value: Utils.UnformatOptions(item.longparam) |
| | | value: window.decodeURIComponent(window.atob(item.longparam)) |
| | | // value: Utils.UnformatOptions(item.longparam) |
| | | } |
| | | }) |
| | | }) |
| | |
| | | |
| | | import asyncComponent from '@/utils/asyncComponent' |
| | | import ColForm from './columnform' |
| | | import CustomScript from '@/templates/zshare/customscript' |
| | | import SettingForm from './settingform' |
| | | import SettingUtils from './utils' |
| | | import './index.scss' |
| | | |
| | | const { TabPane } = Tabs |
| | | |
| | | const CustomScript = asyncComponent(() => import('@/templates/zshare/customscript')) |
| | | const FieldsComponent = asyncComponent(() => import('@/templates/sharecomponent/fieldscomponent')) |
| | | |
| | | class VerifyCard extends Component { |
| | |
| | | import CodeMirror from '@/templates/zshare/codemirror' |
| | | import './index.scss' |
| | | |
| | | const { TextArea } = Input |
| | | |
| | | class SettingForm extends Component { |
| | | static propTpyes = { |
| | | config: PropTypes.object, // 页面配置 |
| | |
| | | |
| | | state = { |
| | | interType: 'system', |
| | | procMode: 'system', |
| | | requestMode: 'system', |
| | | funcTooltip: '', |
| | | funcRules: [] |
| | | } |
| | |
| | | |
| | | this.setState({ |
| | | interType: setting.interType || 'system', |
| | | procMode: setting.procMode || 'system', |
| | | requestMode: setting.requestMode || 'system', |
| | | funcTooltip: tooltip, |
| | | funcRules: rules |
| | | }) |
| | |
| | | this.setState({ |
| | | interType: value |
| | | }) |
| | | } else if (key === 'sysInterface') { |
| | | if (value === 'true') { |
| | | this.props.form.setFieldsValue({ |
| | | interface: window.GLOB.mainSystemApi || '' |
| | | }) |
| | | } |
| | | } else if (key === 'procMode') { |
| | | this.setState({ |
| | | procMode: value |
| | | }) |
| | | } else if (key === 'requestMode') { |
| | | this.setState({ |
| | | requestMode: value |
| | | }) |
| | | } else if (key === 'sysInterface' && value === 'true') { |
| | | this.props.form.setFieldsValue({ |
| | | interface: window.GLOB.mainSystemApi || '' |
| | | }) |
| | | } |
| | | } |
| | | |
| | |
| | | render() { |
| | | const { setting, dict, menu, config, columns } = this.props |
| | | const { getFieldDecorator } = this.props.form |
| | | const { interType, funcRules, funcTooltip } = this.state |
| | | const { interType, funcRules, funcTooltip, procMode, requestMode } = this.state |
| | | |
| | | const formItemLayout = { |
| | | labelCol: { |
| | |
| | | }, |
| | | ] |
| | | })( |
| | | <Radio.Group onChange={(e) => {this.onRadioChange(e, 'interType')}}> |
| | | <Radio.Group style={{whiteSpace: 'nowrap'}} onChange={(e) => {this.onRadioChange(e, 'interType')}}> |
| | | <Radio value="system">系统</Radio> |
| | | <Radio value="inner">内部</Radio> |
| | | <Radio value="outer">外部</Radio> |
| | | <Radio value="custom">自定义</Radio> |
| | | </Radio.Group>)} |
| | | </Form.Item> |
| | | </Col> |
| | |
| | | </Radio.Group>)} |
| | | </Form.Item> |
| | | </Col> : null} |
| | | {interType === 'inner' ? <Col span={12}> |
| | | {interType === 'custom' ? <Col span={12}> |
| | | <Form.Item label="参数处理"> |
| | | {getFieldDecorator('procMode', { |
| | | initialValue: procMode, |
| | | rules: [ |
| | | { |
| | | required: true, |
| | | message: dict['form.required.select'] + '参数处理方式!' |
| | | }, |
| | | ] |
| | | })( |
| | | <Radio.Group style={{whiteSpace: 'nowrap'}} onChange={(e) => {this.onRadioChange(e, 'procMode')}}> |
| | | <Radio value="system">前置脚本</Radio> |
| | | <Radio value="inner">前置函数</Radio> |
| | | </Radio.Group>)} |
| | | </Form.Item> |
| | | </Col> : null} |
| | | {interType === 'custom' && procMode === 'inner' ? <Col span={12}> |
| | | <Form.Item label={ |
| | | <Tooltip placement="topLeft" title={funcTooltip}> |
| | | <Icon type="question-circle" /> |
| | | 前置函数 |
| | | </Tooltip> |
| | | }> |
| | | {getFieldDecorator('innerFunc', { |
| | | initialValue: setting.innerFunc || '', |
| | | rules: [ |
| | | { |
| | | required: true, |
| | | message: dict['form.required.input'] + '前置函数!' |
| | | }, |
| | | { |
| | | max: formRule.func.max, |
| | | message: formRule.func.maxMessage |
| | | }, |
| | | ...funcRules |
| | | ] |
| | | })(<Input placeholder={''} autoComplete="off" />)} |
| | | </Form.Item> |
| | | </Col> : null} |
| | | {interType === 'outer' || interType === 'custom' ? <Col className="data-source" span={24}> |
| | | <Form.Item label="接口地址"> |
| | | {getFieldDecorator('interface', { |
| | | initialValue: setting.interface || '', |
| | | rules: [ |
| | | { |
| | | required: true, |
| | | message: dict['form.required.input'] + '接口地址!' |
| | | }, |
| | | ] |
| | | })(<TextArea rows={2} />)} |
| | | </Form.Item> |
| | | </Col> : null} |
| | | {interType === 'custom' ? <Col className="data-source" span={24}> |
| | | <Form.Item label={ |
| | | <Tooltip placement="topLeft" title="正式系统所使用的的接口地址。"> |
| | | <Icon type="question-circle" /> |
| | | 正式地址 |
| | | </Tooltip> |
| | | }> |
| | | {getFieldDecorator('proInterface', { |
| | | initialValue: setting.proInterface || '' |
| | | })(<TextArea rows={2} />)} |
| | | </Form.Item> |
| | | </Col> : null} |
| | | {interType === 'custom' ? <Col span={12}> |
| | | <Form.Item label="数据请求"> |
| | | {getFieldDecorator('requestMode', { |
| | | initialValue: requestMode, |
| | | rules: [ |
| | | { |
| | | required: true, |
| | | message: dict['form.required.select'] + '数据请求方式!' |
| | | }, |
| | | ] |
| | | })( |
| | | <Radio.Group style={{whiteSpace: 'nowrap'}} onChange={(e) => {this.onRadioChange(e, 'requestMode')}}> |
| | | <Radio value="system">系统函数</Radio> |
| | | <Radio value="inner">内部函数</Radio> |
| | | </Radio.Group>)} |
| | | </Form.Item> |
| | | </Col> : null} |
| | | {interType === 'inner' || (interType === 'custom' && requestMode === 'inner') ? <Col span={12}> |
| | | <Form.Item label={ |
| | | <Tooltip placement="topLeft" title={funcTooltip}> |
| | | <Icon type="question-circle" /> |
| | |
| | | </Form.Item> |
| | | </Col> : null} |
| | | {interType === 'outer' ? <Col span={12}> |
| | | <Form.Item label="接口地址"> |
| | | {getFieldDecorator('interface', { |
| | | initialValue: setting.interface || '', |
| | | rules: [ |
| | | { |
| | | required: true, |
| | | message: dict['form.required.input'] + '接口地址!' |
| | | }, |
| | | ] |
| | | })(<Input placeholder={''} autoComplete="off" />)} |
| | | </Form.Item> |
| | | </Col> : null} |
| | | {interType === 'outer' ? <Col span={12}> |
| | | <Form.Item label="外部函数"> |
| | | {getFieldDecorator('outerFunc', { |
| | | initialValue: setting.outerFunc || '', |
| | |
| | | })(<Input placeholder={''} autoComplete="off" />)} |
| | | </Form.Item> |
| | | </Col> : null} |
| | | {interType === 'system' ? <Col span={24} className="data-source" style={{paddingLeft: '7px'}}> |
| | | {interType === 'system' || (interType === 'custom' && requestMode === 'system') ? <Col span={24} className="data-source" style={{paddingLeft: '7px'}}> |
| | | <Form.Item help={'数据ID:' + menu.MenuID} labelCol={{xs: { span: 24 }, sm: { span: 4 }}} wrapperCol={ {xs: { span: 24 }, sm: { span: 20 }} } label={ |
| | | <Tooltip placement="topLeft" title={'使用系统函数时,需填写数据源。注:数据权限替换符 $@ -> /* 或 \'\'、 @$ -> */ 或 \'\''}> |
| | | <Icon type="question-circle" /> |
| | |
| | | })(<CodeMirror />)} |
| | | </Form.Item> |
| | | </Col> : null} |
| | | {interType === 'system' ? <Col span={12}> |
| | | {interType === 'system' || (interType === 'custom' && requestMode === 'system') ? <Col span={12}> |
| | | <Form.Item label={ |
| | | <Tooltip placement="topLeft" title={'查询时,搜索条件以where条件拼接进入sql,统计时,将数据源中以“@+搜索字段+@”的内容,以搜索条件中的值进行替换后,提交查询,注:查询类型仅在使用系统函数时有效。'}> |
| | | <Icon type="question-circle" /> |
| | |
| | | </Radio.Group>)} |
| | | </Form.Item> |
| | | </Col> : null} |
| | | {interType === 'system' ? <Col span={12}> |
| | | {interType === 'system' || (interType === 'custom' && requestMode === 'system') ? <Col span={12}> |
| | | <Form.Item label="默认sql"> |
| | | {getFieldDecorator('default', { |
| | | initialValue: setting.default || 'true' |
| | |
| | | })(<Input placeholder={'ID asc, UID desc'} autoComplete="off" />)} |
| | | </Form.Item> |
| | | </Col> |
| | | {interType === 'custom' ? <Col span={12}> |
| | | <Form.Item label="回调方式"> |
| | | {getFieldDecorator('callbackType', { |
| | | initialValue: setting.callbackType || 'default' |
| | | })( |
| | | <Radio.Group> |
| | | <Radio value="default">默认脚本</Radio> |
| | | <Radio value="script">自定义脚本</Radio> |
| | | </Radio.Group>)} |
| | | </Form.Item> |
| | | </Col> : null} |
| | | {interType === 'custom' ? <Col span={12}> |
| | | <Form.Item label={ |
| | | <Tooltip placement="topLeft" title={'同步执行:外部接口调用成功后再请求数据;异步执行:外部接口调用与请求数据同时进行。'}> |
| | | <Icon type="question-circle" /> |
| | | 执行方式 |
| | | </Tooltip> |
| | | }> |
| | | {getFieldDecorator('execType', { |
| | | initialValue: setting.execType || 'sync' |
| | | })( |
| | | <Radio.Group> |
| | | <Radio value="sync">同步</Radio> |
| | | <Radio value="async">异步</Radio> |
| | | </Radio.Group>)} |
| | | </Form.Item> |
| | | </Col> : null} |
| | | {interType === 'custom' ? <Col span={12}> |
| | | <Form.Item label="执行次数"> |
| | | {getFieldDecorator('execTime', { |
| | | initialValue: setting.execTime || 'once' |
| | | })( |
| | | <Radio.Group> |
| | | <Radio value="always">始终</Radio> |
| | | <Radio value="once">一次</Radio> |
| | | </Radio.Group>)} |
| | | </Form.Item> |
| | | </Col> : null} |
| | | <Col span={12}> |
| | | <Form.Item label="是否分页"> |
| | | {getFieldDecorator('laypage', { |
| | |
| | | import Api from '@/api' |
| | | import Utils from '@/utils/utils.js' |
| | | import SettingUtils from './utils.jsx' |
| | | import CustomScript from '@/templates/zshare/customscript' |
| | | import asyncComponent from '@/utils/asyncComponent' |
| | | import DataSource from './datasource' |
| | | import './index.scss' |
| | | |
| | | const { TabPane } = Tabs |
| | | const CustomScript = asyncComponent(() => import('@/templates/zshare/customscript')) |
| | | const SimpleScript = asyncComponent(() => import('./simplescript')) |
| | | |
| | | class SettingForm extends Component { |
| | | static propTpyes = { |
| | |
| | | |
| | | let _setting = fromJS(config.setting).toJS() |
| | | let _scripts = _setting.scripts || [] |
| | | let _preScripts = _setting.preScripts || [] |
| | | let _cbScripts = _setting.cbScripts || [] |
| | | |
| | | _setting.default = _setting.default || 'true' // 默认sql |
| | | _setting.sysInterface = _setting.sysInterface || 'false' // 是否为系统接口 |
| | |
| | | arr_field: arr_field.join(','), |
| | | regoptions: Utils.getRegOptions(search), // 搜索条件,正则替换 |
| | | columns: columns, |
| | | scripts: _scripts |
| | | scripts: _scripts, |
| | | preScripts: _preScripts, |
| | | cbScripts: _cbScripts |
| | | }) |
| | | } |
| | | |
| | |
| | | handleConfirm = (trigger) => { |
| | | const { activeKey, setting, scripts } = this.state |
| | | |
| | | let _loading = false |
| | | if (this.scriptsForm && this.scriptsForm.props.form.getFieldValue('sql')) { |
| | | _loading = true |
| | | } else if (this.preScriptsForm && this.preScriptsForm.props.form.getFieldValue('sql')) { |
| | | _loading = true |
| | | } else if (this.cbScriptsForm && this.cbScriptsForm.props.form.getFieldValue('sql')) { |
| | | _loading = true |
| | | } |
| | | |
| | | if (_loading) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '存在未保存脚本,请点击确定保存,或点击取消放弃修改!', |
| | | duration: 5 |
| | | }) |
| | | return |
| | | } |
| | | |
| | | if (trigger) { |
| | | this.setState({loading: true}) |
| | | } |
| | |
| | | }) |
| | | } else { |
| | | return new Promise((resolve, reject) => { |
| | | let _loading = false |
| | | if (this.scriptsForm && this.scriptsForm.state.editItem) { |
| | | _loading = true |
| | | } else if (this.scriptsForm && this.scriptsForm.props.form.getFieldValue('sql')) { |
| | | _loading = true |
| | | } |
| | | |
| | | if (trigger === 'func' && setting.interType !== 'inner') { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '使用内部接口,才可以创建存储过程!', |
| | | duration: 5 |
| | | }) |
| | | this.setState({loading: false}) |
| | | reject() |
| | | } else if (_loading) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '存在未保存脚本,请点击确定保存,或点击取消放弃修改!', |
| | | duration: 5 |
| | | }) |
| | | this.setState({loading: false}) |
| | |
| | | changeTab = (val) => { |
| | | const { activeKey, search, arr_field } = this.state |
| | | |
| | | let _loading = false |
| | | if (this.scriptsForm && this.scriptsForm.props.form.getFieldValue('sql')) { |
| | | _loading = true |
| | | } else if (this.preScriptsForm && this.preScriptsForm.props.form.getFieldValue('sql')) { |
| | | _loading = true |
| | | } else if (this.cbScriptsForm && this.cbScriptsForm.props.form.getFieldValue('sql')) { |
| | | _loading = true |
| | | } |
| | | |
| | | if (_loading) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '存在未保存脚本,请点击确定保存,或点击取消放弃修改!', |
| | | duration: 5 |
| | | }) |
| | | return |
| | | } |
| | | |
| | | if (activeKey === 'setting') { |
| | | let _defaultSql = '' |
| | | this.settingForm.handleConfirm().then(res => { |
| | |
| | | }) |
| | | }) |
| | | } else if (activeKey === 'scripts') { |
| | | let _loading = false |
| | | if (this.scriptsForm && this.scriptsForm.state.editItem) { |
| | | _loading = true |
| | | } else if (this.scriptsForm && this.scriptsForm.props.form.getFieldValue('sql')) { |
| | | _loading = true |
| | | } |
| | | |
| | | if (_loading) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '存在未保存脚本,请点击确定保存,或点击取消放弃修改!', |
| | | duration: 5 |
| | | }) |
| | | return |
| | | } |
| | | |
| | | this.setState({loading: true}) |
| | | this.sqlverify(() => { // 验证成功 |
| | | this.setState({ |
| | |
| | | scriptsUpdate = (scripts) => { |
| | | this.setState({scripts}) |
| | | } |
| | | |
| | | // 前置脚本更新 |
| | | preScriptsUpdate = (preScripts) => { |
| | | this.setState({preScripts}) |
| | | } |
| | | |
| | | // 后置脚本更新 |
| | | cbScriptsUpdate = (cbScripts) => { |
| | | this.setState({cbScripts}) |
| | | } |
| | | |
| | | render() { |
| | | const { config, menu, dict } = this.props |
| | | const { loading, activeKey, setting, defaultSql, columns, scripts } = this.state |
| | | const { loading, activeKey, setting, defaultSql, columns, scripts, preScripts, cbScripts } = this.state |
| | | |
| | | return ( |
| | | <div className="model-table-setting-form-box" id="model-setting-form-body"> |
| | |
| | | scripts={scripts} |
| | | defaultSql={defaultSql} |
| | | searches={this.props.search} |
| | | scriptsChange={this.scriptsChange} |
| | | scriptsUpdate={this.scriptsUpdate} |
| | | wrappedComponentRef={(inst) => this.scriptsForm = inst} |
| | | /> |
| | | </TabPane> |
| | | <TabPane tab={ |
| | | <span> |
| | | 前置脚本 |
| | | {preScripts.length ? <span className="count-tip">{preScripts.length}</span> : null} |
| | | </span> |
| | | } key="prescripts"> |
| | | <SimpleScript |
| | | dict={dict} |
| | | setting={setting} |
| | | scripts={preScripts} |
| | | defaultSql={defaultSql} |
| | | searches={this.props.search} |
| | | scriptsChange={this.scriptsChange} |
| | | scriptsUpdate={this.preScriptsUpdate} |
| | | wrappedComponentRef={(inst) => this.preScriptsForm = inst} |
| | | /> |
| | | </TabPane> |
| | | <TabPane tab={ |
| | | <span> |
| | | 回调脚本 |
| | | {cbScripts.length ? <span className="count-tip">{cbScripts.length}</span> : null} |
| | | </span> |
| | | } key="cbscripts"> |
| | | <SimpleScript |
| | | dict={dict} |
| | | setting={setting} |
| | | scripts={cbScripts} |
| | | searches={this.props.search} |
| | | scriptsChange={this.scriptsChange} |
| | | scriptsUpdate={this.scriptsUpdate} |
| | | wrappedComponentRef={(inst) => this.cbScriptsForm = inst} |
| | | /> |
| | | </TabPane> |
| | | </Tabs> |
| | | </div> |
| | | ) |
New file |
| | |
| | | import React, {Component} from 'react' |
| | | import PropTypes from 'prop-types' |
| | | import { fromJS } from 'immutable' |
| | | import { Form, Row, Col, Icon, Button, notification, Select, Popconfirm, Typography } from 'antd' |
| | | import moment from 'moment' |
| | | |
| | | import Utils from '@/utils/utils.js' |
| | | import Api from '@/api' |
| | | import CodeMirror from '@/templates/zshare/codemirror' |
| | | import asyncComponent from '@/utils/asyncComponent' |
| | | import './index.scss' |
| | | |
| | | const { Paragraph } = Typography |
| | | const EditTable = asyncComponent(() => import('@/templates/zshare/editTable')) |
| | | |
| | | class CustomForm extends Component { |
| | | static propTpyes = { |
| | | dict: PropTypes.object, // 字典项 |
| | | setting: PropTypes.object, // 设置 |
| | | scripts: PropTypes.array, // 自定义脚本列表 |
| | | searches: PropTypes.array, // 搜索条件 |
| | | defaultSql: PropTypes.string, // 默认sql |
| | | scriptsChange: PropTypes.func, // 自定义脚本切换时验证 |
| | | scriptsUpdate: PropTypes.func // 表单 |
| | | } |
| | | |
| | | state = { |
| | | editItem: null, |
| | | loading: false, |
| | | usefulFields: '', |
| | | systemScripts: [], |
| | | scriptsColumns: [ |
| | | { |
| | | title: 'SQL', |
| | | dataIndex: 'sql', |
| | | width: '73%', |
| | | render: (text) => { |
| | | let title = text.match(/^\s*\/\*.+\*\//) |
| | | title = title && title[0] ? title[0] : '' |
| | | text = title ? text.replace(title, '') : text |
| | | |
| | | return ( |
| | | <div> |
| | | {title ? <span style={{color: '#a50'}}>{title}</span> : null} |
| | | <Paragraph copyable ellipsis={{ rows: 4, expandable: true }}>{text}</Paragraph> |
| | | </div> |
| | | ) |
| | | } |
| | | }, |
| | | { |
| | | title: '状态', |
| | | dataIndex: 'status', |
| | | width: '12%', |
| | | render: (text, record) => record.status === 'false' ? |
| | | ( |
| | | <div> |
| | | {this.props.dict['model.status.forbidden']} |
| | | <Icon style={{marginLeft: '5px'}} type="stop" theme="twoTone" twoToneColor="#ff4d4f" /> |
| | | </div> |
| | | ) : |
| | | ( |
| | | <div> |
| | | {this.props.dict['model.status.open']} |
| | | <Icon style={{marginLeft: '5px'}} type="check-circle" theme="twoTone" twoToneColor="#52c41a" /> |
| | | </div> |
| | | ) |
| | | }, |
| | | { |
| | | title: '操作', |
| | | align: 'center', |
| | | width: '15%', |
| | | dataIndex: 'operation', |
| | | render: (text, record) => |
| | | (<div style={{textAlign: 'center'}}> |
| | | <span className="operation-btn" title={this.props.dict['model.edit']} onClick={() => this.handleEdit(record)} style={{color: '#1890ff'}}><Icon type="edit" /></span> |
| | | <span className="operation-btn" title={this.props.dict['header.form.status.change']} onClick={() => this.handleStatus(record)} style={{color: '#8E44AD'}}><Icon type="swap" /></span> |
| | | <Popconfirm |
| | | overlayClassName="popover-confirm" |
| | | title={this.props.dict['model.query.delete']} |
| | | onConfirm={() => this.handleDelete(record) |
| | | }> |
| | | <span className="operation-btn" style={{color: '#ff4d4f'}}><Icon type="delete" /></span> |
| | | </Popconfirm> |
| | | </div>) |
| | | } |
| | | ] |
| | | } |
| | | |
| | | UNSAFE_componentWillMount() { |
| | | const { searches, scripts } = this.props |
| | | |
| | | let _usefulFields = [] |
| | | searches.forEach(item => { |
| | | if (!item.field) return |
| | | if (item.type === 'group') { |
| | | if (item.transfer === 'true') { |
| | | _usefulFields.push(item.field) |
| | | } |
| | | _usefulFields.push(item.datefield) |
| | | _usefulFields.push(item.datefield + '1') |
| | | } else if (['dateweek', 'datemonth', 'daterange'].includes(item.type)) { |
| | | _usefulFields.push(item.field) |
| | | _usefulFields.push(item.field + '1') |
| | | } else if (_usefulFields.includes(item.field)) { |
| | | _usefulFields.push(item.field + '1') |
| | | } else { |
| | | _usefulFields.push(item.field) |
| | | } |
| | | }) |
| | | |
| | | this.setState({ |
| | | usefulFields: _usefulFields.join(', '), |
| | | scripts: fromJS(scripts).toJS() |
| | | }) |
| | | } |
| | | |
| | | componentDidMount () { |
| | | this.getsysScript() |
| | | } |
| | | |
| | | getsysScript = () => { |
| | | 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) |
| | | |
| | | let _sParam = { |
| | | func: 'sPC_Get_SelectedList', |
| | | LText: _scriptSql, |
| | | obj_name: 'data', |
| | | arr_field: 'funcname,longparam' |
| | | } |
| | | |
| | | _sParam.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') |
| | | _sParam.secretkey = Utils.encrypt(_sParam.LText, _sParam.timestamp) |
| | | _sParam.open_key = Utils.encryptOpenKey(_sParam.secretkey, _sParam.timestamp) // 云端数据验证 |
| | | |
| | | Api.getSystemConfig(_sParam).then(res => { |
| | | if (res.status) { |
| | | let _scripts = res.data.map(item => { |
| | | let _item = { |
| | | name: item.funcname, |
| | | value: window.decodeURIComponent(window.atob(item.longparam)) |
| | | // value: Utils.UnformatOptions(item.longparam) |
| | | } |
| | | return _item |
| | | }) |
| | | |
| | | this.setState({ |
| | | systemScripts: _scripts |
| | | }) |
| | | } else { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: res.message, |
| | | duration: 5 |
| | | }) |
| | | } |
| | | }) |
| | | } |
| | | |
| | | handleCancel = () => { |
| | | this.setState({ |
| | | editItem: null |
| | | }) |
| | | this.props.form.setFieldsValue({ |
| | | sql: '' |
| | | }) |
| | | } |
| | | |
| | | handleConfirm = () => { |
| | | const { scripts, editItem } = this.state |
| | | |
| | | let _sql = this.props.form.getFieldValue('sql') |
| | | |
| | | if (!_sql) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '请填写自定义脚本!', |
| | | duration: 5 |
| | | }) |
| | | return |
| | | } else if (/^\s+$/.test(_sql)) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '自定义脚本不可为空!', |
| | | duration: 5 |
| | | }) |
| | | return |
| | | } |
| | | |
| | | let values = { |
| | | uuid: editItem && editItem.uuid ? editItem.uuid : Utils.getuuid(), |
| | | sql: _sql |
| | | } |
| | | |
| | | let _quot = values.sql.match(/'{1}/g) |
| | | let _lparen = values.sql.match(/\({1}/g) |
| | | let _rparen = values.sql.match(/\){1}/g) |
| | | |
| | | _quot = _quot ? _quot.length : 0 |
| | | _lparen = _lparen ? _lparen.length : 0 |
| | | _rparen = _rparen ? _rparen.length : 0 |
| | | |
| | | if (_quot % 2 !== 0) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: 'sql中\'必须成对出现', |
| | | duration: 5 |
| | | }) |
| | | return |
| | | } else if (_lparen !== _rparen) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: 'sql中()必须成对出现', |
| | | duration: 5 |
| | | }) |
| | | return |
| | | } else if (/--/ig.test(values.sql)) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '自定义sql语句中,不可出现字符 -- ,注释请用 /*内容*/', |
| | | duration: 5 |
| | | }) |
| | | return |
| | | } |
| | | |
| | | let error = Utils.verifySql(values.sql, 'customscript') |
| | | |
| | | if (error) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: 'sql中不可使用' + error, |
| | | duration: 5 |
| | | }) |
| | | return |
| | | } |
| | | |
| | | let _scripts = fromJS(scripts).toJS() |
| | | |
| | | if (editItem && editItem.uuid) { |
| | | _scripts = _scripts.map(item => { |
| | | if (item.uuid === values.uuid) { |
| | | return values |
| | | } else { |
| | | return item |
| | | } |
| | | }) |
| | | } else { |
| | | _scripts.push(values) |
| | | } |
| | | |
| | | this.setState({loading: true}) |
| | | this.props.scriptsChange(_scripts).then(res => { |
| | | this.setState({ |
| | | loading: false, |
| | | scripts: _scripts, |
| | | editItem: null |
| | | }) |
| | | |
| | | this.props.scriptsUpdate(_scripts) |
| | | this.props.form.setFieldsValue({ |
| | | sql: '' |
| | | }) |
| | | }, () => { |
| | | this.setState({loading: false}) |
| | | }) |
| | | } |
| | | |
| | | selectScript = (value, option) => { |
| | | let _sql = this.props.form.getFieldValue('sql') |
| | | if (_sql) { |
| | | _sql = _sql + ` |
| | | |
| | | ` |
| | | } |
| | | |
| | | _sql = _sql.replace(/\s{6}$/, '') |
| | | _sql = _sql + `/*${option.props.children}*/ |
| | | ` |
| | | _sql = _sql.replace(/\s{4}$/, '') |
| | | _sql = _sql + value |
| | | |
| | | this.props.form.setFieldsValue({ |
| | | sql: _sql |
| | | }) |
| | | } |
| | | |
| | | handleEdit = (record) => { |
| | | this.setState({ |
| | | editItem: record |
| | | }) |
| | | |
| | | this.props.form.setFieldsValue({ |
| | | sql: record.sql |
| | | }) |
| | | |
| | | this.scrolltop() |
| | | } |
| | | |
| | | scrolltop = () => { |
| | | let node = document.getElementById('model-setting-form-body').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) |
| | | } |
| | | } |
| | | |
| | | changeScripts = (scripts) => { |
| | | this.setState({scripts}) |
| | | this.props.scriptsUpdate(scripts) |
| | | } |
| | | |
| | | handleStatus = (record) => { |
| | | let scripts = fromJS(this.state.scripts).toJS() |
| | | record.status = record.status === 'false' ? 'true' : 'false' |
| | | |
| | | scripts = scripts.map(item => { |
| | | if (item.uuid === record.uuid) { |
| | | return record |
| | | } else { |
| | | return item |
| | | } |
| | | }) |
| | | |
| | | this.setState({scripts}) |
| | | this.props.scriptsUpdate(scripts) |
| | | } |
| | | |
| | | handleDelete = (record) => { |
| | | let scripts = fromJS(this.state.scripts).toJS() |
| | | scripts = scripts.filter(item => item.uuid !== record.uuid) |
| | | |
| | | this.setState({ scripts }) |
| | | this.props.scriptsUpdate(scripts) |
| | | } |
| | | |
| | | render() { |
| | | const { setting, defaultSql, scripts } = this.props |
| | | const { getFieldDecorator } = this.props.form |
| | | const { usefulFields, scriptsColumns, systemScripts } = this.state |
| | | const formItemLayout = { |
| | | labelCol: { |
| | | xs: { span: 24 }, |
| | | sm: { span: 8 } |
| | | }, |
| | | wrapperCol: { |
| | | xs: { span: 24 }, |
| | | sm: { span: 16 } |
| | | } |
| | | } |
| | | |
| | | return ( |
| | | <div className="modal-menu-setting-script"> |
| | | <Form {...formItemLayout}> |
| | | <Row gutter={24}> |
| | | {setting.tableName ? <Col span={8}> |
| | | <Form.Item label={'表名'} style={{whiteSpace: 'nowrap', margin: 0}}> |
| | | {setting.tableName} |
| | | </Form.Item> |
| | | </Col> : null} |
| | | <Col span={16}> |
| | | <Form.Item label={'报错字段'} style={{margin: 0}}> |
| | | ErrorCode, retmsg |
| | | </Form.Item> |
| | | </Col> |
| | | <Col span={24} className="sqlfield"> |
| | | <Form.Item label={'可用字段'}> |
| | | id, bid, loginuid, sessionuid, userid, username, fullname, appkey, time_id, orderBy{setting.laypage === 'true' ? ', pageSize, pageIndex': ''}{usefulFields ? ', ' + usefulFields : ''} |
| | | </Form.Item> |
| | | </Col> |
| | | <Col span={10} className="quick-add"> |
| | | <Form.Item label={'快捷添加'} style={{marginBottom: 0}}> |
| | | <Select |
| | | showSearch |
| | | filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0} |
| | | onChange={this.selectScript} |
| | | > |
| | | <Select.Option key="default" value={defaultSql}>默认sql</Select.Option> |
| | | {systemScripts.map((option, i) => |
| | | <Select.Option style={{whiteSpace: 'normal'}} key={i} value={option.value}>{option.name}</Select.Option> |
| | | )} |
| | | </Select> |
| | | </Form.Item> |
| | | </Col> |
| | | <Col span={6} className="add"> |
| | | <Button onClick={this.handleConfirm} loading={this.state.loading} className="mk-green" style={{marginTop: 5, marginBottom: 15, marginLeft: 30}}> |
| | | 保存 |
| | | </Button> |
| | | <Button onClick={this.handleCancel} style={{marginTop: 5, marginBottom: 15, marginLeft: 10}}> |
| | | 取消 |
| | | </Button> |
| | | </Col> |
| | | <Col span={24} className="sql"> |
| | | <Form.Item label={'sql'}> |
| | | {getFieldDecorator('sql', { |
| | | initialValue: '' |
| | | })(<CodeMirror />)} |
| | | </Form.Item> |
| | | </Col> |
| | | </Row> |
| | | </Form> |
| | | <EditTable data={scripts} actions={['move']} columns={scriptsColumns} onChange={this.changeScripts}/> |
| | | </div> |
| | | ) |
| | | } |
| | | } |
| | | |
| | | export default Form.create()(CustomForm) |
New file |
| | |
| | | .modal-menu-setting-script { |
| | | .sqlfield { |
| | | .ant-form-item { |
| | | margin-bottom: 5px; |
| | | } |
| | | .ant-form-item-control { |
| | | line-height: 24px; |
| | | } |
| | | .ant-form-item-label { |
| | | line-height: 25px; |
| | | } |
| | | .ant-form-item-children { |
| | | line-height: 22px; |
| | | } |
| | | .ant-col-sm-8 { |
| | | width: 10.5%; |
| | | } |
| | | .ant-col-sm-16 { |
| | | width: 89.5%; |
| | | } |
| | | } |
| | | .quick-add { |
| | | .ant-col-sm-8 { |
| | | width: 26%; |
| | | } |
| | | .ant-col-sm-16 { |
| | | width: 74%; |
| | | } |
| | | } |
| | | .sql { |
| | | .ant-col-sm-8 { |
| | | width: 10.5%; |
| | | } |
| | | .ant-col-sm-16 { |
| | | width: 89.5%; |
| | | padding-top: 4px; |
| | | } |
| | | .CodeMirror { |
| | | height: 350px; |
| | | } |
| | | } |
| | | div.ant-typography { |
| | | margin-bottom: 0; |
| | | } |
| | | } |
| | |
| | | import Utils from '@/utils/utils.js' |
| | | import SettingUtils from './utils.jsx' |
| | | import DataSource from './datasource' |
| | | import CustomScript from '@/templates/zshare/customscript' |
| | | import asyncComponent from '@/utils/asyncComponent' |
| | | import './index.scss' |
| | | |
| | | const { TabPane } = Tabs |
| | | const CustomScript = asyncComponent(() => import('@/templates/zshare/customscript')) |
| | | |
| | | class SettingForm extends Component { |
| | | static propTpyes = { |
| | |
| | | let _scripts = res.data.map(item => { |
| | | let _item = { |
| | | name: item.funcname, |
| | | value: Utils.UnformatOptions(item.longparam) |
| | | value: window.decodeURIComponent(window.atob(item.longparam)) |
| | | // value: Utils.UnformatOptions(item.longparam) |
| | | } |
| | | return _item |
| | | }) |
| | |
| | | options: opentypes |
| | | }, |
| | | { |
| | | type: 'select', |
| | | type: 'radio', |
| | | key: 'funcType', |
| | | label: Formdict['header.form.funcType'], |
| | | initVal: card.funcType || '', |
| | |
| | | }, |
| | | { |
| | | type: 'text', |
| | | key: 'sql', |
| | | label: Formdict['model.form.tablename'], |
| | | initVal: card.sql || config.setting.tableName || '', |
| | | required: true |
| | | key: 'label', |
| | | label: '按钮名称', |
| | | initVal: card.label, |
| | | required: true, |
| | | readonly: false |
| | | }, |
| | | { |
| | | type: 'radio', |
| | | key: 'procMode', |
| | | label: '参数处理', |
| | | initVal: card.procMode || 'system', |
| | | required: true, |
| | | options: [{ |
| | | value: 'system', |
| | | text: '系统函数' |
| | | }, { |
| | | value: 'inner', |
| | | text: '内部函数' |
| | | }] |
| | | }, |
| | | { |
| | | type: 'radio', |
| | |
| | | }, |
| | | { |
| | | type: 'text', |
| | | key: 'label', |
| | | label: '按钮名称', |
| | | initVal: card.label, |
| | | required: true, |
| | | readonly: false |
| | | key: 'sql', |
| | | label: Formdict['model.form.tablename'], |
| | | initVal: card.sql || config.setting.tableName || '', |
| | | required: true |
| | | }, |
| | | { |
| | | type: 'text', |
| | |
| | | readonly: false |
| | | }, |
| | | { |
| | | type: 'text', |
| | | type: 'textarea', |
| | | key: 'interface', |
| | | label: Formdict['header.form.interface'], |
| | | initVal: card.sysInterface === 'true' ? (window.GLOB.mainSystemApi || '') : (card.interface || ''), |
| | | required: true, |
| | | readonly: card.sysInterface === 'true' |
| | | }, |
| | | { |
| | | type: 'textarea', |
| | | key: 'proInterface', |
| | | label: '正式地址', |
| | | initVal: card.proInterface || '', |
| | | tooltip: '正式系统所使用的接口地址。', |
| | | required: false |
| | | }, |
| | | { |
| | | type: 'radio', |
| | |
| | | }] |
| | | }, |
| | | { |
| | | type: 'text', |
| | | key: 'proInterface', |
| | | label: '正式地址', |
| | | initVal: card.proInterface || '', |
| | | tooltip: '正式系统所使用的接口地址。', |
| | | required: false |
| | | }, |
| | | { |
| | | type: 'radio', |
| | | key: 'callbackType', |
| | | label: '回调方式', |
| | | initVal: card.callbackType || 'default', |
| | | initVal: card.callbackType || 'script', |
| | | tooltip: '使用默认方式执行时,需要配合计划任务。', |
| | | required: true, |
| | | options: [{ |
| | | value: 'default', |
| | | text: '默认执行' |
| | | text: '默认脚本' |
| | | }, { |
| | | value: 'script', |
| | | text: '自定义脚本' |
| | |
| | | } |
| | | |
| | | selectScript = (value, option) => { |
| | | if (!value || !option) return |
| | | let _sql = this.props.form.getFieldValue('sql') |
| | | if (_sql) { |
| | | _sql = _sql + ` |
| | |
| | | } |
| | | |
| | | return ( |
| | | <Form {...formItemLayout} className="verify-form" id="verify-custom-scripts"> |
| | | <Form {...formItemLayout} className="verify-form" id="verify-custom-callback-scripts"> |
| | | <Row gutter={24}> |
| | | {btn.cbTable ? <Col span={8}> |
| | | <Col span={8}> |
| | | <Form.Item label={'表名'} style={{whiteSpace: 'nowrap', margin: 0}}> |
| | | {btn.cbTable} |
| | | </Form.Item> |
| | | </Col> : null} |
| | | </Col> |
| | | <Col span={16}> |
| | | <Form.Item label={'报错字段'} style={{margin: 0}}> |
| | | ErrorCode, retmsg |
| | |
| | | <Col span={10}> |
| | | <Form.Item label={'快捷添加'} style={{marginBottom: 0}}> |
| | | <Select |
| | | allowClear |
| | | showSearch |
| | | filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0} |
| | | onChange={this.selectScript} |
| | | getPopupContainer={() => document.getElementById('verify-custom-scripts')} |
| | | getPopupContainer={() => document.getElementById('verify-custom-callback-scripts')} |
| | | > |
| | | <Select.Option key="default" value={`declare @${btn.cbTable} table (mk_api_key nvarchar(100))`}>默认sql</Select.Option> |
| | | {systemScripts.map((option, i) => |
| | | <Select.Option key={i} value={option.value}>{option.name}</Select.Option> |
| | | )} |
| | |
| | | } |
| | | |
| | | selectScript = (value, option) => { |
| | | if (!value || !option) return |
| | | |
| | | let _sql = this.props.form.getFieldValue('sql') |
| | | if (_sql) { |
| | | _sql = _sql + ` |
| | |
| | | <Form.Item label={'快捷添加'} style={{marginBottom: 0}}> |
| | | <Select |
| | | showSearch |
| | | allowClear |
| | | filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0} |
| | | onChange={this.selectScript} |
| | | getPopupContainer={() => document.getElementById('verify-custom-scripts')} |
| | |
| | | systemScripts: res.scripts.map(item => { |
| | | return { |
| | | name: item.funcname, |
| | | value: Utils.UnformatOptions(item.longparam) |
| | | value: window.decodeURIComponent(window.atob(item.longparam)) |
| | | // value: Utils.UnformatOptions(item.longparam) |
| | | } |
| | | }) |
| | | }) |
| | |
| | | |
| | | return ( |
| | | <div id="verify-card-box-tab"> |
| | | {card.intertype === 'system' || card.intertype === 'custom' ? <Tabs defaultActiveKey="1" className="verify-card-box"> |
| | | <TabPane tab="基础验证" key="1"> |
| | | <Tabs defaultActiveKey="1" className="verify-card-box"> |
| | | {card.intertype === 'system' || (card.intertype === 'custom' && card.procMode === 'system') ? <TabPane tab="基础验证" key="1"> |
| | | <Form {...formItemLayout}> |
| | | <Row gutter={24}> |
| | | {this.props.card.sqlType !== 'custom' ? <Col span={8}> |
| | |
| | | </Col> : null} |
| | | </Row> |
| | | </Form> |
| | | </TabPane> |
| | | <TabPane tab={ |
| | | </TabPane> : null} |
| | | {card.intertype === 'system' || (card.intertype === 'custom' && card.procMode === 'system') ? <TabPane tab={ |
| | | <span> |
| | | 比较验证 |
| | | {verify.contrasts.length ? <span className="count-tip">{verify.contrasts.length}</span> : null} |
| | |
| | | } key="2x"> |
| | | <ContrastForm dict={this.props.dict} contrastChange={this.contrastChange}/> |
| | | <EditTable actions={['edit', 'move', 'copy', 'del']} type="contrastverify" data={verify.contrasts} columns={contrastColumns} onChange={(contrasts) => this.setState({verify: {...verify, contrasts}})}/> |
| | | </TabPane> |
| | | <TabPane tab={ |
| | | </TabPane> : null} |
| | | {card.intertype === 'system' || (card.intertype === 'custom' && card.procMode === 'system') ? <TabPane tab={ |
| | | <span> |
| | | 自定义验证 |
| | | {verify.customverifys.length ? <span className="count-tip">{verify.customverifys.length}</span> : null} |
| | |
| | | wrappedComponentRef={(inst) => this.customForm = inst} |
| | | /> |
| | | <EditTable actions={['move']} data={verify.customverifys} columns={customColumns} onChange={(customverifys) => {this.setState({verify: {...verify, customverifys}})}}/> |
| | | </TabPane> |
| | | <TabPane tab={ |
| | | </TabPane> : null} |
| | | {card.intertype === 'system' || (card.intertype === 'custom' && card.procMode === 'system') ? <TabPane tab={ |
| | | <span> |
| | | 单号生成 |
| | | {verify.billcodes.length ? <span className="count-tip">{verify.billcodes.length}</span> : null} |
| | |
| | | wrappedComponentRef={(inst) => this.orderForm = inst} |
| | | /> |
| | | <EditTable actions={['move']} data={verify.billcodes} columns={orderColumns} onChange={(billcodes) => {this.setState({verify: {...verify, billcodes}})}}/> |
| | | </TabPane> |
| | | <TabPane tab={ |
| | | </TabPane> : null} |
| | | {card.intertype === 'system' || (card.intertype === 'custom' && card.procMode === 'system') ? <TabPane tab={ |
| | | <span> |
| | | {card.Ot !== 'requiredOnce' ? '唯一性验证' : '同类数据验证'} |
| | | {verify.uniques.length ? <span className="count-tip">{verify.uniques.length}</span> : null} |
| | |
| | | uniqueChange={this.uniqueChange} |
| | | /> |
| | | <EditTable actions={['edit', 'move', 'del']} data={verify.uniques} columns={card.Ot !== 'requiredOnce' ? uniqueColumns : onceUniqueColumns} onChange={this.changeUniques}/> |
| | | </TabPane> |
| | | <TabPane tab={ |
| | | </TabPane> : null} |
| | | {card.intertype === 'system' || (card.intertype === 'custom' && card.procMode === 'system') ? <TabPane tab={ |
| | | <span> |
| | | 创建凭证 |
| | | {verify.voucher && verify.voucher.enabled ? <span className="count-tip">1</span> : null} |
| | |
| | | voucherChange={this.voucherChange} |
| | | wrappedComponentRef={(inst) => this.voucherForm = inst} |
| | | /> |
| | | </TabPane> |
| | | <TabPane tab={ |
| | | </TabPane> : null} |
| | | {card.intertype === 'system' || (card.intertype === 'custom' && card.procMode === 'system') ? <TabPane tab={ |
| | | <span> |
| | | 自定义脚本 |
| | | {verify.scripts.length ? <span className="count-tip">{verify.scripts.length}</span> : null} |
| | |
| | | wrappedComponentRef={(inst) => this.scriptsForm = inst} |
| | | /> |
| | | <EditTable actions={['move']} data={verify.scripts} columns={scriptsColumns} onChange={(scripts) => {this.setState({verify: {...verify, scripts}})}}/> |
| | | </TabPane> |
| | | </TabPane> : null} |
| | | {card.callbackType === 'script' && card.intertype === 'custom' ? <TabPane tab={ |
| | | <span> |
| | | 回调脚本 |
| | |
| | | </Row> |
| | | </Form> |
| | | </TabPane> |
| | | </Tabs> : null} |
| | | {card.intertype !== 'system' && card.intertype !== 'custom' ? <Tabs defaultActiveKey="7" className="verify-card-box"> |
| | | <TabPane tab="信息提示" key="7"> |
| | | <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"> 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 || 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 || 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"> -1 </span> |
| | | 不提示 |
| | | </Form.Item> |
| | | </Col> |
| | | </Row> |
| | | </Form> |
| | | </TabPane> |
| | | </Tabs> : null} |
| | | </Tabs> |
| | | </div> |
| | | ) |
| | | } |