From b48528b1a1a88e289fc0b7ad52f2da213a3f9dfe Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期三, 23 四月 2025 16:34:38 +0800 Subject: [PATCH] Merge branch 'develop' --- src/tabviews/zshare/settingcomponent/index.jsx | 173 ++++++++++++++++++++++++++++++++++----------------------- 1 files changed, 102 insertions(+), 71 deletions(-) diff --git a/src/tabviews/zshare/settingcomponent/index.jsx b/src/tabviews/zshare/settingcomponent/index.jsx index e5820fb..f2e08de 100644 --- a/src/tabviews/zshare/settingcomponent/index.jsx +++ b/src/tabviews/zshare/settingcomponent/index.jsx @@ -1,12 +1,11 @@ import React, {Component} from 'react' import PropTypes from 'prop-types' import { is, fromJS } from 'immutable' -import { Button, Modal, notification, Spin, Empty } from 'antd' +import { Button, Modal, notification, Spin, Empty, Tooltip } from 'antd' import Api from '@/api' import MKEmitter from '@/utils/events.js' -import UtilsUpdate from '@/utils/utils-update.js' -import options from '@/store/options.js' +import { updateSubTable } from '@/utils/utils-update.js' import asyncComponent from '@/utils/asyncSpinComponent' import './index.scss' @@ -14,10 +13,8 @@ class CustomSetting extends Component { static propTpyes = { - dict: PropTypes.object, // 瀛楀吀琛� config: PropTypes.object, // 椤甸潰閰嶇疆淇℃伅 shortcuts: PropTypes.any, // 鑷畾涔夎缃� - permAction: PropTypes.object, // 鎸夐挳鏉冮檺 } state = { @@ -25,6 +22,8 @@ components: null, // 缁勪欢闆嗗悎 revertLoading: false, // 鎭㈠榛樿璁剧疆 confirmLoading: false, // 鑷畾涔夎缃ā鎬佹鍔犺浇涓� + dict: window.GLOB.dict, + lang: sessionStorage.getItem('lang') } shouldComponentUpdate (nextProps, nextState) { @@ -42,7 +41,7 @@ if (config.Template === 'CommonTable' || config.Template === 'TreePage') { this.getPageConfig() - } else if (config.Template === 'CustomPage') { + } else if (config.Template === 'CustomPage' || config.Template === 'BaseTable') { this.getCustomPageConfig() } else { notification.warning({ @@ -83,8 +82,9 @@ if (cell.OpenType === 'funcbutton' && cell.funcType === 'print') { cell.$port = cell.verify ? cell.verify.linkUrl : '' - if (cell.verify && cell.verify.printerTypeList) { + if (cell.verify && cell.verify.printerTypeList && cell.verify.printerTypeList.length > 0) { cell.verify.printerTypeList = cell.verify.printerTypeList.map(_cell => { + _cell.uuid = _cell.uuid || _cell.key _cell.parentId = cell.uuid _cell.$port = cell.$port @@ -98,7 +98,7 @@ _comp.action.push({...cell, ...(userConfig[cell.uuid] || {})}) }) - if (item.type === 'card' || (item.type === 'table' && item.subtype === 'tablecard')) { + if (item.type === 'card') { item.subcards.forEach(card => { card.elements && card.elements.forEach(cell => { if (cell.eleType !== 'button') return @@ -106,8 +106,9 @@ if (cell.OpenType === 'funcbutton' && cell.funcType === 'print') { cell.$port = cell.verify ? cell.verify.linkUrl : '' - if (cell.verify && cell.verify.printerTypeList) { + if (cell.verify && cell.verify.printerTypeList && cell.verify.printerTypeList.length > 0) { cell.verify.printerTypeList = cell.verify.printerTypeList.map(_cell => { + _cell.uuid = _cell.uuid || _cell.key _cell.parentId = cell.uuid _cell.$port = cell.$port @@ -118,7 +119,7 @@ printbtns.push(cell) } - _comp.action.push({...cell, ...(userConfig[cell.uuid] || {})}) + _comp.action.push({...cell, $line: true, ...(userConfig[cell.uuid] || {})}) }) card.backElements && card.backElements.forEach(cell => { if (cell.eleType !== 'button') return @@ -126,8 +127,9 @@ if (cell.OpenType === 'funcbutton' && cell.funcType === 'print') { cell.$port = cell.verify ? cell.verify.linkUrl : '' - if (cell.verify && cell.verify.printerTypeList) { + if (cell.verify && cell.verify.printerTypeList && cell.verify.printerTypeList.length > 0) { cell.verify.printerTypeList = cell.verify.printerTypeList.map(_cell => { + _cell.uuid = _cell.uuid || _cell.key _cell.parentId = cell.uuid _cell.$port = cell.$port @@ -138,32 +140,40 @@ printbtns.push(cell) } - _comp.action.push({...cell, ...(userConfig[cell.uuid] || {})}) + _comp.action.push({...cell, $line: true, ...(userConfig[cell.uuid] || {})}) }) }) - } else if (item.type === 'table' && item.subtype === 'normaltable') { - item.cols && item.cols.forEach(col => { - if (col.type !== 'action') return - col.elements && col.elements.forEach(cell => { - cell.$expanded = false - if (cell.OpenType === 'funcbutton' && cell.funcType === 'print') { + } else if (item.type === 'table') { + let loopCol = (cols) => { + cols.forEach(col => { + if (col.type === 'colspan') { + loopCol(col.subcols) + } else if (col.type === 'custom') { + col.elements.forEach(cell => { + if (cell.eleType !== 'button') return + cell.$expanded = false + if (cell.OpenType === 'funcbutton' && cell.funcType === 'print') { - cell.$port = cell.verify ? cell.verify.linkUrl : '' - if (cell.verify && cell.verify.printerTypeList) { - cell.verify.printerTypeList = cell.verify.printerTypeList.map(_cell => { - _cell.parentId = cell.uuid - _cell.$port = cell.$port + cell.$port = cell.verify ? cell.verify.linkUrl : '' + if (cell.verify && cell.verify.printerTypeList && cell.verify.printerTypeList.length > 0) { + cell.verify.printerTypeList = cell.verify.printerTypeList.map(_cell => { + _cell.uuid = _cell.uuid || _cell.key + _cell.parentId = cell.uuid + _cell.$port = cell.$port - return _cell - }) - cell.$expanded = true - } - printbtns.push(cell) + return _cell + }) + cell.$expanded = true + } + printbtns.push(cell) + } + + _comp.action.push({...cell, $line: true, ...(userConfig[cell.uuid] || {})}) + }) } - - _comp.action.push({...cell, ...(userConfig[cell.uuid] || {})}) }) - }) + } + loopCol(item.cols) } if (_comp.action.length > 0) { @@ -179,7 +189,7 @@ } getPageConfig = () => { - const { shortcuts, permAction } = this.props + const { shortcuts } = this.props let config = fromJS(this.props.config).toJS() let userConfig = {} let components = [] @@ -197,6 +207,7 @@ printbtns.push(item) if (item.verify && item.verify.printerTypeList && item.verify.printerTypeList.length > 0) { item.verify.printerTypeList = item.verify.printerTypeList.map(cell => { + cell.uuid = cell.uuid || cell.key cell.parentId = item.uuid cell.$port = item.$port return cell @@ -252,12 +263,12 @@ if (!subconfig || !subconfig.enabled) return - subconfig = UtilsUpdate.updateSubTable(subconfig) + subconfig = updateSubTable(subconfig) let _comp = {title: res.tab.label, uuid: res.tab.uuid, action: []} subconfig.action.forEach(item => { - if (!permAction[item.uuid]) return + if (!window.GLOB.mkActions[item.uuid]) return item.$expanded = false if (item.OpenType === 'funcbutton' && item.funcType === 'print') { @@ -265,8 +276,9 @@ item.printer = _item ? (_item.printer || '') : '' item.$port = item.verify ? item.verify.linkUrl : '' - if (item.verify && item.verify.printerTypeList) { + if (item.verify && item.verify.printerTypeList && item.verify.printerTypeList.length > 0) { item.verify.printerTypeList = item.verify.printerTypeList.map(cell => { + cell.uuid = cell.uuid || cell.key cell.parentId = item.uuid cell.$port = item.$port cell.printer = _item && _item.printerList ? (_item.printerList[cell.Value] || '') : '' @@ -306,9 +318,14 @@ }) } else if (!links.includes(item.verify.linkUrl)) { links.push(item.verify.linkUrl) + } + }) - let socket = null - socket = new WebSocket('ws://' + item.verify.linkUrl) + if (links.length === 0) return + + let defers = links.map(link => { + return new Promise((resolve) => { + let socket = new WebSocket('ws://' + link) // 鎵撳紑Socket socket.onopen = () =>{ let request = { @@ -323,7 +340,7 @@ let data = '' try { data = JSON.parse(event.data) - } catch { + } catch (e) { data = '' } @@ -350,29 +367,39 @@ }) } - window.GLOB.UserCacheMap.set(item.verify.linkUrl, _printers) - } else if (data && data.cmd === 'getPrinters') { - notification.warning({ - top: 92, - message: data.message, - duration: 5 - }) + resolve({status: true, printers: _printers}) + } else if (data && data.cmd === 'getPrinters' && data.message) { + resolve({status: false, printers: null, message: data.message}) } } socket.onerror = () => { - let tool = item.verify.linkUrl - if (item.verify.linkUrl === '127.0.0.1:13529') { + let tool = link + + if (link === '127.0.0.1:13529') { tool = '鏄庣閫氳缁勪欢' - } else if (item.verify.linkUrl === '127.0.0.1:13528') { + } else if (link === '127.0.0.1:13528') { tool = 'CAINIAO鎵撳嵃缁勪欢' } - notification.warning({ - top: 92, - message: '鏃犳硶杩炴帴鍒�: ' + tool, - duration: 5 - }) + + resolve({status: false, printers: null, message: '鏃犳硶杩炴帴鍒�: ' + tool}) + } + }) + }) + + Promise.all(defers).then(results => { + let res = results.filter(item => item.status)[0] + if (res) { + links.forEach(link => { + window.GLOB.UserCacheMap.set(link, res.printers) + }) + } else { + notification.warning({ + top: 92, + message: results[0].message, + duration: 5 + }) } }) } @@ -400,7 +427,9 @@ return } - Api.deleteMenuStorage(config.MenuID).then(() => { + Api.deleteMenuStorage(config.MenuID) + + setTimeout(() => { this.setState({ visible: false, revertLoading: false @@ -408,7 +437,7 @@ window.GLOB.CacheMap = new Map() MKEmitter.emit('reloadMenuView', config.MenuID) }) - }) + }, 100) }) } @@ -419,7 +448,7 @@ components.forEach(com => { com.action.forEach(item => { - if (item.shortcut && item.shortcut.length > 0) { + if (item.shortcut && item.shortcut.length > 0 && !item.$line) { _LongParam.action.push({uuid: item.uuid, parentId: com.uuid, shortcut: item.shortcut, $shortcut: item.shortcut.join('+')}) } if (item.funcType === 'print' && (item.printer || item.verify.printerTypeList)) { @@ -476,7 +505,9 @@ return } - Api.deleteMenuStorage(config.MenuID).then(() => { + Api.deleteMenuStorage(config.MenuID) + + setTimeout(() => { this.setState({ visible: false, confirmLoading: false @@ -484,7 +515,7 @@ window.GLOB.CacheMap = new Map() MKEmitter.emit('reloadMenuView', config.MenuID) }) - }) + }, 100) }) } @@ -502,30 +533,30 @@ } render() { - const { components, visible } = this.state - + const { components, visible, dict, lang } = this.state + + if (window.GLOB.mkHS || window.GLOB.sysType !== 'local') return null + return ( - <div className="page-setting-wrap"> - {options.sysType === 'local' ? <Button - icon="setting" - shape="circle" - className="page-setting" - onClick={this.trigger} - /> : null} + <div className="tool-wrap"> + <Tooltip placement="left" title={dict['custom_settings'] || '鑷畾涔夎缃�'}> + <Button icon="setting" shape="circle" onClick={this.trigger}/> + </Tooltip> <Modal wrapClassName="custom-setting-modal" - title={'鑷畾涔夎缃�'} + title={dict['custom_settings'] || '鑷畾涔夎缃�'} maskClosable={false} width={950} visible={visible} onCancel={() => { this.setState({ visible: false }) }} footer={[ - <Button key="revert" type="danger" loading={this.state.revertLoading} onClick={this.settingRevert}>{this.props.dict['main.revert.default']}</Button>, - <Button key="cancel" onClick={() => { this.setState({ visible: false }) }}>{this.props.dict['main.cancel']}</Button>, - <Button key="confirm" type="primary" loading={this.state.confirmLoading} onClick={this.settingSubmit}>{this.props.dict['main.submit']}</Button> + <Button key="revert" type="danger" loading={this.state.revertLoading} onClick={this.settingRevert}>{dict['restore_default'] || '鎭㈠榛樿璁剧疆'}</Button>, + <Button key="cancel" onClick={() => { this.setState({ visible: false }) }}>{dict['cancel'] || '鍙栨秷'}</Button>, + <Button key="confirm" type="primary" loading={this.state.confirmLoading} onClick={this.settingSubmit}>{dict['submit'] || '鎻愪氦'}</Button> ]} destroyOnClose > + {lang !== 'en-US' ? <div className="tip">娉細琛岀骇鎸夐挳蹇嵎閿缃棤鏁堛��</div> : null} {components && components.length > 0 ? components.map(item => ( <div key={item.uuid}> <p className="component-title">{item.title}</p> -- Gitblit v1.8.0