HomeView.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383
  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. // this.userinfo.role == 1 && this.userinfo.rrole == 1 && this.userinfo.type == 1 &&
  83. yym = Object.keys(this.userinfo2).length != 0 ? this.userinfo2 : this.userinfo
  84. let val = yym.accountNumber
  85. let userName = JSON.parse(JSON.stringify(val))
  86. const regEmail = new RegExp("^[A-Za-z0-9_-]+@[a-zA-Z0-9_-]+(\\.[a-zA-Z0-9_-]+)+$");
  87. // // 判断用户输入账户带不带后缀
  88. if (!regEmail.test(userName)) {
  89. console.log('111');
  90. } else {
  91. const parts = userName.split('@');
  92. userName = parts[0];
  93. }
  94. return userName
  95. }
  96. },
  97. roleUser(){
  98. // this.userinfo.role == 1 && this.userinfo.rrole == 1 && this.userinfo.type == 1&&
  99. return Object.keys(this.userinfo2).length != 0 ? this.userinfo2 : this.userinfo
  100. }
  101. },
  102. methods: {
  103. ...mapActions({
  104. logout: 'user/logout'
  105. }),
  106. openData(){
  107. window.topU.U.MD.D.I.openApplication('my')
  108. },
  109. // 打开平台应用工具
  110. AddAppJson(val){
  111. console.log('val',val);
  112. // 判断有没有打开过这个应用
  113. let data = this.AppJSon.filter(e=>{
  114. return val.toolId == e.toolId
  115. })
  116. // console.log('data',data);
  117. if (data.length == 0) { //为0则添加进列表,并将其他的展示状态改为false
  118. this.loading = true
  119. // 打开平台工具加载两秒
  120. setTimeout(() => {
  121. this.loading = false
  122. }, 2000);
  123. this.AppJSon.forEach(e=>{
  124. this.$set(e, 'stateL', false); // 使用 Vue.set 确保响应式
  125. })
  126. this.AppJSon.push(val)
  127. }else{
  128. this.AppJSon.forEach(e=>{
  129. if (val.toolId == e.toolId) { //已经打开过了,将点击的工具展示状态改为false
  130. this.$set(e, 'stateL', true); // 使用 Vue.set 确保响应式
  131. }else{
  132. this.$set(e, 'stateL', false); // 确保响应式更新
  133. }
  134. })
  135. }
  136. },
  137. async handleLogout() {
  138. this.$confirm('确定退出吗', '提示', {
  139. confirmButtonText: '确定',
  140. cancelButtonText: '取消',
  141. type: 'warning'
  142. }).then(async () => {
  143. loginOut()
  144. .then(async () => {
  145. this.$message({
  146. message: '退出成功',
  147. type: 'success'
  148. });
  149. await this.logout();
  150. this.$router.push('/login');
  151. })
  152. .catch(err => {
  153. console.error(err);
  154. });
  155. }).catch(() => {
  156. // 取消操作
  157. });
  158. },
  159. // 获取学校权限与组织权限,优先使用学校权限,其次使用组织权限
  160. getPer() {
  161. // 查询首页应用
  162. this.$refs.homepageLRef.getData()
  163. //查询cocofrow最近使用与收藏
  164. this.$refs.sidebarLRef.getData()
  165. let params = [
  166. {
  167. functionName: API_CONFIG.ajax_schoolPermission.functionName, // 调用存储过程的名称
  168. org: this.roleUser.org, //组织id
  169. oid: this.roleUser.organizeid, //学校id
  170. },
  171. ];
  172. // 发起请求
  173. this.$ajax
  174. .post(API_CONFIG.baseUrl, params)
  175. .then((res) => {
  176. let data = res.data[0]
  177. // console.log('data', data)
  178. this.perData= JSON.parse(data[0].json)
  179. this.getToolData()
  180. })
  181. .catch((err) => {
  182. console.error("请求失败,错误信息:", err);
  183. });
  184. },
  185. getToolData() {
  186. let params = [
  187. {
  188. functionName: "select_desktopToolByPage",
  189. status: "",
  190. page: 1,
  191. lim: 9999999,
  192. },
  193. ];
  194. this.$ajax
  195. .post(API_CONFIG.baseUrl, params)
  196. .then((res) => {
  197. let _data = res.data;
  198. let _list = _data[0];
  199. _list.forEach((i) => {
  200. i.url = JSON.parse(i.url);
  201. i.json = JSON.parse(i.json);
  202. i.argumentList = JSON.parse(i.argumentList);
  203. });
  204. this.toolList = _list;
  205. // console.log('_list',_list);
  206. this.setDataListToo(_list);
  207. })
  208. .catch((err) => {
  209. console.log(err);
  210. this.$message.error("获取工具数据失败");
  211. });
  212. },
  213. async setDataListToo(toolList = []) {
  214. // console.log('toolList',toolList);
  215. let _form = JSON.parse(JSON.stringify(this.perData));
  216. // _form.desktop.list.forEach((i, index) => {
  217. // let _index = toolList.findIndex((i2) => i == i2.id);
  218. // if (_index != -1) {
  219. // _form.desktop.list[index] = toolList[_index];
  220. // } else {
  221. // console.log("无工具", i);
  222. // }
  223. // });
  224. _form.admin.index.list.forEach((i, index) => {
  225. let _index = toolList.findIndex((i2) => i == i2.id);
  226. if (_index != -1) {
  227. _form.admin.index.list[index] = toolList[_index];
  228. _form.admin.index.list[index].hovered = false
  229. } else {
  230. console.log("无工具", i);
  231. }
  232. });
  233. _form.admin.sidebar.list.forEach((i, index) => {
  234. if (i.children) {
  235. i.children.forEach((i2, index2) => {
  236. let _toolList = JSON.parse(JSON.stringify(toolList))
  237. let _index = _toolList.findIndex((i3) => i2 == i3.id);
  238. if (_index != -1) {
  239. _form.admin.sidebar.list[index].children[index2] = _toolList[_index];
  240. _form.admin.sidebar.list[index].children[index2].typeId = _form.admin.sidebar.list[index].typeId + "," +_toolList[_index].id;
  241. } else {
  242. console.log("无工具", i);
  243. }
  244. });
  245. } else {
  246. let _toolList = JSON.parse(JSON.stringify(toolList))
  247. let _index = _toolList.findIndex((i2) => i == i2.id);
  248. if (_index != -1) {
  249. _form.admin.sidebar.list[index] = _toolList[_index];
  250. _form.admin.sidebar.list[index].typeId =
  251. _form.admin.sidebar.list[index].id;
  252. } else {
  253. console.log("无工具", i);
  254. }
  255. }
  256. });
  257. // console.log('_form',_form);
  258. await store.commit('user/SET_FROM', _form)
  259. // 获取后台管理设置常见应用
  260. this.$refs.homepageLRef.getadmincocoFlow()
  261. this.$forceUpdate();
  262. },
  263. },
  264. mounted() {
  265. console.log('重新获取数据');
  266. this.getPer()
  267. },
  268. };
  269. </script>
  270. <style scoped>
  271. .top{
  272. width: 100%;
  273. padding: 0 90px;
  274. display: flex;
  275. height: 60px;
  276. box-sizing: border-box;
  277. }
  278. .topCon{
  279. display: flex;
  280. width: 100%;
  281. justify-content: space-between;
  282. align-items: center;
  283. }
  284. .body {
  285. width: 100%;
  286. height: 100%;
  287. overflow: hidden;
  288. font-family: ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
  289. }
  290. .title{
  291. font-family: PingFang SC;
  292. font-weight: 400;
  293. font-size: 14px;
  294. line-height: 100%;
  295. letter-spacing: 0%;
  296. color: #969BA3;
  297. display: flex;
  298. gap: 11px;
  299. }
  300. .person{
  301. display: flex;
  302. align-items: center;
  303. }
  304. .person_name{
  305. display: flex;
  306. gap: 9px;
  307. }
  308. .personInfo{
  309. display: flex;
  310. flex-direction: column;
  311. justify-content: space-between;
  312. }
  313. .personInfoTit{
  314. font-family: PingFang SC;
  315. font-weight: 500;
  316. font-size: 16px;
  317. line-height: 100%;
  318. color: #000000;
  319. }
  320. .personInfoBri{
  321. font-family: PingFang SC;
  322. font-weight: 300;
  323. font-size: 10px;
  324. line-height: 100%;
  325. color: #969BA3;
  326. }
  327. .container {
  328. display: flex;
  329. width: 100%;
  330. height: 100vh;
  331. }
  332. .container >>> .el-loading-mask{
  333. z-index: 0;
  334. }
  335. .table-container {
  336. /* display: flex;
  337. flex: 1;
  338. justify-content: center; */
  339. width: 100%;
  340. background-color: #F9FAFB;
  341. position: relative;
  342. }
  343. .leftBar{
  344. /* box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px 6px rgb(0 0 0 / 0.1); */
  345. /* overflow: visible; */
  346. z-index: 999;
  347. }
  348. </style>