From e5fc2d92b1036aabf9ffc2c9706ed401bd9735c8 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期四, 09 九月 2021 18:14:29 +0800 Subject: [PATCH] 2021-09-09 --- src/tabviews/zshare/actionList/printbutton/index.jsx | 586 ++++++++++++++++++++++++++++++++++++++++++---------------- 1 files changed, 421 insertions(+), 165 deletions(-) diff --git a/src/tabviews/zshare/actionList/printbutton/index.jsx b/src/tabviews/zshare/actionList/printbutton/index.jsx index d7c2078..95a955f 100644 --- a/src/tabviews/zshare/actionList/printbutton/index.jsx +++ b/src/tabviews/zshare/actionList/printbutton/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, Icon } from 'antd' import Api from '@/api' import Utils 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' @@ -21,6 +22,7 @@ class PrintButton extends Component { static propTpyes = { show: PropTypes.any, // 鎸夐挳鏄剧ず鏍峰紡鎺у埗 + position: PropTypes.any, // 鎸夐挳浣嶇疆锛屽伐鍏锋爮涓簍oolbar BID: PropTypes.string, // 涓昏〃ID BData: PropTypes.any, // 涓昏〃鏁版嵁 selectedData: PropTypes.any, // 瀛愯〃涓�夋嫨鏁版嵁 @@ -29,7 +31,6 @@ btn: PropTypes.object, // 鎸夐挳 setting: PropTypes.any, // 椤甸潰閫氱敤璁剧疆 ContainerId: PropTypes.any, // tab椤甸潰ID锛岀敤浜庡脊绐楁帶鍒� - updateStatus: PropTypes.func, // 鎸夐挳鐘舵�佹洿鏂� } state = { @@ -39,7 +40,23 @@ tabledata: null, btnconfig: null, loading: false, + disabled: false, loadingNumber: '' + } + + 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) { @@ -47,10 +64,28 @@ } componentDidMount () { - const { show } = this.props + const { position } = this.props - if (show === 'actionList') { + if (position === 'toolbar') { MKEmitter.addListener('triggerBtnId', this.actionTrigger) + } + } + + 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}) } } @@ -79,13 +114,13 @@ /** * @description 瑙﹀彂鎸夐挳鎿嶄綔 */ - actionTrigger = (triggerId) => { - const { setting, Tab, BID, btn, selectedData } = this.props + actionTrigger = (triggerId, record) => { + 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: '闇�瑕佷笂绾т富閿�硷紒', @@ -95,7 +130,7 @@ } let _this = this - let data = selectedData || [] + let data = record || selectedData || [] if (btn.Ot !== 'notRequired' && data.length === 0) { // 闇�瑕侀�夋嫨琛屾椂锛屾牎楠屾暟鎹� @@ -110,14 +145,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 @@ -140,8 +167,14 @@ if (btn.execMode === 'pop') { this.updateStatus('start') + let modal = this.state.btnconfig + if (!modal && btn.modal) { + modal = this.handleModelConfig(btn.modal) + } + this.setState({ - tabledata: data + tabledata: data, + btnconfig: modal }, () => { this.improveAction() }) @@ -159,6 +192,10 @@ } else { this.triggerPrint(data) } + + if (window.GLOB.systemType === 'production') { + MKEmitter.emit('queryTrigger', {menuId: btn.uuid, name: '鏍囩鎵撳嵃'}) + } } /** @@ -174,17 +211,17 @@ let printlist = [] let templates = [] - let printCount = 1 + let printCount = +(formdata.printCount || formdata.PrintCount || formdata.printcount || formdata.Printcount || 1) - if (formdata.printCount && typeof(formdata.printCount) === 'number' && formdata.printCount >= 1) { - printCount = formdata.printCount + if (isNaN(printCount) || printCount < 1) { + printCount = 1 } new Promise(resolve => { if (btn.intertype === 'system') { // 浣跨敤绯荤粺鏃讹紝鐩存帴浠庤〃鏍兼垨琛ㄥ崟涓�夊彇鏁版嵁 let printcell = {} - printcell.printType = formdata.printType || '' + printcell.printType = formdata.printType || formdata.PrintType || formdata.printtype || formdata.Printtype || '' printcell.printCount = printCount printcell.templateID = btn.verify.Template || '' @@ -208,12 +245,13 @@ // 绯荤粺鎵撳嵃鏁版嵁锛屾牎楠宒ata瀛楁 if (btn.verify.printMode !== 'custom' && (!cell.data || cell.data.length === 0)) return - cell.templateID = cell.templateID || btn.verify.Template - cell.printType = cell.printType || formdata.printType || '' + cell.templateID = cell.templateID || cell.TemplateID || cell.Templateid || cell.templateid || btn.verify.Template + cell.printType = cell.printType || cell.PrintType || cell.printtype || cell.Printtype || formdata.printType || formdata.PrintType || formdata.printtype || formdata.Printtype || '' - let _printCount = printCount - if (cell.printCount && typeof(cell.printCount) === 'number' && cell.printCount >= 1) { - _printCount = cell.printCount + let _printCount = +(cell.printCount || cell.PrintCount || cell.printcount || cell.Printcount || 0) + + if (isNaN(_printCount) || _printCount < 1) { + _printCount = printCount } cell.printCount = _printCount @@ -265,6 +303,7 @@ let errorMsg = '' let _temps = {} + let images = [] result.forEach(res => { if (res.status && !errorMsg) { @@ -278,6 +317,7 @@ status: false } } else { + images = [...images, ..._temp.imgs] _temps[res.tempId] = _temp } } else if (!errorMsg) { @@ -286,7 +326,38 @@ }) if (!errorMsg) { - this.execPrint(printlist, _temps, formdata) + if (images.length > 0) { + let errorUrls = [] + images.forEach(url => { + let img = new Image() + img.onerror = () => { + errorUrls.push(url) + } + img.src = url + }) + + setTimeout(() => { + if (errorUrls.length > 0) { + notification.warning({ + top: 92, + message: '妯℃澘涓浘鐗� ' + errorUrls.join('锛�') + ' 宸插け鏁堬紒', + duration: 5 + }) + Object.keys(_temps).forEach(key => { + _temps[key].config.ReportHeader.Control = _temps[key].config.ReportHeader.Control.map(item => { + if (item.Type === 'image' && errorUrls.includes(item.Value)) { + item.Value = '' + } + return item + }) + }) + } + + this.execPrint(printlist, _temps, formdata) + }, 500) + } else { + this.execPrint(printlist, _temps, formdata) + } } else { this.execError(errorMsg) } @@ -310,6 +381,186 @@ // eslint-disable-next-line let func = new Function('data', 'form', 'printer', 'notification', btn.verify.printFunc) func(printlist, formdata, btn.verify, notification) + + // 鑷畾涔夋墦鍗扮ず渚� + // let defaultPrinter = printer.defaultPrinter || 'lackprinter' + // let printers = {} + // let getuuid = () => { + // let uuid = [] + // let _options = '0123456789abcdefghigklmnopqrstuv' + // for (let i = 0; i < 32; i++) { + // uuid.push(_options.substr(Math.floor(Math.random() * 0x20), 1)) + // } + // uuid = uuid.join('') + // return uuid + // } + // if (printer.printerTypeList && printer.printerTypeList.length > 0) { + // printer.printerTypeList.forEach(cell => { + // if (cell.printer) { + // printers[cell.Value] = cell.printer + // } + // }) + // } + + // let jdList = [] + // let otherList = [] + // data.forEach(item => { + // if (item.CustomData) { + // item.CustomData = JSON.parse(item.CustomData.replace(/\n/g,"\\n").replace(/\r/g,"\\r")) + // } + // if (item.PrintData) { + // item.PrintData = JSON.parse(item.PrintData.replace(/\n/g,"\\n").replace(/\r/g,"\\r")) + // item.PrintData.data = {...form, ...item.PrintData.data} + // } + + // if (!item.PrintData) { + // return + // } + + // if (item.PrintData.ectype === 'jdpop') { + // jdList.push(item) + // } else { + // otherList.push(item) + // } + // }) + + // if (jdList.length === 0 && otherList.length === 0) { + // notification.warning({ + // top: 92, + // message: '鏃犳墦鍗版暟鎹紒', + // duration: 5 + // }) + // return + // } + + // let execPrint = (list, linkUrl) => { + // let printdata = {} + + // list.forEach(res => { + // let _printer = defaultPrinter + + // if (res.printType && printers[res.printType]) { + // _printer = printers[res.printType] + // } + + // printdata[_printer] = printdata[_printer] || [] + + // printdata[_printer].push(res) + // }) + + // let printerList = [] + + // Object.keys(printdata).forEach(printer => { + // let _documents = [] + // printdata[printer].forEach(item => { + // let _cell = { + // documentID: getuuid(), + // contents: [] + // } + + // if (item.PrintData) { + // _cell.contents.push(item.PrintData) + // } + // if (item.CustomData) { + // _cell.contents.push(item.CustomData) + // } + + // for (let i = 0; i < item.printCount; i++) { + // _documents.push(_cell) + // } + // }) + // printerList.push({ + // cmd: 'print', + // requestID: '', + // version: '', + // task: { + // taskID: getuuid(), + // preview: false, + // printer: printer, + // documents: _documents + // } + // }) + // }) + + // let lackItems = printerList.filter(cell => cell.task.printer === 'lackprinter')[0] + + // let socket = new WebSocket('ws://' + linkUrl) + + // // 鎵撳紑Socket + // socket.onopen = () =>{ + // if (lackItems) { + // let request = { + // requestID: '', + // version: '', + // cmd: 'getPrinters' + // } + // socket.send(JSON.stringify(request)) + // } else { + // printerList.forEach(cell => { + // socket.send(JSON.stringify(cell).replace(/\\r/g,"\r").replace(/\\n/g,"\n")) + // }) + + // notification.success({ + // top: 92, + // message: '鎵撳嵃璇锋眰宸插彂鍑恒��', + // duration: 2 + // }) + // } + // } + // // 鐩戝惉娑堟伅 + // socket.onmessage = (event) => { + // let data = '' + + // if (event.data) { + // try { + // data = JSON.parse(event.data) + // } catch (e) { + // notification.warning({ + // top: 92, + // message: event.data, + // duration: 10 + // }) + // data = '' + // } + // } + + // if (data && data.cmd === 'getPrinters' && data.status) { + // printerList.forEach(cell => { + // if (cell.task.printer === 'lackprinter') { + // cell.task.printer = data.defaultPrinter + // } + // socket.send(JSON.stringify(cell).replace(/\\r/g,"\r").replace(/\\n/g,"\n")) + // }) + + // notification.success({ + // top: 92, + // message: '鎵撳嵃璇锋眰宸插彂鍑恒��', + // duration: 2 + // }) + // } else if (data && data.message && !data.status) { + // notification.warning({ + // top: 92, + // message: data.message, + // duration: 10 + // }) + // } + // } + + // socket.onerror = () => { + // notification.warning({ + // top: 92, + // message: '鏃犳硶杩炴帴鍒�:' + linkUrl, + // duration: 10 + // }) + // } + // } + + // if (jdList.length > 0) { + // execPrint(jdList, '127.0.0.1:13529') + // } + // if (otherList.length > 0) { + // execPrint(otherList, '127.0.0.1:13528') + // } } catch (e) { console.warn(e) @@ -347,17 +598,21 @@ let _param = { ...param, ...formdata } params.push(_param) } else if (btn.Ot === 'requiredSgl') { - param[setting.primaryKey] = data[0][setting.primaryKey] + if (setting.primaryKey) { + param[setting.primaryKey] = data[0][setting.primaryKey] + } let _param = { ...param, ...formdata } params.push(_param) } else if (btn.Ot === 'requiredOnce') { - let ids = data.map(d => { return d[setting.primaryKey]}) - ids = ids.filter(Boolean) - ids = ids.join(',') - - param[setting.primaryKey] = ids + if (setting.primaryKey) { + let ids = data.map(d => { return d[setting.primaryKey]}) + ids = ids.filter(Boolean) + ids = ids.join(',') + + param[setting.primaryKey] = ids + } let _param = { ...param, ...formdata } @@ -365,7 +620,10 @@ } else if (btn.Ot === 'required') { params = data.map((cell, index) => { let _param = { ...param } - _param[setting.primaryKey] = cell[setting.primaryKey] + + if (setting.primaryKey) { + _param[setting.primaryKey] = cell[setting.primaryKey] + } formlist.forEach(_data => { if (index !== 0 && _data.readin && cell.hasOwnProperty(_data.key)) { @@ -460,13 +718,21 @@ if (btn.sysInterface === 'true' && options.cloudServiceApi) { res.rduri = options.cloudServiceApi } else if (btn.sysInterface !== 'true') { - res.rduri = btn.interface + if (window.GLOB.systemType === 'production' && btn.proInterface) { + res.rduri = btn.proInterface + } else { + res.rduri = btn.interface + } } } else { if (btn.sysInterface === 'true' && window.GLOB.mainSystemApi) { res.rduri = window.GLOB.mainSystemApi } else if (btn.sysInterface !== 'true') { - res.rduri = btn.interface + if (window.GLOB.systemType === 'production' && btn.proInterface) { + res.rduri = btn.proInterface + } else { + res.rduri = btn.interface + } } } @@ -549,6 +815,7 @@ let _configparam = '' // 鎵撳嵃閰嶇疆淇℃伅 let fields = [] // 妯℃澘涓墍闇�瀛楁 let nonEFields = [] // 闈炵┖瀛楁 + let imgs = [] if (!res.ConfigParam) { error = '鏈幏鍙栧埌鎵撳嵃妯℃澘淇℃伅锛�' @@ -562,7 +829,6 @@ if (!configParam) { error = '鎵撳嵃妯℃澘瑙f瀽閿欒锛�' } else { - let control = configParam.elements.map(element => { let _field = element.field @@ -609,6 +875,12 @@ item.ImageWidth = element.imgWidth item.ImageHeight = element.imgHeight item.Trimming = '' + if (element.productValue && window.GLOB.systemType === 'production') { + item.Value = element.productValue + imgs.push(item.Value) + } else if (item.Value) { + imgs.push(item.Value) + } } else if (item.Type === 'text') { item.FontFamily = element.fontFamily item.FontSize = element.fontSize @@ -669,7 +941,8 @@ error: error, config: _configparam, fields: fields, - nonEFields: nonEFields + nonEFields: nonEFields, + imgs: imgs } } @@ -768,7 +1041,7 @@ task: { taskID: Utils.getuuid(), preview: false, - printer: printer, + printer: printer === 'lackprinter' ? '' : printer, documents: [_cell] } }) @@ -815,19 +1088,19 @@ return } - let lackItems = printerList.filter(cell => cell.task.printer === 'lackprinter')[0] + // let lackItems = printerList.filter(cell => cell.task.printer === 'lackprinter')[0] if (!socket || socket.readyState !== 1 || socket.url !== 'ws://' + btn.verify.linkUrl) { socket = new WebSocket('ws://' + btn.verify.linkUrl) } else { - if (lackItems) { - let request = { - requestID: '', - version: '', - cmd: 'getPrinters' - } - socket.send(JSON.stringify(request)) - } else { + // if (lackItems) { + // let request = { + // requestID: '', + // version: '', + // cmd: 'getPrinters' + // } + // socket.send(JSON.stringify(request)) + // } else { this.syncMessageSend(printerList) this.execSuccess({ @@ -836,19 +1109,19 @@ ErrMesg: '鎵撳嵃璇锋眰宸插彂鍑恒��', status: true }) - } + // } } // 鎵撳紑Socket socket.onopen = () =>{ - if (lackItems) { - let request = { - requestID: '', - version: '', - cmd: 'getPrinters' - } - socket.send(JSON.stringify(request)) - } else { + // if (lackItems) { + // let request = { + // requestID: '', + // version: '', + // cmd: 'getPrinters' + // } + // socket.send(JSON.stringify(request)) + // } else { this.syncMessageSend(printerList) this.execSuccess({ @@ -857,7 +1130,7 @@ ErrMesg: '鎵撳嵃璇锋眰宸插彂鍑恒��', status: true }) - } + // } } // 鐩戝惉娑堟伅 socket.onmessage = (event) => { @@ -866,7 +1139,7 @@ if (event.data) { try { data = JSON.parse(event.data) - } catch { + } catch (e) { this.execError({ ErrCode: 'N', message: event.data, @@ -878,23 +1151,24 @@ } } - if (data && data.cmd === 'getPrinters' && data.status) { - printerList = printerList.map(cell => { - if (cell.task.printer === 'lackprinter') { - cell.task.printer = data.defaultPrinter - } - return cell - }) + // if (data && data.cmd === 'getPrinters' && data.status) { + // printerList = printerList.map(cell => { + // if (cell.task.printer === 'lackprinter') { + // cell.task.printer = data.defaultPrinter + // } + // return cell + // }) - this.syncMessageSend(printerList) + // this.syncMessageSend(printerList) - this.execSuccess({ - ErrCode: 'S', - message: '', - ErrMesg: '鎵撳嵃璇锋眰宸插彂鍑恒��', - status: true - }) - } else if (data && data.message && !data.status) { + // this.execSuccess({ + // ErrCode: 'S', + // message: '', + // ErrMesg: '鎵撳嵃璇锋眰宸插彂鍑恒��', + // status: true + // }) + // } else if (data && data.message && !data.status) { + if (data && data.message && !data.status) { this.execError({ ErrCode: 'N', message: data.message, @@ -954,7 +1228,9 @@ loading: false }) - this.props.updateStatus('refresh', btn.execSuccess) + if (btn.execSuccess !== 'never') { + MKEmitter.emit('refreshByButtonResult', btn.$menuId, btn.execSuccess, btn) + } } /** @@ -991,7 +1267,9 @@ loading: false }) - this.props.updateStatus('refresh', btn.execError) + if (btn.execError !== 'never') { + MKEmitter.emit('refreshByButtonResult', btn.$menuId, btn.execError, btn) + } } /** @@ -1003,6 +1281,29 @@ message: this.state.dict['main.action.settingerror'], duration: 5 }) + } + + 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 } /** @@ -1043,7 +1344,7 @@ duration: 5 }) this.updateStatus('over') - } else if (!_LongParam || (btn.OpenType === 'pop' && _LongParam.type !== 'Modal')) { + } else if (!_LongParam || (btn.execMode === 'pop' && _LongParam.type !== 'Modal')) { notification.warning({ top: 92, message: '鏈幏鍙栧埌鎸夐挳閰嶇疆淇℃伅锛�', @@ -1051,71 +1352,8 @@ }) this.updateStatus('over') } else { - 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 (this.props.dataManager) { // 鏁版嵁鏉冮檺 - _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 - - let _black = cell.blacklist.filter(v => { - return this.props.permRoles.indexOf(v) !== -1 - }) - - if (_black.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 (this.props.dataManager) { // 鏁版嵁鏉冮檺 - _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 - - let _black = cell.blacklist.filter(v => { - return this.props.permRoles.indexOf(v) !== -1 - }) - - if (_black.length > 0) { - cell.hidden = 'true' - } - - return cell - }) - } + _LongParam = updateForm(_LongParam) + _LongParam = this.handleModelConfig(_LongParam) this.setState({ btnconfig: _LongParam @@ -1159,17 +1397,10 @@ const { BData } = this.props const { btnconfig, tabledata } = this.state let _this = this - let _fields = [] + let result = [] - if (btnconfig.groups.length > 0) { - btnconfig.groups.forEach(group => { - _fields = [..._fields, ...group.sublist] - }) - } else { - _fields = btnconfig.fields - } - - let result = _fields.map(item => { + btnconfig.fields.forEach(item => { + if (!item.field) return let _readin = item.readin !== 'false' let _initval = item.initval @@ -1196,14 +1427,18 @@ _fieldlen = item.decimal ? item.decimal : 0 } - return { + if (_initval === undefined) { + _initval = '' + } + + result.push({ key: item.field, readonly: item.readonly === 'true', readin: _readin, fieldlen: _fieldlen, type: item.type, value: _initval - } + }) }) confirm({ @@ -1221,7 +1456,7 @@ * @description 鏄剧ず妯℃�佹 */ getModels = () => { - const { setting, BID } = this.props + const { setting, BID, btn } = this.props const { btnconfig } = this.state if (!this.state.visible || !btnconfig || !btnconfig.setting) return null @@ -1231,9 +1466,12 @@ let clickouter = false let container = document.body - if (setting.tabType === 'main' && btnconfig.setting.container === 'tab' && this.props.ContainerId) { + 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) + container = () => document.getElementById(this.props.ContainerId || btn.ContainerId) } if (btnconfig.setting.clickouter === 'close') { @@ -1268,26 +1506,46 @@ render() { const { btn, show } = this.props - const { loadingNumber, loading } = this.state + const { loadingNumber, loading, disabled } = this.state if (show === 'actionList') { - return <div style={{display: 'inline-block'}}> + return <div style={{display: 'inline-block'}} onClick={(e) => e.stopPropagation()}> <Button icon={btn.icon} loading={loading} + disabled={disabled} className={'mk-btn mk-' + btn.class} onClick={() => {this.actionTrigger()}} >{loadingNumber ? `(${loadingNumber})` : '' + btn.label}</Button> {this.getModels()} </div> } else { // icon銆乼ext銆� all 鍗$墖 - return <div style={{display: 'inline-block'}}> + 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} - icon={show === 'text' ? '' : (btn.icon || '')} + disabled={disabled} + style={btn.style} + icon={icon} onClick={() => {this.actionTrigger()}} - >{show === 'icon' && btn.icon ? '' : btn.label}</Button> + >{label}</Button> {this.getModels()} </div> } @@ -1297,9 +1555,7 @@ const mapStateToProps = (state) => { return { tabviews: state.tabviews, - menuType: state.editLevel, - permRoles: state.permRoles, - dataManager: state.dataManager + menuType: state.editLevel } } -- Gitblit v1.8.0