Browse Source

feat:[模板管理][上传附件调试]

lkf
luojie 2 months ago
parent
commit
efa25e8b96
1 changed files with 99 additions and 16 deletions
  1. +99
    -16
      src/components/Template/HandleFormItem.vue

+ 99
- 16
src/components/Template/HandleFormItem.vue View File

@ -55,7 +55,6 @@
<el-upload ref="uploadRef" class="upload-demo" :action="uploadFileUrl" :on-preview="handlePreview"
:headers="headers"
:before-remove="beforeRemove"
:before-upload="beforeUpload"
:on-remove="handleRemove" multiple :limit="10"
:on-success="handleSuccess"
:on-change="handleChange"
@ -214,6 +213,8 @@ export default {
headers: {
Authorization: "Bearer " + getToken(),
},
pendingUploadFile: null, //
pendingRemoveFile: null, //
}
},
watch: {
@ -257,13 +258,7 @@ export default {
this.selectRegentInfo = data;
console.log(data,"yq")
},
beforeUpload(file){
return false;
},
// //
// beforeRemove(file) {
// return this.$confirm(` ${file.name} `)
// },
//
handleChange(file, fileList) {
// statusready
@ -294,7 +289,25 @@ export default {
return
}
//
//
const existingFiles = fileList.filter(f => f !== file && f.status === 'success');
if (existingFiles.length > 0) {
//
this.pendingUploadFile = file;
// fileList
const index = fileList.indexOf(file);
if (index > -1) {
fileList.splice(index, 1);
}
this.fileList = [...fileList];
//
EventBus.$emit('showEditSignDialog', { uuid: this.uuid });
return;
}
//
this.$nextTick(() => {
// upload
const uploadComponent = this.$refs.uploadRef;
@ -338,20 +351,50 @@ export default {
})
return list;
},
//
beforeRemove(file) {
//
//
this.pendingRemoveFile = { file, fileList: this.fileList };
//
EventBus.$emit('showEditSignDialog', { uuid: this.uuid });
// false
return false;
},
handleRemove(file, fileList) {
//
// on-removebefore-removefalse
// executeRemove
// executeRemove
},
//
executeRemove(file, fileList) {
// el-uploaduploadFiles
const uploadComponent = this.$refs.uploadRef;
if (uploadComponent && uploadComponent.uploadFiles) {
const uploadFileIndex = uploadComponent.uploadFiles.indexOf(file);
if (uploadFileIndex > -1) {
uploadComponent.uploadFiles.splice(uploadFileIndex, 1);
}
}
// fileList
const index = fileList.indexOf(file);
if (index > -1) {
fileList.splice(index, 1);
}
// fileList
this.fileList = [...fileList];
// inputValue
this.inputValue = JSON.stringify(this.getFileList(fileList));
this.$emit("change",this.inputValue)
this.$emit("change", this.inputValue);
//
this.onCommonHandleSaveRecord();
this.$message.success(`文件 ${file.name} 已移除`);
},
handlePreview(file) {
@ -456,7 +499,17 @@ export default {
//
handleEditSignCancel(data) {
if (data.uuid === this.uuid) {
this.resetRecord();
//
if (this.pendingUploadFile) {
this.pendingUploadFile = null;
this.$message.info('已取消文件上传');
} else if (this.pendingRemoveFile) {
//
this.pendingRemoveFile = null;
this.$message.info('已取消文件删除');
} else {
this.resetRecord();
}
}
},
//
@ -466,7 +519,37 @@ export default {
}
},
onEditSignSave(data) {
this.handleUpdateRecord(data)
//
if (this.pendingUploadFile) {
//
const file = this.pendingUploadFile;
// fileList
this.fileList.push(file);
//
this.pendingUploadFile = null;
//
this.$nextTick(() => {
const uploadComponent = this.$refs.uploadRef;
if (uploadComponent) {
uploadComponent.submit();
}
});
} else if (this.pendingRemoveFile) {
//
const { file, fileList } = this.pendingRemoveFile;
//
this.pendingRemoveFile = null;
//
this.executeRemove(file, fileList);
} else {
// /
this.handleUpdateRecord(data);
}
},
getChecked() {
return !!this.getFieldCheckObj()[this.fieldKey]?.checked;

Loading…
Cancel
Save