Home.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559
  1. <script setup>
  2. import {ref,computed} from 'vue'
  3. import { useRouter } from "vue-router";
  4. import {apiMenuList, _apiLogin} from '@/api/user'
  5. import {getStaticImg} from '@/hooks/common'
  6. import {useCachedViewsStore} from '@/store/modules/cachedViews'
  7. import { showToast } from 'vant';
  8. import { useWindowSize } from '@vueuse/core'
  9. import {usePublicSettingStore} from '@/store/modules/publicSetting'
  10. import useLocaleStore from "@/store/modules/i18n";
  11. const publicSettingStore = usePublicSettingStore()
  12. const { width } = useWindowSize()
  13. const cachedViewsStore=useCachedViewsStore()
  14. cachedViewsStore.removeCaches(-1)
  15. const localeStore = useLocaleStore()
  16. const router=useRouter()
  17. const temp = localeStore.locale === 'zhCn' ? 'zh' : 'en'; //根据当前i18n语言设置表格默认语言
  18. const language_version=ref(temp)//语言版本 zh en
  19. function goNext(path){
  20. if(!path){
  21. showToast('功能开发中,敬请期待!')
  22. return
  23. }
  24. const routerEl=router.resolve({path})
  25. window.open(routerEl.href,'_blank')
  26. }
  27. if(!localStorage.getItem('token')){
  28. router.replace('/login')
  29. }
  30. function languageVersionChange(){
  31. if(language_version.value==='zh'){
  32. language_version.value='en'
  33. localeStore.SET_LOCALE('en')
  34. }else{
  35. language_version.value='zh'
  36. localeStore.SET_LOCALE('zhCn')
  37. }
  38. }
  39. const topImg=computed(()=>{
  40. let url=''
  41. if(width.value>650){//大屏
  42. if(language_version.value==='zh'){
  43. url='https://hzstatic.hzinsights.com/static/ETA_mobile/tabbar_home_topimg_en_big.png'
  44. }else{
  45. url='https://hzstatic.hzinsights.com/static/ETA_mobile/tabbar_home_topimg_zh_big.png'
  46. }
  47. }else{
  48. if(language_version.value==='zh'){
  49. url='https://hzstatic.hzinsights.com/static/ETA_mobile/tabbar_home_topimg_en.png'
  50. }else{
  51. url='https://hzstatic.hzinsights.com/static/ETA_mobile/tabbar_home_topimg_zh.png'
  52. }
  53. }
  54. return url
  55. })
  56. /**
  57. * zhName 显示的中文版名称
  58. * enName 显示的英文版名称
  59. * key 对应接口中的 name
  60. * level 说明该菜单在数据中的第几级查找
  61. * type 类型 zh中文 en英文 ==> 默认中文点击切换
  62. */
  63. // const menuConfig=[
  64. // // {
  65. // // zhName:'中文研报',
  66. // // zhDes:'研报一体化管理',
  67. // // key:'研报列表',
  68. // // type:'zh',
  69. // // level:2,
  70. // // path:'/report/list',
  71. // // icon:getStaticImg('tabbar/icon_report.png'),
  72. // // backgroundColor:'#FFFBF6',
  73. // // show:false
  74. // // },
  75. // // {
  76. // // zhName:'英文研报',
  77. // // zhDes:'支持共享协作编辑',
  78. // // enName:'English Research Report',
  79. // // enDes:'Integrated Research Report Management',
  80. // // key:'英文研报',
  81. // // type:'zh',
  82. // // level:2,
  83. // // path:'/reportEn/list',
  84. // // icon:getStaticImg('tabbar/icon_report.png'),
  85. // // backgroundColor:'#FFFBF6',
  86. // // show:false
  87. // // },
  88. // {
  89. // zhName:'智能PPT',
  90. // zhDes:"支持共享协作编辑",
  91. // enName:'PPT Slides',
  92. // enDes:'Support for collaborative editing',
  93. // key:'智能ppt',
  94. // type:'zh',
  95. // level:1,
  96. // path:'/ppt/index',
  97. // icon:getStaticImg('tabbar/icon_PPT.png'),
  98. // backgroundColor:'#FFF5F3',
  99. // show:false
  100. // },
  101. // {
  102. // zhName:'英文ppt',
  103. // zhDes:'支持共享协作编辑',
  104. // enName:'ppt in English',
  105. // enDes:'Support for collaborative editing',
  106. // key:'英文ppt',
  107. // type:'zh',
  108. // level:1,
  109. // path:'/ppten/index',
  110. // icon:getStaticImg('tabbar/icon_PPT.png'),
  111. // backgroundColor:'#FFF5F3',
  112. // show:false
  113. // },
  114. // // {
  115. // // zhName:'数据源',
  116. // // zhDes:'数据对接与整合',
  117. // // key:'数据源',
  118. // // type:'zh',
  119. // // level:1,
  120. // // path:'',
  121. // // icon:getStaticImg('tabbar/icon_dataSource.png'),
  122. // // backgroundColor:'#F8F9FF',
  123. // // show:false
  124. // // },
  125. // {
  126. // zhName:'指标库',
  127. // zhDes:'数据归类与分析',
  128. // enName:'Indics',
  129. // enDes:'Support for collaborative editing',
  130. // key:'指标库',
  131. // type:'zh',
  132. // level:1,
  133. // path:'/dataEDB/index',
  134. // icon:getStaticImg('tabbar/icon_EDB.png'),
  135. // backgroundColor:'#F5FAFF',
  136. // show:false
  137. // },
  138. // // {
  139. // // zhName:'预测指标',
  140. // // zhDes:'模型预测趋势',
  141. // // key:'预测指标',
  142. // // type:'zh',
  143. // // level:1,
  144. // // path:'',
  145. // // icon:getStaticImg('tabbar/icon_preEDB.png'),
  146. // // backgroundColor:'#FFF5F3',
  147. // // show:false
  148. // // },
  149. // {
  150. // zhName:'图库',
  151. // zhDes:'数据可视化平台',
  152. // enName:'Charts',
  153. // enDes:'Support for collaborative editing',
  154. // key:'图库',
  155. // type:'zh',
  156. // level:1,
  157. // path:'/chartETA/list',
  158. // icon:getStaticImg('tabbar/icon_chart.png'),
  159. // backgroundColor:'#F8F9FF',
  160. // show:false
  161. // },
  162. // {
  163. // zhName:'我的图库',
  164. // zhDes:'图表收藏',
  165. // enName:'My Charts',
  166. // enDes:'Support for collaborative editing',
  167. // key:'我的投研',
  168. // type:'zh',
  169. // level:1,
  170. // path:'/myETA/index',
  171. // icon:getStaticImg('tabbar/icon_myChart.png'),
  172. // backgroundColor:'#F5FAFF',
  173. // show:false
  174. // },
  175. // {
  176. // zhName:'表格',
  177. // zhDes:'快速建立平衡表',
  178. // enName:'Tables',
  179. // enDes:'Quickly establish a balance sheet',
  180. // key:'表格',
  181. // type:'zh',
  182. // level:1,
  183. // path:'/sheetList/index',
  184. // icon:getStaticImg('tabbar/icon_table.png'),
  185. // backgroundColor:'#FFFBF6',
  186. // show:false
  187. // },
  188. // ]
  189. // 新增一个用于映射语言版本的函数
  190. const menuConfig=[
  191. {
  192. name:'国事研报',
  193. des:'全系统各类分析报告一体化展示平台',
  194. key:'国事研报',
  195. type:'zh',
  196. level:1,
  197. path:'/war_research_report/list',
  198. icon:getStaticImg('tabbar/icon_reportwar.png'),
  199. backgroundColor:'#F8F9FF',
  200. show:false
  201. },
  202. {
  203. name:'研报中心',
  204. des:'研报一体化管理',
  205. key:'研报中心',
  206. type:'zh',
  207. level:2,
  208. path:'/report/list',
  209. icon:getStaticImg('tabbar/icon_report.png'),
  210. backgroundColor:'#FFFBF6',
  211. show:false
  212. },
  213. {
  214. name:'英文研报',
  215. des:'研报一体化管理',
  216. key:'英文研报',
  217. type:'zh',
  218. level:2,
  219. path:'/reportEn/list',
  220. icon:getStaticImg('tabbar/icon_report.png'),
  221. backgroundColor:'#FFFBF6',
  222. show:false
  223. },
  224. {
  225. name:'智能PPT',
  226. des:"支持共享协作编辑",
  227. key:'智能ppt',
  228. type:'zh',
  229. level:1,
  230. path:'/ppt/index',
  231. icon:getStaticImg('tabbar/icon_PPT.png'),
  232. backgroundColor:'#FFF5F3',
  233. show:false
  234. },
  235. {
  236. name:'文档管理库',
  237. des:'支持上传文档报告',
  238. key:'文档管理库',
  239. type:'zh',
  240. level:2,
  241. path:'/external_report/list',
  242. icon:getStaticImg('tabbar/icon_report.png'),
  243. backgroundColor:'#FFFBF6',
  244. show:false
  245. },
  246. {
  247. name:'英文ppt',
  248. des:'支持共享协作编辑',
  249. key:'英文ppt',
  250. type:'zh',
  251. level:1,
  252. path:'/ppten/index',
  253. icon:getStaticImg('tabbar/icon_PPT.png'),
  254. backgroundColor:'#FFF5F3',
  255. show:false
  256. },
  257. // {
  258. // name:'数据源',
  259. // des:'数据对接与整合',
  260. // key:'数据源',
  261. // type:'zh',
  262. // level:1,
  263. // path:'',
  264. // icon:getStaticImg('tabbar/icon_dataSource.png'),
  265. // backgroundColor:'#F8F9FF',
  266. // show:false
  267. // },
  268. {
  269. name:'指标库',
  270. des:'数据归类与分析',
  271. key:'指标库',
  272. type:'zh',
  273. level:1,
  274. path:'/dataEDB/index',
  275. icon:getStaticImg('tabbar/icon_EDB.png'),
  276. backgroundColor:'#F5FAFF',
  277. show:false
  278. },
  279. // {
  280. // name:'预测指标',
  281. // des:'模型预测趋势',
  282. // key:'预测指标',
  283. // type:'zh',
  284. // level:1,
  285. // path:'',
  286. // icon:getStaticImg('tabbar/icon_preEDB.png'),
  287. // backgroundColor:'#FFF5F3',
  288. // show:false
  289. // },
  290. {
  291. name:'图库',
  292. des:'数据可视化平台',
  293. key:'图库',
  294. type:'zh',
  295. level:1,
  296. path:'/chartETA/list',
  297. icon:getStaticImg('tabbar/icon_chart.png'),
  298. backgroundColor:'#F8F9FF',
  299. show:false
  300. },
  301. {
  302. name:'我的图库',
  303. des:'图表收藏',
  304. key:'我的投研',
  305. type:'zh',
  306. level:1,
  307. path:'/myETA/index',
  308. icon:getStaticImg('tabbar/icon_myChart.png'),
  309. backgroundColor:'#F5FAFF',
  310. show:false
  311. },
  312. {
  313. name:'表格',
  314. des:'快速建立平衡表',
  315. key:'表格',
  316. type:'zh',
  317. level:1,
  318. path:'/sheetList/index',
  319. icon:getStaticImg('tabbar/icon_table.png'),
  320. backgroundColor:'#FFFBF6',
  321. show:false
  322. },
  323. {
  324. name:'Tables',
  325. des:'Quickly establish a balance sheet',
  326. key:'表格',
  327. type:'en',
  328. level:1,
  329. path:'/sheetList/index',
  330. icon:getStaticImg('tabbar/icon_table.png'),
  331. backgroundColor:'#FFFBF6',
  332. show:false
  333. },
  334. ];
  335. function mapMenuToLanguage(item, language) {
  336. if (language === 'zh') {
  337. return { ...item, name: item.zhName, des: item.zhDes, type: 'zh' };
  338. } else {
  339. return { ...item, name: item.enName, des: item.enDes, type: 'en' };
  340. }
  341. }
  342. // 过滤出有权限的菜单项
  343. const filteredMenuConfig = computed(() => {
  344. return menuConfig.filter(item => {
  345. // 根据菜单数据权限过滤
  346. const hasPermission = resMenuList.value.some(f => {
  347. if (item.level === 1) {
  348. return f.name.trim() === item.key;
  349. } else if (item.level === 2) {
  350. return (f.children || []).some(s => s.name.trim() === item.key);
  351. }
  352. return false;
  353. });
  354. return hasPermission;
  355. });
  356. });
  357. // 根据当前语言版本过滤并映射菜单项
  358. // const menuOpts = computed(() => {
  359. // return filteredMenuConfig.value.map(item => mapMenuToLanguage(item, language_version.value));
  360. // });
  361. const menuOpts=computed(()=>{
  362. // 过滤中英文
  363. let arr=menuConfig.filter(item=>item.type===language_version.value)
  364. // 根据菜单数据权限过滤
  365. arr.forEach(item=>{
  366. if(item.level===1){
  367. resMenuList.value.forEach(f=>{
  368. if(f.name.trim()===item.key){
  369. item.show=true
  370. }
  371. })
  372. }
  373. if(item.level===2){
  374. resMenuList.value.forEach(f=>{
  375. const arr=f.children||[]
  376. arr.forEach(s=>{
  377. if(s.name.trim()===item.key){
  378. item.show=true
  379. }
  380. })
  381. })
  382. }
  383. })
  384. arr=arr.filter(item=>item.show)
  385. return arr||[]
  386. })
  387. // 获取菜单权限数据
  388. const resMenuList=ref([])
  389. async function getMenuList(){
  390. menuConfig.forEach(item=>{
  391. item.show=false
  392. })
  393. const res=await apiMenuList()
  394. if(res.Ret===200){
  395. resMenuList.value=res.Data.List||[]
  396. }
  397. }
  398. const getSetTitle=()=>{
  399. _apiLogin.getBaseInfo().then(res=>{
  400. if(res.Ret == 200){
  401. document.title=res.Data.TabNameMobile?res.Data.TabNameMobile.ConfVal:''
  402. }
  403. })
  404. }
  405. getMenuList()
  406. getSetTitle()
  407. </script>
  408. <template>
  409. <div class="home-page">
  410. <img
  411. class="top-img"
  412. :src="topImg"
  413. alt=""
  414. @click="languageVersionChange"
  415. >
  416. <div class="list">
  417. <div
  418. v-for="item in menuOpts"
  419. :key="item.name"
  420. :class="['item-box',
  421. item.type==='en'?'item-box_en':'',
  422. item.key==='国事研报'&&'full-item'
  423. ]"
  424. :style="{backgroundColor:item.backgroundColor}"
  425. @click="goNext(item.path)"
  426. >
  427. <img class="icon" :src="item.icon" alt="">
  428. <div class="content">
  429. <div class="name">{{item.name}}</div>
  430. <div class="des">{{item.des}}</div>
  431. </div>
  432. </div>
  433. <div class="item-box" style="height:0;min-height:0;padding:0"></div>
  434. <div class="item-box" style="height:0;min-height:0;padding:0"></div>
  435. </div>
  436. </div>
  437. </template>
  438. <style lang="scss" scoped>
  439. .home-page{
  440. padding: 30px 34px;
  441. padding-bottom: 140px;
  442. .top-img{
  443. display: block;
  444. width: 100%;
  445. margin-bottom: 40px;
  446. cursor: pointer;
  447. }
  448. .list{
  449. display: flex;
  450. gap: 20px;
  451. flex-wrap: wrap;
  452. .item-box{
  453. width: 331px;
  454. min-height: 228px;
  455. padding: 40px 20px;
  456. display: flex;
  457. justify-content: center;
  458. align-items: center;
  459. border-radius: 32px;
  460. cursor: pointer;
  461. &.full-item {
  462. width: 100%;
  463. justify-content: left;
  464. }
  465. .icon{
  466. width: 90px;
  467. height: 90px;
  468. margin-right: 12px;
  469. }
  470. .content{
  471. .name{
  472. font-size: 36px;
  473. font-weight: 600;
  474. }
  475. .des{
  476. font-size: 24px;
  477. color: $font-grey_999;
  478. margin-top: 12px;
  479. }
  480. }
  481. }
  482. .item-box_en{
  483. flex-direction: column;
  484. justify-content: flex-start;
  485. align-items: flex-start;
  486. .icon{
  487. width: 48px;
  488. height: 48px;
  489. margin-bottom: 12px;
  490. margin-right: 0;
  491. }
  492. }
  493. }
  494. }
  495. @media screen and (min-width:$media-width){
  496. .home-page{
  497. padding: 30px 34px;
  498. max-width: 1180px;
  499. margin: 0 auto;
  500. padding-bottom: 30px;
  501. .top-img{
  502. width: 100%;
  503. margin-bottom: 20px;
  504. }
  505. .list{
  506. gap: 20px;
  507. justify-content: center;
  508. .item-box{
  509. width: 260px;
  510. min-height: 161px;
  511. border-radius: 32px;
  512. padding: 36px 11px;
  513. .icon{
  514. width: 70px;
  515. height: 70px;
  516. margin-right: 6px;
  517. }
  518. .content{
  519. .name{
  520. font-size: 32px;
  521. }
  522. .des{
  523. font-size: 20px;
  524. margin-top: 6px;
  525. }
  526. }
  527. }
  528. .item-box_en{
  529. .icon{
  530. width: 70px;
  531. height: 70px;
  532. margin-bottom: 6px;
  533. }
  534. }
  535. }
  536. }
  537. }
  538. </style>