发货查询细节设计优化
This commit is contained in:
parent
402a83e651
commit
7abc508067
@ -533,3 +533,46 @@ input[type="date"]::-webkit-calendar-picker-indicator:hover{
|
||||
background-repeat: no-repeat;
|
||||
background-position: center;
|
||||
}
|
||||
|
||||
/* Table styles */
|
||||
.table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
background: var(--surface);
|
||||
border-radius: 8px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.table thead {
|
||||
background: var(--border);
|
||||
}
|
||||
|
||||
.table th {
|
||||
padding: 12px;
|
||||
text-align: left;
|
||||
font-weight: 600;
|
||||
color: var(--text);
|
||||
border-bottom: 2px solid var(--border);
|
||||
}
|
||||
|
||||
.table td {
|
||||
padding: 12px;
|
||||
border-bottom: 1px solid var(--border);
|
||||
color: var(--text);
|
||||
}
|
||||
|
||||
.table tbody tr:hover {
|
||||
background: var(--hover);
|
||||
}
|
||||
|
||||
.table tbody tr:last-child td {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
@media(max-width: 768px) {
|
||||
.table th,
|
||||
.table td {
|
||||
padding: 8px;
|
||||
font-size: 14px;
|
||||
}
|
||||
}
|
||||
|
||||
@ -52,10 +52,23 @@
|
||||
</div>
|
||||
<div class="nav-group">
|
||||
<div class="nav-group-title">查询</div>
|
||||
<a href="#/shipments/query" class="nav-item" data-route="shipments-query">
|
||||
<span class="icon">🔍</span>
|
||||
<span class="text">出货查询</span>
|
||||
</a>
|
||||
<div class="nav-item has-children" data-expand="query">
|
||||
<button class="nav-item-btn">
|
||||
<span class="icon">🔍</span>
|
||||
<span class="text">出货查询</span>
|
||||
<span class="caret">▸</span>
|
||||
</button>
|
||||
<div class="nav-children" data-parent="query">
|
||||
<a href="#/shipments/query" class="nav-child" data-route="shipments-query">
|
||||
<span class="child-icon">📋</span>
|
||||
<span>详细记录查询</span>
|
||||
</a>
|
||||
<a href="#/shipments/summary" class="nav-child" data-route="shipments-summary">
|
||||
<span class="child-icon">📊</span>
|
||||
<span>汇总信息查询</span>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="nav-group">
|
||||
<div class="nav-group-title">扩展采集</div>
|
||||
@ -159,6 +172,7 @@
|
||||
<script src="./js/components/upload.js"></script>
|
||||
<script src="./js/components/shipments.js"></script>
|
||||
<script src="./js/components/shipment-query.js"></script>
|
||||
<script src="./js/components/shipment-summary.js"></script>
|
||||
<script src="./js/components/defects.js"></script>
|
||||
<script src="./js/components/devices.js"></script>
|
||||
<script src="./js/components/environment.js"></script>
|
||||
|
||||
@ -83,8 +83,9 @@ const Router = (() => {
|
||||
stats: '良/不良统计',
|
||||
defects: '不良明细',
|
||||
repairs: '返修记录',
|
||||
shipments: '发货记录',
|
||||
query: '查询',
|
||||
shipments: '发货',
|
||||
query: '详细记录查询',
|
||||
summary: '汇总信息查询',
|
||||
devices: '设备状态',
|
||||
environment: '环境参数',
|
||||
personnel: '人员信息',
|
||||
|
||||
@ -1542,11 +1542,25 @@ def clear_module():
|
||||
table = tables.get(module)
|
||||
if not table:
|
||||
return jsonify({'error': 'invalid module'}), 400
|
||||
|
||||
# 清空 SQLite 表
|
||||
conn = get_db()
|
||||
c = conn.cursor()
|
||||
c.execute(f'DELETE FROM {table}')
|
||||
conn.commit()
|
||||
conn.close()
|
||||
|
||||
# 如果是清空发货记录,同时清空 Redis
|
||||
if module == 'shipments':
|
||||
try:
|
||||
r = get_redis()
|
||||
redis_key = 'shipment_sn_mapping'
|
||||
redis_count = r.hlen(redis_key)
|
||||
r.delete(redis_key)
|
||||
log('clear_module_redis', f'shipments: cleared {redis_count} records from redis')
|
||||
except Exception as e:
|
||||
log('clear_module_redis_error', str(e))
|
||||
|
||||
log('clear_module', module)
|
||||
return jsonify({'ok': True})
|
||||
|
||||
@ -1999,27 +2013,71 @@ def shipments_redis_stats():
|
||||
return jsonify({'error': f'获取统计失败:{str(e)}'}), 500
|
||||
|
||||
|
||||
@app.get('/api/shipments/summary')
|
||||
@require_login
|
||||
def shipments_summary():
|
||||
"""查询发货记录汇总信息(按日期范围)"""
|
||||
try:
|
||||
start_date = request.args.get('start')
|
||||
end_date = request.args.get('end')
|
||||
|
||||
if not start_date or not end_date:
|
||||
return jsonify({'error': '请提供开始和结束日期'}), 400
|
||||
|
||||
conn = get_db()
|
||||
c = conn.cursor()
|
||||
|
||||
# 查询指定日期范围内的发货记录
|
||||
c.execute('''
|
||||
SELECT date, qty, receiver, ts
|
||||
FROM shipments
|
||||
WHERE date >= ? AND date <= ?
|
||||
ORDER BY date DESC
|
||||
''', (start_date, end_date))
|
||||
|
||||
rows = [dict(r) for r in c.fetchall()]
|
||||
conn.close()
|
||||
|
||||
log('shipments_summary', f'start={start_date}, end={end_date}, count={len(rows)}')
|
||||
|
||||
return jsonify({
|
||||
'ok': True,
|
||||
'records': rows,
|
||||
'count': len(rows)
|
||||
})
|
||||
except Exception as e:
|
||||
log('shipments_summary_error', str(e))
|
||||
return jsonify({'error': f'查询失败:{str(e)}'}), 500
|
||||
|
||||
|
||||
@app.post('/api/shipments/clear-redis')
|
||||
@require_login
|
||||
@require_any_role('admin','superadmin')
|
||||
def clear_shipments_redis():
|
||||
"""清空 Redis 中的发货记录数据"""
|
||||
"""清空 Redis 和 SQLite 中的发货记录数据"""
|
||||
try:
|
||||
# 清空 Redis
|
||||
r = get_redis()
|
||||
redis_key = 'shipment_sn_mapping'
|
||||
|
||||
# 获取删除前的数量
|
||||
count_before = r.hlen(redis_key)
|
||||
|
||||
# 删除整个 Hash
|
||||
redis_count = r.hlen(redis_key)
|
||||
r.delete(redis_key)
|
||||
|
||||
log('clear_shipments_redis', f'cleared {count_before} records')
|
||||
# 同时清空 SQLite 中的 shipments 表
|
||||
conn = get_db()
|
||||
c = conn.cursor()
|
||||
c.execute('SELECT COUNT(*) as cnt FROM shipments')
|
||||
sqlite_count = c.fetchone()['cnt']
|
||||
c.execute('DELETE FROM shipments')
|
||||
conn.commit()
|
||||
conn.close()
|
||||
|
||||
log('clear_shipments_all', f'cleared redis={redis_count}, sqlite={sqlite_count}')
|
||||
|
||||
return jsonify({
|
||||
'ok': True,
|
||||
'message': f'已清空 {count_before} 条发货记录',
|
||||
'count': count_before
|
||||
'message': f'已清空 Redis {redis_count} 条记录和 SQLite {sqlite_count} 条记录',
|
||||
'redis_count': redis_count,
|
||||
'sqlite_count': sqlite_count
|
||||
})
|
||||
except Exception as e:
|
||||
log('clear_shipments_redis_error', str(e))
|
||||
|
||||
Loading…
Reference in New Issue
Block a user