95 lines
2.3 KiB
Vue
95 lines
2.3 KiB
Vue
<template>
|
||
<div class="stockout-product-container">
|
||
<div v-if="orderInfo" class="order-info">
|
||
<span class="order-code">出库单号:{{ orderInfo.delivery_order_code }}</span>
|
||
</div>
|
||
<el-table
|
||
v-loading="loading"
|
||
:data="data"
|
||
border
|
||
size="small"
|
||
height="100%"
|
||
style="width: 100%"
|
||
>
|
||
<el-table-column
|
||
v-for="col in productColumns"
|
||
:key="col.prop"
|
||
:prop="col.prop"
|
||
:label="col.label"
|
||
:width="col.width"
|
||
:min-width="col.minWidth"
|
||
:fixed="col.fixed"
|
||
:align="col.align"
|
||
/>
|
||
<template #empty>
|
||
<div style="padding: 20px; color: #909399;">暂无商品明细</div>
|
||
</template>
|
||
</el-table>
|
||
</div>
|
||
</template>
|
||
|
||
<script setup lang="ts">
|
||
import { ref, watch } from 'vue'
|
||
import { ElMessage } from 'element-plus'
|
||
import { productColumns, formatStockoutListItems } from '../stockout-config'
|
||
import * as stockoutApi from '@/api/storage.stockout/stockout'
|
||
|
||
const props = defineProps<{
|
||
id: string | number
|
||
}>()
|
||
|
||
const data = ref<any[]>([])
|
||
const orderInfo = ref<any>(null)
|
||
const loading = ref(false)
|
||
|
||
const loadData = async () => {
|
||
if (!props.id) return
|
||
loading.value = true
|
||
data.value = []
|
||
orderInfo.value = null
|
||
try {
|
||
const res: any = await stockoutApi.stockoutListItems({ id: Number(props.id) })
|
||
if (res && (res.code === 200 || res.code === 1 || res.flag === 'success')) {
|
||
const payload = res.data || res
|
||
orderInfo.value = payload.order || null
|
||
const rows = Array.isArray(payload.list)
|
||
? payload.list
|
||
: Array.isArray(payload.items)
|
||
? payload.items
|
||
: []
|
||
data.value = formatStockoutListItems(rows)
|
||
} else {
|
||
ElMessage.error(res?.message || '加载商品明细失败')
|
||
}
|
||
} catch (error) {
|
||
console.error('加载商品明细失败', error)
|
||
ElMessage.error('加载商品明细失败')
|
||
} finally {
|
||
loading.value = false
|
||
}
|
||
}
|
||
|
||
watch(() => props.id, loadData, { immediate: true })
|
||
</script>
|
||
|
||
<style scoped lang="scss">
|
||
.stockout-product-container {
|
||
height: 100%;
|
||
display: flex;
|
||
flex-direction: column;
|
||
box-sizing: border-box;
|
||
|
||
.order-info {
|
||
padding: 6px 10px;
|
||
font-size: 13px;
|
||
color: #606266;
|
||
border-bottom: 1px solid #ebeef5;
|
||
background: #fafafa;
|
||
|
||
.order-code {
|
||
font-weight: 500;
|
||
}
|
||
}
|
||
}
|
||
</style>
|