yuan
2026-08-13 2e36be622d174bb25a9ebdf500e38cd8585593db
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
<template>
  <div>
    <el-dialog v-model="dialogVisible"
               title="领料详情"
               width="1400px"
               @close="handleClose">
      <div class="material-detail-tip">
        展示该生产订单下所有工序的领料记录。
      </div>
      <el-table v-loading="materialDetailLoading"
                :data="materialDetailTableData"
                border
                row-key="id">
        <el-table-column label="工序名称"
                         prop="operationName"
                         min-width="160" />
        <el-table-column label="工单编号"
                         prop="workOrderNo"
                         min-width="150" />
        <el-table-column label="原料名称"
                         prop="materialName"
                         min-width="160" />
        <el-table-column label="原料型号"
                         prop="materialModel"
                         min-width="180" />
        <el-table-column label="批号"
                         prop="batchNo"
                         min-width="150" />
        <el-table-column label="计量单位"
                         prop="unit"
                         width="100" />
        <el-table-column label="领用数量"
                         min-width="110">
          <template #default="{ row }">
            {{ stripTrailingZeros(row.pickQuantity) }}
          </template>
        </el-table-column>
        <el-table-column label="退料数量"
                         min-width="110">
          <template #default="{ row }">
            {{ stripTrailingZeros(row.returnQty) || 0 }}
          </template>
        </el-table-column>
        <el-table-column label="净领料数量"
                         min-width="130">
          <template #default="{ row }">
            {{ stripTrailingZeros(row.effectiveQuantity) || 0 }}
          </template>
        </el-table-column>
        <el-table-column label="领料时间"
                         min-width="120">
          <template #default="{ row }">
            {{ formatDate(row.createTime) }}
          </template>
        </el-table-column>
      </el-table>
      <template #footer>
        <span class="dialog-footer">
          <el-button @click="dialogVisible = false">关闭</el-button>
        </span>
      </template>
    </el-dialog>
  </div>
</template>
 
<script setup>
  import { computed, ref, watch } from "vue";
  import { listMaterialPickingDetail } from "@/api/productionManagement/productionOrder.js";
 
  const formatDate = value => (value ? String(value).slice(0, 10) : "-");
 
  const stripTrailingZeros = val => {
    const str = String(val ?? "");
    if (str.includes(".")) {
      return parseFloat(str).toString();
    }
    return str;
  };
 
  const props = defineProps({
    modelValue: { type: Boolean, default: false },
    orderRow: { type: Object, default: null },
  });
  const emit = defineEmits(["update:modelValue", "confirmed"]);
 
  const dialogVisible = computed({
    get: () => props.modelValue,
    set: val => emit("update:modelValue", val),
  });
 
  const materialDetailLoading = ref(false);
  const materialDetailTableData = ref([]);
 
  const loadDetailList = async () => {
    if (!props.orderRow?.id) return;
    materialDetailLoading.value = true;
    materialDetailTableData.value = [];
    try {
      const res = await listMaterialPickingDetail(props.orderRow.id);
      const records = Array.isArray(res.data) ? res.data : res.data?.records || [];
      materialDetailTableData.value = records.map(item => ({
        ...item,
        operationName: item.operationName || item.processName || "",
        materialName: item.productName || item.materialName || "",
        materialModel: item.model || item.materialModel || "",
        pickQuantity: item.pickQuantity ?? item.quantity ?? 0,
        returnQty: item.returnQty ?? 0,
        effectiveQuantity: item.effectiveQuantity ?? 0,
      }));
    } finally {
      materialDetailLoading.value = false;
    }
  };
 
  watch(
    () => dialogVisible.value,
    visible => {
      if (visible) {
        loadDetailList();
      }
    }
  );
 
  const handleClose = () => {
    materialDetailTableData.value = [];
  };
</script>
 
<style scoped lang="scss">
  .material-detail-tip {
    margin-bottom: 12px;
    color: #606266;
    font-size: 13px;
  }
</style>