From b91c28df2f734b680198e755b7828666e238cea0 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期五, 21 六月 2024 16:43:44 +0800 Subject: [PATCH] Merge branch 'develop' --- src/views/printTemplate/index.jsx | 56 ++++++++++++++++++++++++++++++++++++++------------------ 1 files changed, 38 insertions(+), 18 deletions(-) diff --git a/src/views/printTemplate/index.jsx b/src/views/printTemplate/index.jsx index 8f72e0c..75783b8 100644 --- a/src/views/printTemplate/index.jsx +++ b/src/views/printTemplate/index.jsx @@ -20,6 +20,7 @@ qrurl, imgurl } from './option.js' +import { langs } from '@/store/options' import Utils from '@/utils/utils.js' import printCtrl from './print.js' import Api from '@/api' @@ -35,7 +36,9 @@ class PrintTemplate extends Component { state = { config: null, + oriConfig: null, ID: null, + langName: '', editItemId: '', editItemType: '', fields: [], @@ -67,16 +70,24 @@ } UNSAFE_componentWillMount () { - let _param = window.atob(this.props.match.params.param) - let _params = {} - _param.split('&').forEach(cell => { - let _cell = cell.split('=') - _params[_cell[0]] = _cell[1] - }) + try { + let param = JSON.parse(window.decodeURIComponent(window.atob(this.props.match.params.param))) - this.setState({ - ID: _params.ID - }) + if (param.lang) { + sessionStorage.setItem('lang', param.lang) + } + + this.setState({ + langName: sessionStorage.getItem('lang') !== 'zh-CN' && langs[sessionStorage.getItem('lang')] ? `锛�${langs[sessionStorage.getItem('lang')]}锛塦 : '', + ID: param.ID + }) + } catch (e) { + notification.warning({ + top: 92, + message: '妯℃澘淇℃伅瑙f瀽閿欒锛�', + duration: 5 + }) + } } componentDidMount () { @@ -88,7 +99,7 @@ let cy = position.cy let _selectItem = null - let _config = JSON.parse(JSON.stringify(this.state.config)) + let _config = fromJS(this.state.config).toJS() _config.elements.forEach(element => { let x = +element.left @@ -156,8 +167,8 @@ return } - let _selectItem = JSON.parse(JSON.stringify(this.state.config.elements.filter(ele => ele.uuid === this.state.editItemId)[0])) - let _preItem = JSON.parse(JSON.stringify(_selectItem)) + let _selectItem = fromJS(this.state.config.elements.filter(ele => ele.uuid === this.state.editItemId)[0]).toJS() + let _preItem = fromJS(_selectItem).toJS() let position = this.getclickpoint(e) let cx = position.cx @@ -214,7 +225,7 @@ let result = this.resetItem(_selectItem) if (!is(fromJS(result), fromJS(_preItem))) { - _preItem = JSON.parse(JSON.stringify(result)) + _preItem = fromJS(result).toJS() this.FormRef.resetForm(result) config.elements = config.elements.map(item => { @@ -261,7 +272,7 @@ let result = this.resetItem(fromJS(_selectItem).toJS()) if (!is(fromJS(result), fromJS(_preItem))) { - _preItem = JSON.parse(JSON.stringify(result)) + _preItem = fromJS(result).toJS() this.FormRef.resetForm(result) config.elements = config.elements.map(item => { @@ -407,6 +418,7 @@ this.handleResize() this.setState({ config: _config, + oriConfig: fromJS(_config).toJS(), editItemId: _config.uuid, editItemType: _config.type, formlist: getpageform(_config) @@ -779,9 +791,16 @@ } submitConfig = () => { - const { config } = this.state + const { config, oriConfig } = this.state - if (config.height / config.width > 10 || config.width / config.height > 10) { + if (is(fromJS(config), fromJS(oriConfig))) { + notification.success({ + top: 92, + message: '褰撳墠妯℃澘鏈慨鏀癸紝鏃犻渶淇濆瓨銆�', + duration: 5 + }) + return + } else if (config.height / config.width > 10 || config.width / config.height > 10) { notification.warning({ top: 92, message: '绾稿紶绾垫í姣斾笉鍙秴杩�10!', @@ -878,6 +897,7 @@ }) } this.setState({ + oriConfig: fromJS(config).toJS(), saveloading: false }) }) @@ -950,13 +970,13 @@ } render () { - const { debug } = this.state + const { debug, langName } = this.state return ( <div className="print-template"> <DndProvider backend={HTML5Backend}> <header className="print-header-container ant-menu-dark"> - 妯℃澘鍒朵綔 + 妯℃澘鍒朵綔{langName} <div>蹇嵎閿細Delete锛堝垹闄ゅ厓绱狅級銆乧trl + q锛堝鍒跺厓绱狅級</div> </header> <aside className="tools"> -- Gitblit v1.8.0