yuan
2026-09-18 6c150b332f5faf1ced0403c127ac84c76b452bd7
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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
<template>
  <div v-loading="loading"
       class="forward-result">
    <!-- 订单卡 -->
    <div v-for="chain in data.chains"
         :key="chain.productionOrderId"
         class="order-card">
      <div class="order-head">
        <div class="order-title">
          <el-link type="primary"
                   @click="$emit('goto-order', chain.npsNo)">{{ chain.npsNo }}</el-link>
          <span class="product-name">{{ chain.finishedProduct || '-' }}</span>
        </div>
        <el-tag :type="statusType(chain.orderStatus)">{{ statusText(chain.orderStatus) }}</el-tag>
      </div>
 
      <div class="order-meta">
        <span>计划数量:{{ chain.planQty ?? '-' }} {{ chain.unit || '' }}</span>
        <span>完工数量:{{ chain.completeQty ?? '-' }} {{ chain.unit || '' }}</span>
        <span>下单时间:{{ chain.orderCreateTime || '-' }}</span>
      </div>
 
      <div v-if="chain.batches && chain.batches.length"
           class="hit-batches">
        <span class="hit-label">命中入库批次:</span>
        <el-tag v-for="batch in chain.batches"
                :key="batch.batchNo"
                type="success"
                effect="plain">
          {{ batch.batchNo }}({{ batch.qty }} {{ chain.unit || '' }},{{ batch.inTime }},{{ recordTypeLabel(batch.recordType) }})
        </el-tag>
      </div>
 
      <el-timeline class="order-timeline">
        <!-- 工序报工 -->
        <el-timeline-item v-for="report in sortReports(chain.reports)"
                          :key="report.productMainId + '_' + report.workOrderNo"
                          :timestamp="report.reportTime"
                          type="primary"
                          placement="top">
          <div class="node-title">工序报工:{{ report.operationName || '-' }}</div>
          <el-descriptions :column="3"
                           border
                           size="small">
            <el-descriptions-item label="工单编号">{{ report.workOrderNo || '-' }}</el-descriptions-item>
            <el-descriptions-item label="报工单号">{{ report.productNo || '-' }}</el-descriptions-item>
            <el-descriptions-item label="报工人">{{ report.userName || '-' }}</el-descriptions-item>
            <el-descriptions-item label="设备">{{ report.deviceName || '-' }}</el-descriptions-item>
            <el-descriptions-item label="产出数量">{{ report.outputQty ?? '-' }}</el-descriptions-item>
            <el-descriptions-item label="报废数量">{{ report.scrapQty ?? '-' }}</el-descriptions-item>
          </el-descriptions>
 
          <el-collapse class="input-collapse"
                       :model-value="expandedInputs[reportKey(chain, report)] || []"
                       @update:model-value="val => (expandedInputs[reportKey(chain, report)] = val)">
            <el-collapse-item name="inputs"
                              :title="`投入物料(${inputsFor(chain, report).length})`">
              <el-table :data="inputsFor(chain, report)"
                        border
                        size="small">
                <el-table-column label="物料名称"
                                 prop="materialName"
                                 align="center" />
                <el-table-column label="物料规格"
                                 prop="materialModel"
                                 align="center" />
                <el-table-column label="投入数量"
                                 prop="inputQty"
                                 align="center" />
                <el-table-column label="单位"
                                 prop="unit"
                                 align="center" />
              </el-table>
            </el-collapse-item>
          </el-collapse>
        </el-timeline-item>
 
        <!-- 领料批次(订单级) -->
        <el-timeline-item v-if="chain.picks && chain.picks.length"
                          type="warning"
                          placement="top">
          <div class="node-title">领料批次</div>
          <el-table :data="chain.picks"
                    border
                    size="small">
            <el-table-column label="原料批号"
                             align="center"
                             min-width="200">
              <template #default="{ row }">
                <el-link type="primary"
                         @click="$emit('pick-batch', row.batchNo)">{{ row.batchNo }}</el-link>
              </template>
            </el-table-column>
            <el-table-column label="物料"
                             prop="materialName"
                             align="center" />
            <el-table-column label="物料规格"
                             prop="materialModel"
                             align="center" />
            <el-table-column label="领料数量"
                             align="center">
              <template #default="{ row }">{{ row.quantity }} {{ row.unit || '' }}</template>
            </el-table-column>
            <el-table-column label="工序"
                             prop="operationName"
                             align="center" />
            <el-table-column label="领料时间"
                             prop="pickTime"
                             align="center" />
            <el-table-column label="供应商"
                             align="center">
              <template #default="{ row }">{{ row.supplierName || '-' }}</template>
            </el-table-column>
            <el-table-column label="采购合同号"
                             align="center">
              <template #default="{ row }">{{ row.contractNo || '-' }}</template>
            </el-table-column>
            <el-table-column label="原料检验结论"
                             align="center">
              <template #default="{ row }">{{ row.checkResult || '-' }}</template>
            </el-table-column>
          </el-table>
        </el-timeline-item>
 
        <!-- 检验单 -->
        <el-timeline-item v-if="chain.inspects && chain.inspects.length"
                          type="success"
                          placement="top">
          <div class="node-title">检验单</div>
          <el-table :data="chain.inspects"
                    border
                    size="small">
            <el-table-column label="检验类型"
                             prop="inspectTypeName"
                             align="center" />
            <el-table-column label="工序"
                             align="center">
              <template #default="{ row }">{{ row.process || '-' }}</template>
            </el-table-column>
            <el-table-column label="检验员"
                             prop="checkName"
                             align="center" />
            <el-table-column label="产品名称"
                             prop="productName"
                             align="center" />
            <el-table-column label="规格型号"
                             prop="model"
                             align="center" />
            <el-table-column label="数量"
                             prop="quantity"
                             align="center" />
            <el-table-column label="合格数量"
                             prop="qualifiedQuantity"
                             align="center" />
            <el-table-column label="不合格数量"
                             prop="unqualifiedQuantity"
                             align="center" />
            <el-table-column label="检测结果"
                             align="center">
              <template #default="{ row }">
                <el-tag :type="row.checkResult === '合格' ? 'success' : 'danger'">
                  {{ row.checkResult || '待检测' }}
                </el-tag>
              </template>
            </el-table-column>
            <el-table-column label="检测日期"
                             prop="checkTime"
                             align="center" />
            <el-table-column label="操作"
                             align="center"
                             width="100">
              <template #default="{ row }">
                <el-link type="primary"
                         @click="openInspect(chain, row)">查看详情</el-link>
              </template>
            </el-table-column>
          </el-table>
        </el-timeline-item>
      </el-timeline>
    </div>
 
    <!-- 出库流向(顶层,按批号聚合) -->
    <div v-if="data.outbounds && data.outbounds.length"
         class="order-card">
      <div class="order-head">
        <div class="order-title">
          <span class="product-name">出库流向</span>
        </div>
      </div>
      <el-table :data="data.outbounds"
                border
                size="small">
        <el-table-column label="批号"
                         prop="batchNo"
                         align="center" />
        <el-table-column label="产品名称"
                         prop="productName"
                         align="center" />
        <el-table-column label="规格型号"
                         prop="productModel"
                         align="center" />
        <el-table-column label="出库数量"
                         align="center">
          <template #default="{ row }">{{ row.qty }} {{ row.unit || '' }}</template>
        </el-table-column>
        <el-table-column label="出库类型"
                         align="center">
          <template #default="{ row }">{{ recordTypeLabel(row.recordType) }}</template>
        </el-table-column>
        <el-table-column label="出库时间"
                         prop="outTime"
                         align="center" />
        <el-table-column label="备注"
                         align="center">
          <template #default="{ row }">{{ row.remark || '-' }}</template>
        </el-table-column>
      </el-table>
    </div>
 
    <!-- 检验单详情 -->
    <el-dialog v-model="inspectVisible"
               title="检验单详情"
               width="900px">
      <div v-if="currentInspect"
           class="inspect-detail">
        <el-descriptions :column="3"
                         border
                         size="small">
          <el-descriptions-item label="检验类型">{{ currentInspect.inspectTypeName || '-' }}</el-descriptions-item>
          <el-descriptions-item label="工序">{{ currentInspect.process || '-' }}</el-descriptions-item>
          <el-descriptions-item label="检验员">{{ currentInspect.checkName || '-' }}</el-descriptions-item>
          <el-descriptions-item label="产品名称">{{ currentInspect.productName || '-' }}</el-descriptions-item>
          <el-descriptions-item label="规格型号">{{ currentInspect.model || '-' }}</el-descriptions-item>
          <el-descriptions-item label="单位">{{ currentInspect.unit || '-' }}</el-descriptions-item>
          <el-descriptions-item label="数量">{{ currentInspect.quantity ?? '-' }}</el-descriptions-item>
          <el-descriptions-item label="合格数量">{{ currentInspect.qualifiedQuantity ?? '-' }}</el-descriptions-item>
          <el-descriptions-item label="不合格数量">{{ currentInspect.unqualifiedQuantity ?? '-' }}</el-descriptions-item>
          <el-descriptions-item label="检测结果">
            <el-tag :type="currentInspect.checkResult === '合格' ? 'success' : 'danger'">
              {{ currentInspect.checkResult || '待检测' }}
            </el-tag>
          </el-descriptions-item>
          <el-descriptions-item label="检测日期">{{ currentInspect.checkTime || '-' }}</el-descriptions-item>
          <el-descriptions-item label="不合格现象">{{ currentInspect.defectivePhenomena || '-' }}</el-descriptions-item>
        </el-descriptions>
 
        <h4 class="sub-title">不合格处理</h4>
        <el-table :data="currentUnqualified"
                  border
                  size="small">
          <el-table-column label="序号"
                           type="index"
                           width="60"
                           align="center" />
          <el-table-column label="产品名称"
                           prop="productName"
                           align="center" />
          <el-table-column label="规格型号"
                           prop="model"
                           align="center" />
          <el-table-column label="数量"
                           prop="quantity"
                           align="center" />
          <el-table-column label="不合格现象"
                           prop="defectivePhenomena"
                           align="center" />
          <el-table-column label="处理结果"
                           prop="dealResult"
                           align="center" />
          <el-table-column label="处理人"
                           prop="dealName"
                           align="center" />
          <el-table-column label="处理日期"
                           prop="dealTime"
                           align="center" />
        </el-table>
      </div>
      <template #footer>
        <el-button @click="inspectVisible = false">关闭</el-button>
      </template>
    </el-dialog>
  </div>
