From 7ddb7f6d597bf264a294393008d18ca89e7084da Mon Sep 17 00:00:00 2001
From: shuishen <1109946754@qq.com>
Date: Wed, 28 Jan 2026 18:47:28 +0800
Subject: [PATCH] Merge branch 'master' of http://139.196.74.78:10010/r/jagzwxm/ja_web

---
 applications/task-work-order/src/views/orderView/orderDataManage/dataObjection/FormDiaLog.vue |  217 ++++++++++++++++++++++++++++++++++++-----------------
 1 files changed, 147 insertions(+), 70 deletions(-)

diff --git a/applications/task-work-order/src/views/orderView/orderDataManage/dataObjection/FormDiaLog.vue b/applications/task-work-order/src/views/orderView/orderDataManage/dataObjection/FormDiaLog.vue
index c5d77b1..6d685f0 100644
--- a/applications/task-work-order/src/views/orderView/orderDataManage/dataObjection/FormDiaLog.vue
+++ b/applications/task-work-order/src/views/orderView/orderDataManage/dataObjection/FormDiaLog.vue
@@ -7,7 +7,7 @@
 		destroy-on-close
 		:close-on-click-modal="false"
 	>
-		<div class="detail-container" v-if="dialogReadonly">
+		<div class="detail-container  detail-container1" v-if="dialogReadonly">
 			<el-row class="detail-row-view">
 				<el-col :span="12">
 					<div class="label">标题</div>
@@ -50,7 +50,7 @@
 					<div class="val">{{ formData.reviewOpinion  }}</div>
 				</el-col>
 			</el-row>
-			<div v-if=" detailObjectionStatus === '1'">
+			<div v-if=" detailObjectionStatus === '1' && !requesterProvider">
 				<div class="detail-title" :style="{ marginTop:pxToRem(20)}">异议反馈</div>
 				<el-form ref="feedbackFormRef" class="gd-dialog-form" :model="feedbackFormData"
 								 :rules="feedbackRules" label-width="140px">
@@ -153,7 +153,6 @@
 						<div class="upload-container">
 							<el-upload
 								:http-request="handleHttpRequest"
-								:limit="3"
 								:on-success="handleUploadSuccess"
 								:on-error="handleUploadError"
 								:on-remove="handleFileRemove"
@@ -166,7 +165,7 @@
 									<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>
 						</div>
@@ -178,18 +177,18 @@
 		<template #footer>
 			<template v-if="!dialogReadonly">
 				<el-button
-					color="#F2F3F5"
+		color="#F2F3F5"
 
-					v-if="!dialogReadonly"
-					:loading="submitting"
-					:disabled="submitting"
-					@click="handleSubmit"
-				>
-					保存
-				</el-button>
-				<el-button class="" color="#4C34FF" :loading="submitting" :disabled="submitting" @click="handleApply">申请</el-button>
+		v-if="!dialogReadonly"
+		:loading="submitting || uploading"
+		:disabled="submitting || uploading"
+		@click="handleSubmit"
+	>
+		保存
+	</el-button>
+	<el-button class="" color="#4C34FF" :loading="submitting || uploading" :disabled="submitting || uploading" @click="handleApply">申请</el-button>
 			</template>
-			<template v-if="dialogReadonly && detailObjectionStatus === '1'">
+			<template v-if="dialogReadonly && detailObjectionStatus === '1' && !requesterProvider">
 				<el-button color="#F2F3F5" :loading="submitting" :disabled="submitting" @click="visible = false">取消</el-button>
 
 				<el-button
@@ -233,8 +232,12 @@
 } from '@/views/orderView/orderDataManage/dataObjection/dataObjectionApi'
 import { putFileAttachApi } from '@/views/orderView/orderDataManage/supplyAdd/supplyAddApi'
 import { pxToRem } from '@/utils/rem'
