From dc073060ea4be3ef8de0076616b90c2e1fbc2708 Mon Sep 17 00:00:00 2001
From: 快乐的昕的电脑 <快乐的昕的电脑@DESKTOP-C2BQPQU>
Date: 星期一, 13 十月 2025 16:21:37 +0800
Subject: [PATCH] 填充弹窗列表和下拉列表

---
 components/mold.vue |   66 ++++++++++++++++++--------------
 1 files changed, 37 insertions(+), 29 deletions(-)

diff --git a/components/mold.vue b/components/mold.vue
index 8c4f793..0c5805c 100644
--- a/components/mold.vue
+++ b/components/mold.vue
@@ -127,39 +127,47 @@
 		},
 		methods: {
 			async fetchTools(searchKey) {
-				const res = await this.$post({
-					url: '/MesCutterLedger/QueryTools',
-					data: JSON.stringify({
-						searchKey,
-						pageIndex: this.pageIndex,
-						pageSize: this.pageSize
-					}),
-					headers: { 'Content-Type': 'application/json' }
-				});
+				try {
+					const res = await this.$post({
+						url: '/MesCutterLedger/QueryTools',
+						data: JSON.stringify({
+							searchKey,
+							pageIndex: this.pageIndex,
+							pageSize: this.pageSize
+						}),
+						headers: { 'Content-Type': 'application/json' }
+					});
 
-				if (res.status === 0) {
-					// 鍏煎涓嶅悓杩斿洖缁撴瀯锛氱洿鎺ユ暟缁� / { tbBillList, total } / { data: [...] }
-					const payload = Array.isArray(res.data) ? res.data
-						: (res.data && res.data.tbBillList) ? res.data.tbBillList
-							: (res.data && res.data.data) ? res.data.data
-								: [];
+					if (res.status === 0) {
+						// 鍏煎涓嶅悓杩斿洖缁撴瀯锛氱洿鎺ユ暟缁� / { tbBillList, total } / { data: [...] }
+						const payload = Array.isArray(res.data) ? res.data
+							: (res.data && res.data.tbBillList) ? res.data.tbBillList
+								: (res.data && res.data.data) ? res.data.data
+									: [];
 
-					const getField = (obj, ...keys) => {
-						for (const k of keys) if (obj?.[k] !== undefined && obj?.[k] !== null) return obj[k];
-						return null;
-					};
+						const getField = (obj, ...keys) => {
+							for (const k of keys) if (obj?.[k] !== undefined && obj?.[k] !== null) return obj[k];
+							return null;
+						};
 
-					this.filteredTools = (payload || []).map(t => ({
-						no: getField(t, 'cutterId', 'CUTTER_ID', 'cutteR_ID', 'daA001', 'no'),
-						name: getField(t, 'cutterName', 'CUTTER_NAME', 'cutteR_NAME', 'name'),
-						model: getField(t, 'cutterModel', 'CUTTER_MODEL', 'cutteR_MODEL', 'model')
-					}));
+						const mapped = (payload || []).map(t => ({
+							no: getField(t, 'cutterId', 'CUTTER_ID', 'cutteR_ID', 'daA001', 'no'),
+							name: getField(t, 'cutterName', 'CUTTER_NAME', 'cutteR_NAME', 'name'),
+							model: getField(t, 'cutterModel', 'CUTTER_MODEL', 'cutteR_MODEL', 'model')
+						}));
 
-					// 鎬绘暟鍏煎澶氫釜瀛楁鍚�
-					this.total = (res.data && (res.data.total ?? res.totalCount ?? res.total))
-						|| payload.length || 0;
-				} else {
-					this.$showMessage(res.message || '鏌ヨ澶辫触');
+						// 濉厖寮圭獥鍒楄〃鍜屼笅鎷夊垪琛紙妯℃澘涓笅鎷変娇鐢� toolList锛�
+						this.filteredTools = mapped;
+						this.toolList = mapped.slice();
+
+						// 鎬绘暟浼樺厛鍙栭《灞� totalCount锛屽啀鍙栧祵濂� total锛屽啀閫�鍥� payload 闀垮害
+						this.total = Number(res.totalCount ?? res.data?.total ?? res.data?.totalCount ?? res.total ?? mapped.length ?? 0) || 0;
+					} else {
+						this.$showMessage(res.message || '鏌ヨ澶辫触');
+					}
+				} catch (err) {
+					console.error('fetchTools 閿欒锛�', err);
+					this.$showMessage('鏌ヨ鍒�鍏峰け璐ワ紝璇锋鏌ョ綉缁滄垨鎺ュ彛');
 				}
 			},
 			//缈婚〉

--
Gitblit v1.9.3