From f3d4db769ba9b51b799d981511a710fd443d0e08 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期一, 21 四月 2025 12:18:03 +0800 Subject: [PATCH] Merge branch 'master' into positec --- src/views/design/header/editfirstmenu/index.jsx | 304 +++++++++----------------------------------------- 1 files changed, 55 insertions(+), 249 deletions(-) diff --git a/src/views/design/header/editfirstmenu/index.jsx b/src/views/design/header/editfirstmenu/index.jsx index 200a619..add92a2 100644 --- a/src/views/design/header/editfirstmenu/index.jsx +++ b/src/views/design/header/editfirstmenu/index.jsx @@ -3,23 +3,14 @@ import { is, fromJS } from 'immutable' import { DndProvider } from 'react-dnd' import HTML5Backend from 'react-dnd-html5-backend' -import { notification, Modal, Spin } from 'antd' +import { notification, Modal } from 'antd' import moment from 'moment' -import TransferForm from '@/templates/zshare/basetransferform' import DragElement from './dragelement' import MenuForm from './menuform' import Utils from '@/utils/utils.js' -import zhCN from '@/locales/zh-CN/model.js' -import enUS from '@/locales/en-US/model.js' import Api from '@/api' -import './index.scss' - -import card1 from '@/assets/img/card-bg2.jpg' -import card2 from '@/assets/img/card-bg5.jpg' -import card3 from '@/assets/img/card-bg8.jpg' -import card4 from '@/assets/img/card-bg7.jpg' -import card5 from '@/assets/img/card-bg6.jpg' +// import './index.scss' const { confirm } = Modal @@ -31,37 +22,35 @@ } state = { - thawmenulist: null, // 宸插喕缁撶殑涓�绾ц彍鍗� - addMvisible: null, menulist: null, - editMenu: null, // 缂栬緫鑿滃崟 - editMvisible: false, // 缂栬緫鑿滃崟妯℃�佹 - thawMvisible: false, // 瑙i櫎鍐荤粨妯℃�佹 - confirmLoading: false, // 鎻愪氦涓�傘�傘�� - dict: sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS, - targetKeys: [] // 瑙e喕鑿滃崟鍒楄〃 + editMenu: null, // 缂栬緫鑿滃崟 + visible: false, // 缂栬緫鑿滃崟妯℃�佹 + loading: false, // 鎻愪氦涓�傘�傘�� + change: false } handlePreviewList = (List) => { // 鑿滃崟椤哄簭鏀瑰彉鏃讹紝淇濆瓨涓棿鐘舵�� - this.setState({menulist: List}) + this.setState({menulist: List, change: !is(fromJS(List), fromJS(this.props.menulist))}) } editMenuModal = (Menu) => { // 鑿滃崟缂栬緫锛氫慨鏀� const menu = fromJS(Menu).toJS() - if (!is(fromJS(this.state.menulist), fromJS(this.props.menulist))) { + if (this.state.change) { notification.warning({ top: 92, - message: this.state.dict['model.menu.presave'], + message: '鑿滃崟椤哄簭宸茶皟鏁达紝璇蜂繚瀛橈紒', duration: 5 }) - } else { - this.setState({ - editMvisible: true, - editMenu: menu.card - }) + return } + + this.setState({ + visible: true, + editMenu: menu.card, + loading: false + }) } editMemuSubmit = () => { @@ -69,19 +58,19 @@ this.editMenuFormRef.handleConfirm().then(param => { param.func = 'sPC_MainMenu_Upt' this.setState({ - confirmLoading: true + loading: true }) - Api.getSystemConfig(param).then(res => { + Api.getCloudConfig(param).then(res => { if (res.status) { this.setState({ - confirmLoading: false, - editMvisible: false, + loading: false, + visible: false, editMenu: null }) this.props.reload() } else { this.setState({ - confirmLoading: false + loading: false }) notification.warning({ top: 92, @@ -91,67 +80,30 @@ } }) }, () => {}) - } - - editMemuCancel = () => { - // 缂栬緫鑿滃崟锛氬彇娑� - this.setState({ - confirmLoading: false, - editMvisible: false, - editMenu: null - }) - } - - addMemuSubmit = () => { - // 鏂板缓鑿滃崟锛氭彁浜� - this.addMenuFormRef.handleConfirm().then(param => { - param.func = 'sPC_MainMenu_Add' - param.Sort = (this.props.menulist.length + 1) * 10 - this.setState({ - confirmLoading: true - }) - Api.getSystemConfig(param).then(res => { - if (res.status) { - this.setState({ - confirmLoading: false, - addMvisible: false, - }) - this.props.reload() - } else { - this.setState({ - confirmLoading: false - }) - notification.warning({ - top: 92, - message: res.message, - duration: 5 - }) - } - }) - }, () => {}) - } - - addMemuCancel = () => { - // 鏂板缓鑿滃崟锛氬彇娑� - this.setState({ - confirmLoading: false, - addMvisible: false - }) } deleteMemu = (item) => { - let _this = this + if (this.state.change) { + notification.warning({ + top: 92, + message: '鑿滃崟椤哄簭宸茶皟鏁达紝璇蜂繚瀛橈紒', + duration: 5 + }) + return + } + + let that = this confirm({ - title: this.state.dict['model.menu.close'].replace('@M', item.MenuName), + title: `纭畾鍒犻櫎鑿滃崟銆�${item.MenuName}銆嬪悧锛焋, content: '', onOk() { let param = { func: 'sPC_MainMenu_Del', MenuID: item.MenuID } - return Api.getSystemConfig(param).then(res => { + return Api.getCloudConfig(param).then(res => { if (res.status) { - _this.props.reload() + that.props.reload() } else { notification.warning({ top: 92, @@ -164,99 +116,34 @@ onCancel() {} }) } - - thawMemuSubmit = () => { - const { targetKeys } = this.state - - if (targetKeys.length === 0) { - notification.warning({ - top: 92, - message: this.state.dict['form.required.select'] + this.state.dict['model.menu'], - duration: 5 - }) - } else { - this.setState({ - confirmLoading: true - }) - let defers = targetKeys.map(item => { - return new Promise((resolve) => { - Api.getSystemConfig({ - func: 'sPC_MainMenu_ReDel', - MenuID: item - }).then(res => { - if (res.status) { - resolve('') - } else { - resolve(res.message) - } - }) - }) - }) - Promise.all(defers).then(res => { - let msg = res.filter(Boolean)[0] - if (msg) { - notification.error({ - top: 92, - message: msg, - duration: 10 - }) - } else { - this.setState({ - confirmLoading: false, - thawMvisible: false, - targetKeys: [], - thawmenulist: null - }) - this.props.reload() - } - }) - } - } - - thawMemuCancel = () => { - this.setState({ - thawMvisible: false, - targetKeys: [], - thawmenulist: null - }) - } - handleButton = (type) => { + const that = this // 鑿滃崟缂栬緫锛氭坊鍔狅紝纭畾锛屽彇娑� let _menuchange = !is(fromJS(this.state.menulist), fromJS(this.props.menulist)) - if ((type === 'add' || type === 'thawmenu') && _menuchange) { - notification.warning({ - top: 92, - message: this.state.dict['model.menu.presave'], - duration: 5 - }) - } else if (type === 'add') { - this.setState({ - addMvisible: true - }) - } else if (type === 'confirm' && _menuchange) { - let _this = this + if (type === 'confirm' && _menuchange) { let param = { func: 'sPC_Menu_SortUpt', + exec_type: 'x', LText: this.state.menulist.map((item, index) => { return 'select \'' + item.MenuID + '\' as Menuid,' + (index + 1) * 10 + ' as sort' }) } - param.LText = param.LText.join(' union ') // sql鎷兼帴 - param.LText = Utils.formatOptions(param.LText) // 鍏抽敭瀛楃鏇挎崲锛宐ase64鍔犲瘑 - param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') // 鏃堕棿鎴� - param.secretkey = Utils.encrypt(param.LText, param.timestamp) // md5瀵嗛挜 + param.LText = param.LText.join(' union ') + param.LText = Utils.formatOptions(param.LText, 'x') + param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + param.secretkey = Utils.encrypt('', param.timestamp) confirm({ - title: this.state.dict['model.menu.resetorder'], + title: '纭璋冩暣鑿滃崟椤哄簭鍚楋紵', content: '', onOk() { - return Api.getSystemConfig(param).then(res => { + return Api.getCloudConfig(param).then(res => { if (res.status) { - _this.props.reload() + that.setState({ change: false }) + that.props.reload() } else { notification.warning({ top: 92, @@ -269,42 +156,13 @@ onCancel() {} }) } else if (type === 'cancel' && _menuchange) { - let _this = this - confirm({ title: '鑿滃崟椤哄簭宸茶皟鏁达紝鏀惧純淇濆瓨鍚楋紵', content: '', onOk() { - _this.props.exitEdit() + that.props.exitEdit() }, onCancel() {} - }) - } else if (type === 'thawmenu') { - this.setState({ - thawMvisible: true, - targetKeys: [] - }) - Api.getSystemConfig({ - func: 'sPC_Get_FrozenMenu', - ParentID: '0', - TYPE: 10 - }).then(res => { - if (res.status) { - this.setState({ - thawmenulist: res.data.map(menu => { - return { - key: menu.MenuID, - title: menu.MenuName - } - }) - }) - } else { - notification.warning({ - top: 92, - message: res.message, - duration: 5 - }) - } }) } else { this.props.exitEdit() @@ -317,38 +175,18 @@ UNSAFE_componentWillReceiveProps (nextProps) { if (!is(fromJS(this.props.menulist), fromJS(nextProps.menulist))) { - this.setState({menulist: fromJS(nextProps.menulist).toJS()}) + this.setState({menulist: fromJS(nextProps.menulist).toJS(), change: false}) } } render () { - const { dict, menulist } = this.state + const { menulist, change } = this.state return ( - <div className="header-edit-box"> - <div className="mask"> - <div className="tipcard card1" style={{backgroundImage: 'url(' + card1 + ')'}}> - 鎷栧姩涓�绾ц彍鍗曞彲璋冩暣椤哄簭锛岄『搴忚皟鏁村悗锛岃鐐瑰嚮纭畾鎸夐挳淇濆瓨銆� - </div> - <div className="tipcard card2" style={{backgroundImage: 'url(' + card2 + ')'}}> - 榧犳爣缁忚繃鑿滃崟鏃朵細鏄剧ず缂栬緫鍥炬爣锛岀偣鍑荤紪杈戝彲淇敼鍜屽垹闄よ彍鍗曘�� - </div> - <div className="tipcard card3" style={{backgroundImage: 'url(' + card3 + ')'}}> - 鐐瑰嚮瑙i櫎鍐荤粨鎸夐挳锛屽彲杩樺師宸插垹闄ょ殑涓�绾ц彍鍗曘�� - </div> - <div className="tipcard card4" style={{backgroundImage: 'url(' + card4 + ')'}}> - 鐐瑰嚮娣诲姞鍥炬爣锛屽彲鏂板涓�绾ц彍鍗曘�� - </div> - <div className="tipcard card5" style={{backgroundImage: 'url(' + card5 + ')'}}> - <p>缂栬緫鐘舵�佷腑锛岃彍鍗曚箣澶栧尯鍩熶細閿佸畾锛屾煡鐪嬬郴缁熸暟鎹鐐瑰嚮銆�</p> - <div> - <span className="new-view" onClick={() => {window.open('#/main')}} >鏂伴〉闈�</span> - </div> - </div> - </div> + <> <DndProvider backend={HTML5Backend}> <DragElement - dict={dict} + change={change} list={menulist} handlePreviewList={this.handlePreviewList} handleMenu={this.editMenuModal} @@ -356,54 +194,22 @@ handleButton={this.handleButton} /> </DndProvider> - {/* 鏂板缓鑿滃崟妯℃�佹 */} - <Modal - title={dict['model.add'] + dict['model.menu']} - visible={this.state.addMvisible} - onOk={this.addMemuSubmit} - confirmLoading={this.state.confirmLoading} - onCancel={this.addMemuCancel} - destroyOnClose - > - <MenuForm - dict={dict} - type="add" - menu={null} - inputSubmit={this.addMemuSubmit} - wrappedComponentRef={(inst) => this.addMenuFormRef = inst} - /> - </Modal> - {/* 瑙i櫎鍐荤粨鑿滃崟妯℃�佹 */} - <Modal - title={dict['model.thaw'] + dict['model.menu']} - visible={this.state.thawMvisible} - width={600} - onOk={this.thawMemuSubmit} - confirmLoading={this.state.confirmLoading} - onCancel={this.thawMemuCancel} - destroyOnClose - > - {!this.state.thawmenulist && <Spin style={{marginLeft: 'calc(50% - 22px)', marginTop: '70px', marginBottom: '70px'}} size="large" />} - {this.state.thawmenulist && <TransferForm onChange={(vals) => this.setState({targetKeys: vals})} menulist={this.state.thawmenulist}/>} - </Modal> {/* 缂栬緫鑿滃崟妯℃�佹 */} <Modal - title={dict['model.edit'] + dict['model.menu']} - visible={this.state.editMvisible} + title="缂栬緫鑿滃崟" + visible={this.state.visible} onOk={this.editMemuSubmit} - confirmLoading={this.state.confirmLoading} - onCancel={this.editMemuCancel} + confirmLoading={this.state.loading} + onCancel={() => this.setState({visible: false})} destroyOnClose > <MenuForm - dict={dict} - type="edit" menu={this.state.editMenu} inputSubmit={this.editMemuSubmit} wrappedComponentRef={(inst) => this.editMenuFormRef = inst} /> </Modal> - </div> + </> ) } } -- Gitblit v1.8.0