indexCommon.vue 28 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031
  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. // console.log("res", res);
  352. // console.log("router", route.path);
  353. if (route.path != "/search") {
  354. let listArr = JSON.stringify(res);
  355. router.push({
  356. name: 'search',
  357. params: {
  358. listArr: listArr,
  359. searchText: searchText.value
  360. }
  361. });
  362. } else {
  363. router.replace({
  364. path: "/allback",
  365. query: {
  366. searchData: JSON.stringify(res),
  367. searchText: searchText.value,
  368. },
  369. });
  370. }
  371. }
  372. };
  373. const emits = defineEmits(["setLayout"]);
  374. function setLayout() {
  375. emits("setLayout");
  376. }
  377. const clickId = ref("");
  378. const menuList = reactive({
  379. data: [
  380. {
  381. label: "会话消息",
  382. path: "/index",
  383. imgs: chat,
  384. beimgs: bechat,
  385. },
  386. // {
  387. // label: "接口",
  388. // path: "/swagger",
  389. // imgs: chat,
  390. // beimgs: bechat,
  391. // disabled:true
  392. // },
  393. {
  394. label: "最近文件",
  395. path: "/recent",
  396. imgs: zuijin,
  397. beimgs: bezuijin,
  398. },
  399. {
  400. label: "收藏文件",
  401. path: "/collect",
  402. imgs: colloect,
  403. beimgs: becolloect,
  404. },
  405. {
  406. label: "我的文件",
  407. path: "/myfile",
  408. imgs: my,
  409. beimgs: bemy,
  410. },
  411. {
  412. label: "部门文件",
  413. path: "/department",
  414. imgs: bumen,
  415. beimgs: bebumen,
  416. },
  417. {
  418. label: "公共文件",
  419. path: "/publicment",
  420. imgs: common,
  421. beimgs: becommon,
  422. },
  423. {
  424. label: "高级搜索",
  425. path: "/highsearch",
  426. imgs: highsearch,
  427. beimgs: behighsearch,
  428. },
  429. // {
  430. // label: "传输列表",
  431. // path: "/transFile",
  432. // imgs: chuanshu,
  433. // beimgs: bechuanshu,
  434. // },
  435. // {
  436. // label: "系统管理",
  437. // path: "/admin",
  438. // imgs: system,
  439. // beimgs: issystem,
  440. // },
  441. {
  442. label: "我的协作",
  443. path: "/myjoin",
  444. imgs: manyBody,
  445. beimgs: manyBodyFalse,
  446. },
  447. ],
  448. });
  449. const roles = useUserStore().roles;
  450. const permissionRoles = ['admin', 'dept', 'system', 'audit']
  451. const super_admin = "admin";
  452. const hasRole = roles.some(role => {
  453. return super_admin === role || permissionRoles.includes(role)
  454. })
  455. if (hasRole) {
  456. menuList.data.push(
  457. {
  458. label: "系统管理",
  459. path: "/admin",
  460. imgs: system,
  461. beimgs: issystem,
  462. }
  463. );
  464. }
  465. const clickPath = (index, items) => {
  466. items = toRaw(items);
  467. localStorage.setItem("inChat", items.path == "/index" ? 1 : 0)
  468. // toFileData.value = null
  469. console.log("clickPathitems", items);
  470. // editableTabs.value = arr;
  471. isSwitchFileIframe.value = false
  472. const arr = toRaw(editableTabs.value);
  473. if (!arr.some((item) => item.label == items.label)) {
  474. editableTabs.value.push({
  475. label: items.label,
  476. path: items.path,
  477. });
  478. //需要jSON去转 否则页面无变化 离谱得很
  479. editableTabs.value = JSON.parse(JSON.stringify(editableTabs.value));
  480. } else {
  481. toFileData.value = null;
  482. clickTab(items.path);
  483. }
  484. editableTabsValue.value = items.path;
  485. isAlive.value = true;
  486. // console.log("editableTabs", editableTabs.value);
  487. };
  488. const clickTab = (item) => {
  489. let url = toRaw(item)
  490. console.log("item", url);
  491. setTimeout(() => {
  492. console.log("toFileData.value", toFileData.value);
  493. if (toFileData.value) {
  494. localStorage.setItem("inChat", 0)
  495. console.log(
  496. "tofolder",
  497. JSON.stringify(toRaw(toFileData.value.clickRowId))
  498. );
  499. editableTabsValue.value = toFileData.value.path
  500. router.push({
  501. path: toFileData.value.path,
  502. query: {
  503. // row: JSON.stringify(toRaw(toFileData.value.clickRowId)),
  504. },
  505. });
  506. return;
  507. }
  508. localStorage.setItem("inChat", url == "/index" ? 1 : 0)
  509. let regExp = new RegExp(/^\//);
  510. if (!regExp.test(url)) {
  511. const data = JSON.parse(url);
  512. console.log("data", data);
  513. router.push({
  514. // path: "/fileEdit" + data.docId,
  515. path: "/fileEdit",
  516. query: {
  517. clickRowId: data.docId,
  518. // row:JSON.stringify(toFileData.value)
  519. // copyRow: JSON.stringify(data),
  520. },
  521. });
  522. } else {
  523. editableTabsValue.value = url
  524. router.push({
  525. path: item,
  526. });
  527. }
  528. }, 0);
  529. };
  530. const paneClick = (item) => {
  531. // 可以拿到当前的标签对象
  532. console.log(item, 'pane');
  533. isAlive.value = true;
  534. isSwitchFileIframe.value = false
  535. console.log("paneItem", item);
  536. if (item.clickRowId) {
  537. // 判断是菜单还是目录
  538. toFileData.value = item;
  539. } else {
  540. toFileData.value = null;
  541. }
  542. clickTab(item.path);
  543. };
  544. // 点击文件标签
  545. const filePaneClick = (item) => {
  546. localStorage.setItem("inChat", 0)
  547. console.log("filePaneClickitem", item);
  548. isSwitchFileIframe.value = true
  549. console.log(98588546543);
  550. const row = toRaw(item);
  551. const arr = iFrameData.value.map((par) => {
  552. if (par.id === row.id) {
  553. // editableTabsValue.value = row.id
  554. par.show = true;
  555. // document.getElementById('iframe'+par.id).window.document.iframe[0]
  556. const outIframe = document.getElementById("iframe" + par.id);
  557. const inIframe =
  558. outIframe.contentDocument.getElementsByTagName("iframe")[0];
  559. setTimeout(() => {
  560. console.log('outIframe', outIframe.parentElement);
  561. console.error(outIframe.parentElement);
  562. inIframe.style.height = outIframe.style.height =
  563. outIframe.parentElement.offsetHeight + "px";
  564. inIframe.style.width = outIframe.style.width =
  565. outIframe.parentElement.offsetWidth + "px";
  566. // console.log('dom',outIframe.parentElement.offsetWidth);
  567. // console.log('inIframe',inIframe);
  568. }, 500);
  569. } else {
  570. par.show = false;
  571. }
  572. return toRaw(par);
  573. });
  574. iFrameData.value = arr;
  575. // console.log("Clicknewfilearr", iFrameData.value);
  576. isAlive.value = false;
  577. // console.log("editableTabsValue", editableTabsValue.value);
  578. };
  579. // 创建文件的标签
  580. const addFileTab = (data) => {
  581. console.log("fileTabdata", data);
  582. console.log();
  583. const thisData = JSON.parse(JSON.stringify(toRaw(data)));
  584. const oldIFrameData = iFrameData.value;
  585. const canAdd = oldIFrameData.some((par) => par.src == ""); //是否达到上限
  586. if (!canAdd) return ElMessage.error("已到最大数量,请先关闭其他文件!");
  587. const hasThis = oldIFrameData.find((par) => par.docId == data.docId);//是否已存在
  588. if (hasThis) {
  589. const thisPane = toRaw(hasThis)
  590. // console.log('hasThis',thisPane);
  591. const arr = oldIFrameData.map((par) => {
  592. if (par.id == thisPane.id) {
  593. par.show = true
  594. editableTabsValue.value = par.id// 标签跳转
  595. setTimeout(() => {
  596. iframeSize(par.id)
  597. }, 1000);
  598. } else {
  599. par.show = false
  600. }
  601. return toRaw(par);
  602. });
  603. iFrameData.value = arr;
  604. isAlive.value = false;
  605. return
  606. }
  607. const arr = oldIFrameData.map((par) => {
  608. if (!par.src) {
  609. if (thisData.docId) {
  610. // par.src = `${window.location.origin}/fileEdit?clickRowId=${thisData.docId}`;
  611. par.src = `${window.location.origin}/fileEdit?clickRowId=${thisData.docId}`;
  612. par.name = data.fileName;
  613. par.docId = data.docId
  614. par.show = true
  615. thisData.docId = "";
  616. editableTabsValue.value = par.id// 新建时标签跳转
  617. setTimeout(() => {
  618. iframeSize(par.id)
  619. }, 1000);
  620. }
  621. } else {
  622. par.show = false
  623. }
  624. return toRaw(par);
  625. });
  626. iFrameData.value = arr;
  627. isAlive.value = false;
  628. // const outIframe = document.getElementById("iframe" + par.id);
  629. // const inIframe =
  630. // outIframe.contentDocument.getElementsByTagName("iframe")[0];
  631. // setTimeout(() => {
  632. // console.log('outIframe',outIframe.parentElement);
  633. // console.error(outIframe.parentElement);
  634. // inIframe.style.height = outIframe.style.height =
  635. // outIframe.parentElement.offsetHeight + "px";
  636. // inIframe.style.width = outIframe.style.width =
  637. // outIframe.parentElement.offsetWidth + "px";
  638. // // console.log('dom',outIframe.parentElement.offsetWidth);
  639. // // console.log('inIframe',inIframe);
  640. // }, 500);
  641. console.log("addFileTab", arr);
  642. };
  643. //创建tab标签事件
  644. const addTab = (data) => {
  645. console.log("addTab", data);
  646. const arr = toRaw(editableTabs.value);
  647. if (!arr.some((item) => item.label == data.fileName)) {
  648. // editableTabs.value.push({
  649. // label: data.fileName,
  650. // path: JSON.stringify(data),
  651. // });
  652. editableTabs.value.push({
  653. label: data.fileName,
  654. path: JSON.stringify(data),
  655. });
  656. //需要jSON去转 否则页面无变化 离谱得很
  657. editableTabs.value = JSON.parse(JSON.stringify(editableTabs.value));
  658. // editableTabsValue.value = data.path;
  659. }
  660. };
  661. const addFolderAdd = (data) => {
  662. console.log("data", data);
  663. const arr = toRaw(editableTabs.value);
  664. if (!arr.some((item) => item.label == data.row.dirName)) {
  665. editableTabs.value.push({
  666. label: data.name,
  667. path: data.path,
  668. clickRowId: data.row,
  669. });
  670. //需要jSON去转 否则页面无变化 离谱得很
  671. editableTabs.value = JSON.parse(JSON.stringify(editableTabs.value));
  672. }
  673. console.log("editableTabs", toRaw(editableTabs.value));
  674. };
  675. provide("addTab", addTab);
  676. provide("addFolderAdd", addFolderAdd);
  677. provide("addFileTab", addFileTab);
  678. // TODO 删除tab事件
  679. const closeTab = (item, index, e) => {
  680. e.preventDefault();
  681. e.stopPropagation();
  682. editableTabs.value.splice(index, 1);
  683. editableTabs.value = JSON.parse(JSON.stringify(editableTabs.value));
  684. const nextTab = editableTabs.value[index - 1];
  685. // console.log('nextTab',toRaw(nextTab));
  686. // console.log('item',item);
  687. // console.log('editableTabsValue',editableTabsValue.value);
  688. if (editableTabsValue.value == item.path) {
  689. paneClick(toRaw(nextTab));
  690. }
  691. // console.log("item", item);
  692. // console.log("index", index);
  693. // console.log("e", e);
  694. };
  695. // TODO 删除tab事件
  696. const closeFileTab = (item, index, e) => {
  697. e.preventDefault();
  698. e.stopPropagation();
  699. const data = toRaw(item);
  700. console.log("closeFileTab", data);
  701. let arr = iFrameData.value.map((par) => {
  702. if (par.id === data.id) {
  703. par.src = "";
  704. par.show = false;
  705. par.name = "";
  706. par.docId = ''
  707. }
  708. return toRaw(par);
  709. });
  710. if (data.id == editableTabsValue.value) {
  711. console.log('data.id', data.id);
  712. let isLeft = true
  713. //如果不是第一个就左移
  714. for (let thisId = data.id; thisId > 0; thisId--) {
  715. console.log(arr[thisId - 1].id, arr[thisId - 1].src);
  716. if (arr[thisId - 1].src) {
  717. arr[thisId - 1].show = true
  718. isLeft = false
  719. editableTabsValue.value = arr[thisId - 1].id
  720. return
  721. }
  722. }
  723. // 如果是第一个就跳到文件夹标签右一
  724. if (isLeft) {
  725. const num = toRaw(editableTabs.value).length - 1
  726. const nextTab = editableTabs.value[num]
  727. paneClick(toRaw(nextTab));
  728. console.log('left', nextTab);
  729. }
  730. // isAlive.value = true;
  731. }
  732. iFrameData.value = arr;
  733. // console.log("index", index);
  734. console.log("iFrameData", iFrameData.value);
  735. };
  736. // 控制iframe大小
  737. const iframeSize = (id) => {
  738. const outIframe = document.getElementById("iframe" + id);
  739. const inIframe =
  740. outIframe.contentDocument.getElementsByTagName("iframe")[0];
  741. console.log('outIframe', outIframe.parentElement);
  742. console.error(outIframe.parentElement);
  743. inIframe.style.height = outIframe.style.height =
  744. outIframe.parentElement.offsetHeight + "px";
  745. inIframe.style.width = outIframe.style.width =
  746. outIframe.parentElement.offsetWidth + "px";
  747. // console.log('dom',outIframe.parentElement.offsetWidth);
  748. // console.log('inIframe',inIframe);
  749. }
  750. // 监听和保存标签信息
  751. const setTabLocal = (data) => {
  752. // console.log('setTabLocal',data);
  753. sessionStorage.setItem('tabData', JSON.stringify(data))
  754. }
  755. const setFileTabLocal = (data) => {
  756. console.log('setFileTabLocal', data);
  757. isSwitchFileIframe.value = true
  758. // console.log('setFileTabLocal',data);
  759. sessionStorage.setItem('fileTabData', JSON.stringify(data))
  760. }
  761. const setEditableTabsValue = (data) => {
  762. // console.log('setEditableTabsValue',data);
  763. sessionStorage.setItem('editableTabsValue', JSON.stringify(data))
  764. }
  765. watch(() => iFrameData.value, (newValue, oldValue) => {
  766. // console.log('iFrameData 发生改变了', newValue, oldValue);
  767. setFileTabLocal(toRaw(toRaw(newValue)))
  768. }, {
  769. immediate: true,
  770. deep: true
  771. });
  772. watch(() => editableTabs.value, (newValue, oldValue) => {
  773. // console.log('editableTabs 发生改变了', newValue, oldValue);
  774. setTabLocal(toRaw(newValue))
  775. }, {
  776. immediate: true,
  777. deep: true
  778. });
  779. watch(() => editableTabsValue.value, (newValue, oldValue) => {
  780. // console.log('editableTabsValue 发生改变了', newValue, oldValue);
  781. setEditableTabsValue(toRaw(newValue))
  782. let regExp = new RegExp(/^\//);
  783. if (!regExp.test(editableTabsValue.value)) {
  784. isAlive.value = false;
  785. }
  786. }, {
  787. immediate: true,
  788. deep: true
  789. });
  790. </script>
  791. <style lang="scss" scoped>
  792. @import "@/assets/styles/mixin.scss";
  793. @import "@/assets/styles/variables.module.scss";
  794. //整体布局css
  795. .common-layout,
  796. .el-container {
  797. height: 94vh;
  798. }
  799. :deep .el-main {
  800. --el-main-padding: 8px !important;
  801. }
  802. .nav {
  803. background: #06286c;
  804. height: 48px;
  805. .nav-top {
  806. width: 98%;
  807. display: flex;
  808. justify-content: space-between;
  809. &>div:first-child {
  810. font-family: "Inter-SemiBold";
  811. }
  812. &>div:first-child,
  813. &>div:last-child {
  814. display: flex;
  815. align-items: center;
  816. color: #fff;
  817. &>img {
  818. width: 48px;
  819. height: 48px;
  820. }
  821. }
  822. .logoImg {
  823. width: 150px !important;
  824. height: 100%;
  825. margin-right: 10px;
  826. }
  827. }
  828. .head-img {
  829. border-radius: 12px;
  830. width: 24px;
  831. height: 24px;
  832. margin-right: 10px;
  833. }
  834. .avatar-wrapper {
  835. color: #fff;
  836. display: flex;
  837. align-items: center;
  838. }
  839. .search {
  840. .w-50,
  841. :deep .el-input {
  842. width: 400px;
  843. height: 32px;
  844. border-radius: 4px;
  845. margin-top: 8px;
  846. background: #6f85b5 !important;
  847. --el-input-border-color: #6f85b5;
  848. }
  849. ::v-deep .el-input__inner {
  850. color: #fff !important;
  851. }
  852. }
  853. :deep .el-input__wrapper {
  854. background: #1f3f7e !important;
  855. }
  856. }
  857. .asides {
  858. padding: 8px 10px !important;
  859. font-size: 14px;
  860. color: #000;
  861. background: #fff;
  862. }
  863. .main {
  864. background: #c7cbd8;
  865. }
  866. // tabs标签
  867. .tab_box {
  868. width: 100%;
  869. height: 32px;
  870. border-radius: 4px 4px 4px 4px;
  871. background-color: #fff;
  872. margin-bottom: 8px;
  873. .common-tabs {
  874. height: 32px;
  875. // display: flex;
  876. // align-items: center;
  877. }
  878. .tab_pane {
  879. display: flex;
  880. align-items: center;
  881. justify-content: space-between;
  882. img {
  883. margin-left: 8px;
  884. width: 10px;
  885. height: 10px;
  886. }
  887. }
  888. }
  889. :deep(.common-tabs .el-tabs__item) {
  890. height: 24px !important;
  891. padding: 0px 8px !important;
  892. margin-top: 4px !important;
  893. margin-left: 4px !important;
  894. border: 1px solid #c1cce3 !important;
  895. color: #505870 !important;
  896. font-size: 12px !important;
  897. line-height: 24px;
  898. font-weight: 400 !important;
  899. }
  900. // tag选中颜色
  901. :deep(.common-tabs .el-tabs__item.is-active) {
  902. color: #fff !important;
  903. font-weight: normal;
  904. background-color: #6f85b5;
  905. }
  906. //侧边栏css
  907. .acitve-img-style {
  908. background-color: #f5f7f9;
  909. border-radius: 4px;
  910. }
  911. .img-style {
  912. width: 72px;
  913. height: 72px;
  914. display: flex;
  915. margin-bottom: 8px;
  916. flex-direction: column;
  917. align-items: center;
  918. justify-content: center;
  919. &>img {
  920. width: 40px;
  921. height: 40px;
  922. }
  923. }
  924. .text-style {
  925. text-align: center;
  926. color: #000;
  927. }
  928. </style>
  929. <style lang="scss" scoped>
  930. .el-popper.is-light.type_popper {
  931. background-color: #1f3f7e !important;
  932. border-radius: 4px 4px 4px 4px !important;
  933. border: none !important;
  934. // padding: 0 16px !important;
  935. // box-sizing: border-box !important;
  936. }
  937. .el-popper__arrow::before {
  938. content: none;
  939. }
  940. //鼠标移动上去的选中色
  941. .type_popper {
  942. .el-select-dropdown__item.hover,
  943. .el-select-dropdown__item:hover {
  944. background: #6f85b5 !important;
  945. }
  946. //下拉框的文本颜色
  947. .el-select-dropdown__item {
  948. color: #a4b0d8 !important;
  949. }
  950. //选中之后的颜色
  951. .el-select-dropdown__item.selected {
  952. background: #6f85b5 !important;
  953. color: #fff !important;
  954. }
  955. }
  956. .yuandian {
  957. width: 8px;
  958. height: 8px;
  959. position: absolute;
  960. right: 8px;
  961. top: 6px;
  962. background: #fa5151;
  963. border-radius: 4px;
  964. }
  965. ::v-deep .qualityManual-container-office {
  966. width: 1000px !important;
  967. height: 1000px !important;
  968. iframe {
  969. width: 1000px !important;
  970. height: 1000px !important;
  971. }
  972. }
  973. </style>