|
|
|
@ -135,9 +135,9 @@
|
|
|
|
|
<!-- 预览区域(选中后显示) -->
|
|
|
|
|
<div v-else class="h-full flex flex-col items-center justify-center p-3">
|
|
|
|
|
<img :src="previewUrl" alt="预览图" class="max-h-full max-w-full object-cover rounded-lg mb-2" style="max-height: 200px;">
|
|
|
|
|
<!-- <button type="button" @click="clearFile" class="text-xs text-red-500 hover:text-red-700">-->
|
|
|
|
|
<!-- <i class="fa-solid fa-times-circle mr-1"></i> 移除-->
|
|
|
|
|
<!-- </button>-->
|
|
|
|
|
<!-- <button type="button" @click="clearFile" class="text-xs text-red-500 hover:text-red-700">-->
|
|
|
|
|
<!-- <i class="fa-solid fa-times-circle mr-1"></i> 移除-->
|
|
|
|
|
<!-- </button>-->
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
@ -287,19 +287,19 @@
|
|
|
|
|
<i class="fa-solid fa-download mr-2"></i> 下载PDF
|
|
|
|
|
</a>
|
|
|
|
|
<!-- 结果区域 -->
|
|
|
|
|
<!-- <div class="bg-white rounded-xl shadow-soft p-6 mb-8 transform hover:shadow-lg transition-all duration-300">-->
|
|
|
|
|
<!-- <div class="flex items-start">-->
|
|
|
|
|
<!-- <div class="ml-4">-->
|
|
|
|
|
<!-- <h3 class="text-lg font-medium text-gray-800">PDF生成成功</h3>-->
|
|
|
|
|
<!-- <div class="mt-4 flex flex-wrap gap-3">-->
|
|
|
|
|
<!-- -->
|
|
|
|
|
<!-- <button @click="showResult = false" class="inline-flex items-center px-4 py-2 border border-gray-300 text-sm font-medium rounded-md shadow-sm text-gray-700 bg-white hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-primary transition-colors duration-200">-->
|
|
|
|
|
<!-- <i class="fa-solid fa-times mr-2"></i> 关闭-->
|
|
|
|
|
<!-- </button>-->
|
|
|
|
|
<!-- </div>-->
|
|
|
|
|
<!-- </div>-->
|
|
|
|
|
<!-- </div>-->
|
|
|
|
|
<!-- </div>-->
|
|
|
|
|
<!-- <div class="bg-white rounded-xl shadow-soft p-6 mb-8 transform hover:shadow-lg transition-all duration-300">-->
|
|
|
|
|
<!-- <div class="flex items-start">-->
|
|
|
|
|
<!-- <div class="ml-4">-->
|
|
|
|
|
<!-- <h3 class="text-lg font-medium text-gray-800">PDF生成成功</h3>-->
|
|
|
|
|
<!-- <div class="mt-4 flex flex-wrap gap-3">-->
|
|
|
|
|
<!-- -->
|
|
|
|
|
<!-- <button @click="showResult = false" class="inline-flex items-center px-4 py-2 border border-gray-300 text-sm font-medium rounded-md shadow-sm text-gray-700 bg-white hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-primary transition-colors duration-200">-->
|
|
|
|
|
<!-- <i class="fa-solid fa-times mr-2"></i> 关闭-->
|
|
|
|
|
<!-- </button>-->
|
|
|
|
|
<!-- </div>-->
|
|
|
|
|
<!-- </div>-->
|
|
|
|
|
<!-- </div>-->
|
|
|
|
|
<!-- </div>-->
|
|
|
|
|
</div>
|
|
|
|
|
</form>
|
|
|
|
|
<h4 class="form-header h4">材料上传</h4>
|
|
|
|
@ -451,57 +451,59 @@
|
|
|
|
|
prefix: ctx + "system/applyList",
|
|
|
|
|
},
|
|
|
|
|
computed: {
|
|
|
|
|
previewUrl() {
|
|
|
|
|
previewUrl: function() {
|
|
|
|
|
return this.selectedFile ? window.URL.createObjectURL(this.selectedFile) : '';
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
methods: {
|
|
|
|
|
handleFileUpload(event) {
|
|
|
|
|
let file = event.target.files[0];
|
|
|
|
|
handleFileUpload: function(event) {
|
|
|
|
|
var self = this;
|
|
|
|
|
var file = event.target.files[0];
|
|
|
|
|
if (file) {
|
|
|
|
|
// 检查文件类型和大小
|
|
|
|
|
let fileSize = file.size / 1024 / 1024; // MB
|
|
|
|
|
var fileSize = file.size / 1024 / 1024; // MB
|
|
|
|
|
if (fileSize > 2) {
|
|
|
|
|
this.$message.error('文件大小不能超过2MB');
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
let fileType = file.type;
|
|
|
|
|
var fileType = file.type;
|
|
|
|
|
if (!fileType.startsWith('image/')) {
|
|
|
|
|
this.$message.error('请上传图片文件');
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
// 验证图片格式
|
|
|
|
|
let validFormats = ['image/jpeg', 'image/png'];
|
|
|
|
|
if (!validFormats.includes(fileType)) {
|
|
|
|
|
var validFormats = ['image/jpeg', 'image/png'];
|
|
|
|
|
if (validFormats.indexOf(fileType) === -1) {
|
|
|
|
|
this.$message.error('请上传JPG或PNG格式的图片');
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
// 验证图片尺寸是否接近一寸照片 (2.5cm x 3.5cm, 约295x413像素)
|
|
|
|
|
let img = new Image();
|
|
|
|
|
var img = new Image();
|
|
|
|
|
img.src = window.URL.createObjectURL(file);
|
|
|
|
|
img.onload = () => {
|
|
|
|
|
let width = img.naturalWidth;
|
|
|
|
|
let height = img.naturalHeight;
|
|
|
|
|
let ratio = width / height;
|
|
|
|
|
img.onload = function() {
|
|
|
|
|
var width = img.naturalWidth;
|
|
|
|
|
var height = img.naturalHeight;
|
|
|
|
|
var ratio = width / height;
|
|
|
|
|
// 检查宽高比是否接近一寸照片的比例 (约0.714)
|
|
|
|
|
if (Math.abs(ratio - 0.714) > 0.1) {
|
|
|
|
|
this.$message({
|
|
|
|
|
self.$message({
|
|
|
|
|
message: '建议上传一寸照片尺寸 (约295x413像素)',
|
|
|
|
|
type: 'warning'
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
this.selectedFile = file;
|
|
|
|
|
self.selectedFile = file;
|
|
|
|
|
};
|
|
|
|
|
img.onerror = () => {
|
|
|
|
|
this.$message.error('无法加载图片,请重新选择');
|
|
|
|
|
img.onerror = function() {
|
|
|
|
|
self.$message.error('无法加载图片,请重新选择');
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
clearFile() {
|
|
|
|
|
clearFile: function() {
|
|
|
|
|
this.selectedFile = null;
|
|
|
|
|
document.getElementById('photo').value = '';
|
|
|
|
|
},
|
|
|
|
|
submitForm() {
|
|
|
|
|
submitForm: function() {
|
|
|
|
|
var self = this;
|
|
|
|
|
// 简单验证
|
|
|
|
|
if (!this.formData.name || !this.formData.sex || !this.formData.nationa || !this.formData.nationality || !this.formData.maritalStatus || !this.formData.political || !this.formData.phone || !this.formData.cerno || !this.formData.address || !this.formData.registeredAuthority || !this.formData.permanentAddress || !this.formData.residentBureau || !this.formData.positionCapacity || !this.formData.smPost || !this.formData.smGrade) {
|
|
|
|
|
this.$message({
|
|
|
|
@ -519,7 +521,7 @@
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
// 准备表单数据
|
|
|
|
|
let formData = new FormData();
|
|
|
|
|
var formData = new FormData();
|
|
|
|
|
if (this.formData.name) formData.append("name", this.formData.name);
|
|
|
|
|
if (this.formData.sex) formData.append("sex", this.formData.sex);
|
|
|
|
|
if (this.formData.nationa) formData.append("nationa", this.formData.nationa);
|
|
|
|
@ -543,65 +545,66 @@
|
|
|
|
|
axios.post('/api/pdf/fill', formData, {
|
|
|
|
|
responseType: 'blob'
|
|
|
|
|
})
|
|
|
|
|
.then(response => {
|
|
|
|
|
.then(function(response) {
|
|
|
|
|
// 创建下载URL
|
|
|
|
|
let blob = new Blob([response.data], { type: 'application/pdf' });
|
|
|
|
|
this.pdfUrl = window.URL.createObjectURL(blob);
|
|
|
|
|
this.$message.success('生成pdf成功,请点击下载!');
|
|
|
|
|
var blob = new Blob([response.data], { type: 'application/pdf' });
|
|
|
|
|
self.pdfUrl = window.URL.createObjectURL(blob);
|
|
|
|
|
self.$message.success('生成pdf成功,请点击下载!');
|
|
|
|
|
// 隐藏加载状态,显示结果
|
|
|
|
|
this.isLoading = false;
|
|
|
|
|
this.showResult = true;
|
|
|
|
|
self.isLoading = false;
|
|
|
|
|
self.showResult = true;
|
|
|
|
|
})
|
|
|
|
|
.catch(error => {
|
|
|
|
|
.catch(function(error) {
|
|
|
|
|
console.error('Error:', error);
|
|
|
|
|
this.isLoading = false;
|
|
|
|
|
this.$message.error('生成PDF时出错,请重试');
|
|
|
|
|
self.isLoading = false;
|
|
|
|
|
self.$message.error('生成PDF时出错,请重试');
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
// 新增文件上传相关方法
|
|
|
|
|
handleFileSelection(event) {
|
|
|
|
|
handleFileSelection: function(event) {
|
|
|
|
|
this.selectedFiles = event.target.files;
|
|
|
|
|
if (this.selectedFiles && this.selectedFiles.length > 0) {
|
|
|
|
|
// 只处理第一个文件
|
|
|
|
|
let file = this.selectedFiles[0];
|
|
|
|
|
var file = this.selectedFiles[0];
|
|
|
|
|
// 检查文件类型
|
|
|
|
|
let fileExtension = file.name.split('.').pop().toLowerCase();
|
|
|
|
|
let validExtensions = ['pdf', 'doc', 'docx', 'jpg', 'jpeg', 'png', 'gif', 'bmp'];
|
|
|
|
|
if (!validExtensions.includes(fileExtension)) {
|
|
|
|
|
var fileExtension = file.name.split('.').pop().toLowerCase();
|
|
|
|
|
var validExtensions = ['pdf', 'doc', 'docx', 'jpg', 'jpeg', 'png', 'gif', 'bmp'];
|
|
|
|
|
if (validExtensions.indexOf(fileExtension) === -1) {
|
|
|
|
|
this.$message.error('请上传PDF、Word文档或图片文件');
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
this.uploadFile(file);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
uploadFile(file) {
|
|
|
|
|
uploadFile: function(file) {
|
|
|
|
|
var self = this;
|
|
|
|
|
this.currentFileName = file.name;
|
|
|
|
|
this.uploadProgress = 0;
|
|
|
|
|
|
|
|
|
|
let formData = new FormData();
|
|
|
|
|
var formData = new FormData();
|
|
|
|
|
formData.append('applyId', this.formData.applyId || '');
|
|
|
|
|
formData.append('filename', file.name);
|
|
|
|
|
formData.append('fileCode', 'bm_user_audit_001');
|
|
|
|
|
formData.append('file', file);
|
|
|
|
|
|
|
|
|
|
axios.post(ctx + 'system/file/upload', formData, {
|
|
|
|
|
onUploadProgress: (progressEvent) => {
|
|
|
|
|
this.uploadProgress = Math.round((progressEvent.loaded * 100) / progressEvent.total);
|
|
|
|
|
onUploadProgress: function(progressEvent) {
|
|
|
|
|
self.uploadProgress = Math.round((progressEvent.loaded * 100) / progressEvent.total);
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
.then(response => {
|
|
|
|
|
.then(function(response) {
|
|
|
|
|
if (response.data.code === web_status.SUCCESS) {
|
|
|
|
|
// 显示上传成功提示
|
|
|
|
|
this.uploadSuccess = true;
|
|
|
|
|
this.uploadSuccessMessage = `文件 "${file.name}" 上传成功`;
|
|
|
|
|
self.uploadSuccess = true;
|
|
|
|
|
self.uploadSuccessMessage = '文件 "' + file.name + '" 上传成功';
|
|
|
|
|
|
|
|
|
|
// 3秒后隐藏提示
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
this.uploadSuccess = false;
|
|
|
|
|
setTimeout(function() {
|
|
|
|
|
self.uploadSuccess = false;
|
|
|
|
|
}, 3000);
|
|
|
|
|
|
|
|
|
|
// 更新文件列表
|
|
|
|
|
let fileInfo = {
|
|
|
|
|
var fileInfo = {
|
|
|
|
|
id: response.data.data.fileId,
|
|
|
|
|
fileName: file.name,
|
|
|
|
|
fileSize: file.size,
|
|
|
|
@ -609,43 +612,45 @@
|
|
|
|
|
fileUrl: response.data.data.filePath,
|
|
|
|
|
uploadTime: new Date().toISOString()
|
|
|
|
|
};
|
|
|
|
|
this.uploadedFiles.push(fileInfo);
|
|
|
|
|
self.uploadedFiles.push(fileInfo);
|
|
|
|
|
|
|
|
|
|
// 重置选择框
|
|
|
|
|
document.getElementById('fileUpload').value = '';
|
|
|
|
|
} else {
|
|
|
|
|
this.$message.error(`上传失败: ${response.data.msg}`);
|
|
|
|
|
self.$message.error('上传失败: ' + response.data.msg);
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
.catch(error => {
|
|
|
|
|
.catch(function(error) {
|
|
|
|
|
console.error('上传错误:', error);
|
|
|
|
|
this.$message.error('上传过程中发生错误');
|
|
|
|
|
self.$message.error('上传过程中发生错误');
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
downloadFile(file) {
|
|
|
|
|
downloadFile: function(file) {
|
|
|
|
|
var self = this;
|
|
|
|
|
// 直接通过接口下载
|
|
|
|
|
axios.get(ctx + 'system/file/download',{
|
|
|
|
|
axios.get(ctx + 'system/file/download', {
|
|
|
|
|
params: { fileId: file.id },
|
|
|
|
|
responseType: 'blob', // 重要:指定响应类型为blob
|
|
|
|
|
headers: {
|
|
|
|
|
'Content-Type': 'application/json',
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
.then(response => {
|
|
|
|
|
let url = window.URL.createObjectURL(new Blob([response.data]));
|
|
|
|
|
let link = document.createElement('a');
|
|
|
|
|
.then(function(response) {
|
|
|
|
|
var url = window.URL.createObjectURL(new Blob([response.data]));
|
|
|
|
|
var link = document.createElement('a');
|
|
|
|
|
link.href = url;
|
|
|
|
|
link.setAttribute('download', file.fileName);
|
|
|
|
|
document.body.appendChild(link);
|
|
|
|
|
link.click();
|
|
|
|
|
document.body.removeChild(link);
|
|
|
|
|
})
|
|
|
|
|
.catch(error => {
|
|
|
|
|
.catch(function(error) {
|
|
|
|
|
console.error('下载错误:', error);
|
|
|
|
|
this.$message.error('下载文件时出错');
|
|
|
|
|
self.$message.error('下载文件时出错');
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
submitHandler() {
|
|
|
|
|
submitHandler: function() {
|
|
|
|
|
var self = this;
|
|
|
|
|
if (this.uploadedFiles.length == 0) {
|
|
|
|
|
this.$message.warning('请上传所需材料');
|
|
|
|
|
return;
|
|
|
|
@ -655,53 +660,55 @@
|
|
|
|
|
confirmButtonText: '确定',
|
|
|
|
|
cancelButtonText: '取消',
|
|
|
|
|
type: 'warning'
|
|
|
|
|
}).then(() => {
|
|
|
|
|
$.operate.saveTab(`${this.prefix}/submit?applyId=${this.formData.applyId}`);
|
|
|
|
|
}).catch(() => {
|
|
|
|
|
this.$message({
|
|
|
|
|
}).then(function() {
|
|
|
|
|
$.operate.saveTab(self.prefix + '/submit?applyId=' + self.formData.applyId);
|
|
|
|
|
}).catch(function() {
|
|
|
|
|
self.$message({
|
|
|
|
|
type: 'info',
|
|
|
|
|
message: '已取消'
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
deleteFile(file, index) {
|
|
|
|
|
this.$confirm(`确定要删除文件 "${file.fileName}" 吗?`, '提示', {
|
|
|
|
|
deleteFile: function(file, index) {
|
|
|
|
|
var self = this;
|
|
|
|
|
this.$confirm('确定要删除文件 "' + file.fileName + '" 吗?', '提示', {
|
|
|
|
|
confirmButtonText: '确定',
|
|
|
|
|
cancelButtonText: '取消',
|
|
|
|
|
type: 'warning'
|
|
|
|
|
}).then(() => {
|
|
|
|
|
}).then(function() {
|
|
|
|
|
axios.get(ctx + 'system/file/delFile/' + file.id)
|
|
|
|
|
.then(response => {
|
|
|
|
|
.then(function(response) {
|
|
|
|
|
if (response.data.code === web_status.SUCCESS) {
|
|
|
|
|
this.uploadedFiles.splice(index, 1);
|
|
|
|
|
this.$message.success('文件已成功删除');
|
|
|
|
|
self.uploadedFiles.splice(index, 1);
|
|
|
|
|
self.$message.success('文件已成功删除');
|
|
|
|
|
} else {
|
|
|
|
|
this.$message.error(`删除失败: ${response.data.msg}`);
|
|
|
|
|
self.$message.error('删除失败: ' + response.data.msg);
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
.catch(error => {
|
|
|
|
|
.catch(function(error) {
|
|
|
|
|
console.error('删除错误:', error);
|
|
|
|
|
this.$message.error('删除文件时出错');
|
|
|
|
|
self.$message.error('删除文件时出错');
|
|
|
|
|
});
|
|
|
|
|
}).catch(() => {
|
|
|
|
|
this.$message({
|
|
|
|
|
}).catch(function() {
|
|
|
|
|
self.$message({
|
|
|
|
|
type: 'info',
|
|
|
|
|
message: '已取消删除'
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
// 获取已上传文件
|
|
|
|
|
getUploadedFiles() {
|
|
|
|
|
getUploadedFiles: function() {
|
|
|
|
|
var self = this;
|
|
|
|
|
if (!this.formData.applyId) return;
|
|
|
|
|
axios.get(ctx + 'system/file/getFileInfo', {
|
|
|
|
|
params: {
|
|
|
|
|
applyId: this.formData.applyId,
|
|
|
|
|
fileCode:'bm_user_audit_001',
|
|
|
|
|
fileCode: 'bm_user_audit_001',
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
.then(response => {
|
|
|
|
|
.then(function(response) {
|
|
|
|
|
if (response.data.code === web_status.SUCCESS) {
|
|
|
|
|
this.uploadedFiles = response.data.data.map((file)=>{
|
|
|
|
|
self.uploadedFiles = response.data.data.map(function(file) {
|
|
|
|
|
return {
|
|
|
|
|
id: file.fileId,
|
|
|
|
|
fileName: file.fileName,
|
|
|
|
@ -709,47 +716,47 @@
|
|
|
|
|
fileType: file.fileType,
|
|
|
|
|
fileUrl: file.filePath,
|
|
|
|
|
uploadTime: file.createTime
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
};
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
.catch(error => {
|
|
|
|
|
.catch(function(error) {
|
|
|
|
|
console.error('获取文件列表错误:', error);
|
|
|
|
|
this.$message.error('获取已上传文件时出错');
|
|
|
|
|
self.$message.error('获取已上传文件时出错');
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
// 新增图片预览相关方法
|
|
|
|
|
isImageFile(fileName) {
|
|
|
|
|
const imageExtensions = ['jpg', 'jpeg', 'png', 'gif', 'bmp','pdf'];
|
|
|
|
|
const extension = fileName.split('.').pop().toLowerCase();
|
|
|
|
|
return imageExtensions.includes(extension);
|
|
|
|
|
isImageFile: function(fileName) {
|
|
|
|
|
var imageExtensions = ['jpg', 'jpeg', 'png', 'gif', 'bmp', 'pdf'];
|
|
|
|
|
var extension = fileName.split('.').pop().toLowerCase();
|
|
|
|
|
return imageExtensions.indexOf(extension) !== -1;
|
|
|
|
|
},
|
|
|
|
|
getFileIcon(fileName) {
|
|
|
|
|
const extension = fileName.split('.').pop().toLowerCase();
|
|
|
|
|
getFileIcon: function(fileName) {
|
|
|
|
|
var extension = fileName.split('.').pop().toLowerCase();
|
|
|
|
|
if (extension === 'pdf') return 'fa-solid fa-file-pdf text-red-500';
|
|
|
|
|
if (['doc', 'docx'].includes(extension)) return 'fa-solid fa-file-word text-blue-500';
|
|
|
|
|
if (['jpg', 'jpeg', 'png', 'gif', 'bmp'].includes(extension)) return 'fa-solid fa-file-image text-green-500';
|
|
|
|
|
if (['doc', 'docx'].indexOf(extension) !== -1) return 'fa-solid fa-file-word text-blue-500';
|
|
|
|
|
if (['jpg', 'jpeg', 'png', 'gif', 'bmp'].indexOf(extension) !== -1) return 'fa-solid fa-file-image text-green-500';
|
|
|
|
|
return 'fa-solid fa-file text-gray-500';
|
|
|
|
|
},
|
|
|
|
|
previewFile(file) {
|
|
|
|
|
let extension = file.fileName.split('.').pop().toLowerCase();
|
|
|
|
|
previewFile: function(file) {
|
|
|
|
|
var extension = file.fileName.split('.').pop().toLowerCase();
|
|
|
|
|
if (extension === 'pdf') {
|
|
|
|
|
// 使用preventDefault阻止默认行为,避免影响当前页面状态
|
|
|
|
|
let event = window.event;
|
|
|
|
|
var event = window.event;
|
|
|
|
|
if (event) {
|
|
|
|
|
event.preventDefault();
|
|
|
|
|
}
|
|
|
|
|
window.open(file.fileUrl, '_blank');
|
|
|
|
|
return
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
this.previewingFile = file;
|
|
|
|
|
this.previewModalVisible = true;
|
|
|
|
|
},
|
|
|
|
|
closePreviewModal() {
|
|
|
|
|
closePreviewModal: function() {
|
|
|
|
|
this.previewModalVisible = false;
|
|
|
|
|
this.previewingFile = {};
|
|
|
|
|
},
|
|
|
|
|
getPreviewUrl(file) {
|
|
|
|
|
getPreviewUrl: function(file) {
|
|
|
|
|
// 如果是图片,直接返回URL
|
|
|
|
|
if (this.isImageFile(file.fileName)) {
|
|
|
|
|
return ctx + 'system/file/download?fileId=' + file.id;
|
|
|
|
@ -757,18 +764,23 @@
|
|
|
|
|
return '';
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
mounted() {
|
|
|
|
|
mounted: function() {
|
|
|
|
|
var self = this;
|
|
|
|
|
// 从后端获取转义后的 JSON 字符串
|
|
|
|
|
if ([[${applyInfoList}]]){
|
|
|
|
|
this.formData = {...[[${applyInfoList}]]}
|
|
|
|
|
if ([[${applyInfoList}]]) {
|
|
|
|
|
this.formData = JSON.parse(JSON.stringify([[${applyInfoList}]]));
|
|
|
|
|
// 获取图片并转换为 Blob
|
|
|
|
|
if (this.formData.photoUrl) {
|
|
|
|
|
fetch(this.formData.photoUrl)
|
|
|
|
|
.then(response => response.blob())
|
|
|
|
|
.then(blob => {
|
|
|
|
|
this.selectedFile = blob;
|
|
|
|
|
.then(function(response) {
|
|
|
|
|
return response.blob();
|
|
|
|
|
})
|
|
|
|
|
.then(function(blob) {
|
|
|
|
|
self.selectedFile = blob;
|
|
|
|
|
})
|
|
|
|
|
.catch(error => console.error('处理图片时出错:', error));
|
|
|
|
|
.catch(function(error) {
|
|
|
|
|
console.error('处理图片时出错:', error);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -776,33 +788,6 @@
|
|
|
|
|
this.getUploadedFiles();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
//图片上传
|
|
|
|
|
$('#applyUrlId').on('change.bs.fileinput ', function (e) {
|
|
|
|
|
// 处理自己的业务
|
|
|
|
|
var file = e.target.files[0];
|
|
|
|
|
var data = new FormData();
|
|
|
|
|
data.append("file", file);
|
|
|
|
|
$.ajax({
|
|
|
|
|
type: "POST",
|
|
|
|
|
url: ctx + "common/upload",
|
|
|
|
|
data: data,
|
|
|
|
|
cache: false,
|
|
|
|
|
contentType: false,
|
|
|
|
|
processData: false,
|
|
|
|
|
dataType: 'json',
|
|
|
|
|
success: function (result) {
|
|
|
|
|
if (result.code == web_status.SUCCESS) {
|
|
|
|
|
$("#photoUrl").val(result.url);
|
|
|
|
|
} else {
|
|
|
|
|
$.modal.alertError(result.msg);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
error: function (error) {
|
|
|
|
|
$.modal.alertWarning("图片上传失败。");
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
</script>
|
|
|
|
|
</body>
|
|
|
|
|