<template>
|
<div class="stock-info-page">
|
<a-card>
|
<a-space style="margin-bottom: 16px">
|
<a-input-search
|
v-model:value="searchText"
|
placeholder="搜索物料编码"
|
style="width: 200px"
|
@search="handleSearch"
|
/>
|
<a-button @click="handleExport">
|
<template #icon><download-outlined /></template>
|
导出
|
</a-button>
|
</a-space>
|
|
<a-table
|
:columns="columns"
|
:data-source="dataSource"
|
:loading="loading"
|
:pagination="pagination"
|
@change="handleTableChange"
|
row-key="Id"
|
>
|
<template #bodyCell="{ column, record }">
|
<template v-if="column.key === 'action'">
|
<a @click="handleView(record)">查看明细</a>
|
</template>
|
</template>
|
</a-table>
|
</a-card>
|
</div>
|
</template>
|
|
<script setup lang="ts">
|
import { ref, reactive, onMounted } from 'vue';
|
import { message } from 'ant-design-vue';
|
import { DownloadOutlined } from '@ant-design/icons-vue';
|
import type { StockInfo } from '../../../types/common';
|
|
const columns = [
|
{ title: '仓库编码', dataIndex: 'WarehouseCode', key: 'WarehouseCode' },
|
{ title: '仓库名称', dataIndex: 'WarehouseName', key: 'WarehouseName' },
|
{ title: '货位编码', dataIndex: 'LocationCode', key: 'LocationCode' },
|
{ title: '物料编码', dataIndex: 'MaterielCode', key: 'MaterielCode' },
|
{ title: '物料名称', dataIndex: 'MaterielName', key: 'MaterielName' },
|
{ title: '总数量', dataIndex: 'Quantity', key: 'Quantity' },
|
{ title: '可用数量', dataIndex: 'AvailableQuantity', key: 'AvailableQuantity' },
|
{ title: '锁定数量', dataIndex: 'LockedQuantity', key: 'LockedQuantity' },
|
{ title: '创建时间', dataIndex: 'CreateDate', key: 'CreateDate' },
|
{ title: '操作', key: 'action', width: 120 },
|
];
|
|
const dataSource = ref<StockInfo[]>([]);
|
const loading = ref(false);
|
const searchText = ref('');
|
const pagination = reactive({
|
current: 1,
|
pageSize: 20,
|
total: 0,
|
showSizeChanger: true,
|
showTotal: (total: number) => `共 ${total} 条`,
|
});
|
|
onMounted(() => {
|
fetchData();
|
});
|
|
async function fetchData() {
|
loading.value = true;
|
try {
|
// 这里调用实际的 API
|
setTimeout(() => {
|
dataSource.value = [];
|
pagination.total = 0;
|
loading.value = false;
|
}, 500);
|
} catch (error) {
|
console.error('Fetch data error:', error);
|
loading.value = false;
|
}
|
}
|
|
function handleTableChange(pag: any) {
|
pagination.current = pag.current;
|
pagination.pageSize = pag.pageSize;
|
fetchData();
|
}
|
|
function handleSearch() {
|
pagination.current = 1;
|
fetchData();
|
}
|
|
function handleView(record: StockInfo) {
|
message.info(`查看库存明细: ${record.MaterielCode}`);
|
}
|
|
function handleExport() {
|
message.info('导出库存数据');
|
}
|
</script>
|
|
<style scoped>
|
.stock-info-page {
|
padding: 0;
|
}
|
</style>
|