完善查询逻辑
This commit is contained in:
126
static/js/app.js
126
static/js/app.js
@@ -656,7 +656,7 @@ function displayDifferences() {
|
||||
<pre class="field-value bg-light p-2 rounded mb-0 ${jsonClass}" style="max-height: 400px; overflow-y: auto; margin: 0;">${escapeHtml(diff.pro_value)}
|
||||
${escapeHtml(diff.test_value)}</pre>
|
||||
<button class="btn btn-sm btn-outline-secondary copy-btn"
|
||||
onclick="copyToClipboard('${escapeForJs(diff.pro_value)}\\n${escapeForJs(diff.test_value)}', this)"
|
||||
onclick="copyToClipboard('${escapeForJs(diff.pro_value)}\n${escapeForJs(diff.test_value)}', this)"
|
||||
title="复制全部内容">
|
||||
<i class="fas fa-copy"></i>
|
||||
</button>
|
||||
@@ -716,11 +716,11 @@ function displayIdenticalResults() {
|
||||
<div class="d-flex align-items-center">
|
||||
<label class="form-label me-2 mb-0">每页显示:</label>
|
||||
<select class="form-select form-select-sm me-2" style="width: auto;" onchange="changePageSize(this.value)">
|
||||
<option value="5" ${identicalPageSize == 5 ? 'selected' : ''}>5条</option>
|
||||
<option value="10" ${identicalPageSize == 10 ? 'selected' : ''}>10条</option>
|
||||
<option value="20" ${identicalPageSize == 20 ? 'selected' : ''}>20条</option>
|
||||
<option value="50" ${identicalPageSize == 50 ? 'selected' : ''}>50条</option>
|
||||
<option value="100" ${identicalPageSize == 100 ? 'selected' : ''}>100条</option>
|
||||
<option value="5" ${identicalPageSize == 10 ? 'selected' : ''}>10条</option>
|
||||
<option value="10" ${identicalPageSize == 50 ? 'selected' : ''}>50条</option>
|
||||
<option value="20" ${identicalPageSize == 100 ? 'selected' : ''}>100条</option>
|
||||
<option value="50" ${identicalPageSize == 200 ? 'selected' : ''}>200条</option>
|
||||
<option value="100" ${identicalPageSize == 500 ? 'selected' : ''}>500条</option>
|
||||
<option value="custom">自定义</option>
|
||||
</select>
|
||||
<input type="number" class="form-control form-control-sm me-2" style="width: 80px; display: none;"
|
||||
@@ -817,7 +817,7 @@ function displayIdenticalResults() {
|
||||
<pre class="field-value bg-light p-2 rounded mb-0" style="max-height: 400px; overflow-y: auto; margin: 0;">${escapeHtml(String(proValue))}
|
||||
${escapeHtml(String(testValue))}</pre>
|
||||
<button class="btn btn-sm btn-outline-secondary copy-btn"
|
||||
onclick="copyToClipboard('${escapeForJs(String(proValue))}\\n${escapeForJs(String(testValue))}', this)"
|
||||
onclick="copyToClipboard('${escapeForJs(String(proValue))}\n${escapeForJs(String(testValue))}', this)"
|
||||
title="复制全部内容">
|
||||
<i class="fas fa-copy"></i>
|
||||
</button>
|
||||
@@ -1171,127 +1171,59 @@ function escapeForJs(str) {
|
||||
.replace(/\0/g, '\\0'); // 空字符
|
||||
}
|
||||
|
||||
// 显示原生数据
|
||||
// 显示原生数据(简化测试版本)
|
||||
function showRawData(keyStr) {
|
||||
console.log('showRawData 调用,参数:', keyStr);
|
||||
console.log('showRawData 开始执行,参数:', keyStr);
|
||||
|
||||
// 添加基本检查
|
||||
if (!currentResults) {
|
||||
console.error('没有查询结果数据');
|
||||
showAlert('warning', '请先执行查询操作');
|
||||
alert('请先执行查询操作');
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
// 解析主键
|
||||
const key = JSON.parse(keyStr);
|
||||
const keyValue = Object.values(key)[0];
|
||||
console.log('开始解析 keyStr:', keyStr);
|
||||
|
||||
console.log('解析主键成功:', key, '键值:', keyValue);
|
||||
|
||||
// 查找对应的原生数据记录
|
||||
let proRecord = null;
|
||||
let testRecord = null;
|
||||
|
||||
if (currentResults.raw_pro_data && currentResults.raw_pro_data.length > 0) {
|
||||
proRecord = currentResults.raw_pro_data.find(record =>
|
||||
Object.values(record).includes(keyValue)
|
||||
);
|
||||
// 创建最简单的测试模态框
|
||||
const existingModal = document.getElementById('rawDataModal');
|
||||
if (existingModal) {
|
||||
existingModal.remove();
|
||||
}
|
||||
|
||||
if (currentResults.raw_test_data && currentResults.raw_test_data.length > 0) {
|
||||
testRecord = currentResults.raw_test_data.find(record =>
|
||||
Object.values(record).includes(keyValue)
|
||||
);
|
||||
}
|
||||
|
||||
console.log('查找记录结果 - 生产:', !!proRecord, '测试:', !!testRecord);
|
||||
|
||||
// 安全处理数据
|
||||
const proData = proRecord ? JSON.stringify(proRecord, null, 2) : '{}';
|
||||
const testData = testRecord ? JSON.stringify(testRecord, null, 2) : '{}';
|
||||
|
||||
// 创建重构后的简化模态框
|
||||
const modalHtml = `
|
||||
<div class="modal fade" id="rawDataModal" tabindex="-1" aria-hidden="true">
|
||||
<div class="modal-dialog modal-xl">
|
||||
// 创建基本模态框
|
||||
const modalHTML = `
|
||||
<div class="modal fade" id="rawDataModal" tabindex="-1">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title">
|
||||
<i class="fas fa-database"></i> 原生数据查看 - ${escapeHtml(String(keyValue))}
|
||||
</h5>
|
||||
<h5 class="modal-title">原生数据测试</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="row mb-3">
|
||||
<div class="col-12">
|
||||
<div class="d-flex justify-content-between align-items-center">
|
||||
<div>
|
||||
<span class="badge bg-primary me-2"><i class="fas fa-server"></i> 生产环境: ${proRecord ? Object.keys(proRecord).length : 0} 字段</span>
|
||||
<span class="badge bg-info"><i class="fas fa-flask"></i> 测试环境: ${testRecord ? Object.keys(testRecord).length : 0} 字段</span>
|
||||
</div>
|
||||
<button class="btn btn-sm btn-outline-primary" onclick="copyRawData()" title="复制全部数据">
|
||||
<i class="fas fa-copy"></i> 复制数据
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="card">
|
||||
<div class="card-header bg-light">
|
||||
<h6 class="mb-0"><i class="fas fa-code"></i> 原生数据内容</h6>
|
||||
</div>
|
||||
<div class="card-body p-0">
|
||||
<div class="border-0 bg-light" style="max-height: 500px; overflow-y: auto;">
|
||||
<pre id="rawDataContent" class="mb-0 p-3" style="white-space: pre-wrap; font-size: 0.9em; line-height: 1.4;"></pre>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<p>测试模态框显示成功!</p>
|
||||
<pre id="testContent">测试内容</pre>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">
|
||||
<i class="fas fa-times"></i> 关闭
|
||||
</button>
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">关闭</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
|
||||
// 移除现有模态框
|
||||
const existingModal = document.getElementById('rawDataModal');
|
||||
if (existingModal) {
|
||||
existingModal.remove();
|
||||
}
|
||||
|
||||
// 添加新模态框
|
||||
document.body.insertAdjacentHTML('beforeend', modalHtml);
|
||||
|
||||
// 设置预格式化内容,避免模板字符串中的转义问题
|
||||
const rawDataContent = document.getElementById('rawDataContent');
|
||||
if (rawDataContent) {
|
||||
rawDataContent.textContent = proData + '\n\n' + testData;
|
||||
}
|
||||
|
||||
// 存储数据用于复制功能
|
||||
window.currentRawData = {
|
||||
pro: proData,
|
||||
test: testData,
|
||||
combined: proData + '\n\n' + testData
|
||||
};
|
||||
document.body.insertAdjacentHTML('beforeend', modalHTML);
|
||||
|
||||
// 显示模态框
|
||||
const modal = new bootstrap.Modal(document.getElementById('rawDataModal'));
|
||||
modal.show();
|
||||
|
||||
console.log('重构后的原生数据模态框已显示');
|
||||
console.log('测试模态框显示成功');
|
||||
|
||||
} catch (error) {
|
||||
console.error('显示原生数据失败:', error);
|
||||
showAlert('danger', '显示原生数据失败: ' + error.message);
|
||||
console.error('showRawData 执行失败:', error);
|
||||
console.error('错误堆栈:', error.stack);
|
||||
alert('错误: ' + error.message);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user