fix(query-tool): finalize raw-material tab/export and resolve ORA-00918
This commit is contained in:
@@ -16,9 +16,52 @@ const props = defineProps({
|
||||
type: String,
|
||||
default: '無資料',
|
||||
},
|
||||
hiddenColumns: {
|
||||
type: Array,
|
||||
default: () => [],
|
||||
},
|
||||
columnLabels: {
|
||||
type: Object,
|
||||
default: () => ({}),
|
||||
},
|
||||
columnOrder: {
|
||||
type: Array,
|
||||
default: () => [],
|
||||
},
|
||||
});
|
||||
|
||||
const columns = computed(() => Object.keys(props.rows[0] || {}));
|
||||
const columns = computed(() => {
|
||||
const baseColumns = Object.keys(props.rows[0] || {});
|
||||
if (baseColumns.length === 0) {
|
||||
return [];
|
||||
}
|
||||
|
||||
const hidden = new Set((props.hiddenColumns || []).map((value) => String(value)));
|
||||
const visible = baseColumns.filter((column) => !hidden.has(column));
|
||||
|
||||
if (!Array.isArray(props.columnOrder) || props.columnOrder.length === 0) {
|
||||
return visible;
|
||||
}
|
||||
|
||||
const ordered = [];
|
||||
const seen = new Set();
|
||||
props.columnOrder.forEach((column) => {
|
||||
if (visible.includes(column) && !seen.has(column)) {
|
||||
ordered.push(column);
|
||||
seen.add(column);
|
||||
}
|
||||
});
|
||||
visible.forEach((column) => {
|
||||
if (!seen.has(column)) {
|
||||
ordered.push(column);
|
||||
}
|
||||
});
|
||||
return ordered;
|
||||
});
|
||||
|
||||
function resolveColumnLabel(column) {
|
||||
return props.columnLabels?.[column] || column;
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -40,7 +83,7 @@ const columns = computed(() => Object.keys(props.rows[0] || {}));
|
||||
:key="column"
|
||||
class="whitespace-nowrap border-b border-stroke-soft px-2 py-1.5 text-left font-semibold"
|
||||
>
|
||||
{{ column }}
|
||||
{{ resolveColumnLabel(column) }}
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
@@ -69,7 +69,7 @@ const emit = defineEmits(['change-sub-tab', 'update-workcenter-groups', 'export-
|
||||
|
||||
const tabMeta = Object.freeze({
|
||||
history: { label: '歷程', emptyText: '無歷程資料' },
|
||||
materials: { label: '物料', emptyText: '無物料資料' },
|
||||
materials: { label: '原物料', emptyText: '無原物料資料' },
|
||||
rejects: { label: '報廢', emptyText: '無報廢資料' },
|
||||
holds: { label: 'Hold', emptyText: '無 Hold 資料' },
|
||||
jobs: { label: 'Job', emptyText: '無 Job 資料' },
|
||||
@@ -104,6 +104,39 @@ const activeEmptyText = computed(() => {
|
||||
return tabMeta[props.activeSubTab]?.emptyText || '無資料';
|
||||
});
|
||||
|
||||
const activeColumnLabels = computed(() => {
|
||||
if (props.activeSubTab !== 'materials') {
|
||||
return {};
|
||||
}
|
||||
return {
|
||||
CONTAINERNAME: 'LOT ID',
|
||||
};
|
||||
});
|
||||
|
||||
const activeHiddenColumns = computed(() => {
|
||||
if (props.activeSubTab !== 'materials') {
|
||||
return [];
|
||||
}
|
||||
return ['CONTAINERID'];
|
||||
});
|
||||
|
||||
const activeColumnOrder = computed(() => {
|
||||
if (props.activeSubTab !== 'materials') {
|
||||
return [];
|
||||
}
|
||||
return [
|
||||
'CONTAINERNAME',
|
||||
'MATERIALPARTNAME',
|
||||
'MATERIALLOTNAME',
|
||||
'QTYCONSUMED',
|
||||
'WORKCENTERNAME',
|
||||
'SPECNAME',
|
||||
'EQUIPMENTNAME',
|
||||
'TXNDATE',
|
||||
'WORKCENTER_GROUP',
|
||||
];
|
||||
});
|
||||
|
||||
const canExport = computed(() => {
|
||||
return !activeLoading.value && activeRows.value.length > 0;
|
||||
});
|
||||
@@ -194,6 +227,9 @@ const detailCountLabel = computed(() => {
|
||||
:rows="activeRows"
|
||||
:loading="activeLoading"
|
||||
:empty-text="activeLoaded ? activeEmptyText : '尚未查詢此分頁資料'"
|
||||
:column-labels="activeColumnLabels"
|
||||
:hidden-columns="activeHiddenColumns"
|
||||
:column-order="activeColumnOrder"
|
||||
/>
|
||||
</template>
|
||||
</section>
|
||||
|
||||
Reference in New Issue
Block a user