HomeView.vue 10 KB

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