|
|
@ -997,7 +997,7 @@ |
|
|
</div> |
|
|
</div> |
|
|
|
|
|
|
|
|
<!-- 审核中的货源 --> |
|
|
<!-- 审核中的货源 --> |
|
|
<div class="supply-section"> |
|
|
<div class="supply-section" style="display: none;"> |
|
|
<div class="section-header" onclick="toggleSection('pending')"> |
|
|
<div class="section-header" onclick="toggleSection('pending')"> |
|
|
<div class="section-title">审核中的货源 (0)</div> |
|
|
<div class="section-title">审核中的货源 (0)</div> |
|
|
<div id="pendingToggle" class="section-toggle">▼</div> |
|
|
<div id="pendingToggle" class="section-toggle">▼</div> |
|
|
@ -1008,7 +1008,7 @@ |
|
|
</div> |
|
|
</div> |
|
|
|
|
|
|
|
|
<!-- 审核失败的货源 --> |
|
|
<!-- 审核失败的货源 --> |
|
|
<div class="supply-section"> |
|
|
<div class="supply-section" style="display: none;"> |
|
|
<div class="section-header" onclick="toggleSection('rejected')"> |
|
|
<div class="section-header" onclick="toggleSection('rejected')"> |
|
|
<div class="section-title">审核失败的货源 (0)</div> |
|
|
<div class="section-title">审核失败的货源 (0)</div> |
|
|
<div id="rejectedToggle" class="section-toggle">▼</div> |
|
|
<div id="rejectedToggle" class="section-toggle">▼</div> |
|
|
@ -1144,13 +1144,13 @@ |
|
|
<!-- 价格 --> |
|
|
<!-- 价格 --> |
|
|
<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" onwheel="this.blur()"> |
|
|
</div> |
|
|
</div> |
|
|
|
|
|
|
|
|
<!-- 件数 --> |
|
|
<!-- 件数 --> |
|
|
<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="quantity" placeholder="请输入件数"> |
|
|
<input type="number" class="form-input" id="quantity" placeholder="请输入件数" onwheel="this.blur()"> |
|
|
</div> |
|
|
</div> |
|
|
|
|
|
|
|
|
<!-- 斤重 --> |
|
|
<!-- 斤重 --> |
|
|
@ -1480,13 +1480,13 @@ |
|
|
<!-- 价格 --> |
|
|
<!-- 价格 --> |
|
|
<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" onwheel="this.blur()"> |
|
|
</div> |
|
|
</div> |
|
|
|
|
|
|
|
|
<!-- 件数 --> |
|
|
<!-- 件数 --> |
|
|
<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="editQuantity" placeholder="请输入件数"> |
|
|
<input type="number" class="form-input" id="editQuantity" placeholder="请输入件数" onwheel="this.blur()"> |
|
|
</div> |
|
|
</div> |
|
|
|
|
|
|
|
|
<!-- 斤重 --> |
|
|
<!-- 斤重 --> |
|
|
@ -1777,6 +1777,7 @@ |
|
|
|
|
|
|
|
|
loadSupplies(); |
|
|
loadSupplies(); |
|
|
loadContacts(); |
|
|
loadContacts(); |
|
|
|
|
|
loadFormData(); // 加载保存的表单数据,包括联系人信息 |
|
|
bindEvents(); |
|
|
bindEvents(); |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
@ -2982,10 +2983,40 @@ |
|
|
// 确保contacts是一个数组 |
|
|
// 确保contacts是一个数组 |
|
|
contacts = result.data || []; |
|
|
contacts = result.data || []; |
|
|
console.log('联系人数据加载成功:', contacts); |
|
|
console.log('联系人数据加载成功:', contacts); |
|
|
|
|
|
|
|
|
|
|
|
// 保存到本地缓存,添加时间戳和版本号 |
|
|
|
|
|
const contactsCache = { |
|
|
|
|
|
data: contacts, |
|
|
|
|
|
version: '1.0', |
|
|
|
|
|
timestamp: Date.now() |
|
|
|
|
|
}; |
|
|
|
|
|
localStorage.setItem('contactsCache', JSON.stringify(contactsCache)); |
|
|
|
|
|
|
|
|
updateContactSelects(); |
|
|
updateContactSelects(); |
|
|
} catch (error) { |
|
|
} catch (error) { |
|
|
console.error('加载联系人数据失败:', error); |
|
|
console.error('加载联系人数据失败:', error); |
|
|
// 出错时将contacts设为空数组,避免后续错误 |
|
|
|
|
|
|
|
|
// 尝试从本地缓存加载 |
|
|
|
|
|
try { |
|
|
|
|
|
const cachedContacts = localStorage.getItem('contactsCache'); |
|
|
|
|
|
if (cachedContacts) { |
|
|
|
|
|
const contactsCache = JSON.parse(cachedContacts); |
|
|
|
|
|
// 检查缓存是否有效(7天内) |
|
|
|
|
|
const cacheExpiry = 7 * 24 * 60 * 60 * 1000; |
|
|
|
|
|
if (Date.now() - contactsCache.timestamp < cacheExpiry) { |
|
|
|
|
|
contacts = contactsCache.data || []; |
|
|
|
|
|
console.log('从本地缓存加载联系人数据:', contacts); |
|
|
|
|
|
updateContactSelects(); |
|
|
|
|
|
return; |
|
|
|
|
|
} else { |
|
|
|
|
|
console.log('联系人缓存已过期'); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} catch (cacheError) { |
|
|
|
|
|
console.error('加载联系人缓存失败:', cacheError); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 出错且无有效缓存时,将contacts设为空数组 |
|
|
contacts = []; |
|
|
contacts = []; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
@ -3803,6 +3834,138 @@ |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 加载表单数据 |
|
|
|
|
|
function loadFormData() { |
|
|
|
|
|
try { |
|
|
|
|
|
const savedData = localStorage.getItem('supplyFormDraft'); |
|
|
|
|
|
if (savedData) { |
|
|
|
|
|
const formData = JSON.parse(savedData); |
|
|
|
|
|
|
|
|
|
|
|
// 恢复联系人信息 |
|
|
|
|
|
if (formData.contactId) { |
|
|
|
|
|
const contactElement = document.getElementById('contactId'); |
|
|
|
|
|
const contactDisplayElement = document.getElementById('contactIdDisplayText'); |
|
|
|
|
|
if (contactElement && contactDisplayElement) { |
|
|
|
|
|
contactElement.value = formData.contactId; |
|
|
|
|
|
contactDisplayElement.textContent = formData.contactIdDisplay || '请选择联系人'; |
|
|
|
|
|
selectedContactId = formData.contactId; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 恢复商品名称 |
|
|
|
|
|
if (formData.productName) { |
|
|
|
|
|
const productNameElement = document.getElementById('productName'); |
|
|
|
|
|
const productNameDisplayElement = document.getElementById('productNameDisplayText'); |
|
|
|
|
|
if (productNameElement && productNameDisplayElement) { |
|
|
|
|
|
productNameElement.value = formData.productName; |
|
|
|
|
|
productNameDisplayElement.textContent = formData.productNameDisplay || '请选择商品名称'; |
|
|
|
|
|
selectedProductName = formData.selectedProductName || ''; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 恢复价格 |
|
|
|
|
|
if (formData.price) { |
|
|
|
|
|
const priceElement = document.getElementById('price'); |
|
|
|
|
|
if (priceElement) { |
|
|
|
|
|
priceElement.value = formData.price; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 恢复数量 |
|
|
|
|
|
if (formData.quantity) { |
|
|
|
|
|
const quantityElement = document.getElementById('quantity'); |
|
|
|
|
|
if (quantityElement) { |
|
|
|
|
|
quantityElement.value = formData.quantity; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 恢复蛋黄类型 |
|
|
|
|
|
if (formData.yolk) { |
|
|
|
|
|
const yolkElement = document.getElementById('yolk'); |
|
|
|
|
|
const yolkDisplayElement = document.getElementById('yolkDisplayText'); |
|
|
|
|
|
if (yolkElement && yolkDisplayElement) { |
|
|
|
|
|
yolkElement.value = formData.yolk; |
|
|
|
|
|
yolkDisplayElement.textContent = formData.yolkDisplay || '请选择蛋黄类型'; |
|
|
|
|
|
selectedYolk = formData.selectedYolk || ''; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 恢复规格 |
|
|
|
|
|
if (formData.specification) { |
|
|
|
|
|
const specValueElement = document.getElementById('specValue'); |
|
|
|
|
|
const specDisplayElement = document.getElementById('specDisplayText'); |
|
|
|
|
|
if (specValueElement && specDisplayElement) { |
|
|
|
|
|
specValueElement.value = formData.specification; |
|
|
|
|
|
specDisplayElement.textContent = formData.specificationDisplay || '请选择规格'; |
|
|
|
|
|
selectedSpec = formData.selectedSpec || ''; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 恢复货源状态 |
|
|
|
|
|
if (formData.supplyStatus) { |
|
|
|
|
|
const supplyStatusElement = document.getElementById('supplyStatus'); |
|
|
|
|
|
if (supplyStatusElement) { |
|
|
|
|
|
supplyStatusElement.value = formData.supplyStatus; |
|
|
|
|
|
setSupplyStatus(formData.supplyStatus); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 恢复货源类型 |
|
|
|
|
|
if (formData.sourceType) { |
|
|
|
|
|
const sourceTypeElement = document.getElementById('sourceType'); |
|
|
|
|
|
const sourceTypeDisplayElement = document.getElementById('sourceTypeDisplayText'); |
|
|
|
|
|
if (sourceTypeElement && sourceTypeDisplayElement) { |
|
|
|
|
|
sourceTypeElement.value = formData.sourceType; |
|
|
|
|
|
sourceTypeDisplayElement.textContent = formData.sourceTypeDisplay || '请选择货源类型'; |
|
|
|
|
|
selectedSourceType = formData.selectedSourceType || ''; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 恢复描述 |
|
|
|
|
|
if (formData.description) { |
|
|
|
|
|
const descriptionElement = document.getElementById('description'); |
|
|
|
|
|
if (descriptionElement) { |
|
|
|
|
|
descriptionElement.value = formData.description; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 恢复地区 |
|
|
|
|
|
if (formData.region) { |
|
|
|
|
|
const regionValueElement = document.getElementById('regionValue'); |
|
|
|
|
|
const regionDisplayElement = document.getElementById('regionDisplayText'); |
|
|
|
|
|
if (regionValueElement && regionDisplayElement) { |
|
|
|
|
|
regionValueElement.value = formData.region; |
|
|
|
|
|
regionDisplayElement.textContent = formData.regionDisplay || '请选择地区'; |
|
|
|
|
|
selectedProvince = formData.selectedProvince || ''; |
|
|
|
|
|
selectedCity = formData.selectedCity || ''; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 恢复种类 |
|
|
|
|
|
if (formData.category) { |
|
|
|
|
|
const categoryElement = document.getElementById('category'); |
|
|
|
|
|
const categoryDisplayElement = document.getElementById('categoryDisplayText'); |
|
|
|
|
|
if (categoryElement && categoryDisplayElement) { |
|
|
|
|
|
categoryElement.value = formData.category; |
|
|
|
|
|
categoryDisplayElement.textContent = formData.categoryDisplay || '请选择种类'; |
|
|
|
|
|
selectedCategory = formData.selectedCategory || ''; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 恢复图片 |
|
|
|
|
|
if (Array.isArray(formData.imageUrls)) { |
|
|
|
|
|
supplyData.uploadedImages = formData.imageUrls; |
|
|
|
|
|
renderUploadedImages(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
console.log('表单数据已从localStorage加载'); |
|
|
|
|
|
} |
|
|
|
|
|
} catch (e) { |
|
|
|
|
|
console.error('加载表单数据失败:', e); |
|
|
|
|
|
// 加载失败时不影响用户体验,静默处理错误 |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
// 创建货源 |
|
|
// 创建货源 |
|
|
// 防止重复提交的标志位 |
|
|
// 防止重复提交的标志位 |
|
|
let isSubmitting = false; |
|
|
let isSubmitting = false; |
|
|
@ -4280,23 +4443,8 @@ |
|
|
|
|
|
|
|
|
// 准备发布货源 |
|
|
// 准备发布货源 |
|
|
async function preparePublishSupply(id) { |
|
|
async function preparePublishSupply(id) { |
|
|
if (confirm('确定要上架该货源吗?上架后将进入审核流程。')) { |
|
|
// 点击上架按钮时,先进入编辑页面,并设置为上架模式 |
|
|
try { |
|
|
showEditSupply(id, true); |
|
|
const response = await fetch(`/api/supplies/${id}/publish`, { |
|
|
|
|
|
method: 'POST' |
|
|
|
|
|
}); |
|
|
|
|
|
const result = await response.json(); |
|
|
|
|
|
if (result.success) { |
|
|
|
|
|
alert('上架成功,已进入审核流程'); |
|
|
|
|
|
loadSupplies(); |
|
|
|
|
|
} else { |
|
|
|
|
|
alert('上架失败: ' + (result.message || '未知错误')); |
|
|
|
|
|
} |
|
|
|
|
|
} catch (error) { |
|
|
|
|
|
console.error('上架失败:', error); |
|
|
|
|
|
alert('上架失败: 网络错误'); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 显示审核失败原因 |
|
|
// 显示审核失败原因 |
|
|
@ -4331,7 +4479,7 @@ |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 显示编辑货源 |
|
|
// 显示编辑货源 |
|
|
async function showEditSupply(id) { |
|
|
async function showEditSupply(id, publishMode = false) { |
|
|
try { |
|
|
try { |
|
|
// 查找要编辑的货源,考虑类型转换 |
|
|
// 查找要编辑的货源,考虑类型转换 |
|
|
const supply = supplyData.supplies.find(s => String(s.id) === String(id)); |
|
|
const supply = supplyData.supplies.find(s => String(s.id) === String(id)); |
|
|
@ -4342,6 +4490,8 @@ |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
currentEditSupplyId = id; |
|
|
currentEditSupplyId = id; |
|
|
|
|
|
// 保存发布模式状态 |
|
|
|
|
|
window.currentEditPublishMode = publishMode; |
|
|
|
|
|
|
|
|
// 填充表单数据 |
|
|
// 填充表单数据 |
|
|
// 货源类型 |
|
|
// 货源类型 |
|
|
@ -4372,7 +4522,9 @@ |
|
|
setEditSupplyStatus(supplyStatus); |
|
|
setEditSupplyStatus(supplyStatus); |
|
|
|
|
|
|
|
|
// 分配联系人 |
|
|
// 分配联系人 |
|
|
document.getElementById('editContactIdDisplayText').textContent = supply.contactId || '请选择联系人'; |
|
|
// 显示联系人名称而不是ID |
|
|
|
|
|
const contactName = supply.product_contact || supply.contactId || '请选择联系人'; |
|
|
|
|
|
document.getElementById('editContactIdDisplayText').textContent = contactName; |
|
|
document.getElementById('editContactId').value = supply.contactId || ''; |
|
|
document.getElementById('editContactId').value = supply.contactId || ''; |
|
|
editSelectedContactId = supply.contactId || ''; |
|
|
editSelectedContactId = supply.contactId || ''; |
|
|
document.getElementById('editDescription').value = supply.description || ''; |
|
|
document.getElementById('editDescription').value = supply.description || ''; |
|
|
@ -4396,6 +4548,18 @@ |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 根据模式修改保存按钮文本 |
|
|
|
|
|
const saveButton = document.querySelector('#editSupplyModal .modal-btn-primary'); |
|
|
|
|
|
if (saveButton) { |
|
|
|
|
|
if (publishMode) { |
|
|
|
|
|
saveButton.textContent = '上架'; |
|
|
|
|
|
saveButton.onclick = publishSupplyAfterEdit; |
|
|
|
|
|
} else { |
|
|
|
|
|
saveButton.textContent = '保存'; |
|
|
|
|
|
saveButton.onclick = saveEditSupply; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
// 显示编辑模态框 |
|
|
// 显示编辑模态框 |
|
|
document.getElementById('editSupplyModal').style.display = 'flex'; |
|
|
document.getElementById('editSupplyModal').style.display = 'flex'; |
|
|
} catch (error) { |
|
|
} catch (error) { |
|
|
@ -4408,6 +4572,52 @@ |
|
|
function hideEditSupplyModal() { |
|
|
function hideEditSupplyModal() { |
|
|
document.getElementById('editSupplyModal').style.display = 'none'; |
|
|
document.getElementById('editSupplyModal').style.display = 'none'; |
|
|
currentEditSupplyId = null; |
|
|
currentEditSupplyId = null; |
|
|
|
|
|
// 重置发布模式状态 |
|
|
|
|
|
window.currentEditPublishMode = false; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 编辑后上架货源 |
|
|
|
|
|
async function publishSupplyAfterEdit() { |
|
|
|
|
|
try { |
|
|
|
|
|
// 先保存编辑的货源信息 |
|
|
|
|
|
const saveResult = await saveEditSupply(); |
|
|
|
|
|
if (saveResult) { |
|
|
|
|
|
// 保存成功后,上架货源 |
|
|
|
|
|
await publishSupply(currentEditSupplyId); |
|
|
|
|
|
// 关闭模态框 |
|
|
|
|
|
hideEditSupplyModal(); |
|
|
|
|
|
} |
|
|
|
|
|
} catch (error) { |
|
|
|
|
|
console.error('上架失败:', error); |
|
|
|
|
|
alert('上架失败: ' + (error.message || '未知错误')); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 上架货源 |
|
|
|
|
|
async function publishSupply(id) { |
|
|
|
|
|
if (!id) { |
|
|
|
|
|
alert('货源ID不存在'); |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
|
const response = await fetch(`/api/supplies/${id}/publish`, { |
|
|
|
|
|
method: 'POST' |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
const result = await response.json(); |
|
|
|
|
|
if (result.success) { |
|
|
|
|
|
alert('上架成功'); |
|
|
|
|
|
loadSupplies(); |
|
|
|
|
|
} else { |
|
|
|
|
|
alert('上架失败: ' + (result.message || '未知错误')); |
|
|
|
|
|
} |
|
|
|
|
|
return result.success; |
|
|
|
|
|
} catch (error) { |
|
|
|
|
|
console.error('上架失败:', error); |
|
|
|
|
|
alert('上架失败: ' + error.message); |
|
|
|
|
|
return false; |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 编辑规格选择功能 |
|
|
// 编辑规格选择功能 |
|
|
@ -5035,7 +5245,7 @@ |
|
|
async function saveEditSupply() { |
|
|
async function saveEditSupply() { |
|
|
if (!currentEditSupplyId) { |
|
|
if (!currentEditSupplyId) { |
|
|
alert('货源ID不存在'); |
|
|
alert('货源ID不存在'); |
|
|
return; |
|
|
return false; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
try { |
|
|
try { |
|
|
@ -5057,15 +5267,15 @@ |
|
|
// 验证表单 |
|
|
// 验证表单 |
|
|
if (!formData.productName) { |
|
|
if (!formData.productName) { |
|
|
alert('请选择商品名称'); |
|
|
alert('请选择商品名称'); |
|
|
return; |
|
|
return false; |
|
|
} |
|
|
} |
|
|
if (!formData.price) { |
|
|
if (!formData.price) { |
|
|
alert('请输入价格'); |
|
|
alert('请输入价格'); |
|
|
return; |
|
|
return false; |
|
|
} |
|
|
} |
|
|
if (!formData.quantity) { |
|
|
if (!formData.quantity) { |
|
|
alert('请输入件数'); |
|
|
alert('请输入件数'); |
|
|
return; |
|
|
return false; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
const response = await fetch(`/api/supplies/${currentEditSupplyId}/edit`, { |
|
|
const response = await fetch(`/api/supplies/${currentEditSupplyId}/edit`, { |
|
|
@ -5078,15 +5288,21 @@ |
|
|
|
|
|
|
|
|
const result = await response.json(); |
|
|
const result = await response.json(); |
|
|
if (result.success) { |
|
|
if (result.success) { |
|
|
alert('编辑成功'); |
|
|
// 如果是直接编辑,显示成功消息;如果是编辑后上架,不显示,由上架函数处理 |
|
|
hideEditSupplyModal(); |
|
|
if (!window.currentEditPublishMode) { |
|
|
loadSupplies(); |
|
|
alert('编辑成功'); |
|
|
|
|
|
hideEditSupplyModal(); |
|
|
|
|
|
loadSupplies(); |
|
|
|
|
|
} |
|
|
|
|
|
return true; |
|
|
} else { |
|
|
} else { |
|
|
alert('编辑失败: ' + (result.message || '未知错误')); |
|
|
alert('编辑失败: ' + (result.message || '未知错误')); |
|
|
|
|
|
return false; |
|
|
} |
|
|
} |
|
|
} catch (error) { |
|
|
} catch (error) { |
|
|
console.error('编辑失败:', error); |
|
|
console.error('编辑失败:', error); |
|
|
alert('编辑失败: 网络错误'); |
|
|
alert('编辑失败: 网络错误'); |
|
|
|
|
|
return false; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@ -5094,16 +5310,29 @@ |
|
|
function hideEditSupplyModal() { |
|
|
function hideEditSupplyModal() { |
|
|
document.getElementById('editSupplyModal').style.display = 'none'; |
|
|
document.getElementById('editSupplyModal').style.display = 'none'; |
|
|
currentEditSupplyId = null; |
|
|
currentEditSupplyId = null; |
|
|
|
|
|
// 重置发布模式状态 |
|
|
|
|
|
window.currentEditPublishMode = false; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 处理点击模态框外部关闭 |
|
|
// 处理点击模态框外部关闭 |
|
|
window.onclick = function(event) { |
|
|
window.onclick = function(event) { |
|
|
const modals = document.querySelectorAll('.modal'); |
|
|
// 确保只处理click事件,不处理拖拽选择文本导致的mouseup事件 |
|
|
modals.forEach(modal => { |
|
|
if (event.type === 'click') { |
|
|
if (event.target === modal) { |
|
|
const modals = document.querySelectorAll('.modal'); |
|
|
modal.style.display = 'none'; |
|
|
modals.forEach(modal => { |
|
|
} |
|
|
if (event.target === modal) { |
|
|
}); |
|
|
// 只在真正点击模态框背景时关闭,不在选择文本拖拽到外部时关闭 |
|
|
|
|
|
// 检查事件是否是通过点击触发的,而不是通过拖拽 |
|
|
|
|
|
if (!event.isTrusted) return; |
|
|
|
|
|
|
|
|
|
|
|
// 检查是否有正在进行的选择操作 |
|
|
|
|
|
const selection = window.getSelection(); |
|
|
|
|
|
if (selection && selection.toString()) return; |
|
|
|
|
|
|
|
|
|
|
|
modal.style.display = 'none'; |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
</script> |
|
|
</script> |
|
|
</body> |
|
|
</body> |
|
|
|