|
|
@ -55,7 +55,6 @@ |
|
|
<el-upload ref="uploadRef" class="upload-demo" :action="uploadFileUrl" :on-preview="handlePreview" |
|
|
<el-upload ref="uploadRef" class="upload-demo" :action="uploadFileUrl" :on-preview="handlePreview" |
|
|
:headers="headers" |
|
|
:headers="headers" |
|
|
:before-remove="beforeRemove" |
|
|
:before-remove="beforeRemove" |
|
|
:before-upload="beforeUpload" |
|
|
|
|
|
:on-remove="handleRemove" multiple :limit="10" |
|
|
:on-remove="handleRemove" multiple :limit="10" |
|
|
:on-success="handleSuccess" |
|
|
:on-success="handleSuccess" |
|
|
:on-change="handleChange" |
|
|
:on-change="handleChange" |
|
|
@ -214,6 +213,8 @@ export default { |
|
|
headers: { |
|
|
headers: { |
|
|
Authorization: "Bearer " + getToken(), |
|
|
Authorization: "Bearer " + getToken(), |
|
|
}, |
|
|
}, |
|
|
|
|
|
pendingUploadFile: null, // 用于存储待上传的文件 |
|
|
|
|
|
pendingRemoveFile: null, // 用于存储待删除的文件 |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
watch: { |
|
|
watch: { |
|
|
@ -257,13 +258,7 @@ export default { |
|
|
this.selectRegentInfo = data; |
|
|
this.selectRegentInfo = data; |
|
|
console.log(data,"yq") |
|
|
console.log(data,"yq") |
|
|
}, |
|
|
}, |
|
|
beforeUpload(file){ |
|
|
|
|
|
return false; |
|
|
|
|
|
}, |
|
|
|
|
|
// // 删除前确认 |
|
|
|
|
|
// beforeRemove(file) { |
|
|
|
|
|
// return this.$confirm(`确定移除 ${file.name} ?`) |
|
|
|
|
|
// }, |
|
|
|
|
|
|
|
|
|
|
|
// 文件状态改变时的钩子,添加文件、上传成功、上传失败时都会被调用 |
|
|
// 文件状态改变时的钩子,添加文件、上传成功、上传失败时都会被调用 |
|
|
handleChange(file, fileList) { |
|
|
handleChange(file, fileList) { |
|
|
// 如果是新添加的文件(status为ready),进行验证 |
|
|
// 如果是新添加的文件(status为ready),进行验证 |
|
|
@ -294,7 +289,25 @@ export default { |
|
|
return |
|
|
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(() => { |
|
|
this.$nextTick(() => { |
|
|
// 找到对应的upload组件并提交 |
|
|
// 找到对应的upload组件并提交 |
|
|
const uploadComponent = this.$refs.uploadRef; |
|
|
const uploadComponent = this.$refs.uploadRef; |
|
|
@ -338,20 +351,50 @@ export default { |
|
|
}) |
|
|
}) |
|
|
return list; |
|
|
return list; |
|
|
}, |
|
|
}, |
|
|
|
|
|
// 删除前验证电子签名 |
|
|
|
|
|
beforeRemove(file) { |
|
|
|
|
|
// 所有删除操作都需要验证电子签名 |
|
|
|
|
|
// 保存待删除的文件信息 |
|
|
|
|
|
this.pendingRemoveFile = { file, fileList: this.fileList }; |
|
|
|
|
|
|
|
|
|
|
|
// 触发电子签名弹窗 |
|
|
|
|
|
EventBus.$emit('showEditSignDialog', { uuid: this.uuid }); |
|
|
|
|
|
|
|
|
|
|
|
// 返回false阻止默认删除行为,等待签名验证通过后再删除 |
|
|
|
|
|
return false; |
|
|
|
|
|
}, |
|
|
handleRemove(file, fileList) { |
|
|
handleRemove(file, fileList) { |
|
|
// 从列表中移除文件 |
|
|
|
|
|
|
|
|
// on-remove事件在before-remove返回false时不会触发 |
|
|
|
|
|
// 这个方法在签名验证通过后通过executeRemove调用 |
|
|
|
|
|
// 这里不需要额外处理,因为executeRemove已经处理了删除逻辑 |
|
|
|
|
|
}, |
|
|
|
|
|
// 执行实际的文件删除操作 |
|
|
|
|
|
executeRemove(file, fileList) { |
|
|
|
|
|
// 从el-upload的内部uploadFiles中移除文件 |
|
|
|
|
|
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); |
|
|
const index = fileList.indexOf(file); |
|
|
if (index > -1) { |
|
|
if (index > -1) { |
|
|
fileList.splice(index, 1); |
|
|
fileList.splice(index, 1); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 更新fileList |
|
|
|
|
|
this.fileList = [...fileList]; |
|
|
|
|
|
|
|
|
// 更新inputValue为剩余文件路径列表 |
|
|
// 更新inputValue为剩余文件路径列表 |
|
|
this.inputValue = JSON.stringify(this.getFileList(fileList)); |
|
|
this.inputValue = JSON.stringify(this.getFileList(fileList)); |
|
|
this.$emit("change",this.inputValue) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.$emit("change", this.inputValue); |
|
|
|
|
|
|
|
|
// 触发保存记录 |
|
|
// 触发保存记录 |
|
|
this.onCommonHandleSaveRecord(); |
|
|
this.onCommonHandleSaveRecord(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.$message.success(`文件 ${file.name} 已移除`); |
|
|
this.$message.success(`文件 ${file.name} 已移除`); |
|
|
}, |
|
|
}, |
|
|
handlePreview(file) { |
|
|
handlePreview(file) { |
|
|
@ -456,7 +499,17 @@ export default { |
|
|
// 处理电子签名取消事件 |
|
|
// 处理电子签名取消事件 |
|
|
handleEditSignCancel(data) { |
|
|
handleEditSignCancel(data) { |
|
|
if (data.uuid === this.uuid) { |
|
|
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) { |
|
|
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() { |
|
|
getChecked() { |
|
|
return !!this.getFieldCheckObj()[this.fieldKey]?.checked; |
|
|
return !!this.getFieldCheckObj()[this.fieldKey]?.checked; |
|
|
|