PalaceGridFile.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534
  1. <template>
  2. <div>
  3. <!-- flex盒子 -->
  4. <div class="bigBox">
  5. <template v-for="(item, index) in fileList">
  6. <!-- 循环盒子 -->
  7. <div class="flexBox" @contextmenu="rightClick(item, $event)">
  8. <!-- 图片 -->
  9. <div class="imgBox">
  10. <img :src="getImage(item.fileType)" alt="" style="vertical-align: middle;">
  11. </div>
  12. <!-- 名称 -->
  13. <div class="nameBox">
  14. <p class="nameName">{{ item.fileName }}</p>
  15. </div>
  16. </div>
  17. </template>
  18. <div class="setCli" v-if="cliCC" :style="{ left: xz + 'px', top: (yz - 330) + 'px' }">
  19. <template v-for="(item, index) in filterMouseCli()">
  20. <p @click="chooseSet(item, index, 1)" class="chooseSet">
  21. <img :src="item.img" alt="">
  22. {{ item.name }}
  23. <span v-if="item.name == '在线编辑' || item.name == '协作' ? true : false"
  24. style="color: #7084B4;float: right;position: relative;" class="arrow">></span>
  25. </p>
  26. </template>
  27. </div>
  28. <div class="setCli1" v-if="anyP">
  29. <p @click="chooseSet1(0)" class="chooseSet">
  30. <img src="../../../assets/images/user.png" alt="">
  31. 选择人员
  32. </p>
  33. <p class="chooseSet" @click="goLock">
  34. <img src="../../../assets/images/archiveTray.png" alt="">
  35. 归档
  36. </p>
  37. </div>
  38. <div>
  39. <TransferModal v-if="thanks" :thanks="thanks" :clickRowId="clickRowId" :workOrEdit="workOrEdit"
  40. @getCback="getCback"></TransferModal>
  41. </div>
  42. <!-- 复制粘贴 -->
  43. <div>
  44. <FileTree v-if="fileTrees" :fileTrees="fileTrees" :newSpaceId="newSpaceId" :fileId="clickRowId"
  45. @getChildren="getChildren" :copyOrMove="copyOrMove"></FileTree>
  46. </div>
  47. <div>
  48. <ImgPreview :previewData="previewData" :copyFileType="copyFileType" :showPreview="showPreview"
  49. @closeImgPreview="closeImgPreview"></ImgPreview>
  50. </div>
  51. <!-- <div>
  52. <FileEdit v-if="editOnline" :docId="clickRowId" :copyRow="copyRow" :historyPrew="historyPrew" :historycopyRow="historycopyRow"
  53. :onlyView="onlyView" @cancleHistoryPrew="cancleHistoryPrew"></FileEdit>
  54. </div> -->
  55. </div>
  56. </div>
  57. </template>
  58. <script>
  59. import { ref, onMounted } from "vue"
  60. import { ElMessage } from "element-plus";
  61. import myfile from "../../../api/myfile/myfile";
  62. import documents from "../../../api/document/document";
  63. import TransferModal from '../modalComponebts/Transfer.vue'
  64. import ImgPreview from '@/components/ImgPreview/ImgPreview.vue'
  65. import FileEdit from './FileEdit.vue'
  66. import FileTree from './FileTree.vue'
  67. import ImgFile from "../jsComponents/ImgFile";
  68. import { canPreviewFile } from "@/utils/index.js"
  69. import { preview } from "@/api/common/common.js";
  70. import { listVersion } from "@/api/biz/version";
  71. export default {
  72. setup(props, { emit }) {
  73. let impDirId = ref(0)
  74. let impSpaceId = ref(0)
  75. let newSpaceId = ref(0)
  76. let newDirId = ref(0)
  77. let topPath = ref("")
  78. let fileList = ref([])
  79. let folderList = ref([])
  80. let fileTotal = ref(0)
  81. let fileMenu = ref([])
  82. let isFolder = ref("")
  83. let clickRow = ref({})
  84. let copyRow = ref("")
  85. let clickRowId = ref("")
  86. let copyDirId = ref("")
  87. let copySpaceId = ref("")
  88. let copyFileId = ref("")
  89. let copyFileSize = ref("")
  90. let copyFileType = ref("")
  91. let workOrEdit = ref(0)
  92. let copyOrMove = ref(0)
  93. let nameForm = ref({
  94. name: ""
  95. })
  96. const historycopyRow = ref({})
  97. let copyFileName = ref("")
  98. let yz = ref(0)
  99. let xz = ref(0)
  100. let cliCC = ref(false)
  101. let anyP = ref(false)
  102. let thanks = ref(false)
  103. let fileTrees = ref(false)
  104. let onlyView = ref(false)
  105. let editOnline = ref(false)
  106. let showPreview = ref(false)
  107. let historyPrew = ref(false)
  108. let historyTotal = ref(0)
  109. const fileUserTreeData = reactive({ data: {} });
  110. let previewData = ref()
  111. let mouseCli = ref([
  112. {
  113. img: ImgFile.previewIcon,
  114. name: "预览"
  115. },
  116. {
  117. img: ImgFile.addolder,
  118. name: "移动到...",
  119. },
  120. {
  121. img: ImgFile.copy,
  122. name: "复制到...",
  123. },
  124. {
  125. img: ImgFile.collect,
  126. name: "收藏"
  127. },
  128. {
  129. img: ImgFile.downLoad,
  130. name: "下载"
  131. },
  132. {
  133. img: ImgFile.textbox,
  134. name: "重命名"
  135. },
  136. {
  137. img: ImgFile.share,
  138. name: "分享"
  139. },
  140. {
  141. img: ImgFile.notePencil,
  142. name: "在线编辑"
  143. },
  144. {
  145. img: ImgFile.togger,
  146. name: "协作"
  147. },
  148. {
  149. img: ImgFile.icc,
  150. name: "文字识别"
  151. },
  152. {
  153. img: ImgFile.history,
  154. name: "历史版本"
  155. },
  156. {
  157. img: ImgFile.trash,
  158. name: "删除"
  159. }
  160. ])
  161. // 获取文件夹,中栏,文件
  162. function getAllTop() {
  163. documents.getTop(3).then(res => {
  164. let userMe = [res]
  165. impDirId.value = userMe[0].dirId//固定
  166. impSpaceId.value = userMe[0].spaceId//固定
  167. newSpaceId.value = userMe[0].spaceId//变化
  168. newDirId.value = userMe[0].dirId//变化
  169. topPath.value = userMe[0].dirPath
  170. let obj = {
  171. pageNum: 1,
  172. pageSize: 10
  173. }
  174. documents.getALLdocument({ parentId: userMe[0].dirId - 0, spaceId: userMe[0].spaceId, pageNum: obj.pageNum, pageSize: obj.pageSize }).then(res => {
  175. fileMenu.value = res.data
  176. folderList.value = res.data
  177. })
  178. myfile.getById(userMe[0].dirId - 0, obj).then(res => {
  179. if (res.code === 200) {
  180. fileList.value = res.rows
  181. fileTotal.value = res.total
  182. if (fileTotal.value / 10 != 1) {
  183. let x = Math.trunc(fileTotal.value / 10) + 1
  184. for (var i = 1; i <= x; i++) {
  185. obj.pageNum = i
  186. myfile.getById(userMe[0].dirId - 0, obj).then(res => {
  187. fileList.value = fileList.value.concat(res.rows)
  188. const uniqueFileList = Array.from(new Set(fileList.value.map(item => item.docId)))
  189. .map(docId => fileList.value.find(item => item.docId === docId));
  190. // 合并数组并更新 fileList.value
  191. fileList.value = uniqueFileList
  192. console.log(fileList.value, 'iiii');
  193. })
  194. }
  195. }
  196. }
  197. })
  198. })
  199. }
  200. // 筛选后缀图片
  201. function getImage(file) {
  202. if (file === '.txt') {
  203. return ImgFile.bigTxt
  204. } else if (file === '.xlxs' || file === '.docx' || file === '.xls') {
  205. return ImgFile.bigxlsx
  206. } else if (file === '.pptx') {
  207. return ImgFile.bigpptx
  208. } else if (file === '.word') {
  209. return ImgFile.bigdoc
  210. } else if (file === '.pdf') {
  211. return ImgFile.bigpdf
  212. } else if (file === ".mp3") {
  213. return ImgFile.audio
  214. } else if (file === '.mp4') {
  215. return ImgFile.video
  216. } else if (file === ".png" || file === ".jpg") {
  217. return ImgFile.pic
  218. } else {
  219. return ImgFile.elseFile
  220. }
  221. }
  222. function rightClick(row, event) {
  223. event.preventDefault()
  224. isFolder.value = "N"
  225. clickRow.value = row
  226. xz.value = event.pageX
  227. yz.value = event.pageY
  228. copyRow.value = row
  229. clickRowId.value = row.docId
  230. copyDirId.value = row.dirId
  231. copySpaceId.value = row.spaceId
  232. copyFileId.value = row.fileId
  233. copyFileSize.value = row.fileSize
  234. copyFileType.value = row.fileType
  235. nameForm.value.name = row.fileName
  236. copyFileName.value = row.fileName
  237. if (cliCC.value === true) {
  238. cliCC.value = false
  239. } else {
  240. cliCC.value = true
  241. }
  242. }
  243. //对mouseCli数组进行筛选,实现菜单的区分显示
  244. const filterMouseCli = () => {
  245. 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']
  246. const typeArr = ['.png', '.jpg', '.jpeg', '.JPG', '.mp3', '.mp4']
  247. const imgTypeArr = ['.png', '.jpg', '.jpeg', '.JPG']
  248. const canEditArr = ['.doc', '.docm', '.docx', '.dot', '.dotm', '.dotx', '.txt', '.djvu', '.xps', 'csv', 'fods', 'ods', 'ots', 'xls', 'xlsm', 'xlsx', 'xlt', 'xltm', 'xltx', 'fodp', 'odp', 'otp']
  249. let arr = []
  250. if (!(typeArr.includes(copyFileType.value) || canPreviewArray.includes(copyFileType.value))) {
  251. arr = mouseCli.value.filter(item => item.name !== "预览")
  252. } else {
  253. arr = toRaw(mouseCli.value)
  254. }
  255. if (!canEditArr.includes(copyFileType.value)) {
  256. arr = arr.filter(item => item.name !== "在线编辑" && item.name !== "协作" && item.name !== "历史版本")
  257. }
  258. if (!imgTypeArr.includes(copyFileType.value)) {
  259. arr = arr.filter(item => item.name !== "文字识别")
  260. }
  261. return arr
  262. }
  263. function mouseClick() {
  264. if (cliCC.value) {
  265. cliCC.value = false
  266. }
  267. if (anyP) {
  268. anyP.value = false
  269. }
  270. }
  271. async function chooseSet(row, index, num) {
  272. if (row.name == '在线编辑' || row.name == '协作') {
  273. cliCC.value = true
  274. } else {
  275. cliCC.value = false
  276. }
  277. if (row.name == '分享') {
  278. workOrEdit.value = num
  279. thanks.value = true
  280. } else {
  281. thanks.value = false
  282. }
  283. if (row.name == '协作') {
  284. if (anyP.value) {
  285. anyP.value = false
  286. } else {
  287. anyP.value = true
  288. }
  289. } else {
  290. anyP.value = false
  291. }
  292. if (row.name == '删除') {
  293. myfile.delMenu(clickRowId.value).then(res => {
  294. if (res.code === 200) {
  295. ElMessage({
  296. type: "success",
  297. message: "删除成功"
  298. })
  299. getAllTop()
  300. }
  301. })
  302. }
  303. if (row.name === '复制到...') {
  304. copyOrMove.value = 0
  305. fileTrees.value = true
  306. }
  307. if (row.name === '移动到...') {
  308. copyOrMove.value = 1
  309. fileTrees.value = true
  310. }
  311. if (row.name === '重命名') {
  312. fileNameChange.value = true
  313. }
  314. if (row.name === "下载") {
  315. location.href = `${import.meta.env.VITE_APP_BASE_API}/api/download/${copyFileId.value}`;
  316. }
  317. if (row.name === '收藏') {
  318. collects.value = true
  319. }
  320. if (row.name === '在线编辑') {
  321. editOnline.value = false
  322. cliCC.value = false
  323. }
  324. if (row.name === '文字识别') {
  325. router.push({
  326. path: '/identifyFont',
  327. query: {
  328. fileId: copyFileId.value,
  329. fileType: copyFileType.value
  330. }
  331. })
  332. }
  333. if (row.name === '预览') {
  334. // editOnline.value = true
  335. // emit("showFile", false)
  336. const filePreview = canPreviewFile(copyFileType.value)
  337. if (filePreview) {
  338. onlyView.value = true
  339. emit("showFile", false, clickRowId.value, copyRow.value)
  340. cliCC.value = false
  341. } else {
  342. showPreview.value = true
  343. const res = await preview(copyFileId.value)
  344. previewData.value = URL.createObjectURL(res)
  345. console.log(888);
  346. }
  347. showPreview.value = true
  348. const res = await preview(copyFileId.value)
  349. previewData.value = URL.createObjectURL(res)
  350. } else if (row.name === "历史版本") {
  351. const resHistory = await listVersion({ docId: clickRowId.value })
  352. historyTotal.value = resHistory.total
  353. fileUserTreeData.data = resHistory.rows;
  354. openForwardFile.value = true
  355. }
  356. }
  357. function changeMsgClose(val, item) {
  358. if (val) {
  359. historycopyRow.value = item
  360. editOnline.value = false
  361. cliCC.value = false
  362. historyPrew.value = true
  363. }
  364. openForwardFile.value = val
  365. }
  366. function chooseSet1(num) {
  367. workOrEdit.value = num
  368. thanks.value = true
  369. anyP.value = false
  370. }
  371. function getChildren(data) {
  372. fileTrees.value = data
  373. }
  374. function getCback(data) {
  375. thanks.value = data
  376. }
  377. function closeImgPreview(data) {
  378. showPreview.value = data
  379. }
  380. function cancleHistoryPrew(data) {
  381. historyPrew.value = false
  382. }
  383. onMounted(() => {
  384. getAllTop()
  385. window.addEventListener("click", mouseClick);
  386. })
  387. return {
  388. getAllTop,
  389. impDirId,
  390. impSpaceId,
  391. newDirId,
  392. newSpaceId,
  393. fileList,
  394. fileMenu,
  395. folderList,
  396. fileTotal,
  397. getImage,
  398. rightClick,
  399. filterMouseCli,
  400. copyRow,
  401. clickRow,
  402. clickRowId,
  403. copyDirId,
  404. copySpaceId,
  405. copyFileId,
  406. copyFileSize,
  407. copyFileType,
  408. nameForm,
  409. copyFileName,
  410. cliCC,
  411. mouseClick,
  412. anyP,
  413. xz,
  414. yz,
  415. chooseSet,
  416. chooseSet1,
  417. thanks,
  418. FileTree,
  419. fileTrees,
  420. getCback,
  421. getChildren,
  422. copyOrMove,
  423. onlyView,
  424. editOnline,
  425. showPreview,
  426. ImgPreview,
  427. previewData,
  428. closeImgPreview,
  429. FileEdit,
  430. cancleHistoryPrew,
  431. historycopyRow,
  432. changeMsgClose,
  433. historyPrew,
  434. }
  435. },
  436. components: {
  437. TransferModal,
  438. FileTree,
  439. ImgPreview,
  440. FileEdit
  441. }
  442. }
  443. </script>
  444. <style scoped>
  445. .bigBox {
  446. width: 100%;
  447. height: 100%;
  448. display: flex;
  449. justify-content: flex-start;
  450. align-items: center;
  451. flex-wrap: wrap;
  452. }
  453. .imgBox {
  454. width: 88px;
  455. height: 88px;
  456. text-align: center;
  457. line-height: 88px;
  458. }
  459. .flexBox {
  460. width: 104px;
  461. height: 148px;
  462. position: relative;
  463. }
  464. .nameName {
  465. width: 100%;
  466. white-space: nowrap;
  467. /* 禁止文本换行 */
  468. overflow: hidden;
  469. /* 隐藏溢出部分文本 */
  470. text-overflow: ellipsis;
  471. /* 显示省略号 */
  472. }
  473. .setCli {
  474. width: 156px;
  475. max-height: auto;
  476. position: absolute;
  477. flex-wrap: 400;
  478. background-color: white;
  479. border: 1px solid gray;
  480. border-radius: 4px;
  481. z-index: 3;
  482. overflow-y: auto;
  483. /* // font-size: 16px; */
  484. }
  485. .setCli1 {
  486. width: 156px;
  487. height: auto;
  488. position: absolute;
  489. top: 185px;
  490. left: 455px;
  491. background-color: white;
  492. border: 1px solid gray;
  493. border-radius: 4px;
  494. z-index: 2;
  495. overflow-y: auto;
  496. }
  497. .chooseSet {
  498. width: 140px;
  499. height: 30px;
  500. line-height: 30px;
  501. margin: 5px auto;
  502. font-size: 13px;
  503. /*
  504. display: flex;
  505. align-items: center;
  506. position: relative; */
  507. }
  508. .chooseSet img {
  509. margin-right: 4px;
  510. vertical-align: middle;
  511. }
  512. .chooseSet:hover {
  513. width: 140px;
  514. height: 30px;
  515. line-height: 30px;
  516. margin: 5px auto;
  517. font-size: 13px;
  518. background-color: #F5F7F9;
  519. /* color: white; */
  520. }
  521. </style>