diff --git a/Reject.js b/Reject.js index d3c6c08..dfe7c84 100644 --- a/Reject.js +++ b/Reject.js @@ -706,7 +706,7 @@ app.post('/api/supplies/create', async (req, res) => { let connection; try { connection = await pool.getConnection(); - const { productName, price, quantity, grossWeight, yolk, specification, quality, region, imageUrls, sellerId, supplyStatus, description, sourceType, contactId, category, producting } = req.body; + const { productName, price, costprice, quantity, grossWeight, yolk, specification, quality, region, imageUrls, sellerId, supplyStatus, description, sourceType, contactId, category, producting } = req.body; // 开始事务 await connection.beginTransaction(); @@ -800,6 +800,7 @@ app.post('/api/supplies/create', async (req, res) => { productName, category: category || '', // 添加种类 price: price.toString(), // 确保是varchar类型 + costprice: costprice || '', // 添加采购价 quantity: quantity, // 保持为逗号分隔的字符串,不转换为整数 grossWeight, yolk, @@ -831,18 +832,18 @@ app.post('/api/supplies/create', async (req, res) => { if (columns.length === 0) { // 没有quality字段,不包含quality字段的插入 - insertQuery = 'INSERT INTO products (productId, sellerId, productName, category, price, quantity, grossWeight, yolk, specification, producting, region, status, supplyStatus, sourceType, description, rejectReason, imageUrls, created_at, audit_time, product_contact, contact_phone, autoOfflineTime, autoOfflineDays, autoOfflineHours) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)'; + insertQuery = 'INSERT INTO products (productId, sellerId, productName, category, 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 || '', price.toString(), quantity, grossWeight, + productId, productData.sellerId, productName, category || '', 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 // 添加联系人信息和自动下架时间、小时数 ]; } else { // 有quality字段,包含quality字段的插入 - insertQuery = 'INSERT INTO products (productId, sellerId, productName, category, price, 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 (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)'; + insertQuery = 'INSERT INTO products (productId, sellerId, productName, category, 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 || '', price.toString(), quantity, grossWeight, + productId, productData.sellerId, productName, category || '', 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 // 添加联系人信息和自动下架时间、小时数 @@ -1097,7 +1098,7 @@ app.put('/api/supplies/:id/edit', async (req, res) => { try { const connection = await pool.getConnection(); const productId = req.params.id; - const { productName, price, quantity, grossWeight, yolk, specification, supplyStatus, description, region, contactId, producting, imageUrls } = req.body; + const { productName, price, costprice, quantity, grossWeight, yolk, specification, supplyStatus, description, region, contactId, producting, imageUrls } = req.body; // 开始事务 await connection.beginTransaction(); @@ -1179,7 +1180,7 @@ app.put('/api/supplies/:id/edit', async (req, res) => { // 更新货源信息 const updateQuery = ` UPDATE products - SET productName = ?, price = ?, quantity = ?, grossWeight = ?, + SET productName = ?, price = ?, costprice = ?, quantity = ?, grossWeight = ?, yolk = ?, specification = ?, producting = ?, supplyStatus = ?, description = ?, region = ?, product_contact = ?, contact_phone = ?, imageUrls = ?, autoOfflineHours = ?, updated_at = ? @@ -1187,7 +1188,7 @@ app.put('/api/supplies/:id/edit', async (req, res) => { `; await connection.query(updateQuery, [ - productName, price.toString(), quantityValue, grossWeight, + productName, price.toString(), costprice || '', quantityValue, grossWeight, yolk, specification, producting, supplyStatus, description, region, productContact, contactPhone, JSON.stringify(uploadedImageUrls), req.body.autoOfflineHours || 24, // 默认24小时 diff --git a/supply.html b/supply.html index 44dcf09..b4d2fe4 100644 --- a/supply.html +++ b/supply.html @@ -1304,6 +1304,12 @@ + +
+ + +
+
@@ -1696,6 +1702,12 @@
+ +
+ + +
+
@@ -2295,8 +2307,8 @@ const createSupplyModal = document.getElementById('createSupplyModal'); const editSupplyModal = document.getElementById('editSupplyModal'); - // 检查是否在创建或编辑货源模态框中 - if (createSupplyModal && createSupplyModal.style.display === 'flex') { + // 检查是否在创建或编辑货源模态框中(现在使用active类来控制显示) + if (createSupplyModal && createSupplyModal.classList.contains('active')) { // 检查是否有粘贴的图片 const items = e.clipboardData.items; const imageFiles = []; @@ -2313,7 +2325,7 @@ if (imageFiles.length > 0) { handleDroppedImages(imageFiles); } - } else if (editSupplyModal && editSupplyModal.style.display === 'flex') { + } else if (editSupplyModal && editSupplyModal.classList.contains('active')) { // 检查是否有粘贴的图片 const items = e.clipboardData.items; const imageFiles = []; @@ -5103,6 +5115,7 @@ productName: document.getElementById('productName').value, category: document.getElementById('category').value, price: document.getElementById('price').value, + costprice: document.getElementById('costprice').value, // 添加采购价 quantity: quantities.join(','), // 将件数以英文逗号分隔的字符串形式提交 grossWeight: document.getElementById('grossWeight').value, yolk: document.getElementById('yolk').value, @@ -5676,6 +5689,7 @@ document.getElementById('editRegionDisplayText').textContent = supply.region || '请选择地区'; document.getElementById('editRegionValue').value = supply.region || ''; document.getElementById('editPrice').value = supply.price || ''; + document.getElementById('editCostprice').value = supply.costprice || ''; document.getElementById('editGrossWeight').value = supply.grossWeight || ''; // 自动下架时间(将小时转换为分钟) @@ -6630,6 +6644,7 @@ sourceType: document.getElementById('editSourceType').value, category: document.getElementById('editCategory').value, price: document.getElementById('editPrice').value, + costprice: document.getElementById('editCostprice').value, // 添加采购价 quantity: quantities.join(','), // 将件数以英文逗号分隔的字符串形式提交 grossWeight: document.getElementById('editGrossWeight').value, yolk: document.getElementById('editYolk').value,