From cb9ade2afd2a367ad767bc605ab7086c695dd010 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期五, 09 十二月 2022 15:53:32 +0800 Subject: [PATCH] 2022-12-09 --- src/tabviews/zshare/actionList/printbutton/index.jsx | 642 ++++++++++++++++++++++++++++++++++++++++++++------------- 1 files changed, 491 insertions(+), 151 deletions(-) diff --git a/src/tabviews/zshare/actionList/printbutton/index.jsx b/src/tabviews/zshare/actionList/printbutton/index.jsx index 6c14dd2..988c039 100644 --- a/src/tabviews/zshare/actionList/printbutton/index.jsx +++ b/src/tabviews/zshare/actionList/printbutton/index.jsx @@ -1,7 +1,6 @@ import React, {Component} from 'react' import PropTypes from 'prop-types' import moment from 'moment' -import {connect} from 'react-redux' import { is, fromJS } from 'immutable' import { Button, Modal, notification, message } from 'antd' @@ -22,17 +21,13 @@ class PrintButton extends Component { static propTpyes = { - show: PropTypes.any, // 鎸夐挳鏄剧ず鏍峰紡鎺у埗 BID: PropTypes.string, // 涓昏〃ID BData: PropTypes.any, // 涓昏〃鏁版嵁 selectedData: PropTypes.any, // 瀛愯〃涓�夋嫨鏁版嵁 - Tab: PropTypes.any, // 濡傛灉褰撳墠鍏冪礌涓烘爣绛炬椂锛宼ab涓烘爣绛句俊鎭� MenuID: PropTypes.string, // 鑿滃崟ID btn: PropTypes.object, // 鎸夐挳 setting: PropTypes.any, // 椤甸潰閫氱敤璁剧疆 - ContainerId: PropTypes.any, // tab椤甸潰ID锛岀敤浜庡脊绐楁帶鍒� disabled: PropTypes.any, // 琛屾寜閽鐢� - lineId: PropTypes.any, // 琛岀储寮�+涓婚敭鍊硷紝鐢ㄤ簬琛屾寜閽弻鍑� } state = { @@ -41,10 +36,10 @@ formdata: null, selines: null, btnconfig: null, + confirmLoading: false, loading: false, disabled: false, hidden: false, - loadingNumber: '', autoMatic: false } @@ -146,28 +141,21 @@ * @description 瑙﹀彂鎸夐挳鎿嶄綔 */ actionTrigger = (triggerId, record, type) => { - const { Tab, BID, btn, selectedData, setting } = this.props + const { BID, btn, selectedData, setting } = this.props const { loading, disabled } = this.state if (loading || disabled) return - if (triggerId) { - if (btn.uuid !== triggerId) return - if (this.props.lineId && record && record[0] && this.props.lineId !== record[0].$$key) { - return - } - } + if (triggerId && btn.uuid !== triggerId) return - if (((Tab && Tab.supMenu) || setting.supModule) && !BID) { + if (setting.supModule && !BID) { notification.warning({ top: 92, message: '闇�瑕佷笂绾т富閿�硷紒', duration: 5 }) return - } else if (type === 'linkbtn' && selectedData && selectedData.length === 1) { - if (record[0].$Index !== selectedData[0].$Index) { - return - } + } else if (type === 'linkbtn' && !btn.$toolbtn && !is(fromJS(selectedData || []), fromJS(record))) { + return } this.setState({autoMatic: type === 'autoMatic'}) @@ -195,11 +183,7 @@ // 鏁版嵁閫夋嫨绫诲瀷鏍¢獙 this.actionSettingError() return - } else if ( - !btn.verify || - (btn.verify.printMode === 'normal' && (!btn.verify.Template || !btn.verify.linkUrl)) || - (btn.verify.printMode === 'custom' && (!btn.verify.printFunc || !btn.verify.linkUrl)) - ) { + } else if (!btn.verify || !btn.verify.printMode) { notification.warning({ top: 92, message: '璇峰畬鍠勬墦鍗伴獙璇佷俊鎭紒', @@ -244,44 +228,93 @@ } } + triggerPrint = (data, formlist = []) => { + const { btn } = this.props + + if (btn.verify.printMode === 'RFID') { + this.triggerRFIDPrint(data, formlist) + } else { + this.triggerNormalPrint(data, formlist) + } + } + /** * @description 瑙﹀彂鎵撳嵃 */ - triggerPrint = (data, formlist = []) => { + triggerNormalPrint = (data, formlist) => { const { btn } = this.props let formdata = {} + let baseCount = 1 + let baseType = '' + let baseTemp = btn.verify.Template || '' formlist.forEach(_data => { formdata[_data.key] = _data.value + + if (!_data.value) return + + if (_data.key.toLowerCase() === 'printcount') { + baseCount = +_data.value + } else if (_data.key.toLowerCase() === 'printtype') { + baseType = _data.value + } else if (_data.key.toLowerCase() === 'templateid') { + baseTemp = _data.value + } }) let printlist = [] let templates = [] - let printCount = +(formdata.printCount || formdata.PrintCount || formdata.printcount || formdata.Printcount || 1) - if (isNaN(printCount) || printCount < 1) { - printCount = 1 + if (isNaN(baseCount) || baseCount < 1) { + baseCount = 1 } new Promise(resolve => { if (btn.intertype === 'system') { // 浣跨敤绯荤粺鏃讹紝鐩存帴浠庤〃鏍兼垨琛ㄥ崟涓�夊彇鏁版嵁 - let printcell = {} - - printcell.printType = formdata.printType || formdata.PrintType || formdata.printtype || formdata.Printtype || '' - printcell.printCount = printCount - printcell.templateID = btn.verify.Template || '' - if (btn.Ot === 'notRequired') { + let printcell = {} + + printcell.printType = baseType + printcell.printCount = baseCount + printcell.templateID = baseTemp printcell.data = [formdata] + + templates.push(printcell.templateID) + + printlist.push(printcell) } else { - printcell.data = data.map(cell => { - return {...cell, ...formdata} + data.forEach(cell => { + let _cell = {...cell, ...formdata} + + let printcell = {data: [_cell]} + + printcell.templateID = baseTemp + printcell.printType = baseType + printcell.printCount = 0 + + Object.keys(_cell).forEach(key => { + if (!_cell[key]) return + + let _key = key.toLowerCase() + + if (_key === 'templateid') { + printcell.templateID = _cell[key] + } else if (_key === 'printtype') { + printcell.printType = _cell[key] + } else if (_key === 'printcount') { + printcell.printCount = +_cell[key] + } + }) + + if (isNaN(printcell.printCount) || printcell.printCount < 1) { + printcell.printCount = baseCount + } + + templates.push(printcell.templateID) + + printlist.push(printcell) }) } - - templates.push(printcell.templateID) - - printlist.push(printcell) resolve(true) } else { @@ -291,16 +324,31 @@ // 绯荤粺鎵撳嵃鏁版嵁锛屾牎楠宒ata瀛楁 if (btn.verify.printMode !== 'custom' && (!cell.data || cell.data.length === 0)) return - 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 templateID = baseTemp + let printType = baseType + let printCount = 0 - let _printCount = +(cell.printCount || cell.PrintCount || cell.printcount || cell.Printcount || 0) + Object.keys(cell).forEach(key => { + if (!cell[key]) return - if (isNaN(_printCount) || _printCount < 1) { - _printCount = printCount + let _key = key.toLowerCase() + + if (_key === 'templateid') { + templateID = cell[key] + } else if (_key === 'printtype') { + printType = cell[key] + } else if (_key === 'printcount') { + printCount = +cell[key] + } + }) + + cell.templateID = templateID + cell.printType = printType + cell.printCount = printCount + + if (isNaN(cell.printCount) || cell.printCount < 1) { + cell.printCount = baseCount } - - cell.printCount = _printCount templates.push(cell.templateID) @@ -336,7 +384,7 @@ param.rduri = window.GLOB.mainSystemApi } - Api.getLocalConfig(param).then(result => { + Api.getSystemCacheConfig(param).then(result => { result.tempId = tempId resolve(result) }) @@ -406,6 +454,109 @@ } } else { this.execError(errorMsg) + } + }) + } + + /** + * @description 瑙﹀彂RFID鎵撳嵃 + */ + triggerRFIDPrint = (data, formlist) => { + const { btn } = this.props + let formdata = {} + let list = [] + + formlist.forEach(_data => { + formdata[_data.key] = _data.value + }) + + new Promise(resolve => { + if (btn.intertype === 'system') { // 浣跨敤绯荤粺鏃讹紝鐩存帴浠庤〃鏍兼垨琛ㄥ崟涓�夊彇鏁版嵁 + if (btn.Ot === 'notRequired') { + if (formlist.length > 0) { + list = [formdata] + } + } else { + data.forEach(cell => { + let _cell = {...cell, ...formdata} + list.push(_cell) + }) + } + + resolve(true) + } else { + this.getprintdata(btn, data, formdata, formlist).then(result => { + if (result.next) { + result.list.forEach(cell => { + // 绯荤粺鎵撳嵃鏁版嵁锛屾牎楠宒ata瀛楁 + if (!cell.data || cell.data.length === 0) return + + cell.data.forEach(m => { + let _cell = {...m, ...formdata} + list.push(_cell) + }) + }) + } + + resolve(result.next) + }) + } + }).then(res => { + // 鑾峰彇鎵撳嵃妯℃澘 getTemp + if (!res) return false + + if (list.length === 0) { + notification.warning({ + top: 92, + message: '鏈幏鍙栧埌鎵撳嵃鏁版嵁锛�', + duration: 5 + }) + return false + } + + let param = { + func: 's_PrintTemplateMGetData', + Type: 'Y', + // ID: tempId, // 娣诲姞妯℃澘鏃讹紝淇濆瓨鍙婃煡璇娇鐢ㄦā鏉垮弬鏁� + PrintTempNO: btn.verify.Template + } + + if (window.GLOB.mainSystemApi) { // 浠庡崟鐐圭櫥褰曟湇鍔″櫒鍙栨墦鍗伴厤缃俊鎭� + param.rduri = window.GLOB.mainSystemApi + } + + return Api.getSystemCacheConfig(param) + }).then(result => { + if (!result) { + this.setState({ loading: false }) + return + } + + if (!result.ConfigParam) { + notification.warning({ + top: 92, + message: '鏈幏鍙栧埌鎵撳嵃妯℃澘淇℃伅锛�', + duration: 5 + }) + this.setState({ loading: false }) + } else { + let configParam = '' + try { + configParam = JSON.parse(window.decodeURIComponent(window.atob(result.ConfigParam))) + } catch (e) { + configParam = '' + } + + if (!configParam) { + notification.warning({ + top: 92, + message: '鎵撳嵃妯℃澘瑙f瀽閿欒锛�', + duration: 5 + }) + this.setState({ loading: false }) + } else { + this.execRfidPrint(list, configParam) + } } }) } @@ -683,9 +834,16 @@ _param[setting.primaryKey] = cell[setting.primaryKey] } + let _cell = {} + if (index !== 0) { + Object.keys(cell).forEach(key => { + _cell[key.toLowerCase()] = cell[key] + }) + } + formlist.forEach(_data => { - if (index !== 0 && _data.readin && cell.hasOwnProperty(_data.key)) { - _param[_data.key] = cell[_data.key] + if (index !== 0 && _data.readin && _cell.hasOwnProperty(_data.key.toLowerCase())) { + _param[_data.key] = _cell[_data.key.toLowerCase()] } else { _param[_data.key] = _data.value } @@ -772,9 +930,11 @@ // 澶栭儴璇锋眰 _outParam = JSON.parse(JSON.stringify(res)) - if (this.props.menuType === 'HS') { + 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 @@ -783,13 +943,26 @@ } } } else { - if (btn.sysInterface === 'true' && window.GLOB.mainSystemApi) { - res.rduri = window.GLOB.mainSystemApi - } else if (btn.sysInterface !== 'true') { + 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 (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 } } } @@ -887,7 +1060,18 @@ if (!configParam) { error = '鎵撳嵃妯℃澘瑙f瀽閿欒锛�' } else { - let control = configParam.elements.map(element => { + let control = [] + let rotate = configParam.rotate || 0 + let offsetTop = 0 + let offsetLeft = 0 + + if (rotate === 90) { + offsetTop = configParam.width - configParam.height + } else if (rotate === 270) { + offsetLeft = configParam.height - configParam.width + } + + configParam.elements.forEach(element => { let _field = element.field if (_field === 'other_field') { @@ -899,11 +1083,12 @@ Type: element.type, Value: element.value || '', Field: _field, - Left: element.left, - Top: element.top, + Left: element.left + offsetLeft, + Top: element.top + offsetTop, Width: element.width, Height: element.height, - Rotate: element.rotate, + Rotate: rotate, + // Rotate: element.rotate, BorderSize: element.borderSize / 10, BorderColor: element.borderColor, Align: element.align, @@ -923,11 +1108,12 @@ item.Trimming = '' if (!item.Width) { item.Width = item.BorderSize - item.Left = item.Left - item.Width + item.Left = item.Left - item.Width + 0.1 } else if (!item.Height) { item.Height = item.BorderSize - item.Top = item.Top - item.Height + item.Top = item.Top - item.Height + 0.1 } + item.BackColor = element.borderColor item.BorderSize = 0 } else if (item.Type === 'image') { item.ImageWidth = element.imgWidth @@ -967,8 +1153,14 @@ } } - return item + control.push(item) }) + + let down = false + + if (rotate === 90 || rotate === 270) { + down = true + } _configparam = { Version: '', @@ -977,8 +1169,8 @@ Description: configParam.remark, PrintTempNO: configParam.PrintTempNO, PageSetting: { - Width: configParam.width, - Height: configParam.height, + Width: down ? configParam.height : configParam.width, + Height: down ? configParam.width : configParam.height, Left: '0', Right: '0', Top: '0', @@ -1004,10 +1196,153 @@ } } + execRfidPrint = (list, template) => { + const { btn } = this.props + + list = list.filter(item => !!item[btn.verify.valueField]) + + if (list.length === 0) { + notification.warning({ + top: 92, + message: '鏈幏鍙栧埌鎵撳嵃鏁版嵁锛�', + duration: 5 + }) + this.setState({ loading: false }) + return + } + + let width = template.width + let height = template.height + let gap = template.gap || 0 + let mm = 12 + + if (btn.verify.DPI === '203') { + mm = 8 + } else if (btn.verify.DPI === '600') { + mm = 24 + } + + let items = [] + template.elements.forEach(element => { + if (!['text', 'barcode', 'qrcode'].includes(element.type)) return + + let _field = element.field + + if (_field === 'other_field') { + _field = element.cusfield || '' + } + + let item = { + type: element.type, + value: element.value || '', + field: _field + } + + if (item.type === 'text') { + let size = Math.floor(4 * mm * (element.fontSize || 12) / 12) + let fontWeight = 400 + if (element.fontWeight === 'bold') { + fontWeight = 600 + } else if (element.fontWeight === 'bolder') { + fontWeight = 800 + } else if (element.fontWeight === 'lighter') { + fontWeight = 300 + } + item.draw = `${element.left * mm},${element.top * mm},${size},0,${element.fontFamily || '寰蒋闆呴粦'},${element.align === 'center' ? 5 : 1},${fontWeight},0,0,0,` + } else if (item.type === 'barcode') { + let codeType = 1 + if (element.barcodeType === 'EAN13') { + codeType = 'E30' + } + let narrowWidth = element.narrowWidth || 2 + let horizontal = element.narrowWidth || 2 + let vertical = Math.ceil(element.barcodeHeight * mm) + + item.draw = `${element.left * mm},${element.top * mm},0,${codeType},${narrowWidth},${horizontal},${vertical},${element.barcodeLabel === 'true' ? 'B' : 'N'},` + } else if (item.type === 'qrcode') { + let r = Math.ceil(element.qrcodeWidth / 2) + + item.draw = `${element.left * mm},${element.top * mm},0,0,0,${r},0,0,8,` + } + + items.push(item) + }) + + let ip = '192.168.1.2' + let params = list.map(cell => { + let array = [] + let value = cell[btn.verify.valueField] + + if (btn.verify.linkType !== 'USB') { + array.push({PTK_Connect_Timer: `${ip},${btn.verify.port},5`}); // 鎵撳紑鎵撳嵃鏈虹綉缁滅鍙� + } else { + array.push({PTK_OpenUSBPort: btn.verify.port}); // 鎵撳紑鎵撳嵃鏈篣SB绔彛 + } + + array.push({PTK_ClearBuffer: ''}); // 娓呯┖缂撳瓨 + array.push({PTK_SetDirection: 'B'}); // 璁剧疆鎵撳嵃鏂瑰悜 + array.push({PTK_SetLabelHeight: height * mm + ',' + gap * mm + ',' + 0 + ',' + false}); // 璁剧疆鏍囩楂樺害銆侀棿闅欏強鍋忕Щ + array.push({PTK_SetLabelWidth: width * mm}); // 璁剧疆鏍囩瀹藉害 + array.push({PTK_SetRFID: '0,0,0,0,0'}); // UHF RFID鎵撳嵃璁剧疆 + array.push({PTK_RWRFIDLabel: '1,0,0,4,1,' + value}); + + items.forEach(m => { + let val = '' + if (m.field) { + val = cell[m.field] + } else { + val = m.value + } + + if (!val && val !== 0) return + + if (m.type === 'text') { + array.push({PTK_DrawText_TrueType: m.draw + val}); + } else if (m.type === 'barcode') { + array.push({PTK_DrawBarcode: m.draw + val}); + } else if (m.type === 'qrcode') { + array.push({PTK_DrawBar2D_QR: m.draw + val}); + } + }) + + array.push({PTK_PrintLabel: '1,1'}); + array.push({PTK_CloseUSBPort: ''}); // 鍏抽棴USB閫氳绔彛 + + return { + reqParam: '1', + printparams: JSON.stringify(array) + } + }) + + this.loopRFIDPrint(params) + } + + loopRFIDPrint = (params) => { + let param = params.shift() + + Api.postekPrint(param).then(res => { + if (res.retval === '0') { + if (params.length === 0) { + this.execSuccess({ ErrCode: 'S', message: '', ErrMesg: '鎵撳嵃璇锋眰宸插彂鍑恒��', status: true }) + } else { + setTimeout(() => { + this.loopRFIDPrint(params) + }, 200) + } + } else { + if (res.retval === '30021') { + res.msg = res.msg.replace(/PTK_ClearBuffer[\s\S]*/, '') + } + + this.execError({ErrCode: 'N', message: res.msg}) + } + }) + } + execPrint = (list, template, formdata) => { const { btn } = this.props let _errors = [] - + let defaultPrinter = btn.verify.defaultPrinter || 'lackprinter' let printers = {} if (btn.verify.printerTypeList && btn.verify.printerTypeList.length > 0) { @@ -1108,12 +1443,21 @@ }) if (list.length === 0) { - this.execError({ - ErrCode: 'N', - message: '鏈幏鍙栧埌鎵撳嵃淇℃伅锛�', - ErrMesg: '', - status: false - }) + if (btn.verify.emptyTip === 'false') { + this.execSuccess({ + ErrCode: '-1', + message: '鏈幏鍙栧埌鎵撳嵃淇℃伅锛�', + ErrMesg: '', + status: true + }) + } else { + this.execError({ + ErrCode: 'N', + message: '鏈幏鍙栧埌鎵撳嵃淇℃伅锛�', + ErrMesg: '', + status: false + }) + } return } else if (_errors.length > 0) { let lackerror = [] @@ -1267,24 +1611,31 @@ */ execSuccess = (res) => { const { btn } = this.props - const { autoMatic } = this.state + const { autoMatic, btnconfig } = this.state - if ((res && (res.ErrCode === 'S' || !res.ErrCode)) || autoMatic) { // 鎵ц鎴愬姛 + if ((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') { // 鎵ц鎴愬姛 + } else if (res.ErrCode === 'Y') { // 鎵ц鎴愬姛 Modal.success({ title: res.ErrMesg || this.state.dict['main.action.confirm.success'] }) - } else if (res && res.ErrCode === '-1') { // 瀹屾垚鍚庝笉鎻愮ず + } else if (res.ErrCode === '-1') { // 瀹屾垚鍚庝笉鎻愮ず } + if (autoMatic || !btnconfig || btnconfig.setting.finish !== 'unclose') { + this.setState({ + visible: false + }) + } + this.setState({ - loading: false + loading: false, + confirmLoading: false }) if (autoMatic) { @@ -1329,7 +1680,8 @@ } this.setState({ - loading: false + loading: false, + confirmLoading: false }) if (autoMatic) { @@ -1364,8 +1716,7 @@ 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 } @@ -1449,16 +1800,10 @@ * @description 妯℃�佹锛堣〃鍗曪級锛岀‘璁� */ handleOk = () => { - const { btnconfig, autoMatic } = this.state - if (!this.formRef) return this.formRef.handleConfirm().then(res => { - if (btnconfig.setting.finish !== 'unclose' || autoMatic) { - this.setState({ - visible: false - }) - } + this.setState({ confirmLoading: true }) this.triggerPrint(this.state.selines, res) }) } @@ -1469,15 +1814,28 @@ handleCancel = () => { this.setState({ loading: false, - visible: false + visible: false, + confirmLoading: false }) } modelconfirm = () => { - const { BData } = this.props const { btnconfig, selines } = this.state let _this = this let result = [] + let _data = {} + let BData = {} + + if (selines[0]) { + Object.keys(selines[0]).forEach(key => { + _data[key.toLowerCase()] = selines[0][key] + }) + } + if (this.props.BData) { + Object.keys(this.props.BData).forEach(key => { + BData[key.toLowerCase()] = this.props.BData[key] + }) + } btnconfig.fields.forEach(item => { if (!item.field) return @@ -1488,10 +1846,10 @@ _readin = false } - if (item.type === 'linkMain' && BData && BData.hasOwnProperty(item.field)) { - _initval = BData[item.field] - } else if (_readin && selines[0] && selines[0].hasOwnProperty(item.field)) { - _initval = selines[0][item.field] + 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) { @@ -1558,22 +1916,19 @@ * @description 鏄剧ず妯℃�佹 */ getModels = () => { - const { setting, BID, btn } = this.props + const { BID, btn } = this.props const { btnconfig } = this.state if (!this.state.visible || !btnconfig || !btnconfig.setting) return null - let title = btnconfig.setting.title + let title = btn.label let width = btnconfig.setting.width > 100 ? btnconfig.setting.width : btnconfig.setting.width + 'vw' let clickouter = false let container = document.body - if ( - (setting.tabType === 'main' && btnconfig.setting.container === 'tab' && this.props.ContainerId) || - (btnconfig.setting.container === 'tab' && btn.ContainerId) - ) { + if (btnconfig.setting.container === 'tab' && btn.ContainerId) { width = btnconfig.setting.width > 100 ? btnconfig.setting.width : btnconfig.setting.width + '%' - container = () => document.getElementById(this.props.ContainerId || btn.ContainerId) + container = () => document.getElementById(btn.ContainerId) } if (btnconfig.setting.clickouter === 'close') { @@ -1587,6 +1942,7 @@ getContainer={container} wrapClassName='action-modal' visible={this.state.visible} + confirmLoading={this.state.confirmLoading} width={width} onOk={this.handleOk} onCancel={this.handleCancel} @@ -1595,7 +1951,6 @@ <MutilForm BID={BID} dict={this.state.dict} - menuType={this.props.menuType} action={btnconfig} inputSubmit={this.handleOk} data={this.state.selines[0]} @@ -1607,64 +1962,49 @@ } render() { - const { btn, show } = this.props - const { loadingNumber, loading, disabled, hidden } = this.state + const { btn } = this.props + const { loading, disabled, hidden } = this.state if (hidden) return null - if (show === 'actionList') { - return <div style={{display: 'inline-block'}} onClick={(e) => e.stopPropagation()}> - <Button - icon={btn.icon} - loading={loading} - disabled={disabled} - title={disabled ? (btn.reason || '') : ''} - className={'mk-btn mk-' + btn.class} - onClick={() => {this.actionTrigger()}} - >{loadingNumber ? `(${loadingNumber})` : '' + btn.label}</Button> - {this.getModels()} - </div> - } else { // icon銆乼ext銆� all 鍗$墖 - let label = '' - let icon = '' + let label = '' + let icon = '' + let type = 'link' + let className = '' - if (show === 'button') { - label = btn.label - icon = btn.icon || '' - } else if (show === 'link') { - label = <span>{btn.label}{btn.icon ? <MkIcon 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={disabled ? (btn.reason || '') : (show === 'icon' ? btn.label : '')} - loading={loading} - disabled={disabled} - style={btn.style} - icon={icon} - onClick={() => {this.actionTrigger()}} - >{label}</Button> - {this.getModels()} - </div> + if (btn.show === 'button') { + label = btn.label + icon = btn.icon || '' + } else if (btn.show === 'link') { + label = <span>{btn.label}{btn.icon ? <MkIcon style={{marginLeft: '8px'}} type={btn.icon}/> : ''}</span> + icon = '' + } else if (btn.show === 'icon') { + icon = btn.icon || '' + } else if (!btn.$toolbtn) { + icon = btn.icon || '' + label = btn.label + className = 'mk-btn mk-' + btn.class + } else { + type = '' + icon = btn.icon || '' + label = btn.label + className = 'mk-btn mk-' + btn.class } + + return <> + <Button + type={type} + title={disabled ? (btn.reason || '') : (btn.show === 'icon' ? btn.label : '')} + loading={loading} + disabled={disabled} + style={btn.style || null} + icon={icon} + className={className} + onClick={(e) => {e.stopPropagation(); this.actionTrigger()}} + >{label}</Button> + <span onClick={(e) => {e.stopPropagation()}}>{this.getModels()}</span> + </> } } -const mapStateToProps = (state) => { - return { - menuType: state.editLevel - } -} - -const mapDispatchToProps = () => { - return {} -} - -export default connect(mapStateToProps, mapDispatchToProps)(PrintButton) \ No newline at end of file +export default PrintButton \ No newline at end of file -- Gitblit v1.8.0