From de1b2a2d4e856fd4769f3d96d8c4f048fe5f9004 Mon Sep 17 00:00:00 2001
From: 罗广辉 <guanghui.luo@foxmail.com>
Date: Tue, 20 Jan 2026 18:56:32 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'
---
applications/task-work-order/src/views/orderView/orderDataManage/supplyAdd/ApplyViewDialog.vue | 289 +++++++++++++++++++++++++++++++++++++--------------------
1 files changed, 185 insertions(+), 104 deletions(-)
diff --git a/applications/task-work-order/src/views/orderView/orderDataManage/supplyAdd/ApplyViewDialog.vue b/applications/task-work-order/src/views/orderView/orderDataManage/supplyAdd/ApplyViewDialog.vue
index 5e9f0d5..b03e587 100644
--- a/applications/task-work-order/src/views/orderView/orderDataManage/supplyAdd/ApplyViewDialog.vue
+++ b/applications/task-work-order/src/views/orderView/orderDataManage/supplyAdd/ApplyViewDialog.vue
@@ -9,9 +9,9 @@
<div class="detail-right">
<!-- 拒绝申请-->
<div class="reject-reason-container" v-if="detailDemandStatus === '3'">
- <div class="label">拒绝原因 </div>
+ <div class="label">拒绝原因</div>
<div class="reject-reason">
- 这是拒绝原因这是拒绝原因这是拒绝原因这是拒绝原因这是拒绝原因这是拒绝原因这是拒绝原因这是拒绝原因这是拒绝原因这是拒绝原因这是拒绝原因这是拒绝原因这是拒绝原因这是拒绝原因这是拒绝原因这是拒绝原因这是拒绝原因这是拒绝原因这是拒绝原因这是拒绝原因这是拒绝原因这是拒绝原因
+ {{reasonForRejection}}
</div>
</div>
<div>
@@ -81,48 +81,65 @@
</div>
</div>
</div>
-<!-- 申请中-->
+ <!-- 申请中-->
<div v-if="detailDemandStatus === '1'">
- <div class="label">数据上传 </div>
+ <div class="label">数据上传</div>
<div class="upload-container">
<el-upload
- ref="uploadRef"
- :auto-upload="false"
- :limit="1"
- :on-change="handleFileChange"
- :on-remove="handleFileRemove"
- :before-upload="beforeFileUpload"
- :file-list="fileList"
- accept=".zip,.rar,.7z,.tar,.gz"
- class="upload-demo"
- >
+ :http-request="handleHttpRequest"
+ :limit="3"
+ :on-success="handleUploadSuccess"
+ :on-error="handleUploadError"
+ :on-remove="handleFileRemove"
+ :before-upload="beforeFileUpload"
+ :file-list="fileList"
+ accept=".zip,.rar,.7z,.tar,.gz"
+ class="upload-demo"
+ >
<template #trigger>
<el-button type="primary">选择文件</el-button>
</template>
<template #tip>
- <div class="el-upload__tip">请上传压缩文件 (.zip/.rar/.7z/.tar/.gz)</div>
+ <div class="el-upload__tip">支持上传 (.zip/.rar/.7z/.tar/.gz)格式文件</div>
</template>
</el-upload>
- <el-button type="success" :disabled="!selectedFile" @click="handleUpload" style="margin-top: 10px">
- 上传文件
- </el-button>
<!-- 已上传文件列表 -->
- <div v-if="uploadedFiles.length > 0" class="uploaded-files">
- <h4>已上传文件:</h4>
- <div v-for="(file, index) in uploadedFiles" :key="index" class="file-item">
- <span>{{ file.originalName }}</span>
- <el-button type="text" @click="viewFile(file)" style="margin-left: 10px">查看</el-button>
- <el-button type="text" @click="downloadFile(file)" style="margin-left: 5px">下载</el-button>
- </div>
- </div>
+<!-- <div v-if="uploadedFiles.length > 0" class="uploaded-files">-->
+<!-- <h4>已上传文件:</h4>-->
+<!-- <div v-for="(file, index) in uploadedFiles" :key="index" class="file-item">-->
+<!-- <span>{{ file.originalName }}</span>-->
+<!-- <el-button type="text" @click="viewFile(file)" style="margin-left: 10px">查看</el-button>-->
+<!-- <el-button type="text" @click="downloadFile(file)" style="margin-left: 5px">下载</el-button>-->
+<!-- </div>-->
+<!-- </div>-->
</div>
+ </div>
+ <div v-if="detailDemandStatus === '2'">
+ <div class="label">数据详情</div>
+ <el-table :data="tableData" border style="width: 100%">
+ <el-table-column prop="fileOriginalName" label="文件名称" />
+ <el-table-column prop="fileSize" label="文件大小" />
+ <el-table-column fixed="right" label="操作" min-width="100">
+ <template #default="scope">
+ <el-button link type="text" @click="downloadFileFromTable(scope.row)">下载</el-button>
+ </template>
+ </el-table-column>
+ </el-table>
</div>
</div>
</div>
<template #footer>
- <el-button class="save-btn" color="#4C34FF" @click="rejectTheApplication">拒绝申请</el-button>
- <el-button color="#F2F3F5" @click="approvedByTheReview">审核通过</el-button>
+ <template v-if="detailDemandStatus === '1'">
+ <el-button class="save-btn" color="#4C34FF" @click="rejectTheApplication">拒绝申请</el-button>
+ <el-button color="#F2F3F5" @click="approvedByTheReview">审核通过</el-button>
+ </template>
+ <template v-if="detailDemandStatus === '2'">
+ <el-button class="save-btn" color="#4C34FF" @click="downloadAllFiles">全部下载</el-button>
+ </template>
+ <template v-if="detailDemandStatus === '3'">
+ <el-button class="save-btn" color="#4C34FF" @click="visible =false">关闭</el-button>
+ </template>
</template>
</el-dialog>
@@ -140,7 +157,8 @@
gdSupplyDemandDetailApi,
putFileAttachApi,
gdSupplyDemandAuditPassApi,
- gdSupplyDemandAuditRejectApi
+ gdSupplyDemandAuditRejectApi,
+ gdSupplyDemandAuditAttachmentListApi,
} from '@/views/orderView/orderDataManage/supplyAdd/supplyAddApi'
import { ElMessage } from 'element-plus'
import reasonForRejectionDialog from '@/views/orderView/orderDataManage/supplyAdd/reasonForRejectionDialog.vue'
@@ -150,30 +168,49 @@
const dictObj = inject('dictObj')
const deptTree = inject('deptTree')
const detailDemandStatus = inject('detailDemandStatus')
+const reasonForRejection = inject('reasonForRejection')
const demandId = ref('')
const visible = defineModel() // 弹框显隐
const formData = ref({}) // 表单数据
-const uploadRef = ref() // 上传组件引用
-const selectedFile = ref(null) // 选择的文件
const fileList = ref([]) // 上传文件列表
const uploadedFiles = ref([]) // 已上传文件列表
-const uploadLoading = ref(false) // 上传加载状态
-const responseData = ref([])
-// 拒绝申请弹框控制
-const rejectionDialogVisible = ref(false) // 拒绝申请弹框显隐
+const responseData = ref(null)
+// 自定义上传请求函数
+const handleHttpRequest = async (options) => {
+ try {
+ // 创建FormData对象
+ const formData = new FormData()
+ formData.append('file', options.file)
-// 文件选择变化
-const handleFileChange = (file, fileList) => {
- if (fileList.length > 0) {
- selectedFile.value = file.raw
- } else {
- selectedFile.value = null
+ // 调用导入的API函数
+ const response = await putFileAttachApi(formData)
+ console.log('response',response)
+ if (response.data && response.data.success) {
+ // 调用上传成功的回调
+ options.onSuccess(response)
+ } else {
+ // 调用上传失败的回调
+ options.onError(new Error(response.data?.msg || '文件上传失败'))
+ }
+ } catch (error) {
+ // 调用上传失败的回调
+ options.onError(error)
+ console.error('文件上传失败:', error)
}
}
-
+// 拒绝申请弹框控制
+const rejectionDialogVisible = ref(false) // 拒绝申请弹框显隐
+const tableData = ref([]) // 附件表格数据
// 文件移除
-const handleFileRemove = () => {
- selectedFile.value = null
+const handleFileRemove = (file, fileList) => {
+ // 从已上传文件列表中移除对应文件
+ if (file.response && file.response.attachId) {
+ uploadedFiles.value = uploadedFiles.value.filter(item => item.attachId !== file.response.attachId)
+ }
+ // 清空响应数据
+ if (responseData.value && responseData.value.attachId === file.response?.attachId) {
+ responseData.value = null
+ }
}
// 上传前验证
@@ -196,57 +233,28 @@
return true
}
-// 处理文件上传
-const handleUpload = async () => {
- if (!selectedFile.value) {
- ElMessage.warning('请先选择文件')
- return
- }
+// 上传成功处理函数
+const handleUploadSuccess = (response, file, fileList) => {
+ // 添加更严格的检查,确保response不是undefined
+ if (response && response?.data && response?.data?.success) {
+ const fileData = response.data.data
+ console.log('成功数据', fileData)
+ responseData.value = fileData
+ // 添加到已上传文件列表
+ uploadedFiles.value.push({
+ name: fileData.name,
+ originalName: fileData.originalName,
+ link: fileData.link,
+ attachId: fileData.attachId,
+ })
- // 再次验证文件类型
- if (!beforeFileUpload(selectedFile.value)) {
- return
- }
+ ElMessage.success('文件上传成功!')
+ }
+}
- try {
- uploadLoading.value = true
-
- // 创建FormData对象
- const formData = new FormData()
- formData.append('file', selectedFile.value)
-
- // 调用上传接口
- const response = await putFileAttachApi(formData)
-
- if (response.data && response.data.success) {
- const fileData = response.data.data
- console.log('成功数据', fileData)
- responseData.value = fileData
- // 添加到已上传文件列表
- uploadedFiles.value.push({
- name: fileData.name,
- originalName: fileData.originalName,
- link: fileData.link,
- attachId: fileData.attachId,
- })
-
- ElMessage.success('文件上传成功!')
-
- // 清空上传列表
- uploadRef.value.clearFiles()
- selectedFile.value = null
-
- // 这里可以将附件ID保存到表单数据中,供后续提交使用
- // formData.value.attachmentId = fileData.attachId
- } else {
- ElMessage.error(response.data?.msg || '文件上传失败')
- }
- } catch (error) {
- console.error('文件上传失败:', error)
- ElMessage.error('文件上传失败,请重试')
- } finally {
- uploadLoading.value = false
- }
+// 上传失败处理函数
+const handleUploadError = (error, file, fileList) => {
+ ElMessage.error(error?.message || '文件上传失败,请重试')
}
// 查看文件
@@ -271,6 +279,52 @@
} else {
ElMessage.warning('文件链接无效')
}
+}
+
+// 从表格下载文件
+const downloadFileFromTable = file => {
+ if (file.fileUrl) {
+ // 创建一个隐藏的a标签来触发下载
+ const a = document.createElement('a')
+ a.href = file.fileUrl
+ a.download = file.name || 'attachment'
+ document.body.appendChild(a)
+ a.click()
+ document.body.removeChild(a)
+ } else {
+ ElMessage.warning('文件链接无效')
+ }
+}
+
+// 下载所有文件
+const downloadAllFiles = () => {
+ if (!tableData.value || tableData.value.length === 0) {
+ ElMessage.warning('没有可下载的文件')
+ return
+ }
+
+ // 统计有效文件数量
+ const validFiles = tableData.value.filter(file => file.fileUrl)
+ if (validFiles.length === 0) {
+ ElMessage.warning('所有文件链接均无效')
+ return
+ }
+
+ ElMessage.success(`开始下载${validFiles.length}个文件`)
+
+ // 依次下载每个文件(添加延迟以避免浏览器限制)
+ validFiles.forEach((file, index) => {
+ setTimeout(() => {
+ if (file.fileUrl) {
+ const a = document.createElement('a')
+ a.href = file.fileUrl
+ a.download = file.name || `attachment_${index + 1}`
+ document.body.appendChild(a)
+ a.click()
+ document.body.removeChild(a)
+ }
+ }, index * 300) // 300ms delay between downloads
+ })
}
// 根据部门ID获取部门名称
@@ -317,11 +371,34 @@
data.responsibleDeptName = getDeptNameById(data.responsibleDeptId, deptTree.value)
}
formData.value = data
+
+ // 加载附件数据
+ await loadAttachments(id)
+}
+
+// 加载附件数据
+async function loadAttachments(demandId) {
+ try {
+ const res = await gdSupplyDemandAuditAttachmentListApi({ demandId: demandId })
+ const attachments = res?.data?.data ?? []
+
+ // 格式化附件数据以匹配表格结构
+ tableData.value = attachments.map(attachment => ({
+ fileOriginalName: attachment.fileOriginalName ,
+ fileSize: attachment.fileSize ? `${attachment.fileSize}M` : '',
+ fileUrl: attachment.fileUrl,
+ id: attachment.id,
+ }))
+ } catch (error) {
+ console.error('加载附件数据失败:', error)
+ ElMessage.error('加载附件数据失败,请重试')
+ tableData.value = []
+ }
}
// 拒绝申请
const rejectTheApplication = () => {
- if (responseData.value.length === 0) {
+ if (uploadedFiles.value.length === 0) {
return ElMessage.warning('请上传数据')
}
// 打开拒绝申请弹框
@@ -330,7 +407,9 @@
// 处理拒绝申请确认
const handleRejectionConfirm = reason => {
- const id = [responseData.value.attachId]
+ // 从 uploadedFiles.value 中提取所有 attachId
+ const id = uploadedFiles.value.map(file => file.attachId)
+
gdSupplyDemandAuditRejectApi({ attachIds: id, auditOpinion: reason, demandId: demandId.value })
.then(() => {
ElMessage.success('拒绝申请成功')
@@ -345,10 +424,11 @@
}
// 审核通过
const approvedByTheReview = () => {
- if (responseData.value.length === 0) {
+ if (uploadedFiles.value.length === 0) {
return ElMessage.warning('请上传数据')
}
- const id = [responseData.value.attachId]
+ // 从 uploadedFiles.value 中提取所有 attachId
+ const id = uploadedFiles.value.map(file => file.attachId)
gdSupplyDemandAuditPassApi({ attachIds: id, demandId: demandId.value }).then(() => {
ElMessage.success('审核通过成功')
visible.value = false
@@ -379,12 +459,13 @@
width: 75%;
.reject-reason {
margin-bottom: 20px;
- background: #F2F3F5;
+ background: #f2f3f5;
border-radius: 2px 2px 2px 2px;
padding: 15px;
+ height: 100px;
}
.requirementsDetailsBox {
- background: #F2F3F5;
+ background: #f2f3f5;
border-radius: 2px 2px 2px 2px;
}
@@ -430,20 +511,20 @@
/* 上传容器样式 */
.upload-container {
padding: 15px;
- background: #F2F3F5;
+ background: #f2f3f5;
border-radius: 2px 2px 2px 2px;
}
.uploaded-files {
margin-top: 15px;
-
+
h4 {
margin-bottom: 10px;
font-size: 14px;
color: #333333;
font-weight: 500;
}
-
+
.file-item {
display: flex;
align-items: center;
@@ -451,7 +532,7 @@
background: white;
border-radius: 4px;
margin-bottom: 5px;
-
+
span {
flex: 1;
color: #333;
@@ -476,4 +557,4 @@
:deep(.el-upload-list) {
margin-top: 10px;
}
-</style>
\ No newline at end of file
+</style>
--
Gitblit v1.9.3