+import { useStore } from 'vuex'
+const store = useStore()
+const requesterProvider = computed(() => store.state.user.userInfo?.role_id === '2014158512610869250')
 // 初始化表单数据
 const initForm = () => ({
+	id:'',
 	title: '',
 	objectionType: '',
 	submitter: '',
@@ -278,6 +281,7 @@
 const fileList = ref([]) // 上传文件列表
 const uploadedFiles = ref([]) // 已上传文件列表
 const attachmentDetailsList = ref([])
+const uploading = ref(false) // 文件上传中状态
 
 // 表单校验规则
 const rules = {
@@ -288,6 +292,8 @@
 	catalogResourceName: fieldRules(true),
 	objectionDesc: fieldRules(true),
 	objectionBasis: fieldRules(true),
+	// attachId: dialogMode.value === 'add' ? fieldRules(true) : fieldRules(false)
+
 }
 
 // 异议反馈表单校验规则
@@ -298,6 +304,7 @@
 
 // 自定义上传请求
 const handleHttpRequest = async options => {
+	uploading.value = true
 	try {
 		const formDataObj = new FormData()
 		formDataObj.append('file', options.file)
@@ -310,16 +317,27 @@
 	} catch (error) {
 		options.onError(error)
 		console.error('文件上传失败:', error)
+	} finally {
+		uploading.value = false
 	}
 }
 
 // 文件移除
+// const handleFileRemove = (file, fileListVal) => {
+// uploadedFiles.value = fileListVal
+// }
 const handleFileRemove = (file, fileListVal) => {
-	if (file.response && file.response.attachId) {
-		uploadedFiles.value = uploadedFiles.value.filter(item => item.attachId !== file.response.attachId)
-	}
+  // 从展示列表中移除
+  fileList.value = fileListVal
+  
+  // 从已上传列表中移除
+  const index = uploadedFiles.value.findIndex(item => 
+    item.attachId === file.attachId || item.name === file.name
+  )
+  if (index > -1) {
+    uploadedFiles.value.splice(index, 1)
+  }
 }
-
 // 上传前验证
 const beforeFileUpload = file => {
 	const allowedExtensions = ['.zip', '.rar', '.7z', '.tar', '.gz']
@@ -328,11 +346,11 @@
 		ElMessage.error('只能上传压缩文件格式:.zip/.rar/.7z/.tar/.gz')
 		return false
 	}
-	const maxSize = 100 * 1024 * 1024 // 100MB
-	if (file.size > maxSize) {
-		ElMessage.error('文件大小不能超过100MB')
-		return false
-	}
+	// const maxSize = 100 * 1024 * 1024 // 100MB
+	// if (file.size > maxSize) {
+	// 	ElMessage.error('文件大小不能超过100MB')
+	// 	return false
+	// }
 	return true
 }
 
@@ -357,35 +375,53 @@
 
 // 提交数据的通用函数
 async function submitForm(objectionStatus) {
-	const isValid = await formRef.value?.validate().catch(() => false)
-	if (!isValid) return
-	submitting.value = true
-	try {
-		// 构建符合接口要求的提交数据
-		const submitData = {
-			title: formData.value.title,
-			objectionType: formData.value.objectionType,
-			submitter: formData.value.submitter,
-			submitterContact: formData.value.submitterContact,
-			catalogResourceName: formData.value.catalogResourceName,
-			objectionDesc: formData.value.objectionDesc,
-			objectionBasis: formData.value.objectionBasis,
-			areaCode: formData.value.areaCode || '',
-			handleUnit: formData.value.handleUnit || '',
-			// 构建附件列表
-			attachmentList: uploadedFiles.value.map(file => ({
-				attachId: file.attachId,
-				attachName: file.originalName,
-			})),
-			objectionStatus: objectionStatus
-		}
-		await gdDataObjectionSubmitApi(submitData)
-		ElMessage.success(dialogMode.value === 'add' ? '新增成功' : '更新成功')
-		visible.value = false
-		emit('success')
-	} finally {
-		submitting.value = false
-	}
+  const isValid = await formRef.value?.validate().catch(() => false)
+  if (!isValid) return
+  
+  // 在编辑模式下,如果已有附件,可以不强制上传新附件
+  if (dialogMode.value === 'add' && uploadedFiles.value.length === 0) {
+    return ElMessage.warning('请上传附件')
+  }
+  
+  submitting.value = true
+
+  try {
+    // 构建符合接口要求的提交数据
+    const submitData = {
+      // 编辑模式下传递id
+      ...(formData.value.id && { id: formData.value.id }),
+      title: formData.value.title,
+      objectionType: formData.value.objectionType,
+      submitter: formData.value.submitter,
+      submitterContact: formData.value.submitterContact,
+      catalogResourceName: formData.value.catalogResourceName,
+      objectionDesc: formData.value.objectionDesc,
+      objectionBasis: formData.value.objectionBasis,
+      areaCode: formData.value.areaCode || '',
+      handleUnit: formData.value.handleUnit || '',
+      // 构建附件列表 - 使用当前已上传的文件(包括回显的)
+			...(uploadedFiles.value.length > 0 && {
+				attachmentList: uploadedFiles.value.map(file => ({
+					attachId: file.attachId,
+					attachName: file.originalName,
+				})),
+			}),
+      objectionStatus: objectionStatus
+    }
+    
+    // 如果是编辑且没有修改附件,可以保留原有附件ID
+    if (dialogMode.value === 'edit' && formData.value.attachIds) {
+      // 这里可以根据业务需求决定是否保留原附件ID
+      // 如果接口支持更新时重新上传附件ID列表,可以这样做
+    }
+    
+    await gdDataObjectionSubmitApi(submitData)
+    ElMessage.success(dialogMode.value === 'add' ? '新增成功' : '更新成功')
+    visible.value = false
+    emit('success')
+  } finally {
+    submitting.value = false
+  }
 }
 
 // 提交新增/编辑(保存)
@@ -422,12 +458,42 @@
 }
 // 加载详情
 async function loadDetail() {
-	if (!formData.value.id) return
-	const res = await gdDataObjectionDetailApi({ id: formData.value.id })
-	formData.value = res?.data?.data ?? {}
-	if (formData.value.attachIds) {
-		getAttachDetail(formData.value.attachIds)
-	}
+  if (!formData.value.id) return
+  const res = await gdDataObjectionDetailApi({ id: formData.value.id })
+  formData.value = res?.data?.data ?? {}
+  
+  // 处理附件回显
+  if (formData.value.attachIds) {
+    await getAttachDetail(formData.value.attachIds)
+    // 回显到上传组件
+    updateFileListForDisplay()
+  }
+}
+
+// 更新文件列表用于显示
+function updateFileListForDisplay() {
+  fileList.value = []
+  uploadedFiles.value = []
+  
+  if (attachmentDetailsList.value && attachmentDetailsList.value.length > 0) {
+    attachmentDetailsList.value.forEach(attach => {
+      const fileItem = {
+        name: attach.originalName || attach.name,
+        url: attach.link, // 用于预览
+        attachId: attach.id, // 文件ID
+        originalName: attach.originalName,
+        link: attach.link
+      }
+      
+      fileList.value.push({
+        name: fileItem.name,
+        url: fileItem.url,
+        status: 'success' // 已上传状态
+      })
+      
+      uploadedFiles.value.push(fileItem)
+    })
+  }
 }
 // 获取附件详情
 async function getAttachDetail(attachIds) {
@@ -436,7 +502,6 @@
 	const detailPromises = ids.map(id => getAttachDetailApi({ id }))
 	const results = await Promise.all(detailPromises)
 	attachmentDetailsList.value = results.map(res => res.data.data).filter(Boolean)
-	console.log('附件详情', attachmentDetailsList.value)
 }
 // 处理附件下载
 async function handleDownloadAttach() {
@@ -462,25 +527,37 @@
 
 // 打开弹框
 async function open({ mode = 'add', row } = {}) {
-	dialogMode.value = mode
-	// 重置文件列表
-	fileList.value = []
-	uploadedFiles.value = []
-	// 重置表单数据
-	formData.value = dialogMode.value === 'add' ? initForm() : row
-	// 重置反馈表单数据
-	feedbackFormData.value = initFeedbackForm()
-	if (dialogMode.value !== 'add') {
-		await loadDetail()
-	}
+  dialogMode.value = mode
+  // 重置文件列表
+  fileList.value = []
+  uploadedFiles.value = []
+  // 重置表单数据
+  formData.value = dialogMode.value === 'add' ? initForm() : row
+  // 重置反馈表单数据
+  feedbackFormData.value = initFeedbackForm()
+  
+  if (dialogMode.value !== 'add') {
+    // 如果是编辑,设置ID并加载详情
+    if (row && row.id) {
+      formData.value.id = row.id
+    }
+    await loadDetail()
+  }
 }
 
 defineExpose({ open })
 </script>
 
 <style scoped lang="scss">
+.detail-container1 {
+display: flex;
+flex-direction: column;
+}
 .upload-container {
 	width: 100%;
+	.el-upload__tip {
+		display: inline;
+	}
 }
 .label {
 	width: 120px !important;

--
Gitblit v1.9.3