diff --git a/Reject.js b/Reject.js index 7c3abed..387441b 100644 --- a/Reject.js +++ b/Reject.js @@ -442,7 +442,7 @@ app.get('/api/contacts', async (req, res) => { // 直接从userlogin数据库的Personnel表查询联系人信息,只查询工位名为销售员的联系人 const userLoginConnection = await userLoginPool.getConnection(); const [personnelData] = await userLoginConnection.query( - 'SELECT projectName, alias, phoneNumber FROM Personnel WHERE projectName = "销售员" AND phoneNumber IS NOT NULL AND phoneNumber != ""' + 'SELECT id, projectName, alias, phoneNumber FROM Personnel WHERE projectName = "销售员" AND phoneNumber IS NOT NULL AND phoneNumber != ""' ); userLoginConnection.release(); @@ -451,9 +451,9 @@ app.get('/api/contacts', async (req, res) => { return; } - // 创建联系人数据数组,保持与原API相同的返回格式 - const contacts = personnelData.map((person, index) => ({ - id: index + 1, + // 创建联系人数据数组,保持与原API相同的返回格式,使用实际的数据库ID + const contacts = personnelData.map((person) => ({ + id: person.id, // 使用数据库中的实际ID salesPerson: person.projectName, // 销售员 name: person.alias, // 联系人别名 phoneNumber: person.phoneNumber // 电话号码 @@ -467,37 +467,7 @@ app.get('/api/contacts', async (req, res) => { } }); -// 更新产品联系人API -app.put('/api/supplies/:id/contact', async (req, res) => { - try { - const { id } = req.params; - const { productContact, contactPhone } = req.body; - - // 移除"联系人"前缀和"销售员 - "前缀 - const processedProductContact = productContact.replace(/^(联系人|销售员\s*-\s*)/g, '').trim(); - - const connection = await pool.getConnection(); - - // 更新产品的联系人信息 - const [result] = await connection.query( - 'UPDATE products SET product_contact = ?, contact_phone = ? WHERE id = ?', - [processedProductContact, contactPhone, id] - ); - - connection.release(); - if (result.affectedRows === 0) { - sendResponse(res, false, null, '未找到指定的产品'); - return; - } - - sendResponse(res, true, null, '产品联系人信息更新成功'); - } catch (error) { - console.error('更新产品联系人信息失败:', error.message); - console.error('错误详情:', error); - sendResponse(res, false, null, '更新产品联系人信息失败'); - } -}); // 供应商审核通过API - /api/suppliers/:id/approve console.log('正在注册供应商审核通过API路由: /api/suppliers/:id/approve'); @@ -987,17 +957,17 @@ app.post('/api/supplies/:id/publish', async (req, res) => { return sendResponse(res, false, null, '货源不存在'); } - // 更新状态为审核中 + // 更新状态为已发布(直接上架,不需要审核) await connection.query( 'UPDATE products SET status = ? WHERE id = ?', - ['pending_review', productId] + ['published', productId] ); // 提交事务 await connection.commit(); connection.release(); - sendResponse(res, true, null, '货源已提交审核'); + sendResponse(res, true, null, '货源已成功上架'); } catch (error) { console.error('上架货源失败:', error.message); console.error('错误详情:', error); diff --git a/supply.html b/supply.html index 395d679..23b3864 100644 --- a/supply.html +++ b/supply.html @@ -997,7 +997,7 @@ -
+