indexCommon.vue 38 KB

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