Browse Source

添加产品包装字段及修复编辑记忆功能

Boss2
Default User 2 months ago
parent
commit
07d975a4d0
  1. 17
      Reject.js
  2. 209
      supply.html

17
Reject.js

@ -696,7 +696,7 @@ app.post('/api/supplies/create', async (req, res) => {
let connection; let connection;
try { try {
connection = await pool.getConnection(); 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(); await connection.beginTransaction();
@ -782,6 +782,7 @@ app.post('/api/supplies/create', async (req, res) => {
grossWeight, grossWeight,
yolk, yolk,
specification, specification,
producting,
quality, quality,
region, region,
status: 'published', // 直接上架,而不是审核中 status: 'published', // 直接上架,而不是审核中
@ -805,19 +806,19 @@ app.post('/api/supplies/create', async (req, res) => {
if (columns.length === 0) { if (columns.length === 0) {
// 没有quality字段,不包含quality字段的插入 // 没有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 = [ insertParams = [
productId, productData.sellerId, productName, category || '', price.toString(), parseInt(quantity), grossWeight, 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(), productData.description, productData.rejectReason, productData.imageUrls, new Date(), new Date(),
productContact, contactPhone // 添加联系人信息 productContact, contactPhone // 添加联系人信息
]; ];
} else { } else {
// 有quality字段,包含quality字段的插入 // 有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 = [ insertParams = [
productId, productData.sellerId, productName, category || '', price.toString(), parseInt(quantity), grossWeight, 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, productData.sourceType, productData.description, productData.rejectReason, productData.imageUrls,
new Date(), new Date(), productContact, contactPhone // 添加联系人信息 new Date(), new Date(), productContact, contactPhone // 添加联系人信息
]; ];
@ -1023,7 +1024,7 @@ app.put('/api/supplies/:id/edit', async (req, res) => {
try { try {
const connection = await pool.getConnection(); const connection = await pool.getConnection();
const productId = req.params.id; 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(); await connection.beginTransaction();
@ -1062,14 +1063,14 @@ app.put('/api/supplies/:id/edit', async (req, res) => {
const updateQuery = ` const updateQuery = `
UPDATE products UPDATE products
SET productName = ?, price = ?, quantity = ?, grossWeight = ?, SET productName = ?, price = ?, quantity = ?, grossWeight = ?,
yolk = ?, specification = ?, supplyStatus = ?, description = ?, region = ?, yolk = ?, specification = ?, producting = ?, supplyStatus = ?, description = ?, region = ?,
product_contact = ?, contact_phone = ? product_contact = ?, contact_phone = ?
WHERE id = ? WHERE id = ?
`; `;
await connection.query(updateQuery, [ await connection.query(updateQuery, [
productName, price.toString(), parseInt(quantity), grossWeight, productName, price.toString(), parseInt(quantity), grossWeight,
yolk, specification, supplyStatus, description, region, yolk, specification, producting, supplyStatus, description, region,
productContact, contactPhone, productId productContact, contactPhone, productId
]); ]);

209
supply.html

@ -1120,6 +1120,15 @@
</div> </div>
</div> </div>
<!-- 产品包装 -->
<div class="form-group">
<label class="form-label">产品包装</label>
<div class="form-select" id="producting" onclick="showProductingSelectModal()" style="cursor: pointer; position: relative; padding-right: 30px;">
<span id="productingDisplayText">请选择产品包装</span>
<input type="hidden" id="productingValue" name="producting">
<span style="position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: #999;"></span>
</div>
</div>
<!-- 地区 --> <!-- 地区 -->
<div class="form-group"> <div class="form-group">
@ -1359,6 +1368,28 @@
</div> </div>
</div> </div>
</div> </div>
<!-- 产品包装选择弹窗 -->
<div id="productingSelectModal" class="select-modal">
<div class="select-content">
<div class="select-header">
<h3>选择产品包装</h3>
<button class="close-btn" onclick="hideProductingSelectModal()">×</button>
</div>
<div class="select-search">
<input type="text" id="productingSearchInput" placeholder="搜索产品包装" oninput="filterProductingOptions()" style="width: 100%; padding: 10px; border: 1px solid #d9d9d9; border-radius: 8px; font-size: 14px;">
</div>
<div class="select-body">
<div id="productingOptionsList" class="select-list">
<!-- 产品包装选项将通过JavaScript动态生成 -->
</div>
</div>
<div class="select-footer" style="padding: 16px 20px; display: flex; justify-content: space-between; border-top: 1px solid #f0f0f0; background-color: #fafafa;">
<button onclick="hideProductingSelectModal()" style="padding: 10px 24px; background-color: #f5f5f5; color: #666; border: none; border-radius: 8px; cursor: pointer; font-size: 14px; font-weight: 500; transition: all 0.3s ease;">取消</button>
<button onclick="confirmProductingSelection()" style="padding: 10px 24px; background-color: #1677ff; color: white; border: none; border-radius: 8px; cursor: pointer; font-size: 14px; font-weight: 500; transition: all 0.3s ease;">确定</button>
</div>
</div>
</div>
<!-- 审核失败原因弹窗 --> <!-- 审核失败原因弹窗 -->
<div id="rejectReasonModal" class="modal"> <div id="rejectReasonModal" class="modal">
@ -1457,6 +1488,16 @@
</div> </div>
</div> </div>
<!-- 产品包装 -->
<div class="form-group">
<label class="form-label">产品包装</label>
<div class="form-select" id="editProducting" onclick="showEditProductingSelectModal()" style="cursor: pointer; position: relative; padding-right: 30px;">
<span id="editProductingDisplayText">请选择产品包装</span>
<input type="hidden" id="editProductingValue" name="producting">
<span style="position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: #999;"></span>
</div>
</div>
<!-- 地区 --> <!-- 地区 -->
<div class="form-group"> <div class="form-group">
<label class="form-label">地区</label> <label class="form-label">地区</label>
@ -1655,6 +1696,28 @@
</div> </div>
</div> </div>
<!-- 编辑产品包装选择弹窗 -->
<div id="editProductingSelectModal" class="select-modal">
<div class="select-content">
<div class="select-header">
<h3>选择产品包装</h3>
<button class="close-btn" onclick="hideEditProductingSelectModal()">×</button>
</div>
<div class="select-search">
<input type="text" id="editProductingSearchInput" placeholder="搜索产品包装" oninput="filterEditProductingOptions()" style="width: 100%; padding: 10px; border: 1px solid #d9d9d9; border-radius: 8px; font-size: 14px;">
</div>
<div class="select-body">
<div id="editProductingOptionsList" class="select-list">
<!-- 产品包装选项将通过JavaScript动态生成 -->
</div>
</div>
<div class="select-footer" style="padding: 16px 20px; display: flex; justify-content: space-between; border-top: 1px solid #f0f0f0; background-color: #fafafa;">
<button onclick="hideEditProductingSelectModal()" style="padding: 8px 20px; background-color: #f5f5f5; color: #666; border: none; border-radius: 6px; cursor: pointer;">取消</button>
<button onclick="confirmEditProductingSelection()" style="padding: 8px 20px; background-color: #1677ff; color: white; border: none; border-radius: 6px; cursor: pointer;">确定</button>
</div>
</div>
</div>
<!-- 编辑地区选择弹窗 --> <!-- 编辑地区选择弹窗 -->
<div id="editRegionSelectModal" class="select-modal"> <div id="editRegionSelectModal" class="select-modal">
<div class="select-content"> <div class="select-content">
@ -1726,6 +1789,9 @@
let editAllYolkTypes = ['红心', '黄心', '双色', '未知']; let editAllYolkTypes = ['红心', '黄心', '双色', '未知'];
let editFilteredYolkTypes = [...editAllYolkTypes]; let editFilteredYolkTypes = [...editAllYolkTypes];
let editSelectedYolk = ''; let editSelectedYolk = '';
let editAllProductingOptions = ['1*360枚新包装', '1*360枚旧包新拖', '1*360枚旧包旧拖', '1*420枚新包装', '1*480枚新包装', '30枚蛋托散装', '360枚散托'];
let editFilteredProductingOptions = [...editAllProductingOptions];
let editSelectedProducting = '';
let editFilteredContacts = []; let editFilteredContacts = [];
let editSelectedContactId = ''; let editSelectedContactId = '';
@ -1881,6 +1947,11 @@
let filteredSpecOptions = [...allSpecOptions]; let filteredSpecOptions = [...allSpecOptions];
let selectedSpec = ''; let selectedSpec = '';
// 产品包装选择功能
let allProductingOptions = ['1*360枚新包装', '1*360枚旧包新拖', '1*360枚旧包旧拖', '1*420枚新包装', '1*480枚新包装', '30枚蛋托散装', '360枚散托'];
let filteredProductingOptions = [...allProductingOptions];
let selectedProducting = '';
// 货源类型选择功能 // 货源类型选择功能
let allSourceTypeOptions = ['平台货源', '鸡场直销', '第三方货源']; let allSourceTypeOptions = ['平台货源', '鸡场直销', '第三方货源'];
let filteredSourceTypeOptions = [...allSourceTypeOptions]; let filteredSourceTypeOptions = [...allSourceTypeOptions];
@ -1970,6 +2041,71 @@
hideSpecSelectModal(); 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() { function showSourceTypeSelectModal() {
const sourceTypeSelectModal = document.getElementById('sourceTypeSelectModal'); const sourceTypeSelectModal = document.getElementById('sourceTypeSelectModal');
@ -3988,6 +4124,7 @@
grossWeight: document.getElementById('grossWeight').value, grossWeight: document.getElementById('grossWeight').value,
yolk: document.getElementById('yolk').value, yolk: document.getElementById('yolk').value,
specification: document.getElementById('specValue').value, specification: document.getElementById('specValue').value,
producting: document.getElementById('productingValue').value,
supplyStatus: document.getElementById('supplyStatus').value, supplyStatus: document.getElementById('supplyStatus').value,
sourceType: document.getElementById('sourceType').value, sourceType: document.getElementById('sourceType').value,
description: document.getElementById('description').value, description: document.getElementById('description').value,
@ -4516,6 +4653,11 @@
document.getElementById('editSpecValue').value = supply.specification || ''; document.getElementById('editSpecValue').value = supply.specification || '';
editSelectedSpec = supply.specification || ''; editSelectedSpec = supply.specification || '';
// 产品包装
document.getElementById('editProductingDisplayText').textContent = supply.producting || '请选择产品包装';
document.getElementById('editProductingValue').value = supply.producting || '';
editSelectedProducting = supply.producting || '';
// 货源状态(使用按钮组) // 货源状态(使用按钮组)
const supplyStatus = supply.supplyStatus || '预售'; const supplyStatus = supply.supplyStatus || '预售';
document.getElementById('editSupplyStatus').value = supplyStatus; document.getElementById('editSupplyStatus').value = supplyStatus;
@ -4685,6 +4827,72 @@
hideEditSpecSelectModal(); 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() { function showEditRegionSelectModal() {
@ -5258,6 +5466,7 @@
grossWeight: document.getElementById('editGrossWeight').value, grossWeight: document.getElementById('editGrossWeight').value,
yolk: document.getElementById('editYolk').value, yolk: document.getElementById('editYolk').value,
specification: document.getElementById('editSpecValue').value, specification: document.getElementById('editSpecValue').value,
producting: document.getElementById('editProductingValue').value,
supplyStatus: document.getElementById('editSupplyStatus').value, supplyStatus: document.getElementById('editSupplyStatus').value,
description: document.getElementById('editDescription').value, description: document.getElementById('editDescription').value,
region: document.getElementById('editRegionValue').value, region: document.getElementById('editRegionValue').value,

Loading…
Cancel
Save