|
|
@@ -0,0 +1,145 @@
|
|
|
+<template>
|
|
|
+ <div class="order-item-table-optimized">
|
|
|
+ <el-table
|
|
|
+ :data="itemData"
|
|
|
+ :loading="loading"
|
|
|
+ border
|
|
|
+ size="small"
|
|
|
+ style="width: 100%"
|
|
|
+ >
|
|
|
+ <el-table-column prop="itemCode" label="物料编码" width="120" />
|
|
|
+ <el-table-column prop="itemName" label="物料名称" width="150" />
|
|
|
+ <el-table-column prop="specs" label="规格型号" width="120" />
|
|
|
+ <el-table-column prop="mainItemCategoryName" label="主物料分类" width="120" />
|
|
|
+ <el-table-column prop="warehouseName" label="仓库名称" width="120" />
|
|
|
+ <el-table-column prop="availableQuantity" label="库存数量" width="100" align="right">
|
|
|
+ <template slot-scope="scope">
|
|
|
+ {{ scope.row.availableQuantity | numberFormat(4) }}
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column prop="orderQuantity" label="订单数量" width="100" align="right">
|
|
|
+ <template slot-scope="scope">
|
|
|
+ {{ scope.row.orderQuantity | numberFormat(4) }}
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column prop="confirmQuantity" label="确认数量" width="100" align="right">
|
|
|
+ <template slot-scope="scope">
|
|
|
+ {{ scope.row.confirmQuantity | numberFormat(4) }}
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column prop="unitPrice" label="单价" width="100" align="right">
|
|
|
+ <template slot-scope="scope">
|
|
|
+ ¥{{ scope.row.unitPrice | numberFormat(2) }}
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column prop="taxRate" label="税率" width="80" align="right">
|
|
|
+ <template slot-scope="scope">
|
|
|
+ {{ scope.row.taxRate | numberFormat(2) }}%
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column prop="taxAmount" label="税额" width="100" align="right">
|
|
|
+ <template slot-scope="scope">
|
|
|
+ ¥{{ scope.row.taxAmount | numberFormat(2) }}
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column prop="totalAmount" label="总金额" width="100" align="right">
|
|
|
+ <template slot-scope="scope">
|
|
|
+ ¥{{ scope.row.totalAmount | numberFormat(2) }}
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column prop="itemStatus" label="明细状态" width="100" align="center">
|
|
|
+ <template slot-scope="scope">
|
|
|
+ <el-tag
|
|
|
+ :type="getStatusType(scope.row.itemStatus)"
|
|
|
+ size="mini"
|
|
|
+ >
|
|
|
+ {{ getStatusText(scope.row.itemStatus) }}
|
|
|
+ </el-tag>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ </el-table>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+import { getList } from '@/api/order/order-item'
|
|
|
+import { getOrderItemStatusLabel, getOrderItemStatusTagType } from '@/constants'
|
|
|
+import { formatFloatNumber } from '@/components/order-form/number-format-utils'
|
|
|
+
|
|
|
+export default {
|
|
|
+ name: 'OrderItemTableOptimized',
|
|
|
+ props: {
|
|
|
+ // 新增:支持直接传入明细数据
|
|
|
+ orderItemData: {
|
|
|
+ type: Array,
|
|
|
+ default: () => []
|
|
|
+ },
|
|
|
+ // 保持原有兼容性
|
|
|
+ orderId: {
|
|
|
+ type: [String, Number],
|
|
|
+ default: null
|
|
|
+ }
|
|
|
+ },
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ itemData: [],
|
|
|
+ loading: false
|
|
|
+ }
|
|
|
+ },
|
|
|
+ watch: {
|
|
|
+ // 优先使用传入的明细数据
|
|
|
+ orderItemData: {
|
|
|
+ handler(newVal) {
|
|
|
+ if (Array.isArray(newVal) && newVal.length > 0) {
|
|
|
+ this.itemData = newVal
|
|
|
+ this.loading = false
|
|
|
+ }
|
|
|
+ },
|
|
|
+ immediate: true
|
|
|
+ },
|
|
|
+ // 降级:如果没有传入数据,则按原有方式查询
|
|
|
+ orderId: {
|
|
|
+ handler(newVal) {
|
|
|
+ if (newVal && (!this.orderItemData || this.orderItemData.length === 0)) {
|
|
|
+ this.loadItemData()
|
|
|
+ }
|
|
|
+ },
|
|
|
+ immediate: true
|
|
|
+ }
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ async loadItemData() {
|
|
|
+ if (!this.orderId) return
|
|
|
+
|
|
|
+ this.loading = true
|
|
|
+ try {
|
|
|
+ const response = await getList(1, 1000, { orderId: this.orderId })
|
|
|
+ this.itemData = response.data.data.records || []
|
|
|
+ } catch (error) {
|
|
|
+ console.error('加载订单明细失败:', error)
|
|
|
+ this.$message.error('加载订单明细失败')
|
|
|
+ this.itemData = []
|
|
|
+ } finally {
|
|
|
+ this.loading = false
|
|
|
+ }
|
|
|
+ },
|
|
|
+ getStatusText(status) {
|
|
|
+ return getOrderItemStatusLabel(status)
|
|
|
+ },
|
|
|
+ getStatusType(status) {
|
|
|
+ return getOrderItemStatusTagType(status)
|
|
|
+ }
|
|
|
+ },
|
|
|
+ filters: {
|
|
|
+ numberFormat(value, precision = 2) {
|
|
|
+ return formatFloatNumber(value)
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+</script>
|
|
|
+
|
|
|
+<style scoped>
|
|
|
+.order-item-table-optimized {
|
|
|
+ padding: 10px 0;
|
|
|
+}
|
|
|
+</style>
|