Browse Source

完成合并操作

pull/4/head
Trae AI 2 months ago
parent
commit
89c6e1eba5
  1. 15
      Reject.html
  2. 213
      supply.html

15
Reject.html

@ -1256,13 +1256,20 @@
<div id="supplyImages" style="display: flex; gap: 10px; margin-bottom: 10px; flex-wrap: wrap;"> <div id="supplyImages" style="display: flex; gap: 10px; margin-bottom: 10px; flex-wrap: wrap;">
<!-- 图片预览将动态添加到这里 --> <!-- 图片预览将动态添加到这里 -->
</div> </div>
<div id="imageDropArea" style="border: 2px dashed #d9d9d9; border-radius: 4px; padding: 20px; text-align: center; margin-bottom: 10px; background-color: #fafafa; transition: all 0.3s ease;"> <div id="imageDropArea" style="border: 2px dashed #d9d9d9; border-radius: 4px; padding: 20px; text-align: left; margin-bottom: 10px; background-color: #fafafa; transition: all 0.3s ease;">
<div style="font-size: 14px; color: #666; margin-bottom: 5px;">拖拽图片到此处或点击添加图片</div> <div style="font-size: 14px; color: #666; margin-bottom: 5px; text-align: center;">拖拽图片到此处或点击添加图片</div>
<div style="font-size: 12px; color: #999;">支持JPG、PNG等图片格式,最多上传5张</div> <div style="font-size: 12px; color: #666; margin: 10px 0; padding: 8px; background-color: #f5f5f5; border-radius: 4px;">
<div>图片要求:</div>
<div>1. 箱子堆头图(不得出现地址、电话及货源信息,直营包场除外);</div>
<div>2. 鸡蛋外观图;</div>
<div>3. 敲开鸡蛋后清晰显示蛋清、蛋黄状态,以体现新鲜度;</div>
<div>4. 其他能佐证蛋重、品种的辅助图片。</div>
</div>
<div style="font-size: 12px; color: #999; text-align: left;">支持JPG、PNG等图片格式,最多上传5张</div>
</div> </div>
<input type="file" id="supplyImageUpload" multiple accept="image/*" style="display: none;"> <input type="file" id="supplyImageUpload" multiple accept="image/*" style="display: none;">
<button id="addImageBtn" class="btn btn-default" style="margin-right: 10px;">添加图片</button> <button id="addImageBtn" class="btn btn-default" style="margin-right: 10px;">添加图片</button>
<span style="font-size: 12px; color: #999;">最多上传5张图片</span> <span style="font-size: 12px; color: #999; text-align: left;">最多上传5张图片</span>
</div> </div>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">

213
supply.html

