12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274 |
- <template>
- <div class="common-layout">
- <el-container>
- <el-header class="nav" style="position: sticky; top: 0; left: 0; width: 100%; z-index: 999">
- <div class="nav-top">
- <div>
- <img class="logoImg" src="@/assets/images/logos.png" /><span>聚合智慧文档管理系统</span>
- </div>
- <div class="search">
- <el-input v-model="searchText" maxlength="32" class="w-50 m-2" size="small"
- placeholder="搜索文件" clearable @keyup.enter="toSearch">
- </el-input>
- <el-icon style="position: absolute;top: 15px;left: calc(100% - 40px);z-index: 1;color: white;" @click="toSearch">
- <Search />
- </el-icon>
- </div>
- <div>
- <el-dropdown @command="handleCommand" class="right-menu-item hover-effect" trigger="click">
- <div class="avatar-wrapper">
- <img :src="userStore.avatar
- ? userStore.avatar
- : '@/assets/images/profile.png'
- " class="head-img" /><span style="cursor: pointer;margin-right: 6px;">{{ userStore.name }}</span>
- <el-icon>
- <ArrowDown />
- </el-icon>
- </div>
- <template #dropdown>
- <el-dropdown-menu>
- <!-- <router-link to="/user/profile"> -->
- <el-dropdown-item @click="toUserInfo">个人中心</el-dropdown-item>
- <!-- </router-link> -->
- <el-dropdown-item divided command="logout">
- <span>退出登录</span>
- </el-dropdown-item>
- </el-dropdown-menu>
- </template>
- </el-dropdown>
- </div>
- </div>
- </el-header>
- <el-container>
- <el-aside width="92px" class="asides">
- <div class="aside-con">
- <router-link :to="item.path" v-for="(item, index) in menuList.data" :key="index"
- @click="clickPath(index, item)">
- <div style="position: relative" :class="$route.path == item.path
- ? 'acitve-img-style img-style'
- : 'img-style'
- ">
- <img :src="$route.path == item.path ? item.beimgs : item.imgs" />
- <div class="text-style" v-if="$route.path != item.path">
- {{ item.label }}
- </div>
- <span class="yuandian" v-if="hasNewMessage &&
- item.path == '/index' &&
- ($route.path != item.path || isSwitchFileIframe)
- "></span>
- </div>
- </router-link><br />
- </div>
- </el-aside>
- <el-main class="main">
- <div class="tab_box">
- <!-- <el-tabs
- v-model="editableTabsValue"
- @tab-change="clickTab"
- @tab-add="addTab"
- type="card"
- class="common-tabs"
- > -->
- <el-tabs v-model="editableTabsValue" @tab-add="addTab" type="card" :class="{ inHome: editableTabsValue == '/home' }" class="common-tabs">
- <!-- <el-tab-pane label="首页" @click="clickTab('/index')"> </el-tab-pane> -->
- <el-tab-pane v-for="(item, index) in toRaw(editableTabs)" :key="item.label" :label="item.label"
- :name="item.path" :data-item="JSON.stringify(item)">
- <template #label>
- <div class="tab_pane" :class="{ inHomeLabel: editableTabsValue == '/home' }" @click="paneClick(item)">
- <div class="tab_text">{{ item.label }}</div>
- <div v-if="editableTabsValue == '/home'">
- <img v-if="item.label != '首页'" src="@/assets/images/home/homeClose.png" @click="closeTab(item, index, $event)"
- alt="" />
- </div>
- <div v-else>
- <img v-if="item.label != '首页'" src="@/assets/images/close.png" @click="closeTab(item, index, $event)"
- alt="" />
- </div>
- </div>
- <!-- <router-link
- :key="item"
- :data-path="item.path"
- :to="{
- path: item.path,
- query: { row: item.clickRowId },
- }"
- @click="paneClick(item)"
- class="tags-view-item"
- >
- {{ item.label }}
- </router-link> -->
- </template>
- </el-tab-pane>
- <!-- 文件的iframe -->
- <div v-for="item in iFrameData" :key="item.name">
- <el-tab-pane :label="item.name" :name="item.id" v-if="item.src">
- <template #label>
- <div class="tab_pane" @click="filePaneClick(item)">
- <div class="tab_text">{{ item.name }}</div>
- <img src="@/assets/images/close.png" @click="closeFileTab(item, index, $event)" alt="" />
- </div>
- </template>
- </el-tab-pane>
- </div>
- </el-tabs>
- </div>
- <div v-show="isAlive">
- <router-view v-slot="{ Component }" :key="$router.currentRoute.value.fullPath">
- <KeepAlive :exclude="[ 'allback', 'search']">
- <component :is="Component" />
- </KeepAlive>
- </router-view>
- </div>
- <div v-show="!isAlive" style="width: 100%">
- <div v-for="item in iFrameData" :id="item.src" :key="item.src">
- <div style="width: 100%" v-show="item.show">
- <iframe :src="item.src" frameborder="0" :id="`iframe${item.id}`" :name="`iframe${item.id}`" width="100%"
- height="800px" class="iframeBox" ></iframe>
- </div>
- </div>
- </div>
- </el-main>
- </el-container>
- </el-container>
- </div>
- <div v-loading.fullscreen="loadingPreview" v-if="loadingPreview" class="lodingBox"></div>
- </template>
- <script setup>
- import { nextTick, onMounted,onBeforeMount, provide, ref, watchEffect, watch } from "vue";
- import { ElMessageBox, ElMessage } from "element-plus";
- import useAppStore from "@/store/modules/app";
- import useUserStore from "@/store/modules/user";
- import useSettingsStore from "@/store/modules/settings";
- import Cookies from "js-cookie";
- import chat from "@/assets/images/chat.png";
- import bechat from "@/assets/images/bechat.png";
- import zuijin from "@/assets/images/zuijin.png";
- import bezuijin from "@/assets/images/bezuijin.png";
- import colloect from "@/assets/images/colloect.png";
- import becolloect from "@/assets/images/becolloect.png";
- import system from "@/assets/images/system.png";
- import issystem from "@/assets/images/issystem.png";
- import my from "@/assets/images/my.png";
- import bemy from "@/assets/images/bemy.png";
- import bumen from "@/assets/images/bumen.png";
- import bebumen from "@/assets/images/bebumen.png";
- import common from "@/assets/images/common.png";
- import becommon from "@/assets/images/becommon.png";
- import chuanshu from "@/assets/images/chuanshu.png";
- import bechuanshu from "@/assets/images/bechuanshu.png";
- import highsearch from "@/assets/images/highsearch.png";
- import behighsearch from "@/assets/images/behighsearch.png";
- import manyBody from "@/assets/images/manyBody.png";
- import manyBodyFalse from "@/assets/images/manyBodyFalse.png";
- import { AppMain, Navbar, Settings, TagsView } from "./components";
- import { flieSearch } from "@/api/search/search.js";
- import { useRouter, useRoute } from "vue-router";
- import useWebsoctStore from "@/store/modules/websocket";
- import { toRaw } from "@vue/reactivity";
- import iFrame from "@/components/iFrame/index.vue";
- import { getInfo } from "@/api/login";
- const websoctStore = useWebsoctStore();
- const router = useRouter(); //注册路由
- const route = useRoute();
- const appStore = useAppStore();
- const userStore = useUserStore();
- const settingsStore = useSettingsStore();
- const searchText = ref(""); //搜索ipt的值
- const selectValue = ref(1); //文档空间类型
- const wangzhi = import.meta.env.VITE_APP_BASE_API;
- const isAlive = ref(true);
- const toFileData = ref();
- const loadingPreview = ref(true)
- const uid = useUserStore().uid;
- let hasNewMessage = ref(false)
- let isSwitchFileIframe = ref(false); //是否切换到文件预览标签
- const iFrameData = ref(JSON.parse(sessionStorage.getItem('fileTabData')) || [
- {
- id: 1,
- // src: `${window.location.origin}/fileEdit?clickRowId=113`,
- show: false,
- name: "file1",
- docId: ''
- },
- {
- id: 2,
- src: ``,
- // src: `http://192.168.1.9:81/fileEdit?clickRowId=1198`,
- show: false,
- name: "file2",
- docId: ''
- },
- {
- id: 3,
- src: ``,
- show: false,
- name: "",
- docId: ''
- },
- {
- id: 4,
- src: ``,
- show: false,
- name: "",
- docId: ''
- },
- {
- id: 5,
- src: ``,
- show: false,
- name: "",
- docId: ''
- },
- {
- id: 6,
- src: ``,
- show: false,
- name: "",
- docId: ''
- },
- {
- id: 7,
- src: ``,
- show: false,
- name: "",
- docId: ''
- },
- {
- id: 8,
- src: ``,
- show: false,
- name: "",
- docId: ''
- },
- {
- id: 9,
- src: ``,
- show: false,
- name: "",
- docId: ''
- },
- {
- id: 10,
- src: ``,
- show: false,
- name: "",
- docId: ''
- },
- ]);
- //--------tabs-----------------
- let tabIndex = 2;
- const editableTabsValue = ref(JSON.parse(sessionStorage.getItem('editableTabsValue')) || "/home");
- // const editableTabsValue = ref("/index");
- const editableTabs = ref(JSON.parse(sessionStorage.getItem('tabData')) || [{ label: '首页', path: '/home' }]);
- // const removeTab = (targetName) => {
- // const tabs = editableTabs.value;
- // let activeName = editableTabsValue.value;
- // if (activeName === targetName) {
- // tabs.forEach((tab, index) => {
- // if (tab.name === targetName) {
- // const nextTab = tabs[index + 1] || tabs[index - 1];
- // if (nextTab) {
- // activeName = nextTab.name;
- // }
- // }
- // });
- // }
- // editableTabsValue.value = activeName;
- // editableTabs.value = tabs.filter((tab) => tab.name !== targetName);
- // };
- //-------------------------
- function reload() {
- isAlive.value = false;
- nextTick(() => {
- isAlive.value = true;
- });
- }
- provide("reload", reload);
- function toggleSideBar() {
- appStore.toggleSideBar();
- }
- const logingName = ref("");
- let lisetenMessageTime = null;
- onBeforeMount(()=>{
- needRepass()
- loadingPreview.value = false
- })
- onMounted(async () => {
- logingName.value = Cookies.get("username");
- clearInterval(lisetenMessageTime)
- lisetenMessageTime = setInterval(() => {
- //if(router.currentRoute.value.path=='/index') return;
- //console.log("===============window.noReadList:", localStorage.getItem("noreadlist"),'===========',isSwitchFileIframe.value)
- let tmplist = localStorage.getItem("noreadlist")
- if (tmplist == null || tmplist == '') {
- hasNewMessage.value = false
- return
- }
- tmplist = JSON.parse(tmplist);
- if (tmplist != null) hasNewMessage.value = true
- else hasNewMessage.value = false
- }, 1000);
- // console.log('onMt',editableTabsValue.value);
- // console.log('type',typeof editableTabsValue.value);
- nextTick(() => { // 要放在对响应式数据修改之后
- if (typeof editableTabsValue.value == 'number') {
- setTimeout(() => {
- iframeSize(editableTabsValue.value)
- }, 1000);
- }
- })
- // console.log('router',router)
- });
- watchEffect(async () => {
- if (router.currentRoute.value.path == '/index') return;
- if (websoctStore.noReadList != null) hasNewMessage.value = true
- else hasNewMessage.value = false
- // console.log("===============websoctStore.noReadList:",websoctStore.noReadList,'===========',hasNewMessage.value)
- });
- function handleCommand(command) {
- switch (command) {
- case "setLayout":
- setLayout();
- break;
- case "logout":
- logout();
- break;
- default:
- break;
- }
- }
- function logout() {
- ElMessageBox.confirm("确定注销并退出系统吗?", "提示", {
- confirmButtonText: "确定",
- cancelButtonText: "取消",
- type: "warning",
- })
- .then(() => {
- sessionStorage.clear()
- localStorage.setItem('passArr','')
- userStore.logOut().then(() => {
- location.href = "/index";
- });
- })
- .catch(() => { });
- }
- // 跳转到全文搜索
- const toSearch = async () => {
- if (!searchText.value) return;
- // console.log('searchText = ',searchText.value);
- const query = {
- keyword: searchText.value,
- isAsc: "asc",
- orderByColumn: "createTime",
- pageSize: 20,
- pageNum: 1,
- };
- const res = await flieSearch(query);
- console.log("res", res);
- if (res) {
- const itemData = {
- name: '全局搜索',
- path: 'search',
- clickRowId: {
- searchData: res,
- searchText: searchText.value,
- }
- }
- addFolderAdd(itemData)
- // console.log("res", res);
- // console.log("router", route.path);
- // if (route.path != "/search") {
- // let listArr = JSON.stringify(res);
- // router.push({
- // name: 'search',
- // params: {
- // listArr: listArr,
- // searchText: searchText.value
- // }
- // });
- // } else {
- // router.replace({
- // path: "/allback",
- // query: {
- // searchData: JSON.stringify(res),
- // searchText: searchText.value,
- // },
- // });
- // }
- }
- };
- const emits = defineEmits(["setLayout"]);
- function setLayout() {
- emits("setLayout");
- }
- const clickId = ref("");
- const menuList = reactive({
- data: [
- {
- label: "会话消息",
- path: "/index",
- imgs: chat,
- beimgs: bechat,
- },
- // {
- // label: "接口",
- // path: "/swagger",
- // imgs: chat,
- // beimgs: bechat,
- // disabled:true
- // },
- {
- label: "最近文件",
- path: "/recent",
- imgs: zuijin,
- beimgs: bezuijin,
- },
- {
- label: "收藏文件",
- path: "/collect",
- imgs: colloect,
- beimgs: becolloect,
- },
- {
- label: "我的文件",
- path: "/myfile",
- imgs: my,
- beimgs: bemy,
- },
- {
- label: "部门文件",
- path: "/department",
- imgs: bumen,
- beimgs: bebumen,
- },
- {
- label: "公共文件",
- path: "/publicment",
- imgs: common,
- beimgs: becommon,
- },
- {
- label: "高级搜索",
- path: "/highsearch",
- imgs: highsearch,
- beimgs: behighsearch,
- },
- // {
- // label: "传输列表",
- // path: "/transFile",
- // imgs: chuanshu,
- // beimgs: bechuanshu,
- // },
- // {
- // label: "系统管理",
- // path: "/admin",
- // imgs: system,
- // beimgs: issystem,
- // },
- {
- label: "我的协作",
- path: "/myjoin",
- imgs: manyBody,
- beimgs: manyBodyFalse,
- },
- ],
- });
- const roles = useUserStore().roles;
- const permissionRoles = ['admin', 'dept', 'system', 'audit']
- const super_admin = "admin";
- const hasRole = roles.some(role => {
- return super_admin === role || permissionRoles.includes(role)
- })
- if (hasRole) {
- menuList.data.push(
- {
- label: "系统管理",
- path: "/admin",
- imgs: system,
- beimgs: issystem,
- }
- );
- }
- // 去个人中心
- const toUserInfo = ()=>{
- const itemData = {
- name: '个人中心',
- path: '/user/profile',
- clickRowId:null
- }
- addFolderAdd(itemData)
- }
- // 判断是否需要改密
- const needRepass =async ()=>{
- const infoRes = await getInfo();
- // console.log("infoRes", infoRes);
- if(infoRes.repass){
- userStore.logOut().then(() => {
- location.href = "/index";
- });
- ElMessage.error("密码过期,请重新登录");
- }
- }
- const clickPath = (index, items) => {
- console.log('items',items);
- items = toRaw(items);
- localStorage.setItem("inChat", items.path == "/index" ? 1 : 0)
- // toFileData.value = null
- // editableTabs.value = arr;
- isSwitchFileIframe.value = false
- const arr = toRaw(editableTabs.value);
- if (!arr.some((item) => item.label == items.label)) {
- editableTabs.value.push({
- label: items.label,
- path: items.path,
- });
- //需要jSON去转 否则页面无变化 离谱得很
- editableTabs.value = JSON.parse(JSON.stringify(editableTabs.value));
- } else {
- toFileData.value = null;
- clickTab(items.path);
- }
- editableTabsValue.value = items.path;
- isAlive.value = true;
- };
- const clickTab = (item) => {
- let url = toRaw(item)
- setTimeout(() => {
- console.log('toFileData',toFileData.value);
- if (toFileData.value) {
- localStorage.setItem("inChat", 0)
- // 去全文搜索单独判断
- if (toFileData.value.name == "全局搜索" || toFileData.value.label == "全局搜索") {
- // console.log("clickRowId.value", JSON.stringify(toRaw(toFileData.value).clickRowId));
- editableTabsValue.value = toFileData.value.path
- isAlive.value = true
- // 如果当前已经在search就跳到中转页面
- if (route.path == "/search") {
- router.push({
- path: '/allback',
- query: {
- // row: JSON.stringify(toRaw(toFileData.value.clickRowId)),
- clickRowId: JSON.stringify(toRaw(toFileData.value).clickRowId),
- },
- });
- } else {
- // 否则去search
- router.push({
- name: toFileData.value.path,
- state: {
- // row: JSON.stringify(toRaw(toFileData.value.clickRowId)),
- clickRowId: JSON.stringify(toRaw(toFileData.value).clickRowId),
- },
- });
- }
- return
- }
- // 去文字识别单独判断
- if (toFileData.value.name == "文字识别" || toFileData.value.label == "文字识别") {
- // console.log("clickRowId.value", JSON.stringify(toRaw(toFileData.value).clickRowId));
- editableTabsValue.value = toFileData.value.path
- isAlive.value = true
- router.push({
- name: toFileData.value.path,
- state: {
- // row: JSON.stringify(toRaw(toFileData.value.clickRowId)),
- clickRowId: JSON.stringify(toRaw(toFileData.value).clickRowId),
- },
- });
- return
- }
- // 去Pdf2Word单独判断
- if (toFileData.value.name == "Pdf转Word" || toFileData.value.label == "Pdf转Word") {
- // console.log("clickRowId.value", JSON.stringify(toRaw(toFileData.value).clickRowId));
- editableTabsValue.value = toFileData.value.path
- isAlive.value = true
- router.push({
- name: toFileData.value.path,
- state: {
- // row: JSON.stringify(toRaw(toFileData.value.clickRowId)),
- clickRowId: JSON.stringify(toRaw(toFileData.value).clickRowId),
- },
- });
- return
- }
- // 去个人中心识别单独判断
- if (toFileData.value.name == "个人中心" || toFileData.value.label == "个人中心") {
- // console.log("clickRowId.value", JSON.stringify(toRaw(toFileData.value).clickRowId));
- editableTabsValue.value = toFileData.value.path
- isAlive.value = true
- router.push({
- path: toFileData.value.path,
- });
- return
- }
- // console.log('noONe');
- editableTabsValue.value = toFileData.value.path
- router.push({
- path: toFileData.value.path,
- query: {
- // row: JSON.stringify(toRaw(toFileData.value.clickRowId)),
- clickRowId: toRaw(toFileData.value.clickRowId).dirId,
- },
- });
- return;
- }
- localStorage.setItem("inChat", url == "/index" ? 1 : 0)
- let regExp = new RegExp(/^\//);
- if (!regExp.test(url)) {
- const data = JSON.parse(url);
- router.push({
- // path: "/fileEdit" + data.docId,
- path: "/fileEdit",
- query: {
- clickRowId: data.docId,
- // row:JSON.stringify(toFileData.value)
- // copyRow: JSON.stringify(data),
- },
- });
- } else {
- editableTabsValue.value = url
- router.push({
- path: item + '?dirId=' + item,
- });
- }
- }, 0);
- };
- const paneClick = (item) => {
- // 可以拿到当前的标签对象
- isAlive.value = true;
- isSwitchFileIframe.value = false
- // console.log("paneItem", item);
- if (item.clickRowId) {
- // 判断是菜单还是目录
- toFileData.value = item;
- } else {
- toFileData.value = null;
- }
- clickTab(item.path);
- };
- // 点击文件标签
- const filePaneClick = (item) => {
- localStorage.setItem("inChat", 0)
- isSwitchFileIframe.value = true
- const row = toRaw(item);
- const arr = iFrameData.value.map((par) => {
- if (par.id === row.id) {
- // editableTabsValue.value = row.id
- par.show = true;
- // document.getElementById('iframe'+par.id).window.document.iframe[0]
- const outIframe = document.getElementById("iframe" + par.id);
- const inIframe =
- outIframe.contentDocument.getElementsByTagName("iframe")[0];
- setTimeout(() => {
- // console.log('outIframe',outIframe.parentElement);
- console.error(outIframe.parentElement);
- inIframe.style.height = outIframe.style.height =
- outIframe.parentElement.offsetHeight + "px";
- inIframe.style.width = outIframe.style.width =
- outIframe.parentElement.offsetWidth + "px";
- // console.log('dom',outIframe.parentElement.offsetWidth);
- // console.log('inIframe',inIframe);
- }, 500);
- } else {
- par.show = false;
- }
- return toRaw(par);
- });
- iFrameData.value = arr;
- // console.log("Clicknewfilearr", iFrameData.value);
- isAlive.value = false;
- // console.log("editableTabsValue", editableTabsValue.value);
- };
- // 创建文件的标签
- const addFileTab = (data, bool,copy,history,fileId) => {
- // console.log("addFileTab", data);
- history = history?history:0
- const thisData = JSON.parse(JSON.stringify(toRaw(data)));
- const oldIFrameData = iFrameData.value;
- const canAdd = oldIFrameData.some((par) => par.src == ""); //是否达到上限
- if (!canAdd) return ElMessage.error("已到最大数量,请先关闭其他文件!");
- const hasThis = oldIFrameData.find((par) => par.docId == data.docId);//是否已存在
- if (hasThis) {
- // 已存在打开当前的并且改变编辑状态
- const thisPane = toRaw(hasThis)
- // 如果编辑状态改变了 先删除旧的 再新建
- if(thisPane.src != `${window.location.origin}/fileEdit?clickRowId=${thisData.docId}&canEdit=${bool}&canCopy=${copy}&history=${history}&fileId=${fileId}` ){
- // console.log('buyiyang',`${window.location.origin}/fileEdit?clickRowId=${thisData.docId}&canEdit=${bool}`);
- const arr = oldIFrameData.map((par) => {
- if (par.id === thisPane.id) {
- par.src = "";
- par.show = false;
- par.name = "";
- par.docId = ''
- }
- return toRaw(par);
- });
- iFrameData.value = arr.map((par) => {
- if (!par.src) {
- if (thisData.docId) {
- // par.src = `${window.location.origin}/fileEdit?clickRowId=${thisData.docId}`;
- par.src = `${window.location.origin}/fileEdit?clickRowId=${thisData.docId}&canEdit=${bool}&canCopy=${copy}&history=${history}&fileId=${fileId}`;
- par.name = data.fileName;
- par.docId = data.docId
- par.show = true
- thisData.docId = "";
- editableTabsValue.value = par.id// 新建时标签跳转
- iframeSize(par.id,history)
- }
- } else {
- par.show = false
- }
- return toRaw(par);
- });
- isAlive.value = false;
- return
- }
- // console.log('hasThis',thisPane);
- const arr = oldIFrameData.map((par) => {
- if (par.id == thisPane.id) {
- `${window.location.origin}/fileEdit?clickRowId=${thisData.docId}&canEdit=${bool}&canCopy=${copy}&history=${history}&fileId=${fileId}`
- par.show = true
- editableTabsValue.value = par.id// 标签跳转
- setTimeout(() => {
- iframeSize(par.id,history)
- }, 1000);
- } else {
- par.show = false
- }
- return toRaw(par);
- });
- iFrameData.value = arr;
- isAlive.value = false;
- return
- }
- // 新增标签
- const arr = oldIFrameData.map((par) => {
- if (!par.src) {
- if (thisData.docId) {
- // par.src = `${window.location.origin}/fileEdit?clickRowId=${thisData.docId}`;
- par.src = `${window.location.origin}/fileEdit?clickRowId=${thisData.docId}&canEdit=${bool}&canCopy=${copy}&history=${history}&fileId=${fileId}`;
- par.name = data.fileName;
- par.docId = data.docId
- par.show = true
- thisData.docId = "";
- editableTabsValue.value = par.id// 新建时标签跳转
- setTimeout(() => {
- iframeSize(par,history)
- }, 1000);
- // console.log('open======');
- // window.open(`http://192.168.1.8:81/dev-api/api/history/655b0d360f078a3dc7fd19e4`)
- // window.open(`${window.location.origin}/fileEdit?clickRowId=${thisData.docId}&canEdit=${bool}&canCopy=${copy}&history=${history}&fileId=${fileId}`)
- }
- } else {
- par.show = false
- }
- return toRaw(par);
- });
- iFrameData.value = arr;
- isAlive.value = false;
- // console.log("addFileTab", arr);
- };
- //创建tab标签事件
- const addTab = (data) => {
- // console.log("addTab", data);
- const arr = toRaw(editableTabs.value);
- if (!arr.some((item) => item.label == data.fileName)) {
- // editableTabs.value.push({
- // label: data.fileName,
- // path: JSON.stringify(data),
- // });
- editableTabs.value.push({
- label: data.fileName,
- path: JSON.stringify(data),
- });
- //需要jSON去转 否则页面无变化 离谱得很
- editableTabs.value = JSON.parse(JSON.stringify(editableTabs.value));
- // editableTabsValue.value = data.path;
- }
- };
- const addFolderAdd = (data) => {
- const arr = toRaw(editableTabs.value);
- if (!arr.some((item) => item.label == (data.clickRowId?data.clickRowId.dirName:null) || item.label == data.name)) {
- editableTabs.value.push({
- label: data.name,
- path: data.path,
- clickRowId: data.clickRowId,
- });
- //需要jSON去转 否则页面无变化 离谱得很
- editableTabs.value = JSON.parse(JSON.stringify(editableTabs.value));
- }
- editableTabsValue.value = data.path
- toFileData.value = data
- clickTab(data)
- // console.log("editableTabs", toRaw(editableTabs.value));
- };
- const upFirstFolderData = (query)=>{
- // console.log('query',query);
- const arr = toRaw(editableTabs.value);
- // if(!arr.some(item=>item.clickRowId.dirId === query.dirId)) return
- arr.map(item=>{
- if(item.clickRowId && item.clickRowId.dirId === query.dirId){
- item.label = query.dirName
- return item
- }
- return item
- })
- editableTabs.value = JSON.parse(JSON.stringify(arr))
- // console.log('editableTabs',editableTabs.value);
- }
- const upFileData = (query)=>{
- // console.log('query',query);
- const arr = toRaw(iFrameData.value);
- // if(!arr.some(item=>item.clickRowId.dirId === query.dirId)) return
- arr.map(item=>{
- if(item.docId && item.docId === query.docId){
- item.name = query.fileName
- return item
- }
- return item
- })
- iFrameData.value = JSON.parse(JSON.stringify(arr))
- // console.log('iFrameData',iFrameData.value);
- }
- // 删除文件夹
- const delFolderDataFn = (row)=>{
- // console.log('delFolderDataFn',row);
- // console.log('router.currentRoute.value.path',router.currentRoute.value.params.dirId);
- const nowDirId = router.currentRoute.value.params.dirId
- const thisDirID = row.dirId
- const newArr = editableTabs.value.filter((item,index)=>{
- if(item.clickRowId?.dirId != thisDirID){
- return toRaw(item)
- }else{
- // 要删除的事当前的标签页
- const nextTab = editableTabs.value[index - 1];
- paneClick(toRaw(nextTab));
- }
- })
- editableTabs.value = newArr
- // console.log('editableTabs',editableTabs.value);
- }
- // 删除文件
- const delFileFn = (id)=>{
- const has = iFrameData.value.find(item =>item.docId == id);
- if(has){
- ElMessage.error(`${has.name}文件已被打开,请关闭后重试`);
- return true
- }
- }
- //删除菜单
- const delMenuFn = (name)=>{
- const arr = toRaw(editableTabs.value);
- const newArr = arr.filter(item=>item.label != name)
- editableTabs.value = JSON.parse(JSON.stringify(newArr));
- }
- provide("addTab", addTab);
- provide("addFolderAdd", addFolderAdd);
- provide("addFileTab", addFileTab);
- provide("upFirstFolderData", upFirstFolderData);
- provide("upFileData", upFileData);
- provide("clickPath", clickPath);
- provide("delFolderDataFn", delFolderDataFn);
- provide("delFileFn", delFileFn);
- provide("delMenuFn", delMenuFn);
- // TODO 删除tab事件
- const closeTab = (item, index, e) => {
- e.preventDefault();
- e.stopPropagation();
- editableTabs.value.splice(index, 1);
- editableTabs.value = JSON.parse(JSON.stringify(editableTabs.value));
- const nextTab = editableTabs.value[index - 1];
- // console.log('nextTab',toRaw(nextTab));
- // console.log('item',item);
- // console.log('editableTabsValue',editableTabsValue.value);
- if (editableTabsValue.value == item.path) {
- paneClick(toRaw(nextTab));
- }
- // console.log("item", item);
- // console.log("index", index);
- // console.log("e", e);
- };
- // TODO 删除tab事件
- const closeFileTab = (item, index, e) => {
- e.preventDefault();
- e.stopPropagation();
- const data = toRaw(item);
- let arr = iFrameData.value.map((par) => {
- if (par.id === data.id) {
- par.src = "";
- par.show = false;
- par.name = "";
- par.docId = ''
- }
- return toRaw(par);
- });
- if (data.id == editableTabsValue.value) {
- let isLeft = true
- //如果不是第一个就左移
- for (let thisId = data.id; thisId > 0; thisId--) {
- // console.log(arr[thisId - 1].id, arr[thisId - 1].src);
- if (arr[thisId - 1].src) {
- arr[thisId - 1].show = true
- isLeft = false
- editableTabsValue.value = arr[thisId - 1].id
- return
- }
- }
- // 如果是第一个就跳到文件夹标签右一
- if (isLeft) {
- const num = toRaw(editableTabs.value).length - 1
- const nextTab = editableTabs.value[num]
- paneClick(toRaw(nextTab));
- // console.log('left', nextTab);
- }
- // isAlive.value = true;
- }
- iFrameData.value = arr;
- // console.log("index", index);
- // console.log("iFrameData", iFrameData.value);
- };
- // 控制iframe大小
- const iframeSize = (par,history) => {
- // console.log('执行ifSize',par);
- const outIframe = document.getElementById("iframe" + par.id);
- const inIframe =
- outIframe.contentDocument.getElementsByTagName("iframe")[0];
- if(inIframe==null){
- // console.log('没有inF');
- setTimeout(() => {
- // console.log('==============');
- iframeSize(par)
- }, 200);
- return
- }
- // console.log('outIframe', outIframe.parentElement);
- console.error(outIframe.parentElement);
- inIframe.style.height = outIframe.style.height =
- outIframe.parentElement.offsetHeight + "px";
- inIframe.style.width = outIframe.style.width =
- outIframe.parentElement.offsetWidth + "px";
- // if(history){
- // // var widgetIFrameParent = inIframe.parentNode;
- // outIframe.remove();
- // // widgetIFrameParent.append("<iframe id=\"widgetIFrame\" style=\"width: 100%;height: 600px\" src=\"\"></iframe>");
- // // widgetIFrameParent.append("<iframe :src=\"item.src\" frameborder=\"0\" :id=\"`iframe${item.id}`\" :name=\"`iframe${item.id}`\" width=\"100%\" height=\"800px\" class=\"iframeBox\" ></iframe>");
- // // var widgetIFrameNew = document.getElementById("iframe" + par.id);
- // // widgetIFrameNew.attr('src',encodeURI(par.src));
- // // widgetIFrameNew.css('width',"100%")
- // }
- // console.log('dom',outIframe.parentElement.offsetWidth);
- // console.log('inIframe',inIframe);
- }
- // 监听和保存标签信息
- const setTabLocal = (data) => {
- // console.log('setTabLocal',data);
- // console.log('data====', data)
- sessionStorage.setItem('tabData', JSON.stringify(data))
- }
- const setFileTabLocal = (data) => {
- // console.log('setFileTabLocal', data);
- isSwitchFileIframe.value = true
- // console.log('setFileTabLocal',data);
- sessionStorage.setItem('fileTabData', JSON.stringify(data))
- }
- const setEditableTabsValue = (data) => {
- // console.log('setEditableTabsValue',data);
- sessionStorage.setItem('editableTabsValue', JSON.stringify(data))
- }
- watch(() => iFrameData.value, (newValue, oldValue) => {
- // console.log('iFrameData 发生改变了', newValue, oldValue);
- setFileTabLocal(toRaw(toRaw(newValue)))
- }, {
- immediate: true,
- deep: true
- });
- watch(() => editableTabs.value, (newValue, oldValue) => {
- // console.log('editableTabs 发生改变了', newValue, oldValue);
- setTabLocal(toRaw(newValue))
- // console.log('editableTabs.valuewatch', editableTabs.value)
- }, {
- immediate: true,
- deep: true
- });
- watch(() => editableTabsValue.value, (newValue, oldValue) => {
- // console.log('editableTabsValue 发生改变了', newValue, oldValue);
- setEditableTabsValue(toRaw(newValue))
- let regExp = new RegExp(/^\//);
- if (!regExp.test(editableTabsValue.value) && editableTabsValue.value != "identifyFont" && editableTabsValue.value != "search"&& editableTabsValue.value != "pdf2word") {
- isAlive.value = false;
- }
- // console.log('first editableTabsValue.value', editableTabsValue.value)
- }, {
- immediate: true,
- deep: true
- });
- // watch(() => isAlive.value, (newValue, oldValue) => {
- // console.log('isAlive.isAlive', newValue)
- // }, {
- // immediate: true,
- // deep: true
- // });
- </script>
- <style lang="scss" scoped>
- @import "@/assets/styles/mixin.scss";
- @import "@/assets/styles/variables.module.scss";
- //整体布局css
- .common-layout,
- .el-container {
- height: 94vh;
- }
- .lodingBox {
- position: absolute;
- top: 0;
- left: 0;
- width: 100vh;
- height: 100vh;
- z-index: 10000000;
- }
- :deep .el-main {
- --el-main-padding: 8px !important;
- }
- .inHome{
- background: linear-gradient(344deg, #010E70 0%, #000918 100%) !important;
- }
- .nav {
- background: #06286c;
- height: 48px;
- .nav-top {
- width: 98%;
- display: flex;
- justify-content: space-between;
- &>div:first-child {
- font-family: "Inter-SemiBold";
- }
- &>div:first-child,
- &>div:last-child {
- display: flex;
- align-items: center;
- color: #fff;
- &>img {
- width: 48px;
- height: 48px;
- }
- }
- .logoImg {
- width: 150px !important;
- height: 100%;
- margin-right: 10px;
- }
- }
- .head-img {
- border-radius: 12px;
- width: 24px;
- height: 24px;
- margin-right: 10px;
- }
- .avatar-wrapper {
- color: #fff;
- display: flex;
- align-items: center;
- }
- .search {
- position: relative;
- .w-50,
- :deep .el-input {
- width: 400px;
- height: 32px;
- border-radius: 4px;
- margin-top: 8px;
- background: #6f85b5 !important;
- --el-input-border-color: #6f85b5;
- }
- ::v-deep .el-input__inner {
- color: #fff !important;
- }
- }
- :deep .el-input__wrapper {
- background: #1f3f7e !important;
- }
- }
- .asides {
- padding: 8px 10px !important;
- font-size: 14px;
- color: #000;
- background: #fff;
- }
- .main {
- background: #c7cbd8;
- }
- // tabs标签
- .tab_box {
- width: 100%;
- height: 32px;
- border-radius: 4px 4px 4px 4px;
- background-color: #fff;
- margin-bottom: 8px;
- .common-tabs {
- height: 32px;
- // display: flex;
- // align-items: center;
- }
- .tab_pane {
- display: flex;
- align-items: center;
- justify-content: space-between;
- img {
- margin-left: 8px;
- width: 10px;
- height: 10px;
- }
- }
- }
- :deep(.common-tabs .el-tabs__item) {
- height: 24px !important;
- padding: 0px 8px !important;
- margin-top: 4px !important;
- margin-left: 4px !important;
- border: 1px solid #c1cce3 ;
- color: #505870 ;
- font-size: 12px !important;
- line-height: 24px;
- font-weight: 400 !important;
- }
- :deep(.inHome .el-tabs__item) {
- background-color: #4A5C8B !important;
- border: 1px solid #8BA0BD !important;
- color: #B7CBE7 !important;
- }
- // tag选中颜色
- :deep(.common-tabs .el-tabs__item.is-active) {
- color: #fff !important;
- font-weight: normal;
- background-color: #6f85b5;
- }
- // tag选中颜色
- :deep(.inHome .el-tabs__item.is-active) {
- color: #010C3D !important;
- font-weight: normal;
- background: #8BA0BD !important;
- }
- //侧边栏css
- .acitve-img-style {
- background-color: #f5f7f9;
- border-radius: 4px;
- }
- .img-style {
- width: 72px;
- height: 72px;
- display: flex;
- margin-bottom: 8px;
- flex-direction: column;
- align-items: center;
- justify-content: center;
- &>img {
- width: 40px;
- height: 40px;
- }
- }
- .text-style {
- text-align: center;
- color: #000;
- }
- </style>
- <style lang="scss" scoped>
- .el-popper.is-light.type_popper {
- background-color: #1f3f7e !important;
- border-radius: 4px 4px 4px 4px !important;
- border: none !important;
- // padding: 0 16px !important;
- // box-sizing: border-box !important;
- }
- .el-popper__arrow::before {
- content: none;
- }
- //鼠标移动上去的选中色
- .type_popper {
- .el-select-dropdown__item.hover,
- .el-select-dropdown__item:hover {
- background: #6f85b5 !important;
- }
- //下拉框的文本颜色
- .el-select-dropdown__item {
- color: #a4b0d8 !important;
- }
- //选中之后的颜色
- .el-select-dropdown__item.selected {
- background: #6f85b5 !important;
- color: #fff !important;
- }
- }
- .yuandian {
- width: 8px;
- height: 8px;
- position: absolute;
- right: 8px;
- top: 6px;
- background: #fa5151;
- border-radius: 4px;
- }
- ::v-deep .qualityManual-container-office {
- width: 1000px !important;
- height: 1000px !important;
- iframe {
- width: 1000px !important;
- height: 1000px !important;
- }
- }
- :deep(.el-tabs--card>.el-tabs__header) {
- border-bottom: none !important;
- }
- </style>
|