sidebarL.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528
  1. <template>
  2. <div class="left">
  3. <!-- <div > -->
  4. <div class="logo2" @click="gotoKanban">
  5. <img :src="fromL.basics.logo ? fromL.basics.logo : require('../assets/img/moren.png')" alt="">
  6. </div>
  7. <!-- <div class="ulT"> -->
  8. <!-- 默认首页 -->
  9. <div class="ulTOne" @click.stop="goto(0)">
  10. <div class="menu_left">
  11. <img class="logo" :src="activeL === 0 ? require('../assets/img/sy.svg') : require('../assets/img/sy1.svg')" alt="">
  12. <span class="barT" :style="{color : activeL === 0 ? '#0051D7' :''}">首页</span>
  13. </div>
  14. </div>
  15. <!-- 权限 -->
  16. <div style="width: 100%;" v-for="(item,index) in appSignL(fromL.admin.sidebar.list)"
  17. :key="index+1">
  18. <!-- 渲染菜单类型 -->
  19. <div class="ulTOne" v-if="item.menuName">
  20. <!-- 二级导航 -->
  21. <div class="ulTCopy">
  22. <div class="ulTCopyTit">
  23. <span>{{ item.menuName }}</span>
  24. </div>
  25. <div class="ulTCopyHei">
  26. <div class="ulTCopyTxt"
  27. v-for="(i,ind) in appSignL(item.children)"
  28. @click="levTwo(i,ind,index)" :key="ind+'a'">
  29. <div class="ulTCopyTxt"
  30. :style="{background : (activeLTwo === index+1 +'+' + ind)? '#0663FE' : '',color: (activeLTwo === index+1 +'+' + ind)? '#fff' :''}"
  31. v-for="(p,pin) in AppCon(i.url)" :key="pin+'p'">
  32. <div class="ulTCopyConT">{{ p.name }}</div>
  33. </div>
  34. </div>
  35. </div>
  36. </div>
  37. <div class="menu_left">
  38. <img :src="activeL === (index +1) ? item.menuActiveIcon : item.menuIcon" class="logo" alt="">
  39. <span class="barT" :style="{color : activeL === (index +1) ? '#0051D7' :''}">{{ item.menuName }}</span>
  40. </div>
  41. </div>
  42. <!-- 渲染平台工具类型 -->
  43. <div style="width: 100%;" @click.stop="goto(index,item)"
  44. v-else>
  45. <div class="ulTOne"
  46. v-for="(p,pin) in AppCon(item.url)" :key="pin+'p'">
  47. <div class="menu_left" @mouseenter="mouGet(item.toolId)" >
  48. <img class="logo"
  49. :src="activeL === (index +1) ? p.activeIcon : p.defaultIcon"
  50. alt="">
  51. <span class="barT" :style="{color : activeL === (index +1) ? '#0051D7' :''}">
  52. {{ p.name }}
  53. </span>
  54. </div>
  55. <!-- 二级导航 -->
  56. <div class="ulTCopy" v-if="item.toolId.includes('appStore') && ((cocoFlowList[0] && cocoFlowList[0].length) || (cocoFlowList[1] && cocoFlowList[1].length))">
  57. <div class="ulTCopyTit">
  58. <span>CocoFlow</span>
  59. </div>
  60. <div class="ulTCopyHei" >
  61. <span v-if="cocoFlowList[0] && cocoFlowList[0].length" style="color: #00000066;">最近使用</span>
  62. <div class="ulTCopyTxt"
  63. v-for="(i,ind) in cocoFlowList[0]"
  64. @click.stop="openNewWindow(i.url)" :key="ind+'ab'">
  65. <div class="ulTCopyConT">{{ i.name }}</div>
  66. </div>
  67. <span v-if="cocoFlowList[0] && cocoFlowList[1].length" style="color: #00000066;">我的收藏</span>
  68. <div class="ulTCopyTxt"
  69. v-for="(i,ind) in cocoFlowList[1]" @click.stop="openNewWindow(i.url)" :key="ind+'a'">
  70. <div class="ulTCopyConT">{{ i.name }}</div>
  71. </div>
  72. </div>
  73. </div>
  74. </div>
  75. </div>
  76. </div>
  77. </div>
  78. </template>
  79. <script>
  80. import { mapGetters, mapActions } from 'vuex';
  81. import store from '../store'
  82. import { API_CONFIG } from "@/common/apiConfig";
  83. export default {
  84. props:['urlAddress'],
  85. computed: {
  86. ...mapGetters(['userinfo','userinfo2','fromL','appSign']),
  87. // 如果hk,com没有图标,默认使用cn的
  88. AppCon(){
  89. return function(c) {
  90. let k = JSON.parse(JSON.stringify(c))
  91. let data = k.filter(e=>{
  92. return e.region == this.roleUser.schoolArea || e.region == this.roleUser.orgArea
  93. })
  94. let data2 = k.filter(e=>{
  95. return e.region == 'cn'
  96. })
  97. // 如果hk,com没有图标,默认使用cn的
  98. if (!data[0].icon){
  99. data[0].icon = data2[0].icon
  100. data[0].activeIcon = data2[0].activeIcon
  101. }
  102. return data
  103. };
  104. },
  105. // 筛选是否为管理员可见,是否被删除
  106. appSignL(){
  107. return function(val){
  108. let data = []
  109. if (this.roleUser.type == 1 && this.roleUser.role == 1) {
  110. val.forEach( e =>{
  111. if (e.menuName || e.status == 0) {
  112. data.push(e)
  113. }
  114. })
  115. } else {
  116. val.forEach( e =>{
  117. if (e.menuName || (e.isAdmin == '0' && e.status == 0)) {
  118. data.push(e)
  119. }
  120. })
  121. }
  122. return data
  123. }
  124. },
  125. roleUser(){
  126. return Object.keys(this.userinfo2).length != 0 ? this.userinfo2 : this.userinfo
  127. }
  128. },
  129. data() {
  130. return {
  131. // 一级选中第几个
  132. activeL:0,
  133. visible:true,
  134. // 二级选中第几个
  135. activeLTwo: null,
  136. cocoFlowList:[],
  137. }
  138. },
  139. methods: {
  140. ...mapActions({
  141. logout: 'user/logout'
  142. }),
  143. // 跳转到看板
  144. async gotoKanban(){
  145. // 重新获取基础数据
  146. await store.dispatch('user/getschPerInfo')
  147. await store.commit('user/SET_USERINFO2', {})
  148. let num = this.userinfo.type == 1 && this.userinfo.role == 1 && this.userinfo.rrole == 1 ? 1 : 2
  149. this.$router.push({
  150. path: '/KanBan',
  151. query: {
  152. index: num,
  153. }
  154. });
  155. },
  156. mouGet(val){
  157. console.log('val',val);
  158. if(!val.includes('appStore')) return
  159. console.log('666')
  160. this.getData()
  161. },
  162. // 点击一级导航
  163. async goto(index,val = null){
  164. // console.log('goto',val);
  165. // 清空二级菜单选中状态
  166. this.activeLTwo = ''
  167. // val = null 就是点击了首页
  168. if (val) {
  169. this.activeL = index + 1
  170. }else{
  171. // 点击首页清空内容,并把标识去除
  172. await store.commit('user/SET_AppSIGN', '')
  173. this.$emit('update:urlAddress','')
  174. this.$emit('getPer')
  175. this.activeL = index
  176. return
  177. }
  178. // 点击相同应用不刷新
  179. if (this.appSign == val.toolId) return
  180. // 更新标识
  181. await store.commit('user/SET_AppSIGN', val.toolId)
  182. let url = ''
  183. // 查出对应账号的应用区域地址
  184. val.url.forEach(e => {
  185. // if (e.region == this.roleUser.schoolArea || e.region == this.roleUser.orgArea) {
  186. if (e.region == this.$region) {
  187. url = e.url
  188. }
  189. });
  190. let _userinfo = this.roleUser, //登录用户信息
  191. { userid: _userid, organizeid: _oid, type: _type, org: _org, role: _role, classid: _classId } = _userinfo; // 解构赋值获取用户信息
  192. const _TscreenType = 1, _SscreenType = 3; // 常量定义
  193. let queryString = ''
  194. if(val.argumentList && val.argumentList.length){
  195. const paramsMap = {
  196. userid: _userid,
  197. org: _org,
  198. oid: _oid,
  199. tType: _type,
  200. role: _role,
  201. classId: _classId,
  202. TscreenType: _TscreenType,
  203. SscreenType: _SscreenType
  204. };
  205. const canshu = val.argumentList
  206. .filter(param => paramsMap[param] !== undefined || param === 'type')
  207. .map(param => param === 'type' ? `tType=${paramsMap['tType']}` : `${param}=${paramsMap[param]}`);
  208. queryString = canshu.length ? (url.includes('?') ? '&' : '?') + canshu.join('&') : ''; // 生成查询字符串
  209. }
  210. let _url = url + queryString
  211. console.log('_url',_url);
  212. // let kpl = ` <iframe
  213. // allow= "camera *; microphone *;display-capture;midi;encrypted-media;"
  214. // frameborder="no"
  215. // border="0"
  216. // style="border:0;width:100%;height:100%;"
  217. // src="${_url}"
  218. // ref="${val.toolId}"
  219. // >
  220. // </iframe>`
  221. let pl = {json:_url ,stateL :true,toolId :val.toolId}
  222. // 添加打开应用
  223. this.$emit('AddAppJson',pl)
  224. },
  225. // 获取cocoFlow收藏与历史使用记录
  226. getData(){
  227. let params = [
  228. {
  229. functionName: API_CONFIG.ajax_appStoreSave.functionName,
  230. uid: this.roleUser.userid,
  231. },
  232. ];
  233. this.$ajax
  234. .post(API_CONFIG.baseUrl, params)
  235. .then((res) => {
  236. this.cocoFlowList = [res.data[0],res.data[1]]
  237. })
  238. .catch((err) => {
  239. console.log(err);
  240. this.$message.error("获取cocoFlow收藏与历史失败");
  241. });
  242. },
  243. // 点击二级导航
  244. async levTwo(val,index,aInd){
  245. console.log('val,index,aInd',val,index,aInd);
  246. this.activeL = ''
  247. this.activeL = aInd +1
  248. this.activeLTwo = `${aInd + 1}+${index}`
  249. // 点击相同应用不刷新
  250. if (this.appSign == val.toolId) return
  251. // 更新标识
  252. await store.commit('user/SET_AppSIGN', val.toolId)
  253. let url = ''
  254. val.url.forEach(e => {
  255. // if (e.region == this.roleUser.schoolArea || e.region == this.roleUser.orgArea) {
  256. if (e.region == this.$region) {
  257. url = e.url
  258. }
  259. });
  260. let _userinfo = this.roleUser, //登录用户信息
  261. { userid: _userid, organizeid: _oid, type: _type, org: _org, role: _role, classid: _classId } = _userinfo; // 解构赋值获取用户信息
  262. const _TscreenType = 1, _SscreenType = 3; // 常量定义
  263. let queryString = ''
  264. if(val.argumentList && val.argumentList.length){
  265. const paramsMap = {
  266. userid: _userid,
  267. org: _org,
  268. oid: _oid,
  269. tType: _type,
  270. role: _role,
  271. classId: _classId,
  272. TscreenType: _TscreenType,
  273. SscreenType: _SscreenType
  274. };
  275. const canshu = val.argumentList
  276. .filter(param => paramsMap[param] !== undefined || param === 'type')
  277. .map(param => param === 'type' ? `tType=${paramsMap['tType']}` : `${param}=${paramsMap[param]}`);
  278. queryString = canshu.length ? (url.includes('?') ? '&' : '?') + canshu.join('&') : ''; // 生成查询字符串
  279. }
  280. let _url = url + queryString
  281. console.log('_url',_url);
  282. // let kpl = ` <iframe
  283. // allow= "camera *; microphone *;display-capture;midi;encrypted-media;"
  284. // frameborder="no"
  285. // border="0"
  286. // style="border:0;width:100%;height:100%;"
  287. // src="${_url}"
  288. // ref="pageCon"
  289. // >
  290. // </iframe>`
  291. let pl = {json:_url ,stateL :true,toolId :val.toolId}
  292. this.$emit('AddAppJson',pl)
  293. },
  294. openNewWindow(val) {
  295. console.log(val);
  296. // // 基本用法:打开指定 URL
  297. window.open(val, "_blank");
  298. },
  299. },
  300. }
  301. </script>
  302. <style scoped>
  303. .ulTCopy{
  304. height: 90%;
  305. width: 154px;
  306. overflow: hidden;
  307. background-color: rgb(255 255 255 / 98%);
  308. border-radius: 12px;
  309. position: fixed;
  310. left: -75px;
  311. top: 70px;
  312. z-index: -100;
  313. transition: transform .5s ease;
  314. }
  315. .ulTOne:hover .ulTCopy{
  316. display: block !important;
  317. transform: translateX(164px) !important; /* 初始位置在视图之外 */
  318. z-index: -100;
  319. box-shadow: 0px 6px 30px 5px #0000000D;
  320. }
  321. .logo{
  322. margin: auto;
  323. width: 24px;
  324. height: 24px;
  325. }
  326. .iconW{
  327. width: 30px;
  328. height: 30px;
  329. display: flex;
  330. align-content: center;
  331. justify-content: center;
  332. padding: 1px;
  333. box-sizing: border-box;
  334. }
  335. .logo2 {
  336. cursor: pointer;
  337. box-sizing: border-box;
  338. width: 100%;
  339. background-color: #fff;
  340. text-align: center;
  341. }
  342. .logo2 img{
  343. width: 60px;
  344. height: 60px;
  345. }
  346. .userInfo{
  347. width: 80px;
  348. color: #374151;
  349. font-size: 12px;
  350. display: flex;
  351. flex-direction: column;
  352. align-items: center;
  353. padding: 8px;
  354. box-sizing: border-box;
  355. background-color: #fff;
  356. padding-bottom: 20px;
  357. }
  358. .left {
  359. font-family: ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji" !important;
  360. width: 80px;
  361. height: 100%;
  362. padding:23px 6px;
  363. box-sizing: border-box;
  364. background-color: #ffffff;
  365. display: flex;
  366. flex-direction: column;
  367. align-items: center;
  368. gap: 24px;
  369. overflow: auto;
  370. border-right: 1px #D5D5D5 solid;
  371. }
  372. .ulTOne{
  373. width: 100%;
  374. border-radius: 10px;
  375. display: flex;
  376. height: 48px;
  377. flex-wrap:nowrap;
  378. align-content: center;
  379. justify-content: center;
  380. position: relative;
  381. }
  382. .barT{
  383. font-size:10px;
  384. overflow: hidden;
  385. white-space: nowrap;
  386. text-overflow: ellipsis;
  387. }
  388. .menu_left {
  389. width: 32px;
  390. height: 42px;
  391. font-size: 10px;
  392. color: #64748b;
  393. box-sizing: border-box;
  394. cursor: pointer;
  395. margin: auto;
  396. display: flex;
  397. flex-direction: column;
  398. align-items: center;
  399. gap: 2px;
  400. }
  401. .ulTCopyTit{
  402. font-family: PingFang SC;
  403. font-weight: 600;
  404. font-size: 12px;
  405. letter-spacing: 0px;
  406. color: #000;
  407. height: 40px;
  408. padding: 12px 16px;
  409. box-sizing: border-box;
  410. border-bottom: .5px #e5e7eb solid;
  411. background: #fff !important;
  412. }
  413. .ulTCopyHei{
  414. display: flex;flex-direction: column;
  415. gap: 10px;
  416. overflow: auto;
  417. padding: 10px;
  418. overflow-x: hidden;
  419. height: calc(100% - 72px);
  420. }
  421. .ulTCopyTxt{
  422. box-sizing: border-box;display: flex;
  423. align-items: center;
  424. color: #374151;
  425. width: 100%;
  426. border-radius: 10px;
  427. font-size: 16px;
  428. margin: 0;
  429. }
  430. .ulTCopyTxtBlock{
  431. width: 100%;
  432. }
  433. .ulTCopyConT {
  434. width: 100%;
  435. font-size: 12px;
  436. cursor: pointer;
  437. border-radius: 8px;
  438. padding: 8px;
  439. box-sizing: border-box;
  440. white-space: nowrap;
  441. overflow: hidden;
  442. text-overflow: ellipsis;
  443. }
  444. .ulTCopyConT:hover{
  445. background: #e7e7e7;
  446. color: #000;
  447. }
  448. .ulTCopyTxtCon{
  449. display: flex;align-items: center;width: 100%;
  450. }
  451. /* .ulTCopyTxt:hover{
  452. background-color: #f3f4f6 !important;
  453. } */
  454. .cha:hover{
  455. color: #000 !important;
  456. }
  457. .ovlH{
  458. overflow: hidden;
  459. white-space: nowrap;
  460. text-overflow: ellipsis;
  461. }
  462. </style>