HomeView.vue 10 KB

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