indexCommon.vue 37 KB

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