diff --git a/Reject.js b/Reject.js
index 7c3abed..948d720 100644
--- a/Reject.js
+++ b/Reject.js
@@ -726,7 +726,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 } = req.body;
+ const { productName, price, quantity, grossWeight, yolk, specification, quality, region, imageUrls, sellerId, supplyStatus, description, sourceType, contactId, category, producting } = req.body;
// 开始事务
await connection.beginTransaction();
@@ -813,6 +813,7 @@ app.post('/api/supplies/create', async (req, res) => {
yolk,
specification,
quality,
+ producting: producting || '', // 添加产品包装
region,
status: 'published', // 直接上架,而不是审核中
supplyStatus: supplyStatus || '', // 预售/现货
@@ -835,19 +836,19 @@ 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, region, status, supplyStatus, sourceType, description, rejectReason, imageUrls, created_at, audit_time, product_contact, contact_phone) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)';
+ 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) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)';
insertParams = [
productId, productData.sellerId, productName, category || '', price.toString(), parseInt(quantity), grossWeight,
- yolk, specification, region, productData.status, productData.supplyStatus, productData.sourceType,
+ yolk, specification, producting, region, productData.status, productData.supplyStatus, productData.sourceType,
productData.description, productData.rejectReason, productData.imageUrls, new Date(), new Date(),
productContact, contactPhone // 添加联系人信息
];
} else {
// 有quality字段,包含quality字段的插入
- insertQuery = 'INSERT INTO products (productId, sellerId, productName, category, price, quantity, grossWeight, yolk, specification, quality, region, status, supplyStatus, sourceType, description, rejectReason, imageUrls, created_at, audit_time, product_contact, contact_phone) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)';
+ insertQuery = 'INSERT INTO products (productId, sellerId, productName, category, price, quantity, grossWeight, yolk, specification, quality, producting, region, status, supplyStatus, sourceType, description, rejectReason, imageUrls, created_at, audit_time, product_contact, contact_phone) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)';
insertParams = [
productId, productData.sellerId, productName, category || '', price.toString(), parseInt(quantity), grossWeight,
- yolk, specification, quality, region, productData.status, productData.supplyStatus,
+ yolk, specification, quality, producting, region, productData.status, productData.supplyStatus,
productData.sourceType, productData.description, productData.rejectReason, productData.imageUrls,
new Date(), new Date(), productContact, contactPhone // 添加联系人信息
];
@@ -1053,7 +1054,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 } = req.body;
+ const { productName, price, quantity, grossWeight, yolk, specification, supplyStatus, description, region, contactId, producting } = req.body;
// 开始事务
await connection.beginTransaction();
@@ -1093,14 +1094,14 @@ app.put('/api/supplies/:id/edit', async (req, res) => {
UPDATE products
SET productName = ?, price = ?, quantity = ?, grossWeight = ?,
yolk = ?, specification = ?, supplyStatus = ?, description = ?, region = ?,
- product_contact = ?, contact_phone = ?
+ producting = ?, product_contact = ?, contact_phone = ?
WHERE id = ?
`;
await connection.query(updateQuery, [
productName, price.toString(), parseInt(quantity), grossWeight,
yolk, specification, supplyStatus, description, region,
- productContact, contactPhone, productId
+ producting, productContact, contactPhone, productId
]);
// 提交事务
@@ -1316,6 +1317,22 @@ async function ensureDatabaseSchema() {
console.log('audit_time字段添加成功');
}
+ // 检查表是否有producting字段
+ console.log('检查表products是否有producting字段...');
+ const [productingColumns] = await connection.query(
+ 'SHOW COLUMNS FROM `products` LIKE ?',
+ ['producting']
+ );
+ console.log('检查表字段结果:', productingColumns.length > 0 ? '已存在' : '不存在');
+
+ if (productingColumns.length === 0) {
+ console.log('添加producting字段到products表...');
+ await connection.query(
+ 'ALTER TABLE `products` ADD COLUMN producting VARCHAR(255) COMMENT "产品包装"'
+ );
+ console.log('producting字段添加成功');
+ }
+
// 检查audit_logs表是否存在,如果不存在则创建
console.log('检查audit_logs表是否存在...');
const [tables] = await connection.query(
diff --git a/package-lock.json b/package-lock.json
index 8871825..a42c8c5 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,5 +1,5 @@
{
- "name": "Review",
+ "name": "Review2",
"lockfileVersion": 3,
"requires": true,
"packages": {
@@ -52,6 +52,7 @@
"integrity": "sha512-e7jT4DxYvIDLk1ZHmU/m/mB19rex9sv0c2ftBtjSBv+kVM/902eh0fINUzD7UwLLNR+jU585GxUJ8/EBfAM5fw==",
"dev": true,
"license": "MIT",
+ "peer": true,
"dependencies": {
"@babel/code-frame": "^7.27.1",
"@babel/generator": "^7.28.5",
@@ -1295,6 +1296,7 @@
}
],
"license": "MIT",
+ "peer": true,
"dependencies": {
"baseline-browser-mapping": "^2.9.0",
"caniuse-lite": "^1.0.30001759",
diff --git a/supply-manager.js b/supply-manager.js
index 0747554..a22c956 100644
--- a/supply-manager.js
+++ b/supply-manager.js
@@ -34,6 +34,13 @@ class SupplyManager {
editSpecSearchKeyword: '',
filteredSpecOptions: [],
filteredEditSpecOptions: [],
+ productingOptions: ['1*360枚新包装', '1*360枚旧包新拖', '1*360枚旧包旧拖', '1*420枚新包装', '1*480枚新包装', '30枚蛋托散装', '360枚散托'],
+ productingSearchKeyword: '',
+ editProductingSearchKeyword: '',
+ filteredProductingOptions: [],
+ filteredEditProductingOptions: [],
+ showProductingSelectModal: false,
+ currentProductingMode: 'create',
showRegionSelectModal: false,
currentRegionMode: 'create',
regionOptions: [
diff --git a/supply.html b/supply.html
index efe4faf..79c7dff 100644
--- a/supply.html
+++ b/supply.html
@@ -988,9 +988,52 @@
+
+
+
+
+
+
+
+
+
@@ -1139,7 +1191,7 @@
-
+
+
+
@@ -1459,7 +1521,7 @@
-
+
@@ -1923,6 +1985,145 @@
}
hideSpecSelectModal();
}
+
+ // 产品包装相关变量
+ const allProductingOptions = ['1*360枚新包装', '1*360枚旧包新拖', '1*360枚旧包旧拖', '1*420枚新包装', '1*480枚新包装', '30枚蛋托散装', '360枚散托'];
+ let filteredProductingOptions = [];
+ let selectedProducting = '';
+
+ // 显示产品包装选择弹窗
+ function showProductingSelectModal() {
+ const productingSelectModal = document.getElementById('productingSelectModal');
+ productingSelectModal.classList.add('active');
+ // 重置搜索输入
+ document.getElementById('productingSearchInput').value = '';
+ filteredProductingOptions = [...allProductingOptions];
+ generateProductingOptions();
+ }
+
+ // 隐藏产品包装选择弹窗
+ function hideProductingSelectModal() {
+ const productingSelectModal = document.getElementById('productingSelectModal');
+ productingSelectModal.classList.remove('active');
+ }
+
+ // 生成产品包装选项
+ function generateProductingOptions() {
+ const productingOptionsList = document.getElementById('productingOptionsList');
+ productingOptionsList.innerHTML = '';
+
+ filteredProductingOptions.forEach(producting => {
+ const option = document.createElement('div');
+ option.className = 'select-item';
+ option.textContent = producting;
+ option.onclick = () => {
+ // 移除所有选项的选中状态
+ document.querySelectorAll('.select-item').forEach(item => {
+ item.classList.remove('selected');
+ });
+ // 添加当前选项的选中状态
+ option.classList.add('selected');
+ selectedProducting = producting;
+ };
+ option.ondblclick = () => {
+ // 双击直接确认选择
+ document.getElementById('productingDisplayText').textContent = producting;
+ document.getElementById('productingValue').value = producting;
+ hideProductingSelectModal();
+ };
+ productingOptionsList.appendChild(option);
+ });
+ }
+
+ // 过滤产品包装选项
+ function filterProductingOptions() {
+ const searchInput = document.getElementById('productingSearchInput');
+ const searchKeyword = searchInput.value.toLowerCase();
+
+ filteredProductingOptions = allProductingOptions.filter(producting => {
+ return producting.toLowerCase().includes(searchKeyword);
+ });
+
+ generateProductingOptions();
+ }
+
+ // 确认产品包装选择
+ function confirmProductingSelection() {
+ if (selectedProducting) {
+ document.getElementById('productingDisplayText').textContent = selectedProducting;
+ document.getElementById('productingValue').value = selectedProducting;
+ }
+ hideProductingSelectModal();
+ }
+
+ // 编辑产品包装相关变量
+ let editFilteredProductingOptions = [];
+ let editSelectedProducting = '';
+
+ // 显示编辑产品包装选择弹窗
+ function showEditProductingSelectModal() {
+ const editProductingSelectModal = document.getElementById('editProductingSelectModal');
+ editProductingSelectModal.classList.add('active');
+ // 重置搜索输入
+ document.getElementById('editProductingSearchInput').value = '';
+ editFilteredProductingOptions = [...allProductingOptions];
+ generateEditProductingOptions();
+ }
+
+ // 隐藏编辑产品包装选择弹窗
+ function hideEditProductingSelectModal() {
+ const editProductingSelectModal = document.getElementById('editProductingSelectModal');
+ editProductingSelectModal.classList.remove('active');
+ }
+
+ // 生成编辑产品包装选项
+ function generateEditProductingOptions() {
+ const editProductingOptionsList = document.getElementById('editProductingOptionsList');
+ editProductingOptionsList.innerHTML = '';
+
+ editFilteredProductingOptions.forEach(producting => {
+ const option = document.createElement('div');
+ option.className = 'select-item';
+ option.textContent = producting;
+ option.onclick = () => {
+ // 移除所有选项的选中状态
+ document.querySelectorAll('.select-item').forEach(item => {
+ item.classList.remove('selected');
+ });
+ // 添加当前选项的选中状态
+ option.classList.add('selected');
+ editSelectedProducting = producting;
+ };
+ option.ondblclick = () => {
+ // 双击直接确认选择
+ document.getElementById('editProductingDisplayText').textContent = producting;
+ document.getElementById('editProductingValue').value = producting;
+ hideEditProductingSelectModal();
+ };
+ editProductingOptionsList.appendChild(option);
+ });
+ }
+
+ // 过滤编辑产品包装选项
+ function filterEditProductingOptions() {
+ const searchInput = document.getElementById('editProductingSearchInput');
+ const searchKeyword = searchInput.value.toLowerCase();
+
+ editFilteredProductingOptions = allProductingOptions.filter(producting => {
+ return producting.toLowerCase().includes(searchKeyword);
+ });
+
+ generateEditProductingOptions();
+ }
+
+ // 确认编辑产品包装选择
+ function confirmEditProductingSelection() {
+ if (editSelectedProducting) {
+ document.getElementById('editProductingDisplayText').textContent = editSelectedProducting;
+ document.getElementById('editProductingValue').value = editSelectedProducting;
+ }
+ hideEditProductingSelectModal();
+ }
// 显示货源类型选择弹窗
function showSourceTypeSelectModal() {
@@ -3289,7 +3490,7 @@
货源状态: ${supply.supplyStatus || '未设置'}
货源描述: ${supply.description || '无'}
件数: ${supply.quantity || '0'}件
-
斤重: ${supply.grossWeight || ''}斤
+
斤重: ${supply.grossWeight || ''}斤
地区: ${supply.region || '未设置'}
价格: ¥${supply.price || '0'}
创建时间: ${formatDate(supply.created_at)}
@@ -3441,7 +3642,7 @@
const productName = document.getElementById('productName');
const price = document.getElementById('price');
const quantity = document.getElementById('quantity');
- const grossWeight = document.getElementById('grossWeight');
+ const grossWeight = null; // 斤重功能已隐藏
const yolk = document.getElementById('yolk');
const specValue = document.getElementById('specValue');
const supplyStatus = document.getElementById('supplyStatus');
@@ -3456,7 +3657,7 @@
if (productName) productName.value = formData.productName || '';
if (price) price.value = formData.price || '';
if (quantity) quantity.value = formData.quantity || '';
- if (grossWeight) grossWeight.value = formData.grossWeight || '';
+ // 斤重功能已隐藏
if (yolk) yolk.value = formData.yolk || '';
if (specValue) specValue.value = formData.specification || '';
if (supplyStatus) supplyStatus.value = formData.supplyStatus || '';
@@ -3674,7 +3875,7 @@
// 设置表单自动保存
function setupAutoSave() {
// 为所有输入字段添加输入事件监听
- const formFields = ['productName', 'price', 'quantity', 'grossWeight', 'yolk', 'specValue', 'supplyStatus', 'description', 'regionValue', 'contactId', 'sourceType'];
+ const formFields = ['productName', 'price', 'quantity', 'grossWeight', 'yolk', 'specValue', 'supplyStatus', 'description', 'regionValue', 'contactId', 'sourceType', 'productingValue'];
formFields.forEach(fieldId => {
const element = document.getElementById(fieldId);
@@ -3704,7 +3905,8 @@
'sourceTypeDisplayText',
'productNameDisplayText',
'yolkDisplayText',
- 'contactIdDisplayText'
+ 'contactIdDisplayText',
+ 'productingDisplayText'
];
customDisplays.forEach(displayId => {
@@ -3744,7 +3946,7 @@
const productName = document.getElementById('productName');
const price = document.getElementById('price');
const quantity = document.getElementById('quantity');
- const grossWeight = document.getElementById('grossWeight');
+ const grossWeight = null; // 斤重功能已隐藏
const yolk = document.getElementById('yolk');
const specValue = document.getElementById('specValue');
const supplyStatus = document.getElementById('supplyStatus');
@@ -3760,6 +3962,8 @@
const yolkDisplayText = document.getElementById('yolkDisplayText');
const contactIdDisplayText = document.getElementById('contactIdDisplayText');
const categoryDisplayText = document.getElementById('categoryDisplayText');
+ const productingValue = document.getElementById('productingValue');
+ const productingDisplayText = document.getElementById('productingDisplayText');
// 确保所有字段都是安全获取的
const formData = {
@@ -3767,7 +3971,7 @@
category: category ? category.value : '',
price: price ? price.value : '',
quantity: quantity ? quantity.value : '',
- grossWeight: grossWeight ? grossWeight.value : '',
+ grossWeight: '', // 斤重功能已隐藏
yolk: yolk ? yolk.value : '',
specification: specValue ? specValue.value : '',
specificationDisplay: specDisplayText ? specDisplayText.textContent : '请选择规格',
@@ -3777,6 +3981,8 @@
region: regionValue ? regionValue.value : '',
regionDisplay: regionDisplayText ? regionDisplayText.textContent : '请选择地区',
contactId: contactId ? contactId.value : '',
+ producting: productingValue ? productingValue.value : '',
+ productingDisplay: productingDisplayText ? productingDisplayText.textContent : '请选择产品包装',
// 保存其他自定义下拉框显示文本
sourceTypeDisplay: sourceTypeDisplayText ? sourceTypeDisplayText.textContent : '请选择货源类型',
productNameDisplay: productNameDisplayText ? productNameDisplayText.textContent : '请选择商品名称',
@@ -3819,7 +4025,7 @@
category: document.getElementById('category').value,
price: document.getElementById('price').value,
quantity: document.getElementById('quantity').value,
- grossWeight: document.getElementById('grossWeight').value,
+ grossWeight: '', // 斤重功能已隐藏
yolk: document.getElementById('yolk').value,
specification: document.getElementById('specValue').value,
supplyStatus: document.getElementById('supplyStatus').value,
@@ -3827,6 +4033,7 @@
description: document.getElementById('description').value,
region: document.getElementById('regionValue').value,
contactId: document.getElementById('contactId').value,
+ producting: document.getElementById('productingValue').value,
imageUrls: supplyData.uploadedImages,
sellerId: userInfo.userId // 添加当前登录用户的userId作为sellerId
};
@@ -4365,7 +4572,11 @@
document.getElementById('editRegionValue').value = supply.region || '';
document.getElementById('editPrice').value = supply.price || '';
document.getElementById('editQuantity').value = supply.quantity || '';
- document.getElementById('editGrossWeight').value = supply.grossWeight || '';
+ // 斤重功能已隐藏
+
+ // 产品包装
+ document.getElementById('editProductingDisplayText').textContent = supply.producting || '请选择产品包装';
+ document.getElementById('editProductingValue').value = supply.producting || '';
// 显示商品图片
const editUploadImages = document.getElementById('editUploadImages');
@@ -5030,14 +5241,15 @@
category: document.getElementById('editCategory').value,
price: document.getElementById('editPrice').value,
quantity: document.getElementById('editQuantity').value,
- grossWeight: document.getElementById('editGrossWeight').value,
+ grossWeight: '', // 斤重功能已隐藏
yolk: document.getElementById('editYolk').value,
specification: document.getElementById('editSpecValue').value,
supplyStatus: document.getElementById('editSupplyStatus').value,
description: document.getElementById('editDescription').value,
region: document.getElementById('editRegionValue').value,
- contactId: document.getElementById('editContactId').value
- };
+ contactId: document.getElementById('editContactId').value,
+ producting: document.getElementById('editProductingValue').value
+ };
// 验证表单
if (!formData.productName) {