@ -413,7 +413,8 @@
font-size: 14px; font-size: 14px;
box-sizing: border-box; box-sizing: border-box;
transition: all 0.3s; transition: all 0.3s;
background-color: #fff; background-color: #fafafa;
caret-color: #333;
} }
.form-input:hover, .form-input:hover,
@ -422,10 +423,14 @@
} }
.form-input:focus, .form-input:focus,
.form-select:focus { .form-input:active,
.form-select:focus,
.form-select:active {
outline: none; outline: none;
border-color: #1677ff; border-color: #1677ff;
box-shadow: 0 0 0 2px rgba(22, 119, 255, 0.2); box-shadow: 0 0 0 2px rgba(22, 119, 255, 0.2);
background-color: #fafafa;
caret-color: #333;
} }
/* 图片上传 */ /* 图片上传 */
@ -1082,9 +1087,12 @@
<label class="form-label">货源状态</label> <label class="form-label">货源状态</label>
<div style="display: flex; gap: 10px;"> <div style="display: flex; gap: 10px;">
<button type="button" id="preSaleBtn" class="status-button" onclick="setSupplyStatus('预售')" style="padding: 8px 20px; border: 2px solid #d9d9d9; background-color: white; color: #666; border-radius: 6px; cursor: pointer;">预售</button> <button type="button" id="preSaleBtn" class="status-button" onclick="setSupplyStatus('预售')" style="padding: 8px 20px; border: 2px solid #d9d9d9; background-color: white; color: #666; border-radius: 6px; cursor: pointer;">预售</button>
<button type="button" id="inStockBtn" class="status-button" onclick="setSupplyStatus('现货')" style="padding: 8px 20px; border: 2px solid #d9d9d9; background-color: white; color: #666; border-radius: 6px; cursor: pointer;">现货</button> <button type="button" id="inStockBtn" class="status-button" onclick="setSupplyStatus('现货')" style="padding: 8px 20px; border: 2px solid #d9d9d9; background-color: white; color: #666; border-radius: 6px; cursor: pointer;">现货</button>
<input type="hidden" id="supplyStatus" value=""> <input type="hidden" id="supplyStatus" value="">
</div> </div>
<div style="margin-top: 10px; padding: 8px; background-color: #f5f5f5; border-radius: 4px; font-size: 12px; color: #666; text-align: left;">
预售(没有现货,销售未来的货), 现货(当日可用于销售的货源)
</div>
</div> </div>
<!-- 商品图片 --> <!-- 商品图片 -->
@ -1094,7 +1102,14 @@
<div id="uploadImages" class="upload-images"></div> <div id="uploadImages" class="upload-images"></div>
<div class="add-image" onclick="triggerImageUpload()">+</div> <div class="add-image" onclick="triggerImageUpload()">+</div>
<input type="file" id="imageUpload" multiple accept="image/*" style="display: none;" onchange="handleImageUpload(event)"> <input type="file" id="imageUpload" multiple accept="image/*" style="display: none;" onchange="handleImageUpload(event)">
<div style="font-size: 12px; color: #999; margin-top: 10px;">最多上传5张图片</div> <div style="font-size: 12px; color: #666; margin-top: 10px; text-align: left; padding: 8px; background-color: #f5f5f5; border-radius: 4px;">
<div>图片要求:</div>
<div>1. 箱子堆头图(不得出现地址、电话及货源信息,直营包场除外);</div>
<div>2. 鸡蛋外观图;</div>
<div>3. 敲开鸡蛋后清晰显示蛋清、蛋黄状态,以体现新鲜度;</div>
<div>4. 其他能佐证蛋重、品种的辅助图片。</div>
</div>
<div style="font-size: 12px; color: #999; margin-top: 10px; text-align: left;">最多上传5张图片</div>
</div> </div>
</div> </div>
@ -1180,7 +1195,7 @@
<!-- 价格 --> <!-- 价格 -->
<div class="form-group"> <div class="form-group">
<label class="form-label">价格</label> <label class="form-label">价格(销售价)</label>
<input type="number" class="form-input" id="price" placeholder="请输入价格" step="0.01"> <input type="number" class="form-input" id="price" placeholder="请输入价格" step="0.01">
</div> </div>
@ -1233,6 +1248,11 @@
<h3>选择货源类型</h3> <h3>选择货源类型</h3>
<button class="close-btn" onclick="hideSourceTypeSelectModal()">×</button> <button class="close-btn" onclick="hideSourceTypeSelectModal()">×</button>
</div> </div>
<div style="padding: 10px 20px; background-color: #f0f8ff; border-radius: 4px; margin: 0 20px; font-size: 12px; color: #1890ff;">
<div>平台货源: 直接包场货源</div>
<div>鸡场直销: 鸡场直销货源</div>
<div>第三方货源: 贸易商货源</div>
</div>
<div class="select-search"> <div class="select-search">
<input type="text" id="sourceTypeSearchInput" placeholder="搜索货源类型" oninput="filterSourceTypeOptions()" style="width: 100%; padding: 10px; border: 1px solid #d9d9d9; border-radius: 8px; font-size: 14px;"> <input type="text" id="sourceTypeSearchInput" placeholder="搜索货源类型" oninput="filterSourceTypeOptions()" style="width: 100%; padding: 10px; border: 1px solid #d9d9d9; border-radius: 8px; font-size: 14px;">
</div> </div>
@ -1277,6 +1297,10 @@
<h3>选择蛋黄类型</h3> <h3>选择蛋黄类型</h3>
<button class="close-btn" onclick="hideYolkSelectModal()">×</button> <button class="close-btn" onclick="hideYolkSelectModal()">×</button>
</div> </div>
<div style="padding: 10px 20px; background-color: #fff3cd; border: 1px solid #ffeeba; border-radius: 4px; margin: 0 20px; font-size: 12px; color: #856404;">
<div>请按实际情况选择蛋黄颜色,对于脏次或者冻库蛋不知道蛋黄颜色的情况下可以填写未知</div>
<div>(如果有色卡可以在货源描述里面填写色度)</div>
</div>
<div class="select-search"> <div class="select-search">
<input type="text" id="yolkSearchInput" placeholder="搜索蛋黄类型" oninput="filterYolkOptions()" style="width: 100%; padding: 10px; border: 1px solid #d9d9d9; border-radius: 8px; font-size: 14px;"> <input type="text" id="yolkSearchInput" placeholder="搜索蛋黄类型" oninput="filterYolkOptions()" style="width: 100%; padding: 10px; border: 1px solid #d9d9d9; border-radius: 8px; font-size: 14px;">
</div> </div>
@ -1321,6 +1345,11 @@
<h3>选择规格</h3> <h3>选择规格</h3>
<button class="close-btn" onclick="hideSpecSelectModal()">×</button> <button class="close-btn" onclick="hideSpecSelectModal()">×</button>
</div> </div>
<div style="padding: 0 20px 10px 20px;">
<div style="padding: 8px; background-color: #f5f5f5; border-radius: 4px; font-size: 12px; color: #666; text-align: left;">
按重量选择该批次货最多的重量区间
</div>
</div>
<div class="select-search"> <div class="select-search">
<input type="text" id="specSearchInput" placeholder="搜索规格" oninput="filterSpecOptions()" style="width: 100%; padding: 10px; border: 1px solid #d9d9d9; border-radius: 8px; font-size: 14px;"> <input type="text" id="specSearchInput" placeholder="搜索规格" oninput="filterSpecOptions()" style="width: 100%; padding: 10px; border: 1px solid #d9d9d9; border-radius: 8px; font-size: 14px;">
</div> </div>
@ -1349,10 +1378,9 @@
</div> </div>
<div class="select-body"> <div class="select-body">
<div id="regionOptionsList" style="display: flex; gap: 10px; padding: 10px;"> <div id="regionOptionsList" style="display: flex; gap: 10px; padding: 10px;">
<!-- 省市选择将通过JavaScript动态生成 --> <!-- 省市选择将通过JavaScript动态生成 -->
<div id="provinceList" style="flex: 1; overflow-y: auto;"></div> <div id="provinceList" style="flex: 1; overflow-y: auto;"></div>
<div id="cityList" style="flex: 1; overflow-y: auto;"></div> <div id="cityList" style="flex: 1; overflow-y: auto;"></div>
<div id="districtList" style="flex: 1; overflow-y: auto;"></div>
</div> </div>
</div> </div>
<div class="select-footer" style="padding: 16px 20px; display: flex; justify-content: space-between; border-top: 1px solid #f0f0f0; background-color: #fafafa;"> <div class="select-footer" style="padding: 16px 20px; display: flex; justify-content: space-between; border-top: 1px solid #f0f0f0; background-color: #fafafa;">
@ -1417,6 +1445,9 @@
<button type="button" id="editInStockBtn" class="status-button" onclick="setEditSupplyStatus('现货')" style="padding: 8px 20px; border: 2px solid #d9d9d9; background-color: white; color: #666; border-radius: 6px; cursor: pointer;">现货</button> <button type="button" id="editInStockBtn" class="status-button" onclick="setEditSupplyStatus('现货')" style="padding: 8px 20px; border: 2px solid #d9d9d9; background-color: white; color: #666; border-radius: 6px; cursor: pointer;">现货</button>
<input type="hidden" id="editSupplyStatus" value=""> <input type="hidden" id="editSupplyStatus" value="">
</div> </div>
<div style="margin-top: 10px; padding: 8px; background-color: #f5f5f5; border-radius: 4px; font-size: 12px; color: #666; text-align: left;">
预售(没有现货,销售未来的货), 现货(当日可用于销售的货源)
</div>
</div> </div>
<!-- 商品图片 --> <!-- 商品图片 -->
@ -1510,7 +1541,7 @@
<!-- 价格 --> <!-- 价格 -->
<div class="form-group"> <div class="form-group">
<label class="form-label">价格</label> <label class="form-label">价格(销售价)</label>
<input type="number" class="form-input" id="editPrice" placeholder="请输入价格" step="0.01"> <input type="number" class="form-input" id="editPrice" placeholder="请输入价格" step="0.01">
</div> </div>
@ -1547,6 +1578,11 @@
<h3>选择规格</h3> <h3>选择规格</h3>
<button class="close-btn" onclick="hideEditSpecSelectModal()">×</button> <button class="close-btn" onclick="hideEditSpecSelectModal()">×</button>
</div> </div>
<div style="padding: 0 20px 10px 20px;">
<div style="padding: 8px; background-color: #f5f5f5; border-radius: 4px; font-size: 12px; color: #666; text-align: left;">
按重量选择该批次货最多的重量区间
</div>
</div>
<div class="select-search"> <div class="select-search">
<input type="text" id="editSpecSearchInput" placeholder="搜索规格" oninput="filterEditSpecOptions()" style="width: 100%; padding: 10px; border: 1px solid #d9d9d9; border-radius: 8px; font-size: 14px;"> <input type="text" id="editSpecSearchInput" placeholder="搜索规格" oninput="filterEditSpecOptions()" style="width: 100%; padding: 10px; border: 1px solid #d9d9d9; border-radius: 8px; font-size: 14px;">
</div> </div>
@ -1569,6 +1605,11 @@
<h3>选择货源类型</h3> <h3>选择货源类型</h3>
<button class="close-btn" onclick="hideEditSourceTypeSelectModal()">×</button> <button class="close-btn" onclick="hideEditSourceTypeSelectModal()">×</button>
</div> </div>
<div style="padding: 10px 20px; background-color: #f0f8ff; border-radius: 4px; margin: 0 20px; font-size: 12px; color: #1890ff;">
<div>平台货源: 直接包场货源</div>
<div>鸡场直销: 鸡场直销货源</div>
<div>第三方货源: 贸易商货源</div>
</div>
<div class="select-search"> <div class="select-search">
<input type="text" id="editSourceTypeSearchInput" placeholder="搜索货源类型" oninput="filterEditSourceTypeOptions()" style="width: 100%; padding: 10px; border: 1px solid #d9d9d9; border-radius: 8px; font-size: 14px;"> <input type="text" id="editSourceTypeSearchInput" placeholder="搜索货源类型" oninput="filterEditSourceTypeOptions()" style="width: 100%; padding: 10px; border: 1px solid #d9d9d9; border-radius: 8px; font-size: 14px;">
</div> </div>
@ -1635,6 +1676,10 @@
<h3>选择蛋黄类型</h3> <h3>选择蛋黄类型</h3>
<button class="close-btn" onclick="hideEditYolkSelectModal()">×</button> <button class="close-btn" onclick="hideEditYolkSelectModal()">×</button>
</div> </div>
<div style="padding: 10px 20px; background-color: #fff3cd; border: 1px solid #ffeeba; border-radius: 4px; margin: 0 20px; font-size: 12px; color: #856404;">
<div>请按实际情况选择蛋黄颜色,对于脏次或者冻库蛋不知道蛋黄颜色的情况下可以填写未知</div>
<div>(如果有色卡可以在货源描述里面填写色度)</div>
</div>
<div class="select-search"> <div class="select-search">
<input type="text" id="editYolkSearchInput" placeholder="搜索蛋黄类型" oninput="filterEditYolkOptions()" style="width: 100%; padding: 10px; border: 1px solid #d9d9d9; border-radius: 8px; font-size: 14px;"> <input type="text" id="editYolkSearchInput" placeholder="搜索蛋黄类型" oninput="filterEditYolkOptions()" style="width: 100%; padding: 10px; border: 1px solid #d9d9d9; border-radius: 8px; font-size: 14px;">
</div> </div>
@ -1731,16 +1776,16 @@
let editSelectedProvince = ''; let editSelectedProvince = '';
let editSelectedCity = ''; let editSelectedCity = '';
let editSelectedDistrict = ''; let editSelectedDistrict = '';
let editAllSourceTypes = ['平台货源', '三方认证', '三方未认证']; let editAllSourceTypes = ['平台货源', '鸡场直销', '第三方货源'];
let editFilteredSourceTypes = [...editAllSourceTypes]; let editFilteredSourceTypes = [...editAllSourceTypes];
let editSelectedSourceType = ''; let editSelectedSourceType = '';
let editAllCategories = ['粉壳', '褐壳', '绿壳', '白壳']; let editAllCategories = ['粉壳', '褐壳', '绿壳', '白壳'];
let editFilteredCategories = [...editAllCategories]; let editFilteredCategories = [...editAllCategories];
let editSelectedCategory = ''; let editSelectedCategory = '';
let editAllProductNames = ['罗曼粉', '伊莎粉', '罗曼灰', '海蓝灰', '海蓝褐', '绿壳', '双黄蛋']; let editAllProductNames = ['罗曼粉', '伊莎粉', '罗曼灰', '海蓝灰', '海蓝褐', '绿壳', '粉一', '粉三', '粉八', '京粉1号', '京红', '京粉6号', '京粉3号', '农大系列', '黑鸡土蛋', '大午金凤', '黑凤'];
let editFilteredProductNames = [...editAllProductNames]; let editFilteredProductNames = [...editAllProductNames];
let editSelectedProductName = ''; let editSelectedProductName = '';
let editAllYolkTypes = ['红心', '黄心', '双色']; let editAllYolkTypes = ['红心', '黄心', '双色', '未知'];
let editFilteredYolkTypes = [...editAllYolkTypes]; let editFilteredYolkTypes = [...editAllYolkTypes];
let editSelectedYolk = ''; let editSelectedYolk = '';
let editFilteredContacts = []; let editFilteredContacts = [];
@ -1893,22 +1938,22 @@
} }
// 规格选择功能 // 规格选择功能
let allSpecOptions = ['格子装', '散托', '不限规格', '净重47+', '净重46-47', '净重45-46', '净重44-45', '净重43-44', '净重42-43', '净重41-42', '净重40-41', '净重39-40', '净重38-39', '净重37-39', '净重37-38', '净重36-38', '净重36-37', '净重35-36', '净重34-35', '净重33-34', '净重32-33', '净重32-34', '净重31-32', '净重30-35', '净重30-34', '净重30-32', '净重30-31', '净重29-31', '净重29-30', '净重28-29', '净重28以下', '毛重52以上', '毛重50-51', '毛重48-49', '毛重47-48', '毛重46-47', '毛重45-47', '毛重45-46', '毛重44-45', '毛重43-44', '毛重42-43', '毛重41-42', '毛重40-41', '毛重38-39', '毛重36-37', '毛重34-35', '毛重32-33', '毛重30-31', '毛重30以下']; let allSpecOptions = ['净重47+', '净重46-47', '净重45-46', '净重44-45', '净重43-44', '净重42-43', '净重41-42', '净重40-41', '净重39-40', '净重38-39', '净重37-39', '净重37-38', '净重36-38', '净重36-37', '净重35-36', '净重34-35', '净重33-34', '净重32-33', '净重32-34', '净重31-32', '净重30-35', '净重30-34', '净重30-32', '净重30-31', '净重29-31', '净重29-30', '净重28-29', '净重28以下', '毛重52以上', '毛重50-51', '毛重48-49', '毛重47-48', '毛重46-47', '毛重45-47', '毛重45-46', '毛重44-45', '毛重43-44', '毛重42-43', '毛重41-42', '毛重40-41', '毛重38-39', '毛重36-37', '毛重34-35', '毛重32-33', '毛重30-31', '毛重30以下'];
let filteredSpecOptions = [...allSpecOptions]; let filteredSpecOptions = [...allSpecOptions];
let selectedSpec = ''; let selectedSpec = '';
// 货源类型选择功能 // 货源类型选择功能
let allSourceTypeOptions = ['平台货源', '三方认证', '三方未认证']; let allSourceTypeOptions = ['平台货源', '鸡场直销', '第三方货源'];
let filteredSourceTypeOptions = [...allSourceTypeOptions]; let filteredSourceTypeOptions = [...allSourceTypeOptions];
let selectedSourceType = ''; let selectedSourceType = '';
// 商品名称选择功能 // 商品名称选择功能
let allProductNameOptions = ['罗曼粉', '伊莎粉', '罗曼灰', '海蓝灰', '海蓝褐', '绿壳', '双黄蛋']; let allProductNameOptions = ['罗曼粉', '伊莎粉', '罗曼灰', '海蓝灰', '海蓝褐', '绿壳', '粉一', '粉三', '粉八', '京粉1号', '京红', '京粉6号', '京粉3号', '农大系列', '黑鸡土蛋', '大午金凤', '黑凤'];
let filteredProductNameOptions = [...allProductNameOptions]; let filteredProductNameOptions = [...allProductNameOptions];
let selectedProductName = ''; let selectedProductName = '';
// 蛋黄类型选择功能 // 蛋黄类型选择功能
let allYolkOptions = ['红心', '黄心', '双色']; let allYolkOptions = ['红心', '黄心', '双色', '未知'];
let filteredYolkOptions = [...allYolkOptions]; let filteredYolkOptions = [...allYolkOptions];
let selectedYolk = ''; let selectedYolk = '';
@ -2952,7 +2997,6 @@
let selectedProvince = ''; let selectedProvince = '';
let selectedCity = ''; let selectedCity = '';
let selectedDistrict = '';
let filteredProvinces = [...allRegionOptions]; let filteredProvinces = [...allRegionOptions];
// 显示地区选择弹窗 // 显示地区选择弹窗
@ -2975,7 +3019,6 @@
function generateRegionOptions() { function generateRegionOptions() {
const provinceList = document.getElementById('provinceList'); const provinceList = document.getElementById('provinceList');
const cityList = document.getElementById('cityList'); const cityList = document.getElementById('cityList');
const districtList = document.getElementById('districtList');
// 生成省份选项 // 生成省份选项
provinceList.innerHTML = ''; provinceList.innerHTML = '';
@ -2986,12 +3029,9 @@
option.onclick = () => { option.onclick = () => {
selectedProvince = province.province; selectedProvince = province.province;
selectedCity = ''; selectedCity = '';
selectedDistrict = '';
updateRegionDisplay(); updateRegionDisplay();
// 生成城市选项 // 生成城市选项
generateCityOptions(province.cities); generateCityOptions(province.cities);
// 清空区县选项
districtList.innerHTML = '';
}; };
provinceList.appendChild(option); provinceList.appendChild(option);
}); });
@ -3000,7 +3040,6 @@
// 生成城市选项 // 生成城市选项
function generateCityOptions(cities) { function generateCityOptions(cities) {
const cityList = document.getElementById('cityList'); const cityList = document.getElementById('cityList');
const districtList = document.getElementById('districtList');
cityList.innerHTML = ''; cityList.innerHTML = '';
cities.forEach(city => { cities.forEach(city => {
@ -3009,34 +3048,14 @@
option.textContent = city.city; option.textContent = city.city;
option.onclick = () => { option.onclick = () => {
selectedCity = city.city; selectedCity = city.city;
selectedDistrict = '';
updateRegionDisplay();
// 生成区县选项
generateDistrictOptions(city.districts);
};
cityList.appendChild(option);
});
}
// 生成区县选项
function generateDistrictOptions(districts) {
const districtList = document.getElementById('districtList');
districtList.innerHTML = '';
districts.forEach(district => {
const option = document.createElement('div');
option.className = 'select-item';
option.textContent = district;
option.onclick = () => {
selectedDistrict = district;
updateRegionDisplay(); updateRegionDisplay();
}; };
option.ondblclick = () => { option.ondblclick = () => {
// 双击区县直接确认整个地区选择 // 双击城市直接确认整个地区选择
selectedDistrict = district; selectedCity = city.city;
updateRegionDisplay(); updateRegionDisplay();
// 构建完整的地区字符串 // 构建完整的地区字符串
const regionString = `${selectedProvince} ${selectedCity} ${selectedDistrict}`; const regionString = `${selectedProvince} ${selectedCity}`;
// 设置到表单 // 设置到表单
document.getElementById('regionDisplayText').textContent = regionString; document.getElementById('regionDisplayText').textContent = regionString;
document.getElementById('regionValue').value = regionString; document.getElementById('regionValue').value = regionString;
@ -3044,17 +3063,22 @@
hideRegionSelectModal(); hideRegionSelectModal();
saveFormData(); // 保存选择 saveFormData(); // 保存选择
}; };
districtList.appendChild(option); cityList.appendChild(option);
});
// 使用requestAnimationFrame确保滚动操作在浏览器下一次重绘前执行
requestAnimationFrame(() => {
cityList.scrollTop = 0;
}); });
} }
// 更新地区显示 // 更新地区显示
function updateRegionDisplay() { function updateRegionDisplay() {
const currentRegion = document.getElementById('currentRegion'); const currentRegion = document.getElementById('currentRegion');
let displayText = '当前选择: '; let displayText = '当前选择: ';
if (selectedProvince && selectedCity && selectedDistrict) { if (selectedProvince && selectedCity) {
displayText += `${selectedProvince} ${selectedCity} ${selectedDistrict}`;
} else if (selectedProvince && selectedCity) {
displayText += `${selectedProvince} ${selectedCity}`; displayText += `${selectedProvince} ${selectedCity}`;
} else if (selectedProvince) { } else if (selectedProvince) {
displayText += selectedProvince; displayText += selectedProvince;
@ -3072,32 +3096,26 @@
// 重置选择 // 重置选择
selectedProvince = ''; selectedProvince = '';
selectedCity = ''; selectedCity = '';
selectedDistrict = '';
// 先尝试直接查找区县 // 先尝试直接查找城市
let foundDistrict = false; let foundCity = false;
for (let i = 0; i < allRegionOptions.length; i++) { for (let i = 0; i < allRegionOptions.length; i++) {
const province = allRegionOptions[i]; const province = allRegionOptions[i];
for (let j = 0; j < province.cities.length; j++) { for (let j = 0; j < province.cities.length; j++) {
const city = province.cities[j]; const city = province.cities[j];
for (let k = 0; k < city.districts.length; k++) { if (city.city.toLowerCase().includes(searchKeyword)) {
const district = city.districts[k]; // 找到匹配的城市,自动填充省市
if (district.toLowerCase().includes(searchKeyword)) { selectedProvince = province.province;
// 找到匹配的区县,自动填充省市区 selectedCity = city.city;
selectedProvince = province.province; foundCity = true;
selectedCity = city.city; break;
selectedDistrict = district;
foundDistrict = true;
break;
}
} }
if (foundDistrict) break;
} }
if (foundDistrict) break; if (foundCity) break;
} }
if (foundDistrict) { if (foundCity) {
// 如果找到区县,只显示对应的省份 // 如果找到城市,只显示对应的省份
filteredProvinces = allRegionOptions.filter(province => province.province === selectedProvince); filteredProvinces = allRegionOptions.filter(province => province.province === selectedProvince);
generateRegionOptions(); generateRegionOptions();
@ -3115,39 +3133,27 @@
} }
option.onclick = () => { option.onclick = () => {
selectedCity = city.city; selectedCity = city.city;
selectedDistrict = '';
updateRegionDisplay(); updateRegionDisplay();
generateDistrictOptions(city.districts);
}; };
cityList.appendChild(option); cityList.appendChild(option);
});
// 如果是选中的城市,生成区县选项 // 使用requestAnimationFrame确保滚动操作在浏览器下一次重绘前执行
if (city.city === selectedCity) { requestAnimationFrame(() => {
generateDistrictOptions(city.districts); cityList.scrollTop = 0;
}
}); });
} }
// 更新区县选项的选中状态
const districtList = document.getElementById('districtList');
const districtOptions = districtList.querySelectorAll('.select-item');
districtOptions.forEach(option => {
if (option.textContent === selectedDistrict) {
option.classList.add('selected');
}
});
} else { } else {
// 否则按原逻辑过滤 // 否则按原逻辑过滤
filteredProvinces = allRegionOptions.filter(province => { filteredProvinces = allRegionOptions.filter(province => {
return province.province.toLowerCase().includes(searchKeyword) || return province.province.toLowerCase().includes(searchKeyword) ||
province.cities.some(city => city.city.toLowerCase().includes(searchKeyword) || province.cities.some(city => city.city.toLowerCase().includes(searchKeyword));
city.districts.some(district => district.toLowerCase().includes(searchKeyword)));
}); });
generateRegionOptions(); generateRegionOptions();
// 清空城市和区县选项 // 清空城市选项
document.getElementById('cityList').innerHTML = ''; const cityList = document.getElementById('cityList');
document.getElementById('districtList').innerHTML = ''; cityList.innerHTML = '';
} }
updateRegionDisplay(); updateRegionDisplay();
@ -3155,24 +3161,17 @@
// 确认地区选择 // 确认地区选择
function confirmRegionSelection() { function confirmRegionSelection() {
if (selectedProvince && selectedCity && selectedDistrict) { if (selectedProvince && selectedCity) {
const regionDisplayText = document.getElementById('regionDisplayText'); const regionDisplayText = document.getElementById('regionDisplayText');
const regionValue = document.getElementById('regionValue'); const regionValue = document.getElementById('regionValue');
const regionText = `${selectedProvince} ${selectedCity} ${selectedDistrict}`; const regionText = `${selectedProvince} ${selectedCity}`;
regionDisplayText.textContent = regionText; regionDisplayText.textContent = regionText;
regionValue.value = regionText; regionValue.value = regionText;
saveFormData(); // 保存选择
} }
hideRegionSelectModal(); hideRegionSelectModal();
} }
// 确认创建货源时,获取隐藏域的值
function addSupply() {
const spec = document.getElementById('specValue').value;
const region = document.getElementById('regionValue').value;
// 继续原有逻辑...
}
// 加载联系人数据 // 加载联系人数据
async function loadContacts() { async function loadContacts() {
try { try {
@ -3605,7 +3604,6 @@
selectedSpec = ''; selectedSpec = '';
selectedProvince = ''; selectedProvince = '';
selectedCity = ''; selectedCity = '';
selectedDistrict = '';
selectedSourceType = ''; selectedSourceType = '';
selectedProductName = ''; selectedProductName = '';
selectedYolk = ''; selectedYolk = '';
@ -3702,7 +3700,6 @@
if (formData.selectedSpec) selectedSpec = formData.selectedSpec; if (formData.selectedSpec) selectedSpec = formData.selectedSpec;
if (formData.selectedProvince) selectedProvince = formData.selectedProvince; if (formData.selectedProvince) selectedProvince = formData.selectedProvince;
if (formData.selectedCity) selectedCity = formData.selectedCity; if (formData.selectedCity) selectedCity = formData.selectedCity;
if (formData.selectedDistrict) selectedDistrict = formData.selectedDistrict;
// 为所有下拉框触发change事件,确保UI完全同步 // 为所有下拉框触发change事件,确保UI完全同步
const dropdownElements = [productName, yolk, sourceType, contactId]; const dropdownElements = [productName, yolk, sourceType, contactId];
@ -3729,7 +3726,6 @@
selectedSpec = formData.selectedSpec || ''; selectedSpec = formData.selectedSpec || '';
selectedProvince = formData.selectedProvince || ''; selectedProvince = formData.selectedProvince || '';
selectedCity = formData.selectedCity || ''; selectedCity = formData.selectedCity || '';
selectedDistrict = formData.selectedDistrict || '';
selectedSourceType = formData.selectedSourceType || ''; selectedSourceType = formData.selectedSourceType || '';
selectedProductName = formData.selectedProductName || ''; selectedProductName = formData.selectedProductName || '';
selectedYolk = formData.selectedYolk || ''; selectedYolk = formData.selectedYolk || '';
@ -3995,7 +3991,6 @@
selectedSpec: selectedSpec || '', selectedSpec: selectedSpec || '',
selectedProvince: selectedProvince || '', selectedProvince: selectedProvince || '',
selectedCity: selectedCity || '', selectedCity: selectedCity || '',
selectedDistrict: selectedDistrict || '',
selectedSourceType: selectedSourceType || '', selectedSourceType: selectedSourceType || '',
selectedProductName: selectedProductName || '', selectedProductName: selectedProductName || '',
selectedYolk: selectedYolk || '', selectedYolk: selectedYolk || '',
@ -4015,7 +4010,15 @@
} }
// 创建货源 // 创建货源
// 防止重复提交的标志位
let isSubmitting = false;
async function addSupply() { async function addSupply() {
// 防止重复提交
if (isSubmitting) {
return;
}
// 获取当前登录用户信息 // 获取当前登录用户信息
const userInfo = checkLogin(); const userInfo = checkLogin();
if (!userInfo) return; if (!userInfo) return;
@ -4077,6 +4080,12 @@
} }
try { try {
// 设置为提交中状态,禁用按钮
isSubmitting = true;
const submitBtn = document.querySelector('.modal-btn-primary');
submitBtn.disabled = true;
submitBtn.textContent = '创建中...';
const response = await fetch('/api/supplies/create', { const response = await fetch('/api/supplies/create', {
method: 'POST', method: 'POST',
headers: { headers: {
@ -4102,6 +4111,12 @@
} catch (error) { } catch (error) {
console.error('创建货源失败:', error); console.error('创建货源失败:', error);
alert('创建失败: 网络错误'); alert('创建失败: 网络错误');
} finally {
// 恢复提交状态,启用按钮
isSubmitting = false;
const submitBtn = document.querySelector('.modal-btn-primary');
submitBtn.disabled = false;
submitBtn.textContent = '创建';
} }
} }

Loading…
Cancel
Save