|
|
@@ -112,7 +112,7 @@ import Up from "@/api/upload";
|
|
|
import utils from "@/utils/utils";
|
|
|
import { DeleteOutlined, FileOutlined, FileTextOutlined, PlayCircleOutlined, LeftOutlined, RightOutlined } from "@ant-design/icons-vue";
|
|
|
import { Empty } from "ant-design-vue";
|
|
|
-const emit = defineEmits(['allUploadSuccess']);
|
|
|
+const emit = defineEmits(['allUploadSuccess', 'uploadSuccess']);
|
|
|
|
|
|
const simpleImage = Empty.PRESENTED_IMAGE_SIMPLE;
|
|
|
|
|
|
@@ -410,6 +410,7 @@ function beforeUpload(file) {
|
|
|
|
|
|
const uploadItem = reactive({
|
|
|
uploadId: `${Date.now()}_${Math.random().toString(36).slice(2)}`,
|
|
|
+ uploadOrder: ++uploadOrderCounter, // 上传顺序号
|
|
|
document: file.name,
|
|
|
postfix: ext,
|
|
|
fileType: inferFileType(ext, type),
|
|
|
@@ -434,8 +435,10 @@ function beforeUpload(file) {
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
-// 全局待上传计数,用于精确判断“所有文件都已处理完毕”
|
|
|
+// 全局待上传计数,用于精确判断"所有文件都已处理完毕"
|
|
|
let pendingUploadCount = 0;
|
|
|
+// 全局上传顺序计数器,用于保证批量上传时的顺序
|
|
|
+let uploadOrderCounter = 0;
|
|
|
|
|
|
// 实际上传逻辑
|
|
|
async function performUpload(uploadItem, file) {
|
|
|
@@ -487,8 +490,19 @@ async function performUpload(uploadItem, file) {
|
|
|
});
|
|
|
if (feedback.code != 1) throw new Error(feedback.msg || '上传结果确认失败');
|
|
|
|
|
|
+ // 尝试从 uploadSuccess 返回的各种可能字段获取 linksid
|
|
|
+ const feedbackData = feedback.data || {};
|
|
|
+ if (feedbackData.linksid) {
|
|
|
+ uploadItem.linksid = feedbackData.linksid;
|
|
|
+ } else if (feedbackData.attachmentids && feedbackData.attachmentids[0]) {
|
|
|
+ uploadItem.attachmentid = feedbackData.attachmentids[0];
|
|
|
+ uploadItem.linksid = feedbackData.attachmentids[0];
|
|
|
+ } else if (feedbackData.attachmentid) {
|
|
|
+ uploadItem.linksid = feedbackData.attachmentid;
|
|
|
+ }
|
|
|
+
|
|
|
if (uploadItem.ownertable != 'sat_sharematerial') {
|
|
|
- const attachmentid = feedback.data.attachmentids[0];
|
|
|
+ const attachmentid = feedbackData.attachmentids ? feedbackData.attachmentids[0] : feedbackData.attachmentid;
|
|
|
const binding = await Api.requested({
|
|
|
id: 20240407135802,
|
|
|
content: {
|
|
|
@@ -498,6 +512,10 @@ async function performUpload(uploadItem, file) {
|
|
|
},
|
|
|
});
|
|
|
if (binding.code != 1) throw new Error(binding.msg || '附件绑定失败');
|
|
|
+ // 绑定接口也可能返回 linksid
|
|
|
+ if (binding.data && binding.data.linksid) {
|
|
|
+ uploadItem.linksid = binding.data.linksid;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
uploadItem.status = 'done';
|
|
|
@@ -514,10 +532,20 @@ async function performUpload(uploadItem, file) {
|
|
|
|
|
|
// 检查是否全部上传完成(等待所有 pending 任务结束,并给后端落库预留时间)
|
|
|
let dowmTime = null;
|
|
|
-const checkAllUploadComplete = () => {
|
|
|
+const checkAllUploadComplete = async () => {
|
|
|
clearTimeout(dowmTime);
|
|
|
- dowmTime = setTimeout(() => {
|
|
|
+ dowmTime = setTimeout(async () => {
|
|
|
if (pendingUploadCount === 0 && !list.value.some((v) => v.status === 'uploading')) {
|
|
|
+ const invalidLinksidItems = list.value.filter(v => v.linksid === -1 || !v.linksid);
|
|
|
+
|
|
|
+ if (invalidLinksidItems.length > 0) {
|
|
|
+ dowmTime = setTimeout(() => checkAllUploadComplete(), 1000);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ const uploadedCount = list.value.filter(v => v.status === 'done' && v.uploadOrder).length;
|
|
|
+
|
|
|
+ emit('uploadSuccess', { uploadedCount });
|
|
|
emit('allUploadSuccess');
|
|
|
}
|
|
|
}, 1500);
|
|
|
@@ -570,9 +598,7 @@ function init(attinfos, pic = props.pic) {
|
|
|
setSequenceAll();
|
|
|
}
|
|
|
}
|
|
|
-function addImage() {
|
|
|
- console.log("添加图片");
|
|
|
-}
|
|
|
+function addImage() { }
|
|
|
|
|
|
let linksid = ref(null);
|
|
|
|