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 @@ -
+