From 6c66c9c2a6d0f7e7ccc65d4d9e478f1acb74d87e Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期五, 20 八月 2021 12:12:48 +0800 Subject: [PATCH] 2021-08-20 --- src/tabviews/zshare/actionList/normalbutton/index.jsx | 464 +++++++++++++++++++++++++++++++++++++--------------------- 1 files changed, 296 insertions(+), 168 deletions(-) diff --git a/src/tabviews/zshare/actionList/normalbutton/index.jsx b/src/tabviews/zshare/actionList/normalbutton/index.jsx index 7eda245..8aac0c2 100644 --- a/src/tabviews/zshare/actionList/normalbutton/index.jsx +++ b/src/tabviews/zshare/actionList/normalbutton/index.jsx @@ -3,7 +3,7 @@ import moment from 'moment' import {connect} from 'react-redux' import { is, fromJS } from 'immutable' -import { Button, Modal, notification, message } from 'antd' +import { Button, Modal, notification, message, Drawer, Icon } from 'antd' import Api from '@/api' import Utils, { getSysDefaultSql } from '@/utils/utils.js' @@ -11,6 +11,7 @@ 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' import './index.scss' @@ -41,7 +42,25 @@ btnconfig: null, loading: false, loadingNumber: '', + disabled: false, checkParam: null + } + + moduleParams = null + + UNSAFE_componentWillMount () { + const { btn, selectedData } = this.props + let disabled = false + + if (btn.controlField && selectedData && selectedData.length > 0) { // 琛ㄦ牸涓寜閽殣钘忔帶鍒� + selectedData.forEach(item => { + let s = item[btn.controlField] + '' + if (s === btn.controlVal || (btn.controlVal && btn.controlVal.split(',').includes(s))) { + disabled = true + } + }) + this.setState({disabled}) + } } shouldComponentUpdate (nextProps, nextState) { @@ -51,8 +70,28 @@ componentDidMount () { const { position } = this.props - if (position === 'toolbar') { - MKEmitter.addListener('triggerBtnId', this.actionTrigger) + MKEmitter.addListener('triggerBtnId', this.actionTrigger) + if (position === 'form') { + MKEmitter.addListener('triggerFormSubmit', this.actionSubmit) + } + MKEmitter.addListener('returnModuleParam', this.resetModuleParam) + } + + UNSAFE_componentWillReceiveProps (nextProps) { + const { btn, selectedData } = this.props + + if (btn.controlField && !is(fromJS(nextProps.selectedData || []), fromJS(selectedData || []))) { + let disabled = false + + if (nextProps.selectedData && nextProps.selectedData.length > 0) { // 琛ㄦ牸涓寜閽殣钘忔帶鍒� + nextProps.selectedData.forEach(item => { + let s = item[btn.controlField] + '' + if (s === btn.controlVal || (btn.controlVal && btn.controlVal.split(',').includes(s))) { + disabled = true + } + }) + } + this.setState({disabled}) } } @@ -61,6 +100,28 @@ return } MKEmitter.removeListener('triggerBtnId', this.actionTrigger) + MKEmitter.removeListener('triggerFormSubmit', this.actionSubmit) + MKEmitter.removeListener('returnModuleParam', this.resetModuleParam) + } + + actionSubmit = (res) => { + const { btn } = this.props + + if (btn.uuid !== res.menuId) return + + this.setState({ + loading: true + }) + + this.execSubmit(this.state.tabledata, () => {}, res.form) + } + + resetModuleParam = (menuId, btnId, param) => { + const { btn } = this.props + + if (btn.$menuId !== menuId || btn.uuid !== btnId || !param) return + + this.moduleParams = param } /** @@ -83,12 +144,12 @@ * @description 瑙﹀彂鎸夐挳鎿嶄綔 */ actionTrigger = (triggerId, record) => { - const { setting, Tab, BID, btn, selectedData } = this.props + const { Tab, BID, btn, selectedData, setting } = this.props const { loading } = this.state if ((triggerId && btn.uuid !== triggerId) || loading) return - if (Tab && Tab.supMenu && !BID) { + if (((Tab && Tab.supMenu) || setting.supModule) && !BID) { notification.warning({ top: 92, message: '闇�瑕佷笂绾т富閿�硷紒', @@ -113,14 +174,6 @@ notification.warning({ top: 92, message: this.state.dict['main.action.confirm.selectSingleLine'], - duration: 5 - }) - return - } else if (!setting.primaryKey) { - // 闇�瑕侀�夋嫨琛屾椂锛屾牎楠屾槸鍚﹁缃富閿� - notification.warning({ - top: 92, - message: '鏈缃富閿紒', duration: 5 }) return @@ -178,7 +231,13 @@ return } - if (btn.OpenType === 'prompt') { + if (btn.OpenType === 'formSubmit') { + this.setState({ + tabledata: data + }) + MKEmitter.emit('mkFormSubmit', btn.uuid) + return + } else if (btn.OpenType === 'prompt') { this.updateStatus('start') confirm({ title: this.state.dict['main.action.confirm.tip'], @@ -197,9 +256,14 @@ } else if (btn.OpenType === 'pop') { this.updateStatus('start') + let modal = this.state.btnconfig + if (!modal && btn.modal) { + modal = this.handleModelConfig(btn.modal) + } + this.setState({ tabledata: data, - btnconfig: btn.modal ? btn.modal : this.state.btnconfig + btnconfig: modal }, () => { this.improveAction() }) @@ -231,7 +295,7 @@ let primaryId = '' - if (btn.Ot === 'requiredSgl' || btn.Ot === 'requiredOnce') { + if ((btn.Ot === 'requiredSgl' || btn.Ot === 'requiredOnce') && setting.primaryKey) { let ids = data.map(d => { return d[setting.primaryKey] || ''}) ids = ids.filter(Boolean) primaryId = ids.join(',') @@ -241,11 +305,11 @@ param.ID = primaryId if (retmsg) { - const { sql, callbacksql } = getSysDefaultSql(btn, setting, '', param, data[0], columns, this.props.Tab, retmsg) // 鏁版嵁婧� + const { sql, callbacksql } = getSysDefaultSql(btn, setting, '', param, data[0], columns, this.props.Tab, retmsg, this.moduleParams, Utils.getAllSearchOptions) // 鏁版嵁婧� param.LText = sql param.$callbacksql = callbacksql } else { - param.LText = getSysDefaultSql(btn, setting, '', param, data[0], columns, this.props.Tab) // 鏁版嵁婧� + param.LText = getSysDefaultSql(btn, setting, '', param, data[0], columns, this.props.Tab, false, this.moduleParams, Utils.getAllSearchOptions) // 鏁版嵁婧� } if (sessionStorage.getItem('dataM') === 'true') { // 鏁版嵁鏉冮檺 @@ -269,7 +333,7 @@ } param.LText = Utils.formatOptions(param.LText) - } else if (btn.OpenType === 'pop') { // 琛ㄥ崟 + } else if (btn.OpenType === 'pop' || btn.OpenType === 'formSubmit') { // 琛ㄥ崟 if (btn.sqlType === 'insert') { // 绯荤粺鍑芥暟娣诲姞鏃讹紝鐢熸垚uuid primaryId = '' @@ -283,11 +347,11 @@ param.ID = primaryId || Utils.getguid() if (retmsg) { - const { sql, callbacksql } = getSysDefaultSql(btn, setting, formdata, param, data[0], columns, this.props.Tab, retmsg) // 鏁版嵁婧� + const { sql, callbacksql } = getSysDefaultSql(btn, setting, formdata, param, data[0], columns, this.props.Tab, retmsg, this.moduleParams, Utils.getAllSearchOptions) // 鏁版嵁婧� param.LText = sql param.$callbacksql = callbacksql } else { - param.LText = getSysDefaultSql(btn, setting, formdata, param, data[0], columns, this.props.Tab) // 鏁版嵁婧� + param.LText = getSysDefaultSql(btn, setting, formdata, param, data[0], columns, this.props.Tab, false, this.moduleParams, Utils.getAllSearchOptions) // 鏁版嵁婧� } if (sessionStorage.getItem('dataM') === 'true') { // 鏁版嵁鏉冮檺 @@ -315,11 +379,11 @@ param.ID = primaryId if (retmsg) { - const { sql, callbacksql } = getSysDefaultSql(btn, setting, formdata, param, data[0], columns, this.props.Tab, retmsg) // 鏁版嵁婧� + const { sql, callbacksql } = getSysDefaultSql(btn, setting, formdata, param, data[0], columns, this.props.Tab, retmsg, this.moduleParams, Utils.getAllSearchOptions) // 鏁版嵁婧� param.LText = sql param.$callbacksql = callbacksql } else { - param.LText = getSysDefaultSql(btn, setting, formdata, param, data[0], columns, this.props.Tab) // 鏁版嵁婧� + param.LText = getSysDefaultSql(btn, setting, formdata, param, data[0], columns, this.props.Tab, false, this.moduleParams, Utils.getAllSearchOptions) // 鏁版嵁婧� } if (sessionStorage.getItem('dataM') === 'true') { // 鏁版嵁鏉冮檺 @@ -377,11 +441,11 @@ param.ID = primaryId if (retmsg) { - const { sql, callbacksql } = getSysDefaultSql(btn, setting, '', param, cell, columns, this.props.Tab, retmsg) // 鏁版嵁婧� + const { sql, callbacksql } = getSysDefaultSql(btn, setting, '', param, cell, columns, this.props.Tab, retmsg, this.moduleParams, Utils.getAllSearchOptions) // 鏁版嵁婧� param.LText = sql param.$callbacksql = callbacksql } else { - param.LText = getSysDefaultSql(btn, setting, '', param, cell, columns, this.props.Tab) // 鏁版嵁婧� + param.LText = getSysDefaultSql(btn, setting, '', param, cell, columns, this.props.Tab, false, this.moduleParams, Utils.getAllSearchOptions, Utils.getAllSearchOptions) // 鏁版嵁婧� } if (sessionStorage.getItem('dataM') === 'true') { // 鏁版嵁鏉冮檺 @@ -410,11 +474,11 @@ param.ID = Utils.getguid() if (retmsg) { - const { sql, callbacksql } = getSysDefaultSql(btn, setting, formdata, param, cell, columns, this.props.Tab, retmsg) // 鏁版嵁婧� + const { sql, callbacksql } = getSysDefaultSql(btn, setting, formdata, param, cell, columns, this.props.Tab, retmsg, this.moduleParams, Utils.getAllSearchOptions) // 鏁版嵁婧� param.LText = sql param.$callbacksql = callbacksql } else { - param.LText = getSysDefaultSql(btn, setting, formdata, param, cell, columns, this.props.Tab) // 鏁版嵁婧� + param.LText = getSysDefaultSql(btn, setting, formdata, param, cell, columns, this.props.Tab, false, this.moduleParams, Utils.getAllSearchOptions) // 鏁版嵁婧� } if (sessionStorage.getItem('dataM') === 'true') { // 鏁版嵁鏉冮檺 @@ -433,11 +497,11 @@ param.ID = primaryId if (retmsg) { - const { sql, callbacksql } = getSysDefaultSql(btn, setting, formdata, param, cell, columns, this.props.Tab, retmsg) // 鏁版嵁婧� + const { sql, callbacksql } = getSysDefaultSql(btn, setting, formdata, param, cell, columns, this.props.Tab, retmsg, this.moduleParams, Utils.getAllSearchOptions) // 鏁版嵁婧� param.LText = sql param.$callbacksql = callbacksql } else { - param.LText = getSysDefaultSql(btn, setting, formdata, param, cell, columns, this.props.Tab) // 鏁版嵁婧� + param.LText = getSysDefaultSql(btn, setting, formdata, param, cell, columns, this.props.Tab, false, this.moduleParams, Utils.getAllSearchOptions) // 鏁版嵁婧� } if (sessionStorage.getItem('dataM') === 'true') { // 鏁版嵁鏉冮檺 @@ -485,15 +549,17 @@ let primaryId = '' - if (btn.Ot === 'requiredSgl' || btn.Ot === 'requiredOnce') { + if ((btn.Ot === 'requiredSgl' || btn.Ot === 'requiredOnce') && setting.primaryKey) { let ids = data.map(d => { return d[setting.primaryKey] || ''}) ids = ids.filter(Boolean) primaryId = ids.join(',') } - param[setting.primaryKey] = primaryId // 璁剧疆涓婚敭鍙傛暟 + if (setting.primaryKey) { + param[setting.primaryKey] = primaryId // 璁剧疆涓婚敭鍙傛暟 + } - if (btn.OpenType === 'pop') { // 琛ㄥ崟 + if (btn.OpenType === 'pop' || btn.OpenType === 'formSubmit') { // 琛ㄥ崟 formdata.forEach(_data => { param[_data.key] = _data.value }) @@ -532,7 +598,9 @@ param[_data.key] = _data.value }) } - param[setting.primaryKey] = primaryId + if (setting.primaryKey) { + param[setting.primaryKey] = primaryId + } if (this.props.menuType === 'HS' && param.func === 's_sDataDictb_TBBack' && param.LTextOut) { // 鍑芥暟 s_sDataDictb_TBBack 浜戠楠岃瘉 param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') @@ -551,6 +619,30 @@ * @description 鎸夐挳鎻愪氦鎵ц */ execSubmit = (data, _resolve, formdata) => { + 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 + ) { + MKEmitter.emit('queryModuleParam', btn.$menuId, btn.uuid) + setTimeout(() => { + if (this.moduleParams) { + this.execRealSubmit(data, _resolve, formdata) + } else { + setTimeout(() => { + this.execRealSubmit(data, _resolve, formdata) + }, 100) + } + }, 50) + } else { + this.execRealSubmit(data, _resolve, formdata) + } + } + + execRealSubmit = (data, _resolve, formdata) => { const { setting, btn } = this.props if (btn.intertype === 'system' || btn.intertype === 'inner') { // 绯荤粺鎺ュ彛 let params = [] @@ -604,7 +696,7 @@ param.BID = this.props.BID } - if (btn.OpenType === 'pop' && formdata) { // 琛ㄥ崟 + if ((btn.OpenType === 'pop' || btn.OpenType === 'formSubmit') && formdata) { // 琛ㄥ崟 formdata.forEach(_data => { param[_data.key] = _data.value }) @@ -690,10 +782,10 @@ Api.genericInterface(param).then(res => { if (res.status) { - if (res.mk_ex_invoke === 'false' && params.length === 0) { + if ((res.mk_ex_invoke === 'false' || res.mk_ex_invoke === false) && params.length === 0) { this.execSuccess(res) _resolve() - } else if (res.mk_ex_invoke === 'false' && params.length > 0) { + } else if ((res.mk_ex_invoke === 'false' || res.mk_ex_invoke === false) && params.length > 0) { this.customLoopRequest(params, _resolve) } else { this.customOuterRequest(params, res, record, _resolve) @@ -707,10 +799,10 @@ return new Promise(resolve => { Api.genericInterface(_this.state.checkParam).then((result) => { if (result.status) { - if (result.mk_ex_invoke === 'false' && params.length === 0) { + if ((result.mk_ex_invoke === 'false' || result.mk_ex_invoke === false) && params.length === 0) { _this.execSuccess(result) _resolve() - } else if (result.mk_ex_invoke === 'false' && params.length > 0) { + } else if ((result.mk_ex_invoke === 'false' || result.mk_ex_invoke === false) && params.length > 0) { _this.customLoopRequest(params, _resolve) } else { _this.customOuterRequest(params, result, record, _resolve) @@ -772,8 +864,8 @@ param[key] = result[key] }) - Api.directRequest(url, btn.method, param).then(res => { - if (typeof(res) !== 'object' || Array.isArray(res)) { + Api.directRequest(url, btn.method, param, btn.cross).then(res => { + if (typeof(res) !== 'object') { let error = '鏈煡鐨勮繑鍥炵粨鏋滐紒' if (typeof(res) === 'string') { @@ -788,12 +880,20 @@ this.customCallbackRequest(params, result, record, _resolve) } else { + if (Array.isArray(res)) { + res = { data: res } + } res.mk_api_key = mkey this.customCallbackRequest(params, res, record, _resolve) } - }, () => { - this.updateStatus('over') - _resolve() + }, (e) => { + let result = { + mk_api_key: mkey, + $ErrCode: 'E', + $ErrMesg: e && e.statusText ? e.statusText : '' + } + + this.customCallbackRequest([], result, record, _resolve) }) } @@ -840,6 +940,9 @@ subObjs.push(val) } } else { + if (typeof(val) === 'string') { + val = val.replace(/'/ig, '"') + } keys.push(key) vals.push(`'${val}'`) } @@ -885,8 +988,7 @@ param.ID = record.ID } - let _prevCustomScript = `${record.callbacksql || 'declare @ErrorCode nvarchar(50),@retmsg nvarchar(4000)'} - Select @ErrorCode='',@retmsg='' + let _prevCustomScript = `${record.callbacksql} ${errSql} ` let _backCustomScript = '' @@ -1191,7 +1293,7 @@ } if (btn.execSuccess !== 'never') { - MKEmitter.emit('refreshByButtonResult', btn.$menuId, btn.execSuccess, btn) + MKEmitter.emit('refreshByButtonResult', btn.$menuId, btn.execSuccess || '', btn) } } @@ -1221,6 +1323,7 @@ let _param = { templatecode: verify.noteCode, // 妯℃澘缂栫爜 TypeCharOne: verify.noteTemp, // N涓嶅悓鍐呭锛孻鐩稿悓鍐呭 + ID: verify.noteId || '' // 妯℃澘Id锛屾殏鏃舵湭浣跨敤 } _param.submitdate = res.submitdate @@ -1285,10 +1388,12 @@ _param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') _param.secretkey = Utils.encrypt(_param.LText, _param.timestamp) - _param.rduri = 'http://sso.mk9h.cn/webapi/dostar' - _param.appkey = window.GLOB.appkey || '' + _param.rduri = 'http://sso.mk9h.cn/webapi/dostars' - Api.dostarInterface(_param).then(result => { + _param.userid = 'bh0bapabtd45epsgra79segbch6c1ibk' + _param.LoginUID = 'bh0bapabtd45epsgra79segbch6c1ibk' + + Api.getLocalConfig(_param).then(result => { if (!result.status) { notification.warning({ top: 92, @@ -1393,6 +1498,29 @@ }) } + handleModelConfig = (config) => { + let roleId = sessionStorage.getItem('role_id') || '' // 瑙掕壊ID + config.fields = config.fields.map(cell => { + // 鏁版嵁婧恠ql璇彞锛岄澶勭悊锛屾潈闄愰粦鍚嶅崟瀛楁璁剧疆涓洪殣钘忚〃鍗� + 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.arr_field = _option.field + } + + // 瀛楁鏉冮檺榛戝悕鍗� + if (!cell.blacklist || cell.blacklist.length === 0) return cell + if (cell.blacklist.filter(v => roleId.indexOf(v) > -1).length > 0) { + cell.hidden = 'true' + } + + return cell + }) + return config + } + /** * @description 鑾峰彇鎸夐挳閰嶇疆淇℃伅 */ @@ -1439,67 +1567,9 @@ }) this.updateStatus('over') } else { - let roleId = sessionStorage.getItem('role_id') || '' // 瑙掕壊ID - if (_LongParam.groups.length > 0) { - _LongParam.groups.forEach(group => { - group.sublist = group.sublist.map(cell => { - // 鏁版嵁婧恠ql璇彞锛岄澶勭悊锛� 鏉冮檺榛戝悕鍗曞瓧娈佃缃负闅愯棌琛ㄥ崟 - if (['select', 'link', 'multiselect', 'radio', 'checkbox', 'checkcard'].includes(cell.type) && cell.resourceType === '1') { - let _option = Utils.getSelectQueryOptions(cell) - - if (sessionStorage.getItem('dataM') === 'true') { // 鏁版嵁鏉冮檺 - _option.sql = _option.sql.replace(/\$@/ig, '/*') - _option.sql = _option.sql.replace(/@\$/ig, '*/') - } else { - _option.sql = _option.sql.replace(/@\$|\$@/ig, '') - } - // 澶栬仈鏁版嵁搴撴浛鎹� - if (window.GLOB.externalDatabase !== null) { - _option.sql = _option.sql.replace(/@db@/ig, window.GLOB.externalDatabase) - } - - cell.data_sql = Utils.formatOptions(_option.sql) - cell.base_sql = window.btoa(window.encodeURIComponent(_option.sql)) - cell.arr_field = _option.field - } - - // 瀛楁鏉冮檺榛戝悕鍗� - if (!cell.blacklist || cell.blacklist.length === 0) return cell - if (cell.blacklist.filter(v => roleId.indexOf(v) > -1).length > 0) { - cell.hidden = 'true' - } - - return cell - }) - }) - } else { - _LongParam.fields = _LongParam.fields.map(cell => { - // 鏁版嵁婧恠ql璇彞锛岄澶勭悊锛屾潈闄愰粦鍚嶅崟瀛楁璁剧疆涓洪殣钘忚〃鍗� - if (['select', 'link', 'multiselect', 'radio', 'checkbox', 'checkcard'].includes(cell.type) && cell.resourceType === '1') { - let _option = Utils.getSelectQueryOptions(cell) - - if (sessionStorage.getItem('dataM') === 'true') { // 鏁版嵁鏉冮檺 - _option.sql = _option.sql.replace(/\$@/ig, '/*') - _option.sql = _option.sql.replace(/@\$/ig, '*/') - } else { - _option.sql = _option.sql.replace(/@\$|\$@/ig, '') - } - - cell.data_sql = Utils.formatOptions(_option.sql) - cell.base_sql = window.btoa(window.encodeURIComponent(_option.sql)) - cell.arr_field = _option.field - } - - // 瀛楁鏉冮檺榛戝悕鍗� - if (!cell.blacklist || cell.blacklist.length === 0) return cell - if (cell.blacklist.filter(v => roleId.indexOf(v) > -1).length > 0) { - cell.hidden = 'true' - } - - return cell - }) - } - + _LongParam = updateForm(_LongParam) + _LongParam = this.handleModelConfig(_LongParam) + this.setState({ btnconfig: _LongParam }, () => { @@ -1548,17 +1618,10 @@ const { BData } = this.props const { btnconfig, tabledata } = this.state let _this = this - let _fields = [] - - if (btnconfig.groups.length > 0) { - btnconfig.groups.forEach(group => { - _fields = [..._fields, ...group.sublist] - }) - } else { - _fields = btnconfig.fields - } - let result = _fields.map(item => { + let result = [] + btnconfig.fields.forEach(item => { + if (!item.field) return let _readin = item.readin !== 'false' let _initval = item.initval @@ -1585,14 +1648,25 @@ _fieldlen = item.decimal ? item.decimal : 0 } - return { + if (_initval === undefined) { + _initval = '' + } + + let _type = item.type + + if (['date', 'datemonth', 'datetime'].includes(_type) && item.declareType === 'nvarchar(50)') { + _type = 'text' + } + + result.push({ key: item.field, readonly: item.readonly === 'true', readin: _readin, fieldlen: _fieldlen, - type: item.type, + writein: item.writein !== 'false', + type: _type, value: _initval - } + }) }) confirm({ @@ -1619,51 +1693,87 @@ let title = btnconfig.setting.title let width = btnconfig.setting.width + 'vw' - let clickouter = false - let container = document.body + let clickouter = btnconfig.setting.clickouter === 'close' - if ( - (setting.tabType === 'main' && btnconfig.setting.container === 'tab' && this.props.ContainerId) || - (btnconfig.setting.container === 'tab' && btn.ContainerId) - ) { - width = btnconfig.setting.width + '%' - container = () => document.getElementById(this.props.ContainerId || btn.ContainerId) + if (btnconfig.setting.display === 'drawer') { + let height = '100vh' + if (btnconfig.setting.placement === 'top' || btnconfig.setting.placement === 'bottom') { + width = '100vw' + height = btnconfig.setting.width + 'vh' + } + return ( + <Drawer + title={title} + width={width} + height={height} + maskClosable={clickouter} + onClose={this.handleCancel} + visible={visible} + placement={btnconfig.setting.placement || 'right'} + bodyStyle={{ paddingBottom: 80 }} + destroyOnClose + > + <MutilForm + BID={BID} + dict={this.state.dict} + menuType={this.props.menuType} + action={btnconfig} + inputSubmit={this.handleOk} + data={this.state.tabledata[0]} + BData={this.props.BData} + wrappedComponentRef={(inst) => this.formRef = inst} + /> + <div style={{ position: 'absolute', zIndex: 1, right: 0, bottom: 0, width: '100%', borderTop: '1px solid #e9e9e9', padding: '10px 16px', background: '#fff', textAlign: 'right'}}> + <Button onClick={this.handleCancel} style={{ marginRight: 8 }}> + 鍙栨秷 + </Button> + <Button onClick={this.handleOk} loading={this.state.confirmLoading} type="primary"> + 纭畾 + </Button> + </div> + </Drawer> + ) + } else { + let container = document.body + + if ( + (setting.tabType === 'main' && btnconfig.setting.container === 'tab' && this.props.ContainerId) || + (btnconfig.setting.container === 'tab' && btn.ContainerId) + ) { + width = btnconfig.setting.width + '%' + container = () => document.getElementById(this.props.ContainerId || btn.ContainerId) + } + return ( + <Modal + title={title} + maskClosable={clickouter} + getContainer={container} + wrapClassName='action-modal' + visible={visible} + width={width} + onOk={this.handleOk} + confirmLoading={this.state.confirmLoading} + onCancel={this.handleCancel} + destroyOnClose + > + <MutilForm + BID={BID} + dict={this.state.dict} + menuType={this.props.menuType} + action={btnconfig} + inputSubmit={this.handleOk} + data={this.state.tabledata[0]} + BData={this.props.BData} + wrappedComponentRef={(inst) => this.formRef = inst} + /> + </Modal> + ) } - - if (btnconfig.setting.clickouter === 'close') { - clickouter = true - } - - return ( - <Modal - title={title} - maskClosable={clickouter} - getContainer={container} - wrapClassName='action-modal' - visible={visible} - width={width} - onOk={this.handleOk} - confirmLoading={this.state.confirmLoading} - onCancel={this.handleCancel} - destroyOnClose - > - <MutilForm - BID={BID} - dict={this.state.dict} - menuType={this.props.menuType} - action={btnconfig} - inputSubmit={this.handleOk} - data={this.state.tabledata[0]} - BData={this.props.BData} - wrappedComponentRef={(inst) => this.formRef = inst} - /> - </Modal> - ) } render() { const { btn, show, style } = this.props - const { loadingNumber, loading, visible } = this.state + const { loadingNumber, loading, disabled } = this.state if (show === 'actionList') { return <div style={{display: 'inline-block'}} onClick={(e) => e.stopPropagation()}> @@ -1671,10 +1781,11 @@ style={style} icon={btn.icon} loading={loading} + disabled={disabled} className={'mk-btn mk-' + btn.class} onClick={() => {this.actionTrigger()}} >{(loadingNumber ? `(${loadingNumber})` : '') + btn.label}</Button> - {visible ? this.getModels() : null} + {this.getModels()} </div> } else if (show && show.indexOf('plus') > -1) { return <div className="mk-btn-wrap"> @@ -1685,19 +1796,36 @@ style={{fontSize: show.substring(4) + 'px'}} onClick={() => {this.actionTrigger()}} ></Button> - {visible ? this.getModels() : null} + {this.getModels()} </div> } else { // icon銆乼ext銆� all 鍗$墖 + let label = '' + let icon = '' + + if (show === 'button') { + label = btn.label + icon = btn.icon || '' + } else if (show === 'link') { + label = <span>{btn.label}{btn.icon ? <Icon style={{marginLeft: '8px'}} type={btn.icon}/> : ''}</span> + icon = '' + } else if (show === 'icon') { + icon = btn.icon || '' + // } else if (show === 'text') { + } else { + label = btn.label + } + return <div style={{display: 'inline-block'}} onClick={(e) => e.stopPropagation()}> <Button type="link" title={show === 'icon' ? btn.label : ''} loading={loading} - style={btn.btnstyle || style} - icon={show === 'text' ? '' : (btn.icon || '')} + disabled={disabled} + style={btn.style || style} + icon={icon} onClick={() => {this.actionTrigger()}} - >{show === 'icon' && btn.icon ? '' : btn.label}</Button> - {visible ? this.getModels() : null} + >{label}</Button> + {this.getModels()} </div> } } -- Gitblit v1.8.0