fix(query-tool): export all selected CIDs instead of single, fix hold detail float precision
Export was sending only one container_id while the detail table loaded data for all selected CIDs (including subtree), causing "查無資料" errors. Now sends container_ids array and uses batch service functions. Also rounds hold detail age KPI cards to 1 decimal place. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -17,7 +17,8 @@ function formatAge(value) {
|
|||||||
if (value === null || value === undefined || value === '-') {
|
if (value === null || value === undefined || value === '-') {
|
||||||
return '-';
|
return '-';
|
||||||
}
|
}
|
||||||
return `${value}天`;
|
const num = Number(value);
|
||||||
|
return `${Number.isFinite(num) ? num.toFixed(1) : value}天`;
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -378,9 +378,9 @@ export function useLotDetail(initial = {}) {
|
|||||||
async function exportSubTab(tab) {
|
async function exportSubTab(tab) {
|
||||||
const normalized = normalizeSubTab(tab);
|
const normalized = normalizeSubTab(tab);
|
||||||
const exportType = EXPORT_TYPE_MAP[normalized];
|
const exportType = EXPORT_TYPE_MAP[normalized];
|
||||||
const containerId = selectedContainerId.value;
|
const cids = getActiveCids();
|
||||||
|
|
||||||
if (!exportType || !containerId) {
|
if (!exportType || cids.length === 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -389,7 +389,7 @@ export function useLotDetail(initial = {}) {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const params = {
|
const params = {
|
||||||
container_id: containerId,
|
container_ids: cids,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (normalized === 'jobs') {
|
if (normalized === 'jobs') {
|
||||||
|
|||||||
@@ -40,6 +40,15 @@ from mes_dashboard.services.query_tool_service import (
|
|||||||
validate_equipment_input,
|
validate_equipment_input,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def _resolve_export_cids(params: dict) -> list[str]:
|
||||||
|
"""Extract container_ids from export params, supporting both batch and single."""
|
||||||
|
cids = params.get('container_ids') or []
|
||||||
|
if isinstance(cids, list) and cids:
|
||||||
|
return [c for c in cids if c]
|
||||||
|
single = params.get('container_id')
|
||||||
|
return [single] if single else []
|
||||||
|
|
||||||
# Create Blueprint
|
# Create Blueprint
|
||||||
query_tool_bp = Blueprint('query_tool', __name__)
|
query_tool_bp = Blueprint('query_tool', __name__)
|
||||||
|
|
||||||
@@ -605,11 +614,14 @@ def export_csv():
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
if export_type == 'lot_history':
|
if export_type == 'lot_history':
|
||||||
container_id = params.get('container_id')
|
cids = _resolve_export_cids(params)
|
||||||
if not container_id:
|
if not cids:
|
||||||
return jsonify({'error': '請指定 CONTAINERID'}), 400
|
return jsonify({'error': '請指定 CONTAINERID'}), 400
|
||||||
result = get_lot_history(container_id)
|
if len(cids) > 1:
|
||||||
filename = f'lot_history_{container_id}.csv'
|
result = get_lot_history_batch(cids)
|
||||||
|
else:
|
||||||
|
result = get_lot_history(cids[0])
|
||||||
|
filename = f'lot_history_{cids[0]}.csv'
|
||||||
|
|
||||||
elif export_type == 'adjacent_lots':
|
elif export_type == 'adjacent_lots':
|
||||||
result = get_adjacent_lots(
|
result = get_adjacent_lots(
|
||||||
@@ -620,19 +632,34 @@ def export_csv():
|
|||||||
filename = 'adjacent_lots.csv'
|
filename = 'adjacent_lots.csv'
|
||||||
|
|
||||||
elif export_type == 'lot_materials':
|
elif export_type == 'lot_materials':
|
||||||
container_id = params.get('container_id')
|
cids = _resolve_export_cids(params)
|
||||||
result = get_lot_materials(container_id)
|
if not cids:
|
||||||
filename = f'lot_raw_materials_{container_id}.csv'
|
return jsonify({'error': '請指定 CONTAINERID'}), 400
|
||||||
|
if len(cids) > 1:
|
||||||
|
result = get_lot_associations_batch(cids, 'materials')
|
||||||
|
else:
|
||||||
|
result = get_lot_materials(cids[0])
|
||||||
|
filename = f'lot_raw_materials_{cids[0]}.csv'
|
||||||
|
|
||||||
elif export_type == 'lot_rejects':
|
elif export_type == 'lot_rejects':
|
||||||
container_id = params.get('container_id')
|
cids = _resolve_export_cids(params)
|
||||||
result = get_lot_rejects(container_id)
|
if not cids:
|
||||||
filename = f'lot_rejects_{container_id}.csv'
|
return jsonify({'error': '請指定 CONTAINERID'}), 400
|
||||||
|
if len(cids) > 1:
|
||||||
|
result = get_lot_associations_batch(cids, 'rejects')
|
||||||
|
else:
|
||||||
|
result = get_lot_rejects(cids[0])
|
||||||
|
filename = f'lot_rejects_{cids[0]}.csv'
|
||||||
|
|
||||||
elif export_type == 'lot_holds':
|
elif export_type == 'lot_holds':
|
||||||
container_id = params.get('container_id')
|
cids = _resolve_export_cids(params)
|
||||||
result = get_lot_holds(container_id)
|
if not cids:
|
||||||
filename = f'lot_holds_{container_id}.csv'
|
return jsonify({'error': '請指定 CONTAINERID'}), 400
|
||||||
|
if len(cids) > 1:
|
||||||
|
result = get_lot_associations_batch(cids, 'holds')
|
||||||
|
else:
|
||||||
|
result = get_lot_holds(cids[0])
|
||||||
|
filename = f'lot_holds_{cids[0]}.csv'
|
||||||
|
|
||||||
elif export_type == 'lot_splits':
|
elif export_type == 'lot_splits':
|
||||||
container_id = params.get('container_id')
|
container_id = params.get('container_id')
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user