</template>
 
<script setup>
  import { ref, reactive } from "vue";
 
  defineProps({
    data: {
      type: Object,
      required: true,
    },
    loading: {
      type: Boolean,
      default: false,
    },
  });
 
  defineEmits(["goto-order", "pick-batch"]);
 
  const statusTypeMap = { 1: "primary", 2: "warning", 3: "success", 5: "danger" };
  const statusTextMap = { 1: "待开始", 2: "进行中", 3: "已完成", 5: "已结束" };
  const statusType = status => statusTypeMap[status] || "info";
  const statusText = status => statusTextMap[status] || "已取消";
 
  const inTypeMap = {
    0: "自定义入库",
    2: "生产报工入库",
    6: "质检合格入库",
    7: "采购入库",
    10: "采购入库",
  };
  const outTypeMap = {
    1: "自定义出库",
    3: "生产报工出库",
    8: "销售出库",
    13: "销售发货出库",
  };
  const recordTypeLabel = type => {
    const key = String(type ?? "");
    return inTypeMap[key] || outTypeMap[key] || key || "-";
  };
 
  const sortReports = reports =>
    [...(reports || [])].sort((a, b) =>
      String(a.reportTime || "").localeCompare(String(b.reportTime || ""))
    );
 
  const inputsFor = (chain, report) =>
    (chain.inputs || []).filter(
      item => String(item.productMainId) === String(report.productMainId)
    );
 
  const reportKey = (chain, report) =>
    `${chain.productionOrderId}_${report.productMainId}_${report.workOrderNo}`;
  const expandedInputs = reactive({});
 
  // 检验单详情
  const inspectVisible = ref(false);
  const currentInspect = ref(null);
  const currentUnqualified = ref([]);
  const openInspect = (chain, inspect) => {
    currentInspect.value = inspect;
    const own = inspect.unqualifiedList || [];
    currentUnqualified.value = own.length
      ? own
      : (chain.unqualifiedList || []).filter(
          item => String(item.inspectId) === String(inspect.inspectId)
        );
    inspectVisible.value = true;
  };
</script>
 
<style scoped lang="scss">
  .forward-result {
    min-height: 200px;
  }
 
  .order-card {
    background-color: #ffffff;
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.08);
  }
 
  .order-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 12px;
    border-bottom: 1px solid #ebeef5;
  }
 
  .order-title {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 16px;
  }
 
  .product-name {
    font-weight: 600;
    color: #1a1a1a;
  }
 
  .order-meta {
    display: flex;
    gap: 28px;
    padding: 12px 0;
    font-size: 13px;
    color: #606266;
  }
 
  .hit-batches {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background-color: #f0f9eb;
    border-radius: 6px;
 
    .hit-label {
      font-size: 13px;
      color: #606266;
    }
  }
 
  .order-timeline {
    margin-top: 20px;
    padding-left: 4px;
  }
 
  .node-title {
    font-size: 14px;
    font-weight: 600;
    color: #303133;
    margin-bottom: 12px;
  }
 
  .input-collapse {
    margin-top: 12px;
  }
 
  .sub-title {
    margin: 20px 0 12px;
    font-size: 14px;
    font-weight: 600;
    color: #303133;
  }
</style>