|
|
@@ -120,6 +120,25 @@
|
|
|
</div>
|
|
|
</div>
|
|
|
|
|
|
+<!-- Import Modal -->
|
|
|
+<div id="import-modal" class="fixed inset-0 z-50 hidden">
|
|
|
+ <div class="absolute inset-0 bg-black/60 backdrop-blur-sm" onclick="closeImportModal()"></div>
|
|
|
+ <div class="absolute top-1/2 left-1/2 transform -translate-x-1/2 -translate-y-1/2 bg-gray-800 rounded-xl shadow-2xl border border-gray-700 w-[480px] p-6 animate-fade-in-up">
|
|
|
+ <h3 class="text-xl font-bold text-white mb-1">数据入库</h3>
|
|
|
+ <p class="text-sm text-gray-400 mb-4" id="import-item-title"></p>
|
|
|
+ <label class="text-sm text-gray-300 mb-1 block">选择知识库</label>
|
|
|
+ <select id="import-kb-select" class="w-full bg-gray-700 text-white rounded p-2 border border-gray-600 focus:outline-none focus:border-blue-500 mb-4">
|
|
|
+ <option value="">加载中...</option>
|
|
|
+ </select>
|
|
|
+ <div class="flex justify-end gap-3">
|
|
|
+ <button onclick="closeImportModal()" class="px-4 py-2 rounded text-gray-400 hover:text-white hover:bg-gray-700 transition-colors">取消</button>
|
|
|
+ <button id="import-submit-btn" class="px-4 py-2 rounded bg-green-600 text-white hover:bg-green-700 transition-colors shadow-lg">
|
|
|
+ <i class="fas fa-upload"></i> 提交入库
|
|
|
+ </button>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+</div>
|
|
|
+
|
|
|
<script>
|
|
|
let currentPage = 1;
|
|
|
let currentKeyword = '';
|
|
|
@@ -210,6 +229,9 @@
|
|
|
<button onclick="viewDeepItem(${item.id})" class="text-blue-400 hover:text-blue-300 p-1" title="查看详情">
|
|
|
<i class="fas fa-eye"></i>
|
|
|
</button>
|
|
|
+ <button onclick="openImportModal(${item.id})" class="text-green-400 hover:text-green-300 p-1" title="入库">
|
|
|
+ <i class="fas fa-upload"></i>
|
|
|
+ </button>
|
|
|
<button onclick="deleteItem(${item.id})" class="text-red-400 hover:text-red-300 p-1" title="删除">
|
|
|
<i class="fas fa-trash-alt"></i>
|
|
|
</button>
|
|
|
@@ -349,5 +371,79 @@
|
|
|
if (confirmCallback) confirmCallback();
|
|
|
closeConfirm();
|
|
|
});
|
|
|
+
|
|
|
+ // --- Import Modal ---
|
|
|
+ let currentImportId = null;
|
|
|
+
|
|
|
+ function openImportModal(id) {
|
|
|
+ currentImportId = id;
|
|
|
+ // 获取当前行标题
|
|
|
+ const row = $(`.row-checkbox[value="${id}"]`).closest('tr');
|
|
|
+ const title = row.find('a[title]').attr('title') || `ID: ${id}`;
|
|
|
+ $('#import-item-title').text(title);
|
|
|
+
|
|
|
+ // 加载知识库列表
|
|
|
+ const select = $('#import-kb-select');
|
|
|
+ select.html('<option value="">加载中...</option>');
|
|
|
+
|
|
|
+ $.get('/deep/api/knowledge-bases', function(response) {
|
|
|
+ select.empty();
|
|
|
+ const items = response.items || response.data?.items || [];
|
|
|
+ if (items.length === 0) {
|
|
|
+ select.html('<option value="">暂无知识库</option>');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ items.forEach(kb => {
|
|
|
+ select.append(`<option value="${kb.id}">${kb.name}</option>`);
|
|
|
+ });
|
|
|
+ }).fail(function() {
|
|
|
+ select.html('<option value="">加载失败</option>');
|
|
|
+ showToast('知识库列表加载失败', 'error');
|
|
|
+ });
|
|
|
+
|
|
|
+ $('#import-modal').removeClass('hidden');
|
|
|
+ }
|
|
|
+
|
|
|
+ function closeImportModal() {
|
|
|
+ $('#import-modal').addClass('hidden');
|
|
|
+ currentImportId = null;
|
|
|
+ }
|
|
|
+
|
|
|
+ $('#import-submit-btn').click(function() {
|
|
|
+ const kbId = $('#import-kb-select').val();
|
|
|
+ const kbName = $('#import-kb-select option:selected').text();
|
|
|
+
|
|
|
+ if (!kbId) {
|
|
|
+ showToast('请选择知识库', 'info');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ $(this).prop('disabled', true).html('<i class="fas fa-spinner fa-spin"></i> 提交中...');
|
|
|
+
|
|
|
+ $.ajax({
|
|
|
+ url: '/deep/api/import',
|
|
|
+ type: 'POST',
|
|
|
+ contentType: 'application/json',
|
|
|
+ data: JSON.stringify({
|
|
|
+ deep_id: currentImportId,
|
|
|
+ kb_id: kbId,
|
|
|
+ kb_name: kbName,
|
|
|
+ }),
|
|
|
+ success: function(response) {
|
|
|
+ closeImportModal();
|
|
|
+ if (response.code === '000000') {
|
|
|
+ showToast('入库任务已提交,请在样本中心查看进度', 'success');
|
|
|
+ } else {
|
|
|
+ showToast('入库失败: ' + (response.message || '未知错误'), 'error');
|
|
|
+ }
|
|
|
+ },
|
|
|
+ error: function() {
|
|
|
+ showToast('入库请求失败', 'error');
|
|
|
+ },
|
|
|
+ complete: function() {
|
|
|
+ $('#import-submit-btn').prop('disabled', false).html('<i class="fas fa-upload"></i> 提交入库');
|
|
|
+ }
|
|
|
+ });
|
|
|
+ });
|
|
|
</script>
|
|
|
{% endblock %}
|