专长:增强 AI 设置和搜索功能
- 更新了 AI 设置页面,统一了 AI 补充、自然语言搜索、入站预处理和标签标准化的配置。 - 在编辑页面新增了 AI 标签和笔记标准化板块,包括建议预览及应用功能。 - 改进的搜索页面,支持带有示例的自然语言查询和模糊选择下拉菜单。 - 增强的搜索结果显示,包含更多匹配信息和查看 AI 搜索过程的模态。 - 更新新组件样式,优化布局以提升用户体验。
This commit is contained in:
@@ -36,15 +36,15 @@
|
||||
<input type="hidden" name="q" value="{{ search_query or '' }}">
|
||||
<label>
|
||||
料号 *
|
||||
<input type="text" name="part_no" required value="{{ component.part_no if component else '' }}" aria-label="料号" placeholder="如 STM32F103C8T6">
|
||||
<input id="part-no-input" type="text" name="part_no" required value="{{ component.part_no if component else '' }}" aria-label="料号" placeholder="如 STM32F103C8T6">
|
||||
</label>
|
||||
<label>
|
||||
名称 *
|
||||
<input type="text" name="name" required value="{{ component.name if component else '' }}" aria-label="名称" placeholder="如 MCU STM32F103C8T6">
|
||||
<input id="name-input" type="text" name="name" required value="{{ component.name if component else '' }}" aria-label="名称" placeholder="如 MCU STM32F103C8T6">
|
||||
</label>
|
||||
<label>
|
||||
规格
|
||||
<input type="text" name="specification" value="{{ component.specification if component else '' }}" placeholder="如 Cortex-M3 / LQFP-48">
|
||||
<input id="specification-input" type="text" name="specification" value="{{ component.specification if component else '' }}" placeholder="如 Cortex-M3 / LQFP-48">
|
||||
</label>
|
||||
<label>
|
||||
数量
|
||||
@@ -52,7 +52,7 @@
|
||||
</label>
|
||||
<label class="full">
|
||||
备注
|
||||
<textarea name="note" rows="3" placeholder="如 LCSC item 9243">{{ component.note if component else '' }}</textarea>
|
||||
<textarea id="note-input" name="note" rows="3" placeholder="如 LCSC item 9243">{{ component.note if component else '' }}</textarea>
|
||||
</label>
|
||||
<label class="full">
|
||||
<input type="checkbox" name="confirm_merge" value="1">
|
||||
@@ -82,6 +82,42 @@
|
||||
</section>
|
||||
|
||||
<aside class="entry-sidebar">
|
||||
<section class="panel quick-inbound-panel">
|
||||
<h2>AI 标签与备注标准化</h2>
|
||||
<p class="hint">生成更适合标签打印的短名称,并自动补全统一搜索关键词。确认后再回填到表单。</p>
|
||||
<p class="hint" id="standardize-status" aria-live="polite"></p>
|
||||
<section class="ai-standardize-preview" id="standardize-preview" hidden>
|
||||
<div class="standardize-grid">
|
||||
<div>
|
||||
<strong>短标签</strong>
|
||||
<p id="standardize-short-label">-</p>
|
||||
</div>
|
||||
<div>
|
||||
<strong>建议名称</strong>
|
||||
<p id="standardize-name">-</p>
|
||||
</div>
|
||||
<div>
|
||||
<strong>建议规格</strong>
|
||||
<p id="standardize-specification">-</p>
|
||||
</div>
|
||||
<div class="full">
|
||||
<strong>建议备注</strong>
|
||||
<p id="standardize-note">-</p>
|
||||
</div>
|
||||
<div class="full">
|
||||
<strong>搜索关键词</strong>
|
||||
<div class="match-tags" id="standardize-keywords"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="actions">
|
||||
<button class="btn" type="button" id="apply-standardization-btn">应用到表单</button>
|
||||
</div>
|
||||
</section>
|
||||
<div class="actions">
|
||||
<button class="btn btn-light" type="button" id="generate-standardization-btn">生成标准化建议</button>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="panel quick-inbound-panel">
|
||||
<h2>立创编号入库</h2>
|
||||
<p class="hint">当前编辑位置: {{ slot_code }}。仅支持粘贴立创商品详情页链接,系统会自动提取 itemId 并查询。</p>
|
||||
@@ -126,5 +162,104 @@
|
||||
</aside>
|
||||
</div>
|
||||
</main>
|
||||
<script>
|
||||
(function () {
|
||||
var partNoInput = document.getElementById('part-no-input');
|
||||
var nameInput = document.getElementById('name-input');
|
||||
var specificationInput = document.getElementById('specification-input');
|
||||
var noteInput = document.getElementById('note-input');
|
||||
var generateBtn = document.getElementById('generate-standardization-btn');
|
||||
var applyBtn = document.getElementById('apply-standardization-btn');
|
||||
var status = document.getElementById('standardize-status');
|
||||
var preview = document.getElementById('standardize-preview');
|
||||
var shortLabelNode = document.getElementById('standardize-short-label');
|
||||
var nameNode = document.getElementById('standardize-name');
|
||||
var specificationNode = document.getElementById('standardize-specification');
|
||||
var noteNode = document.getElementById('standardize-note');
|
||||
var keywordNode = document.getElementById('standardize-keywords');
|
||||
var latestSuggestion = null;
|
||||
|
||||
if (!partNoInput || !nameInput || !specificationInput || !noteInput || !generateBtn || !applyBtn || !status || !preview) {
|
||||
return;
|
||||
}
|
||||
|
||||
function escapeHtml(text) {
|
||||
return String(text || '')
|
||||
.replace(/&/g, '&')
|
||||
.replace(/</g, '<')
|
||||
.replace(/>/g, '>')
|
||||
.replace(/"/g, '"')
|
||||
.replace(/'/g, ''');
|
||||
}
|
||||
|
||||
function renderSuggestion(suggestion) {
|
||||
latestSuggestion = suggestion;
|
||||
preview.hidden = false;
|
||||
shortLabelNode.textContent = suggestion.short_label || '-';
|
||||
nameNode.textContent = suggestion.name || '-';
|
||||
specificationNode.textContent = suggestion.specification || '-';
|
||||
noteNode.textContent = suggestion.note || '-';
|
||||
keywordNode.innerHTML = (suggestion.keywords || []).map(function (keyword) {
|
||||
return '<span class="tag">' + escapeHtml(keyword) + '</span>';
|
||||
}).join('') || '<span class="tag">-</span>';
|
||||
}
|
||||
|
||||
generateBtn.addEventListener('click', function () {
|
||||
if (!partNoInput.value.trim() && !nameInput.value.trim()) {
|
||||
status.textContent = '请先填写料号或名称';
|
||||
return;
|
||||
}
|
||||
|
||||
generateBtn.disabled = true;
|
||||
status.textContent = '正在生成标准化建议...';
|
||||
|
||||
var payload = new URLSearchParams();
|
||||
payload.set('part_no', partNoInput.value || '');
|
||||
payload.set('name', nameInput.value || '');
|
||||
payload.set('specification', specificationInput.value || '');
|
||||
payload.set('note', noteInput.value || '');
|
||||
|
||||
fetch('{{ url_for('ai_component_standardize') }}', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8'
|
||||
},
|
||||
body: payload.toString()
|
||||
}).then(function (resp) {
|
||||
return resp.json().then(function (data) {
|
||||
if (!resp.ok || !data.ok) {
|
||||
throw new Error(data.message || '生成失败');
|
||||
}
|
||||
return data;
|
||||
});
|
||||
}).then(function (data) {
|
||||
renderSuggestion(data.suggestion || {});
|
||||
status.textContent = data.parse_notice || '标准化建议已生成,可先预览再应用';
|
||||
}).catch(function (error) {
|
||||
status.textContent = '生成失败: ' + error.message;
|
||||
}).finally(function () {
|
||||
generateBtn.disabled = false;
|
||||
});
|
||||
});
|
||||
|
||||
applyBtn.addEventListener('click', function () {
|
||||
if (!latestSuggestion) {
|
||||
status.textContent = '请先生成标准化建议';
|
||||
return;
|
||||
}
|
||||
|
||||
if (latestSuggestion.name) {
|
||||
nameInput.value = latestSuggestion.name;
|
||||
}
|
||||
if (latestSuggestion.specification) {
|
||||
specificationInput.value = latestSuggestion.specification;
|
||||
}
|
||||
if (latestSuggestion.note) {
|
||||
noteInput.value = latestSuggestion.note;
|
||||
}
|
||||
status.textContent = '建议已回填到表单,确认无误后再保存';
|
||||
});
|
||||
})();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user