From c882b3d43649bb546d390114ad965015d5c04e61 Mon Sep 17 00:00:00 2001 From: chenglb Date: Tue, 26 Dec 2023 09:28:41 +0800 Subject: [PATCH] =?UTF-8?q?fix;=20=20=E9=97=AE=E9=A2=98=E5=8D=95=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/layout/SideBar/index.scss | 7 + src/pages/Nav/index.scss | 28 +-- .../AppMgm/WechatMenuMgm/loadable.jsx | 218 ++++++++++----------- .../BusinessConfig/HotCbdConf/loadable.jsx | 16 +- src/router/index.jsx | 2 +- 5 files changed, 138 insertions(+), 133 deletions(-) diff --git a/src/components/layout/SideBar/index.scss b/src/components/layout/SideBar/index.scss index f4f36e9..c9aab77 100644 --- a/src/components/layout/SideBar/index.scss +++ b/src/components/layout/SideBar/index.scss @@ -12,6 +12,7 @@ } } } + .ant-menu-submenu .ant-menu-submenu .ant-menu-submenu-title{ padding-left: 20px !important; } @@ -22,6 +23,12 @@ .ant-menu-submenu .ant-menu-sub .ant-menu-submenu::before{ display: none !important; } + .menu-container>.ant-menu>.ant-menu-submenu>.ant-menu-submenu-title{ + padding-left: 10px !important; + .ant-menu-title-content{ + margin-left: 5px; + } + } } .ant-menu-submenu-popup .ant-menu-sub .ant-menu-submenu .ant-menu-title-content{ diff --git a/src/pages/Nav/index.scss b/src/pages/Nav/index.scss index b06da07..00dbcfc 100644 --- a/src/pages/Nav/index.scss +++ b/src/pages/Nav/index.scss @@ -30,9 +30,9 @@ background: url("@/assets/images/nav/nav_item.png"); background-size: 100% 100%; background-position: center; - width: px2vw(246); - height: px2vh(680); - padding-top: px2vh(130); + width: 246px; + height: 680px; + padding-top: 130px; position: relative; &:hover{ @@ -52,7 +52,7 @@ content: ''; display: block; background-color: #3AA9FF; - width: px2vw(246); + width: 246px; height: px2vh(4); border-radius: px2vh(2); position: absolute; @@ -60,43 +60,43 @@ } } .out-wrapper{ - height: px2vh(180); - width: px2vw(180); + height: 180px; + width: 180px; margin: auto; } .icon-wrapper{ margin: auto ; font-size: 16px; - width: px2vw(120); - height: px2vw(120); + width: 120px; + height: 120px; display: flex; align-items: center; justify-content: center; // background-color: rgba(12, 43, 67, 0.6); // border: 1px solid #3AA9FF; .icon-pda{ - width: px2vw(40) !important; - height: px2vh(40) !important; + width: 40px !important; + height: 40px !important; } } .line{ height: 2px; - width: px2vw(120); + width: 120px; margin: auto ; // background-color: red; border-bottom: 2px solid #3E536C; } .zh-name{ text-align: center; - margin-top: px2vh(60); - font-size: px2vw(18); + margin-top: 60px; + font-size: 18px; font-weight: 700; } .en-name{ text-align: center; font-weight: 400; opacity: 0.4; - font-size: px2vw(12); + font-size: 12px; } } .icon_pda{ diff --git a/src/pages/OperationCenter/AppMgm/WechatMenuMgm/loadable.jsx b/src/pages/OperationCenter/AppMgm/WechatMenuMgm/loadable.jsx index 4a68d60..16143c2 100644 --- a/src/pages/OperationCenter/AppMgm/WechatMenuMgm/loadable.jsx +++ b/src/pages/OperationCenter/AppMgm/WechatMenuMgm/loadable.jsx @@ -23,6 +23,15 @@ function WechatMenuMgm() { if(res.status == 20000){ // console.log(res.data) setConfigArray(res.data) + if(res.data.length){ + let temp = res.data[0] + setRightData({ + name: temp.name, + type: temp.type, + url: temp.url + }) + setActiveMenuIndex(0) + } }else{ } @@ -30,17 +39,7 @@ function WechatMenuMgm() { .catch(err=>{ console.log(err) }) - } - - const choseOneMenu = (index, idx)=>{ - setActiveMenuIndex(index) - setActiveSubmenuIndex(idx) - let temp = configArray[index].children[idx] - setRightData(temp) - setIsEdit(true) - } - - + } const deleteMenu = ()=>{ if(configArray[activeMenuIndex].children){ @@ -67,9 +66,23 @@ function WechatMenuMgm() { temp.splice(activeMenuIndex, 1) setConfigArray(temp) } - setActiveMenuIndex(-1) + // setActiveMenuIndex(-1) setActiveSubmenuIndex(-1) message.success('一级菜单删除成功') + if(temp.length > 0){ + setActiveMenuIndex(0) + setRightData({ + name: temp[0].name, + type: temp[0].type, + url: temp[0].url, + }) + }else{ + setActiveMenuIndex(-1) + setActiveSubmenuIndex(-1) + setRightData({ + name: '', type: '', url:'' + }) + } } const deleteSubMenu = ()=>{ @@ -78,11 +91,16 @@ function WechatMenuMgm() { temp_children.splice(activeSubmenuIndex, 1) temp[activeMenuIndex].children = temp_children setConfigArray(temp) - setActiveMenuIndex(-1) + // setActiveMenuIndex(-1) setActiveSubmenuIndex(-1) message.success('子菜单删除成功') + setRightData({ + name: temp[activeMenuIndex].name, + type: temp[activeMenuIndex].type, + url: temp[activeMenuIndex].url, + }) } - + // 点击一级菜单 const clickMenu = (index)=>{ setActiveMenuIndex(index) setActiveSubmenuIndex(-1) @@ -91,11 +109,29 @@ function WechatMenuMgm() { type: configArray[index].type, url: configArray[index].url }) - setIsEdit(true) } - + // 点击子菜单 + const choseOneMenu = (index, idx)=>{ + setActiveMenuIndex(index) + setActiveSubmenuIndex(idx) + let temp = configArray[index].children[idx] + setRightData(temp) + } + // 添加子菜单 const addOneMenu = (index)=>{ + if(activeSubmenuIndex > -1){ + if(!/^[\u4e00-\u9fa5]{1,4}$/.test(rightData.name) && !/^[a-zA-Z]{1,8}$/.test(rightData.name) ){ + message.error('名称不符合规范, 请重新输入') + return + } + if(!rightData.url){ + message.error('子菜单网络地址不能为空') + return + } + } let temp = [...configArray] + temp[index].type = '' + temp[index].url = '' if(temp[index].children){ let tempchildren = [...temp[index].children] tempchildren.push({name: '子菜单' , type: 1, url: ""}) @@ -103,35 +139,43 @@ function WechatMenuMgm() { }else{ temp[index].children = [{name: '子菜单', type: 1, url: ""}] } + setRightData({name: '子菜单', type: 1, url: ""}) setConfigArray(temp) - + setActiveSubmenuIndex(temp[index].children?.length - 1) // setRightData({name: '子菜单', type: 1, url: ""}) // setActiveMenuIndex(index) - // if(configArray[index].children?.length){ - // setActiveSubmenuIndex(configArray[index].children?.length) + // if(temp[index].children?.length){ + // setActiveSubmenuIndex(temp[index].children?.length) // }else{ // setActiveSubmenuIndex(0) // } - // setIsEdit(false) } const addFirstMenu = ()=>{ - setRightData({name: '一级菜单', type: 1, url: ""}) + if(activeSubmenuIndex > -1){ + if(!/^[\u4e00-\u9fa5]{1,4}$/.test(rightData.name) && !/^[a-zA-Z]{1,8}$/.test(rightData.name) ){ + message.error('子菜单名称不符合规范, 请重新输入') + return + } + if(!rightData.url){ + message.error('子菜单网络地址不能为空') + return + } + } + setRightData({name: '一级菜单', type: '', url: ""}) if(configArray.length < 3){ setActiveMenuIndex(configArray.length) let temp = [...configArray] - temp.push({name: '一级菜单', type: 1, url: ""}) + temp.push({name: '一级菜单', type: '', url: ""}) setConfigArray(temp) } setActiveSubmenuIndex(-1) - setIsEdit(false) } const onChange = (type, e)=>{ - // let value = e.target.value, temp = {...rightData} - // temp[type] = value - // setRightData(temp) - let value = e.target.value + let value = e.target.value, temp = {...rightData} + temp[type] = value + setRightData(temp) let temp_config = [...configArray] if(activeSubmenuIndex > -1 && activeMenuIndex > -1){ temp_config[activeMenuIndex].children[activeSubmenuIndex][type] = value @@ -142,6 +186,39 @@ function WechatMenuMgm() { } const publish = ()=>{ + if(configArray.length == 0){ + message.error('请先进行配置') + return + } + if(activeSubmenuIndex > -1){ + if(rightData.url == '' ){ + message.error('子菜单网页地址不能为空') + return + } + } + let flag = true; + for(let i = 0; i < configArray.length; i++){ + if(!configArray[i].children){ + if(configArray[i].type == '' || configArray[i].url == ''){ + if(configArray[i].url == ''){ + message.error('未添加子菜单的一级菜单网页地址不能为空') + }else if(configArray[i].type == ''){ + message.error('未添加子菜单的一级菜单消息类型不能为空') + } + setActiveMenuIndex(i) + setRightData({ + name: configArray[i].name, + type: configArray[i].type, + url: configArray[i].url + }) + flag = false + break + } + } + } + if(!flag){ + return + } ajax.publishMenu(configArray).then(res=>{ if(res.status == 20000){ message.success(res.message) @@ -154,88 +231,7 @@ function WechatMenuMgm() { }) } - const save = ()=>{ - if(!/^[\u4e00-\u9fa5]{1,4}$/.test(rightData.name) && !/^[a-zA-Z]{1,8}$/.test(rightData.name) ){ - message.error('名称不符合规范, 请重新输入') - return - } - if(!rightData.url){ - message.error('网络地址不能为空') - return - } - if(activeMenuIndex > -1 && activeSubmenuIndex == -1){ - // 添加一级菜单 - // if(configArray.length){ - // let lastMenu = configArray[configArray.length - 1] - // if(lastMenu.children?.length){ //如果有子菜单, 不验证是否设置消息类型和网页地址, 但是要验证每个子菜单是否设置完整 - // let flag = true; - // for(let i = 0; i < lastMenu.children.length ;i++){ - // if(!lastMenu.children[i].url){ - // message.error('所有子菜单的网络地址不能为空') - // flag = false - // break - // } - // } - // if(!flag){ - // return - // } - // }else{ - // if(!/^[\u4e00-\u9fa5]{1,4}$/.test(lastMenu.name) && !/^[a-zA-Z]{1,8}$/.test(lastMenu.name) ){ - // message.error('上一个菜单的名称不符合规范, 请重新输入') - // return - // } - // if(!lastMenu.url){ - // message.error('请先设置上一个一级菜单的网络地址') - // return - // } - // } - // } - // let temp = [...configArray] - // temp.push({name: '一级菜单', type: 1, url: ""}) - // setConfigArray(temp) - // setActiveMenuIndex(configArray.length - 1) - // setRightData({name: '一级菜单', type: 1, url: ""}) - if(isEdit){ - let temp = [...configArray] - temp[activeMenuIndex].name = rightData.name - temp[activeMenuIndex].type = rightData.type - temp[activeMenuIndex].url = rightData.url - setConfigArray(temp) - message.success('一级菜单编辑成功') - }else{ - let temp = [...configArray] - temp.push(rightData) - setConfigArray(temp) - message.success('一级菜单添加成功') - setIsEdit(true) - } - }else{ - if(isEdit){ - let temp_arr = [...configArray]; - console.log(temp_arr[activeMenuIndex]) - // if(temp_arr[activeMenuIndex]?.children[activeSubmenuIndex]){ - // temp_arr[activeMenuIndex]?.children[activeSubmenuIndex] = rightData - // } - temp_arr[activeMenuIndex].children[activeSubmenuIndex] = rightData - setConfigArray(temp_arr) - message.success('子菜单编辑成功') - }else{ - let temp = [...configArray] - if(temp[activeMenuIndex].children){ - let tempchildren = [...temp[activeMenuIndex].children] - tempchildren.push(rightData) - temp[activeMenuIndex].children = tempchildren - }else{ - temp[activeMenuIndex].children = [rightData] - } - setConfigArray(temp) - message.success('子菜单添加成功') - setIsEdit(true) - } - - } - - + const save = ()=>{ } useEffect(()=>{ @@ -350,8 +346,10 @@ function WechatMenuMgm() { {/*    */} : null } + { + configArray.length > 0 ? <>  : null + } -   diff --git a/src/pages/SystemMgm/BusinessConfig/HotCbdConf/loadable.jsx b/src/pages/SystemMgm/BusinessConfig/HotCbdConf/loadable.jsx index 7c6b5ff..1e0a78d 100644 --- a/src/pages/SystemMgm/BusinessConfig/HotCbdConf/loadable.jsx +++ b/src/pages/SystemMgm/BusinessConfig/HotCbdConf/loadable.jsx @@ -86,7 +86,7 @@ function HotCbdConf() { ]; const [pageData, setPageData] = useSetState({ // 分页参数 pn: defaultParams?.pn || 1, - size:defaultParams?.size || 20, + page_size:defaultParams?.page_size || 20, }) //检索条件 const formSearch = [ @@ -119,7 +119,7 @@ function HotCbdConf() { const excuteSearch=()=>{ setPageData({...pageData, pn: 1}) - search({pn: 1, size:pageData.size}) + search({pn: 1, page_size:pageData.page_size}) } //列表数据 @@ -127,7 +127,7 @@ function HotCbdConf() { let obj = params; if(params.pn === undefined){ obj.pn = pageData.pn - obj.size = pageData.size + obj.page_size = pageData.page_size }else if(params.area === undefined){ obj.name = formData.name obj.area = formData.area @@ -234,7 +234,7 @@ function HotCbdConf() { area: '' }) setPageData({...pageData, pn: 1}) - search({name: '', area: '', pn: 1, size: pageData.size}) + search({name: '', area: '', pn: 1, page_size: pageData.page_size}) } const addConfig = ()=>{ @@ -244,16 +244,16 @@ function HotCbdConf() { const onShowSizeChange = (current, pageSize) => { let pn - if (pageData.size == pageSize) { + if (pageData.page_size == pageSize) { pn = current } else { pn = 1 } setPageData({ pn: pn, - size: pageSize, + page_size: pageSize, }) - search({pn: pn, size: pageSize}) + search({pn: pn, page_size: pageSize}) } // 递归区域数据 const tranverseTreeData = (data)=>{ @@ -370,7 +370,7 @@ function HotCbdConf() { // showTotal={() => `共 ${total_records} 条`} total={total} current={pageData.pn} - pageSize={pageData.size} + pageSize={pageData.page_size} pageSizeOptions={dictionary?.pageSizeOptions} onChange={onShowSizeChange} onShowSizeChange={onShowSizeChange} diff --git a/src/router/index.jsx b/src/router/index.jsx index c5f8786..946a953 100644 --- a/src/router/index.jsx +++ b/src/router/index.jsx @@ -15,7 +15,6 @@ function RouterMap(props) { const location = useLocation(); const [loading, setLoading] = useState(true) const storeRoutes = useSelector((state) => state.user.route) -// console.log(storeRoutes) const skin = localStorage.getItem("skin") const dispatch = useDispatch() const renderElement = (route) => { @@ -94,6 +93,7 @@ function RouterMap(props) { const reverseZoom = 1 / zoom; window.zoom = zoom document.getElementsByTagName('body')[0].style = `zoom:${zoom}`; + // document.getElementsByTagName('body')[0].style = `zoom:${reverseZoom}`; };