HomeView.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552
  1. <template>
  2. <div class="body">
  3. <div class="container">
  4. <div class="leftBar" style="height: 100%">
  5. <sidebarL
  6. @getPer="getPer"
  7. @AddAppJson="AddAppJson"
  8. ref="sidebarLRef"
  9. ></sidebarL>
  10. </div>
  11. <div class="table-container">
  12. <div class="top">
  13. <div class="topCon">
  14. <div class="title">
  15. <span v-if="roleUser.orgName">{{ roleUser.orgName }}</span>
  16. <span style="color: #0663fe; font-weight: 600">{{
  17. roleUser.schoolName
  18. }}</span>
  19. </div>
  20. <div class="person">
  21. <div class="person_name" @click="editInfo">
  22. <!-- @click="openData()" -->
  23. <img
  24. style="
  25. width: 40px;
  26. height: 40px;
  27. object-fit: cover;
  28. border-radius: 50%;
  29. cursor: pointer;
  30. "
  31. :src="
  32. roleUser.headportrait
  33. ? roleUser.headportrait
  34. : require('../assets/img/toux2.png')
  35. "
  36. alt=""
  37. />
  38. <div class="personInfo">
  39. <div class="personInfoTit">
  40. {{ roleUser.username }}
  41. </div>
  42. <div class="personInfoBri">
  43. {{ userSuffix() }}
  44. </div>
  45. </div>
  46. </div>
  47. <el-button
  48. type="text"
  49. @click="handleLogout"
  50. style="margin-left: 20px"
  51. >退出</el-button
  52. >
  53. </div>
  54. </div>
  55. </div>
  56. <!-- 首页 -->
  57. <homepageL
  58. @AddAppJson="AddAppJson"
  59. v-show="!appSign"
  60. ref="homepageLRef"
  61. ></homepageL>
  62. <!-- 循环数组展示iframe -->
  63. <div v-for="(item, index) in AppJSon" :key="index">
  64. <!-- {{ item }} -->
  65. <div style="height: calc(100vh - 60px)" v-show="item.stateL">
  66. <iframe
  67. allow="camera *; microphone *;display-capture;midi;encrypted-media;fullscreen *;"
  68. frameborder="no"
  69. style="border: 0; width: 100%; height: calc(100vh - 60px)"
  70. :src="item.json"
  71. :ref="item.toolId"
  72. >
  73. </iframe>
  74. </div>
  75. </div>
  76. <!-- 荔园首页定制工具,不保存缓存 -->
  77. <div style="height: calc(100vh - 60px)" v-if="clearifa">
  78. <iframe
  79. allow="camera *; microphone *;display-capture;midi;encrypted-media;fullscreen *;"
  80. frameborder="no"
  81. style="border: 0; width: 100%; height: calc(100vh - 60px)"
  82. :src="clearifa"
  83. >
  84. </iframe>
  85. </div>
  86. <div
  87. v-if="loading"
  88. style="
  89. position: absolute;
  90. left: 0;
  91. top: 0;
  92. width: 100%;
  93. height: 100%;
  94. background-color: #fff;
  95. display: flex;
  96. justify-content: center;
  97. align-items: center;
  98. "
  99. >
  100. <div
  101. style="display: flex; flex-direction: column; align-items: center"
  102. >
  103. <img
  104. style="height: 75px; transform: scale(2)"
  105. src="../assets/img/cocoloading.gif"
  106. alt=""
  107. />
  108. <div style="color: #0354d7">拼命加载中...</div>
  109. </div>
  110. </div>
  111. </div>
  112. </div>
  113. <userInfoA
  114. ref="userInfoA"
  115. :userid="roleUser.userid"
  116. :oid="roleUser.organizeid"
  117. :role="roleUser.role"
  118. />
  119. </div>
  120. </template>
  121. <script>
  122. import { mapGetters, mapActions } from "vuex";
  123. import { loginOut } from "@/api/user";
  124. import sidebarL from "../components/sidebarL.vue";
  125. import { API_CONFIG } from "@/common/apiConfig";
  126. import store from "../store";
  127. import userInfoA from "../components/userInfoA.vue";
  128. import homepageL from "./homepageL.vue";
  129. export default {
  130. name: "HomeView",
  131. components: {
  132. sidebarL,
  133. homepageL,
  134. userInfoA,
  135. },
  136. data() {
  137. return {
  138. AppJSon: [],
  139. loading: false,
  140. clearifa: "",
  141. // 荔园集团下的学校
  142. mergedList: [
  143. "3823a6a5-1b6e-11f0-a66a-005056924926",
  144. "292e34dc-1b6e-11f0-a66a-005056924926",
  145. "21d6b367-1b6e-11f0-a66a-005056924926",
  146. "1a1a172d-1b6e-11f0-a66a-005056924926",
  147. "1197f86b-1b6e-11f0-a66a-005056924926",
  148. "f235659b-1b6d-11f0-a66a-005056924926",
  149. "d87b62d3-1b6d-11f0-a66a-005056924926",
  150. "c25ea59b-1b6d-11f0-a66a-005056924926",
  151. ],
  152. };
  153. },
  154. computed: {
  155. ...mapGetters(["userinfo", "appSign", "userinfo2"]),
  156. userSuffix() {
  157. let yym = "";
  158. return function () {
  159. // this.userinfo.role == 1 && this.userinfo.rrole == 1 && this.userinfo.type == 1 &&
  160. yym =
  161. Object.keys(this.userinfo2).length != 0
  162. ? this.userinfo2
  163. : this.userinfo;
  164. let val = yym.accountNumber;
  165. let userName = JSON.parse(JSON.stringify(val));
  166. const regEmail = new RegExp(
  167. "^[A-Za-z0-9_-]+@[a-zA-Z0-9_-]+(\\.[a-zA-Z0-9_-]+)+$"
  168. );
  169. // // 判断用户输入账户带不带后缀
  170. if (!regEmail.test(userName)) {
  171. console.log("111");
  172. } else {
  173. const parts = userName.split("@");
  174. userName = parts[0];
  175. }
  176. return userName;
  177. };
  178. },
  179. roleUser() {
  180. // this.userinfo.role == 1 && this.userinfo.rrole == 1 && this.userinfo.type == 1&&
  181. return Object.keys(this.userinfo2).length != 0
  182. ? this.userinfo2
  183. : this.userinfo;
  184. },
  185. },
  186. methods: {
  187. ...mapActions({
  188. logout: "user/logout",
  189. }),
  190. // 打开个人信息
  191. openData() {
  192. window.topU.U.MD.D.I.openApplication("my");
  193. },
  194. // 打开编辑弹框
  195. editInfo() {
  196. this.$refs.userInfoA.openDig();
  197. },
  198. // 打开平台应用工具
  199. AddAppJson(val) {
  200. console.log("AddAppJson", val);
  201. // 荔园首页工具切换,不缓存工具
  202. if (val.clearL) {
  203. this.AppJSon.forEach((e) => {
  204. this.$set(e, "stateL", false); // 使用 Vue.set 确保响应式
  205. });
  206. this.loading = true;
  207. this.clearifa = val.json;
  208. // 打开平台工具加载两秒
  209. setTimeout(() => {
  210. this.loading = false;
  211. }, 2000);
  212. return;
  213. }
  214. // 判断有没有打开过这个应用
  215. let data = this.AppJSon.filter((e) => {
  216. return val.toolId == e.toolId;
  217. });
  218. if (data.length == 0) {
  219. //为0则添加进列表,并将其他的展示状态改为false
  220. this.loading = true;
  221. // 打开平台工具加载两秒
  222. setTimeout(() => {
  223. this.loading = false;
  224. }, 2000);
  225. this.AppJSon.forEach((e) => {
  226. this.$set(e, "stateL", false); // 使用 Vue.set 确保响应式
  227. });
  228. this.AppJSon.push(val);
  229. } else {
  230. this.AppJSon.forEach((e) => {
  231. if (val.toolId == e.toolId) {
  232. //已经打开过了,将点击的工具展示状态改为false
  233. this.$set(e, "stateL", true); // 使用 Vue.set 确保响应式
  234. } else {
  235. this.$set(e, "stateL", false); // 确保响应式更新
  236. }
  237. });
  238. setTimeout(() => {
  239. // console.log('this.$refs.appRef.contentWindow.document.body;', this.$refs[val.toolId][0].contentWindow.document.body);
  240. if (!this.$refs[val.toolId][0].contentWindow.document.body) {
  241. this.$refs[val.toolId][0].contentWindow.location.reload();
  242. }
  243. }, 2000);
  244. }
  245. },
  246. async handleLogout() {
  247. this.$confirm("确定退出吗", "提示", {
  248. confirmButtonText: "确定",
  249. cancelButtonText: "取消",
  250. type: "warning",
  251. })
  252. .then(async () => {
  253. loginOut()
  254. .then(async () => {
  255. this.$message({
  256. message: "退出成功",
  257. type: "success",
  258. });
  259. await this.logout();
  260. // this.$router.push("/login");
  261. })
  262. .catch((err) => {
  263. console.error(err);
  264. });
  265. })
  266. .catch(() => {
  267. // 取消操作
  268. });
  269. },
  270. // 获取学校权限与组织权限,优先使用学校权限,其次使用组织权限
  271. async getPer() {
  272. this.clearifa = "";
  273. // 查询首页应用
  274. this.$refs.homepageLRef.getData();
  275. //查询cocofrow最近使用与收藏
  276. this.$refs.sidebarLRef.getData();
  277. let params = [
  278. {
  279. functionName: API_CONFIG.ajax_schoolPermission.functionName, // 调用存储过程的名称
  280. org: this.roleUser.org, //组织id
  281. oid: this.roleUser.organizeid, //学校id
  282. },
  283. ];
  284. // 获取学校权限与组织权限,优先使用学校权限,其次使用组织权限
  285. // 第一步
  286. let res = await this.$ajax.post(API_CONFIG.baseUrl, params);
  287. let perData = JSON.parse(res.data[0][0].json);
  288. // console.log('perData',JSON.parse(JSON.stringify(perData)));
  289. // 第二步
  290. let params2 = [
  291. {
  292. functionName: "select_desktopToolByPage",
  293. status: "",
  294. page: 1,
  295. lim: 9999999,
  296. },
  297. ];
  298. let res2 = await this.$ajax.post(API_CONFIG.baseUrl, params2);
  299. let toolList = res2.data[0];
  300. toolList.forEach((i) => {
  301. i.url = JSON.parse(i.url);
  302. i.json = JSON.parse(i.json);
  303. i.argumentList = JSON.parse(i.argumentList);
  304. });
  305. // let params3 = [
  306. // {
  307. // functionName: "select_schUsuallyApp",
  308. // userid: "",
  309. // stand: "cn",
  310. // },
  311. // ];
  312. // let res3 = await this.$ajax.post(API_CONFIG.baseUrl, params3);
  313. // let _list = res3.data[0];
  314. // _list.forEach((i) => {
  315. // i.json = JSON.parse(i.json);
  316. // });
  317. // let appList = _list;
  318. // 第三步
  319. perData.desktop.list.forEach((i, index) => {
  320. let _index = toolList.findIndex((i2) => i == i2.id);
  321. if (_index != -1) {
  322. perData.desktop.list[index] = toolList[_index];
  323. } else {
  324. console.log("无工具", i);
  325. }
  326. });
  327. // console.log(
  328. // "perData.admin.cocoFlow",
  329. // JSON.parse(JSON.stringify(perData.admin))
  330. // );
  331. // if (perData.admin.cocoFlow) {
  332. // perData.admin.cocoFlow.forEach((i, index) => {
  333. // let _index = appList.findIndex((i2) => i.id == i2.id);
  334. // if (_index != -1) {
  335. // let _setData = appList[_index];
  336. // _setData.setIcon = i.setIcon;
  337. // perData.admin.cocoFlow[index] = _setData;
  338. // } else {
  339. // console.log("无应用", i);
  340. // }
  341. // });
  342. // }
  343. // if (perData.admin.cocoFlow2) {
  344. // perData.admin.cocoFlow2.forEach((i, index) => {
  345. // let _index = appList.findIndex((i2) => i.id == i2.id);
  346. // if (_index != -1) {
  347. // let _setData = appList[_index];
  348. // _setData.setIcon = i.setIcon;
  349. // perData.admin.cocoFlow2[index] = _setData;
  350. // } else {
  351. // console.log("无应用", i);
  352. // }
  353. // });
  354. // }
  355. // if (perData.admin.CampusF && perData.admin.CampusF.appList) {
  356. // perData.admin.CampusF.appList.forEach((i, index) => {
  357. // let _index = appList.findIndex((i2) => i.id == i2.id);
  358. // if (_index != -1) {
  359. // let _setData = appList[_index];
  360. // _setData.setIcon = i.setIcon;
  361. // perData.admin.CampusF.appList[index] = _setData;
  362. // } else {
  363. // console.log("无应用", i);
  364. // }
  365. // });
  366. // }
  367. perData.admin.index.list.forEach((i, index) => {
  368. let _index = toolList.findIndex((i2) => i == i2.id);
  369. if (_index != -1) {
  370. perData.admin.index.list[index] = toolList[_index];
  371. perData.admin.index.list[index].hovered = false;
  372. } else {
  373. console.log("无工具", i);
  374. }
  375. });
  376. perData.admin.sidebar.list.forEach((i, index) => {
  377. if (i.children) {
  378. i.children.forEach((i2, index2) => {
  379. let _toolList = JSON.parse(JSON.stringify(toolList));
  380. let _index = _toolList.findIndex((i3) => i2 == i3.id);
  381. if (_index != -1) {
  382. perData.admin.sidebar.list[index].children[index2] =
  383. _toolList[_index];
  384. perData.admin.sidebar.list[index].children[index2].typeId =
  385. perData.admin.sidebar.list[index].typeId +
  386. "," +
  387. _toolList[_index].id;
  388. } else {
  389. console.log("无工具", i);
  390. }
  391. });
  392. } else {
  393. let _toolList = JSON.parse(JSON.stringify(toolList));
  394. let _index = _toolList.findIndex((i2) => i == i2.id);
  395. if (_index != -1) {
  396. perData.admin.sidebar.list[index] = _toolList[_index];
  397. perData.admin.sidebar.list[index].typeId =
  398. perData.admin.sidebar.list[index].id;
  399. } else {
  400. console.log("无工具", i);
  401. }
  402. }
  403. });
  404. await store.commit("user/SET_FROM", perData);
  405. // 获取后台管理设置常见应用
  406. this.$refs.homepageLRef.getadmincocoFlow();
  407. },
  408. },
  409. mounted() {
  410. console.log("重新获取数据");
  411. this.getPer();
  412. if (
  413. !this.roleUser.cclassid &&
  414. !this.roleUser.rrole &&
  415. this.mergedList.includes(this.roleUser.org)
  416. ) {
  417. this.editInfo();
  418. }
  419. },
  420. };
  421. </script>
  422. <style scoped>
  423. .top {
  424. width: 100%;
  425. padding: 0 90px;
  426. display: flex;
  427. height: 60px;
  428. box-sizing: border-box;
  429. }
  430. .topCon {
  431. display: flex;
  432. width: 100%;
  433. justify-content: space-between;
  434. align-items: center;
  435. }
  436. .body {
  437. width: 100%;
  438. height: 100%;
  439. overflow: hidden;
  440. font-family: ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji",
  441. "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
  442. }
  443. .title {
  444. font-family: PingFang SC;
  445. font-weight: 400;
  446. font-size: 14px;
  447. line-height: 100%;
  448. letter-spacing: 0%;
  449. color: #969ba3;
  450. display: flex;
  451. gap: 11px;
  452. }
  453. .person {
  454. display: flex;
  455. align-items: center;
  456. }
  457. .person_name {
  458. display: flex;
  459. gap: 9px;
  460. }
  461. .personInfo {
  462. display: flex;
  463. flex-direction: column;
  464. justify-content: space-between;
  465. padding: 5px 0 2px;
  466. box-sizing: border-box;
  467. }
  468. .personInfoTit {
  469. font-family: PingFang SC;
  470. font-weight: 500;
  471. font-size: 14px;
  472. line-height: 100%;
  473. color: #000000;
  474. }
  475. .personInfoBri {
  476. font-family: PingFang SC;
  477. font-weight: 300;
  478. font-size: 10px;
  479. line-height: 100%;
  480. color: #969ba3;
  481. }
  482. .container {
  483. display: flex;
  484. width: 100%;
  485. height: 100vh;
  486. }
  487. .container >>> .el-loading-mask {
  488. z-index: 0;
  489. }
  490. .table-container {
  491. /* display: flex;
  492. flex: 1;
  493. justify-content: center; */
  494. width: 100%;
  495. background-color: #f9fafb;
  496. position: relative;
  497. }
  498. .leftBar {
  499. /* box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px 6px rgb(0 0 0 / 0.1); */
  500. /* overflow: visible; */
  501. z-index: 999;
  502. }
  503. </style>