| | |
| | | import { updateForm } from '@/utils/utils-update.js' |
| | | import MKEmitter from '@/utils/events.js' |
| | | import MkIcon from '@/components/mk-icon' |
| | | import MkCounter from './mkcounter' |
| | | // import './index.scss' |
| | | |
| | | const MutilForm = asyncSpinComponent(() => import('@/tabviews/zshare/mutilform')) |
| | |
| | | loadingTotal: '', |
| | | disabled: false, |
| | | hidden: false, |
| | | checkParam: null, |
| | | autoMatic: false, |
| | | check: false |
| | | check: false, |
| | | count: 0 |
| | | } |
| | | |
| | | moduleParams = null |
| | | |
| | | UNSAFE_componentWillMount () { |
| | | const { btn, selectedData, BData } = this.props |
| | | let disabled = false |
| | | const { btn, selectedData, BData, disabled } = this.props |
| | | |
| | | if (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}) |
| | | } |
| | | |
| | | if (btn.OpenType === 'form') { |
| | | let data = selectedData && selectedData[0] ? selectedData[0] : null |
| | | this.setState({check: data && data[btn.field] === btn.openVal}) |
| | | if (btn.formType === 'counter') { |
| | | let count = 0 |
| | | if (data && data[btn.field]) { |
| | | count = +data[btn.field] |
| | | if (isNaN(count)) { |
| | | count = 0 |
| | | } |
| | | } |
| | | this.setState({count: count }) |
| | | } else { |
| | | this.setState({check: data && data[btn.field] === btn.openVal}) |
| | | } |
| | | } else if (btn.OpenType === 'formSubmit') { |
| | | this.setState({ |
| | | selines: selectedData || [] |
| | |
| | | } |
| | | |
| | | UNSAFE_componentWillReceiveProps (nextProps) { |
| | | const { btn, selectedData, BData } = this.props |
| | | const { btn } = this.props |
| | | |
| | | let disabled = false |
| | | if (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({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}) |
| | | } |
| | | |
| | | if (btn.OpenType === 'form') { |
| | | let data = nextProps.selectedData && nextProps.selectedData[0] ? nextProps.selectedData[0] : null |
| | | this.setState({check: data && data[btn.field] === btn.openVal}) |
| | | if (btn.formType === 'counter') { |
| | | let count = 0 |
| | | if (data && data[btn.field]) { |
| | | count = +data[btn.field] |
| | | if (isNaN(count)) { |
| | | count = 0 |
| | | } |
| | | } |
| | | this.setState({count: count }) |
| | | } else { |
| | | this.setState({check: data && data[btn.field] === btn.openVal}) |
| | | } |
| | | } else if (btn.OpenType === 'formSubmit') { |
| | | this.setState({ |
| | | selines: nextProps.selectedData || [] |
| | |
| | | MKEmitter.removeListener('triggerBtnId', this.actionTrigger) |
| | | MKEmitter.removeListener('triggerFormSubmit', this.actionSubmit) |
| | | 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)) { |
| | | 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) => { |
| | |
| | | this.improveAction() |
| | | }) |
| | | } else if (btn.OpenType === 'form') { |
| | | this.setState({ |
| | | loading: true, |
| | | check: !this.state.check |
| | | }, () => { |
| | | let type = 'text' |
| | | let fieldlen = 50 |
| | | let value = this.state.check ? btn.openVal : btn.closeVal |
| | | |
| | | if (typeof(value) === 'number') { |
| | | type = 'number' |
| | | fieldlen = 0 |
| | | } |
| | | |
| | | if (btn.formType === 'counter') { |
| | | let item = { |
| | | type: type, |
| | | type: 'number', |
| | | readin: true, |
| | | writein: true, |
| | | fieldlen: fieldlen, |
| | | fieldlen: btn.decimal || 0, |
| | | key: btn.field, |
| | | value: value |
| | | value: this.state.count |
| | | } |
| | | this.execSubmit(data, () => { this.setState({loading: false})}, [item]) |
| | | }) |
| | | this.execSubmit(data, () => {}, [item]) |
| | | } else { |
| | | this.setState({ |
| | | loading: true, |
| | | check: !this.state.check |
| | | }, () => { |
| | | let type = 'text' |
| | | let fieldlen = 50 |
| | | let value = this.state.check ? btn.openVal : btn.closeVal |
| | | |
| | | if (typeof(value) === 'number') { |
| | | type = 'number' |
| | | fieldlen = 0 |
| | | } |
| | | |
| | | let item = { |
| | | type: type, |
| | | readin: true, |
| | | writein: true, |
| | | fieldlen: fieldlen, |
| | | key: btn.field, |
| | | value: value |
| | | } |
| | | this.execSubmit(data, () => { this.setState({loading: false})}, [item]) |
| | | }) |
| | | } |
| | | } |
| | | |
| | | if (window.GLOB.systemType === 'production') { |
| | |
| | | let param = { // 系统存储过程 |
| | | func: 'sPC_TableData_InUpDe' |
| | | } |
| | | let check_param = null |
| | | |
| | | if (this.props.BID) { |
| | | param.BID = this.props.BID |
| | |
| | | param.secretkey = Utils.encrypt('', param.timestamp) |
| | | |
| | | if (/\$check@|@check\$/ig.test(param.LText)) { |
| | | check_param = fromJS(param).toJS() |
| | | check_param.LText = check_param.LText.replace(/\$check@/ig, '/*') |
| | | check_param.LText = check_param.LText.replace(/@check\$/ig, '*/') |
| | | check_param.LText = Utils.formatOptions(check_param.LText) |
| | | |
| | | if (btn.intertype === 'system') { |
| | | param.$unCheckParam = fromJS(param).toJS() |
| | | } |
| | | param.LText = param.LText.replace(/\$check@|@check\$/ig, '') |
| | | } |
| | | |
| | |
| | | param.secretkey = Utils.encrypt('', param.timestamp) |
| | | |
| | | if (/\$check@|@check\$/ig.test(param.LText)) { |
| | | check_param = fromJS(param).toJS() |
| | | check_param.LText = check_param.LText.replace(/\$check@/ig, '/*') |
| | | check_param.LText = check_param.LText.replace(/@check\$/ig, '*/') |
| | | check_param.LText = Utils.formatOptions(check_param.LText) |
| | | |
| | | if (btn.intertype === 'system') { |
| | | param.$unCheckParam = fromJS(param).toJS() |
| | | } |
| | | param.LText = param.LText.replace(/\$check@|@check\$/ig, '') |
| | | } |
| | | |
| | |
| | | param.secretkey = Utils.encrypt('', param.timestamp) |
| | | |
| | | if (/\$check@|@check\$/ig.test(param.LText)) { |
| | | check_param = fromJS(param).toJS() |
| | | check_param.LText = check_param.LText.replace(/\$check@/ig, '/*') |
| | | check_param.LText = check_param.LText.replace(/@check\$/ig, '*/') |
| | | check_param.LText = Utils.formatOptions(check_param.LText) |
| | | |
| | | if (btn.intertype === 'system') { |
| | | param.$unCheckParam = fromJS(param).toJS() |
| | | } |
| | | param.LText = param.LText.replace(/\$check@|@check\$/ig, '') |
| | | } |
| | | |
| | |
| | | |
| | | if (window.GLOB.mkHS) { // 函数 sPC_TableData_InUpDe 云端验证 |
| | | param.open_key = Utils.encryptOpenKey(param.secretkey, param.timestamp) |
| | | if (check_param) { |
| | | check_param.open_key = Utils.encryptOpenKey(check_param.secretkey, check_param.timestamp) |
| | | } |
| | | } |
| | | |
| | | param.menuname = btn.logLabel |
| | |
| | | param.s_debug_type = 'Y' |
| | | } |
| | | |
| | | if (check_param) { |
| | | check_param.menuname = btn.logLabel |
| | | this.setState({checkParam: check_param}) |
| | | } |
| | | |
| | | if (window.GLOB.breakpoint) { |
| | | param.func = 'sPC_TableData_InUpDe_debug' |
| | | } |
| | | |
| | | if (param.$unCheckParam) { |
| | | param.$unCheckParam.LText = param.$unCheckParam.LText.replace(/\$check@/ig, '/*').replace(/@check\$/ig, '*/') |
| | | param.$unCheckParam.LText = Utils.formatOptions(param.$unCheckParam.LText) |
| | | param.$unCheckParam.menuname = btn.logLabel |
| | | |
| | | if (window.GLOB.probation) { |
| | | param.$unCheckParam.s_debug_type = 'Y' |
| | | } |
| | | } |
| | | |
| | | _params.push(param) |
| | |
| | | } 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) |
| | | |
| | | if (/\$check@|@check\$/ig.test(param.LText)) { |
| | | if (btn.intertype === 'system') { |
| | | param.$unCheckParam = fromJS(param).toJS() |
| | | } |
| | | param.LText = param.LText.replace(/\$check@|@check\$/ig, '') |
| | | } |
| | | |
| | | param.LText = Utils.formatOptions(param.LText) |
| | | } else if (btn.OpenType === 'pop') { // 表单 |
| | | if (index !== 0) { |
| | |
| | | } 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) |
| | | |
| | | if (/\$check@|@check\$/ig.test(param.LText)) { |
| | | if (btn.intertype === 'system') { |
| | | param.$unCheckParam = fromJS(param).toJS() |
| | | } |
| | | param.LText = param.LText.replace(/\$check@|@check\$/ig, '') |
| | | } |
| | | |
| | | param.LText = Utils.formatOptions(param.LText) |
| | | } else { |
| | | param.ID = primaryId |
| | |
| | | } 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) |
| | | |
| | | if (/\$check@|@check\$/ig.test(param.LText)) { |
| | | if (btn.intertype === 'system') { |
| | | param.$unCheckParam = fromJS(param).toJS() |
| | | } |
| | | param.LText = param.LText.replace(/\$check@|@check\$/ig, '') |
| | | } |
| | | |
| | | param.LText = Utils.formatOptions(param.LText) |
| | | } |
| | | } |
| | |
| | | |
| | | if (window.GLOB.breakpoint) { |
| | | param.func = 'sPC_TableData_InUpDe_debug' |
| | | } |
| | | |
| | | if (param.$unCheckParam) { |
| | | param.$unCheckParam.LText = param.$unCheckParam.LText.replace(/\$check@/ig, '/*').replace(/@check\$/ig, '*/') |
| | | param.$unCheckParam.LText = Utils.formatOptions(param.$unCheckParam.LText) |
| | | param.$unCheckParam.menuname = btn.logLabel |
| | | |
| | | if (window.GLOB.probation) { |
| | | param.$unCheckParam.s_debug_type = 'Y' |
| | | } |
| | | } |
| | | |
| | | return param |
| | |
| | | } |
| | | |
| | | // 添加数据中字段,表单值优先(按钮不选行或多行拼接时跳过) |
| | | if (data && btn.Ot !== 'notRequired' && btn.Ot !== 'requiredOnce' && columns && columns.length > 0) { |
| | | if (data && btn.Ot !== 'notRequired' && columns && columns.length > 0) { |
| | | datavars = {...data, ...datavars} |
| | | |
| | | const setField = (col) => { |
| | |
| | | _sql = _sql.replace(/@SessionUid@/ig, `'${localStorage.getItem('SessionUid') || ''}'`) |
| | | _sql = _sql.replace(/@UserID@/ig, `'${sessionStorage.getItem('UserID') || ''}'`) |
| | | _sql = _sql.replace(/@Appkey@/ig, `'${window.GLOB.appkey || ''}'`) |
| | | _sql = _sql.replace(/@typename@/ig, `'admin'`) |
| | | |
| | | return _sql |
| | | } |
| | |
| | | params = this.getInnerParam(data, formdata) |
| | | } |
| | | |
| | | if (params.length <= 20) { |
| | | if (params[0].$unCheckParam) { |
| | | this.checkLoopRequest(params, _resolve) |
| | | } else if (params.length <= 20 && btn.execType !== 'single') { |
| | | let deffers = params.map((param, i) => { |
| | | return new Promise(resolve => { |
| | | setTimeout(() => { |
| | |
| | | let iserror = false |
| | | let errorMsg = '' |
| | | result.forEach(res => { |
| | | if (iserror) return |
| | | if (res.status) { |
| | | errorMsg = res |
| | | } else { |
| | |
| | | _resolve() |
| | | }) |
| | | } else { // 超出20个请求时循环执行 |
| | | if (btn.progress === 'progressbar' && btn.$toolbtn) { |
| | | if (btn.progress === 'progressbar' && btn.$toolbtn && params.length > 1) { |
| | | this.setState({ |
| | | loadingTotal: params.length |
| | | }) |
| | |
| | | sql = _prevCustomScript + sql |
| | | sql = sql + _backCustomScript |
| | | |
| | | sql = sql.replace(/@ID@/ig, `'${record.ID || ''}'`) |
| | | sql = sql.replace(/@BID@/ig, `'${this.props.BID || ''}'`) |
| | | sql = sql.replace(/@LoginUID@/ig, `'${sessionStorage.getItem('LoginUID') || ''}'`) |
| | | sql = sql.replace(/@SessionUid@/ig, `'${localStorage.getItem('SessionUid') || ''}'`) |
| | | sql = sql.replace(/@UserID@/ig, `'${sessionStorage.getItem('UserID') || ''}'`) |
| | | sql = sql.replace(/@Appkey@/ig, `'${window.GLOB.appkey || ''}'`) |
| | | sql = sql.replace(/@typename@/ig, `'admin'`) |
| | | |
| | | if (window.GLOB.debugger === true || (window.debugger === true && options.sysType !== 'cloud')) { |
| | | console.info(sql.replace(/\n\s{8}/ig, '\n')) |
| | | } |
| | |
| | | } |
| | | |
| | | /** |
| | | * @description 数据检验循环执行 |
| | | */ |
| | | checkLoopRequest = (params, _resolve) => { |
| | | let param = params.shift() |
| | | let unCheckParam = param.$unCheckParam |
| | | |
| | | delete param.$unCheckParam |
| | | |
| | | this.setState({ |
| | | loadingNumber: params.length |
| | | }) |
| | | |
| | | Api.genericInterface(param).then(res => { |
| | | if (res.status) { |
| | | this.triggerNote(res) // 消息 |
| | | |
| | | if (params.length === 0) { |
| | | this.execSuccess(res) |
| | | _resolve() |
| | | } else { |
| | | this.checkLoopRequest(params, _resolve) |
| | | } |
| | | } else if (res.ErrCode === 'C') { |
| | | const _this = this |
| | | confirm({ |
| | | title: '继续执行?', |
| | | content: res.message, |
| | | onOk() { |
| | | return new Promise(resolve => { |
| | | Api.genericInterface(unCheckParam).then(result => { |
| | | if (result.status) { |
| | | _this.triggerNote(result) // 消息 |
| | | |
| | | if (params.length === 0) { |
| | | _this.execSuccess(result) |
| | | _resolve() |
| | | } else { |
| | | _this.checkLoopRequest(params, _resolve) |
| | | } |
| | | } else { |
| | | _this.execError(result) |
| | | _resolve() |
| | | } |
| | | resolve() |
| | | }) |
| | | }) |
| | | }, |
| | | onCancel() { |
| | | _this.execError(res) |
| | | _resolve() |
| | | } |
| | | }) |
| | | } else { |
| | | this.execError(res) |
| | | _resolve() |
| | | } |
| | | }, () => { |
| | | this.updateStatus() |
| | | _resolve() |
| | | }) |
| | | } |
| | | |
| | | /** |
| | | * @description 外部请求循环执行 |
| | | */ |
| | | outerLoopRequest = (params, _resolve) => { |
| | |
| | | result.open_key = Utils.encryptOpenKey(result.secretkey, result.timestamp) |
| | | } |
| | | } else { |
| | | if (btn.sysInterface === 'true' && window.GLOB.mainSystemApi) { |
| | | result.rduri = window.GLOB.mainSystemApi |
| | | } else if (btn.sysInterface !== 'true') { |
| | | if (btn.sysInterface === 'true') { |
| | | if (window.GLOB.mainSystemApi) { |
| | | result.rduri = window.GLOB.mainSystemApi |
| | | } |
| | | } else if (btn.sysInterface === 'external') { |
| | | if (window.GLOB.systemType === 'production') { |
| | | result.$token = btn.exProInterface || '' |
| | | } else { |
| | | result.$token = btn.exInterface || '' |
| | | } |
| | | } else { |
| | | if (window.GLOB.systemType === 'production' && btn.proInterface) { |
| | | result.rduri = btn.proInterface |
| | | } else { |
| | |
| | | * 4、模态框执行成功后是否关闭 |
| | | * 5、通知主列表刷新 |
| | | */ |
| | | execSuccess = (res) => { |
| | | execSuccess = (res = {}) => { |
| | | const { btn } = this.props |
| | | const { btnconfig, autoMatic } = this.state |
| | | |
| | | if ((res && (res.ErrCode === 'S' || !res.ErrCode)) || autoMatic) { // 执行成功 |
| | | notification.success({ |
| | | top: 92, |
| | | message: res.ErrMesg || this.state.dict['main.action.confirm.success'], |
| | | duration: btn.verify && btn.verify.stime ? btn.verify.stime : 2 |
| | | }) |
| | | } else if (res && res.ErrCode === 'Y') { // 执行成功 |
| | | if (res.message && /^@speak@/.test(res.message)) { |
| | | res.message = res.message.replace('@speak@', '') |
| | | let val = res.message.match(/<<.*>>/) |
| | | res.message = res.message.replace(/\s*<<.*>>\s*/g, '') |
| | | val = val ? val[0].replace(/<<|>>/g, '') : '' |
| | | |
| | | if (/^http/.test(val)) { |
| | | let audio = document.createElement('audio') |
| | | audio.src = val |
| | | audio.play() |
| | | } |
| | | |
| | | if (!res.message) { |
| | | res.ErrCode = '-1' |
| | | } |
| | | } |
| | | |
| | | if ((res.ErrCode === 'S' || !res.ErrCode) || autoMatic) { // 执行成功 |
| | | if (btn.formType !== 'counter' || res.message) { |
| | | notification.success({ |
| | | top: 92, |
| | | 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 && res.ErrCode === '-1') { // 完成后不提示 |
| | | } else if (res.ErrCode === '-1') { // 完成后不提示 |
| | | |
| | | } |
| | | |
| | |
| | | MenuID: btn.MenuID, |
| | | MenuName: btn.MenuName, |
| | | MenuNo: btn.MenuNo, |
| | | type: btn.tabType, |
| | | param: { |
| | | $BID: id |
| | | } |
| | | type: btn.tabType |
| | | } |
| | | } else if (!newtab) { |
| | | return |
| | | } |
| | | |
| | | if (['linkage_navigation', 'linkage', 'menu_board'].includes(window.GLOB.navBar)) { |
| | | MKEmitter.emit('modifyTabs', newtab, 'replace') |
| | | } else { |
| | | MKEmitter.emit('modifyTabs', newtab, 'plus', true) |
| | | } |
| | | newtab = {...newtab, param: { $BID: id }} |
| | | |
| | | MKEmitter.emit('modifyTabs', newtab, true) |
| | | } |
| | | } |
| | | |
| | |
| | | const { btn } = this.props |
| | | const { btnconfig, autoMatic } = this.state |
| | | |
| | | if (res.message && /^@speak@/.test(res.message)) { |
| | | res.message = res.message.replace('@speak@', '') |
| | | let val = res.message.match(/<<.*>>/) |
| | | res.message = res.message.replace(/\s*<<.*>>\s*/g, '') |
| | | val = val ? val[0].replace(/<<|>>/g, '') : '' |
| | | |
| | | if (/^http/.test(val)) { |
| | | let audio = document.createElement('audio') |
| | | audio.src = val |
| | | audio.play() |
| | | } |
| | | |
| | | if (!res.message) { |
| | | res.ErrCode = '-1' |
| | | } |
| | | } |
| | | |
| | | 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 || '执行失败!') |
| | | } |
| | | |
| | | if (autoMatic) { |
| | |
| | | loadingTotal: '', |
| | | }) |
| | | |
| | | if (res.ErrCode === 'C') { |
| | | const _this = this |
| | | if (this.state.checkParam) { |
| | | let param = this.state.checkParam |
| | | confirm({ |
| | | title: res.message || res.ErrMesg, |
| | | content: '继续执行?', |
| | | onOk() { |
| | | return new Promise(resolve => { |
| | | Api.genericInterface(param).then((result) => { |
| | | if (result.status) { |
| | | _this.execSuccess(result) |
| | | } else { |
| | | _this.execError(result) |
| | | } |
| | | resolve() |
| | | }, () => { |
| | | _this.setState({ |
| | | visible: false |
| | | }) |
| | | resolve() |
| | | }) |
| | | }) |
| | | }, |
| | | onCancel() { |
| | | _this.setState({ |
| | | visible: false |
| | | }) |
| | | if (btn.execError !== 'never') { |
| | | MKEmitter.emit('refreshByButtonResult', btn.$menuId, btn.execError, btn, '', this.state.selines) |
| | | } |
| | | } |
| | | }) |
| | | this.setState({checkParam: null}) |
| | | return |
| | | } else { |
| | | Modal.error({ |
| | | title: res.message || res.ErrMesg, |
| | | }) |
| | | } |
| | | } |
| | | |
| | | if (btnconfig && btnconfig.setting && btnconfig.setting.errFocus) { |
| | | MKEmitter.emit('mkFC', 'focus', btnconfig.setting.errFocus) |
| | | } |
| | |
| | | MKEmitter.emit('popclose') |
| | | } else if (btn.execError !== 'never') { |
| | | MKEmitter.emit('refreshByButtonResult', btn.$menuId, btn.execError, btn, '', this.state.selines) |
| | | } else if (btn.OpenType === 'form') { |
| | | } else if (btn.OpenType === 'form' && btn.formType !== 'counter') { |
| | | let data = this.props.selectedData && this.props.selectedData[0] ? this.props.selectedData[0] : null |
| | | this.setState({check: data && data[btn.field] === btn.openVal}) |
| | | } |
| | |
| | | if (['select', 'link', 'multiselect', 'radio', 'checkbox', 'checkcard'].includes(cell.type) && cell.resourceType === '1') { |
| | | let _option = Utils.getSelectQueryOptions(cell) |
| | | |
| | | cell.data_sql = Utils.formatOptions(_option.sql) |
| | | cell.base_sql = window.btoa(window.encodeURIComponent(_option.sql)) |
| | | cell.base_sql = _option.sql |
| | | cell.arr_field = _option.field |
| | | } |
| | | |
| | |
| | | this.setState({ |
| | | visible: true |
| | | }) |
| | | |
| | | if (btnconfig.setting.display === 'modal' && btnconfig.setting.moveable === 'true') { |
| | | setTimeout(() => { |
| | | this.setMove() |
| | | }, 100) |
| | | } |
| | | } |
| | | } else if (!btn.$old) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '未获取到按钮配置信息!', |
| | | duration: 5 |
| | | }) |
| | | this.setState({ loading: false }) |
| | | } else { |
| | | Api.getCacheConfig({ |
| | | func: 'sPC_Get_LongParam', |
| | |
| | | width = btnconfig.setting.width > 100 ? btnconfig.setting.width : btnconfig.setting.width + '%' |
| | | container = () => document.getElementById(btn.ContainerId) |
| | | } |
| | | |
| | | return ( |
| | | <Modal |
| | | title={title} |
| | | maskClosable={clickouter} |
| | | getContainer={container} |
| | | wrapClassName='action-modal' |
| | | wrapClassName={'action-modal' + (btnconfig.setting.moveable === 'true' ? ' moveable-modal modal-' + btn.uuid : '')} |
| | | visible={visible} |
| | | width={width} |
| | | onOk={this.handleOk} |
| | | maskStyle={btnconfig.setting.moveable === 'true' ? {backgroundColor: 'rgba(0, 0, 0, 0.15)'} : null} |
| | | confirmLoading={this.state.confirmLoading} |
| | | onCancel={this.handleCancel} |
| | | destroyOnClose |
| | |
| | | } |
| | | } |
| | | |
| | | setMove = () => { |
| | | const { btn } = this.props |
| | | let wrap = document.getElementsByClassName('modal-' + btn.uuid)[0] |
| | | |
| | | if (!wrap) return |
| | | |
| | | let node = wrap.getElementsByClassName('ant-modal-header')[0] |
| | | |
| | | if (!node) return |
| | | |
| | | node.onmousedown = function(e) { |
| | | let orileft = 0 |
| | | let oritop = 0 |
| | | let oleft = e.clientX |
| | | let otop = e.clientY |
| | | |
| | | if (node.parentNode.style.left) { |
| | | orileft = parseFloat(node.parentNode.style.left) |
| | | } |
| | | if (node.parentNode.style.top) { |
| | | oritop = parseFloat(node.parentNode.style.top) |
| | | } |
| | | |
| | | document.onmousemove = function(e) { |
| | | let left = e.clientX - oleft |
| | | let top = e.clientY - otop |
| | | |
| | | node.parentNode.style.left = (orileft + left) + 'px' |
| | | node.parentNode.style.top = (oritop + top) + 'px' |
| | | } |
| | | } |
| | | |
| | | document.onmouseup = function() { |
| | | document.onmousemove = null |
| | | } |
| | | } |
| | | |
| | | changeCount = (count) => { |
| | | this.setState({count}, () => { |
| | | this.actionTrigger() |
| | | }) |
| | | } |
| | | |
| | | render() { |
| | | const { btn } = this.props |
| | | const { loadingNumber, loadingTotal, loading, disabled, hidden, check } = this.state |
| | | const { loadingNumber, loadingTotal, loading, disabled, hidden, check, count } = this.state |
| | | |
| | | if (hidden) return null |
| | | |
| | | if (btn.OpenType === 'form') { |
| | | if (btn.formType === 'switch') { |
| | | return <Switch loading={loading} checked={check} disabled={disabled || loading} title={disabled ? (btn.reason || '') : ''} onChange={(val,e) => {e.stopPropagation();this.actionTrigger()}} style={btn.style} className={btn.size === 'large' ? 'ant-switch-large' : ''} size={btn.size} checkedChildren={btn.openText || ''} unCheckedChildren={btn.closeText || ''}/> |
| | | } else if (btn.formType === 'counter') { |
| | | return <MkCounter count={count} disabled={disabled} btn={btn} onChange={this.changeCount}/> |
| | | } else if (btn.formType === 'radio') { |
| | | return <Checkbox disabled={disabled || loading} title={disabled ? (btn.reason || '') : ''} checked={check} onChange={(e) => {e.stopPropagation();this.actionTrigger()}} style={btn.style}></Checkbox> |
| | | return <Checkbox className={btn.checkType || ''} disabled={disabled || loading} title={disabled ? (btn.reason || '') : ''} checked={check} onChange={(e) => {e.stopPropagation();this.actionTrigger()}} style={btn.style}></Checkbox> |
| | | } else { |
| | | return <Button type="link" icon="scan" disabled={true} style={btn.style} onClick={(e) => {e.stopPropagation()}}></Button> |
| | | } |