|
|
|
@ -3,23 +3,35 @@
|
|
|
|
|
|
|
|
|
|
<div class="user-info-head">
|
|
|
|
|
<el-row>
|
|
|
|
|
|
|
|
|
|
<el-col :span="6">
|
|
|
|
|
<el-button type="primary" icon="el-icon-view" size="small" @click="showImgViewer">资质文件预览
|
|
|
|
|
<el-button type="primary" icon="el-icon-view" size="small" @click="viewFile">资质文件预览(pdf)
|
|
|
|
|
</el-button>
|
|
|
|
|
</el-col>
|
|
|
|
|
<el-col :span="6">
|
|
|
|
|
<el-upload action="#" :http-request="requestUpload" :show-file-list="false" :before-upload="beforeUpload">
|
|
|
|
|
<el-button type="primary" icon="el-icon-plus" size="small" @click="uploadPdf">上传资质文件</el-button>
|
|
|
|
|
</el-upload>
|
|
|
|
|
</el-col>
|
|
|
|
|
<el-upload
|
|
|
|
|
class="upload-demo"
|
|
|
|
|
action
|
|
|
|
|
:data="{type:'.pdf'}"
|
|
|
|
|
:on-change="handleChange"
|
|
|
|
|
:on-success="handleSuccess"
|
|
|
|
|
:file-list="fileList"
|
|
|
|
|
:auto-upload="false"
|
|
|
|
|
:http-request="requestUpload"
|
|
|
|
|
>
|
|
|
|
|
<el-button size="small" type="primary" icon="el-icon-plus"
|
|
|
|
|
style="margin-left: 50px;padding-right: 15px"
|
|
|
|
|
>上传资质文件</el-button>
|
|
|
|
|
</el-upload>
|
|
|
|
|
</el-row>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
import {uploadFile} from "@/api/basic/uploadZz";
|
|
|
|
|
import {filterByid} from "@/api/purchase/companyCert";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export default {
|
|
|
|
|
props: {
|
|
|
|
@ -31,10 +43,18 @@ export default {
|
|
|
|
|
type: Object,
|
|
|
|
|
required: true,
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
data() {
|
|
|
|
|
return {
|
|
|
|
|
filePdf:{}
|
|
|
|
|
addForm:{
|
|
|
|
|
file:null,
|
|
|
|
|
fileName:'',
|
|
|
|
|
fileData:null
|
|
|
|
|
},
|
|
|
|
|
filePdfa:null,
|
|
|
|
|
newFile:{},
|
|
|
|
|
filePdf: null,
|
|
|
|
|
};
|
|
|
|
|
},
|
|
|
|
|
methods: {
|
|
|
|
@ -42,49 +62,97 @@ export default {
|
|
|
|
|
requestUpload() {
|
|
|
|
|
},
|
|
|
|
|
// 上传预处理
|
|
|
|
|
beforeUpload(file) {
|
|
|
|
|
console.log("zhegewenjian hdhdhd",file)
|
|
|
|
|
this.filePdf.fileName = file.name
|
|
|
|
|
if (file.type === "application/pdf") {
|
|
|
|
|
uploadFile(file).then(response => {
|
|
|
|
|
console.log("上传成功")
|
|
|
|
|
this.inputQuery.filePath = this.inputQuery.filePath + ";" + this.options.img + ";"
|
|
|
|
|
this.splitImages()
|
|
|
|
|
this.$modal.msgSuccess("提交成功");
|
|
|
|
|
this.visible = false;
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
this.$modal.msgError("文件格式错误,请上传Pdf类型的文件。");
|
|
|
|
|
|
|
|
|
|
//上传之前调用方法
|
|
|
|
|
beforeUpload(file){
|
|
|
|
|
this.addForm.file = file;
|
|
|
|
|
this.addForm.fileName = file.name;
|
|
|
|
|
// this.fileSize = file.size;
|
|
|
|
|
const extension = file.name.split('.').slice(-1) == 'pdf'
|
|
|
|
|
if (!extension) {
|
|
|
|
|
this.$message.warning('上传模板只能是pdf格式!')
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
let reader = new FileReader();
|
|
|
|
|
reader.readAsDataURL(file);
|
|
|
|
|
let that = this;
|
|
|
|
|
reader.onload = function() {
|
|
|
|
|
that.addForm.fileData = reader.result;
|
|
|
|
|
};
|
|
|
|
|
return false; // 返回false不会自动上传
|
|
|
|
|
},
|
|
|
|
|
//预览pdf 文件,这里用的是打开新窗口用浏览器查看PDF
|
|
|
|
|
viewFile(){
|
|
|
|
|
if (this.formName == 1){
|
|
|
|
|
if(this.filePdf == null){
|
|
|
|
|
this.$message.warning('请先上传PDF文件');
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
var win = window.open();
|
|
|
|
|
win.document.write(
|
|
|
|
|
'<body style="margin:0px;"><object data="' +
|
|
|
|
|
this.filePdf +
|
|
|
|
|
'" type="application/pdf" width="100%" height="100%"><iframe src="' +
|
|
|
|
|
this.filePdf +
|
|
|
|
|
'" scrolling="no" width="100%" height="100%" frameborder="0" ></iframe></object></body>'
|
|
|
|
|
);
|
|
|
|
|
}else {
|
|
|
|
|
if ( this.filePdf == null){
|
|
|
|
|
this.$message.error("请上传资质文件");
|
|
|
|
|
}else {
|
|
|
|
|
window.open(this.filePdf,'_blank')
|
|
|
|
|
console.log("hhhhhhhhhhhhhhhhhhhhhhhh",this.filePdf)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// getCropFile(data) {
|
|
|
|
|
// debugger
|
|
|
|
|
// console.log(data);
|
|
|
|
|
// uploadFile(data).then(response => {
|
|
|
|
|
// this.open = false;
|
|
|
|
|
// this.options.img = response.data.name;
|
|
|
|
|
// this.inputQuery.filePath = this.inputQuery.filePath + ";" + this.options.img + ";"
|
|
|
|
|
// this.splitImages()
|
|
|
|
|
// this.$modal.msgSuccess("提交成功");
|
|
|
|
|
// this.visible = false;
|
|
|
|
|
// });
|
|
|
|
|
// },
|
|
|
|
|
|
|
|
|
|
// 上传Pdf
|
|
|
|
|
uploadPdf() {
|
|
|
|
|
let formData = new FormData();
|
|
|
|
|
console.log("xixiixixixiixixixi",this.filePdf.fileName)
|
|
|
|
|
formData.append("file", data, this.options.filename);
|
|
|
|
|
formData.append("type", "pdf2");
|
|
|
|
|
uploadFile(formData).then(response => {
|
|
|
|
|
this.open = false;
|
|
|
|
|
console.log(response.data.name);
|
|
|
|
|
this.options.img = response.data.name;
|
|
|
|
|
this.inputQuery.filePath = this.options.img
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
//点击确定按钮上传到后台
|
|
|
|
|
getOneCert(){
|
|
|
|
|
let cQuery = {
|
|
|
|
|
id : this.inputQuery.id
|
|
|
|
|
};
|
|
|
|
|
filterByid(cQuery).then(res => {
|
|
|
|
|
if (res.code == 20000){
|
|
|
|
|
this.filePdf = res.data.filePdfPath
|
|
|
|
|
console.log("dayinchu zhege ba ",this.filePdf)
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
submitAddForm(){
|
|
|
|
|
let formData = new FormData();
|
|
|
|
|
formData.append("file", this.addForm.file);
|
|
|
|
|
formData.append("type", ".pdf");
|
|
|
|
|
console.log("heihei", this.addForm.file)
|
|
|
|
|
this.newFile = this.addForm.file
|
|
|
|
|
uploadFile(formData).then(response => {
|
|
|
|
|
if (response == 20000){
|
|
|
|
|
this.filePdf = response.data.name
|
|
|
|
|
this.$modal.msgSuccess("提交成功");
|
|
|
|
|
this.visible = false;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
handleChange(file,fileList){
|
|
|
|
|
console.log("zaici dayin ",file.raw)
|
|
|
|
|
let newFile = file.raw
|
|
|
|
|
let formData = new FormData();
|
|
|
|
|
formData.append("file",newFile);
|
|
|
|
|
formData.append("type", ".pdf");
|
|
|
|
|
uploadFile(formData).then(res => {
|
|
|
|
|
if (res.code == 20000){
|
|
|
|
|
console.log("aaaaaaaachenggong",res)
|
|
|
|
|
this.inputQuery.filePdfPath = res.data.name
|
|
|
|
|
this.filePdf = res.data.name
|
|
|
|
|
this.$modal.msgSuccess("提交成功");
|
|
|
|
|
this.visible = false;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
console.log('文件列表发生变化',file);
|
|
|
|
|
},
|
|
|
|
|
handleSuccess(response, file) {
|
|
|
|
|
// this.filePdf = file.response.data.name
|
|
|
|
|
// 文件上传成功的处理逻辑
|
|
|
|
|
console.log('上传成功', response, file);
|
|
|
|
|
},
|
|
|
|
|
// 关闭窗口
|
|
|
|
|
closeDialog() {
|
|
|
|
@ -93,13 +161,13 @@ export default {
|
|
|
|
|
|
|
|
|
|
splitImages() {
|
|
|
|
|
// 输入验证:确保filePath是字符串类型
|
|
|
|
|
if (typeof this.inputQuery.filePath !== "string") {
|
|
|
|
|
if (typeof this.inputQuery.filePdfPath !== "string") {
|
|
|
|
|
console.warn("inputQuery.filePath is not a string");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
try {
|
|
|
|
|
// 分割字符串并处理边界条件
|
|
|
|
|
let imagePaths = this.inputQuery.filePath.split(";");
|
|
|
|
|
// // 分割字符串并处理边界条件
|
|
|
|
|
// let imagePaths = this.inputQuery.filePath.split(";");
|
|
|
|
|
// 过滤掉空路径
|
|
|
|
|
this.imgList = imagePaths.filter(path => path.trim() !== "" && path.trim() !== null && path.trim() !== "null");
|
|
|
|
|
console.log(this.imgList);
|
|
|
|
@ -113,6 +181,8 @@ export default {
|
|
|
|
|
|
|
|
|
|
created() {
|
|
|
|
|
this.splitImages();
|
|
|
|
|
this.getOneCert();
|
|
|
|
|
console.log("dayin dayin ",this.inputQuery)
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
</script>
|
|
|
|
|