From 17bdc12280602e882f42445d10d68e9e2575773f Mon Sep 17 00:00:00 2001
From: gongchunyi <deslre0381@gmail.com>
Date: 星期二, 03 三月 2026 09:15:20 +0800
Subject: [PATCH] feat: 售后附件与临期售后信息接口对接

---
 src/views/customerService/afterSalesHandling/index.vue |  105 ++++++++++++++++++++++++++++------------------------
 1 files changed, 56 insertions(+), 49 deletions(-)

diff --git a/src/views/customerService/afterSalesHandling/index.vue b/src/views/customerService/afterSalesHandling/index.vue
index c3a19b4..9f3b25a 100644
--- a/src/views/customerService/afterSalesHandling/index.vue
+++ b/src/views/customerService/afterSalesHandling/index.vue
@@ -263,7 +263,7 @@
 	}
 }
 
-// 鎵撳紑闄勪欢寮规-----  TODO锛氭帴鍙f槸娌℃湁瀵规帴鐨勶紝闇�瑕佹柊澧炴帴鍙o紝涓哄啓鎶ュ憡娣诲姞鐨�
+// 鎵撳紑闄勪欢寮规
 const openFilesFormDia = async (row) => {
 	currentFileRow.value = row
 	try {
@@ -311,8 +311,9 @@
 			try {
 				const formData = new FormData()
 				formData.append("file", file)
+				formData.append("id", currentFileRow.value.id)
 				const uploadRes = await request({
-					url: "/file/upload",
+					url: "/afterSalesService/file/upload",
 					method: "post",
 					data: formData,
 					headers: {
@@ -321,33 +322,23 @@
 					},
 				})
 				if (uploadRes.code === 200) {
-					const fileData = {
+					proxy.$modal.msgSuccess("鏂囦欢涓婁紶鎴愬姛")
+					// 閲嶆柊鑾峰彇鏂囦欢鍒楄〃
+					const listRes = await afterSalesServiceFileListPage({
 						afterSalesServiceId: currentFileRow.value.id,
-						name: uploadRes.data?.originalName || file.name,
-						url: uploadRes.data?.tempPath || uploadRes.data?.url,
+						current: 1,
+						size: 100,
+					})
+					if (listRes.code === 200 && fileListRef.value) {
+						const fileList = (listRes.data?.records || []).map((item) => ({
+							name: item.fileName,
+							url: item.fileUrl,
+							id: item.id,
+							...item,
+						}))
+						fileListRef.value.setList(fileList)
 					}
-					const saveRes = await afterSalesServiceFileAdd(fileData)
-					if (saveRes.code === 200) {
-						proxy.$modal.msgSuccess("鏂囦欢涓婁紶鎴愬姛")
-						const listRes = await afterSalesServiceFileListPage({
-							afterSalesServiceId: currentFileRow.value.id,
-							current: 1,
-							size: 100,
-						})
-						if (listRes.code === 200 && fileListRef.value) {
-							const fileList = (listRes.data?.records || []).map((item) => ({
-								name: item.name || item.fileName,
-								url: item.url || item.fileUrl,
-								id: item.id,
-								...item,
-							}))
-							fileListRef.value.setList(fileList)
-						}
-						resolve({ name: fileData.name, url: fileData.url, id: saveRes.data?.id })
-					} else {
-						proxy.$modal.msgError(saveRes.msg || "鏂囦欢淇濆瓨澶辫触")
-						resolve(null)
-					}
+					resolve({ name: file.name, url: "", id: null })
 				} else {
 					proxy.$modal.msgError(uploadRes.msg || "鏂囦欢涓婁紶澶辫触")
 					resolve(null)
@@ -367,31 +358,47 @@
 // 鍒犻櫎闄勪欢
 const handleFileDelete = async (row) => {
 	try {
-		const res = await afterSalesServiceFileDel([row.id])
-		if (res.code === 200) {
-			proxy.$modal.msgSuccess("鍒犻櫎鎴愬姛")
-			if (currentFileRow.value && fileListRef.value) {
-				const listRes = await afterSalesServiceFileListPage({
-					afterSalesServiceId: currentFileRow.value.id,
-					current: 1,
-					size: 100,
-				})
-				if (listRes.code === 200) {
-					const fileList = (listRes.data?.records || []).map((item) => ({
-						name: item.name || item.fileName,
-						url: item.url || item.fileUrl,
-						id: item.id,
-						...item,
-					}))
-					fileListRef.value.setList(fileList)
-				}
+		// 娣诲姞纭瀵硅瘽妗�
+		const confirmResult = await ElMessageBox.confirm(
+			'纭畾瑕佸垹闄よ繖涓檮浠跺悧锛�',
+			'鍒犻櫎纭',
+			{
+				confirmButtonText: '纭畾',
+				cancelButtonText: '鍙栨秷',
+				type: 'warning'
 			}
-		} else {
-			proxy.$modal.msgError(res.msg || "鍒犻櫎澶辫触")
-			return false
+		)
+
+		if (confirmResult === 'confirm') {
+			const res = await afterSalesServiceFileDel(row.id)
+			if (res.code === 200) {
+				proxy.$modal.msgSuccess("鍒犻櫎鎴愬姛")
+				if (currentFileRow.value && fileListRef.value) {
+					const listRes = await afterSalesServiceFileListPage({
+						afterSalesServiceId: currentFileRow.value.id,
+						current: 1,
+						size: 100,
+					})
+					if (listRes.code === 200) {
+						const fileList = (listRes.data?.records || []).map((item) => ({
+							name: item.fileName,
+							url: item.fileUrl,
+							id: item.id,
+							...item,
+						}))
+						fileListRef.value.setList(fileList)
+					}
+				}
+			} else {
+				proxy.$modal.msgError(res.msg || "鍒犻櫎澶辫触")
+				return false
+			}
 		}
 	} catch (error) {
-		proxy.$modal.msgError("鍒犻櫎澶辫触")
+		// 濡傛灉鐢ㄦ埛鍙栨秷鍒犻櫎锛屼笉鏄剧ず閿欒淇℃伅
+		if (error !== 'cancel') {
+			proxy.$modal.msgError("鍒犻櫎澶辫触")
+		}
 		return false
 	}
 }

--
Gitblit v1.9.3