MyFile.vue 63 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724
  1. <template>
  2. <div>
  3. <div class="bigBox">
  4. <div class="settingBox" @click="mouseClick">
  5. <!-- 设置盒子顶部搜索 -->
  6. <div class="topSearch">
  7. <div style="position: relative;">
  8. <el-input v-model="searchFire" class="searchFire" size="large" placeholder="搜索文件"
  9. style="width: 15rem;" />
  10. <el-icon style="color: gray;display: inline-block;position: absolute;top: 8px;right: 5px;">
  11. <Search />
  12. </el-icon>
  13. </div>
  14. <div>
  15. <el-icon style="font-size: 24px;" @click="createNewMenu(1)">
  16. <Plus />
  17. </el-icon>
  18. <!-- @click="createNewFile" -->
  19. </div>
  20. </div>
  21. <!-- 方块点击盒子 -->
  22. <div
  23. style="display: flex;justify-content: flex-start;align-items: flex-start;flex-wrap: wrap;height: 80vh;align-content: flex-start;overflow-y: auto;">
  24. <!-- v-for盒子 -->
  25. <template v-for="(item, index) in fileMenu">
  26. <div class="setBox" @click="changeFile(item, index)">
  27. <el-dropdown trigger="click" class="selectChe">
  28. <span class="el-dropdown-link">
  29. ...
  30. </span>
  31. <template #dropdown>
  32. <el-dropdown-menu>
  33. <el-dropdown-item @click="restName(item, index)">重命名</el-dropdown-item>
  34. <el-dropdown-item @click="delName(item, index)">删除</el-dropdown-item>
  35. </el-dropdown-menu>
  36. </template>
  37. </el-dropdown>
  38. <img src="../../assets/images/fileStyle.png" style="width: 72px;height: 72px;">
  39. <p class="ellipsis-text">{{ item.dirName }}</p>
  40. </div>
  41. </template>
  42. </div>
  43. <div>
  44. <p>
  45. <span style="margin-left: 5px;">{{ formatStorage(useSpace) }}/{{ allSpace + "G" }}</span>
  46. <span style="margin-left: 5px;font-size: 12px;color: blue;cursor: pointer;"
  47. @click="askApply">申请扩容</span>
  48. </p>
  49. <el-progress style="margin-left: 8px;" :percentage="percent()" />
  50. </div>
  51. </div>
  52. <!-- 右侧大盒子 -->
  53. <div class="mesBox">
  54. <!-- 功能盒子 -->
  55. <div class="useBox">
  56. <!-- table切换 -->
  57. <div style="width: 100%;height: 24px;background-color: #7084B4;line-height: 20px;">
  58. <template v-for="(item, index) in menuList">
  59. <span @click="tableChange(item, index)"
  60. :class="['tables', { tableLis: selectedIndex === index }]">
  61. {{ item.name }}
  62. <img v-if="selectedIndex === index ? true : false"
  63. style="position: absolute;top: 4px;right: 4px;" src="../../assets/images/close.png"
  64. @click="shotdown(item)">
  65. </span>
  66. </template>
  67. </div>
  68. </div>
  69. <!-- 展示文件夹盒子 -->
  70. <!-- 文件夹 -->
  71. <div v-if="editOnline">
  72. <!-- 众多功能 -->
  73. <div class="manyUse">
  74. <div
  75. style="display: flex;width: 92px;height: 32px;justify-content: flex-start;align-items: center;line-height: 18px;">
  76. <div style="margin-left: 5px;">
  77. <img src="../../assets/images/upload.png" style="width: 24px;height: 24px;" alt="">
  78. </div>
  79. <div style="margin-left: 5px;">
  80. <span style="color: black;cursor: pointer;" @click="uploadModal = true">上传
  81. </span>
  82. </div>
  83. </div>
  84. <div
  85. style="display: flex;width: 82px;height: 32px;justify-content: flex-start;align-items: center;">
  86. <div style="margin-left: 5px;">
  87. <el-icon
  88. style="background-color: #7084B4;width: 24px;height: 24px;border-radius: 50%;color: white;"
  89. @click="createNewMenu(0)">
  90. <Plus />
  91. </el-icon>
  92. </div>
  93. <div style="margin-left: 5px;" @click="createNewMenu(0)">
  94. <span style="font-size: 14px;">新建</span>
  95. </div>
  96. </div>
  97. <template v-for="(item, index) in useMenu" :key="index">
  98. <div :class="{ 'isCheck': haveCheck }"
  99. style="display: flex;width: 82px;opacity:0.5;height: 32px;justify-content: flex-start;align-items: center;line-height: 18px;cursor: pointer;"
  100. @click="getMenu(item, index)">
  101. <div style="margin-left: 5px;">
  102. <img :src="item.img" style="width: 24px;height: 24px;" alt="">
  103. </div>
  104. <div style="margin-left: 5px;">
  105. <span style="font-size: 14px;">{{ item.name }}</span>
  106. </div>
  107. </div>
  108. </template>
  109. </div>
  110. <!-- 面包屑功能栏 -->
  111. <div class="breadBox">
  112. <!-- 左侧 -->
  113. <div style="display: flex;justify-content: space-around;align-items: center;">
  114. <!-- 前进后退 -->
  115. <div style="display: flex;justify-content: space-around;align-items: center;">
  116. <img style="display:block;width: 11px;height: 11px;" :src="blueLeft" alt=""
  117. @click="arrowLift">
  118. <img style="display:block;width: 16px;height: 16px;" :src="grayRight" alt="">
  119. </div>
  120. <!-- 面包屑 -->
  121. <div class="topPath">
  122. {{ topPath }}
  123. <!-- <BreadMenu></BreadMenu> -->
  124. </div>
  125. </div>
  126. <!-- 右侧 -->
  127. <div>
  128. <img :src="sort" alt="">
  129. <img :src="squre" alt="" @click="gridChange">
  130. </div>
  131. </div>
  132. <!-- </div> -->
  133. <!-- 展示文件夹盒子 -->
  134. <!-- 文件夹 -->
  135. <div class="detailBox file-jia" @click="mouseClick">
  136. <el-collapse v-model="folder" accordion class="collapseSell">
  137. <el-collapse-item title="文件夹" name="1" class="custom-collapse-item">
  138. <el-table v-if="folderGrid" :data="folderList" style="width: 100%"
  139. @selection-change="handleSelectionChange1" :single-select="true" @row-click="folderClick"
  140. @row-contextmenu="folderRClick" ref="taskTableRef">
  141. <el-table-column type="selection" width="55" />
  142. <el-table-column label="名称" width="180">
  143. <template #default="scope">
  144. <span>
  145. <el-icon v-if="scope.row.isFavorite == 'N'">
  146. <Star />
  147. </el-icon>
  148. <img v-else @click.stop="delCollect(scope.row,true)" src="../../assets/images/yellowstar.png" alt="">
  149. <img src="../../assets/images/fileBox.png" style="width: 20px;height: 24px;"
  150. alt="">
  151. {{ scope.row.dirName }}
  152. </span>
  153. </template>
  154. </el-table-column>
  155. <el-table-column prop="createTime" label="时间" width="180" />
  156. <el-table-column prop="dirType" label="类型">
  157. <template #default="scope">
  158. <span>{{ scope.row.dirType === "1" ? "文件夹" : "未知类型" }}</span>
  159. </template>
  160. </el-table-column>
  161. <el-table-column label="大小">
  162. <template #default="scope">
  163. <span>
  164. 10KB
  165. </span>
  166. </template>
  167. </el-table-column>
  168. </el-table>
  169. <PlaceGridFolder v-else :folderClick="folderClick" :restName="restName"
  170. :collectFolder="collectFolder" :getAllTop="getAllTop" @folderBack="folderBack">
  171. </PlaceGridFolder>
  172. </el-collapse-item>
  173. </el-collapse>
  174. <!-- 右键唤出的菜单 -->
  175. <div class="right_menu" v-if="folderVisible"
  176. :style="{ left: folderleft + 'px', top: foldertop + 'px' }">
  177. <div class="menu_item" @click="folderClick(null, null)">
  178. <img src="@/assets/images/trash.png" alt="" />
  179. <span>打开</span>
  180. </div>
  181. <div class="menu_item" @click="restName(null, null)">
  182. <img src="@/assets/images/textbox.png" alt="" />
  183. <span>重命名</span>
  184. </div>
  185. <div class="menu_item" @click="collectFolder">
  186. <img src="@/assets/images/collect.png" alt="" />
  187. <span>收藏</span>
  188. </div>
  189. </div>
  190. </div>
  191. <!-- 文件 -->
  192. <div class="fileTable">
  193. <el-collapse v-model="files" accordion class="collapse" style="height: 200px;">
  194. <el-collapse-item title="文件" name="2" class="">
  195. <el-table v-if="fileGrid" :data="fileList" style="width: 100%;position: relative;"
  196. @row-contextmenu="handleRowClick" @selection-change="handleSelectionChange"
  197. @row-click="mouseClick" :default-sort="{ prop: 'createTime', order: 'descending' }">
  198. <el-table-column type="selection" width="55" />
  199. <el-table-column label="名称" width="200">
  200. <template #default="scope">
  201. <span style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis;">
  202. <el-icon v-if="scope.row.isFavorite == 'N'">
  203. <Star />
  204. </el-icon>
  205. <img v-else @click.stop="delCollect(scope.row,false)" src="../../assets/images/yellowstar.png" alt="">
  206. <img :src="getImage(scope.row.fileType)" alt="">
  207. {{ scope.row.fileName }}
  208. </span>
  209. </template>
  210. </el-table-column>
  211. <el-table-column prop="createTime" label="时间" sortable width="180" />
  212. <el-table-column prop="fileType" label="类型" />
  213. <el-table-column label="大小">
  214. <template #default="scope">
  215. <span>
  216. {{ formatFileSize(scope.row.fileSize) }}
  217. </span>
  218. </template>
  219. </el-table-column>
  220. </el-table>
  221. <PalaceGridFile v-else @showFile="showFile" :getAllTop="getAllTop" @navBack="navBack"
  222. @lastBB="lastBB" @onlineCase="onlineCase" @shareBack="shareBack"></PalaceGridFile>
  223. </el-collapse-item>
  224. </el-collapse>
  225. <div class="setCli" v-if="cliCC" :style="{ left: xz + 'px', top: yz - 260 + 'px' }">
  226. <template v-for="(item, index) in filterMouseCli()" :key="index">
  227. <p @click="chooseSet(item, index, 1)" class="chooseSet">
  228. <img :src="item.img" alt="">
  229. {{ item.name }}
  230. <span v-if="item.name == '在线编辑' || item.name == '协作' ? true : false"
  231. style="color: #7084B4;float: right;position: relative;" class="arrow">></span>
  232. </p>
  233. </template>
  234. </div>
  235. <div class="setCli1" v-if="anyP" :style="{ left: xz + 155 + 'px', top: yz + 'px' }">
  236. <p @click="chooseSet1(0)" class="chooseSet">
  237. <img src="../../assets/images/user.png" alt="">
  238. 选择人员
  239. </p>
  240. <p class="chooseSet" @click="goLock">
  241. <img src="../../assets/images/archiveTray.png" alt="">
  242. 归档
  243. </p>
  244. </div>
  245. </div>
  246. </div>
  247. <div v-else>
  248. <div>
  249. <el-button @click="editOnline = true; historyPrew = false">返回</el-button>
  250. </div>
  251. <FileEdit :docId="clickRowId" :copyRow="copyRow" :historyPrew="historyPrew"
  252. :historycopyRow="historycopyRow" :onlyView="onlyView" @cancleHistoryPrew="cancleHistoryPrew">
  253. </FileEdit>
  254. </div>
  255. </div>
  256. <!-- 扩容弹窗 -->
  257. <div>
  258. <SpaceBig v-if="spaces" :spaces="spaces" :impSpaceId="impSpaceId" @getSpaceC="getSpaceC"></SpaceBig>
  259. </div>
  260. <!-- 新增文件夹弹窗 -->
  261. <div>
  262. <CreateFloder v-if="folderCase" :folderCase="folderCase" @getChildrenC="getChildrenC" :oneOrTwo="oneOrTwo"
  263. :impDirId="impDirId" :impSpaceId="impSpaceId" :newDirId="newDirId" :newSpaceId="newSpaceId"
  264. :getAllTop="getAllTop">
  265. </CreateFloder>
  266. </div>
  267. <!-- 文件上传 -->
  268. <div>
  269. <el-dialog v-model="uploadModal" title="文件上传" width="30%">
  270. <el-upload class="upload-demo" drag :http-request="onSuccess" multiple>
  271. <el-icon class="el-icon--upload"><upload-filled /></el-icon>
  272. <div class="el-upload__text">拖入或<em>点击上传</em></div>
  273. <template #tip>
  274. <div class="el-upload__tip">请选择或拖入文件</div>
  275. </template>
  276. </el-upload>
  277. <template #footer>
  278. <span class="dialog-footer">
  279. <el-button @click="uploadModal = false">取消</el-button>
  280. <el-button type="primary" @click="sureUpload">确认</el-button>
  281. </span>
  282. </template>
  283. </el-dialog>
  284. </div>
  285. <!-- 文件重命名 -->
  286. <div>
  287. <el-dialog v-model="fileNameChange" title="重命名" width="30%">
  288. <el-form :model="nameForm" label-width="120px">
  289. <el-form-item label="新名字">
  290. <el-input v-model="nameForm.name"></el-input>
  291. </el-form-item>
  292. </el-form>
  293. <template #footer>
  294. <span class="dialog-footer">
  295. <el-button @click="fileNameChange = false">取消</el-button>
  296. <el-button type="primary" @click="sureChangeName">
  297. 确认
  298. </el-button>
  299. </span>
  300. </template>
  301. </el-dialog>
  302. </div>
  303. <!-- 文件收藏 -->
  304. <div>
  305. <FileCollect v-if="collects" :collects="collects" @getCollects="getCollects" :copyFileName="copyFileName"
  306. :copyFileId="copyFileId" @refreshFile="refreshFile" :isFolder="isFolder" :clickRow="clickRow"></FileCollect>
  307. </div>
  308. <!-- 中栏重命名 -->
  309. <div>
  310. <FolderReName v-if="rename" :rename="rename" :selectedBox="selectedBox" :getAllTop="getAllTop"
  311. :copyFolderName="copyFolderName" @getRename="getRename">
  312. </FolderReName>
  313. </div>
  314. <ImgPreview :previewData="previewData" :copyFileType="copyFileType" :showPreview="showPreview"
  315. @closeImgPreview="closeImgPreview"></ImgPreview>
  316. <div>
  317. <FileTree v-if="fileTrees" :fileTrees="fileTrees" :newSpaceId="newSpaceId" :fileId="clickRowId"
  318. @getChildren="getChildren" :copyOrMove="copyOrMove"></FileTree>
  319. </div>
  320. <!-- 穿梭框 -->
  321. <div>
  322. <TransferModal v-if="thanks" :thanks="thanks" :clickRowId="clickRowId" :workOrEdit="workOrEdit"
  323. @getCback="getCback"></TransferModal>
  324. </div>
  325. </div>
  326. </div>
  327. <!-- 图片预览 -->
  328. <!-- 历史版本 -->
  329. <historyList :openFile="openForwardFile" :docId="clickRowId" :name="nameForm.name" :copyRow="copyRow"
  330. @close="openForwardFile = false" :fileUserTreeData="fileUserTreeData.data" @changeMsgClose="changeMsgClose"
  331. :historyTotal="historyTotal">
  332. </historyList>
  333. <!-- 历史版本 -->
  334. </template>
  335. <script>
  336. import { ref, toRaw, onMounted } from 'vue'
  337. import myfile from '../../api/myfile/myfile'
  338. import { delFavorite } from '@/api/biz/favorite.js'
  339. import documents from '../../api/document/document'
  340. import fileCount from '../../api/fileCount/fileCount'
  341. import FileTree from './components/FileTree.vue'
  342. import BreadMenu from './components/BreadMenu.vue'
  343. import FileEdit from './components/FileEdit.vue'
  344. import TransferModal from './modalComponebts/Transfer.vue'
  345. import CreateFloder from './modalComponebts/CreateFloder.vue'
  346. import FileCollect from './modalComponebts/FileCollect.vue'
  347. import FolderReName from './modalComponebts/FolderReName.vue'
  348. import SpaceBig from './modalComponebts/SpaceBig.vue'
  349. import PlaceGridFolder from './components/PlaceGridFolder.vue'
  350. import PalaceGridFile from './components/PalaceGridFile.vue'
  351. import ImgFile from "./jsComponents/ImgFile"
  352. import { Search } from '@element-plus/icons-vue'
  353. import blueLeft from '../../assets/images/blueLeft.png'
  354. import grayRight from "../../assets/images/grayRight.png"
  355. import sort from '../../assets/images/sort.png'
  356. import squre from '../../assets/images/squre.png'
  357. import { ElMessage } from 'element-plus'
  358. import ImgPreview from '@/components/ImgPreview/ImgPreview.vue'
  359. import { preview } from "@/api/common/common.js";
  360. import historyList from "@/components/historyList/index.vue"; //选择文件发送的列表,历史版本
  361. import { listVersion } from "@/api/biz/version";
  362. import useUserStore from "@/store/modules/user";
  363. import { useRouter, useRoute } from "vue-router";
  364. import { canPreviewFile } from "@/utils/index.js"
  365. export default {
  366. setup() {
  367. const { proxy } = getCurrentInstance();
  368. let fileTrees = ref(false)//filetree父传子
  369. let thanks = ref(false)//transfer父传子
  370. let collects = ref(false)//文件收藏父传子
  371. let rename = ref(false)//文件夹重命名
  372. let spaces = ref(false)//空间扩容父传子
  373. let folderCase = ref(false)
  374. let fileGrid = ref(true)
  375. let folderGrid = ref(true)
  376. let editOnline = ref(true)
  377. let searchFire = ref('')
  378. let selectedIndex = ref(0)
  379. let folder = ref(['1'])
  380. let files = ref(['2'])
  381. let folderList = ref([])
  382. let cliCC = ref(false)
  383. let anyP = ref(false)
  384. let uploadModal = ref(false)
  385. let collectImg = ref(true)
  386. let selectedBox = ref(-1)
  387. let clickRowId = ref(0)
  388. let trandata = ref()
  389. let folderId = ref('')
  390. let fileId = ref('')
  391. let tranvalue = ref([])
  392. let useSpace = ref(0)
  393. let allSpace = ref(0)
  394. let fileArr = ref([])
  395. let copyDirId = ref(0)//需要操作的dirid
  396. let copySpaceId = ref(0)//需要操作的spaceid
  397. let copyDocId = ref(0)//需要操作的docid
  398. let copyFileId = ref(0)//需要操作的fileid
  399. let copyFileSize = ref(0)//需要操作的filesize
  400. let copyFileType = ref('')//需要操作的文件类型
  401. let copyFileName = ref("")//需要操作的文件名
  402. let copyFolderName = ref("")
  403. let copySpaceCup = ref(0)
  404. let directoryId = ref('')
  405. let impSpaceId = ref("")
  406. let impDirId = ref("")
  407. let impNum = ref(0)
  408. let copyParentId = ref("")//文件夹
  409. let needBag = ref("")
  410. let copyOrMove = ref(0)//0代表复制,1代表移动
  411. let oneOrTwo = ref(0)//0代表二级,1代表一级
  412. let sortNum = ref(0)
  413. let folderTotal = ref(0)//文件夹total
  414. let fileTotal = ref(0)//文件total
  415. const openForwardFile = ref(false) //历史版本展示
  416. const delMoreFile = ref([]) //删除多个文件夹
  417. const historyTotal = ref(0)
  418. const historyPrew = ref(false)
  419. let xz = ref(0)
  420. let yz = ref(0)
  421. const fileUserTreeData = reactive({ data: {} });
  422. let fileList = ref([
  423. ])
  424. let menuList = ref([
  425. {
  426. name: "我的空间",
  427. choose: "我的空间"
  428. }
  429. ])
  430. let useMenu = ref([
  431. // {
  432. // img: ImgFile.copy,
  433. // name: "复制"
  434. // },
  435. // {
  436. // img: ImgFile.clipboard,
  437. // name: "粘贴"
  438. // },
  439. {
  440. img: ImgFile.share,
  441. name: "分享给"
  442. },
  443. {
  444. img: ImgFile.trash,
  445. name: "删除"
  446. },
  447. ])
  448. let arrorMenu = ref([
  449. {
  450. img: ImgFile.file,
  451. name: "文件"
  452. },
  453. {
  454. img: ImgFile.folder,
  455. name: '文件夹'
  456. },
  457. {
  458. img: ImgFile.image,
  459. name: "图片"
  460. },
  461. {
  462. img: ImgFile.filmSlate,
  463. name: "视频"
  464. },
  465. {
  466. img: ImgFile.musicNotes,
  467. name: "音频"
  468. }
  469. ])
  470. let mouseCli = ref([
  471. {
  472. img: ImgFile.previewIcon,
  473. name: "预览"
  474. },
  475. {
  476. img: ImgFile.addolder,
  477. name: "移动到...",
  478. },
  479. {
  480. img: ImgFile.copy,
  481. name: "复制到...",
  482. },
  483. // {
  484. // img: ImgFile.clipboard,
  485. // name: "粘贴"
  486. // },
  487. {
  488. img: ImgFile.collect,
  489. name: "收藏"
  490. },
  491. {
  492. img: ImgFile.downLoad,
  493. name: "下载"
  494. },
  495. {
  496. img: ImgFile.textbox,
  497. name: "重命名"
  498. },
  499. // {
  500. // img: ImgFile.goon,
  501. // name: "发送"
  502. // },
  503. {
  504. img: ImgFile.share,
  505. name: "分享"
  506. },
  507. {
  508. img: ImgFile.notePencil,
  509. name: "在线编辑"
  510. },
  511. {
  512. img: ImgFile.togger,
  513. name: "协作"
  514. },
  515. {
  516. img: ImgFile.icc,
  517. name: "文字识别"
  518. },
  519. {
  520. img: ImgFile.history,
  521. name: "历史版本"
  522. },
  523. {
  524. img: ImgFile.trash,
  525. name: "删除"
  526. }
  527. ])
  528. let nameForm = ref({
  529. name: ""
  530. })
  531. let fileNameChange = ref(false)
  532. let fileMenu = ref([])
  533. let copyRow = ref({})
  534. let newDirId = ref('')
  535. let newSpaceId = ref('')
  536. let workOrEdit = ref(0)
  537. const showPreview = ref(false)//控制图片预览组件显示
  538. const previewData = ref()//需要预览的文件的数据
  539. const router = useRouter(); //注册路由
  540. const folderVisible = ref(false); //显示文件夹右键菜单
  541. const foldertop = ref(0);
  542. const folderleft = ref(0);
  543. const thisFolder = ref({}); //当前右键的文件夹
  544. const folderCheckout = ref(false)//是否有勾选
  545. const fileCheckout = ref(false)//是否有勾选
  546. const haveCheck = ref(false)//是否有勾选
  547. const onlyView = ref(false) //预览
  548. const topPath = ref()//顶部路径
  549. const isFolder = ref('N') //是否为文件夹
  550. const clickRow = ref()//当前右键的行数据
  551. // 获取文件夹,中栏,文件
  552. function getAllTop() {
  553. documents.getTop(3).then(res => {
  554. let userMe = [res]
  555. impDirId.value = userMe[0].dirId//固定
  556. impSpaceId.value = userMe[0].spaceId//固定
  557. newSpaceId.value = userMe[0].spaceId//变化
  558. newDirId.value = userMe[0].dirId//变化
  559. topPath.value = userMe[0].dirPath
  560. let obj = {
  561. pageNum: 1,
  562. pageSize: 10
  563. }
  564. documents.getALLdocument({ parentId: userMe[0].dirId - 0, spaceId: userMe[0].spaceId, pageNum: obj.pageNum, pageSize: obj.pageSize }).then(res => {
  565. fileMenu.value = res.data
  566. folderList.value = res.data
  567. })
  568. myfile.getById(userMe[0].dirId - 0, obj).then(res => {
  569. if (res.code === 200) {
  570. fileList.value = res.rows
  571. fileTotal.value = res.total
  572. if (fileTotal.value / 10 != 1) {
  573. let x = Math.trunc(fileTotal.value / 10) + 1
  574. for (var i = 1; i <= x; i++) {
  575. obj.pageNum = i
  576. myfile.getById(userMe[0].dirId - 0, obj).then(res => {
  577. fileList.value = fileList.value.concat(res.rows)
  578. const uniqueFileList = Array.from(new Set(fileList.value.map(item => item.docId)))
  579. .map(docId => fileList.value.find(item => item.docId === docId));
  580. // 合并数组并更新 fileList.value
  581. fileList.value = uniqueFileList
  582. })
  583. }
  584. }
  585. }
  586. })
  587. })
  588. }
  589. function getSpaceList() {
  590. myfile.fileType(3).then(res => {
  591. useSpace.value = res.data.usedCap
  592. allSpace.value = res.data.spaceCap
  593. })
  594. }
  595. function changeFile(row, num) {
  596. copyParentId.value = row.parentId
  597. newDirId.value = row.dirId
  598. newSpaceId.value = row.spaceId
  599. documents.getALLdocument({ parentId: row.dirId - 0, spaceId: row.spaceId - 0 }).then(res => {
  600. folderList.value = res.data
  601. // if (res.code === 200) {
  602. if (res.data.length === 0) {
  603. myfile.getById(newDirId.value)
  604. .then(res => {
  605. if (res.code === 200) {
  606. fileList.value = res.rows;
  607. }
  608. })
  609. .catch(error => {
  610. console.error("myfile.getAllFileMenu 调用失败:", error);
  611. });
  612. } else {
  613. myfile.getById(row.dirId - 0)
  614. .then(res => {
  615. if (res.code === 200) {
  616. fileList.value = res.rows;
  617. }
  618. })
  619. .catch(error => {
  620. console.error("myfile.getAllFileMenu 调用失败:", error);
  621. });
  622. }
  623. // }
  624. })
  625. selectedIndex.value = num
  626. const newItem = {
  627. name: row.dirName,
  628. choose: row.dirName,
  629. dirIds: row.dirId,
  630. spaceIds: row.spaceId
  631. };
  632. // 检查 newItem 是否已存在于 menuList 中
  633. const isItemExist = menuList.value.some(item => item.choose === newItem.choose);
  634. // 如果不存在,则添加它
  635. if (!isItemExist) {
  636. menuList.value.push(newItem);
  637. }
  638. }
  639. // tableMenu切换
  640. function tableChange(row, num) {
  641. if (row.name == '我的空间') {
  642. getAllTop()
  643. if (!editOnline.value) {
  644. editOnline.value = true
  645. }
  646. } else {
  647. let obj = {
  648. pageNum: 1,
  649. pageSize: 10
  650. }
  651. documents.getALLdocument({ parentId: row.dirIds - 0, spaceId: row.spaceIds - 0, pageNum: obj.pageNum, pageSize: obj.pageSize }).then(res => {
  652. // fileMenu.value = res.data
  653. folderList.value = res.data
  654. })
  655. myfile.getById(row.dirIds - 0, obj).then(res => {
  656. if (res.code === 200) {
  657. fileList.value = res.rows
  658. fileTotal.value = res.total
  659. if (fileTotal.value / 10 != 1) {
  660. let x = Math.trunc(fileTotal.value / 10) + 1
  661. for (var i = 1; i <= x; i++) {
  662. obj.pageNum = i
  663. myfile.getById(userMe[0].dirId - 0, obj).then(res => {
  664. fileList.value = fileList.value.concat(res.rows)
  665. const uniqueFileList = Array.from(new Set(fileList.value.map(item => item.docId)))
  666. .map(docId => fileList.value.find(item => item.docId === docId));
  667. // 合并数组并更新 fileList.value
  668. fileList.value = uniqueFileList
  669. })
  670. }
  671. }
  672. }
  673. })
  674. }
  675. selectedIndex.value = num
  676. }
  677. // x图标事件
  678. function shotdown(row) {
  679. menuList.value = menuList.value.filter(item => item.name !== row.name)
  680. selectedIndex.value = -1
  681. if (!editOnline.value) {
  682. editOnline.value = true
  683. }
  684. }
  685. // 文件名表格每一行点击事件
  686. function handleRowClick(row, col, e) {
  687. isFolder.value = "N"
  688. clickRow.value = row
  689. e.preventDefault();
  690. e.stopPropagation();
  691. xz.value = e.pageX
  692. yz.value = e.pageY
  693. copyRow.value = row
  694. clickRowId.value = row.docId
  695. copyDirId.value = row.dirId
  696. copySpaceId.value = row.spaceId
  697. copyFileId.value = row.fileId
  698. copyFileSize.value = row.fileSize
  699. copyFileType.value = row.fileType
  700. nameForm.value.name = row.fileName
  701. copyFileName.value = row.fileName
  702. if (cliCC.value === true) {
  703. cliCC.value = false
  704. } else {
  705. cliCC.value = true
  706. }
  707. }
  708. // 申请扩容
  709. function askApply() {
  710. spaces.value = true
  711. }
  712. //mouse弹框
  713. async function chooseSet(row, index, num) {
  714. if (row.name == '在线编辑' || row.name == '协作') {
  715. cliCC.value = true
  716. }
  717. if (row.name == '分享') {
  718. workOrEdit.value = num
  719. thanks.value = true
  720. } else {
  721. thanks.value = false
  722. }
  723. if (row.name == '协作') {
  724. if (anyP.value) {
  725. anyP.value = false
  726. } else {
  727. anyP.value = true
  728. }
  729. } else {
  730. anyP.value = false
  731. }
  732. if (row.name == '删除') {
  733. myfile.delMenu(clickRowId.value).then(res => {
  734. if (res.code === 200) {
  735. ElMessage({
  736. type: "success",
  737. message: "删除成功"
  738. })
  739. getAllTop()
  740. }
  741. })
  742. }
  743. if (row.name === '复制到...') {
  744. copyOrMove.value = 0
  745. fileTrees.value = true
  746. }
  747. if (row.name === '移动到...') {
  748. copyOrMove.value = 1
  749. fileTrees.value = true
  750. }
  751. if (row.name === '重命名') {
  752. fileNameChange.value = true
  753. }
  754. if (row.name === "下载") {
  755. location.href = `${import.meta.env.VITE_APP_BASE_API}/api/download/${copyFileId.value}`;
  756. }
  757. if (row.name === '收藏') {
  758. collects.value = true
  759. }
  760. if (row.name === '在线编辑') {
  761. editOnline.value = false
  762. cliCC.value = false
  763. const newItem = {
  764. name: copyFileName.value,
  765. choose: copyFileId.value,
  766. dirIds: copyDirId.value,
  767. spaceIds: copySpaceId.value
  768. };
  769. // 检查 newItem 是否已存在于 menuList 中
  770. const isItemExist = menuList.value.some(item => item.choose === newItem.choose);
  771. // 如果不存在,则添加它
  772. if (!isItemExist) {
  773. menuList.value.push(newItem);
  774. }
  775. selectedIndex.value = selectedIndex.value + 1
  776. }
  777. if (row.name === '文字识别') {
  778. router.push({
  779. path: '/identifyFont',
  780. query: {
  781. fileId: copyFileId.value,
  782. fileType: copyFileType.value
  783. }
  784. })
  785. }
  786. if (row.name === '预览') {
  787. const filePreview = canPreviewFile(copyFileType.value)
  788. if (filePreview) {
  789. onlyView.value = true
  790. editOnline.value = false
  791. cliCC.value = false
  792. } else {
  793. showPreview.value = true
  794. const res = await preview(copyFileId.value)
  795. previewData.value = URL.createObjectURL(res)
  796. }
  797. console.log('filePreview', filePreview);
  798. // console.log('res',res);
  799. showPreview.value = true
  800. const res = await preview(copyFileId.value)
  801. previewData.value = URL.createObjectURL(res)
  802. } else if (row.name === "历史版本") {
  803. const resHistory = await listVersion({ docId: clickRowId.value })
  804. historyTotal.value = resHistory.total
  805. fileUserTreeData.data = resHistory.rows;
  806. openForwardFile.value = true
  807. }
  808. }
  809. function chooseSet1(num) {
  810. workOrEdit.value = num
  811. thanks.value = true
  812. anyP.value = false
  813. }
  814. function createNewMenu(num) {
  815. oneOrTwo.value = num
  816. folderCase.value = true
  817. }
  818. function cancleHistoryPrew(val) {
  819. historyPrew.value = false
  820. }
  821. function createNewFile() {
  822. addFile.value = true
  823. }
  824. function arrowClick(row, num) {
  825. if (row.name === '文件') {
  826. uploadModal.value = true
  827. } else {
  828. uploadModal.value = false
  829. }
  830. }
  831. // 确认上传
  832. function sureUpload() {
  833. if (fileArr.value.length > 0) {
  834. for (var i = 1; i <= fileArr.value.length; i++) {
  835. myfile.uploadFile({
  836. spaceId: newSpaceId.value - 0,
  837. dirId: newDirId.value - 0,
  838. file: fileArr.value[i - 1]
  839. }).then(res => {
  840. if (res.code === 200) {
  841. ElMessage({
  842. message: "上传文件成功",
  843. type: "success"
  844. })
  845. getAllTop()
  846. uploadModal.value = false
  847. fileArr.value = []
  848. }
  849. })
  850. }
  851. }
  852. }
  853. function onSuccess(files, val) {
  854. fileArr.value.push(files.file)
  855. }
  856. // 筛选后缀图片
  857. function getImage(file) {
  858. if (file === '.txt') {
  859. return ImgFile.txt
  860. } else if (file === '.xlxs' || file === '.docx') {
  861. return ImgFile.xlxs
  862. } else if (file === '.pptx') {
  863. return ImgFile.pptx
  864. } else if (file === '.word') {
  865. return ImgFile.word
  866. } else if (file === '.pdf') {
  867. return ImgFile.pdf
  868. }
  869. }
  870. // 表格多选框
  871. function handleSelectionChange(val) {
  872. delMoreFile.value = val //删除多项的数据
  873. // if (val.length > 1) {
  874. // // 如果选择了多项,只保留最后一项
  875. // val.shift();
  876. // }
  877. if (val.length === 1) {
  878. fileId.value = val[0].docId
  879. }
  880. if (val.length) {
  881. folderCheckout.value = true
  882. haveCheck.value = true
  883. } else {
  884. folderCheckout.value = false
  885. if (!fileCheckout.value) {
  886. haveCheck.value = false
  887. }
  888. }
  889. }
  890. // 文件夹
  891. function handleSelectionChange1(val) {
  892. delMoreFile.value = val //删除多项的数据
  893. if (val.length > 1) {
  894. // 如果选择了多项,只保留最后一项
  895. val.shift();
  896. proxy.$refs.taskTableRef.toggleRowSelection(val.shift(), false);//单选操作
  897. }
  898. if (val.length === 1) {
  899. folderId.value = val[0].dirId
  900. }
  901. if (val.length) {
  902. fileCheckout.value = true
  903. haveCheck.value = true
  904. } else {
  905. fileCheckout.value = false
  906. if (!folderCheckout.value) {
  907. haveCheck.value = false
  908. }
  909. }
  910. }
  911. // 重命名
  912. function restName(row, index) {
  913. // 判断是点击打开还是右键菜单打开
  914. row = row ? row : clickRow.value
  915. copyFolderName.value = row.dirName
  916. selectedBox.value = row.dirId
  917. rename.value = true
  918. }
  919. function getMenu(row, num) {
  920. if (row.name === '删除') {
  921. const datas = []
  922. const isFile = ref(false)
  923. delMoreFile.value.map(i => {//多选删除
  924. if (i.parentId) {//文件
  925. isFile.value = true
  926. } else {//文件夹
  927. datas.push(i.docId)
  928. }
  929. })
  930. // 文件夹删除
  931. if (isFile.value) {//文件
  932. documents.delDocument(folderId.value).then(res => {
  933. if (res.code === 200) {
  934. ElMessage({
  935. message: "删除成功",
  936. type: "success"
  937. })
  938. getAllTop()
  939. } else {
  940. ElMessage({
  941. message: "删除失败,目录应不为空",
  942. type: "error"
  943. })
  944. }
  945. isFile.value = false
  946. })
  947. } else {
  948. myfile.delMenu(datas.toString()).then(res => {
  949. if (res.code === 200) {
  950. ElMessage({
  951. message: "删除成功",
  952. type: "success"
  953. })
  954. getAllTop()
  955. }
  956. })
  957. }
  958. }
  959. }
  960. function delName(row, num) {
  961. documents.delDocument(row.dirId).then(res => {
  962. if (res.code === 200) {
  963. getAllTop()
  964. ElMessage({
  965. message: "删除成功",
  966. type: "success"
  967. })
  968. }
  969. })
  970. }
  971. // 计算百分比
  972. function percent() {
  973. let numP = 0;
  974. if (useSpace.value && allSpace.value) {
  975. numP = (useSpace.value / allSpace.value) * 100;
  976. }
  977. return numP.toFixed(2) - 0; // 将结果保留两位小数
  978. }
  979. // 文件夹每行点击事件
  980. function folderClick(row, list) {
  981. // 上一级dirId就是下一级的parentId
  982. // 判断是点击打开还是右键菜单打开
  983. if(row){
  984. thisFolder.value = row;
  985. }else{
  986. row =clickRow.value
  987. }
  988. console.log('row', toRaw(row));
  989. topPath.value = row.dirPath
  990. // console.log('topPath',toRaw(topPath.value));
  991. newDirId.value = row.dirId
  992. newSpaceId.value = row.spaceId
  993. documents.getALLdocument({
  994. parentId: newDirId.value - 0,
  995. spaceId: newSpaceId.value - 0
  996. }).then(res => {
  997. folderList.value = res.data
  998. if (res.data.length === 0) {
  999. myfile.getById(newDirId.value).then(res => {
  1000. if (res.code === 200) {
  1001. fileList.value = res.rows
  1002. }
  1003. })
  1004. } else {
  1005. myfile.getById(newDirId.value).then(res => {
  1006. if (res.code === 200) {
  1007. fileList.value = res.rows
  1008. }
  1009. })
  1010. }
  1011. })
  1012. }
  1013. // 确认文件重命名
  1014. function sureChangeName() {
  1015. myfile.editNewMenu({
  1016. dirId: copyDirId.value - 0,
  1017. docId: clickRowId.value - 0,
  1018. fileId: copyFileId.value,
  1019. fileName: nameForm.value.name,
  1020. fileSize: copyFileSize.value - 0,
  1021. fileType: copyFileType.value,
  1022. remark: '',
  1023. spaceId: copySpaceId.value - 0,
  1024. }).then(res => {
  1025. if (res.code === 200) {
  1026. ElMessage({
  1027. message: "重命名成功",
  1028. type: "success"
  1029. })
  1030. fileNameChange.value = false
  1031. getAllTop()
  1032. }
  1033. })
  1034. }
  1035. // 判断id
  1036. function isId() {
  1037. if (directoryId.value === '') {
  1038. directoryId.value = 0
  1039. getAllTop()
  1040. }
  1041. if (folderId.value === '') {
  1042. folderId.value = 0
  1043. getAllTop()
  1044. }
  1045. }
  1046. //关闭图片预览事件
  1047. const closeImgPreview = () => {
  1048. // console.log('close');
  1049. showPreview.value = false
  1050. }
  1051. function getChildren(data) {
  1052. fileTrees.value = data
  1053. }
  1054. function getCback(data) {
  1055. thanks.value = data
  1056. }
  1057. function getChildrenC(data) {
  1058. folderCase.value = data
  1059. }
  1060. function getCollects(data) {
  1061. collects.value = data
  1062. }
  1063. function getRename(data) {
  1064. rename.value = data
  1065. }
  1066. function getSpaceC(data) {
  1067. spaces.value = data
  1068. }
  1069. function navBack(data, name) {
  1070. nameForm.value.name = name
  1071. fileNameChange.value = data
  1072. }
  1073. function onlineCase(data, uid, row) {
  1074. editOnline.value = data
  1075. clickRowId.value = uid
  1076. copyRow = row
  1077. }
  1078. function shareBack(data, num) {
  1079. thanks.value = data
  1080. workOrEdit.value = num
  1081. }
  1082. function showFile(data, e, a) {
  1083. editOnline.value = data
  1084. clickRowId.value = e
  1085. copyRow = a
  1086. }
  1087. function folderBack(dir, spa, nam) {
  1088. selectedBox.value = dir
  1089. copyFolderName.value = nam
  1090. copyFileName.value = spa
  1091. }
  1092. //历史版本
  1093. const forwardTreeData = reactive({ data: {} });
  1094. const historycopyRow = ref({})
  1095. function changeMsgClose(val, item) {
  1096. if (val) {
  1097. historycopyRow.value = item
  1098. editOnline.value = false
  1099. cliCC.value = false
  1100. historyPrew.value = true
  1101. }
  1102. openForwardFile.value = val
  1103. }
  1104. function lastBB(data, row, num) {
  1105. openForwardFile.value = data
  1106. historyTotal.value = row
  1107. fileUserTreeData.data = num
  1108. }
  1109. //对mouseCli数组进行筛选,实现菜单的区分显示
  1110. const filterMouseCli = () => {
  1111. const canPreviewArray = ['.doc', '.docm', '.docx', '.dot', '.dotm', '.dotx', '.epub', '.fodt', '.htm', '.html', '.mht', '.odt', '.ott', '.pdf', '.rtf', '.txt', '.djvu', '.xps', 'csv', 'fods', 'ods', 'ots', 'xls', 'xlsm', 'xlsx', 'xlt', 'xltm', 'xltx', 'fodp', 'odp', 'otp', 'pot', 'potm', 'potx', 'pps', 'ppsm', 'ppsx', 'ppt', 'pptm', 'pptx']
  1112. const typeArr = ['.png', '.jpg', '.jpeg', '.JPG', '.mp3', '.mp4']
  1113. const imgTypeArr = ['.png', '.jpg', '.jpeg', '.JPG']
  1114. const canEditArr = ['.doc', '.docm', '.docx', '.dot', '.dotm', '.dotx', '.txt', '.djvu', '.xps', 'csv', 'fods', 'ods', 'ots', 'xls', 'xlsm', 'xlsx', 'xlt', 'xltm', 'xltx', 'fodp', 'odp', 'otp']
  1115. let arr = []
  1116. if (!(typeArr.includes(copyFileType.value) || canPreviewArray.includes(copyFileType.value))) {
  1117. arr = mouseCli.value.filter(item => item.name !== "预览")
  1118. } else {
  1119. arr = toRaw(mouseCli.value)
  1120. }
  1121. if (!canEditArr.includes(copyFileType.value)) {
  1122. arr = arr.filter(item => item.name !== "在线编辑" && item.name !== "协作" && item.name !== "历史版本")
  1123. }
  1124. if (!imgTypeArr.includes(copyFileType.value)) {
  1125. arr = arr.filter(item => item.name !== "文字识别")
  1126. }
  1127. return arr
  1128. }
  1129. function mouseClick() {
  1130. if (cliCC.value) {
  1131. cliCC.value = false
  1132. }
  1133. if (anyP) {
  1134. anyP.value = false
  1135. }
  1136. }
  1137. // 文件夹右键事件
  1138. const folderRClick = (row, col, e) => {
  1139. e.preventDefault();
  1140. e.stopPropagation();
  1141. // thisFolder.value = '' //先清空
  1142. let thisRow = toRaw(row)
  1143. // console.log('thisFolder',thisFolder.value);
  1144. clickRow.value = thisRow
  1145. copyFolderName.value = row.dirName
  1146. // 唤出右键菜单,思路:获取鼠标位置来定位菜单
  1147. folderVisible.value = true;
  1148. foldertop.value = e.pageY;
  1149. folderleft.value = e.pageX;
  1150. };
  1151. // 关闭文件夹右键菜单
  1152. const closeRMenu = () => {
  1153. // console.log("close");
  1154. folderVisible.value = false;
  1155. };
  1156. // 文件夹收藏事件
  1157. const collectFolder = () => {
  1158. isFolder.value = 'Y'
  1159. // clickRow.value = thisFolder.value
  1160. // thisFolder.value = ''
  1161. copyFileName.value = clickRow.value.dirName
  1162. collects.value = true
  1163. }
  1164. // 左箭头事件
  1165. const arrowLift = () => {
  1166. // router.go(-1)
  1167. }
  1168. // 归档
  1169. function goLock() {
  1170. fileCount.lockActor(clickRowId.value).then(res => {
  1171. if (res.code === 200) {
  1172. ElMessage({
  1173. type: "success",
  1174. message: "归档成功"
  1175. })
  1176. cliCC.value = false
  1177. anyP.value = false
  1178. }
  1179. })
  1180. }
  1181. function formatFileSize(fileSize) {
  1182. if (fileSize >= 1024 * 1024 * 1024) {
  1183. // 大于等于1GB,显示GB
  1184. return (fileSize / (1024 * 1024 * 1024)).toFixed(2) + 'GB';
  1185. } else if (fileSize >= 1024 * 1024) {
  1186. // 大于等于1MB,显示MB
  1187. return (fileSize / (1024 * 1024)).toFixed(2) + 'MB';
  1188. } else if (fileSize >= 1024) {
  1189. // 大于等于1KB,显示KB
  1190. return (fileSize / 1024).toFixed(2) + 'KB';
  1191. } else {
  1192. // 小于1KB,显示字节
  1193. return fileSize + 'B';
  1194. }
  1195. }
  1196. function formatStorage(sizeInGB) {
  1197. if (sizeInGB >= 1) {
  1198. return sizeInGB.toFixed(2) + 'GB';
  1199. } else {
  1200. const sizeInMB = sizeInGB * 1024;
  1201. if (sizeInMB >= 1) {
  1202. return sizeInMB.toFixed(2) + 'MB';
  1203. } else {
  1204. const sizeInKB = sizeInMB * 1024;
  1205. return sizeInKB.toFixed(2) + 'KB';
  1206. }
  1207. }
  1208. }
  1209. function gridChange() {
  1210. if (fileGrid.value) {
  1211. fileGrid.value = false
  1212. } else {
  1213. fileGrid.value = true
  1214. }
  1215. if (folderGrid.value) {
  1216. folderGrid.value = false
  1217. } else {
  1218. folderGrid.value = true
  1219. }
  1220. }
  1221. //点击收藏后刷新文件
  1222. const refreshFile = ()=>{
  1223. // console.log('ref',toRaw(thisFolder.value));
  1224. if(toRaw(thisFolder.value).isFavorite){//如果点开了文件夹
  1225. console.log(111);
  1226. folderClick()
  1227. }else{
  1228. console.log(222);
  1229. getAllTop()
  1230. }
  1231. }
  1232. // 取消文件收藏
  1233. const delCollect = async (row,isfolder)=>{
  1234. const thisRow = toRaw(row)
  1235. console.log('thisRow',thisRow);
  1236. let query = {}
  1237. if(isfolder){
  1238. query = {
  1239. isFolder:"Y",
  1240. relaId:thisRow.dirId
  1241. }
  1242. }else{
  1243. query = {
  1244. isFolder:"N",
  1245. relaId:thisRow.docId
  1246. }
  1247. }
  1248. const res = await delFavorite(query)
  1249. //TODO 之后需要重新获取数据 并message提示
  1250. console.log('res',res);
  1251. refreshFile()
  1252. }
  1253. onMounted(() => {
  1254. getAllTop()
  1255. getSpaceList()
  1256. // 添加监听,点击其他地方关闭文件夹右键菜单
  1257. window.addEventListener("click", closeRMenu, true);
  1258. window.addEventListener("click", mouseClick, true);
  1259. })
  1260. return {
  1261. getSpaceList,
  1262. folderList,//文件夹的数据
  1263. fileList,//文件夹的数据
  1264. searchFire,//搜索文件的model
  1265. changeFile,//切换右侧视图的file
  1266. menuList,//右侧切换
  1267. tableChange,//改变class点击事件
  1268. selectedIndex,//当前选中下标
  1269. shotdown,//筛选出当前数据
  1270. useMenu,
  1271. arrorMenu,
  1272. blueLeft,//返回
  1273. grayRight,//前进
  1274. squre,//视图切换
  1275. sort,//排序
  1276. folder,
  1277. files,
  1278. handleRowClick,
  1279. askApply,//申请扩容
  1280. cliCC,
  1281. mouseCli,//文件点击弹框
  1282. chooseSet,
  1283. trandata,
  1284. tranvalue,
  1285. anyP,
  1286. chooseSet1,
  1287. fileMenu,
  1288. createNewMenu,
  1289. // delBoser,
  1290. clickRowId,
  1291. createNewFile,
  1292. // fileUpload,
  1293. getImage,//筛选文件类型
  1294. handleSelectionChange,
  1295. handleSelectionChange1,
  1296. selectedBox,//重命名相关
  1297. restName,//重命名相关
  1298. getMenu,
  1299. folderId,
  1300. fileId,
  1301. // getAllMiddle,//拿到所有空间信息
  1302. delName,//删除空间信息
  1303. useSpace,//使用空间
  1304. allSpace,//总空间
  1305. percent,
  1306. arrowClick,
  1307. uploadModal,
  1308. sureUpload,
  1309. onSuccess,
  1310. fileArr,
  1311. directoryId,
  1312. folderClick,
  1313. copyDirId,//复制移动需要的↓
  1314. copyDocId,
  1315. copySpaceId,
  1316. copyFileId,
  1317. copyFileName,
  1318. copyFileSize,
  1319. copyFileType,
  1320. sureChangeName,//文件重命名
  1321. fileNameChange,//文件重命名模态框
  1322. nameForm,
  1323. collectImg,//收藏小星星
  1324. sortNum,
  1325. needBag,
  1326. isId,
  1327. editOnline,//在线编辑
  1328. copyParentId,
  1329. copyRow,
  1330. getAllTop,
  1331. newDirId,
  1332. newSpaceId,
  1333. showPreview,//控制图片预览
  1334. closeImgPreview,//关闭预览事件
  1335. previewData,//预览文件数据
  1336. router,
  1337. fileTrees,
  1338. getChildren,//子传父
  1339. copyOrMove,
  1340. impDirId,
  1341. impNum,
  1342. impSpaceId,
  1343. //历史版本=========
  1344. openForwardFile,
  1345. forwardTreeData,
  1346. fileUserTreeData,
  1347. filterMouseCli,
  1348. changeMsgClose,
  1349. historyPrew,
  1350. historycopyRow,
  1351. thanks,
  1352. getCback,
  1353. mouseClick,
  1354. folderVisible,
  1355. foldertop,
  1356. folderleft,
  1357. thisFolder,
  1358. folderRClick,
  1359. closeRMenu,
  1360. cancleHistoryPrew,
  1361. historyTotal,
  1362. //历史版本=========
  1363. fileUserTreeData,
  1364. thanks,
  1365. getCback,
  1366. mouseClick,
  1367. workOrEdit,
  1368. folderCase,//新建文件夹传值
  1369. getChildrenC,
  1370. oneOrTwo,//父传子判断
  1371. folderCheckout,
  1372. fileCheckout,
  1373. haveCheck,
  1374. onlyView,
  1375. goLock,
  1376. collects,//收藏父传子
  1377. getCollects,//收藏子传父
  1378. folderTotal,
  1379. fileTotal,
  1380. delMoreFile,//删除多个文件夹
  1381. topPath,
  1382. xz,//文件右键菜单left
  1383. yz,//文件右键菜单top
  1384. formatFileSize,
  1385. isFolder,
  1386. clickRow,
  1387. rename,
  1388. getRename,//文件夹重命名子传父
  1389. copyFolderName,
  1390. spaces,//空间扩容父传子
  1391. getSpaceC,//空间扩容子传父
  1392. copySpaceCup,
  1393. fileGrid,
  1394. folderGrid,
  1395. gridChange,
  1396. collectFolder,
  1397. arrowLift,
  1398. formatStorage,
  1399. showFile,
  1400. navBack,
  1401. onlineCase,
  1402. lastBB,
  1403. shareBack,
  1404. folderBack,
  1405. refreshFile,
  1406. delCollect
  1407. }
  1408. },
  1409. watch: {
  1410. },
  1411. components: {
  1412. BreadMenu,
  1413. FileEdit,
  1414. ImgPreview,
  1415. FileTree,
  1416. historyList,
  1417. TransferModal,
  1418. CreateFloder,
  1419. FileCollect,
  1420. FolderReName,
  1421. SpaceBig,
  1422. PlaceGridFolder,
  1423. PalaceGridFile,
  1424. },
  1425. }
  1426. </script>
  1427. <style lang="scss" scoped>
  1428. p {
  1429. margin: 0;
  1430. padding: 0;
  1431. }
  1432. .bigBox {
  1433. width: 100%;
  1434. height: 100%;
  1435. display: flex;
  1436. justify-content: flex-start;
  1437. overflow: hidden;
  1438. }
  1439. .settingBox {
  1440. width: 25vw;
  1441. height: 92vh;
  1442. border: 1px solid black;
  1443. border-radius: 4px;
  1444. /* margin: 5px 5px; */
  1445. margin-right: 5px;
  1446. background-color: white;
  1447. }
  1448. .topSearch {
  1449. width: 100%;
  1450. height: 48px;
  1451. background-color: #EBEFF6;
  1452. display: flex;
  1453. justify-content: space-around;
  1454. align-items: center;
  1455. }
  1456. .searchFire {
  1457. width: 248px;
  1458. height: 32px;
  1459. }
  1460. .setBox {
  1461. width: 88px;
  1462. height: 112px;
  1463. text-align: center;
  1464. margin-left: 5px;
  1465. margin-top: 5px;
  1466. position: relative;
  1467. }
  1468. .setBox:hover {
  1469. background-color: #EEF9FF;
  1470. }
  1471. .setBox:hover .selectChe {
  1472. background-color: #EEF9FF;
  1473. display: block;
  1474. }
  1475. .selectChe {
  1476. display: none;
  1477. width: 20px;
  1478. height: 20px;
  1479. background: rgba(255, 255, 255, 0.7);
  1480. border-radius: 4px 4px 4px 4px;
  1481. position: absolute;
  1482. top: 2px;
  1483. right: 2px;
  1484. line-height: 10px;
  1485. }
  1486. .mesBox {
  1487. width: 75vw;
  1488. height: 92vh;
  1489. border-radius: 4px;
  1490. background-color: white;
  1491. }
  1492. .useBox {
  1493. width: 100%;
  1494. height: 24px;
  1495. }
  1496. .tables {
  1497. display: inline-block;
  1498. width: 112px;
  1499. height: 22px;
  1500. border-radius: 4px;
  1501. line-height: 21px;
  1502. text-align: center;
  1503. font-size: 12px;
  1504. margin-left: 5px;
  1505. position: relative;
  1506. white-space: nowrap;
  1507. overflow: hidden;
  1508. text-overflow: ellipsis;
  1509. }
  1510. .tableLis {
  1511. display: inline-block;
  1512. width: 112px;
  1513. height: 22px;
  1514. border-radius: 4px;
  1515. background-color: #EBEFF6;
  1516. line-height: 21px;
  1517. text-align: center;
  1518. font-size: 12px;
  1519. margin-left: 5px;
  1520. position: relative;
  1521. white-space: nowrap;
  1522. overflow: hidden;
  1523. text-overflow: ellipsis;
  1524. max-width: auto;
  1525. }
  1526. .manyUse {
  1527. width: 100%;
  1528. height: 48px;
  1529. /* background-color: gray; */
  1530. line-height: 48px;
  1531. display: flex;
  1532. justify-content: flex-start;
  1533. align-items: center;
  1534. }
  1535. .el-dropdown-link {
  1536. color: white;
  1537. }
  1538. .breadBox {
  1539. width: 100%;
  1540. height: 24px;
  1541. display: flex;
  1542. justify-content: space-between;
  1543. align-items: center;
  1544. background-color: #F6F7F9;
  1545. .topPath {
  1546. color: #6F85B5;
  1547. font-size: 12px;
  1548. }
  1549. }
  1550. :deep(.el-collapse-item__header) {
  1551. height: 24px !important;
  1552. background-color: #EBEFF6 !important;
  1553. }
  1554. .detailBox {
  1555. width: 100%;
  1556. height: 270px;
  1557. }
  1558. :deep(.el-dialog__header) {
  1559. background-color: #ECEFF7;
  1560. margin-right: 0px;
  1561. }
  1562. .fileTable {
  1563. height: 100%;
  1564. overflow-y: hidden;
  1565. margin-top: 55px;
  1566. }
  1567. .setCli {
  1568. width: 156px;
  1569. max-height: auto;
  1570. position: absolute;
  1571. top: -70px;
  1572. left: 300px;
  1573. flex-wrap: 400;
  1574. background-color: white;
  1575. border: 1px solid gray;
  1576. border-radius: 4px;
  1577. z-index: 3;
  1578. overflow-y: auto;
  1579. // font-size: 16px;
  1580. }
  1581. .setCli1 {
  1582. width: 156px;
  1583. height: auto;
  1584. position: absolute;
  1585. background-color: white;
  1586. border: 1px solid gray;
  1587. border-radius: 4px;
  1588. z-index: 2;
  1589. overflow-y: auto;
  1590. }
  1591. .chooseSet {
  1592. width: 140px;
  1593. height: 30px;
  1594. line-height: 30px;
  1595. margin: 5px auto;
  1596. font-size: 13px;
  1597. // display: flex;
  1598. // align-items: center;
  1599. // position: relative;
  1600. img {
  1601. margin-right: 4px;
  1602. vertical-align: middle;
  1603. }
  1604. }
  1605. .chooseSet:hover {
  1606. width: 140px;
  1607. height: 30px;
  1608. line-height: 30px;
  1609. margin: 5px auto;
  1610. font-size: 13px;
  1611. background-color: #F5F7F9;
  1612. /* color: white; */
  1613. }
  1614. :deep([data-v-69cdaa40] .el-collapse-item__header) {
  1615. padding-left: 10px;
  1616. }
  1617. :deep(.el-collapse-item__content) {
  1618. // height: 235px;
  1619. overflow-y: auto;
  1620. }
  1621. .ellipsis-text {
  1622. white-space: nowrap;
  1623. overflow: hidden;
  1624. text-overflow: ellipsis;
  1625. max-width: auto;
  1626. }
  1627. .right_menu {
  1628. width: 156px;
  1629. position: absolute;
  1630. padding: 8px;
  1631. box-shadow: 0px 2px 10px 1px rgba(199, 203, 216);
  1632. border-radius: 4px 4px 4px 4px;
  1633. border: 1px solid gray;
  1634. background-color: #fff;
  1635. z-index: 10000;
  1636. .menu_item {
  1637. width: 100%;
  1638. height: 30px;
  1639. border-radius: 4px 4px 4px 4px;
  1640. line-height: 30px;
  1641. display: flex;
  1642. margin: 5px auto;
  1643. align-items: center;
  1644. font-size: 13px;
  1645. &:hover {
  1646. background-color: #f5f7f9;
  1647. }
  1648. span {
  1649. margin-left: 4px;
  1650. }
  1651. }
  1652. }
  1653. .isCheck {
  1654. opacity: 1 !important;
  1655. }
  1656. :deep(.el-tag__content) {
  1657. display: block;
  1658. }
  1659. :deep(.el-icon el-tag__close) {
  1660. display: block;
  1661. }
  1662. :deep(.el-collapse-item__content) {
  1663. height: 100%;
  1664. border-bottom: none;
  1665. }
  1666. :deep(.el-collapse-item__wrap) {
  1667. height: 300px;
  1668. }
  1669. // 隐藏全选按钮
  1670. .file-jia {
  1671. :deep(.el-table th.el-table__cell:nth-child(1) .cell) {
  1672. visibility: hidden;
  1673. }
  1674. }
  1675. </style>