| | |
| | | |
| | | import Api from '@/api' |
| | | import Utils from '@/utils/utils.js' |
| | | import options from '@/store/options.js' |
| | | import zhCN from '@/locales/zh-CN/main.js' |
| | | import enUS from '@/locales/en-US/main.js' |
| | | import asyncSpinComponent from '@/utils/asyncSpinComponent' |
| | | import { updateForm } from '@/utils/utils-update.js' |
| | | import MKEmitter from '@/utils/events.js' |
| | |
| | | } |
| | | |
| | | state = { |
| | | dict: sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS, |
| | | visible: false, |
| | | formdata: null, |
| | | selines: null, |
| | |
| | | } |
| | | |
| | | UNSAFE_componentWillMount () { |
| | | const { btn, selectedData, BData } = this.props |
| | | let disabled = false |
| | | const { btn, selectedData, BData, disabled } = this.props |
| | | |
| | | if (btn.control !== 'parent' && btn.controlField && selectedData && selectedData.length > 0) { // 表格中按钮隐藏控制 |
| | | selectedData.forEach(item => { |
| | | let s = item[btn.controlField] !== undefined ? item[btn.controlField] + '' : '' |
| | | if (s === btn.controlVal || (btn.controlVal && btn.controlVal.split(',').includes(s))) { |
| | | disabled = true |
| | | } |
| | | }) |
| | | this.setState({hidden: disabled && btn.control === 'hidden'}) |
| | | } else if (btn.control === 'parent') { |
| | | if (!BData || !BData.hasOwnProperty(btn.controlField)) { |
| | | this.setState({hidden: true}) |
| | | } else { |
| | | let s = BData[btn.controlField] + '' |
| | | if (s === btn.controlVal || (btn.controlVal && btn.controlVal.split(',').includes(s))) { |
| | | this.setState({hidden: true}) |
| | | } else { |
| | | this.setState({hidden: false}) |
| | | } |
| | | } |
| | | } |
| | | |
| | | if (this.props.disabled || disabled) { |
| | | if (btn.controlField) { |
| | | this.setStatus(btn, selectedData || [], BData, disabled) |
| | | } else if (disabled) { |
| | | this.setState({disabled: true}) |
| | | } |
| | | } |
| | |
| | | } |
| | | |
| | | UNSAFE_componentWillReceiveProps (nextProps) { |
| | | const { btn, selectedData, BData } = this.props |
| | | const { btn } = this.props |
| | | |
| | | let disabled = false |
| | | if (btn.control !== 'parent' && btn.controlField && !is(fromJS(nextProps.selectedData || []), fromJS(selectedData || []))) { |
| | | if (nextProps.selectedData && nextProps.selectedData.length > 0) { // 表格中按钮隐藏控制 |
| | | nextProps.selectedData.forEach(item => { |
| | | let s = item[btn.controlField] !== undefined ? item[btn.controlField] + '' : '' |
| | | if (s === btn.controlVal || (btn.controlVal && btn.controlVal.split(',').includes(s))) { |
| | | disabled = true |
| | | } |
| | | }) |
| | | } |
| | | this.setState({disabled, hidden: disabled && btn.control === 'hidden'}) |
| | | } else if (btn.control === 'parent' && !is(fromJS(nextProps.BData || {}), fromJS(BData || {}))) { |
| | | if (!nextProps.BData || !nextProps.BData.hasOwnProperty(btn.controlField)) { |
| | | this.setState({hidden: true}) |
| | | } else { |
| | | let s = nextProps.BData[btn.controlField] + '' |
| | | if (s === btn.controlVal || (btn.controlVal && btn.controlVal.split(',').includes(s))) { |
| | | this.setState({hidden: true}) |
| | | } else { |
| | | this.setState({hidden: false}) |
| | | } |
| | | } |
| | | } |
| | | |
| | | if (nextProps.disabled || disabled) { |
| | | this.setState({disabled: true}) |
| | | if (btn.controlField) { |
| | | this.setStatus(btn, nextProps.selectedData || [], nextProps.BData, nextProps.disabled) |
| | | } else { |
| | | this.setState({disabled: false}) |
| | | this.setState({disabled: nextProps.disabled === true}) |
| | | } |
| | | } |
| | | |
| | |
| | | } |
| | | MKEmitter.removeListener('triggerBtnId', this.actionTrigger) |
| | | MKEmitter.removeListener('triggerBtnPopSubmit', this.triggerBtnPopSubmit) |
| | | } |
| | | |
| | | setStatus = (btn, data, BData, disprop) => { |
| | | let disabled = false |
| | | let hidden = false |
| | | |
| | | if (btn.control !== 'parent') { |
| | | if (data.length > 0) { |
| | | data.forEach(item => { |
| | | let s = item[btn.controlField] !== undefined ? item[btn.controlField] + '' : '' |
| | | if (btn.controlVals.includes(s) || item.$lock) { |
| | | disabled = true |
| | | } |
| | | }) |
| | | } else if (btn.controlVals.includes('')) { |
| | | disabled = true |
| | | } |
| | | } else { |
| | | if (!BData || !BData.hasOwnProperty(btn.controlField)) { |
| | | hidden = true |
| | | } else { |
| | | let s = BData[btn.controlField] + '' |
| | | if (btn.controlVals.includes(s)) { |
| | | hidden = true |
| | | } |
| | | } |
| | | } |
| | | |
| | | if (disabled && btn.control === 'hidden') { |
| | | hidden = true |
| | | } |
| | | |
| | | if (disprop) { |
| | | disabled = true |
| | | } |
| | | |
| | | this.setState({hidden, disabled}) |
| | | } |
| | | |
| | | triggerBtnPopSubmit = (id) => { |
| | |
| | | // 需要选择行时,校验数据 |
| | | notification.warning({ |
| | | top: 92, |
| | | message: this.state.dict['main.action.confirm.selectline'], |
| | | message: '请选择行!', |
| | | duration: 5 |
| | | }) |
| | | return |
| | |
| | | // 需要选择单行时,校验数据 |
| | | notification.warning({ |
| | | top: 92, |
| | | message: this.state.dict['main.action.confirm.selectSingleLine'], |
| | | message: '请选择单行数据!', |
| | | duration: 5 |
| | | }) |
| | | return |
| | | } else if (!['requiredSgl', 'notRequired', 'requiredOnce', 'required'].includes(btn.Ot)) { |
| | | // 数据选择类型校验 |
| | | this.actionSettingError() |
| | | return |
| | | } else if (!btn.verify || !btn.verify.printMode) { |
| | | notification.warning({ |
| | |
| | | } else if (btn.execMode === 'prompt') { |
| | | this.setState({ loading: true }) |
| | | confirm({ |
| | | title: this.state.dict['main.action.confirm.tip'], |
| | | title: '确定要执行吗?', |
| | | onOk() { |
| | | _this.triggerPrint(data) |
| | | }, |
| | |
| | | errorMsg = { |
| | | ErrCode: 'N', |
| | | message: _temp.error, |
| | | ErrMesg: _temp.error, |
| | | status: false |
| | | } |
| | | } else { |
| | |
| | | |
| | | return Api.getSystemCacheConfig(param) |
| | | }).then(result => { |
| | | if (!result) { |
| | | if (!result || result.ErrCode === 'LoginError') { |
| | | this.setState({ loading: false }) |
| | | return |
| | | } |
| | |
| | | this.execSuccess({ |
| | | ErrCode: '-1', |
| | | message: '', |
| | | ErrMesg: '', |
| | | status: true |
| | | }) |
| | | |
| | |
| | | if (btn.intertype === 'inner') { |
| | | params = params.map(_param => { |
| | | _param.func = btn.innerFunc |
| | | |
| | | if (btn.recordUser === 'true') { |
| | | _param.username = sessionStorage.getItem('User_Name') || '' |
| | | _param.fullname = sessionStorage.getItem('Full_Name') || '' |
| | | } |
| | | |
| | | return _param |
| | | }) |
| | |
| | | |
| | | let _dataresource = btn.verify.setting.dataresource |
| | | let _customScript = '' |
| | | |
| | | let _tailScript = '' |
| | | btn.verify.scripts && btn.verify.scripts.forEach(script => { |
| | | if (script.status !== 'false') { |
| | | if (script.status === 'false') return |
| | | if (script.position !== 'back') { |
| | | _customScript += ` |
| | | ${script.sql} |
| | | ` |
| | | } else { |
| | | _tailScript += ` |
| | | ${script.sql} |
| | | ` |
| | | } |
| | |
| | | _dataresource = '' |
| | | } |
| | | |
| | | let isDataM = sessionStorage.getItem('dataM') === 'true' |
| | | let regoptions = [ |
| | | { reg: /@ID@/ig, value: `'${ID}'`}, |
| | | { reg: /@BID@/ig, value: `'${BID || ''}'`}, |
| | | { reg: /@LoginUID@/ig, value: `'${sessionStorage.getItem('LoginUID') || ''}'`}, |
| | | { reg: /@SessionUid@/ig, value: `'${localStorage.getItem('SessionUid') || ''}'`}, |
| | | { reg: /@UserID@/ig, value: `'${sessionStorage.getItem('UserID') || ''}'`}, |
| | | { reg: /@Appkey@/ig, value: `'${window.GLOB.appkey || ''}'`}, |
| | | { reg: /@typename@/ig, value: `'admin'`}, |
| | | { reg: /\$@/ig, value: isDataM ? '/*' : ''}, |
| | | { reg: /@\$/ig, value: isDataM ? '*/' : ''}, |
| | | { reg: /@datam@/ig, value: isDataM ? `'Y'` : `''`}, |
| | | ] |
| | | |
| | | regoptions.forEach(item => { |
| | | _dataresource = _dataresource.replace(item.reg, item.value) |
| | | _customScript = _customScript.replace(item.reg, item.value) |
| | | _tailScript = _tailScript.replace(item.reg, item.value) |
| | | }) |
| | | |
| | | if (/\s/.test(_dataresource)) { |
| | | _dataresource = '(' + _dataresource + ') tb' |
| | | } |
| | | |
| | | if (sessionStorage.getItem('dataM') === 'true') { // 数据权限 |
| | | _dataresource = _dataresource.replace(/\$@/ig, '/*').replace(/@datam@/ig, '\'Y\'') |
| | | _dataresource = _dataresource.replace(/@\$/ig, '*/') |
| | | _customScript = _customScript.replace(/\$@/ig, '/*').replace(/@datam@/ig, '\'Y\'') |
| | | _customScript = _customScript.replace(/@\$/ig, '*/') |
| | | } else { |
| | | _dataresource = _dataresource.replace(/@\$|\$@/ig, '').replace(/@datam@/ig, '\'\'') |
| | | _customScript = _customScript.replace(/@\$|\$@/ig, '').replace(/@datam@/ig, '\'\'') |
| | | } |
| | | |
| | | let initsql = `declare @ErrorCode nvarchar(50),@retmsg nvarchar(4000),@UserName nvarchar(50),@FullName nvarchar(50),@RoleID nvarchar(512),@mk_departmentcode nvarchar(512),@mk_organization nvarchar(512),@mk_user_type nvarchar(20),@mk_nation nvarchar(50),@mk_province nvarchar(50),@mk_city nvarchar(50),@mk_district nvarchar(50),@mk_address nvarchar(100) |
| | |
| | | _initvars.push(`@${_key}='${form.value}'`) |
| | | } |
| | | |
| | | if (form.fieldlen && form.fieldlen > 2048) { |
| | | if (form.fieldlen && form.fieldlen > 4000) { |
| | | form.fieldlen = 'max' |
| | | } |
| | | |
| | |
| | | select ${_initvars.join(',')} |
| | | ` |
| | | } |
| | | |
| | | |
| | | if (_customScript) { |
| | | _customScript = `${initsql} |
| | | ${_customScript} |
| | | ` |
| | | } |
| | | |
| | | _dataresource = _dataresource.replace(/@select\$|\$select@/ig, '') |
| | | _customScript = _customScript.replace(/@select\$|\$select@/ig, '') |
| | | _dataresource = _dataresource.replace(/\$sum@/ig, '/*') |
| | | _dataresource = _dataresource.replace(/@sum\$/ig, '*/') |
| | | _customScript = _customScript.replace(/\$sum@/ig, '/*') |
| | | _customScript = _customScript.replace(/@sum\$/ig, '*/') |
| | | |
| | | _dataresource = _dataresource.replace(/@ID@/ig, `'${ID}'`) |
| | | _customScript = _customScript.replace(/@ID@/ig, `'${ID}'`) |
| | | _dataresource = _dataresource.replace(/@BID@/ig, `'${BID || ''}'`) |
| | | _customScript = _customScript.replace(/@BID@/ig, `'${BID || ''}'`) |
| | | _dataresource = _dataresource.replace(/@LoginUID@/ig, `'${sessionStorage.getItem('LoginUID') || ''}'`) |
| | | _customScript = _customScript.replace(/@LoginUID@/ig, `'${sessionStorage.getItem('LoginUID') || ''}'`) |
| | | _dataresource = _dataresource.replace(/@SessionUid@/ig, `'${localStorage.getItem('SessionUid') || ''}'`) |
| | | _customScript = _customScript.replace(/@SessionUid@/ig, `'${localStorage.getItem('SessionUid') || ''}'`) |
| | | _dataresource = _dataresource.replace(/@UserID@/ig, `'${sessionStorage.getItem('UserID') || ''}'`) |
| | | _customScript = _customScript.replace(/@UserID@/ig, `'${sessionStorage.getItem('UserID') || ''}'`) |
| | | _dataresource = _dataresource.replace(/@Appkey@/ig, `'${window.GLOB.appkey || ''}'`) |
| | | _customScript = _customScript.replace(/@Appkey@/ig, `'${window.GLOB.appkey || ''}'`) |
| | | |
| | | |
| | | let LText = '' |
| | | |
| | |
| | | if (_customScript) { |
| | | if (LText) { |
| | | LText = `${LText} |
| | | ${_tailScript} |
| | | aaa: |
| | | if @ErrorCode!='' |
| | | insert into tmp_err_retmsg (ID, ErrorCode, retmsg, CreateUserID) select @time_id@,@ErrorCode, @retmsg,@UserID@ |
| | | insert into tmp_err_retmsg (ID, ErrorCode, retmsg, CreateUserID) select @time_id@,@ErrorCode, @retmsg,'${sessionStorage.getItem('UserID') || ''}' |
| | | ` |
| | | } else { |
| | | _customScript = `${_customScript} |
| | | ${_tailScript} |
| | | aaa: |
| | | if @ErrorCode!='' |
| | | insert into tmp_err_retmsg (ID, ErrorCode, retmsg, CreateUserID) select @time_id@,@ErrorCode, @retmsg,@UserID@ |
| | | insert into tmp_err_retmsg (ID, ErrorCode, retmsg, CreateUserID) select @time_id@,@ErrorCode, @retmsg,'${sessionStorage.getItem('UserID') || ''}' |
| | | ` |
| | | } |
| | | } else if (_tailScript) { |
| | | LText = `${initsql} |
| | | ${LText} |
| | | ${_tailScript} |
| | | aaa: |
| | | if @ErrorCode!='' |
| | | insert into tmp_err_retmsg (ID, ErrorCode, retmsg, CreateUserID) select @time_id@,@ErrorCode, @retmsg,'${sessionStorage.getItem('UserID') || ''}' |
| | | ` |
| | | } else { |
| | | LText = `${initsql} |
| | | ${LText} |
| | |
| | | } |
| | | |
| | | // 测试系统打印查询语句 |
| | | if (window.GLOB.debugger === true || (window.debugger === true && options.sysType !== 'cloud')) { |
| | | if (window.GLOB.debugger === true) { |
| | | _customScript && console.info(`${btn.logLabel ? `/*${btn.logLabel} 自定义脚本*/\n` : ''}${LText ? '' : '/*不执行默认sql*/\n'}${_customScript}`) |
| | | LText && console.info(`${btn.logLabel ? `/*${btn.logLabel} 数据源*/\n` : ''}` + LText.replace(/\n\s{8}/ig, '\n')) |
| | | } |
| | |
| | | param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') |
| | | param.secretkey = Utils.encrypt('', param.timestamp) |
| | | |
| | | param.username = userName |
| | | param.fullname = fullName |
| | | |
| | | if (window.GLOB.probation) { |
| | | param.s_debug_type = 'Y' |
| | | } |
| | |
| | | printOuterLoopRequest = (params, btn, _list, _resolve) => { |
| | | let param = params.shift() |
| | | let _outParam = null |
| | | let ver_token = false |
| | | |
| | | new Promise(resolve => { |
| | | // 内部请求 |
| | |
| | | // 外部请求 |
| | | _outParam = JSON.parse(JSON.stringify(res)) |
| | | |
| | | if (window.GLOB.mkHS) { |
| | | if (btn.sysInterface === 'true' && options.cloudServiceApi) { |
| | | res.rduri = options.cloudServiceApi |
| | | res.userid = sessionStorage.getItem('CloudUserID') || '' |
| | | res.LoginUID = sessionStorage.getItem('CloudLoginUID') || '' |
| | | } else if (btn.sysInterface !== 'true') { |
| | | if (window.GLOB.systemType === 'production' && btn.proInterface) { |
| | | res.rduri = btn.proInterface |
| | | } else { |
| | | res.rduri = btn.interface |
| | | } |
| | | if (btn.sysInterface === 'true') { |
| | | if (window.GLOB.mainSystemApi) { |
| | | res.rduri = window.GLOB.mainSystemApi |
| | | } |
| | | } else { |
| | | if (btn.sysInterface === 'true') { |
| | | if (window.GLOB.mainSystemApi) { |
| | | res.rduri = window.GLOB.mainSystemApi |
| | | } |
| | | } else if (btn.sysInterface === 'external') { |
| | | if (window.GLOB.systemType === 'production') { |
| | | res.$token = btn.exProInterface || '' |
| | | } else { |
| | | res.$token = btn.exInterface || '' |
| | | } |
| | | } else if (btn.sysInterface === 'external') { |
| | | if (window.GLOB.systemType === 'production') { |
| | | res.$token = btn.exProInterface || '' |
| | | } else { |
| | | if (window.GLOB.systemType === 'production' && btn.proInterface) { |
| | | res.rduri = btn.proInterface |
| | | } else { |
| | | res.rduri = btn.interface |
| | | } |
| | | res.$token = btn.exInterface || '' |
| | | } |
| | | ver_token = true |
| | | } else { |
| | | if (window.GLOB.systemType === 'production' && btn.proInterface) { |
| | | res.rduri = btn.proInterface |
| | | } else { |
| | | res.rduri = btn.interface |
| | | } |
| | | |
| | | let host = window.GLOB.baseurl.replace(/http(s):\/\//, '') |
| | | if (res.rduri.indexOf(host) === -1 && /\/dostars/.test(res.rduri)) { |
| | | res.$login = true |
| | | } |
| | | let host = window.GLOB.baseurl.replace(/http(s):\/\//, '') |
| | | if (res.rduri.indexOf(host) === -1 && /\/dostars/.test(res.rduri)) { |
| | | res.$login = true |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | return Api.genericInterface(res) |
| | | }).then(response => { |
| | | if (!response) return |
| | | if (!response || response.ErrCode === 'LoginError') return |
| | | |
| | | if (btn.callbackFunc) { |
| | | if (ver_token && response.ErrCode === 'token_error') { |
| | | response.ErrCode = 'E' |
| | | this.execError(response) |
| | | _resolve({next: false, list: []}) |
| | | } else if (btn.callbackFunc) { |
| | | // 存在回调函数时,调用 |
| | | delete response.message |
| | | delete response.status |
| | |
| | | _resolve({next: false, list: []}) |
| | | } |
| | | }).then(response => { |
| | | if (!response) return |
| | | if (!response || response.ErrCode === 'LoginError') return |
| | | |
| | | if (response.status) { |
| | | _list.push(response) |
| | |
| | | Api.postekPrint(param).then(res => { |
| | | if (res.retval === '0') { |
| | | if (params.length === 0) { |
| | | this.execSuccess({ ErrCode: 'S', message: '', ErrMesg: '打印请求已发出。', status: true }) |
| | | this.execSuccess({ ErrCode: 'S', message: '打印请求已发出。', status: true }) |
| | | } else { |
| | | setTimeout(() => { |
| | | this.loopRFIDPrint(params) |
| | |
| | | this.execSuccess({ |
| | | ErrCode: '-1', |
| | | message: '未获取到打印信息!', |
| | | ErrMesg: '', |
| | | status: true |
| | | }) |
| | | } else { |
| | | this.execError({ |
| | | ErrCode: 'N', |
| | | message: '未获取到打印信息!', |
| | | ErrMesg: '', |
| | | status: false |
| | | }) |
| | | } |
| | |
| | | this.execError({ |
| | | ErrCode: 'N', |
| | | message: msg.join(' ; ') + ' !', |
| | | ErrMesg: '', |
| | | status: false |
| | | }) |
| | | return |
| | |
| | | |
| | | this.execSuccess({ |
| | | ErrCode: 'S', |
| | | message: '', |
| | | ErrMesg: '打印请求已发出。', |
| | | message: '打印请求已发出。', |
| | | status: true |
| | | }) |
| | | } |
| | |
| | | |
| | | this.execSuccess({ |
| | | ErrCode: 'S', |
| | | message: '', |
| | | ErrMesg: '打印请求已发出。', |
| | | message: '打印请求已发出。', |
| | | status: true |
| | | }) |
| | | } |
| | |
| | | this.execError({ |
| | | ErrCode: 'N', |
| | | message: event.data, |
| | | ErrMesg: '', |
| | | status: false |
| | | }) |
| | | |
| | |
| | | |
| | | // this.execSuccess({ |
| | | // ErrCode: 'S', |
| | | // message: '', |
| | | // ErrMesg: '打印请求已发出。', |
| | | // message: '打印请求已发出。', |
| | | // status: true |
| | | // }) |
| | | // } else if (data && data.message && !data.status) { |
| | |
| | | this.execError({ |
| | | ErrCode: 'N', |
| | | message: data.message, |
| | | ErrMesg: '', |
| | | status: false |
| | | }) |
| | | } |
| | |
| | | this.execError({ |
| | | ErrCode: 'N', |
| | | message: '无法连接到:' + btn.verify.linkUrl, |
| | | ErrMesg: '', |
| | | status: false |
| | | }) |
| | | } |
| | |
| | | * 4、模态框执行成功后是否关闭 |
| | | * 5、通知主列表刷新 |
| | | */ |
| | | execSuccess = (res) => { |
| | | execSuccess = (res = {}) => { |
| | | const { btn } = this.props |
| | | const { autoMatic, btnconfig } = this.state |
| | | |
| | | if ((res.ErrCode === 'S' || !res.ErrCode) || autoMatic) { // 执行成功 |
| | | notification.success({ |
| | | top: 92, |
| | | message: res.ErrMesg || this.state.dict['main.action.confirm.success'], |
| | | message: res.message || '执行成功!', |
| | | duration: btn.verify && btn.verify.stime ? btn.verify.stime : 2 |
| | | }) |
| | | } else if (res.ErrCode === 'Y') { // 执行成功 |
| | | Modal.success({ |
| | | title: res.ErrMesg || this.state.dict['main.action.confirm.success'] |
| | | title: res.message || '执行成功!' |
| | | }) |
| | | } else if (res.ErrCode === '-1') { // 完成后不提示 |
| | | |
| | |
| | | if (btn.execSuccess !== 'never') { |
| | | MKEmitter.emit('refreshByButtonResult', btn.$menuId, btn.execSuccess, btn, '', this.state.selines) |
| | | } |
| | | |
| | | if (btn.execSuccess === 'popclose' && btn.$tabId) { // 标签关闭刷新 |
| | | MKEmitter.emit('refreshPopButton', btn.$tabId) |
| | | } |
| | | } |
| | | |
| | | /** |
| | |
| | | const { btn } = this.props |
| | | const { btnconfig, autoMatic } = this.state |
| | | |
| | | if (!['LoginError', 'C', '-2', 'E', 'N', 'F', 'NM'].includes(res.ErrCode)) { |
| | | res.ErrCode = 'E' |
| | | } |
| | | |
| | | if (res.ErrCode === 'E' && !autoMatic) { |
| | | Modal.error({ |
| | | title: res.message || res.ErrMesg, |
| | | title: res.message || '执行失败!', |
| | | }) |
| | | } else if (res.ErrCode === 'N' || autoMatic) { |
| | | notification.error({ |
| | | top: 92, |
| | | message: res.message || res.ErrMesg, |
| | | message: res.message || '执行失败!', |
| | | duration: btn.verify && btn.verify.ntime ? btn.verify.ntime : 10 |
| | | }) |
| | | } else if (res.ErrCode === 'F') { |
| | | notification.error({ |
| | | className: 'notification-custom-error', |
| | | top: 92, |
| | | message: res.message || res.ErrMesg, |
| | | message: res.message || '执行失败!', |
| | | duration: btn.verify && btn.verify.ftime ? btn.verify.ftime : 10 |
| | | }) |
| | | } else if (res.ErrCode === 'NM') { |
| | | message.error(res.message || res.ErrMesg) |
| | | message.error(res.message || '执行失败!') |
| | | } |
| | | |
| | | this.setState({ |
| | |
| | | if (btn.execError !== 'never') { |
| | | MKEmitter.emit('refreshByButtonResult', btn.$menuId, btn.execError, btn, '', this.state.selines) |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * @description 按钮配置信息错误提示 |
| | | */ |
| | | actionSettingError = () => { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: this.state.dict['main.action.settingerror'], |
| | | duration: 5 |
| | | }) |
| | | } |
| | | |
| | | handleModelConfig = (config) => { |
| | |
| | | |
| | | btnconfig.fields.forEach(item => { |
| | | if (!item.field) return |
| | | let _readin = item.readin !== 'false' |
| | | let _initval = item.initval |
| | | |
| | | if (item.type === 'linkMain' || item.type === 'funcvar') { |
| | | _readin = false |
| | | } |
| | | |
| | | if (item.type === 'linkMain' && BData.hasOwnProperty(item.field.toLowerCase())) { |
| | | _initval = BData[item.field.toLowerCase()] |
| | | } else if (_readin && _data.hasOwnProperty(item.field.toLowerCase())) { |
| | | _initval = _data[item.field.toLowerCase()] |
| | | } else if (item.type === 'date' && _initval) { |
| | | _initval = moment().subtract(_initval, 'days').format('YYYY-MM-DD') |
| | | } else if (item.type === 'datemonth' && _initval) { |
| | | _initval = moment().subtract(_initval, 'month').format('YYYY-MM') |
| | | } else if (item.type === 'datetime' && _initval) { |
| | | _initval = moment().subtract(_initval, 'days').format('YYYY-MM-DD HH:mm:ss') |
| | | } |
| | | |
| | | let _fieldlen = item.fieldlength || 50 |
| | | if (item.type === 'textarea' || item.type === 'fileupload' || item.type === 'multiselect') { |
| | | _fieldlen = item.fieldlength || 512 |
| | | } else if (item.type === 'number') { |
| | | _fieldlen = item.decimal ? item.decimal : 0 |
| | | } else if (item.type === 'rate') { |
| | | item.rateCount = item.rateCount || 5 |
| | | let allowHalf = item.allowHalf === 'true' |
| | | |
| | | if (allowHalf) { |
| | | _initval = parseFloat(_initval) |
| | | if (_initval % 0.5 !== 0) { |
| | | _initval = parseInt(_initval) |
| | | } |
| | | } else { |
| | | _initval = parseInt(_initval) |
| | | } |
| | | |
| | | if (isNaN(_initval) || _initval < 0) { |
| | | _initval = 0 |
| | | } else if (_initval > item.rateCount) { |
| | | _initval = item.rateCount |
| | | } |
| | | } |
| | | |
| | | if (_initval === undefined) { |
| | | _initval = '' |
| | | } |
| | | |
| | | result.push({ |
| | | let _item = { |
| | | key: item.field, |
| | | readonly: item.readonly === 'true', |
| | | readin: item.readin !== 'false' && item.readin !== 'top', |
| | | fieldlen: _fieldlen, |
| | | fieldlen: item.fieldlength || 50, |
| | | writein: item.writein !== 'false', |
| | | type: item.type, |
| | | value: _initval |
| | | }) |
| | | value: item.initval, |
| | | isconst: item.constant === 'true' |
| | | } |
| | | |
| | | let key = item.field.toLowerCase() |
| | | let _readin = item.readin !== 'false' |
| | | |
| | | if (_item.type === 'date') { // 时间兼容 |
| | | _item.precision = item.precision || 'day' |
| | | } else if (_item.type === 'datetime') { |
| | | _item.type = 'date' |
| | | _item.precision = 'second' |
| | | } else if (['funcvar', 'linkMain'].includes(_item.type)) { |
| | | _readin = false |
| | | _item.readin = false |
| | | } else if (['select', 'link', 'radio'].includes(_item.type)) { // 选中第一项 |
| | | if (/^\s*\$first\s*$/.test(_item.value)) { |
| | | _item.value = '' |
| | | |
| | | if (item.resourceType === '0' && item.options[0] && item.options[0].Value) { |
| | | _item.value = item.options[0].Value |
| | | } |
| | | } |
| | | } |
| | | |
| | | if (_item.type === 'funcvar') { |
| | | _item.value = '' |
| | | } else if (_item.type === 'linkMain' && BData.hasOwnProperty(key)) { |
| | | _item.value = BData[key] |
| | | } else if (_readin && _data.hasOwnProperty(key)) { |
| | | _item.value = _data[key] |
| | | } else if (_item.type === 'date' && _item.value) { |
| | | _item.value = moment().subtract(_item.value, 'days').format(_item.precision === 'day' ? 'YYYY-MM-DD' : 'YYYY-MM-DD HH:mm:ss') |
| | | } else if (_item.type === 'datemonth' && _item.value) { |
| | | _item.value = moment().subtract(_item.value, 'month').format('YYYY-MM') |
| | | } |
| | | |
| | | _item.value = _item.value === undefined ? '' : _item.value |
| | | |
| | | if (_item.type === 'number' || item.declare === 'decimal') { |
| | | _item.type = 'number' |
| | | _item.fieldlen = item.decimal || 0 |
| | | } else if (['text', 'textarea', 'linkMain'].includes(_item.type)) { |
| | | _item.value = _item.value + '' |
| | | _item.value = _item.value.replace(/\t+|\v+/g, '') // 去除制表符 |
| | | |
| | | if (item.interception !== 'false') { // 去除首尾空格 |
| | | if (item.interception === 'func') { |
| | | try { |
| | | // eslint-disable-next-line |
| | | let func = new Function('value', 'data', item.func) |
| | | _item.value = func(_item.value, _data) |
| | | _item.value = _item.value !== undefined ? _item.value : '' |
| | | } catch (e) { |
| | | console.warn(e) |
| | | _item.value = '' |
| | | } |
| | | } else { |
| | | _item.value = _item.value.replace(/(^\s*|\s*$)/g, '') |
| | | } |
| | | } |
| | | if (_item.type === 'text' && /@appkey@|@SessionUid@|@bid@/ig.test(_item.value)) { // 特殊字段替换 |
| | | _item.value = _item.value.replace(/^(\s*)@appkey@(\s*)$/ig, window.GLOB.appkey).replace(/^(\s*)@SessionUid@(\s*)$/ig, (localStorage.getItem('SessionUid') || '')).replace(/^(\s*)@bid@(\s*)$/ig, (this.props.BID || '')) |
| | | } |
| | | if (_item.type === 'text' && item.lenControl && item.lenControl !== 'limit') { |
| | | if (item.lenControl === 'left') { |
| | | _item.value = _item.value.substr(0, item.fieldlength) |
| | | } else { |
| | | _item.value = _item.value.slice(-item.fieldlength) |
| | | } |
| | | } |
| | | } else if (_item.type === 'datemonth') { |
| | | _item.type = 'text' |
| | | } else if (_item.type === 'date') { |
| | | _item.type = item.declareType === 'nvarchar(50)' ? 'text' : 'date' |
| | | } else if (_item.type === 'switch' || _item.type === 'check') { |
| | | if (_readin) { |
| | | _item.value = _item.value === item.openVal ? item.openVal : item.closeVal |
| | | } else { |
| | | if (item.initval === true) { |
| | | _item.value = item.openVal |
| | | } else { |
| | | _item.value = item.closeVal |
| | | } |
| | | } |
| | | } else if (_item.type === 'rate') { |
| | | let count = item.rateCount || 5 |
| | | _item.value = parseInt(_item.value) |
| | | |
| | | if (isNaN(_item.value) || _item.value < 0) { |
| | | _item.value = 0 |
| | | } else if (_item.value > count) { |
| | | _item.value = count |
| | | } |
| | | } |
| | | |
| | | result.push(_item) |
| | | }) |
| | | |
| | | if (btnconfig.setting.display === 'exec') { |
| | | this.execSubmit(selines, () => {}, result) |
| | | } else { |
| | | confirm({ |
| | | title: this.state.dict['main.action.confirm.tip'], |
| | | title: '确定要执行吗?', |
| | | onOk() { |
| | | _this.triggerPrint(selines, result) |
| | | }, |
| | |
| | | > |
| | | <MutilForm |
| | | BID={BID} |
| | | dict={this.state.dict} |
| | | action={btnconfig} |
| | | inputSubmit={this.handleOk} |
| | | data={this.state.selines[0]} |
| | |
| | | return <> |
| | | <Button |
| | | type={type} |
| | | id={'button' + btn.uuid} |
| | | title={disabled ? (btn.reason || '') : (btn.show === 'icon' ? btn.label : '')} |
| | | loading={loading} |
| | | disabled={disabled} |