HomeView.vue 5.9 KB

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