123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534 |
- <template>
- <div>
- <!-- flex盒子 -->
- <div class="bigBox">
- <template v-for="(item, index) in fileList">
- <!-- 循环盒子 -->
- <div class="flexBox" @contextmenu="rightClick(item, $event)">
- <!-- 图片 -->
- <div class="imgBox">
- <img :src="getImage(item.fileType)" alt="" style="vertical-align: middle;">
- </div>
- <!-- 名称 -->
- <div class="nameBox">
- <p class="nameName">{{ item.fileName }}</p>
- </div>
- </div>
- </template>
- <div class="setCli" v-if="cliCC" :style="{ left: xz + 'px', top: (yz - 330) + 'px' }">
- <template v-for="(item, index) in filterMouseCli()">
- <p @click="chooseSet(item, index, 1)" class="chooseSet">
- <img :src="item.img" alt="">
- {{ item.name }}
- <span v-if="item.name == '在线编辑' || item.name == '协作' ? true : false"
- style="color: #7084B4;float: right;position: relative;" class="arrow">></span>
- </p>
- </template>
- </div>
- <div class="setCli1" v-if="anyP">
- <p @click="chooseSet1(0)" class="chooseSet">
- <img src="../../../assets/images/user.png" alt="">
- 选择人员
- </p>
- <p class="chooseSet" @click="goLock">
- <img src="../../../assets/images/archiveTray.png" alt="">
- 归档
- </p>
- </div>
- <div>
- <TransferModal v-if="thanks" :thanks="thanks" :clickRowId="clickRowId" :workOrEdit="workOrEdit"
- @getCback="getCback"></TransferModal>
- </div>
- <!-- 复制粘贴 -->
- <div>
- <FileTree v-if="fileTrees" :fileTrees="fileTrees" :newSpaceId="newSpaceId" :fileId="clickRowId"
- @getChildren="getChildren" :copyOrMove="copyOrMove"></FileTree>
- </div>
- <div>
- <ImgPreview :previewData="previewData" :copyFileType="copyFileType" :showPreview="showPreview"
- @closeImgPreview="closeImgPreview"></ImgPreview>
- </div>
- <!-- <div>
- <FileEdit v-if="editOnline" :docId="clickRowId" :copyRow="copyRow" :historyPrew="historyPrew" :historycopyRow="historycopyRow"
- :onlyView="onlyView" @cancleHistoryPrew="cancleHistoryPrew"></FileEdit>
- </div> -->
- </div>
- </div>
- </template>
- <script>
- import { ref, onMounted } from "vue"
- import { ElMessage } from "element-plus";
- import myfile from "../../../api/myfile/myfile";
- import documents from "../../../api/document/document";
- import TransferModal from '../modalComponebts/Transfer.vue'
- import ImgPreview from '@/components/ImgPreview/ImgPreview.vue'
- import FileEdit from './FileEdit.vue'
- import FileTree from './FileTree.vue'
- import ImgFile from "../jsComponents/ImgFile";
- import { canPreviewFile } from "@/utils/index.js"
- import { preview } from "@/api/common/common.js";
- import { listVersion } from "@/api/biz/version";
- export default {
- setup(props, { emit }) {
- let impDirId = ref(0)
- let impSpaceId = ref(0)
- let newSpaceId = ref(0)
- let newDirId = ref(0)
- let topPath = ref("")
- let fileList = ref([])
- let folderList = ref([])
- let fileTotal = ref(0)
- let fileMenu = ref([])
- let isFolder = ref("")
- let clickRow = ref({})
- let copyRow = ref("")
- let clickRowId = ref("")
- let copyDirId = ref("")
- let copySpaceId = ref("")
- let copyFileId = ref("")
- let copyFileSize = ref("")
- let copyFileType = ref("")
- let workOrEdit = ref(0)
- let copyOrMove = ref(0)
- let nameForm = ref({
- name: ""
- })
- const historycopyRow = ref({})
- let copyFileName = ref("")
- let yz = ref(0)
- let xz = ref(0)
- let cliCC = ref(false)
- let anyP = ref(false)
- let thanks = ref(false)
- let fileTrees = ref(false)
- let onlyView = ref(false)
- let editOnline = ref(false)
- let showPreview = ref(false)
- let historyPrew = ref(false)
- let historyTotal = ref(0)
- const fileUserTreeData = reactive({ data: {} });
- let previewData = ref()
- let mouseCli = ref([
- {
- img: ImgFile.previewIcon,
- name: "预览"
- },
- {
- img: ImgFile.addolder,
- name: "移动到...",
- },
- {
- img: ImgFile.copy,
- name: "复制到...",
- },
- {
- img: ImgFile.collect,
- name: "收藏"
- },
- {
- img: ImgFile.downLoad,
- name: "下载"
- },
- {
- img: ImgFile.textbox,
- name: "重命名"
- },
- {
- img: ImgFile.share,
- name: "分享"
- },
- {
- img: ImgFile.notePencil,
- name: "在线编辑"
- },
- {
- img: ImgFile.togger,
- name: "协作"
- },
- {
- img: ImgFile.icc,
- name: "文字识别"
- },
- {
- img: ImgFile.history,
- name: "历史版本"
- },
- {
- img: ImgFile.trash,
- name: "删除"
- }
- ])
- // 获取文件夹,中栏,文件
- function getAllTop() {
- documents.getTop(3).then(res => {
- let userMe = [res]
- impDirId.value = userMe[0].dirId//固定
- impSpaceId.value = userMe[0].spaceId//固定
- newSpaceId.value = userMe[0].spaceId//变化
- newDirId.value = userMe[0].dirId//变化
- topPath.value = userMe[0].dirPath
- let obj = {
- pageNum: 1,
- pageSize: 10
- }
- documents.getALLdocument({ parentId: userMe[0].dirId - 0, spaceId: userMe[0].spaceId, pageNum: obj.pageNum, pageSize: obj.pageSize }).then(res => {
- fileMenu.value = res.data
- folderList.value = res.data
- })
- myfile.getById(userMe[0].dirId - 0, obj).then(res => {
- if (res.code === 200) {
- fileList.value = res.rows
- fileTotal.value = res.total
- if (fileTotal.value / 10 != 1) {
- let x = Math.trunc(fileTotal.value / 10) + 1
- for (var i = 1; i <= x; i++) {
- obj.pageNum = i
- myfile.getById(userMe[0].dirId - 0, obj).then(res => {
- fileList.value = fileList.value.concat(res.rows)
- const uniqueFileList = Array.from(new Set(fileList.value.map(item => item.docId)))
- .map(docId => fileList.value.find(item => item.docId === docId));
- // 合并数组并更新 fileList.value
- fileList.value = uniqueFileList
- console.log(fileList.value, 'iiii');
- })
- }
- }
- }
- })
- })
- }
- // 筛选后缀图片
- function getImage(file) {
- if (file === '.txt') {
- return ImgFile.bigTxt
- } else if (file === '.xlxs' || file === '.docx' || file === '.xls') {
- return ImgFile.bigxlsx
- } else if (file === '.pptx') {
- return ImgFile.bigpptx
- } else if (file === '.word') {
- return ImgFile.bigdoc
- } else if (file === '.pdf') {
- return ImgFile.bigpdf
- } else if (file === ".mp3") {
- return ImgFile.audio
- } else if (file === '.mp4') {
- return ImgFile.video
- } else if (file === ".png" || file === ".jpg") {
- return ImgFile.pic
- } else {
- return ImgFile.elseFile
- }
- }
- function rightClick(row, event) {
- event.preventDefault()
- isFolder.value = "N"
- clickRow.value = row
- xz.value = event.pageX
- yz.value = event.pageY
- copyRow.value = row
- clickRowId.value = row.docId
- copyDirId.value = row.dirId
- copySpaceId.value = row.spaceId
- copyFileId.value = row.fileId
- copyFileSize.value = row.fileSize
- copyFileType.value = row.fileType
- nameForm.value.name = row.fileName
- copyFileName.value = row.fileName
- if (cliCC.value === true) {
- cliCC.value = false
- } else {
- cliCC.value = true
- }
- }
- //对mouseCli数组进行筛选,实现菜单的区分显示
- const filterMouseCli = () => {
- 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']
- const typeArr = ['.png', '.jpg', '.jpeg', '.JPG', '.mp3', '.mp4']
- const imgTypeArr = ['.png', '.jpg', '.jpeg', '.JPG']
- const canEditArr = ['.doc', '.docm', '.docx', '.dot', '.dotm', '.dotx', '.txt', '.djvu', '.xps', 'csv', 'fods', 'ods', 'ots', 'xls', 'xlsm', 'xlsx', 'xlt', 'xltm', 'xltx', 'fodp', 'odp', 'otp']
- let arr = []
- if (!(typeArr.includes(copyFileType.value) || canPreviewArray.includes(copyFileType.value))) {
- arr = mouseCli.value.filter(item => item.name !== "预览")
- } else {
- arr = toRaw(mouseCli.value)
- }
- if (!canEditArr.includes(copyFileType.value)) {
- arr = arr.filter(item => item.name !== "在线编辑" && item.name !== "协作" && item.name !== "历史版本")
- }
- if (!imgTypeArr.includes(copyFileType.value)) {
- arr = arr.filter(item => item.name !== "文字识别")
- }
- return arr
- }
- function mouseClick() {
- if (cliCC.value) {
- cliCC.value = false
- }
- if (anyP) {
- anyP.value = false
- }
- }
- async function chooseSet(row, index, num) {
- if (row.name == '在线编辑' || row.name == '协作') {
- cliCC.value = true
- } else {
- cliCC.value = false
- }
- if (row.name == '分享') {
- workOrEdit.value = num
- thanks.value = true
- } else {
- thanks.value = false
- }
- if (row.name == '协作') {
- if (anyP.value) {
- anyP.value = false
- } else {
- anyP.value = true
- }
- } else {
- anyP.value = false
- }
- if (row.name == '删除') {
- myfile.delMenu(clickRowId.value).then(res => {
- if (res.code === 200) {
- ElMessage({
- type: "success",
- message: "删除成功"
- })
- getAllTop()
- }
- })
- }
- if (row.name === '复制到...') {
- copyOrMove.value = 0
- fileTrees.value = true
- }
- if (row.name === '移动到...') {
- copyOrMove.value = 1
- fileTrees.value = true
- }
- if (row.name === '重命名') {
- fileNameChange.value = true
- }
- if (row.name === "下载") {
- location.href = `${import.meta.env.VITE_APP_BASE_API}/api/download/${copyFileId.value}`;
- }
- if (row.name === '收藏') {
- collects.value = true
- }
- if (row.name === '在线编辑') {
- editOnline.value = false
- cliCC.value = false
- }
- if (row.name === '文字识别') {
- router.push({
- path: '/identifyFont',
- query: {
- fileId: copyFileId.value,
- fileType: copyFileType.value
- }
- })
- }
- if (row.name === '预览') {
- // editOnline.value = true
- // emit("showFile", false)
- const filePreview = canPreviewFile(copyFileType.value)
- if (filePreview) {
- onlyView.value = true
- emit("showFile", false, clickRowId.value, copyRow.value)
- cliCC.value = false
- } else {
- showPreview.value = true
- const res = await preview(copyFileId.value)
- previewData.value = URL.createObjectURL(res)
- console.log(888);
- }
- showPreview.value = true
- const res = await preview(copyFileId.value)
- previewData.value = URL.createObjectURL(res)
- } else if (row.name === "历史版本") {
- const resHistory = await listVersion({ docId: clickRowId.value })
- historyTotal.value = resHistory.total
- fileUserTreeData.data = resHistory.rows;
- openForwardFile.value = true
- }
- }
- function changeMsgClose(val, item) {
- if (val) {
- historycopyRow.value = item
- editOnline.value = false
- cliCC.value = false
- historyPrew.value = true
- }
- openForwardFile.value = val
- }
- function chooseSet1(num) {
- workOrEdit.value = num
- thanks.value = true
- anyP.value = false
- }
- function getChildren(data) {
- fileTrees.value = data
- }
- function getCback(data) {
- thanks.value = data
- }
- function closeImgPreview(data) {
- showPreview.value = data
- }
- function cancleHistoryPrew(data) {
- historyPrew.value = false
- }
- onMounted(() => {
- getAllTop()
- window.addEventListener("click", mouseClick);
- })
- return {
- getAllTop,
- impDirId,
- impSpaceId,
- newDirId,
- newSpaceId,
- fileList,
- fileMenu,
- folderList,
- fileTotal,
- getImage,
- rightClick,
- filterMouseCli,
- copyRow,
- clickRow,
- clickRowId,
- copyDirId,
- copySpaceId,
- copyFileId,
- copyFileSize,
- copyFileType,
- nameForm,
- copyFileName,
- cliCC,
- mouseClick,
- anyP,
- xz,
- yz,
- chooseSet,
- chooseSet1,
- thanks,
- FileTree,
- fileTrees,
- getCback,
- getChildren,
- copyOrMove,
- onlyView,
- editOnline,
- showPreview,
- ImgPreview,
- previewData,
- closeImgPreview,
- FileEdit,
- cancleHistoryPrew,
- historycopyRow,
- changeMsgClose,
- historyPrew,
- }
- },
- components: {
- TransferModal,
- FileTree,
- ImgPreview,
- FileEdit
- }
- }
- </script>
- <style scoped>
- .bigBox {
- width: 100%;
- height: 100%;
- display: flex;
- justify-content: flex-start;
- align-items: center;
- flex-wrap: wrap;
- }
- .imgBox {
- width: 88px;
- height: 88px;
- text-align: center;
- line-height: 88px;
- }
- .flexBox {
- width: 104px;
- height: 148px;
- position: relative;
- }
- .nameName {
- width: 100%;
- white-space: nowrap;
- /* 禁止文本换行 */
- overflow: hidden;
- /* 隐藏溢出部分文本 */
- text-overflow: ellipsis;
- /* 显示省略号 */
- }
- .setCli {
- width: 156px;
- max-height: auto;
- position: absolute;
- flex-wrap: 400;
- background-color: white;
- border: 1px solid gray;
- border-radius: 4px;
- z-index: 3;
- overflow-y: auto;
- /* // font-size: 16px; */
- }
- .setCli1 {
- width: 156px;
- height: auto;
- position: absolute;
- top: 185px;
- left: 455px;
- background-color: white;
- border: 1px solid gray;
- border-radius: 4px;
- z-index: 2;
- overflow-y: auto;
- }
- .chooseSet {
- width: 140px;
- height: 30px;
- line-height: 30px;
- margin: 5px auto;
- font-size: 13px;
- /*
- display: flex;
- align-items: center;
- position: relative; */
- }
- .chooseSet img {
- margin-right: 4px;
- vertical-align: middle;
- }
- .chooseSet:hover {
- width: 140px;
- height: 30px;
- line-height: 30px;
- margin: 5px auto;
- font-size: 13px;
- background-color: #F5F7F9;
- /* color: white; */
- }
- </style>
|