报告上传/删除

This commit is contained in:
bb_pan 2025-06-19 15:25:22 +08:00
parent 0f73417cc2
commit 1f5d118581
2 changed files with 238 additions and 249 deletions

View File

@ -86,6 +86,19 @@ export function getSignListApi(query) {
}) })
} }
// 查看新增报告
export function bmFileInfoAddApi(data) {
return request({
url: '/material/bm_file_info',
method: 'post',
data
})
}
// 查看删除报告
export function bmFileInfoRemoveApi(id) {
return request({
url: '/material/bm_file_info/' + id,
method: 'delete',
})
}

View File

@ -1,42 +1,28 @@
<template> <template>
<div> <div>
<el-row :gutter="10" class="mb8"> <el-row :gutter="10" class="mb8">
<el-col :span="1.5"> <el-col :span="1.5">
<el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport">导出</el-button> <el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport">
导出
</el-button>
</el-col> </el-col>
</el-row> </el-row>
<el-table <el-table v-loading="loading" :data="equipmentList">
v-loading="loading"
:data="equipmentList"
>
<el-table-column label="序号" align="center" type="index" /> <el-table-column label="序号" align="center" type="index" />
<el-table-column <el-table-column label="物资名称" align="center" prop="maTypeName" :show-overflow-tooltip="true" />
label="物资名称" <el-table-column label="规格型号" align="center" prop="typeName" :show-overflow-tooltip="true" />
align="center"
prop="maTypeName"
:show-overflow-tooltip="true"
/>
<el-table-column
label="规格型号"
align="center"
prop="typeName"
:show-overflow-tooltip="true"
/>
<el-table-column <el-table-column
label="单位" label="单位"
align="center" align="center"
prop="unitName" prop="unitName"
:show-overflow-tooltip="true" :show-overflow-tooltip="true"
> ></el-table-column>
</el-table-column>
<el-table-column <el-table-column
label="采购数量" label="采购数量"
align="center" align="center"
prop="purchaseNum" prop="purchaseNum"
:show-overflow-tooltip="true" :show-overflow-tooltip="true"
> ></el-table-column>
</el-table-column>
<el-table-column <el-table-column
label="购置单价(元含税)" label="购置单价(元含税)"
align="center" align="center"
@ -49,109 +35,118 @@
prop="purchasePrice" prop="purchasePrice"
:show-overflow-tooltip="true" :show-overflow-tooltip="true"
/> />
<el-table-column <el-table-column label="租赁价(元/天)" align="center" prop="rentPrice" :show-overflow-tooltip="true" />
label="租赁价(元/天)" <el-table-column label="是否未固定资产" align="center" prop="fixCode" :show-overflow-tooltip="true" />
align="center" <el-table-column label="出厂日期" align="center" prop="productionTime" :show-overflow-tooltip="true" />
prop="rentPrice" <el-table-column label="相关配套资料" align="center" prop="">
:show-overflow-tooltip="true"
/>
<el-table-column
label="是否未固定资产"
align="center"
prop="fixCode"
:show-overflow-tooltip="true"
/>
<el-table-column
label="出厂日期"
align="center"
prop="productionTime"
:show-overflow-tooltip="true"
/>
<el-table-column
label="相关配套资料"
align="center"
prop=""
>
<template slot-scope="scope"> <template slot-scope="scope">
<div style="color: #02A7F0;cursor: pointer;" @click="openFileDialog(scope.row)" v-if="scope.row.isExitFile==1">报告管理</div> <div
<div style="color: red;cursor: pointer;" @click="openFileDialog(scope.row)" v-if="scope.row.isExitFile==0">报告管理</div> style="color: #02a7f0; cursor: pointer"
@click="openFileDialog(scope.row)"
v-if="scope.row.isExitFile == 1"
>
报告管理
</div>
<div
style="color: red; cursor: pointer"
@click="openFileDialog(scope.row)"
v-if="scope.row.isExitFile == 0"
>
报告管理
</div>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="状态" align="center" prop="status" :show-overflow-tooltip="true"> <el-table-column label="状态" align="center" prop="status" :show-overflow-tooltip="true">
<template slot-scope="scope"> <template slot-scope="scope">
<dict-tag :options="dict.type.purchase_task_status" :value="scope.row.status"/> <dict-tag :options="dict.type.purchase_task_status" :value="scope.row.status" />
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
<el-dialog title="报告管理" :visible.sync="open" width="900px" append-to-body> <el-dialog title="报告管理" :visible.sync="open" width="900px" append-to-body>
<el-table :data="fileDataList" width="100%" height="350px"> <el-table :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" :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>
</template> </template>
</el-table-column> </el-table-column>
<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.typeName}}</div> <div>{{ this.rowData.typeName }}</div>
</template> </template>
</el-table-column> </el-table-column>
<!-- <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" 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: space-between">
<!-- <el-upload ref="upload" :limit="1" :headers="upload.headers" <el-upload
:action="upload.url" :show-file-list="false" accept=".png, .jpg, .jpeg, .pdf, .doc, .docx" ref="upload"
:on-success="handleFileSuccess" :auto-upload="true" :headers="upload.headers"
:action="upload.url"
:show-file-list="false"
accept=".png, .jpg, .jpeg, .pdf, .doc, .docx"
:on-success="(res, file, fileList) => handleFileSuccess(scope.row, res, file, fileList)"
:auto-upload="true"
> >
<el-button size="mini" type="text" @click="beforeFileUpload(scope.row)"> <el-button size="mini" type="text" @click="beforeFileUpload(scope.row)">上传</el-button>
上传 </el-upload>
</el-button>
</el-upload> -->
<el-button size="mini" type="text" @click="picturePreviewFile(scope.row)" v-if="scope.row.fileListTemp!=0"> <el-button
size="mini"
type="text"
@click="picturePreviewFile(scope.row)"
v-if="scope.row.fileListTemp != 0"
>
查看 查看
</el-button> </el-button>
</div> </div>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
</el-dialog> </el-dialog>
<!-- 图片查看弹窗 --> <!-- 图片查看弹窗 -->
<el-dialog :visible.sync="dialogVisible" width="500px" height="500px" > <el-dialog :visible.sync="dialogVisible" width="500px" height="500px">
<img width="100%" height="500px" :src="dialogImageUrl" /> <img width="100%" height="500px" :src="dialogImageUrl" />
</el-dialog> </el-dialog>
<!-- 文件查看列表 --> <!-- 文件查看列表 -->
<el-dialog title="文件列表" :visible.sync="dialogVisibleFile" width="500px" height="500px" > <el-dialog title="文件列表" :visible.sync="dialogVisibleFile" width="500px" height="500px">
<el-table :data="fileListInfo" width="100%" height="350px"> <el-table :data="fileListInfo" width="100%" height="350px" style="overflow: auto">
<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="name" :show-overflow-tooltip="true"/> <el-table-column label="文件名称" align="center" prop="name" :show-overflow-tooltip="true" />
<el-table-column label="操作" align="center" > <el-table-column label="操作" align="center">
<template slot-scope="scope"> <template slot-scope="scope">
<el-button size="mini" type="text" @click="picturePreview(scope.row)" v-if="scope.row.url" > <el-button size="mini" type="text" @click="picturePreview(scope.row)" v-if="scope.row.url">
查看 查看
</el-button> </el-button>
<el-button
size="mini"
type="text"
@click="handleDelete(scope.row)"
v-if="scope.row.url"
style="color: red"
>
删除
</el-button>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
</el-dialog> </el-dialog>
</div> </div>
</template> </template>
<script> <script>
import { getPurchaseCheckInfo } from '@/api/purchase/goodsArrived'
import { import {
getPurchaseCheckInfo uploadPurchaseFile,
} from '@/api/purchase/goodsArrived' getPurchaseFileList,
import { uploadPurchaseFile,getPurchaseFileList } from "@/api/purchase/goodsAccept"; bmFileInfoAddApi,
bmFileInfoRemoveApi
} from '@/api/purchase/goodsAccept'
import { getToken } from '@/utils/auth' import { getToken } from '@/utils/auth'
export default { export default {
name: 'QueryTools', name: 'QueryTools',
@ -164,24 +159,24 @@ export default {
type: Boolean, type: Boolean,
default: () => { default: () => {
return false return false
}, }
}, },
queryTaskId: { queryTaskId: {
type: [String, Number], type: [String, Number],
default: () => { default: () => {
return '' return ''
}, }
}, },
queryId: { queryId: {
type: [String, Number], type: [String, Number],
default: () => { default: () => {
return '' return ''
}, }
}, }
}, },
data() { data() {
return { return {
fixCodeList:["否","是"], fixCodeList: ['否', '是'],
//ID //ID
taskId: '', taskId: '',
// //
@ -192,13 +187,13 @@ export default {
equipmentList: [], equipmentList: [],
// //
open: false, open: false,
rowData:{}, rowData: {},
fileDataList: [ fileDataList: [
{dictLabel:"合格证",fileType:"0",name:"",url:""}, { 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: '' }
], ],
fileListInfo: [], fileListInfo: [],
// //
@ -211,12 +206,10 @@ export default {
// //
dialogImageUrl: '', dialogImageUrl: '',
dialogVisible: false, dialogVisible: false,
dialogVisibleFile: false, dialogVisibleFile: false
} }
}, },
computed: { computed: {},
},
mounted() { mounted() {
this.taskId = this.queryTaskId this.taskId = this.queryTaskId
this.id = this.queryId this.id = this.queryId
@ -226,143 +219,104 @@ export default {
//- //-
getTaskInfo() { getTaskInfo() {
this.loading = true this.loading = true
getPurchaseCheckInfo({taskId:this.taskId,id:this.id,taskStage: 1}).then((response) => { getPurchaseCheckInfo({ taskId: this.taskId, id: this.id, taskStage: 1 }).then(response => {
this.taskInfo = response.data this.taskInfo = response.data
this.equipmentList = response.data.purchaseCheckDetailsList this.equipmentList = response.data.purchaseCheckDetailsList
this.equipmentList.forEach((item) => { this.equipmentList.forEach(item => {
item.fixCode = this.fixCodeList[Number(item.fixCode)] item.fixCode = this.fixCodeList[Number(item.fixCode)]
}) })
this.loading = false this.loading = false
}) })
}, },
// //
openFileDialog(row){ openFileDialog(row) {
this.rowData=row; this.rowData = row
this.fileDataList = [{dictLabel:"合格证",fileType:"0",name:"",url:"",fileList:[],fileListTemp:[]}, this.fileDataList = [
{dictLabel:"型式试验报告",fileType:"1",name:"",url:"",fileList:[],fileListTemp:[]}, { dictLabel: '合格证', fileType: '0', name: '', url: '', fileList: [], fileListTemp: [] },
{dictLabel:"出厂检测报告",fileType:"2",name:"",url:"",fileList:[],fileListTemp:[]}, { dictLabel: '型式试验报告', fileType: '1', name: '', url: '', fileList: [], fileListTemp: [] },
{dictLabel:"第三方检测报告",fileType:"3",name:"",url:"",fileList:[],fileListTemp:[]}, { dictLabel: '出厂检测报告', fileType: '2', name: '', url: '', fileList: [], fileListTemp: [] },
{dictLabel:"其他",fileType:"4",name:"",url:"",fileList:[],fileListTemp:[]}] { dictLabel: '第三方检测报告', fileType: '3', name: '', url: '', fileList: [], fileListTemp: [] },
{ dictLabel: '其他', fileType: '4', name: '', url: '', fileList: [], fileListTemp: [] }
]
this.getFileData() this.getFileData()
this.open=true this.open = true
}, },
async getFileData(){ async getFileData() {
this.fileDataList = [
{ dictLabel: '合格证', fileType: '0', name: '', url: '', fileList: [], fileListTemp: [] },
{ dictLabel: '型式试验报告', fileType: '1', name: '', url: '', fileList: [], fileListTemp: [] },
{ dictLabel: '出厂检测报告', fileType: '2', name: '', url: '', fileList: [], fileListTemp: [] },
{ dictLabel: '第三方检测报告', fileType: '3', name: '', url: '', fileList: [], fileListTemp: [] },
{ dictLabel: '其他', fileType: '4', name: '', url: '', fileList: [], fileListTemp: [] }
]
let param = { let param = {
modelId:this.rowData.typeId, modelId: this.rowData.typeId,
taskType:0, taskType: 0,
taskId:this.rowData.taskId taskId: this.rowData.taskId,
pageNum: 1,
pageSize: 9999999
} }
await getPurchaseFileList(param) await getPurchaseFileList(param)
.then(response => { .then(response => {
if(response.rows.length>0){ if (response.rows.length > 0) {
console.log("xxxxxxxxxxx") console.log('xxxxxxxxxxx')
response.rows.forEach(item=>{ response.rows.forEach(item => {
let index = this.fileDataList.findIndex(v => v.fileType == item.fileType) let index = this.fileDataList.findIndex(v => v.fileType == item.fileType)
this.fileDataList[index].fileList.push({ this.fileDataList[index].fileList.push({
name:item.name, name: item.name,
url:item.url url: item.url
}) })
this.fileDataList[index].fileListTemp.push({ this.fileDataList[index].fileListTemp.push({
name:item.name, name: item.name,
url:item.url url: item.url,
id: item.id
}) })
}) })
} }
}) })
.catch(() => {}) .catch(() => {})
}, },
beforeFileUpload(row){ beforeFileUpload(row) {
console.log('🚀 ~ beforeFileUpload ~ row:', row)
this.rowData.fileType = row.fileType this.rowData.fileType = row.fileType
}, },
beforeUpload(row, file) { beforeUpload(row, file) {
row.fileList.push(file); row.fileList.push(file)
console.log('6666666',row.fileList) console.log('6666666', row.fileList)
if (row.fileList.length > 3) { if (row.fileList.length > 3) {
this.$message.warning('最多只能上传三张图片'); this.$message.warning('最多只能上传三张图片')
// //
row.fileList.pop(); row.fileList.pop()
return false; // return false //
} }
return true; // return true //
}, },
// //
handleFileSuccess(row,response, file, fileList) { handleFileSuccess(row, response, file, fileList) {
console.log('🚀 ~ handleFileSuccess ~ row:', row)
if (response.code == 200) { if (response.code == 200) {
if (this.taskId == "") {// //
row.fileListTemp.push({ // row.fileListTemp.push({
"name": response.data.name, // name: response.data.name,
"url": response.data.url, // url: response.data.url
}) // })
// console.log(response)
// console.log(this.rowData)
// console.log(this.rowData.bmFileInfos)
let obj = { let obj = {
"taskId": this.taskId, taskId: this.taskId,
"taskType": "0", taskType: '0',
"name": response.data.name, name: response.data.name,
"url": response.data.url, url: response.data.url,
"modelId": this.rowData.partId, modelId: this.rowData.typeId,
"fileType": this.rowData.fileType, fileType: this.rowData.fileType
// "dictLabel": this.rowData.dictLabel,
} }
// console.log('🚀 ~ handleFileSuccess ~ obj:', obj)
let index = this.fileDataList.findIndex(v=>v.fileType==this.rowData.fileType) bmFileInfoAddApi(obj).then(res => {
this.fileDataList[index].name = response.data.name setTimeout(() => {
this.fileDataList[index].url = response.data.url this.getFileData()
//- }, 500)
if(this.rowData.bmFileInfos.length>0){
let index2 = this.rowData.bmFileInfos.findIndex(v=>v.fileType==this.rowData.fileType)
if(index2>-1){//-
this.rowData.bmFileInfos.splice(index2,0,obj)
}else{//-
this.rowData.bmFileInfos.push(obj)
}
}else{
this.rowData.bmFileInfos.push(obj)
}
} else {//
row.fileListTemp.push({
"name": response.data.name,
"url": response.data.url,
}) })
let obj = {
"taskId": this.taskId,
"taskType": "0",
"name": response.data.name,
"url": response.data.url,
"modelId": this.rowData.partId,
"fileType": this.rowData.fileType,
// "dictLabel": this.rowData.dictLabel,
}
//
let index = this.fileDataList.findIndex(v=>v.fileType==this.rowData.fileType)
this.fileDataList[index].name = response.data.name
this.fileDataList[index].url = response.data.url
//-
if(this.rowData.bmFileInfos.length>0){
let index2 = this.rowData.bmFileInfos.findIndex(v=>v.fileType==this.rowData.fileType)
if(index2>-1){//-
this.rowData.bmFileInfos.splice(index2,0,obj)
}else{//-
this.rowData.bmFileInfos.push(obj)
}
}else{
this.rowData.bmFileInfos.push(obj)
}
uploadPurchaseFile(param).then((response) => {
this.$modal.msgSuccess('上传成功')
}).catch(() => {
this.$modal.msgError('上传失败')
})
}
} }
}, },
@ -373,32 +327,54 @@ export default {
}, },
// //
picturePreview(file) { picturePreview(file) {
this.dialogImageUrl = file.url.replaceAll('#','%23'); this.dialogImageUrl = file.url.replaceAll('#', '%23')
const parts = file.name.split('.'); const parts = file.name.split('.')
const extension = parts.pop(); const extension = parts.pop()
if(extension === 'doc' || extension === 'DOC' || extension === 'docx' || extension === 'DOCX' || extension === 'pdf' || extension === 'PDF'){ if (
const windowName = file.name; extension === 'doc' ||
window.open(file.url,windowName) extension === 'DOC' ||
}else{ extension === 'docx' ||
extension === 'DOCX' ||
extension === 'pdf' ||
extension === 'PDF'
) {
const windowName = file.name
window.open(file.url, windowName)
} else {
this.dialogVisible = true this.dialogVisible = true
} }
}, },
//
handleDelete(row) {
console.log('🚀 ~ handleDelete ~ row:', row)
//
this.$modal.confirm('是否确认删除所选择图片?').then(() => {
bmFileInfoRemoveApi([row.id]).then(res => {
this.dialogVisibleFile = false
this.getFileData()
})
})
},
/** 导出按钮操作 */ /** 导出按钮操作 */
handleExport() { handleExport() {
const formatTime = (date) => { const formatTime = date => {
const year = date.getFullYear(); const year = date.getFullYear()
const month = String(date.getMonth() + 1).padStart(2, '0'); const month = String(date.getMonth() + 1).padStart(2, '0')
const day = String(date.getDate()).padStart(2, '0'); const day = String(date.getDate()).padStart(2, '0')
const hours = String(date.getHours()).padStart(2, '0'); const hours = String(date.getHours()).padStart(2, '0')
const minutes = String(date.getMinutes()).padStart(2, '0'); const minutes = String(date.getMinutes()).padStart(2, '0')
const seconds = String(date.getSeconds()).padStart(2, '0'); const seconds = String(date.getSeconds()).padStart(2, '0')
return `${year}${month}${day}_${hours}${minutes}${seconds}`; return `${year}${month}${day}_${hours}${minutes}${seconds}`
}; }
const currentTime = formatTime(new Date()); const currentTime = formatTime(new Date())
this.download('/material/purchase_check_info/exportDetails',{taskId:this.taskId,id:this.id,taskStage: 1},`新购到货详情_${currentTime}.xlsx`) this.download(
}, '/material/purchase_check_info/exportDetails',
}, { taskId: this.taskId, id: this.id, taskStage: 1 },
`新购到货详情_${currentTime}.xlsx`
)
}
}
} }
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>