Files
frontend_hmi_station/src/views/pwoManage/index.vue

124 lines
3.1 KiB
Vue
Raw Normal View History

2025-12-23 13:37:48 +08:00
<script setup lang="ts">
2025-12-29 09:02:46 +08:00
import { ref, onMounted, watch } from 'vue';
import { useRouter } from 'vue-router';
2025-12-23 13:37:48 +08:00
import { message } from 'ant-design-vue';
import type { ColumnsType } from 'ant-design-vue/es/table/interface';
2025-12-29 09:02:46 +08:00
import { listStation } from '@/api/pwoManage/station';
import { usePwoStore, useJobStore } from '@/store';
2025-12-23 13:37:48 +08:00
interface TableItem {
key: string;
index: number;
operationTitle: string;
planQty: number;
okQty: number;
ngQty: number;
status: string;
[key: string]: any;
}
2025-12-29 09:02:46 +08:00
const router = useRouter();
2025-12-23 13:37:48 +08:00
const pwoStore = usePwoStore();
2025-12-29 09:02:46 +08:00
const jobStore = useJobStore();
2025-12-23 13:37:48 +08:00
const tableData = ref<TableItem[]>([]);
const columns = [
{ title: '序号', dataIndex: 'index', key: 'index', align: 'center', width: 80 },
{ title: '制程', dataIndex: 'operationTitle', key: 'operationTitle', align: 'center' },
{ title: '总数量', dataIndex: 'planQty', key: 'planQty', align: 'center' },
{ title: '合格数量', dataIndex: 'okQty', key: 'okQty', align: 'center' },
{ title: '报废数量', dataIndex: 'ngQty', key: 'ngQty', align: 'center' },
{ title: '状态', dataIndex: 'status', key: 'status', align: 'center' },
2025-12-29 09:02:46 +08:00
{ title: '操作', key: 'action', align: 'center' },
2025-12-23 13:37:48 +08:00
];
const loadingStations = ref(false);
const fetchStations = async (traceOrderCode: string) => {
try {
loadingStations.value = true;
const res = await listStation({ traceOrderCode });
tableData.value = (res.rows || []).map((item: any, idx: number) => {
return {
key: String(item.id ?? idx),
index: item.seqNo ?? idx + 1,
...item,
} as TableItem;
});
} catch (error: any) {
message.error(error?.msg || error?.message || '查询站点失败');
} finally {
loadingStations.value = false;
}
};
2025-12-29 09:02:46 +08:00
const handleInfeed = (record: any) => {
jobStore.setInfo(record);
router.push({ name: 'Infeed' });
2025-12-23 13:37:48 +08:00
};
2025-12-29 09:02:46 +08:00
const handleOutfeed = () => {
router.push({ name: 'Outfeed' });
};
2025-12-23 13:37:48 +08:00
watch(
2025-12-29 09:02:46 +08:00
() => pwoStore.pwoInfo.code,
2025-12-23 13:37:48 +08:00
(val) => {
if (val) {
2025-12-29 09:02:46 +08:00
fetchStations(val);
2025-12-23 13:37:48 +08:00
}
2025-12-29 09:02:46 +08:00
},
{ immediate: true }
)
2025-12-23 13:37:48 +08:00
function rowClick(record: TableItem) {
return {
onClick: () => {
2025-12-29 09:02:46 +08:00
jobStore.setInfo(record);
2025-12-23 13:37:48 +08:00
},
};
}
</script>
<template>
<div class="table-wrapper">
<a-table
:dataSource="tableData"
:columns="columns as ColumnsType<TableItem>"
:pagination="false"
:loading="loadingStations"
bordered
sticky
rowKey="key"
class="custom-table"
:customRow="rowClick"
>
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'action'">
2025-12-29 09:02:46 +08:00
<a-space>
<a-button size="large" type="primary" @click="handleInfeed(record)">进站</a-button>
<a-button size="large" type="primary" danger @click="handleOutfeed">出站</a-button>
</a-space>
2025-12-23 13:37:48 +08:00
</template>
</template>
</a-table>
</div>
</template>
<style scoped lang="scss">
.table-wrapper {
height: 100%;
overflow: auto;
.custom-table {
:deep(.ant-table-thead > tr > th) {
background-color: #e6f7ff;
font-weight: bold;
}
:deep(.ant-table-tbody > tr > td) {
padding: 12px 8px;
}
}
}
</style>