feat: 智能添加根据类别参数字段配置解析 - 支持子类别额外字段
This commit is contained in:
@@ -330,12 +330,20 @@
|
||||
<div id="smartAddModal" class="fixed inset-0 bg-black/50 z-50 hidden flex items-center justify-center">
|
||||
<div class="bg-white rounded-xl max-w-4xl w-full mx-4 max-h-[90vh] overflow-auto">
|
||||
<div class="p-6 border-b flex justify-between items-center sticky top-0 bg-white z-10">
|
||||
<h2 class="text-xl font-bold text-gray-800"><i class="ri-magic-line mr-2 text-orange-600"></i>智能添加(支持多图解析)</h2>
|
||||
<h2 class="text-xl font-bold text-gray-800"><i class="ri-magic-line mr-2 text-orange-600"></i>智能添加(根据参数字段解析)</h2>
|
||||
<button onclick="closeSmartAddModal()" class="text-gray-400 hover:text-gray-600"><i class="ri-close-line text-2xl"></i></button>
|
||||
</div>
|
||||
<div class="p-6">
|
||||
<!-- 子类别选择 -->
|
||||
<div class="mb-4" id="smartAddSubcategoryArea">
|
||||
<label class="text-sm text-gray-600 mb-2 block">选择子类别(可选,用于匹配特定参数字段)</label>
|
||||
<select id="smartAddSubcategory" class="w-full px-3 py-2 border rounded-lg">
|
||||
<option value="">请选择子类别</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="mb-6">
|
||||
<p class="text-sm text-gray-500 mb-3">上传产品图片,AI将自动识别并解析参数。支持一次上传多张图片,可识别多个产品。</p>
|
||||
<p class="text-sm text-gray-500 mb-3">上传产品图片,AI将根据类别参数字段配置自动识别并解析参数。支持一次上传多张图片,可识别多个产品。</p>
|
||||
<div class="flex flex-wrap gap-3 mb-3" id="smartImagePreviewArea">
|
||||
<!-- 图片预览区 -->
|
||||
</div>
|
||||
@@ -1905,9 +1913,37 @@
|
||||
document.getElementById('smartAddPreview').classList.add('hidden');
|
||||
document.getElementById('smartImagePreviewArea').innerHTML = '';
|
||||
document.getElementById('smartImageCount').textContent = '0';
|
||||
|
||||
// 加载子类别选项
|
||||
loadSmartAddSubcategories(type);
|
||||
|
||||
document.getElementById('smartAddModal').classList.remove('hidden');
|
||||
}
|
||||
|
||||
// 加载智能添加的子类别选项
|
||||
function loadSmartAddSubcategories(type) {
|
||||
const select = document.getElementById('smartAddSubcategory');
|
||||
let categoryId;
|
||||
|
||||
if (type === 'model') categoryId = 'ai-models';
|
||||
else if (type === 'gpu') categoryId = 'gpus';
|
||||
else if (type === 'cpu') categoryId = 'cpus';
|
||||
else if (type === 'dynamic') categoryId = dynamicCategoryId;
|
||||
else categoryId = null;
|
||||
|
||||
const cat = categories.find(c => c.id === categoryId);
|
||||
const subcats = cat ? (cat.subcategories || []) : [];
|
||||
|
||||
if (subcats.length > 0) {
|
||||
document.getElementById('smartAddSubcategoryArea').classList.remove('hidden');
|
||||
select.innerHTML = '<option value="">请选择子类别</option>' +
|
||||
subcats.map(s => `<option value="${s.id}">${s.name}</option>`).join('');
|
||||
} else {
|
||||
document.getElementById('smartAddSubcategoryArea').classList.add('hidden');
|
||||
select.innerHTML = '<option value="">请选择子类别</option>';
|
||||
}
|
||||
}
|
||||
|
||||
function closeSmartAddModal() {
|
||||
document.getElementById('smartAddModal').classList.add('hidden');
|
||||
}
|
||||
@@ -2018,6 +2054,7 @@
|
||||
// 预览解析结果
|
||||
async function previewSmartParse() {
|
||||
const text = document.getElementById('smartAddText').value.trim();
|
||||
const subcategoryId = document.getElementById('smartAddSubcategory').value;
|
||||
|
||||
if (!text && smartAddImages.length === 0) {
|
||||
alert('请上传图片或输入文本');
|
||||
@@ -2035,7 +2072,8 @@
|
||||
body: JSON.stringify({
|
||||
text: text,
|
||||
images: smartAddImages,
|
||||
category_type: smartAddType
|
||||
category_type: smartAddType,
|
||||
subcategory_id: subcategoryId
|
||||
})
|
||||
});
|
||||
|
||||
@@ -2074,6 +2112,7 @@
|
||||
|
||||
async function smartAddSubmit() {
|
||||
const text = document.getElementById('smartAddText').value.trim();
|
||||
const subcategoryId = document.getElementById('smartAddSubcategory').value;
|
||||
|
||||
if (!text && smartAddImages.length === 0) {
|
||||
alert('请上传图片或输入文本');
|
||||
@@ -2096,6 +2135,8 @@
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({
|
||||
text: text,
|
||||
images: smartAddImages,
|
||||
subcategory_id: subcategoryId
|
||||
images: smartAddImages
|
||||
})
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user