From 07b12c1779821c98bc288b7b55c38503e3c70612 Mon Sep 17 00:00:00 2001 From: Default User Date: Sat, 10 Jan 2026 16:53:42 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=BC=96=E8=BE=91=E8=B4=A7?= =?UTF-8?q?=E6=BA=90=E6=97=B6=E8=81=94=E7=B3=BB=E4=BA=BA=E4=BF=A1=E6=81=AF?= =?UTF-8?q?=E8=A2=AB=E8=A6=86=E7=9B=96=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Reject.js | 24 ++++++++++++++++++++---- supply.html | 21 ++++++++++++--------- 2 files changed, 32 insertions(+), 13 deletions(-) diff --git a/Reject.js b/Reject.js index 3c255af..c2295d5 100644 --- a/Reject.js +++ b/Reject.js @@ -1380,10 +1380,21 @@ app.put('/api/supplies/:id/edit', async (req, res) => { return sendResponse(res, false, null, '货源已被锁定,无法编辑'); } - // 处理联系人信息 - let productContact = ''; - let contactPhone = ''; - if (contactId) { + // 处理联系人信息:只在有新联系人ID且能查询到时才更新,否则保持原有值 + let productContact = null; + let contactPhone = null; + + // 先查询原有联系人信息 + const [existingProduct] = await connection.query( + 'SELECT product_contact, contact_phone FROM products WHERE id = ?', + [productId] + ); + + // 如果没有提供contactId或contactId为空,使用原有联系人信息 + if (!contactId || contactId === '') { + productContact = existingProduct[0].product_contact; + contactPhone = existingProduct[0].contact_phone; + } else { // 从userlogin数据库获取联系人信息 const userLoginConnection = await userLoginPool.getConnection(); const [personnelData] = await userLoginConnection.query( @@ -1393,8 +1404,13 @@ app.put('/api/supplies/:id/edit', async (req, res) => { userLoginConnection.release(); if (personnelData && personnelData.length > 0) { + // 成功查询到联系人,使用新联系人信息 productContact = personnelData[0].alias || ''; contactPhone = personnelData[0].phoneNumber || ''; + } else { + // 未查询到联系人,使用原有联系人信息 + productContact = existingProduct[0].product_contact; + contactPhone = existingProduct[0].contact_phone; } } diff --git a/supply.html b/supply.html index 88022cf..0e4f72b 100644 --- a/supply.html +++ b/supply.html @@ -4611,7 +4611,7 @@ // 处理操作按钮 let actionsHTML = ''; if (supply.status === 'published') { - actionsHTML = ``; + actionsHTML = ` `; } else if (supply.status === 'pending_review') { actionsHTML = ` @@ -6100,14 +6100,14 @@ const autoOfflineTime = new Date(); autoOfflineTime.setMinutes(autoOfflineTime.getMinutes() + minutes); // 格式化为数据库存储的北京时间格式 (YYYY-MM-DD HH:mm:ss) - const autoOfflineTimeStr = autoOfflineTime.getFullYear() + '-' + - String(autoOfflineTime.getMonth() + 1).padStart(2, '0') + '-' + - String(autoOfflineTime.getDate()).padStart(2, '0') + ' ' + - String(autoOfflineTime.getHours()).padStart(2, '0') + ':' + - String(autoOfflineTime.getMinutes()).padStart(2, '0') + ':' + - String(autoOfflineTime.getSeconds()).padStart(2, '0'); - - const formData = { + const autoOfflineTimeStr = autoOfflineTime.getFullYear() + '-' + + String(autoOfflineTime.getMonth() + 1).padStart(2, '0') + '-' + + String(autoOfflineTime.getDate()).padStart(2, '0') + ' ' + + String(autoOfflineTime.getHours()).padStart(2, '0') + ':' + + String(autoOfflineTime.getMinutes()).padStart(2, '0') + ':' + + String(autoOfflineTime.getSeconds()).padStart(2, '0'); + + const formData = { productName: document.getElementById('productName').value, category: document.getElementById('category').value, price: document.getElementById('price').value, @@ -7966,6 +7966,9 @@ String(autoOfflineTime.getMinutes()).padStart(2, '0') + ':' + String(autoOfflineTime.getSeconds()).padStart(2, '0'); + // 获取当前编辑的货源信息,用于保留原联系人数据 + const currentSupply = supplyData.supplies.find(s => String(s.id) === String(currentEditSupplyId)); + const formData = { productName: document.getElementById('editProductName').value, sourceType: document.getElementById('editSourceType').value,