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/expiryAfterSales/index.vue              |   72 ++++++++++-------
 src/api/customerService/index.js                                  |   16 +--
 src/views/customerService/afterSalesHandling/index.vue            |  105 ++++++++++++++------------
 src/views/customerService/expiryAfterSales/components/formDia.vue |   42 +++++++---
 4 files changed, 134 insertions(+), 101 deletions(-)

diff --git a/src/api/customerService/index.js b/src/api/customerService/index.js
index 9f458b6..ee3272a 100644
--- a/src/api/customerService/index.js
+++ b/src/api/customerService/index.js
@@ -59,11 +59,10 @@
   })
 }
 // 鍞悗澶勭悊-闄勪欢鍒犻櫎
-export function afterSalesServiceFileDel(ids) {
+export function afterSalesServiceFileDel(id) {
   return request({
-    url: '/afterSalesService/file/del',
+    url: `/afterSalesService/file/del/${id}`,
     method: 'delete',
-    data: ids,
   })
 }
 
@@ -79,7 +78,7 @@
 // 涓存湡鍞悗绠$悊-鍒嗛〉鏌ヨ
 export function expiryAfterSalesListPage(query) {
   return request({
-    url: '/expiryAfterSales/listPage',
+    url: '/afterSalesNearExpiryService/listPage',
     method: 'get',
     params: query,
   })
@@ -88,7 +87,7 @@
 // 涓存湡鍞悗绠$悊-鏂板
 export function expiryAfterSalesAdd(query) {
   return request({
-    url: '/expiryAfterSales/add',
+    url: '/afterSalesNearExpiryService/add',
     method: 'post',
     data: query,
   })
@@ -97,17 +96,16 @@
 // 涓存湡鍞悗绠$悊-鏇存柊
 export function expiryAfterSalesUpdate(query) {
   return request({
-    url: '/expiryAfterSales/update',
+    url: '/afterSalesNearExpiryService/update',
     method: 'post',
     data: query,
   })
 }
 
 // 涓存湡鍞悗绠$悊-鍒犻櫎
-export function expiryAfterSalesDelete(query) {
+export function expiryAfterSalesDelete(ids) {
   return request({
-    url: '/expiryAfterSales/delete',
+    url: '/afterSalesNearExpiryService/delete?ids=' + ids,
     method: 'delete',
-    data: query,
   })
 }
\ No newline at end of file
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
 	}
 }
diff --git a/src/views/customerService/expiryAfterSales/components/formDia.vue b/src/views/customerService/expiryAfterSales/components/formDia.vue
index e8293d6..2fe603b 100644
--- a/src/views/customerService/expiryAfterSales/components/formDia.vue
+++ b/src/views/customerService/expiryAfterSales/components/formDia.vue
@@ -161,8 +161,8 @@
 import {ref, computed} from "vue";
 import useUserStore from "@/store/modules/user.js";
 import { getCurrentDate } from "@/utils/index.js";
-// import {userListNoPageByTenantId} from "@/api/system/user.js"; // 鏆傛椂娉ㄩ噴鎺夛紝浣跨敤鍋囨暟鎹�
-// import {expiryAfterSalesAdd, expiryAfterSalesUpdate} from "@/api/customerService/index.js"; // 鏆傛椂娉ㄩ噴鎺夛紝浣跨敤鍋囨暟鎹�
+import {userListNoPageByTenantId} from "@/api/system/user.js";
+import {expiryAfterSalesAdd, expiryAfterSalesUpdate} from "@/api/customerService/index.js";
 const { proxy } = getCurrentInstance()
 const emit = defineEmits(['close'])
 const dialogFormVisible = ref(false);
@@ -218,14 +218,10 @@
   operationType.value = type;
   dialogFormVisible.value = true;
 	
-	// 妯℃嫙鑾峰彇鐢ㄦ埛鍒楄〃
-	userList.value = [
-		{ userId: 1, nickName: "寮犱笁" },
-		{ userId: 2, nickName: "鏉庡洓" },
-		{ userId: 3, nickName: "鐜嬩簲" },
-		{ userId: 4, nickName: "璧靛叚" },
-		{ userId: 5, nickName: "瀛欏叓" }
-	];
+	// 鑾峰彇鐢ㄦ埛鍒楄〃
+	userListNoPageByTenantId().then(res => {
+		userList.value = res.data;
+	});
 
 	if (type === 'add') {
 		// 鏂板鏃堕噸缃〃鍗�
@@ -256,12 +252,30 @@
 const submitForm = () => {
 	proxy.$refs["formRef"].validate(valid => {
 		if (valid) {
-			// 妯℃嫙鎻愪氦鎿嶄綔
-			setTimeout(() => {
-				console.log("妯℃嫙鎻愪氦鐨勬暟鎹�:", form.value);
+			const submitData = {
+				id: form.value.id,
+				productName: form.value.productName,
+				batchNumber: form.value.batchNumber,
+				expireDate: form.value.expiryDate,
+				stockQuantity: form.value.stockQuantity,
+				customerName: form.value.customerName,
+				contactPhone: form.value.contactPhone,
+				disRes: form.value.problemDesc,
+				status: form.value.status,
+				disposeUserId: form.value.handlerId,
+				disposeNickName: userList.value.find(item => item.userId === form.value.handlerId)?.nickName,
+				disposeResult: form.value.handleResult,
+				disDate: form.value.handleDate
+			};
+			
+			const apiCall = operationType.value === 'add' ? expiryAfterSalesAdd : expiryAfterSalesUpdate;
+			apiCall(submitData).then(() => {
 				proxy.$modal.msgSuccess(operationType.value === 'add' ? "鏂板鎴愬姛" : "鏇存柊鎴愬姛");
 				closeDia();
-			}, 300);
+			}).catch(error => {
+				console.error('鎻愪氦鏁版嵁澶辫触:', error);
+				proxy.$modal.msgError('鎻愪氦鏁版嵁澶辫触锛岃绋嶅悗閲嶈瘯');
+			});
 		}
 	});
 }
diff --git a/src/views/customerService/expiryAfterSales/index.vue b/src/views/customerService/expiryAfterSales/index.vue
index df44504..ee5395d 100644
--- a/src/views/customerService/expiryAfterSales/index.vue
+++ b/src/views/customerService/expiryAfterSales/index.vue
@@ -72,7 +72,7 @@
 import {onMounted, ref} from "vue";
 import FormDia from "@/views/customerService/expiryAfterSales/components/formDia.vue";
 import {ElMessageBox} from "element-plus";
-// import {expiryAfterSalesDelete, expiryAfterSalesListPage} from "@/api/customerService/index.js"; // 鏆傛椂娉ㄩ噴鎺夛紝浣跨敤鍋囨暟鎹�
+import {expiryAfterSalesDelete, expiryAfterSalesListPage} from "@/api/customerService/index.js";
 import useUserStore from "@/store/modules/user.js";
 const { proxy } = getCurrentInstance();
 const userStore = useUserStore()
@@ -127,7 +127,8 @@
 			label: "澶勭悊鐘舵��",
 			prop: "status",
 			width: "",
-			slot: true,
+			dataType: "slot",
+			slot: "status",
 		},
 		{
 			label: "澶勭悊浜�",
@@ -142,7 +143,8 @@
 		{
 			label: "鎿嶄綔",
 			prop: "operation",
-			slot: true,
+			dataType: "slot",
+			slot: "operation",
 			width: "200",
 		},
 	],
@@ -190,21 +192,39 @@
 // 鑾峰彇鍒楄〃鏁版嵁
 const getList = () => {
 	tableLoading.value = true;
-	// 鍙栨秷娉ㄩ噴骞朵娇鐢ㄧ湡瀹濧PI
-	// expiryAfterSalesListPage({
-	// 	...searchForm.value,
-	// 	current: page.value.current,
-	// 	size: page.value.size
-	// }).then(res => {
-	// 	tableData.value = res.data.records;
-	// 	page.value.total = res.data.total;
-	// 	tableLoading.value = false;
-	// });
+	// 鏋勯�犳煡璇㈠弬鏁帮紝鏄犲皠鍓嶇瀛楁鍒板悗绔瓧娈�
+	const queryParams = {
+		expireDate: searchForm.value.expiryDate,
+		disDate: searchForm.value.handleDate,
+		status: searchForm.value.status,
+		current: page.value.current,
+		size: page.value.size
+	};
 	
-	// 鏆傛椂杩斿洖绌烘暟鎹�
-	tableData.value = [];
-	page.value.total = 0;
-	tableLoading.value = false;
+	expiryAfterSalesListPage(queryParams).then(res => {
+		// 鏄犲皠鍚庣杩斿洖鏁版嵁鍒板墠绔〃鏍�
+		tableData.value = res.data.records.map(item => ({
+			id: item.id,
+			productName: item.productName,
+			batchNumber: item.batchNumber,
+			expiryDate: item.expireDate,
+			stockQuantity: item.stockQuantity,
+			customerName: item.customerName,
+			contactPhone: item.contactPhone,
+			problemDesc: item.disRes,
+			status: item.status,
+			handlerId: item.disposeUserId,
+			handlerName: item.disposeNickName,
+			handleResult: item.disposeResult,
+			handleDate: item.disDate
+		}));
+		page.value.total = res.data.total;
+		tableLoading.value = false;
+	}).catch(error => {
+		console.error('鑾峰彇鍒楄〃鏁版嵁澶辫触:', error);
+		tableLoading.value = false;
+		proxy.$modal.msgError('鑾峰彇鏁版嵁澶辫触锛岃绋嶅悗閲嶈瘯');
+	});
 };
 
 // 鎵撳紑寮规
@@ -230,18 +250,12 @@
 	})
 		.then(() => {
 			tableLoading.value = true;
-			// 鍙栨秷娉ㄩ噴骞朵娇鐢ㄧ湡瀹濧PI
-			// expiryAfterSalesDelete(ids).then(() => {
-			// 	proxy.$modal.msgSuccess("鍒犻櫎鎴愬姛");
-			// 	getList();
-			// }).finally(() => {
-			// 	tableLoading.value = false;
-			// });
-			
-			// 鏆傛椂妯℃嫙鍒犻櫎鎴愬姛
-			tableLoading.value = false;
-			proxy.$modal.msgSuccess("鍒犻櫎鎴愬姛");
-			getList();
+			expiryAfterSalesDelete(ids).then(() => {
+				proxy.$modal.msgSuccess("鍒犻櫎鎴愬姛");
+				getList();
+			}).finally(() => {
+				tableLoading.value = false;
+			});
 		})
 		.catch(() => {
 			proxy.$modal.msg("宸插彇娑�");

--
Gitblit v1.9.3