diff --git a/Reject.js b/Reject.js
index 387441b..9624567 100644
--- a/Reject.js
+++ b/Reject.js
@@ -696,7 +696,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();
@@ -782,6 +782,7 @@ app.post('/api/supplies/create', async (req, res) => {
grossWeight,
yolk,
specification,
+ producting,
quality,
region,
status: 'published', // 直接上架,而不是审核中
@@ -805,19 +806,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, producting, quality, 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, producting, quality, region, productData.status, productData.supplyStatus,
productData.sourceType, productData.description, productData.rejectReason, productData.imageUrls,
new Date(), new Date(), productContact, contactPhone // 添加联系人信息
];
@@ -1023,7 +1024,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();
@@ -1062,14 +1063,14 @@ app.put('/api/supplies/:id/edit', async (req, res) => {
const updateQuery = `
UPDATE products
SET productName = ?, price = ?, quantity = ?, grossWeight = ?,
- yolk = ?, specification = ?, supplyStatus = ?, description = ?, region = ?,
+ yolk = ?, specification = ?, producting = ?, supplyStatus = ?, description = ?, region = ?,
product_contact = ?, contact_phone = ?
WHERE id = ?
`;
await connection.query(updateQuery, [
productName, price.toString(), parseInt(quantity), grossWeight,
- yolk, specification, supplyStatus, description, region,
+ yolk, specification, producting, supplyStatus, description, region,
productContact, contactPhone, productId
]);
diff --git a/supply.html b/supply.html
index 23b3864..962c56d 100644
--- a/supply.html
+++ b/supply.html
@@ -1120,6 +1120,15 @@
+
+
@@ -1359,6 +1368,28 @@
+
+
+
@@ -1457,6 +1488,16 @@
+
+
+
@@ -1655,6 +1696,28 @@
+
+
+
@@ -1726,6 +1789,9 @@
let editAllYolkTypes = ['红心', '黄心', '双色', '未知'];
let editFilteredYolkTypes = [...editAllYolkTypes];
let editSelectedYolk = '';
+ let editAllProductingOptions = ['1*360枚新包装', '1*360枚旧包新拖', '1*360枚旧包旧拖', '1*420枚新包装', '1*480枚新包装', '30枚蛋托散装', '360枚散托'];
+ let editFilteredProductingOptions = [...editAllProductingOptions];
+ let editSelectedProducting = '';
let editFilteredContacts = [];
let editSelectedContactId = '';
@@ -1881,6 +1947,11 @@
let filteredSpecOptions = [...allSpecOptions];
let selectedSpec = '';
+ // 产品包装选择功能
+ let allProductingOptions = ['1*360枚新包装', '1*360枚旧包新拖', '1*360枚旧包旧拖', '1*420枚新包装', '1*480枚新包装', '30枚蛋托散装', '360枚散托'];
+ let filteredProductingOptions = [...allProductingOptions];
+ let selectedProducting = '';
+
// 货源类型选择功能
let allSourceTypeOptions = ['平台货源', '鸡场直销', '第三方货源'];
let filteredSourceTypeOptions = [...allSourceTypeOptions];
@@ -1970,6 +2041,71 @@
hideSpecSelectModal();
}
+ // 显示产品包装选择弹窗
+ 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();
+ }
+
// 显示货源类型选择弹窗
function showSourceTypeSelectModal() {
const sourceTypeSelectModal = document.getElementById('sourceTypeSelectModal');
@@ -3988,6 +4124,7 @@
grossWeight: document.getElementById('grossWeight').value,
yolk: document.getElementById('yolk').value,
specification: document.getElementById('specValue').value,
+ producting: document.getElementById('productingValue').value,
supplyStatus: document.getElementById('supplyStatus').value,
sourceType: document.getElementById('sourceType').value,
description: document.getElementById('description').value,
@@ -4516,6 +4653,11 @@
document.getElementById('editSpecValue').value = supply.specification || '';
editSelectedSpec = supply.specification || '';
+ // 产品包装
+ document.getElementById('editProductingDisplayText').textContent = supply.producting || '请选择产品包装';
+ document.getElementById('editProductingValue').value = supply.producting || '';
+ editSelectedProducting = supply.producting || '';
+
// 货源状态(使用按钮组)
const supplyStatus = supply.supplyStatus || '预售';
document.getElementById('editSupplyStatus').value = supplyStatus;
@@ -4685,6 +4827,72 @@
hideEditSpecSelectModal();
}
+ // 编辑产品包装选择功能
+ // 显示编辑产品包装选择弹窗
+ function showEditProductingSelectModal() {
+ const editProductingSelectModal = document.getElementById('editProductingSelectModal');
+ editProductingSelectModal.classList.add('active');
+ // 重置搜索输入
+ document.getElementById('editProductingSearchInput').value = '';
+ editFilteredProductingOptions = [...editAllProductingOptions];
+ 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('#editProductingOptionsList .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 = editAllProductingOptions.filter(producting => {
+ return producting.toLowerCase().includes(searchKeyword);
+ });
+
+ generateEditProductingOptions();
+ }
+
+ // 确认编辑产品包装选择
+ function confirmEditProductingSelection() {
+ if (editSelectedProducting) {
+ document.getElementById('editProductingDisplayText').textContent = editSelectedProducting;
+ document.getElementById('editProductingValue').value = editSelectedProducting;
+ }
+ hideEditProductingSelectModal();
+ }
+
// 编辑地区选择功能
// 显示编辑地区选择弹窗
function showEditRegionSelectModal() {
@@ -5258,6 +5466,7 @@
grossWeight: document.getElementById('editGrossWeight').value,
yolk: document.getElementById('editYolk').value,
specification: document.getElementById('editSpecValue').value,
+ producting: document.getElementById('editProductingValue').value,
supplyStatus: document.getElementById('editSupplyStatus').value,
description: document.getElementById('editDescription').value,
region: document.getElementById('editRegionValue').value,