indexCommon.vue 28 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039
  1. <template>
  2. <div class="common-layout">
  3. <el-container>
  4. <el-header class="nav" style="position: sticky; top: 0; left: 0; width: 100%; z-index: 999">
  5. <div class="nav-top">
  6. <div>
  7. <img class="logoImg" src="@/assets/images/logos.png" /><span>聚合智慧文档管理系统</span>
  8. </div>
  9. <div class="search">
  10. <el-input v-model="searchText" maxlength="32" class="w-50 m-2" size="small" placeholder="搜索文件"
  11. suffix-icon="Search" clearable @keyup.enter="toSearch" />
  12. </div>
  13. <div>
  14. <el-dropdown @command="handleCommand" class="right-menu-item hover-effect" trigger="click">
  15. <div class="avatar-wrapper">
  16. <img :src="userStore.avatar
  17. ? userStore.avatar
  18. : '@/assets/images/profile.png'
  19. " class="head-img" /><span style="cursor: pointer;margin-right: 6px;">{{ userStore.name }}</span>
  20. <el-icon>
  21. <ArrowDown />
  22. </el-icon>
  23. </div>
  24. <template #dropdown>
  25. <el-dropdown-menu>
  26. <router-link to="/user/profile">
  27. <el-dropdown-item>个人中心</el-dropdown-item>
  28. </router-link>
  29. <el-dropdown-item divided command="logout">
  30. <span>退出登录</span>
  31. </el-dropdown-item>
  32. </el-dropdown-menu>
  33. </template>
  34. </el-dropdown>
  35. </div>
  36. </div>
  37. </el-header>
  38. <el-container>
  39. <el-aside width="92px" class="asides">
  40. <div class="aside-con">
  41. <router-link :to="item.path" v-for="(item, index) in menuList.data" :key="index"
  42. @click="clickPath(index, item)">
  43. <div style="position: relative" :class="$route.path == item.path
  44. ? 'acitve-img-style img-style'
  45. : 'img-style'
  46. ">
  47. <img :src="$route.path == item.path ? item.beimgs : item.imgs" />
  48. <div class="text-style" v-if="$route.path != item.path">
  49. {{ item.label }}
  50. </div>
  51. <span class="yuandian" v-if="hasNewMessage &&
  52. item.path == '/index' &&
  53. ($route.path != item.path || isSwitchFileIframe)
  54. "></span>
  55. </div>
  56. </router-link><br />
  57. </div>
  58. </el-aside>
  59. <el-main class="main">
  60. <div class="tab_box">
  61. <!-- <el-tabs
  62. v-model="editableTabsValue"
  63. @tab-change="clickTab"
  64. @tab-add="addTab"
  65. type="card"
  66. class="common-tabs"
  67. > -->
  68. <el-tabs v-model="editableTabsValue" @tab-add="addTab" type="card" class="common-tabs">
  69. <!-- <el-tab-pane label="首页" @click="clickTab('/index')"> </el-tab-pane> -->
  70. <el-tab-pane v-for="(item, index) in toRaw(editableTabs)" :key="item.path" :label="item.label"
  71. :name="item.path" :data-item="JSON.stringify(item)">
  72. <template #label>
  73. <div class="tab_pane" @click="paneClick(item)">
  74. <div class="tab_text">{{ item.label }}</div>
  75. <img v-if="item.label != '首页'" src="@/assets/images/close.png" @click="closeTab(item, index, $event)"
  76. alt="" />
  77. </div>
  78. <!-- <router-link
  79. :key="item"
  80. :data-path="item.path"
  81. :to="{
  82. path: item.path,
  83. query: { row: item.clickRowId },
  84. }"
  85. @click="paneClick(item)"
  86. class="tags-view-item"
  87. >
  88. {{ item.label }}
  89. </router-link> -->
  90. </template>
  91. </el-tab-pane>
  92. <!-- 文件的iframe -->
  93. <div v-for="item in iFrameData" :key="item.id">
  94. <el-tab-pane :label="item.name" :name="item.id" v-if="item.src">
  95. <template #label>
  96. <div class="tab_pane" @click="filePaneClick(item)">
  97. <div class="tab_text">{{ item.name }}</div>
  98. <img src="@/assets/images/close.png" @click="closeFileTab(item, index, $event)" alt="" />
  99. </div>
  100. </template>
  101. </el-tab-pane>
  102. </div>
  103. </el-tabs>
  104. </div>
  105. <div v-show="isAlive">
  106. <router-view v-slot="{ Component }" :key="$router.currentRoute.value.fullPath">
  107. <KeepAlive :exclude="['identifyFont', 'allback', 'search']">
  108. <component :is="Component" />
  109. </KeepAlive>
  110. </router-view>
  111. </div>
  112. <div v-show="!isAlive" style="width: 100%">
  113. <div v-for="item in iFrameData" :key="item.id">
  114. <div style="width: 100%" v-show="item.show">
  115. <iframe :src="item.src" frameborder="0" :id="`iframe${item.id}`" :name="`iframe${item.id}`" width="100%"
  116. height="800px" class="iframeBox" v-show="item.show"></iframe>
  117. </div>
  118. </div>
  119. </div>
  120. </el-main>
  121. </el-container>
  122. </el-container>
  123. </div>
  124. </template>
  125. <script setup>
  126. import { nextTick, onMounted, provide, ref, watchEffect, watch } from "vue";
  127. import { ElMessageBox, ElMessage } from "element-plus";
  128. import useAppStore from "@/store/modules/app";
  129. import useUserStore from "@/store/modules/user";
  130. import useSettingsStore from "@/store/modules/settings";
  131. import Cookies from "js-cookie";
  132. import chat from "@/assets/images/chat.png";
  133. import bechat from "@/assets/images/bechat.png";
  134. import zuijin from "@/assets/images/zuijin.png";
  135. import bezuijin from "@/assets/images/bezuijin.png";
  136. import colloect from "@/assets/images/colloect.png";
  137. import becolloect from "@/assets/images/becolloect.png";
  138. import system from "@/assets/images/system.png";
  139. import issystem from "@/assets/images/issystem.png";
  140. import my from "@/assets/images/my.png";
  141. import bemy from "@/assets/images/bemy.png";
  142. import bumen from "@/assets/images/bumen.png";
  143. import bebumen from "@/assets/images/bebumen.png";
  144. import common from "@/assets/images/common.png";
  145. import becommon from "@/assets/images/becommon.png";
  146. import chuanshu from "@/assets/images/chuanshu.png";
  147. import bechuanshu from "@/assets/images/bechuanshu.png";
  148. import highsearch from "@/assets/images/highsearch.png";
  149. import behighsearch from "@/assets/images/behighsearch.png";
  150. import manyBody from "@/assets/images/manyBody.png";
  151. import manyBodyFalse from "@/assets/images/manyBodyFalse.png";
  152. import { AppMain, Navbar, Settings, TagsView } from "./components";
  153. import { flieSearch } from "@/api/search/search.js";
  154. import { useRouter, useRoute } from "vue-router";
  155. import useWebsoctStore from "@/store/modules/websocket";
  156. import { toRaw } from "@vue/reactivity";
  157. import iFrame from "@/components/iFrame/index.vue";
  158. const websoctStore = useWebsoctStore();
  159. const router = useRouter(); //注册路由
  160. const route = useRoute();
  161. const appStore = useAppStore();
  162. const userStore = useUserStore();
  163. const settingsStore = useSettingsStore();
  164. const searchText = ref(""); //搜索ipt的值
  165. const selectValue = ref(1); //文档空间类型
  166. const wangzhi = import.meta.env.VITE_APP_BASE_API;
  167. const isAlive = ref(true);
  168. const toFileData = ref();
  169. const uid = useUserStore().uid;
  170. let hasNewMessage = ref(false)
  171. let isSwitchFileIframe = ref(false); //是否切换到文件预览标签
  172. const iFrameData = ref(JSON.parse(sessionStorage.getItem('fileTabData')) || [
  173. {
  174. id: 1,
  175. // src: `${window.location.origin}/fileEdit?clickRowId=113`,
  176. show: false,
  177. name: "file1",
  178. docId: ''
  179. },
  180. {
  181. id: 2,
  182. src: ``,
  183. // src: `http://192.168.1.9:81/fileEdit?clickRowId=1198`,
  184. show: false,
  185. name: "file2",
  186. docId: ''
  187. },
  188. {
  189. id: 3,
  190. src: ``,
  191. show: false,
  192. name: "",
  193. docId: ''
  194. },
  195. {
  196. id: 4,
  197. src: ``,
  198. show: false,
  199. name: "",
  200. docId: ''
  201. },
  202. {
  203. id: 5,
  204. src: ``,
  205. show: false,
  206. name: "",
  207. docId: ''
  208. },
  209. {
  210. id: 6,
  211. src: ``,
  212. show: false,
  213. name: "",
  214. docId: ''
  215. },
  216. {
  217. id: 7,
  218. src: ``,
  219. show: false,
  220. name: "",
  221. docId: ''
  222. },
  223. {
  224. id: 8,
  225. src: ``,
  226. show: false,
  227. name: "",
  228. docId: ''
  229. },
  230. {
  231. id: 9,
  232. src: ``,
  233. show: false,
  234. name: "",
  235. docId: ''
  236. },
  237. {
  238. id: 10,
  239. src: ``,
  240. show: false,
  241. name: "",
  242. docId: ''
  243. },
  244. ]);
  245. //--------tabs-----------------
  246. let tabIndex = 2;
  247. const editableTabsValue = ref(JSON.parse(sessionStorage.getItem('editableTabsValue')) || "/index");
  248. // const editableTabsValue = ref("/index");
  249. const editableTabs = ref(JSON.parse(sessionStorage.getItem('tabData')) || [{ label: '首页', path: '/reindex' }]);
  250. // const removeTab = (targetName) => {
  251. // const tabs = editableTabs.value;
  252. // let activeName = editableTabsValue.value;
  253. // if (activeName === targetName) {
  254. // tabs.forEach((tab, index) => {
  255. // if (tab.name === targetName) {
  256. // const nextTab = tabs[index + 1] || tabs[index - 1];
  257. // if (nextTab) {
  258. // activeName = nextTab.name;
  259. // }
  260. // }
  261. // });
  262. // }
  263. // editableTabsValue.value = activeName;
  264. // editableTabs.value = tabs.filter((tab) => tab.name !== targetName);
  265. // };
  266. //-------------------------
  267. function reload() {
  268. isAlive.value = false;
  269. nextTick(() => {
  270. isAlive.value = true;
  271. });
  272. }
  273. provide("reload", reload);
  274. function toggleSideBar() {
  275. appStore.toggleSideBar();
  276. }
  277. const logingName = ref("");
  278. let lisetenMessageTime = null;
  279. onMounted(() => {
  280. logingName.value = Cookies.get("username");
  281. clearInterval(lisetenMessageTime)
  282. lisetenMessageTime = setInterval(() => {
  283. //if(router.currentRoute.value.path=='/index') return;
  284. //console.log("===============window.noReadList:", localStorage.getItem("noreadlist"),'===========',isSwitchFileIframe.value)
  285. let tmplist = localStorage.getItem("noreadlist")
  286. if (tmplist == null || tmplist == '') {
  287. hasNewMessage.value = false
  288. return
  289. }
  290. tmplist = JSON.parse(tmplist);
  291. if (tmplist != null) hasNewMessage.value = true
  292. else hasNewMessage.value = false
  293. }, 1000);
  294. // console.log('onMt',editableTabsValue.value);
  295. // console.log('type',typeof editableTabsValue.value);
  296. nextTick(() => { // 要放在对响应式数据修改之后
  297. if (typeof editableTabsValue.value == 'number') {
  298. setTimeout(() => {
  299. iframeSize(editableTabsValue.value)
  300. }, 1000);
  301. }
  302. })
  303. // console.log('router',router)
  304. });
  305. watchEffect(async () => {
  306. if (router.currentRoute.value.path == '/index') return;
  307. if (websoctStore.noReadList != null) hasNewMessage.value = true
  308. else hasNewMessage.value = false
  309. // console.log("===============websoctStore.noReadList:",websoctStore.noReadList,'===========',hasNewMessage.value)
  310. });
  311. function handleCommand(command) {
  312. switch (command) {
  313. case "setLayout":
  314. setLayout();
  315. break;
  316. case "logout":
  317. logout();
  318. break;
  319. default:
  320. break;
  321. }
  322. }
  323. function logout() {
  324. ElMessageBox.confirm("确定注销并退出系统吗?", "提示", {
  325. confirmButtonText: "确定",
  326. cancelButtonText: "取消",
  327. type: "warning",
  328. })
  329. .then(() => {
  330. sessionStorage.clear()
  331. userStore.logOut().then(() => {
  332. location.href = "/index";
  333. });
  334. })
  335. .catch(() => { });
  336. }
  337. // 跳转到全文搜索
  338. const toSearch = async () => {
  339. if (!searchText.value) return;
  340. // console.log('searchText = ',searchText.value);
  341. const query = {
  342. keyword: searchText.value,
  343. isAsc: "asc",
  344. orderByColumn: "createTime",
  345. pageSize: 3,
  346. pageNum: 1,
  347. };
  348. const res = await flieSearch(query);
  349. console.log("res", res);
  350. if (res) {
  351. const itemData = {
  352. name:'全局搜索',
  353. path:'search',
  354. clickRowId:{
  355. searchData: res,
  356. searchText: searchText.value,
  357. }
  358. }
  359. addFolderAdd(itemData)
  360. // console.log("res", res);
  361. // console.log("router", route.path);
  362. // if (route.path != "/search") {
  363. // let listArr = JSON.stringify(res);
  364. // router.push({
  365. // name: 'search',
  366. // params: {
  367. // listArr: listArr,
  368. // searchText: searchText.value
  369. // }
  370. // });
  371. // } else {
  372. // router.replace({
  373. // path: "/allback",
  374. // query: {
  375. // searchData: JSON.stringify(res),
  376. // searchText: searchText.value,
  377. // },
  378. // });
  379. // }
  380. }
  381. };
  382. const emits = defineEmits(["setLayout"]);
  383. function setLayout() {
  384. emits("setLayout");
  385. }
  386. const clickId = ref("");
  387. const menuList = reactive({
  388. data: [
  389. {
  390. label: "会话消息",
  391. path: "/index",
  392. imgs: chat,
  393. beimgs: bechat,
  394. },
  395. // {
  396. // label: "接口",
  397. // path: "/swagger",
  398. // imgs: chat,
  399. // beimgs: bechat,
  400. // disabled:true
  401. // },
  402. {
  403. label: "最近文件",
  404. path: "/recent",
  405. imgs: zuijin,
  406. beimgs: bezuijin,
  407. },
  408. {
  409. label: "收藏文件",
  410. path: "/collect",
  411. imgs: colloect,
  412. beimgs: becolloect,
  413. },
  414. {
  415. label: "我的文件",
  416. path: "/myfile",
  417. imgs: my,
  418. beimgs: bemy,
  419. },
  420. {
  421. label: "部门文件",
  422. path: "/department",
  423. imgs: bumen,
  424. beimgs: bebumen,
  425. },
  426. {
  427. label: "公共文件",
  428. path: "/publicment",
  429. imgs: common,
  430. beimgs: becommon,
  431. },
  432. {
  433. label: "高级搜索",
  434. path: "/highsearch",
  435. imgs: highsearch,
  436. beimgs: behighsearch,
  437. },
  438. // {
  439. // label: "传输列表",
  440. // path: "/transFile",
  441. // imgs: chuanshu,
  442. // beimgs: bechuanshu,
  443. // },
  444. // {
  445. // label: "系统管理",
  446. // path: "/admin",
  447. // imgs: system,
  448. // beimgs: issystem,
  449. // },
  450. {
  451. label: "我的协作",
  452. path: "/myjoin",
  453. imgs: manyBody,
  454. beimgs: manyBodyFalse,
  455. },
  456. ],
  457. });
  458. const roles = useUserStore().roles;
  459. const permissionRoles = ['admin', 'dept', 'system', 'audit']
  460. const super_admin = "admin";
  461. const hasRole = roles.some(role => {
  462. return super_admin === role || permissionRoles.includes(role)
  463. })
  464. if (hasRole) {
  465. menuList.data.push(
  466. {
  467. label: "系统管理",
  468. path: "/admin",
  469. imgs: system,
  470. beimgs: issystem,
  471. }
  472. );
  473. }
  474. const clickPath = (index, items) => {
  475. items = toRaw(items);
  476. localStorage.setItem("inChat", items.path == "/index" ? 1 : 0)
  477. // toFileData.value = null
  478. console.log("clickPathitems", items);
  479. // editableTabs.value = arr;
  480. isSwitchFileIframe.value = false
  481. const arr = toRaw(editableTabs.value);
  482. if (!arr.some((item) => item.label == items.label)) {
  483. editableTabs.value.push({
  484. label: items.label,
  485. path: items.path,
  486. });
  487. //需要jSON去转 否则页面无变化 离谱得很
  488. editableTabs.value = JSON.parse(JSON.stringify(editableTabs.value));
  489. } else {
  490. toFileData.value = null;
  491. clickTab(items.path);
  492. }
  493. editableTabsValue.value = items.path;
  494. isAlive.value = true;
  495. // console.log("editableTabs", editableTabs.value);
  496. };
  497. const clickTab = (item) => {
  498. let url = toRaw(item)
  499. console.log("item", url);
  500. setTimeout(() => {
  501. console.log("toFileData.value", toFileData.value);
  502. if (toFileData.value) {
  503. localStorage.setItem("inChat",0)
  504. // 去全文搜索单独判断
  505. if(toFileData.value.name == "全局搜索"){
  506. console.log("clickRowId.value", JSON.stringify(toRaw(toFileData.value).clickRowId));
  507. editableTabsValue.value = toFileData.value.path
  508. router.push({
  509. name: toFileData.value.path,
  510. state: {
  511. // row: JSON.stringify(toRaw(toFileData.value.clickRowId)),
  512. clickRowId: JSON.stringify(toRaw(toFileData.value).clickRowId),
  513. },
  514. });
  515. return
  516. }
  517. editableTabsValue.value = toFileData.value.path
  518. router.push({
  519. path: toFileData.value.path,
  520. query: {
  521. // row: JSON.stringify(toRaw(toFileData.value.clickRowId)),
  522. clickRowId: toRaw(toFileData.value.clickRowId).dirId,
  523. },
  524. });
  525. return;
  526. }
  527. localStorage.setItem("inChat", url == "/index" ? 1 : 0)
  528. let regExp = new RegExp(/^\//);
  529. if (!regExp.test(url)) {
  530. const data = JSON.parse(url);
  531. console.log("data", data);
  532. router.push({
  533. // path: "/fileEdit" + data.docId,
  534. path: "/fileEdit",
  535. query: {
  536. clickRowId: data.docId,
  537. // row:JSON.stringify(toFileData.value)
  538. // copyRow: JSON.stringify(data),
  539. },
  540. });
  541. } else {
  542. editableTabsValue.value = url
  543. router.push({
  544. path: item+'?dirId='+item,
  545. });
  546. }
  547. }, 0);
  548. };
  549. const paneClick = (item) => {
  550. // 可以拿到当前的标签对象
  551. console.log(item, 'pane');
  552. isAlive.value = true;
  553. isSwitchFileIframe.value = false
  554. // console.log("paneItem", item);
  555. if (item.clickRowId) {
  556. // 判断是菜单还是目录
  557. toFileData.value = item;
  558. } else {
  559. toFileData.value = null;
  560. }
  561. clickTab(item.path);
  562. };
  563. // 点击文件标签
  564. const filePaneClick = (item) => {
  565. localStorage.setItem("inChat", 0)
  566. console.log("filePaneClickitem", item);
  567. isSwitchFileIframe.value = true
  568. console.log(98588546543);
  569. const row = toRaw(item);
  570. const arr = iFrameData.value.map((par) => {
  571. if (par.id === row.id) {
  572. // editableTabsValue.value = row.id
  573. par.show = true;
  574. // document.getElementById('iframe'+par.id).window.document.iframe[0]
  575. const outIframe = document.getElementById("iframe" + par.id);
  576. const inIframe =
  577. outIframe.contentDocument.getElementsByTagName("iframe")[0];
  578. setTimeout(() => {
  579. // console.log('outIframe',outIframe.parentElement);
  580. console.error(outIframe.parentElement);
  581. inIframe.style.height = outIframe.style.height =
  582. outIframe.parentElement.offsetHeight + "px";
  583. inIframe.style.width = outIframe.style.width =
  584. outIframe.parentElement.offsetWidth + "px";
  585. // console.log('dom',outIframe.parentElement.offsetWidth);
  586. // console.log('inIframe',inIframe);
  587. }, 500);
  588. } else {
  589. par.show = false;
  590. }
  591. return toRaw(par);
  592. });
  593. iFrameData.value = arr;
  594. // console.log("Clicknewfilearr", iFrameData.value);
  595. isAlive.value = false;
  596. // console.log("editableTabsValue", editableTabsValue.value);
  597. };
  598. // 创建文件的标签
  599. const addFileTab = (data,bool) => {
  600. // console.log("fileTabdata", data);
  601. console.log();
  602. const thisData = JSON.parse(JSON.stringify(toRaw(data)));
  603. const oldIFrameData = iFrameData.value;
  604. const canAdd = oldIFrameData.some((par) => par.src == ""); //是否达到上限
  605. if (!canAdd) return ElMessage.error("已到最大数量,请先关闭其他文件!");
  606. const hasThis = oldIFrameData.find((par) => par.docId == data.docId);//是否已存在
  607. if (hasThis) {
  608. const thisPane = toRaw(hasThis)
  609. // console.log('hasThis',thisPane);
  610. const arr = oldIFrameData.map((par) => {
  611. if (par.id == thisPane.id) {
  612. par.show = true
  613. editableTabsValue.value = par.id// 标签跳转
  614. setTimeout(() => {
  615. iframeSize(par.id)
  616. }, 1000);
  617. } else {
  618. par.show = false
  619. }
  620. return toRaw(par);
  621. });
  622. iFrameData.value = arr;
  623. isAlive.value = false;
  624. return
  625. }
  626. const arr = oldIFrameData.map((par) => {
  627. if (!par.src) {
  628. if (thisData.docId) {
  629. // par.src = `${window.location.origin}/fileEdit?clickRowId=${thisData.docId}`;
  630. par.src = `${window.location.origin}/fileEdit?clickRowId=${thisData.docId}&canEdit=${bool}`;
  631. par.name = data.fileName;
  632. par.docId = data.docId
  633. par.show = true
  634. thisData.docId = "";
  635. editableTabsValue.value = par.id// 新建时标签跳转
  636. setTimeout(() => {
  637. iframeSize(par.id)
  638. }, 1000);
  639. }
  640. } else {
  641. par.show = false
  642. }
  643. return toRaw(par);
  644. });
  645. iFrameData.value = arr;
  646. isAlive.value = false;
  647. // console.log("addFileTab", arr);
  648. };
  649. //创建tab标签事件
  650. const addTab = (data) => {
  651. // console.log("addTab", data);
  652. const arr = toRaw(editableTabs.value);
  653. if (!arr.some((item) => item.label == data.fileName)) {
  654. // editableTabs.value.push({
  655. // label: data.fileName,
  656. // path: JSON.stringify(data),
  657. // });
  658. editableTabs.value.push({
  659. label: data.fileName,
  660. path: JSON.stringify(data),
  661. });
  662. //需要jSON去转 否则页面无变化 离谱得很
  663. editableTabs.value = JSON.parse(JSON.stringify(editableTabs.value));
  664. // editableTabsValue.value = data.path;
  665. }
  666. };
  667. const addFolderAdd = (data) => {
  668. console.log("data", data);
  669. const arr = toRaw(editableTabs.value);
  670. if (!arr.some((item) => item.label == data.clickRowId.dirName ||item.label == data.name )) {
  671. editableTabs.value.push({
  672. label: data.name,
  673. path: data.path,
  674. clickRowId: data.clickRowId,
  675. });
  676. //需要jSON去转 否则页面无变化 离谱得很
  677. editableTabs.value = JSON.parse(JSON.stringify(editableTabs.value));
  678. }
  679. editableTabsValue.value = data.path
  680. toFileData.value = data
  681. clickTab(data)
  682. // console.log("editableTabs", toRaw(editableTabs.value));
  683. };
  684. provide("addTab", addTab);
  685. provide("addFolderAdd", addFolderAdd);
  686. provide("addFileTab", addFileTab);
  687. // TODO 删除tab事件
  688. const closeTab = (item, index, e) => {
  689. e.preventDefault();
  690. e.stopPropagation();
  691. editableTabs.value.splice(index, 1);
  692. editableTabs.value = JSON.parse(JSON.stringify(editableTabs.value));
  693. const nextTab = editableTabs.value[index - 1];
  694. // console.log('nextTab',toRaw(nextTab));
  695. // console.log('item',item);
  696. // console.log('editableTabsValue',editableTabsValue.value);
  697. if (editableTabsValue.value == item.path) {
  698. paneClick(toRaw(nextTab));
  699. }
  700. // console.log("item", item);
  701. // console.log("index", index);
  702. // console.log("e", e);
  703. };
  704. // TODO 删除tab事件
  705. const closeFileTab = (item, index, e) => {
  706. e.preventDefault();
  707. e.stopPropagation();
  708. const data = toRaw(item);
  709. console.log("closeFileTab", data);
  710. let arr = iFrameData.value.map((par) => {
  711. if (par.id === data.id) {
  712. par.src = "";
  713. par.show = false;
  714. par.name = "";
  715. par.docId = ''
  716. }
  717. return toRaw(par);
  718. });
  719. if (data.id == editableTabsValue.value) {
  720. console.log('data.id', data.id);
  721. let isLeft = true
  722. //如果不是第一个就左移
  723. for (let thisId = data.id; thisId > 0; thisId--) {
  724. console.log(arr[thisId - 1].id, arr[thisId - 1].src);
  725. if (arr[thisId - 1].src) {
  726. arr[thisId - 1].show = true
  727. isLeft = false
  728. editableTabsValue.value = arr[thisId - 1].id
  729. return
  730. }
  731. }
  732. // 如果是第一个就跳到文件夹标签右一
  733. if (isLeft) {
  734. const num = toRaw(editableTabs.value).length - 1
  735. const nextTab = editableTabs.value[num]
  736. paneClick(toRaw(nextTab));
  737. console.log('left', nextTab);
  738. }
  739. // isAlive.value = true;
  740. }
  741. iFrameData.value = arr;
  742. // console.log("index", index);
  743. console.log("iFrameData", iFrameData.value);
  744. };
  745. // 控制iframe大小
  746. const iframeSize = (id) => {
  747. const outIframe = document.getElementById("iframe" + id);
  748. const inIframe =
  749. outIframe.contentDocument.getElementsByTagName("iframe")[0];
  750. console.log('outIframe', outIframe.parentElement);
  751. console.error(outIframe.parentElement);
  752. inIframe.style.height = outIframe.style.height =
  753. outIframe.parentElement.offsetHeight + "px";
  754. inIframe.style.width = outIframe.style.width =
  755. outIframe.parentElement.offsetWidth + "px";
  756. // console.log('dom',outIframe.parentElement.offsetWidth);
  757. // console.log('inIframe',inIframe);
  758. }
  759. // 监听和保存标签信息
  760. const setTabLocal = (data) => {
  761. // console.log('setTabLocal',data);
  762. sessionStorage.setItem('tabData', JSON.stringify(data))
  763. }
  764. const setFileTabLocal = (data) => {
  765. console.log('setFileTabLocal', data);
  766. isSwitchFileIframe.value = true
  767. // console.log('setFileTabLocal',data);
  768. sessionStorage.setItem('fileTabData', JSON.stringify(data))
  769. }
  770. const setEditableTabsValue = (data) => {
  771. // console.log('setEditableTabsValue',data);
  772. sessionStorage.setItem('editableTabsValue', JSON.stringify(data))
  773. }
  774. watch(() => iFrameData.value, (newValue, oldValue) => {
  775. // console.log('iFrameData 发生改变了', newValue, oldValue);
  776. setFileTabLocal(toRaw(toRaw(newValue)))
  777. }, {
  778. immediate: true,
  779. deep: true
  780. });
  781. watch(() => editableTabs.value, (newValue, oldValue) => {
  782. // console.log('editableTabs 发生改变了', newValue, oldValue);
  783. setTabLocal(toRaw(newValue))
  784. }, {
  785. immediate: true,
  786. deep: true
  787. });
  788. watch(() => editableTabsValue.value, (newValue, oldValue) => {
  789. // console.log('editableTabsValue 发生改变了', newValue, oldValue);
  790. setEditableTabsValue(toRaw(newValue))
  791. let regExp = new RegExp(/^\//);
  792. if (!regExp.test(editableTabsValue.value)) {
  793. isAlive.value = false;
  794. }
  795. }, {
  796. immediate: true,
  797. deep: true
  798. });
  799. </script>
  800. <style lang="scss" scoped>
  801. @import "@/assets/styles/mixin.scss";
  802. @import "@/assets/styles/variables.module.scss";
  803. //整体布局css
  804. .common-layout,
  805. .el-container {
  806. height: 94vh;
  807. }
  808. :deep .el-main {
  809. --el-main-padding: 8px !important;
  810. }
  811. .nav {
  812. background: #06286c;
  813. height: 48px;
  814. .nav-top {
  815. width: 98%;
  816. display: flex;
  817. justify-content: space-between;
  818. &>div:first-child {
  819. font-family: "Inter-SemiBold";
  820. }
  821. &>div:first-child,
  822. &>div:last-child {
  823. display: flex;
  824. align-items: center;
  825. color: #fff;
  826. &>img {
  827. width: 48px;
  828. height: 48px;
  829. }
  830. }
  831. .logoImg {
  832. width: 150px !important;
  833. height: 100%;
  834. margin-right: 10px;
  835. }
  836. }
  837. .head-img {
  838. border-radius: 12px;
  839. width: 24px;
  840. height: 24px;
  841. margin-right: 10px;
  842. }
  843. .avatar-wrapper {
  844. color: #fff;
  845. display: flex;
  846. align-items: center;
  847. }
  848. .search {
  849. .w-50,
  850. :deep .el-input {
  851. width: 400px;
  852. height: 32px;
  853. border-radius: 4px;
  854. margin-top: 8px;
  855. background: #6f85b5 !important;
  856. --el-input-border-color: #6f85b5;
  857. }
  858. ::v-deep .el-input__inner {
  859. color: #fff !important;
  860. }
  861. }
  862. :deep .el-input__wrapper {
  863. background: #1f3f7e !important;
  864. }
  865. }
  866. .asides {
  867. padding: 8px 10px !important;
  868. font-size: 14px;
  869. color: #000;
  870. background: #fff;
  871. }
  872. .main {
  873. background: #c7cbd8;
  874. }
  875. // tabs标签
  876. .tab_box {
  877. width: 100%;
  878. height: 32px;
  879. border-radius: 4px 4px 4px 4px;
  880. background-color: #fff;
  881. margin-bottom: 8px;
  882. .common-tabs {
  883. height: 32px;
  884. // display: flex;
  885. // align-items: center;
  886. }
  887. .tab_pane {
  888. display: flex;
  889. align-items: center;
  890. justify-content: space-between;
  891. img {
  892. margin-left: 8px;
  893. width: 10px;
  894. height: 10px;
  895. }
  896. }
  897. }
  898. :deep(.common-tabs .el-tabs__item) {
  899. height: 24px !important;
  900. padding: 0px 8px !important;
  901. margin-top: 4px !important;
  902. margin-left: 4px !important;
  903. border: 1px solid #c1cce3 !important;
  904. color: #505870 !important;
  905. font-size: 12px !important;
  906. line-height: 24px;
  907. font-weight: 400 !important;
  908. }
  909. // tag选中颜色
  910. :deep(.common-tabs .el-tabs__item.is-active) {
  911. color: #fff !important;
  912. font-weight: normal;
  913. background-color: #6f85b5;
  914. }
  915. //侧边栏css
  916. .acitve-img-style {
  917. background-color: #f5f7f9;
  918. border-radius: 4px;
  919. }
  920. .img-style {
  921. width: 72px;
  922. height: 72px;
  923. display: flex;
  924. margin-bottom: 8px;
  925. flex-direction: column;
  926. align-items: center;
  927. justify-content: center;
  928. &>img {
  929. width: 40px;
  930. height: 40px;
  931. }
  932. }
  933. .text-style {
  934. text-align: center;
  935. color: #000;
  936. }
  937. </style>
  938. <style lang="scss" scoped>
  939. .el-popper.is-light.type_popper {
  940. background-color: #1f3f7e !important;
  941. border-radius: 4px 4px 4px 4px !important;
  942. border: none !important;
  943. // padding: 0 16px !important;
  944. // box-sizing: border-box !important;
  945. }
  946. .el-popper__arrow::before {
  947. content: none;
  948. }
  949. //鼠标移动上去的选中色
  950. .type_popper {
  951. .el-select-dropdown__item.hover,
  952. .el-select-dropdown__item:hover {
  953. background: #6f85b5 !important;
  954. }
  955. //下拉框的文本颜色
  956. .el-select-dropdown__item {
  957. color: #a4b0d8 !important;
  958. }
  959. //选中之后的颜色
  960. .el-select-dropdown__item.selected {
  961. background: #6f85b5 !important;
  962. color: #fff !important;
  963. }
  964. }
  965. .yuandian {
  966. width: 8px;
  967. height: 8px;
  968. position: absolute;
  969. right: 8px;
  970. top: 6px;
  971. background: #fa5151;
  972. border-radius: 4px;
  973. }
  974. ::v-deep .qualityManual-container-office {
  975. width: 1000px !important;
  976. height: 1000px !important;
  977. iframe {
  978. width: 1000px !important;
  979. height: 1000px !important;
  980. }
  981. }
  982. </style>