修改bug
This commit is contained in:
parent
b4a7b8f07e
commit
4bd1531ef5
|
|
@ -28,30 +28,30 @@
|
|||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref, reactive, computed, watch, nextTick, createApp, unref } from 'vue';
|
||||
import { Icon } from '/@/components/Icon';
|
||||
import { getToken } from '/@/utils/auth';
|
||||
import { uploadUrl, baseUploadUrl } from '/@/api/common/api';
|
||||
import { propTypes } from '/@/utils/propTypes';
|
||||
import { useMessage } from '/@/hooks/web/useMessage';
|
||||
import { createImgPreview } from '/@/components/Preview/index';
|
||||
import { useAttrs } from '/@/hooks/core/useAttrs';
|
||||
import { useDesign } from '/@/hooks/web/useDesign';
|
||||
import { UploadTypeEnum } from './upload.data';
|
||||
import { getFileAccessHttpUrl } from '/@/utils/common/compUtils';
|
||||
import UploadItemActions from './components/UploadItemActions.vue';
|
||||
import { defHttp } from '/@/utils/http/axios';
|
||||
import { buildUUID } from '/@/utils/uuid';
|
||||
import CryptoJS from 'crypto-js';
|
||||
import { ref, reactive, computed, watch, nextTick, createApp, unref } from 'vue';
|
||||
import { Icon } from '/@/components/Icon';
|
||||
import { getToken } from '/@/utils/auth';
|
||||
import { uploadUrl, baseUploadUrl } from '/@/api/common/api';
|
||||
import { propTypes } from '/@/utils/propTypes';
|
||||
import { useMessage } from '/@/hooks/web/useMessage';
|
||||
import { createImgPreview } from '/@/components/Preview/index';
|
||||
import { useAttrs } from '/@/hooks/core/useAttrs';
|
||||
import { useDesign } from '/@/hooks/web/useDesign';
|
||||
import { UploadTypeEnum } from './upload.data';
|
||||
import { getFileAccessHttpUrl } from '/@/utils/common/compUtils';
|
||||
import UploadItemActions from './components/UploadItemActions.vue';
|
||||
import { defHttp } from '/@/utils/http/axios';
|
||||
import { buildUUID } from '/@/utils/uuid';
|
||||
import CryptoJS from 'crypto-js';
|
||||
|
||||
import { downloadFile as ajaxDownloadFileFn } from '/@/api/common/api';
|
||||
import { downloadFile as ajaxDownloadFileFn } from '/@/api/common/api';
|
||||
|
||||
const spinning = ref<boolean>(false);
|
||||
const { createMessage, createConfirm } = useMessage();
|
||||
const { prefixCls } = useDesign('j-upload');
|
||||
const attrs = useAttrs();
|
||||
const emit = defineEmits(['change', 'update:value']);
|
||||
const props = defineProps({
|
||||
const spinning = ref<boolean>(false);
|
||||
const { createMessage, createConfirm } = useMessage();
|
||||
const { prefixCls } = useDesign('j-upload');
|
||||
const attrs = useAttrs();
|
||||
const emit = defineEmits(['change', 'update:value']);
|
||||
const props = defineProps({
|
||||
value: propTypes.oneOfType([propTypes.string, propTypes.array]),
|
||||
text: propTypes.string.def('上传'),
|
||||
fileType: propTypes.string.def(UploadTypeEnum.all),
|
||||
|
|
@ -83,24 +83,24 @@
|
|||
//后加的,查询biz参数
|
||||
getBizParam: propTypes.object.def({}),
|
||||
disabled: propTypes.bool.def(false),
|
||||
});
|
||||
});
|
||||
|
||||
const otherData = ref<Object>({});
|
||||
const otherClass = ref<Object>({});
|
||||
const otherData = ref<Object>({});
|
||||
const otherClass = ref<Object>({});
|
||||
|
||||
const headers = reactive({
|
||||
const headers = reactive({
|
||||
'X-Access-Token': getToken(),
|
||||
});
|
||||
const fileList = ref<any[]>([]);
|
||||
const uploadGoOn = ref<boolean>(true);
|
||||
// refs
|
||||
const containerRef = ref();
|
||||
// 是否达到了最大上传数量
|
||||
const isMaxCount = computed(() => props.maxCount > 0 && fileList.value.length >= props.maxCount);
|
||||
// 当前是否是上传图片模式
|
||||
const isImageMode = computed(() => props.fileType === UploadTypeEnum.image);
|
||||
// 合并 props 和 attrs
|
||||
const bindProps = computed(() => {
|
||||
});
|
||||
const fileList = ref<any[]>([]);
|
||||
const uploadGoOn = ref<boolean>(true);
|
||||
// refs
|
||||
const containerRef = ref();
|
||||
// 是否达到了最大上传数量
|
||||
const isMaxCount = computed(() => props.maxCount > 0 && fileList.value.length >= props.maxCount);
|
||||
// 当前是否是上传图片模式
|
||||
const isImageMode = computed(() => props.fileType === UploadTypeEnum.image);
|
||||
// 合并 props 和 attrs
|
||||
const bindProps = computed(() => {
|
||||
const bind: any = Object.assign({}, props, unref(attrs));
|
||||
bind.name = 'file';
|
||||
bind.listType = isImageMode.value ? 'picture-card' : 'text';
|
||||
|
|
@ -109,7 +109,7 @@
|
|||
//update-begin-author:taoyan date:20220407 for: 自定义beforeUpload return false,并不能中断上传过程
|
||||
if (!bind.beforeUpload) {
|
||||
bind.beforeUpload = onBeforeUpload;
|
||||
} else if(!bind.forceBeforeUploadFn){
|
||||
} else if (!bind.forceBeforeUploadFn) {
|
||||
//强制使用
|
||||
bind.beforeUpload = onBeforeUpload;
|
||||
}
|
||||
|
|
@ -119,9 +119,9 @@
|
|||
bind.accept = 'image/*';
|
||||
}
|
||||
return bind;
|
||||
});
|
||||
});
|
||||
|
||||
watch(
|
||||
watch(
|
||||
() => props.value,
|
||||
(val) => {
|
||||
if (Array.isArray(val)) {
|
||||
|
|
@ -135,34 +135,34 @@
|
|||
}
|
||||
},
|
||||
{ immediate: true }
|
||||
);
|
||||
);
|
||||
|
||||
watch(fileList, () => nextTick(() => addActionsListener()), { immediate: true });
|
||||
watch(fileList, () => nextTick(() => addActionsListener()), { immediate: true });
|
||||
|
||||
const loadBizFn = (params) => defHttp.get({ url: '/ktgl/kcKetangbiao/getBizPath', params }, { isTransformResponse: false })
|
||||
const loadBizFn = (params) => defHttp.get({ url: '/ktgl/kcKetangbiao/getBizPath', params }, { isTransformResponse: false });
|
||||
|
||||
function loadBiz(param){
|
||||
function loadBiz(param) {
|
||||
otherData.value.loading = true;
|
||||
// otherClass.value = { 'upload-disabled': true, }
|
||||
loadBizFn(param).then(res => {
|
||||
loadBizFn(param).then((res) => {
|
||||
//otherData.value
|
||||
if(res.success){
|
||||
if (res.success) {
|
||||
otherData.value.biz = res.result;
|
||||
}else{
|
||||
} else {
|
||||
delete otherData.value.biz;
|
||||
}
|
||||
// otherClass.value = {}
|
||||
delete otherData.value.loading;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
watch(() => props.getBizParam,
|
||||
watch(
|
||||
() => props.getBizParam,
|
||||
(param, oldParam) => {
|
||||
if(JSON.stringify(param) != JSON.stringify(oldParam)){
|
||||
if (JSON.stringify(param) != JSON.stringify(oldParam)) {
|
||||
nextTick(() => {
|
||||
console.log(`🚀 ~ props.isGetBiz:`, props.isGetBiz, bindProps.value.disabled, loadBiz);
|
||||
if(props.isGetBiz && !bindProps.value.disabled){
|
||||
if (props.isGetBiz && !bindProps.value.disabled) {
|
||||
//非被禁用状态,查询
|
||||
nextTick(() => {
|
||||
loadBiz(param);
|
||||
|
|
@ -172,12 +172,12 @@
|
|||
}
|
||||
},
|
||||
{ immediate: true }
|
||||
);
|
||||
);
|
||||
|
||||
const antUploadItemCls = 'ant-upload-list-item';
|
||||
const antUploadItemCls = 'ant-upload-list-item';
|
||||
|
||||
// Listener
|
||||
function addActionsListener() {
|
||||
// Listener
|
||||
function addActionsListener() {
|
||||
if (!isImageMode.value) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -191,10 +191,10 @@
|
|||
uploadItem.addEventListener('mouseover', onAddActionsButton);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 添加可左右移动的按钮
|
||||
function onAddActionsButton(event) {
|
||||
// 添加可左右移动的按钮
|
||||
function onAddActionsButton(event) {
|
||||
const getUploadItem = () => {
|
||||
for (const path of event.path) {
|
||||
if (path.classList.contains(antUploadItemCls)) {
|
||||
|
|
@ -226,10 +226,10 @@
|
|||
actions[0].appendChild(div);
|
||||
uploadItem.setAttribute('data-has-actions', 'true');
|
||||
uploadItem.removeEventListener('mouseover', onAddActionsButton);
|
||||
}
|
||||
}
|
||||
|
||||
// 解析数据库存储的逗号分割
|
||||
function parsePathsValue(paths) {
|
||||
// 解析数据库存储的逗号分割
|
||||
function parsePathsValue(paths) {
|
||||
if (!paths || paths.length == 0) {
|
||||
fileList.value = [];
|
||||
return;
|
||||
|
|
@ -246,10 +246,10 @@
|
|||
});
|
||||
}
|
||||
fileList.value = list;
|
||||
}
|
||||
}
|
||||
|
||||
// 解析数组值
|
||||
function parseArrayValue(array) {
|
||||
// 解析数组值
|
||||
function parseArrayValue(array) {
|
||||
if (!array || array.length == 0) {
|
||||
fileList.value = [];
|
||||
return;
|
||||
|
|
@ -266,10 +266,10 @@
|
|||
});
|
||||
}
|
||||
fileList.value = list;
|
||||
}
|
||||
}
|
||||
|
||||
// 文件上传之前的操作
|
||||
function onBeforeUpload(file) {
|
||||
// 文件上传之前的操作
|
||||
function onBeforeUpload(file) {
|
||||
uploadGoOn.value = true;
|
||||
if (isImageMode.value) {
|
||||
if (file.type.indexOf('image') < 0) {
|
||||
|
|
@ -279,15 +279,17 @@
|
|||
}
|
||||
}
|
||||
//扩展验证(目前仅支持扩展名验证)
|
||||
if(props.forceAcceptVerify){
|
||||
if (props.forceAcceptVerify) {
|
||||
let fileName = file?.name;
|
||||
if(fileName.indexOf('.')){
|
||||
let suffix = fileName.split('.')[1];
|
||||
console.log('👩⚕️', fileName);
|
||||
if (fileName.indexOf('.')) {
|
||||
let suffix = fileName.split('.').pop().toLowerCase();
|
||||
console.log('🤶', suffix);
|
||||
let fileTypes = unref(bindProps).accept;
|
||||
if(fileTypes){
|
||||
if(fileTypes.indexOf(',')){
|
||||
if (fileTypes) {
|
||||
if (fileTypes.indexOf(',')) {
|
||||
let typeList = fileTypes.split(',');
|
||||
if(typeList.indexOf('.' + suffix) == -1){
|
||||
if (typeList.indexOf('.' + suffix) == -1) {
|
||||
createMessage.warning('请上传【*' + typeList.join(',*') + '】格式的文件');
|
||||
uploadGoOn.value = false;
|
||||
return false;
|
||||
|
|
@ -299,13 +301,13 @@
|
|||
|
||||
// 扩展 beforeUpload 验证
|
||||
if (typeof props.beforeUpload === 'function') {
|
||||
return props.beforeUpload(file, unref(bindProps), () => uploadGoOn.value = false );
|
||||
return props.beforeUpload(file, unref(bindProps), () => (uploadGoOn.value = false));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// 删除处理事件
|
||||
function onRemove() {
|
||||
// 删除处理事件
|
||||
function onRemove() {
|
||||
if (props.removeConfirm) {
|
||||
return new Promise((resolve) => {
|
||||
createConfirm({
|
||||
|
|
@ -318,10 +320,10 @@
|
|||
});
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// upload组件change事件
|
||||
function onFileChange(info) {
|
||||
// upload组件change事件
|
||||
function onFileChange(info) {
|
||||
if (!info.file.status && uploadGoOn.value === false) {
|
||||
info.fileList.pop();
|
||||
}
|
||||
|
|
@ -367,16 +369,16 @@
|
|||
fileSize: item.size,
|
||||
};
|
||||
newFileList.push(fileJson);
|
||||
}else{
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
emitValue(newFileList);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function handlePathChange() {
|
||||
function handlePathChange() {
|
||||
let uploadFiles = fileList.value;
|
||||
let path = '';
|
||||
if (!uploadFiles || uploadFiles.length == 0) {
|
||||
|
|
@ -394,24 +396,24 @@
|
|||
path = pathList.join(',');
|
||||
}
|
||||
emitValue(path);
|
||||
}
|
||||
}
|
||||
|
||||
// 预览文件、图片
|
||||
function onFilePreview(file) {
|
||||
// 预览文件、图片
|
||||
function onFilePreview(file) {
|
||||
if (isImageMode.value) {
|
||||
createImgPreview({ imageList: [file.url], maskClosable: true });
|
||||
} else {
|
||||
// window.open(file.url);
|
||||
openWindowWithLoading(file.url);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* 自定义下载事件,带加载中
|
||||
*/
|
||||
function openWindowWithLoading(url){
|
||||
function openWindowWithLoading(url) {
|
||||
spinning.value = true;
|
||||
let fileName = url.substring(url.lastIndexOf("/")+1);
|
||||
let fileName = url.substring(url.lastIndexOf('/') + 1);
|
||||
let uploadAxiosHttpConfig = {
|
||||
//超时时间,分钟 * 秒 * 毫秒 60分钟
|
||||
timeout: 60 * 60 * 1000,
|
||||
|
|
@ -420,9 +422,17 @@
|
|||
//自定义前缀
|
||||
apiUrl: '',
|
||||
//不自动处理
|
||||
isTransformResponse: false
|
||||
}
|
||||
ajaxDownloadFileFn(url, fileName, {}, () => { spinning.value = false; }, uploadAxiosHttpConfig);
|
||||
isTransformResponse: false,
|
||||
};
|
||||
ajaxDownloadFileFn(
|
||||
url,
|
||||
fileName,
|
||||
{},
|
||||
() => {
|
||||
spinning.value = false;
|
||||
},
|
||||
uploadAxiosHttpConfig
|
||||
);
|
||||
//spinning.value = false;
|
||||
// let xhr = new XMLHttpRequest();
|
||||
// xhr.open('GET',url,true);
|
||||
|
|
@ -448,60 +458,60 @@
|
|||
// }
|
||||
// spinning.value = false;
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
function emitValue(value) {
|
||||
function emitValue(value) {
|
||||
emit('change', value);
|
||||
emit('update:value', value);
|
||||
}
|
||||
}
|
||||
|
||||
function uidGenerator() {
|
||||
function uidGenerator() {
|
||||
return '-' + parseInt(Math.random() * 10000 + 1, 10);
|
||||
}
|
||||
}
|
||||
|
||||
function getFileName(path) {
|
||||
function getFileName(path) {
|
||||
if (path.lastIndexOf('\\') >= 0) {
|
||||
let reg = new RegExp('\\\\', 'g');
|
||||
path = path.replace(reg, '/');
|
||||
}
|
||||
return path.substring(path.lastIndexOf('/') + 1);
|
||||
}
|
||||
}
|
||||
|
||||
// //获取文件md5(仅支持小文件,,,弃用)
|
||||
// function calculateFileMd5(file) {
|
||||
// return new Promise((resolve, reject) => {
|
||||
// const reader = new FileReader();
|
||||
// // 当文件被成功读取时调用onload事件
|
||||
// reader.onload = function (event) {
|
||||
// const arrayBufferView = event.target.result;
|
||||
// // 将ArrayBuffer转换为WordArray对象
|
||||
// const wordArray = CryptoJS.lib.WordArray.create(arrayBufferView);
|
||||
// // 计算MD5哈希值
|
||||
// const md5Hash = CryptoJS.MD5(wordArray).toString();
|
||||
// resolve(md5Hash);
|
||||
// };
|
||||
// // 当发生错误时调用onerror事件
|
||||
// reader.onerror = function () {
|
||||
// reject('Failed to read file');
|
||||
// };
|
||||
// // 开始读取文件内容
|
||||
// reader.readAsArrayBuffer(file);
|
||||
// });
|
||||
// }
|
||||
// //获取文件md5(仅支持小文件,,,弃用)
|
||||
// function calculateFileMd5(file) {
|
||||
// return new Promise((resolve, reject) => {
|
||||
// const reader = new FileReader();
|
||||
// // 当文件被成功读取时调用onload事件
|
||||
// reader.onload = function (event) {
|
||||
// const arrayBufferView = event.target.result;
|
||||
// // 将ArrayBuffer转换为WordArray对象
|
||||
// const wordArray = CryptoJS.lib.WordArray.create(arrayBufferView);
|
||||
// // 计算MD5哈希值
|
||||
// const md5Hash = CryptoJS.MD5(wordArray).toString();
|
||||
// resolve(md5Hash);
|
||||
// };
|
||||
// // 当发生错误时调用onerror事件
|
||||
// reader.onerror = function () {
|
||||
// reject('Failed to read file');
|
||||
// };
|
||||
// // 开始读取文件内容
|
||||
// reader.readAsArrayBuffer(file);
|
||||
// });
|
||||
// }
|
||||
|
||||
/**
|
||||
/**
|
||||
* 计算文件md5(分批次计算,挺慢的,支持大文件)
|
||||
*/
|
||||
function calFileMd5(file){
|
||||
function calFileMd5(file) {
|
||||
return new Promise((resolve, reject) => {
|
||||
let md5 = CryptoJS.algo.MD5.create();
|
||||
//获取文件对象
|
||||
let reader = new FileReader();
|
||||
let step = 1024* 1024;
|
||||
let step = 1024 * 1024;
|
||||
let total = file.size;
|
||||
let cuLoaded = 0;
|
||||
let time=1;
|
||||
console.info("文件大小:" + file.size);
|
||||
let time = 1;
|
||||
console.info('文件大小:' + file.size);
|
||||
//读取一段成功
|
||||
reader.onload = (e) => {
|
||||
//console.log("开始读取第"+time+"段");
|
||||
|
|
@ -519,11 +529,11 @@
|
|||
resolve(hash + buildUUID());
|
||||
}
|
||||
time++;
|
||||
}
|
||||
};
|
||||
reader.onerror = (e) => {
|
||||
console.error('读取文件MD5出现错误 =>',e);
|
||||
console.error('读取文件MD5出现错误 =>', e);
|
||||
reject(e);
|
||||
}
|
||||
};
|
||||
//开始读取
|
||||
readBlob(0);
|
||||
//指定开始位置,分块读取文件
|
||||
|
|
@ -533,18 +543,15 @@
|
|||
reader.readAsArrayBuffer(blob);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function calFileUid(file){
|
||||
function calFileUid(file) {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(buildUUID());
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//请求接口的数据返回
|
||||
//请求接口的数据返回
|
||||
// function upSearch(data){
|
||||
// return new Promise((resolve,reject)=>{
|
||||
// setTimeout(()=>{
|
||||
|
|
@ -585,30 +592,29 @@
|
|||
|
||||
//limitUp([1,2,3,4,5,6,7,8], 3)
|
||||
|
||||
async function limitPromise(promises, limit) {
|
||||
const results = [];
|
||||
|
||||
async function limitPromise(promises, limit) {
|
||||
const results = []
|
||||
|
||||
for(let i=0; i<=promises.length; i+=limit) {
|
||||
const tasks = []
|
||||
for (let i = 0; i <= promises.length; i += limit) {
|
||||
const tasks = [];
|
||||
// 切片 Promise.all 的参数
|
||||
for(const promise of promises.slice(i, i + limit)) {
|
||||
tasks.push(promise)
|
||||
for (const promise of promises.slice(i, i + limit)) {
|
||||
tasks.push(promise);
|
||||
}
|
||||
// 用 await 以确保后面的任务不会在执行当前任务时执行
|
||||
const result = await Promise.all(tasks)
|
||||
results.push(...result)
|
||||
const result = await Promise.all(tasks);
|
||||
results.push(...result);
|
||||
}
|
||||
|
||||
return results
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
//分片大小 5m
|
||||
const chunkSize = 5 * 1024 * 1024;
|
||||
//分片大小 5m
|
||||
const chunkSize = 5 * 1024 * 1024;
|
||||
|
||||
const runBatchNum = 20;
|
||||
const runBatchNum = 20;
|
||||
|
||||
const uploadAxiosHttpConfig = {
|
||||
const uploadAxiosHttpConfig = {
|
||||
//超时时间,分钟 * 秒 * 毫秒 60分钟
|
||||
timeout: 60 * 60 * 1000,
|
||||
//不自动拼接前缀
|
||||
|
|
@ -616,62 +622,64 @@
|
|||
//自定义前缀
|
||||
apiUrl: baseUploadUrl,
|
||||
//不自动处理
|
||||
isTransformResponse: false
|
||||
}
|
||||
isTransformResponse: false,
|
||||
};
|
||||
|
||||
const defUploadFn = (params) => defHttp.post({ url: '/sys/common/upload', params }, uploadAxiosHttpConfig );
|
||||
const defUploadFn = (params) => defHttp.post({ url: '/sys/common/upload', params }, uploadAxiosHttpConfig);
|
||||
|
||||
const bigFileUploadInit = (params) => defHttp.post({ url: '/sys/common/sectionUpload/init', params }, uploadAxiosHttpConfig );
|
||||
const bigFileUploadInit = (params) => defHttp.post({ url: '/sys/common/sectionUpload/init', params }, uploadAxiosHttpConfig);
|
||||
|
||||
const bigFileUploadUpload = (params) => defHttp.post({ url: '/sys/common/sectionUpload/upload', params }, uploadAxiosHttpConfig );
|
||||
const bigFileUploadUpload = (params) => defHttp.post({ url: '/sys/common/sectionUpload/upload', params }, uploadAxiosHttpConfig);
|
||||
|
||||
const bigFileUploadEnd = (params) => defHttp.post({ url: '/sys/common/sectionUpload/end', params }, uploadAxiosHttpConfig)
|
||||
const bigFileUploadEnd = (params) => defHttp.post({ url: '/sys/common/sectionUpload/end', params }, uploadAxiosHttpConfig);
|
||||
|
||||
/**
|
||||
/**
|
||||
* 自定义文件上传方法,小于5m的走默认上传,大于5m的走切片上传
|
||||
*/
|
||||
function uploadFn(customRequestData){
|
||||
function uploadFn(customRequestData) {
|
||||
const { data, file, onProgress, onSuccess, onError } = customRequestData; // 解构出a-upload的内置的方法(进度条,成功失败等)
|
||||
|
||||
let fileSize = file.size;
|
||||
let uploadPromiseList = [];
|
||||
|
||||
if(fileSize <= chunkSize){
|
||||
if (fileSize <= chunkSize) {
|
||||
let formData = new FormData();
|
||||
Object.keys(data).forEach(key => {
|
||||
Object.keys(data).forEach((key) => {
|
||||
formData.append(key, data[key]);
|
||||
});
|
||||
formData.append('file', file);
|
||||
//传统直传
|
||||
defUploadFn(formData).then(res => {
|
||||
defUploadFn(formData)
|
||||
.then((res) => {
|
||||
console.log(`🚀 ~ 传统直传 - defUploadFn ~ res:`, res);
|
||||
if(res.success){
|
||||
onProgress({ percent: 100 }, file) // 进度条
|
||||
onSuccess(res, file) // 上传文件的状态
|
||||
if (res.success) {
|
||||
onProgress({ percent: 100 }, file); // 进度条
|
||||
onSuccess(res, file); // 上传文件的状态
|
||||
} else {
|
||||
onError(res, res, file);
|
||||
}
|
||||
}).catch(err => {
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(`🚀 ~ 传统直传 - defUploadFn ~ err:`, err);
|
||||
onError(err, err, file);
|
||||
});
|
||||
} else {
|
||||
//计算当前选择文件需要的分片数量
|
||||
const chunkCount = Math.ceil(fileSize / chunkSize);
|
||||
console.log("文件大小:",(file.size / 1024 / 1024) + "Mb","分片数:",chunkCount);
|
||||
console.log('文件大小:', file.size / 1024 / 1024 + 'Mb', '分片数:', chunkCount);
|
||||
//获取文件md5
|
||||
console.log('第一步,计算文件的md5',calFileMd5, file);
|
||||
calFileMd5(file).then(fileMd5 => {
|
||||
console.log('第一步,计算文件的md5', calFileMd5, file);
|
||||
calFileMd5(file).then((fileMd5) => {
|
||||
console.log(`🚀 ~ 文件的md5是:`, fileMd5);
|
||||
const initUploadParams = { chunkCount, fileMd5 , ...data, };
|
||||
const initUploadParams = { chunkCount, fileMd5, ...data };
|
||||
let successNum = 0;
|
||||
|
||||
let taskAllList = [];
|
||||
//切片上传(开始)
|
||||
console.log('第二步,根据md5创建文件夹', initUploadParams);
|
||||
bigFileUploadInit(initUploadParams).then(res => {
|
||||
bigFileUploadInit(initUploadParams).then((res) => {
|
||||
console.log('第三步,准备切片文件', res);
|
||||
if(res.success){
|
||||
if (res.success) {
|
||||
onProgress({ percent: 0 }, file); // 进度条
|
||||
//后台创建成功,下一步,分批次上传
|
||||
for (let i = 1; i <= chunkCount; i++) {
|
||||
|
|
@ -679,94 +687,96 @@
|
|||
partNumber: i,
|
||||
...initUploadParams,
|
||||
file: null,
|
||||
}
|
||||
};
|
||||
//分片开始位置
|
||||
let start = (i - 1) * chunkSize
|
||||
let start = (i - 1) * chunkSize;
|
||||
//分片结束位置
|
||||
let end = Math.min(fileSize, start + chunkSize)
|
||||
let end = Math.min(fileSize, start + chunkSize);
|
||||
//取文件指定范围内的byte,从而得到分片数据
|
||||
let _chunkFile = file.slice(start, end)
|
||||
console.log("第四步,开始准备文件第" + i + "个分片" + ",切片范围从" + start + "到" + end)
|
||||
let _chunkFile = file.slice(start, end);
|
||||
console.log('第四步,开始准备文件第' + i + '个分片' + ',切片范围从' + start + '到' + end);
|
||||
|
||||
uploadParams.file = _chunkFile;
|
||||
let uploadFormData = new FormData();
|
||||
Object.keys(uploadParams).forEach(key => {
|
||||
Object.keys(uploadParams).forEach((key) => {
|
||||
uploadFormData.append(key, uploadParams[key]);
|
||||
});
|
||||
|
||||
console.log('第五步,准备切片文件上传参数', uploadFormData);
|
||||
taskAllList.push(new Promise((resolve, reject) => {
|
||||
taskAllList.push(
|
||||
new Promise((resolve, reject) => {
|
||||
console.log('第六步,准备切片文件上传前,', uploadFormData);
|
||||
bigFileUploadUpload(uploadFormData).then(res => {
|
||||
bigFileUploadUpload(uploadFormData)
|
||||
.then((res) => {
|
||||
console.log('第七步,切片文件上传后,', uploadFormData, res);
|
||||
if(res.success) {
|
||||
if (res.success) {
|
||||
successNum++;
|
||||
let percent = Number(Number(successNum/chunkCount*100).toFixed(0))
|
||||
onProgress({ percent }, file) // 进度条
|
||||
let percent = Number(Number((successNum / chunkCount) * 100).toFixed(0));
|
||||
onProgress({ percent }, file); // 进度条
|
||||
resolve(res);
|
||||
}else{
|
||||
} else {
|
||||
reject(res);
|
||||
}
|
||||
}).catch(err => {
|
||||
reject(err)
|
||||
})
|
||||
.catch((err) => {
|
||||
reject(err);
|
||||
});
|
||||
}));
|
||||
})
|
||||
);
|
||||
}
|
||||
//任务分片,一次20片
|
||||
console.log('第八步,全部切片,根据指定线程数执行,', limitPromise, taskAllList);
|
||||
limitPromise(taskAllList, runBatchNum).then(resList => {
|
||||
limitPromise(taskAllList, runBatchNum)
|
||||
.then((resList) => {
|
||||
console.log('第九步,全部切片,根据指定线程数执行完成后的结果,', resList);
|
||||
//完成后再执行一个合并
|
||||
let endUploadParams = {
|
||||
...initUploadParams,
|
||||
fileName: file.name,
|
||||
}
|
||||
};
|
||||
console.log('第十步,全部切片,发生合并指令,', endUploadParams);
|
||||
bigFileUploadEnd(endUploadParams).then(res => {
|
||||
bigFileUploadEnd(endUploadParams)
|
||||
.then((res) => {
|
||||
console.log(`第十一步 ~ 合并返回值 defHttp.post ~ res:`, res);
|
||||
//返回跟单个上传一样的返回值,
|
||||
if(res.success){
|
||||
onProgress({ percent: 100 }, file) // 进度条
|
||||
onSuccess(res, file) // 上传文件的状态
|
||||
if (res.success) {
|
||||
onProgress({ percent: 100 }, file); // 进度条
|
||||
onSuccess(res, file); // 上传文件的状态
|
||||
} else {
|
||||
onError(res, res, file);
|
||||
}
|
||||
|
||||
}).catch(err => {
|
||||
})
|
||||
.catch((err) => {
|
||||
console.error(`🚀 ~ 合并出现错误! defHttp.post ~ err:`, err);
|
||||
onError(err, err, file);
|
||||
});
|
||||
})
|
||||
}).catch(err => {
|
||||
.catch((err) => {
|
||||
console.error(`🚀 ~ 全部完成后,其中有错误limitPromise ~ err:`, err);
|
||||
//有错误,,
|
||||
onError(err, err, file);
|
||||
});
|
||||
|
||||
}
|
||||
//return
|
||||
})
|
||||
|
||||
})
|
||||
|
||||
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
// Promise.all(uploadPromiseList).then(resList => {
|
||||
|
||||
// });
|
||||
}
|
||||
}
|
||||
|
||||
defineExpose({
|
||||
defineExpose({
|
||||
addActionsListener,
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="less">
|
||||
//noinspection LessUnresolvedVariable
|
||||
@prefix-cls: ~'@{namespace}-j-upload';
|
||||
//noinspection LessUnresolvedVariable
|
||||
@prefix-cls: ~'@{namespace}-j-upload';
|
||||
|
||||
.@{prefix-cls} {
|
||||
.@{prefix-cls} {
|
||||
&-container {
|
||||
position: relative;
|
||||
|
||||
|
|
@ -834,14 +844,14 @@
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.example {
|
||||
.example {
|
||||
text-align: center;
|
||||
background: rgba(0, 0, 0, 0);
|
||||
border-radius: 4px;
|
||||
position: absolute;
|
||||
left: 50%;
|
||||
top: 50%;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
<a-tabs v-model:activeKey="activeKey" style="padding: 10px">
|
||||
<a-tab-pane key="1" tab="未读">
|
||||
<div style="width: 100%; text-align: right; ">
|
||||
<RouterLink target='_blank' to="/site/teacherYiyueMore">查看更多</RouterLink>
|
||||
<RouterLink target='_blank' to="/site/teacherWeiduMore">查看更多</RouterLink>
|
||||
</div>
|
||||
<div style="min-height: 70px">
|
||||
<a-row>
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
<a-layout-content>
|
||||
<a-card class="rowGutter" id="jcgkkDom">
|
||||
<template #title>
|
||||
<div style="font-size: 24px; font-weight: bold">已读信息</div>
|
||||
<div style="font-size: 24px; font-weight: bold">未读信息</div>
|
||||
</template>
|
||||
<a-row :gutter="[16, 16]" style="margin-top: 20px">
|
||||
<a-col v-for="(item, index) in listData" :key="index" :span="24">
|
||||
|
|
@ -17,7 +17,7 @@
|
|||
<div style="margin-top: 5px">{{ index + 1 }}、{{ item.content }}</div>
|
||||
</a-col>
|
||||
<a-col :span="2" style="text-align: right">
|
||||
<a-button type="primary" @click="openKecheng(item)" style="margin-left: 10px">已读</a-button>
|
||||
<a-button type="primary" @click="openKecheng(item)" style="margin-left: 10px">查看</a-button>
|
||||
</a-col>
|
||||
</a-row>
|
||||
</a-col>
|
||||
|
|
|
|||
|
|
@ -380,7 +380,7 @@ import { Input, Popover, Pagination, Empty, Affix as aAffix } from 'ant-design-v
|
|||
import { defHttp } from '/@/utils/http/axios';
|
||||
import { useMessage } from '/@/hooks/web/useMessage';
|
||||
import { useRouter } from 'vue-router';
|
||||
import { randomString, simpleDebounce, getFileAccessHttpUrl } from '/@/utils/common/compUtils';
|
||||
import { randomString, simpleDebounce, getFileAccessHttpUrl, baseApiUrl } from '/@/utils/common/compUtils';
|
||||
import { useFileList } from '/@/components/jeecg/comment/useComment';
|
||||
|
||||
import draggable from 'vuedraggable';
|
||||
|
|
@ -391,6 +391,11 @@ import stuIndex from './stuIndex.vue';
|
|||
import { downloadFile as ajaxDownloadFileFn } from '/@/api/common/api';
|
||||
import zykYylistPage from '/@/views/zyk/ZykInfoYinyongModal.vue';
|
||||
|
||||
import Base64 from 'crypto-js/enc-base64';
|
||||
import { dataURLtoBlob, urlToBase64 } from '/@/utils/file/base64Conver';
|
||||
import UTF8 from 'crypto-js/enc-utf8';
|
||||
import { encryptByBase64 } from '/@/utils/cipher';
|
||||
|
||||
const spinning = ref<boolean>(false);
|
||||
//当前路由信息
|
||||
const { currentRoute } = useRouter();
|
||||
|
|
@ -416,6 +421,8 @@ const videoOpen = ref<boolean>(false);
|
|||
const controls = ref(true);
|
||||
const autoplay = ref(false);
|
||||
const loop = ref(false);
|
||||
// 文件预览地址的domain 在后台配置的
|
||||
let onlinePreviewDomain = '';
|
||||
|
||||
const playVideoInFullscreen = async () => {
|
||||
console.log('💋', videoPlayer);
|
||||
|
|
@ -472,7 +479,7 @@ enum Api {
|
|||
delThree = '/teachingunitcontent/kcTeachingUnitContentThree/delete',
|
||||
}
|
||||
|
||||
function handleView(urlPath){
|
||||
function handleView(urlPath) {
|
||||
// var url = 'http://127.0.0.1:8080/file/test.txt'; //要预览文件的访问地址
|
||||
// window.open('http://127.0.0.1:8012/onlinePreview?url='+encodeURIComponent(base64Encode(url)));
|
||||
}
|
||||
|
|
@ -801,20 +808,47 @@ function editThreePage(two, three, threeIndex) {
|
|||
threePageData.value = { two, three, threeIndex };
|
||||
}
|
||||
|
||||
function viewThreePage(three) {
|
||||
async function viewThreePage(three) {
|
||||
console.log('🙇♂️', three);
|
||||
|
||||
if (three.value.type == 'video') {
|
||||
if (three.type == 'video') {
|
||||
handleVideo(three);
|
||||
} else if (three.value.type == 'document') {
|
||||
} else if (three.type == 'document') {
|
||||
// var file = 'https://kczxcs.nenu.edu.cn/jeecg-boot/temp/0731课程作业问题汇总_1722673666833.docx';
|
||||
// var file = baseApiUrl + "/"+three.filePath;
|
||||
// console.log('🤬', file);
|
||||
// let url = getFileAccessHttpUrl(encodeURIComponent(file));
|
||||
// var t2 = encryptByBase64(url);
|
||||
// window.open('https://fileview.jeecg.com/onlinePreview?url=' + encodeURIComponent(t2));
|
||||
|
||||
} else if (three.value.type == 'richText') {
|
||||
// var file = 'https://kczxcs.nenu.edu.cn/jeecg-boot/temp/ylhpsf.pdf';
|
||||
var file = baseApiUrl + "/"+three.filePath;
|
||||
console.log('🤬', file);
|
||||
// let url = getFileAccessHttpUrl(encodeURIComponent(file));
|
||||
// var t2 = encryptByBase64(url);
|
||||
window.open('https://fileview.jeecg.com/onlinePreview?url=' + encodeURIComponent(encryptByBase64(file)));
|
||||
|
||||
|
||||
} else if (three.type == 'richText') {
|
||||
threePageOpen.value = true;
|
||||
threePageDisableSubmit.value = true;
|
||||
threePageData.value = { three };
|
||||
}
|
||||
}
|
||||
|
||||
const getViewFileDomain = () => defHttp.get({ url: '/sys/comment/getFileViewDomain' });
|
||||
/**
|
||||
* 初始化domain
|
||||
*/
|
||||
async function initViewDomain() {
|
||||
if (!onlinePreviewDomain) {
|
||||
onlinePreviewDomain = await getViewFileDomain();
|
||||
}
|
||||
if (!onlinePreviewDomain.startsWith('http')) {
|
||||
onlinePreviewDomain = 'http://' + onlinePreviewDomain;
|
||||
}
|
||||
}
|
||||
|
||||
function delThree(e, two, three) {
|
||||
stop(e);
|
||||
delThreeFetch({ id: three.id }).then((res) => {
|
||||
|
|
|
|||
|
|
@ -213,12 +213,13 @@
|
|||
import { defHttp } from '/@/utils/http/axios';
|
||||
import { useMessage } from "/@/hooks/web/useMessage";
|
||||
import { useRouter } from 'vue-router';
|
||||
import { randomString, simpleDebounce, getFileAccessHttpUrl } from '/@/utils/common/compUtils'
|
||||
import { randomString, simpleDebounce, getFileAccessHttpUrl, baseApiUrl } from '/@/utils/common/compUtils'
|
||||
|
||||
import draggable from 'vuedraggable';
|
||||
import JUpload from '/@/components/Form/src/jeecg/components/JUpload/JUpload.vue';
|
||||
import JEditor from '/@/components/Form/src/jeecg/components/JEditor.vue';
|
||||
import downloadAssembly from '/@/views/zy/jiaoXueDanYuanNeiRong/downloadAssembly.vue';
|
||||
import { encryptByBase64 } from '/@/utils/cipher';
|
||||
|
||||
//当前路由信息
|
||||
const { currentRoute } = useRouter();
|
||||
|
|
@ -550,11 +551,19 @@ function handleVideo(three){
|
|||
}
|
||||
|
||||
function viewThreePage(three) {
|
||||
if (three.type == 'video') {
|
||||
handleVideo(three);
|
||||
} else if (three.type == 'document') {
|
||||
var file = baseApiUrl + "/"+three.filePath;
|
||||
window.open('https://fileview.jeecg.com/onlinePreview?url=' + encodeURIComponent(encryptByBase64(file)));
|
||||
} else if (three.type == 'richText') {
|
||||
threePageOpen.value = true;
|
||||
threePageDisableSubmit.value = true;
|
||||
threePageData.value = { three };
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function threePageHandleOk(){
|
||||
threePageOpen.value = false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@
|
|||
<a-col :span="24" class="zyCon">
|
||||
<span style="text-align: left;width:50%;display: block;float:left;">作业得分:{{ item.stuscore ? item.stuscore : '未评' }}分</span>
|
||||
<span style="text-align: right;width:50%;display: block;float:left;" class="wpopen" v-if="handleSfkshp(item)" @click="handleHpfs(item)">互评分数:{{ item.xshpfs ? item.xshpfs : '未评' }}分</span>
|
||||
<span style="text-align: left;width:50%;display: block;float:left;" v-if="handleSfkshp(item)">绩效分数:{{ item.jxfs ? item.jxfs : '未评' }}分</span>
|
||||
<span style="text-align: left;width:50%;display: block;float:left;" v-if="handleSfkshp(item)">互评奖励:{{ item.jxfs ? item.jxfs : '未评' }}分</span>
|
||||
<span style="text-align: right;width:50%;display: block;float:left;">总分:{{ item.zzdf ? item.zzdf : '未评' }}分</span>
|
||||
</a-col>
|
||||
<a-col :span="24" class="zyCon">
|
||||
|
|
|
|||
|
|
@ -113,7 +113,8 @@ d<template>
|
|||
<a-form-item label="作业要求" v-bind="validateInfos.content">
|
||||
<j-editor v-model:value="zyInfo.content" v-if="zyyqShow" @blur="handleZyyqShow(0)" />
|
||||
<div style="color: #777777" v-html="zyInfo.content" v-if="!zyyqShow"></div>
|
||||
<div @click="handleZyyqShow(1)"><span style="cursor: pointer; color: #18a689">温馨提示:点击可编辑作业要求</span></div>
|
||||
<div @click="handleZyyqShow(1)" class="tishi" v-if="zyInfo.xshpkg == '1'">温馨提示:点击可编辑作业要求</div>
|
||||
<!-- <div @click="handleZyyqShow(1)"><span style="cursor: pointer; color: #18a689">温馨提示:点击可编辑作业要求</span></div> -->
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="24">
|
||||
|
|
@ -143,6 +144,7 @@ d<template>
|
|||
<a-col :span="24">
|
||||
<div class="region">
|
||||
<div class="region-title">学生互评</div>
|
||||
<div style="float:right;margin-right:8px;" v-if="zyInfo.xshpkg == '1'"><span style="color:#18a689; cursor: pointer;" @click="handleHpsf">预览互评算法</span></div>
|
||||
<a-form-item label="学生互评">
|
||||
<div class="tishi" v-if="zyInfo.xshpkg == '1'">温馨提示:每份作业至少互评3次,每个学生互评5份作业</div>
|
||||
<j-dict-select-tag
|
||||
|
|
@ -183,7 +185,7 @@ d<template>
|
|||
style="margin-top: 15px"
|
||||
/> -->
|
||||
</a-form-item>
|
||||
<a-form-item label="互评开始时间" :labelCol="labelCol3" :wrapperCol="wrapperCol3">
|
||||
<a-form-item label="互评开始时间" :labelCol="labelCol2" :wrapperCol="wrapperCol2">
|
||||
<a-date-picker
|
||||
placeholder="请选择互评开始时间"
|
||||
v-model:value="zyInfo.xshpkssj"
|
||||
|
|
@ -194,7 +196,7 @@ d<template>
|
|||
style="width: 100%"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="互评结束时间" :labelCol="labelCol3" :wrapperCol="wrapperCol3">
|
||||
<a-form-item label="互评结束时间" :labelCol="labelCol2" :wrapperCol="wrapperCol2">
|
||||
<a-date-picker
|
||||
placeholder="请选择互评结束时间"
|
||||
v-model:value="zyInfo.xshpjssj"
|
||||
|
|
@ -249,7 +251,7 @@ d<template>
|
|||
</a-form-item>
|
||||
</div>
|
||||
</a-col>
|
||||
<a-col :span="24" style="text-align: left; margin-top: 10px; margin-bottom: 40px; margin-left: 140px">
|
||||
<a-col :span="24" style="text-align: center; margin-top: 10px; margin-bottom: 40px; ">
|
||||
<a-button type="primary" @click="submitForm">保存</a-button>
|
||||
<a-button type="primary" @click="reloadZy" style="margin-left: 15px">返回</a-button>
|
||||
</a-col>
|
||||
|
|
@ -1154,7 +1156,7 @@ const columnsCcjg = [
|
|||
},
|
||||
},
|
||||
{
|
||||
title: '查重率',
|
||||
title: '查重率(%)',
|
||||
dataIndex: 'percentage',
|
||||
key: 'percentage',
|
||||
},
|
||||
|
|
|
|||
|
|
@ -94,7 +94,7 @@ export const newcolumns: BasicColumn[] = [
|
|||
slots: { customRender: 'xshpfsaction' },
|
||||
},
|
||||
{
|
||||
title: '绩效分',
|
||||
title: '互评奖励',
|
||||
align: "center",
|
||||
dataIndex: 'jxzf',
|
||||
},
|
||||
|
|
|
|||
|
|
@ -1,6 +1,11 @@
|
|||
<template>
|
||||
<div style="background: #fff; margin: 10px 0;padding:10px;">
|
||||
<div style="text-align: right;width:100%;"><a-button type="primary" @click="handleback">返回</a-button></div>
|
||||
<div style="width:100%;">
|
||||
<a-row>
|
||||
<a-col :span="12" style="text-align: left;"><span style="color:#18a689; cursor: pointer;" @click="handleHpsf">预览互评算法</span></a-col>
|
||||
<a-col :span="12" style="text-align: right;"><a-button type="primary" @click="handleback">返回</a-button></a-col>
|
||||
</a-row>
|
||||
</div>
|
||||
<a-tabs v-model:activeKey="activeKey" @change="handleChange">
|
||||
<a-tab-pane key="1" tab="待互评">
|
||||
<ZyInfoStudentHpList ref="dhpPage"/>
|
||||
|
|
@ -20,9 +25,12 @@ import { ref, reactive, onMounted, unref } from 'vue';
|
|||
import ZyInfoStudentHpList from '/@/views/zy/zyInfoStudentHp/ZyInfoStudentHpList.vue'
|
||||
import ZyInfoStudentHpYpyList from '/@/views/zy/zyInfoStudentHp/ZyInfoStudentHpYpyList.vue'
|
||||
import ZyInfoStudentHpMyhpfsList from '/@/views/zy/zyInfoStudentHp/ZyInfoStudentHpMyhpfsList.vue'
|
||||
import { useGlobSetting } from '/@/hooks/setting';
|
||||
|
||||
import { useRouter } from 'vue-router';
|
||||
import { defHttp } from '/@/utils/http/axios';
|
||||
const globSetting = useGlobSetting();
|
||||
const baseApiUrl = globSetting.domainUrl;
|
||||
var activeKey = ref('1');
|
||||
const dhpPage = ref();
|
||||
const yhpPage = ref();
|
||||
|
|
@ -42,6 +50,14 @@ function handleChange(record) {
|
|||
wdhpPage.value.reload();
|
||||
}
|
||||
}
|
||||
|
||||
//预览互评算法
|
||||
function handleHpsf(){
|
||||
// openByUrl({url:'/downPath/ylhpsf.pdf',target: '_blank',fileName:'算法说明.pdf'})
|
||||
// window.open(pdfUrl.value, '_blank');
|
||||
// window.open(require('../../../downPath/ylhpsf.pdf'), '_blank');
|
||||
window.open(baseApiUrl+'/temp/ylhpsf.pdf');
|
||||
}
|
||||
function handleback(){
|
||||
var href = "/stuzy/studentDqzy";
|
||||
router.push({path:href,query: {rwbh,xqxn,type,teano}});
|
||||
|
|
|
|||
Loading…
Reference in New Issue