编辑查看文件管理上传

This commit is contained in:
zzyuan 2024-11-07 11:21:22 +08:00
parent 6613e9fe16
commit 83a3627af9
2 changed files with 43 additions and 33 deletions

View File

@ -111,7 +111,7 @@
<el-table v-loading="dialogLoading" :data="fileDataList" width="100%" height="350px"> <el-table v-loading="dialogLoading" :data="fileDataList" width="100%" height="350px">
<el-table-column label="序号" type="index" width="55" align="center"/> <el-table-column label="序号" type="index" width="55" align="center"/>
<el-table-column label="报告类型" align="center" prop="dictLabel" :show-overflow-tooltip="true"/> <el-table-column label="报告类型" align="center" prop="dictLabel" :show-overflow-tooltip="true"/>
<el-table-column label="文件名称" align="center" prop="fileName" :show-overflow-tooltip="true"/> <el-table-column label="文件名称" align="center" prop="name" :show-overflow-tooltip="true"/>
<el-table-column label="类型名称" align="center" :show-overflow-tooltip="true"> <el-table-column label="类型名称" align="center" :show-overflow-tooltip="true">
<template> <template>
<div>{{this.rowData.maTypeName}}</div> <div>{{this.rowData.maTypeName}}</div>
@ -126,8 +126,8 @@
<el-table-column label="截止有效期" align="center" prop="orgName" :show-overflow-tooltip="true"/> --> <el-table-column label="截止有效期" align="center" prop="orgName" :show-overflow-tooltip="true"/> -->
<el-table-column label="操作" align="center" width="100"> <el-table-column label="操作" align="center" width="100">
<template slot-scope="scope"> <template slot-scope="scope">
<div style="display: flex;align-items: center;justify-content: space-between;"> <div style="display: flex;align-items: center;justify-content: center;">
<el-upload ref="upload" :limit="1" :headers="upload.headers" <el-upload ref="upload" :limit="1" :headers="upload.headers" v-show="!isView"
:action="upload.url" :show-file-list="false" accept=".png, .jpg, .jpeg, .pdf, .doc, .docx" :action="upload.url" :show-file-list="false" accept=".png, .jpg, .jpeg, .pdf, .doc, .docx"
:on-success="handleFileSuccess" :auto-upload="true" :on-success="handleFileSuccess" :auto-upload="true"
> >
@ -136,7 +136,7 @@
</el-button> </el-button>
</el-upload> </el-upload>
<el-button size="mini" type="text" @click="picturePreview(scope.row)" v-if="scope.row.fileUrl"> <el-button size="mini" type="text" @click="picturePreview(scope.row)" v-if="scope.row.url" style="margin-left: 10px;">
查看 查看
</el-button> </el-button>
</div> </div>
@ -192,11 +192,11 @@
open: false, open: false,
rowData:{}, rowData:{},
fileDataList: [ fileDataList: [
{dictLabel:"合格证",dictCode:"0",fileName:"",fileUrl:""}, {dictLabel:"合格证",fileType:"0",name:"",url:""},
{dictLabel:"型式试验报告",dictCode:"1",fileName:"",fileUrl:""}, {dictLabel:"型式试验报告",fileType:"1",name:"",url:""},
{dictLabel:"出厂检测报告",dictCode:"2",fileName:"",fileUrl:""}, {dictLabel:"出厂检测报告",fileType:"2",name:"",url:""},
{dictLabel:"第三方监测报告",dictCode:"3",fileName:"",fileUrl:""}, {dictLabel:"第三方监测报告",fileType:"3",name:"",url:""},
{dictLabel:"其他报告",dictCode:"4",fileName:"",fileUrl:""}, {dictLabel:"其他报告",fileType:"4",name:"",url:""},
], ],
// //
queryParams: { queryParams: {
@ -295,24 +295,34 @@
// //
openFileDialog(row){ openFileDialog(row){
this.rowData=row; this.rowData=row;
// this.getFileData() this.fileDataList = [{dictLabel:"合格证",fileType:"0",name:"",url:""},
{dictLabel:"型式试验报告",fileType:"1",name:"",url:""},
{dictLabel:"出厂检测报告",fileType:"2",name:"",url:""},
{dictLabel:"第三方监测报告",fileType:"3",name:"",url:""},
{dictLabel:"其他报告",fileType:"4",name:"",url:""}]
this.getFileData()
this.open=true this.open=true
}, },
// getFileData(){ getFileData(){
// let param = { let param = {
// typeId:this.rowData.typeId, modelId:this.rowData.typeId,
// taskId:this.rowData.taskId taskType:0,
// } taskId:this.rowData.taskId
// this.dialogLoading=true }
// getPurchaseFileList(param).then((response) => { getPurchaseFileList(param).then((response) => {
// this.fileDataList=response.data if(response.rows.length>0){
// this.dialogLoading = false; response.rows.forEach(item=>{
// }).catch(() => {this.dialogLoading = false;}) let index = this.fileDataList.findIndex(v=>v.fileType==item.fileType)
// }, this.fileDataList[index].name = item.name
this.fileDataList[index].url = item.url
})
}
}).catch(() => {
})
},
beforeFileUpload(row){ beforeFileUpload(row){
this.rowData.dictCode=row.dictCode; this.rowData.fileType=row.fileType;
this.rowData.dictLabel=row.dictLabel; // this.rowData.dictLabel=row.dictLabel;
}, },
// //
handleFileSuccess(response, file, fileList) { handleFileSuccess(response, file, fileList) {
@ -323,7 +333,7 @@
"name": response.data.name, "name": response.data.name,
"url": response.data.url, "url": response.data.url,
"modelId": this.rowData.typeId, "modelId": this.rowData.typeId,
"fileType": this.rowData.dictCode, "fileType": this.rowData.fileType,
} }
console.log(param) console.log(param)
uploadPurchaseFile(param).then((response) => { uploadPurchaseFile(param).then((response) => {
@ -336,12 +346,12 @@
}, },
// //
picturePreview(file) { picturePreview(file) {
this.dialogImageUrl = file.fileUrl; this.dialogImageUrl = file.url;
const parts = file.fileName.split('.'); const parts = file.name.split('.');
const extension = parts.pop(); const extension = parts.pop();
if(extension === 'doc'||extension === 'docx'||extension === 'pdf'){ if(extension === 'doc'||extension === 'docx'||extension === 'pdf'){
const windowName = file.fileName; const windowName = file.name;
window.open(file.fileUrl,windowName) window.open(file.url,windowName)
}else{ }else{
this.dialogVisible = true this.dialogVisible = true
} }

View File

@ -591,7 +591,7 @@ export default {
}, },
/** 保存按钮操作 */ /** 保存按钮操作 */
handleSave() { handleSave() {
console.log(this.equipmentList) // console.log(this.equipmentList)
if (this.equipmentList.length > 0) { if (this.equipmentList.length > 0) {
this.$refs['maForm'].validate((valid) => { this.$refs['maForm'].validate((valid) => {
if (valid) { if (valid) {
@ -621,7 +621,7 @@ export default {
}) })
} else if (!this.isEdit) { } else if (!this.isEdit) {
console.log('新增') console.log('新增')
console.log(this.equipmentList) // console.log(this.equipmentList)
this.loading = true this.loading = true
addPurchaseCheckInfo({purchaseCheckDetailsList: this.equipmentList,purchaseCheckInfo:this.maForm}).then((response) => { addPurchaseCheckInfo({purchaseCheckDetailsList: this.equipmentList,purchaseCheckInfo:this.maForm}).then((response) => {
if (response.code == 200) { if (response.code == 200) {
@ -652,12 +652,12 @@ export default {
// //
openFileDialog(row){ openFileDialog(row){
this.rowData=row; this.rowData=row;
if(this.taskId==""){ this.fileDataList = [{dictLabel:"合格证",fileType:"0",name:"",url:""},
this.fileDataList = [{dictLabel:"合格证",fileType:"0",name:"",url:""},
{dictLabel:"型式试验报告",fileType:"1",name:"",url:""}, {dictLabel:"型式试验报告",fileType:"1",name:"",url:""},
{dictLabel:"出厂检测报告",fileType:"2",name:"",url:""}, {dictLabel:"出厂检测报告",fileType:"2",name:"",url:""},
{dictLabel:"第三方监测报告",fileType:"3",name:"",url:""}, {dictLabel:"第三方监测报告",fileType:"3",name:"",url:""},
{dictLabel:"其他报告",fileType:"4",name:"",url:""}] {dictLabel:"其他报告",fileType:"4",name:"",url:""}]
if(this.taskId==""){
// console.log(this.rowData) // console.log(this.rowData)
// console.log(this.rowData.bmFileInfos) // console.log(this.rowData.bmFileInfos)
if(this.rowData.bmFileInfos.length>0){ if(this.rowData.bmFileInfos.length>0){