From 7b47c7b9da14233d7f76d3c70a4fd8a70f54d52c Mon Sep 17 00:00:00 2001 From: Default User Date: Thu, 8 Jan 2026 16:16:24 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=B8=8A=E6=9E=B6=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=EF=BC=9A=E7=BC=96=E8=BE=91=E5=90=8E=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E8=B0=83=E7=94=A8=E4=B8=8A=E6=9E=B6API=EF=BC=8C=E7=A1=AE?= =?UTF-8?q?=E4=BF=9D=E7=8A=B6=E6=80=81=E4=B8=BApublished?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Reject.js | 16 ++++----- supply.html | 94 +++++++++++++++++++++++++++++------------------------ 2 files changed, 59 insertions(+), 51 deletions(-) diff --git a/Reject.js b/Reject.js index e6b330e..5eb59d9 100644 --- a/Reject.js +++ b/Reject.js @@ -830,9 +830,9 @@ app.post('/api/supplies/create', async (req, res) => { await connection.beginTransaction(); // 验证必填字段 - if (!productName || !price || !quantity || !supplyStatus || !sourceType) { + if (!productName || !costprice || !quantity || !supplyStatus || !sourceType) { connection.release(); - return sendResponse(res, false, null, '商品名称、价格、最小起订量、货源状态和货源类型不能为空'); + return sendResponse(res, false, null, '商品名称、采购价、最小起订量、货源状态和货源类型不能为空'); } // 如果sellerId为空,设置一个默认值 @@ -919,7 +919,7 @@ app.post('/api/supplies/create', async (req, res) => { sellerId: sellerId, // 使用前端传入的sellerId productName, category: category || '', // 添加种类 - price: price.toString(), // 确保是varchar类型 + price: (price || '').toString(), // 确保是varchar类型 costprice: costprice || '', // 添加采购价 quantity: quantity, // 保持为逗号分隔的字符串,不转换为整数 grossWeight, @@ -954,7 +954,7 @@ app.post('/api/supplies/create', async (req, res) => { // 没有quality字段,不包含quality字段的插入 insertQuery = 'INSERT INTO products (productId, sellerId, productName, category, freshness, price, costprice, quantity, grossWeight, yolk, specification, producting, region, status, supplyStatus, sourceType, description, rejectReason, imageUrls, created_at, audit_time, product_contact, contact_phone, autoOfflineTime, autoOfflineDays, autoOfflineHours) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)'; insertParams = [ - productId, productData.sellerId, productName, category || '', req.body.freshness || '', price.toString(), costprice || '', quantity, grossWeight, + productId, productData.sellerId, productName, category || '', req.body.freshness || '', (price || '').toString(), costprice || '', quantity, grossWeight, yolk, specification, producting, region, productData.status, productData.supplyStatus, productData.sourceType, productData.description, productData.rejectReason, productData.imageUrls, new Date(), new Date(), productContact, contactPhone, req.body.autoOfflineTime, req.body.autoOfflineDays, req.body.autoOfflineHours // 添加联系人信息和自动下架时间、小时数 @@ -963,7 +963,7 @@ app.post('/api/supplies/create', async (req, res) => { // 有quality字段,包含quality字段的插入 insertQuery = 'INSERT INTO products (productId, sellerId, productName, category, freshness, price, costprice, quantity, grossWeight, yolk, specification, producting, quality, region, status, supplyStatus, sourceType, description, rejectReason, imageUrls, created_at, audit_time, product_contact, contact_phone, autoOfflineTime, autoOfflineDays, autoOfflineHours) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)'; insertParams = [ - productId, productData.sellerId, productName, category || '', req.body.freshness || '', price.toString(), costprice || '', quantity, grossWeight, + productId, productData.sellerId, productName, category || '', req.body.freshness || '', (price || '').toString(), costprice || '', quantity, grossWeight, yolk, specification, producting, quality, region, productData.status, productData.supplyStatus, productData.sourceType, productData.description, productData.rejectReason, productData.imageUrls, new Date(), new Date(), productContact, contactPhone, req.body.autoOfflineTime, req.body.autoOfflineDays, req.body.autoOfflineHours // 添加联系人信息和自动下架时间、小时数 @@ -993,7 +993,7 @@ app.post('/api/supplies/create', async (req, res) => { productId: productId, productName, category: category || '', - price: price.toString(), + price: (price || '').toString(), costprice: costprice || '', quantity, grossWeight, @@ -1468,7 +1468,7 @@ app.put('/api/supplies/:id/edit', async (req, res) => { `; await connection.query(updateQuery, [ - productName, price.toString(), costprice || '', quantityValue, grossWeight, + productName, (price || '').toString(), costprice || '', quantityValue, grossWeight, yolk, specification, producting, supplyStatus, description, region, productContact, contactPhone, JSON.stringify(uploadedImageUrls), autoOfflineTime || null, // 自动下架时间 @@ -1489,7 +1489,7 @@ app.put('/api/supplies/:id/edit', async (req, res) => { data: { id: productId, productName, - price: price.toString(), + price: (price || '').toString(), costprice: costprice || '', quantity, grossWeight, diff --git a/supply.html b/supply.html index 27c87bb..983e66d 100644 --- a/supply.html +++ b/supply.html @@ -1349,7 +1349,7 @@ -
+