HomeView.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  1. <template>
  2. <div class="body">
  3. <!-- <div class="top">
  4. <div class="title">CocoClass后台管理</div>
  5. <div class="person">
  6. <div class="person_name">{{ userinfo ? userinfo.username : "" }}</div>
  7. <el-button type="text" @click="handleLogout" style="margin-left: 20px">退出</el-button>
  8. </div>
  9. </div> -->
  10. <div class="container">
  11. <div class="leftBar" style="height: 100%;">
  12. <sidebarL @getPer="getPer" :urlAddress.sync="urlAddress" ref="sidebarLRef"></sidebarL>
  13. </div>
  14. <div class="table-container">
  15. <!-- <router-view></router-view> -->
  16. <!-- 首页 -->
  17. <homepageL :urlAddress.sync="urlAddress" v-show="!appSign" ref="homepageLRef"></homepageL>
  18. <!-- 应用 -->
  19. <iframe
  20. v-if="appSign && urlAddress"
  21. allow= "camera *; microphone *;display-capture;midi;encrypted-media;"
  22. frameborder="no"
  23. border="0"
  24. scrolling="no"
  25. style="border:0;width:100%;height:100%;"
  26. :src="urlAddress"
  27. ref="pageCon"
  28. >
  29. </iframe>
  30. <!-- <div style="height: 100%;" id="pageCon"></div> -->
  31. </div>
  32. </div>
  33. </div>
  34. </template>
  35. <script>
  36. import { mapGetters, mapActions } from 'vuex';
  37. import { loginOut } from '@/api/user';
  38. import sidebarL from '../components/sidebarL.vue';
  39. import { API_CONFIG } from "@/common/apiConfig";
  40. import store from '../store'
  41. import homepageL from './homepageL.vue';
  42. export default {
  43. name: "HomeView",
  44. components:{
  45. sidebarL,
  46. homepageL
  47. },
  48. data() {
  49. return {
  50. perData:[],
  51. toolList:[],
  52. form:{},
  53. urlAddress:''
  54. }
  55. },
  56. computed: {
  57. ...mapGetters(['userinfo','appSign']),
  58. },
  59. methods: {
  60. ...mapActions({
  61. logout: 'user/logout'
  62. }),
  63. async handleLogout() {
  64. this.$confirm('确定退出吗', '提示', {
  65. confirmButtonText: '确定',
  66. cancelButtonText: '取消',
  67. type: 'warning'
  68. }).then(async () => {
  69. loginOut()
  70. .then(async () => {
  71. this.$message({
  72. message: '退出成功',
  73. type: 'success'
  74. });
  75. await this.logout();
  76. this.$router.push('/login');
  77. })
  78. .catch(err => {
  79. console.error(err);
  80. });
  81. }).catch(() => {
  82. // 取消操作
  83. });
  84. },
  85. // 获取学校权限与组织权限,优先使用学校权限,其次使用组织权限
  86. getPer() {
  87. this.$refs.homepageLRef.getData()
  88. let params = [
  89. {
  90. functionName: API_CONFIG.ajax_schoolPermission.functionName, // 调用存储过程的名称
  91. org: this.userinfo.org, //组织id
  92. oid: this.userinfo.organizeid, //学校id
  93. },
  94. ];
  95. // 发起请求
  96. this.$ajax
  97. .post(API_CONFIG.baseUrl, params)
  98. .then((res) => {
  99. let data = res.data[0]
  100. // console.log('data', data)
  101. this.perData= JSON.parse(data[0].json)
  102. this.getToolData()
  103. })
  104. .catch((err) => {
  105. console.error("请求失败,错误信息:", err);
  106. });
  107. },
  108. getToolData() {
  109. let params = [
  110. {
  111. functionName: "select_desktopToolByPage",
  112. status: "",
  113. page: 1,
  114. lim: 9999999,
  115. },
  116. ];
  117. this.$ajax
  118. .post(API_CONFIG.baseUrl, params)
  119. .then((res) => {
  120. let _data = res.data;
  121. let _list = _data[0];
  122. _list.forEach((i) => {
  123. i.url = JSON.parse(i.url);
  124. i.json = JSON.parse(i.json);
  125. i.argumentList = JSON.parse(i.argumentList);
  126. });
  127. this.toolList = _list;
  128. // console.log('_list',_list);
  129. this.setDataListToo(_list);
  130. })
  131. .catch((err) => {
  132. console.log(err);
  133. this.$message.error("获取工具数据失败");
  134. });
  135. },
  136. async setDataListToo(toolList = []) {
  137. // console.log('toolList',toolList);
  138. let _form = JSON.parse(JSON.stringify(this.perData));
  139. // _form.desktop.list.forEach((i, index) => {
  140. // let _index = toolList.findIndex((i2) => i == i2.id);
  141. // if (_index != -1) {
  142. // _form.desktop.list[index] = toolList[_index];
  143. // } else {
  144. // console.log("无工具", i);
  145. // }
  146. // });
  147. _form.admin.index.list.forEach((i, index) => {
  148. let _index = toolList.findIndex((i2) => i == i2.id);
  149. if (_index != -1) {
  150. _form.admin.index.list[index] = toolList[_index];
  151. } else {
  152. console.log("无工具", i);
  153. }
  154. });
  155. _form.admin.sidebar.list.forEach((i, index) => {
  156. if (i.children) {
  157. i.children.forEach((i2, index2) => {
  158. let _toolList = JSON.parse(JSON.stringify(toolList))
  159. let _index = _toolList.findIndex((i3) => i2 == i3.id);
  160. if (_index != -1) {
  161. _form.admin.sidebar.list[index].children[index2] = _toolList[_index];
  162. _form.admin.sidebar.list[index].children[index2].typeId = _form.admin.sidebar.list[index].typeId + "," +_toolList[_index].id;
  163. } else {
  164. console.log("无工具", i);
  165. }
  166. });
  167. } else {
  168. let _toolList = JSON.parse(JSON.stringify(toolList))
  169. let _index = _toolList.findIndex((i2) => i == i2.id);
  170. if (_index != -1) {
  171. _form.admin.sidebar.list[index] = _toolList[_index];
  172. _form.admin.sidebar.list[index].typeId =
  173. _form.admin.sidebar.list[index].id;
  174. } else {
  175. console.log("无工具", i);
  176. }
  177. }
  178. });
  179. // console.log('_form',_form);
  180. await store.commit('user/SET_FROM', _form)
  181. this.$forceUpdate();
  182. },
  183. },
  184. mounted() {
  185. this.getPer()
  186. },
  187. };
  188. </script>
  189. <style scoped>
  190. .body {
  191. width: 100%;
  192. height: 100%;
  193. overflow: hidden;
  194. font-family: ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
  195. }
  196. .container {
  197. display: flex;
  198. width: 100%;
  199. height: 100vh;
  200. }
  201. .table-container {
  202. /* display: flex;
  203. flex: 1;
  204. justify-content: center; */
  205. width: 100%;
  206. background-color: #F9FAFB;
  207. }
  208. /* .leftBar{ */
  209. /* box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px 6px rgb(0 0 0 / 0.1); */
  210. /* overflow: visible; */
  211. /* z-index: 999999999; */
  212. /* } */
  213. </style>