indexCommon.vue 30 KB

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