ow
This commit is contained in:
1 parent
7f5bf3c68d
commit
816209fc35
37 files changed
+3236
-4515
No files matched your search
@@ -5,11 +5,13 @@
|
||||
@refresh="onReSearch" @search="onSearchByName" @breadcrumb-click="onBreadcrumbClick" />
|
||||
|
||||
<OperatorStation :selected-items="keys" :upload-url="uploadUrl" :headers="headers" :can-create="canCreate"
|
||||
:can-amend="canAmend" :can-delete="canDelete" :can-view="canView" @create-folder="onCreate"
|
||||
@before-upload="beforeUpload" @download="onDownloadSelected" @share="onShareSelected"
|
||||
@publish="onPublishSelected" @view-preview="onViewPreviewSelected" @play-video="onUrlVideoPlayItem"
|
||||
@play-audio="onPlayAudioItem" @pause-audio="onPauseAudio" @continue-audio="onContinueAudio"
|
||||
@preview="onPreviewSelected" @rename="onAmendSelected" @move="onMoveSelected" @delete="onDeleteSelected" />
|
||||
:can-amend="canAmend" :can-delete="canDelete" :can-view="canView"
|
||||
:resolve-file-path="resolveUploadFilePath" @create-folder="onCreate" @upload-start="onUploadStart"
|
||||
@upload-progress="onUploadProgress" @upload-success="onUploadSuccess" @upload-error="onUploadError"
|
||||
@download="onDownloadSelected" @share="onShareSelected" @publish="onPublishSelected"
|
||||
@view-preview="onViewPreviewSelected" @play-video="onUrlVideoPlayItem" @play-audio="onPlayAudioItem"
|
||||
@pause-audio="onPauseAudio" @continue-audio="onContinueAudio" @preview="onPreviewSelected"
|
||||
@rename="onAmendSelected" @move="onMoveSelected" @delete="onDeleteSelected" />
|
||||
|
||||
<MyComputer :datas="datas" v-model:selected-keys="keys" @select-change="onSelectChange"
|
||||
@open-folder="onOpenFolder" @open-file="onOpenFile" @preview-image="onPreviewOrgFile" />
|
||||
@@ -68,10 +70,8 @@ import { notification } from "ant-design-vue";
|
||||
import { SearchCriteriaResultData } from "@/data/auto/searchCriteriaResultData";
|
||||
import dmsFolder from "./DmsFolderModal.vue";
|
||||
import { useLoginProfileStore } from "@/store/modules/loginProfile";
|
||||
import type { UploadProps } from "ant-design-vue";
|
||||
import { WebSitePolicy } from "@/policy/custom/webSitePolicy";
|
||||
import { orderBy } from "lodash-es";
|
||||
import axios from "axios";
|
||||
import VideoPlay from "./PlayVideo.vue";
|
||||
import { Howl } from "howler";
|
||||
import { PublishVideoEntity } from "@/data/auto/publishVideoEntity";
|
||||
@@ -79,7 +79,6 @@ import publishVideoService from "@/service/master/publishVideoService";
|
||||
import { useWindowSize } from "@vueuse/core";
|
||||
import fileTypePolicy from "@/policy/custom/fileTypePolicy";
|
||||
import { PublishAudioEntity } from "@/data/auto/publishAudioEntity";
|
||||
import { v4 as uuidv4 } from "uuid";
|
||||
import { FamilyFolderFavoriteViewEntity } from "@/data/auto/familyFolderFavoriteViewEntity";
|
||||
import { DmsFileEntity } from "@/data/auto/dmsFileEntity";
|
||||
import { PublishData } from "@/data/auto/publishData";
|
||||
@@ -113,12 +112,11 @@ const route = useRoute();
|
||||
const router = useRouter();
|
||||
const previousFilePath = ref<string>("");
|
||||
|
||||
const fileList = ref<UploadProps["fileList"]>([]);
|
||||
const uploadUrl = ref<string>(WebSitePolicy.WebApiRoot + "DmsFile/UploadFile");
|
||||
const uploadUrl = ref<string>(WebSitePolicy.WebApiRoot + "DmsFile/UploadDmsFile");
|
||||
if (process.env.NODE_ENV === "development") {
|
||||
uploadUrl.value = WebSitePolicy.WebApiRootDev + "/DmsFile/UploadFile";
|
||||
uploadUrl.value = WebSitePolicy.WebApiRootDev + "/DmsFile/UploadDmsFile";
|
||||
} else {
|
||||
uploadUrl.value = WebSitePolicy.WebApiRoot + "/DmsFile/UploadFile";
|
||||
uploadUrl.value = WebSitePolicy.WebApiRoot + "/DmsFile/UploadDmsFile";
|
||||
}
|
||||
|
||||
const currFilePath = ref<string>("");
|
||||
@@ -276,99 +274,35 @@ onMounted(async () => {
|
||||
onSearchByFilePath(rootPath.value);
|
||||
});
|
||||
|
||||
const beforeUpload: UploadProps["beforeUpload"] = async (file) => {
|
||||
if (!file || typeof file.size !== "number") {
|
||||
return false;
|
||||
}
|
||||
loading.value = true;
|
||||
fileList.value = [...(fileList.value || []), file];
|
||||
const chunks = splitFile(file);
|
||||
|
||||
let bindOption: BindOption = bindOptions.value.filter(
|
||||
/** 解析上传目标文件夹(DMS 当前路径) */
|
||||
const resolveUploadFilePath = () => {
|
||||
const bindOption = bindOptions.value.filter(
|
||||
(x) => x.BindValue == DmsFileUploadViewDisplayData.DB_FILE_PATH,
|
||||
)[0];
|
||||
currFilePath.value = headers.value.FilePath = bindOption.Value;
|
||||
let i = 1;
|
||||
let fileSize = file.size;
|
||||
let uid: string = uuidv4();
|
||||
spinTip.value = "上传中(1/" + chunks.length + ")...";
|
||||
await uploadChunk(chunks, file.name, uid, i);
|
||||
return bindOption?.Value || currFilePath.value;
|
||||
};
|
||||
|
||||
const onUploadStart = () => {
|
||||
loading.value = true;
|
||||
};
|
||||
|
||||
const onUploadProgress = (payload: { text?: string }) => {
|
||||
spinTip.value = payload?.text || "上传中...";
|
||||
};
|
||||
|
||||
const onUploadSuccess = (payload: { total?: number }) => {
|
||||
const total = payload?.total ?? 1;
|
||||
let sec = 2500;
|
||||
if (total > 25) sec = total * 100;
|
||||
spinTip.value = "加载中...";
|
||||
return false;
|
||||
setTimeout(() => {
|
||||
onReSearch();
|
||||
}, sec);
|
||||
};
|
||||
|
||||
const uploadChunk = async (
|
||||
chunks: any,
|
||||
fileName: string,
|
||||
uid: string,
|
||||
index: number,
|
||||
) => {
|
||||
const formData = new FormData();
|
||||
|
||||
const fileExtension = fileName.split(".").pop();
|
||||
formData.append(
|
||||
fileName,
|
||||
chunks[index - 1],
|
||||
uid +
|
||||
"-" +
|
||||
index.toString() +
|
||||
"-" +
|
||||
chunks.length.toString() +
|
||||
"." +
|
||||
fileExtension,
|
||||
);
|
||||
|
||||
if (process.env.NODE_ENV === "development") {
|
||||
axios.defaults.baseURL = WebSitePolicy.WebApiRootDev;
|
||||
axios.defaults.withCredentials = true;
|
||||
} else {
|
||||
axios.defaults.baseURL = WebSitePolicy.WebApiRoot;
|
||||
}
|
||||
try {
|
||||
let response = await axios.create().request({
|
||||
url: "/DmsFile/UploadFile",
|
||||
method: "post",
|
||||
data: formData,
|
||||
headers: headers.value,
|
||||
});
|
||||
|
||||
if (response.status == 200 && index < chunks.length) {
|
||||
spinTip.value = "上传中(" + (index + 1) + "/" + chunks.length + ")...";
|
||||
await uploadChunk(chunks, fileName, uid, index + 1);
|
||||
} else if (index == chunks.length) {
|
||||
let sec: number = 2500;
|
||||
if (index > 25) sec = index * 100;
|
||||
spinTip.value = "加载中...";
|
||||
setTimeout(function () {
|
||||
onReSearch();
|
||||
}, sec);
|
||||
}
|
||||
} catch (error) {
|
||||
loading.value = false;
|
||||
spinTip.value = "加载中...";
|
||||
}
|
||||
};
|
||||
|
||||
const CHUNK_SIZE = 1 * 1024 * 1024;
|
||||
|
||||
const splitFile = (file: any) => {
|
||||
const chunks: Blob[] = [];
|
||||
if (
|
||||
!file ||
|
||||
typeof file.size !== "number" ||
|
||||
typeof file.slice !== "function"
|
||||
) {
|
||||
return chunks;
|
||||
}
|
||||
let start = 0;
|
||||
while (start < file.size) {
|
||||
const end = Math.min(start + CHUNK_SIZE, file.size);
|
||||
const chunk = file.slice(start, end);
|
||||
chunks.push(chunk);
|
||||
start += CHUNK_SIZE;
|
||||
}
|
||||
return chunks;
|
||||
const onUploadError = () => {
|
||||
loading.value = false;
|
||||
spinTip.value = "加载中...";
|
||||
};
|
||||
|
||||
const onSelectChange = (selected: DmsFileUploadViewDisplayData[]) => {
|
||||
|
||||
Reference in new issue
Block a user