| | |
| | | } |
| | | |
| | | moduleParams = null |
| | | preCallback = null |
| | | |
| | | UNSAFE_componentWillMount () { |
| | | const { btn, selectedData, BData, disabled } = this.props |
| | |
| | | } |
| | | |
| | | actionSubmit = (res) => { |
| | | const { btn, setting, BID } = this.props |
| | | const { btn } = this.props |
| | | const { selines } = this.state |
| | | |
| | | if (btn.uuid !== res.menuId) return |
| | | |
| | | let data = selines || [] |
| | | |
| | | if (setting.supModule && !BID) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '需要上级主键值!', |
| | | duration: 3 |
| | | }) |
| | | return |
| | | } else if (btn.Ot !== 'notRequired' && data.length === 0) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '请选择行!', |
| | | duration: 5 |
| | | }) |
| | | return |
| | | } else if (btn.Ot === 'requiredSgl' && data.length !== 1) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '请选择单行数据!', |
| | | duration: 5 |
| | | }) |
| | | let valid = this.checkBtnData(data) |
| | | |
| | | if (!valid) { |
| | | this.preCallback && this.preCallback() |
| | | return |
| | | } |
| | | |
| | |
| | | |
| | | this.execSubmit(data, () => {}, res.form) |
| | | } |
| | | |
| | | /** |
| | | * @description 按钮状态改变 |
| | | */ |
| | | updateStatus = () => { |
| | | this.setState({ |
| | | loading: false, |
| | | visible: false, |
| | | confirmLoading: false |
| | | }) |
| | | } |
| | | |
| | | /** |
| | | * @description 触发按钮操作 |
| | | */ |
| | | actionTrigger = (triggerId, record, type) => { |
| | | const { BID, btn, selectedData, setting } = this.props |
| | | actionTrigger = (triggerId, record, type, callback) => { |
| | | const { btn, selectedData } = this.props |
| | | const { loading, disabled } = this.state |
| | | |
| | | if (type === 'preButton') { |
| | | if (btn.uuid !== triggerId) return |
| | | |
| | | this.preTrigger(callback) |
| | | return |
| | | } else { |
| | | this.preCallback = null |
| | | } |
| | | |
| | | if (loading || disabled) return |
| | | if (triggerId && btn.uuid !== triggerId) return |
| | | |
| | | if (setting.supModule && !BID) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '需要上级主键值!', |
| | | duration: 5 |
| | | }) |
| | | return |
| | | } else if (type === 'linkbtn' && !btn.$toolbtn && !is(fromJS(selectedData || []), fromJS(record))) { |
| | | return |
| | | } |
| | | if (type === 'linkbtn' && !btn.$toolbtn && !is(fromJS(selectedData || []), fromJS(record))) return |
| | | if (btn.OpenType === 'form' && btn.formType === 'count_line') return |
| | | |
| | | this.setState({autoMatic: type === 'autoMatic'}) |
| | | |
| | | let _this = this |
| | | let data = record || selectedData || [] |
| | | |
| | | if (btn.Ot !== 'notRequired' && data.length === 0) { |
| | | // 需要选择行时,校验数据 |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '请选择行!', |
| | | duration: 5 |
| | | }) |
| | | return |
| | | } else if (btn.Ot === 'requiredSgl' && data.length !== 1) { |
| | | // 需要选择单行时,校验数据 |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '请选择单行数据!', |
| | | duration: 5 |
| | | }) |
| | | return |
| | | } else if (btn.intertype === 'system') { |
| | | // 使用内部接口时,操作类型和数据源不可为空 |
| | | if (!btn.sql || !btn.sqlType) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '按钮操作类型错误!', |
| | | duration: 5 |
| | | }) |
| | | return |
| | | } else if (data.length === 0 && btn.verify && btn.verify.voucher && btn.verify.voucher.enabled) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '使用创建凭证函数,需要选择行!', |
| | | duration: 5 |
| | | }) |
| | | return |
| | | } |
| | | } else if (btn.intertype === 'inner') { |
| | | // 使用内部接口时,内部函数不可为空 |
| | | if (!btn.innerFunc) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '按钮内部函数不可为空!', |
| | | duration: 5 |
| | | }) |
| | | return |
| | | } |
| | | } else if (btn.intertype === 'custom' || btn.intertype === 'outer') { |
| | | if (btn.callbackType === 'script' && (!btn.verify || !btn.verify.cbScripts || !btn.verify.cbScripts.filter(item => item.status !== 'false').length === 0)) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '使用自定义脚本回调时,回调脚本不可为空!', |
| | | duration: 5 |
| | | }) |
| | | return |
| | | } 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 (btn.intertype === 'custom' && window.GLOB.systemType === 'production' && !btn.proInterface) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '尚未设置正式系统接口地址!', |
| | | duration: 5 |
| | | }) |
| | | return |
| | | } |
| | | } else if (!['inner', 'outer', 'system', 'custom'].includes(btn.intertype)) { |
| | | if (btn.OpenType === 'form' && btn.formType === 'count_line') { |
| | | return |
| | | } |
| | | // 接口类型错误 |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '按钮接口类型错误!', |
| | | duration: 5 |
| | | }) |
| | | return |
| | | } |
| | | let valid = this.checkBtnData(data) |
| | | |
| | | if (!valid) return |
| | | |
| | | this.setState({ |
| | | selines: data |
| | |
| | | this.setState({}, () => { |
| | | MKEmitter.emit('mkFormSubmit', btn.uuid) |
| | | }) |
| | | return |
| | | } else if (btn.OpenType === 'prompt') { |
| | | this.setState({loading: true}) |
| | | confirm({ |
| | |
| | | let _change = { |
| | | prompt: '提示框', |
| | | exec: '直接执行', |
| | | pop: '弹窗(表单)' |
| | | pop: '弹窗(表单)', |
| | | formSubmit: '表单', |
| | | form: '表单', |
| | | } |
| | | MKEmitter.emit('queryTrigger', {menuId: btn.uuid, name: _change[btn.OpenType]}) |
| | | } |
| | | } |
| | | |
| | | preTrigger = (callback) => { |
| | | const { btn, selectedData } = this.props |
| | | const { loading, disabled } = this.state |
| | | |
| | | if (loading || disabled) { |
| | | callback() |
| | | return |
| | | } else if (btn.OpenType === 'form') { |
| | | callback() |
| | | return |
| | | } |
| | | |
| | | let _this = this |
| | | let data = selectedData || [] |
| | | |
| | | let valid = this.checkBtnData(data) |
| | | |
| | | if (!valid) { |
| | | callback() |
| | | return |
| | | } |
| | | |
| | | this.preCallback = callback |
| | | |
| | | this.setState({ |
| | | selines: data |
| | | }) |
| | | |
| | | if (btn.OpenType === 'formSubmit') { |
| | | this.setState({}, () => { |
| | | MKEmitter.emit('mkFormSubmit', btn.uuid, callback) |
| | | }) |
| | | } else if (btn.OpenType === 'prompt') { |
| | | this.setState({loading: true}) |
| | | confirm({ |
| | | title: btn.tipTitle || '确定要执行吗?', |
| | | onOk() { |
| | | return new Promise(resolve => { |
| | | _this.execSubmit(data, resolve) |
| | | }) |
| | | }, |
| | | onCancel() { |
| | | callback() |
| | | _this.setState({loading: false}) |
| | | } |
| | | }) |
| | | } else if (btn.OpenType === 'exec') { |
| | | this.setState({loading: true}) |
| | | this.execSubmit(data, () => { this.setState({loading: false})}) |
| | | } else if (btn.OpenType === 'pop') { |
| | | let modal = this.state.btnconfig |
| | | if (!modal && btn.modal) { |
| | | modal = this.handleModelConfig(btn.modal) |
| | | } |
| | | |
| | | this.setState({ |
| | | loading: true, |
| | | btnconfig: modal |
| | | }) |
| | | |
| | | if (modal) { |
| | | if (modal.setting.display === 'prompt' || modal.setting.display === 'exec') { |
| | | this.modelconfirm() |
| | | } else { |
| | | this.setState({ |
| | | visible: true |
| | | }) |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * @description 按钮状态改变 |
| | | */ |
| | | updateStatus = () => { |
| | | this.setState({ |
| | | loading: false, |
| | | visible: false, |
| | | confirmLoading: false |
| | | }) |
| | | } |
| | | |
| | | checkBtnData = (data) => { |
| | | const { BID, btn, setting } = this.props |
| | | |
| | | if (setting.supModule && !BID) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '需要上级主键值!', |
| | | duration: 5 |
| | | }) |
| | | return false |
| | | } else if (btn.Ot !== 'notRequired' && data.length === 0) { |
| | | // 需要选择行时,校验数据 |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '请选择行!', |
| | | duration: 5 |
| | | }) |
| | | return false |
| | | } else if (btn.Ot === 'requiredSgl' && data.length !== 1) { |
| | | // 需要选择单行时,校验数据 |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '请选择单行数据!', |
| | | duration: 5 |
| | | }) |
| | | return false |
| | | } else if (btn.intertype === 'system') { |
| | | if (data.length === 0 && btn.verify && btn.verify.voucher && btn.verify.voucher.enabled) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '使用创建凭证函数,需要选择行!', |
| | | duration: 5 |
| | | }) |
| | | return false |
| | | } |
| | | } else if (btn.intertype === 'custom' || btn.intertype === 'outer') { |
| | | if (btn.callbackType === 'script' && (!btn.verify || !btn.verify.cbScripts || !btn.verify.cbScripts.filter(item => item.status !== 'false').length === 0)) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '使用自定义脚本回调时,回调脚本不可为空!', |
| | | duration: 5 |
| | | }) |
| | | return false |
| | | } 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 false |
| | | } else if (btn.intertype === 'custom' && window.GLOB.systemType === 'production' && !btn.proInterface) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '尚未设置正式系统接口地址!', |
| | | duration: 5 |
| | | }) |
| | | return false |
| | | } |
| | | } |
| | | |
| | | return true |
| | | } |
| | | |
| | | getSystemParam = (data, formdata, retmsg) => { |
| | |
| | | param.ID = primaryId |
| | | |
| | | if (retmsg) { |
| | | const { sql, callbacksql } = getSysDefaultSql(btn, setting, '', param, data[0], columns, retmsg, this.moduleParams, Utils.getAllSearchOptions) // 数据源 |
| | | const { sql, callbacksql } = getSysDefaultSql(btn, setting, '', param, data[0], columns, retmsg, this.moduleParams) // 数据源 |
| | | param.LText = sql |
| | | param.$callbacksql = callbacksql |
| | | } else { |
| | | param.LText = getSysDefaultSql(btn, setting, '', param, data[0], columns, false, this.moduleParams, Utils.getAllSearchOptions) // 数据源 |
| | | param.LText = getSysDefaultSql(btn, setting, '', param, data[0], columns, false, this.moduleParams) // 数据源 |
| | | if (btn.output) { |
| | | param.key_back_type = 'Y' |
| | | } |
| | |
| | | param.ID = primaryId || Utils.getguid() |
| | | |
| | | if (retmsg) { |
| | | const { sql, callbacksql } = getSysDefaultSql(btn, setting, formdata, param, data[0], columns, retmsg, this.moduleParams, Utils.getAllSearchOptions) // 数据源 |
| | | const { sql, callbacksql } = getSysDefaultSql(btn, setting, formdata, param, data[0], columns, retmsg, this.moduleParams) // 数据源 |
| | | param.LText = sql |
| | | param.$callbacksql = callbacksql |
| | | } else { |
| | | param.LText = getSysDefaultSql(btn, setting, formdata, param, data[0], columns, false, this.moduleParams, Utils.getAllSearchOptions) // 数据源 |
| | | param.LText = getSysDefaultSql(btn, setting, formdata, param, data[0], columns, false, this.moduleParams) // 数据源 |
| | | if (btn.output) { |
| | | param.key_back_type = 'Y' |
| | | } |
| | |
| | | param.ID = primaryId |
| | | |
| | | if (retmsg) { |
| | | const { sql, callbacksql } = getSysDefaultSql(btn, setting, formdata, param, data[0], columns, retmsg, this.moduleParams, Utils.getAllSearchOptions) // 数据源 |
| | | const { sql, callbacksql } = getSysDefaultSql(btn, setting, formdata, param, data[0], columns, retmsg, this.moduleParams) // 数据源 |
| | | param.LText = sql |
| | | param.$callbacksql = callbacksql |
| | | } else { |
| | | param.LText = getSysDefaultSql(btn, setting, formdata, param, data[0], columns, false, this.moduleParams, Utils.getAllSearchOptions) // 数据源 |
| | | param.LText = getSysDefaultSql(btn, setting, formdata, param, data[0], columns, false, this.moduleParams) // 数据源 |
| | | if (btn.output) { |
| | | param.key_back_type = 'Y' |
| | | } |
| | |
| | | param.ID = primaryId |
| | | |
| | | if (retmsg) { |
| | | const { sql, callbacksql } = getSysDefaultSql(btn, setting, '', param, cell, columns, retmsg, this.moduleParams, Utils.getAllSearchOptions) // 数据源 |
| | | const { sql, callbacksql } = getSysDefaultSql(btn, setting, '', param, cell, columns, retmsg, this.moduleParams) // 数据源 |
| | | param.LText = sql |
| | | param.$callbacksql = callbacksql |
| | | } else { |
| | | param.LText = getSysDefaultSql(btn, setting, '', param, cell, columns, false, this.moduleParams, Utils.getAllSearchOptions) // 数据源 |
| | | param.LText = getSysDefaultSql(btn, setting, '', param, cell, columns, false, this.moduleParams) // 数据源 |
| | | if (btn.output) { |
| | | param.key_back_type = 'Y' |
| | | } |
| | |
| | | param.ID = Utils.getguid() |
| | | |
| | | if (retmsg) { |
| | | const { sql, callbacksql } = getSysDefaultSql(btn, setting, formdata, param, cell, columns, retmsg, this.moduleParams, Utils.getAllSearchOptions) // 数据源 |
| | | const { sql, callbacksql } = getSysDefaultSql(btn, setting, formdata, param, cell, columns, retmsg, this.moduleParams) // 数据源 |
| | | param.LText = sql |
| | | param.$callbacksql = callbacksql |
| | | } else { |
| | | param.LText = getSysDefaultSql(btn, setting, formdata, param, cell, columns, false, this.moduleParams, Utils.getAllSearchOptions) // 数据源 |
| | | param.LText = getSysDefaultSql(btn, setting, formdata, param, cell, columns, false, this.moduleParams) // 数据源 |
| | | if (btn.output) { |
| | | param.key_back_type = 'Y' |
| | | } |
| | |
| | | param.ID = primaryId |
| | | |
| | | if (retmsg) { |
| | | const { sql, callbacksql } = getSysDefaultSql(btn, setting, formdata, param, cell, columns, retmsg, this.moduleParams, Utils.getAllSearchOptions) // 数据源 |
| | | const { sql, callbacksql } = getSysDefaultSql(btn, setting, formdata, param, cell, columns, retmsg, this.moduleParams) // 数据源 |
| | | param.LText = sql |
| | | param.$callbacksql = callbacksql |
| | | } else { |
| | | param.LText = getSysDefaultSql(btn, setting, formdata, param, cell, columns, false, this.moduleParams, Utils.getAllSearchOptions) // 数据源 |
| | | param.LText = getSysDefaultSql(btn, setting, formdata, param, cell, columns, false, this.moduleParams) // 数据源 |
| | | if (btn.output) { |
| | | param.key_back_type = 'Y' |
| | | } |
| | |
| | | /** |
| | | * @description 按钮提交执行 |
| | | */ |
| | | execSubmit = (data, _resolve, formdata) => { |
| | | execSubmit = (data, _resolve, formdata, force) => { |
| | | const { setting, btn } = this.props |
| | | this.moduleParams = null |
| | | |
| | | if ( |
| | | (btn.intertype === 'system' || (btn.intertype === 'custom' && btn.procMode === 'system')) && |
| | | btn.sqlType !== 'insert' && btn.Ot !== 'notRequired' && btn.verify && btn.verify.invalid === 'true' && |
| | | setting.dataresource |
| | | ) { |
| | | if (btn.preButton && !force) { |
| | | this.trigger(btn.preButton, data, _resolve, formdata, 0) |
| | | } else if (btn.verify && btn.verify.invalid === 'true' && setting.dataresource) { |
| | | MKEmitter.emit('queryModuleParam', btn.$menuId, (param) => { |
| | | this.moduleParams = param |
| | | let datasource = setting.dataresource |
| | | let customScript = setting.customScript || '' |
| | | let allSearch = Utils.getAllSearchOptions(param.search) |
| | | |
| | | let regoptions = allSearch.map(item => { |
| | | return { |
| | | reg: new RegExp('@' + item.key + '@', 'ig'), |
| | | value: `'${item.value}'` |
| | | } |
| | | }) |
| | | |
| | | regoptions.push({ |
| | | reg: new RegExp('@userName@', 'ig'), |
| | | value: `'${sessionStorage.getItem('User_Name') || ''}'` |
| | | }, { |
| | | reg: new RegExp('@fullName@', 'ig'), |
| | | value: `'${sessionStorage.getItem('Full_Name') || ''}'` |
| | | }, { |
| | | reg: new RegExp('@orderBy@', 'ig'), |
| | | value: setting.order |
| | | }, { |
| | | reg: new RegExp('@pageSize@', 'ig'), |
| | | value: 10 |
| | | }, { |
| | | reg: new RegExp('@pageIndex@', 'ig'), |
| | | value: 1 |
| | | }) |
| | | |
| | | regoptions.forEach(item => { |
| | | datasource = datasource.replace(item.reg, item.value) |
| | | customScript = customScript.replace(item.reg, item.value) |
| | | }) |
| | | |
| | | this.moduleParams = { |
| | | datasource, |
| | | customScript |
| | | } |
| | | |
| | | this.execRealSubmit(data, _resolve, formdata) |
| | | }) |
| | | } else { |
| | | this.execRealSubmit(data, _resolve, formdata) |
| | | } |
| | | } |
| | | |
| | | trigger = (btnId, data, resolve, formdata, times) => { |
| | | if (times > 50) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '前置按钮加载失败!', |
| | | duration: 5 |
| | | }) |
| | | this.setState({loading: false}) |
| | | resolve() |
| | | return |
| | | } |
| | | times++ |
| | | |
| | | let node = document.getElementById('button' + btnId) |
| | | |
| | | if (node) { |
| | | MKEmitter.emit('triggerBtnId', btnId, null, 'preButton', (res) => { |
| | | if (!res) { |
| | | this.setState({loading: false}) |
| | | resolve() |
| | | return |
| | | } |
| | | |
| | | if (res.status) { |
| | | this.execSubmit(data, resolve, formdata, true) |
| | | } else { |
| | | this.execError(res) |
| | | } |
| | | }) |
| | | } else { |
| | | setTimeout(() => { |
| | | this.trigger(btnId, data, resolve, formdata, times) |
| | | }, 100) |
| | | } |
| | | } |
| | | |
| | |
| | | const { btn } = this.props |
| | | const { autoMatic } = this.state |
| | | |
| | | if (autoMatic) { |
| | | if (this.preCallback) { |
| | | this.setState({ |
| | | loading: false, |
| | | visible: false |
| | | }) |
| | | this.preCallback(res) |
| | | return |
| | | } else if (autoMatic) { |
| | | this.setState({ |
| | | loading: false, |
| | | visible: false |
| | |
| | | const { btn } = this.props |
| | | const { autoMatic } = this.state |
| | | |
| | | if (autoMatic) { |
| | | if (this.preCallback) { |
| | | this.setState({ |
| | | loading: false, |
| | | visible: false |
| | | }) |
| | | this.preCallback(res) |
| | | return |
| | | } else if (autoMatic) { |
| | | notification.error({ |
| | | top: 92, |
| | | message: res.message || '执行失败!', |
| | |
| | | visible: false, |
| | | confirmLoading: false |
| | | }) |
| | | |
| | | this.preCallback && this.preCallback() |
| | | } |
| | | |
| | | modelconfirm = () => { |
| | |
| | | }) |
| | | }, |
| | | onCancel() { |
| | | _this.preCallback && _this.preCallback() |
| | | _this.setState({ loading: false }) |
| | | } |
| | | }) |