董国庆
昨天 c85d2427b749c5e7236f0474f9215e5936cdfa7c
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
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
<template>
  <Card>
    <div class="header-title-left">
      <img src="@/assets/public/headercard.png" />
      <div>所属实验调度</div>
      <el-button v-if="isEngineer && pageType !== 'detail'" @click="showScheduling = true" class="el-icon-plus" type="primary">
        选择实验调度</el-button>
    </div>
    <Table :data="schedulingData" :total="schedulingTotal" :height="null">
      <template>
        <el-table-column type="index" label="序号" width="80"></el-table-column>
        <el-table-column prop="projectName" label="所属项目课题方案"></el-table-column>
        <el-table-column prop="experimentCode" label="实验编号"></el-table-column>
        <el-table-column prop="experimentName" label="实验名称"></el-table-column>
        <el-table-column prop="experimentDate" label="通知时间"></el-table-column>
        <el-table-column prop="experimentStartTime" label="实验开始时间"></el-table-column>
        <el-table-column prop="experimentEndTime" label="实验结束时间"></el-table-column>
        <el-table-column prop="participantsName" label="参加人员"></el-table-column>
        <el-table-column prop="status" label="状态">
          <template slot-scope="scope">
            <el-tag :type="getStatusType(scope.row.status)">
              {{ getStatusText(scope.row.status) }}
            </el-tag>
          </template>
        </el-table-column>
      </template>
    </Table>
 
    <!-- 化验师专用部分 -->
    <div v-if="isAssayer" class="assayer-section">
      <div class="header-title-left" style="margin-top: 38px">
        <img src="@/assets/public/headercard.png" />
        <span>送样-收样记录</span>
        <el-button type="primary" class="el-icon-plus" @click="showPendingColumns = !showPendingColumns">
          {{ showPendingColumns ? "收起待收样详情" : "展开待收样详情" }}
        </el-button>
        <el-button type="primary" class="el-icon-plus" @click="showReceivedColumns = !showReceivedColumns">
          {{ showReceivedColumns ? "收起已收样详情" : "展开已收样详情" }}
        </el-button>
      </div>
      <div class="sample-code">
        取样单编号:{{ form.sampleCode || "DD-25010BS01" }}
      </div>
 
      <!-- 待收样列表 -->
      <div class="pending-samples">
        <div class="sub-title">待收样列表</div>
        <el-button 
          type="primary" 
          class="batch-receive" 
          @click="handleBatchReceive"
          :disabled="selectedSamples.length == 0"
        >批量接收</el-button>
        <Table ref="pendingTable" 
          :data="pendingSamples" 
          :total="pendingSamplesTotal" 
          :height="null"
          :row-key="row => row.id"
          @selection-change="handlePendingSelectionChange">
          <template>
            <el-table-column 
              type="selection" 
              width="55" 
              fixed="left" >
            </el-table-column>
            <el-table-column type="index" label="序号" width="80"></el-table-column>
            <el-table-column prop="samplingName" label="取样名称" width="150"></el-table-column>
            <el-table-column prop="sampleCode" label="取样样品编号" width="150"></el-table-column>
            <el-table-column prop="temperature" label="温度" width="150"></el-table-column>
            <el-table-column prop="samplePh" label="PH" width="150"></el-table-column>
            <el-table-column prop="waterAddition" label="加水量" width="150"></el-table-column>
            <template v-if="showPendingColumns">
              <el-table-column prop="addAuxiliaryOne" label="加辅1" width="150"></el-table-column>
              <el-table-column prop="addAuxiliaryTwo" label="加辅2" width="150"></el-table-column>
              <el-table-column prop="addAuxiliaryThree" label="加辅3" width="150"></el-table-column>
              <el-table-column prop="addAuxiliaryFour" label="加辅4" width="150"></el-table-column>
              <el-table-column prop="addAuxiliaryFive" label="加辅5" width="150"></el-table-column>
              <el-table-column prop="addAuxiliarySix" label="加辅6" width="150"></el-table-column>
              <el-table-column prop="addAuxiliarySeven" label="加辅7" width="150"></el-table-column>
              <el-table-column prop="addAuxiliaryEight" label="加辅8" width="150"></el-table-column>
              <el-table-column prop="addAuxiliaryNine" label="加辅9" width="150"></el-table-column>
              <el-table-column prop="addAuxiliaryTen" label="加辅10" width="150"></el-table-column>
            </template>
            <el-table-column prop="sampleAmount" label="取样量" width="150"></el-table-column>
            <el-table-column prop="pictures" label="拍照" width="150">
              <template slot-scope="scope">
                <template v-if="scope.row.pictures">
                  <el-image
                    v-for="(url, index) in scope.row.pictures.split(',')" 
                    :key="index"
                    src="https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg"
                    :preview-src-list="[url]"
                    style="width: 50px; height: 50px;"
                  />
                </template>
                <span v-else>-</span>
              </template>
            </el-table-column>
            <el-table-column prop="handlePersonName" label="操作人员" width="150"></el-table-column>
            <el-table-column label="状态" prop="status" width="100" fixed="right">
              <template slot-scope="scope">
                <span>{{ scope.row.status == '2' ? '待接收' : '已接收' }}</span>
              </template>
            </el-table-column>
            <el-table-column label="操作" width="100" fixed="right">
              <template slot-scope="scope">
                <el-button type="text" @click="handleReceive(scope.row)">接收</el-button>
              </template>
            </el-table-column>
          </template>
        </Table>
      </div>
      <!-- 已收样列表 -->
      <div class="received-samples">
        <div class="sub-title">已收样列表</div>
        <Table ref="receivedTable" :data="receivedSamples" :total="receivedSamplesTotal" :height="null">
          <template>
            <el-table-column type="index" label="序号" width="80"></el-table-column>
            <el-table-column prop="samplingName" label="取样名称" width="150"></el-table-column>
            <el-table-column prop="sampleCode" label="取样样品编号" width="150"></el-table-column>
            <el-table-column prop="temperature" label="温度" width="150"></el-table-column>
            <el-table-column prop="samplePh" label="PH" width="150"></el-table-column>
            <el-table-column prop="waterAddition" label="加水量" width="150"></el-table-column>
            <template v-if="showReceivedColumns">
              <el-table-column prop="addAuxiliaryOne" label="加辅1" width="150"></el-table-column>
              <el-table-column prop="addAuxiliaryTwo" label="加辅2" width="150"></el-table-column>
              <el-table-column prop="addAuxiliaryThree" label="加辅3" width="150"></el-table-column>
              <el-table-column prop="addAuxiliaryFour" label="加辅4" width="150"></el-table-column>
              <el-table-column prop="addAuxiliaryFive" label="加辅5" width="150"></el-table-column>
              <el-table-column prop="addAuxiliarySix" label="加辅6" width="150"></el-table-column>
              <el-table-column prop="addAuxiliarySeven" label="加辅7" width="150"></el-table-column>
              <el-table-column prop="addAuxiliaryEight" label="加辅8" width="150"></el-table-column>
              <el-table-column prop="addAuxiliaryNine" label="加辅9" width="150"></el-table-column>
              <el-table-column prop="addAuxiliaryTen" label="加辅10" width="150"></el-table-column>
            </template>
            <el-table-column prop="sampleAmount" label="取样量" width="150"></el-table-column>
            <el-table-column prop="pictures" label="拍照" width="150">
              <template slot-scope="scope">
                <template v-if="scope.row.pictures">
                  <el-image
                    v-for="(url, index) in scope.row.pictures.split(',')" 
                    :key="index"
                    src="https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg"
                    :preview-src-list="[url]"
                    style="width: 50px; height: 50px;"
                  />
                </template>
                <span v-else>-</span>
              </template>
            </el-table-column>
            <el-table-column prop="handlePersonName" label="操作人员" width="150"></el-table-column>
            <el-table-column prop="receiveTime" label="收样时间" width="150"></el-table-column>
            <el-table-column prop="receiver" label="收样人" width="150"></el-table-column>
            <el-table-column label="状态" prop="status" width="100" fixed="right">
              <template slot-scope="scope">
                <span>{{ scope.row.status == '3' ? '已接收' : '待接收' }}</span>
              </template>
            </el-table-column>
          </template>
        </Table>
      </div>
    </div>
 
    <!-- 工程师部分 -->
    <div v-if="isEngineer">
      <div class="header-title-left" style="margin-top: 38px">
        <img src="@/assets/public/headercard.png" />
        <span>基础信息</span>
      </div>
      <el-form ref="form" :model="form" :rules="rules" inline label-position="top" v-if="pageType !== 'detail'">
        <el-form-item label="取样单编号" prop="sampleCode">
          <el-input v-model="form.sampleCode" :disabled="true" placeholder="自动生成" />
        </el-form-item>
      </el-form>
      <div>取样单编号:{{ form.sampleCode }}</div>
      <div class="header-title-left" style="margin-top: 38px">
        <img src="@/assets/public/headercard.png" />
        <span>取样操作记录</span>
        <el-button v-if="isEngineer && pageType !== 'detail'" type="primary" class="el-icon-plus" @click="showAddTime = true">
          新增工艺时间
        </el-button>
        <el-button type="primary" class="el-icon-plus" @click="showAdditives = !showAdditives">
          {{ showAdditives ? "收起辅料详情" : "展开辅料详情" }}
        </el-button>
      </div>
      <Table ref="sampleTable" :data="sampleData" :total="sampleTotal" :height="null">
        <template>
          <el-table-column prop="index" label="序号" width="80"></el-table-column>
          <el-table-column prop="processTime" label="工艺时间" width="150"></el-table-column>
          <el-table-column prop="samplingName" label="取样名称" width="150"></el-table-column>
          <el-table-column prop="sampleCode" label="取样样品编号" width="150"></el-table-column>
          <el-table-column prop="temperature" label="温度" width="150"></el-table-column>
          <el-table-column prop="samplePh" label="PH" width="150"></el-table-column>
          <el-table-column prop="waterAddition" label="加水量" width="150"></el-table-column>
          <template v-if="showAdditives">
            <el-table-column prop="addAuxiliaryOne" label="加辅1" width="150"></el-table-column>
            <el-table-column prop="addAuxiliaryTwo" label="加辅2" width="150"></el-table-column>
            <el-table-column prop="addAuxiliaryThree" label="加辅3" width="150"></el-table-column>
            <el-table-column prop="addAuxiliaryFour" label="加辅4" width="150"></el-table-column>
            <el-table-column prop="addAuxiliaryFive" label="加辅5" width="150"></el-table-column>
            <el-table-column prop="addAuxiliarySix" label="加辅6" width="150"></el-table-column>
            <el-table-column prop="addAuxiliarySeven" label="加辅7" width="150"></el-table-column>
            <el-table-column prop="addAuxiliaryEight" label="加辅8" width="150"></el-table-column>
            <el-table-column prop="addAuxiliaryNine" label="加辅9" width="150"></el-table-column>
            <el-table-column prop="addAuxiliaryTen" label="加辅10" width="150"></el-table-column>
          </template>
          <el-table-column prop="sampleAmount" label="取样量" width="150"></el-table-column>
          <el-table-column prop="pictures" label="拍照" width="150">
            <template slot-scope="scope">
              <template v-if="scope.row.pictures">
                <el-image
                  v-for="(url, index) in scope.row.pictures.split(',')" 
                  :key="index"
                  :src="url"
                  :preview-src-list="[url]"
                  style="width: 50px; height: 50px;"
                />
              </template>
              <span v-else>-</span>
            </template>
          </el-table-column>
          <el-table-column prop="handlePersonName" label="操作人员" width="150"></el-table-column>
        </template>
      </Table>
      <div v-if="pageType == 'detail'" style="margin-top: 38px">备注:</div>
      <el-input 
        v-if="pageType == 'detail'" 
        type="textarea" 
        
        v-model="form.remark" 
        placeholder="请输入内容" 
        style="margin-top: 10px"
        :disabled="true" 
      />
 
      <div class="add-project-footer" v-if="isEngineer && pageType !== 'detail'">
        <el-button type="primary" class="save-btn" @click="handleSave">保存</el-button>
        <el-button @click="handleSaveDraft">存草稿</el-button>
      </div>
    </div>
 
    <experimentalScheduling :show="showScheduling" @close="handleSchedulingClose" @submit="handleSchedulingSubmit" />
    <addTime :show.sync="showAddTime" @confirm="handleAddTime" />
    <receive-confirm-dialog :visible.sync="showReceiveConfirm" :sample-count="selectedSamples.length"
      @confirm="confirmReceive" />
  </Card>
</template>
 
<script>
import experimentalScheduling from "./components/experimental-scheduling.vue";
import addTime from "./components/addTime.vue";
import ReceiveConfirmDialog from "./components/receiveConfirmDialog.vue";
import { add, getDetail, update, batchCollectSamples } from "./service";
 
export default {
  name: "AddSample",
  components: {
    experimentalScheduling,
    addTime,
    ReceiveConfirmDialog,
  },
  data() {
    return {
      showScheduling: false,
      showAddTime: false,
      showAdditives: true,
      showReceiveConfirm: false,
      showPendingColumns: true,
      showReceivedColumns: true,
      schedulingData: [],
      schedulingTotal: 0,
      sampleData: [],
      sampleTotal: 0,
      form: {
        sampleCode: "",
        dispatchId: "", // 实验调度id
        samplingCode: "", // 取样单编号
        status: 1, // 状态:1=已发送待提交
        samplingRecordOperations: [], // 取样操作记录集合
        remark: "", // 备注,json存储
      },
      rules: {
      },
      userRole: '', // 修改初始值为空字符串
      // 化验师相关数据
      pendingSamples: [],
      pendingSamplesTotal: 0,
      receivedSamples: [],
      receivedSamplesTotal: 0,
      selectedSamples: [],
      // 状态映射表
      statusTypeMap: {
        "-1": "info",
        "1": "warning",
        "2": "success",
        "3": "info"
      },
      statusTextMap: {
        "-1": "草稿箱",
        "1": "待确认",
        "2": "已确认",
        "3": "已封存"
      },
      // 页面类型:add-新增,edit-编辑,detail-详情
      pageType: 'add',
    };
  },
  created() {
    const userInfo = JSON.parse(sessionStorage.getItem('userInfo') || '{}');
    this.userRole = userInfo.roleType || '';
 
    // 获取路由参数
    const { id, type } = this.$route.query;
    if (id) {
      this.pageType = type || 'detail';
      this.getDetailData(id);
    }
  },
  computed: {
    isEngineer() {
      return this.userRole == '3'; // 工艺工程师
    },
    isAssayer() {
      return this.userRole == '4'; // 化验师
    },
  },
  methods: {
    // 获取详情数据
    async getDetailData(id) {
      try {
        const res = await getDetail({ id });
        if (res) {
          const detail = res;
          console.log('获取到的详情数据:', detail);
          
          // 设置表单数据
          this.form = {
            ...this.form,
            ...detail,
            dispatchId: detail.dispatchId,
            sampleCode: detail.samplingCode,
          };
          
          // 设置实验调度数据
          if (detail.experimentDispatch) {
            this.schedulingData = [detail.experimentDispatch];
          }
 
          // 设置取样操作记录
          if (detail.samplingRecordOperations && detail.samplingRecordOperations.length > 0) {
            console.log('原始取样操作记录:', detail.samplingRecordOperations);
            
            // 如果是化验师角色,需要将数据分为待接收和已接收
            if (this.isAssayer) {
              // 确保status是字符串类型
              this.pendingSamples = detail.samplingRecordOperations
                .filter(item => {
                  const status = String(item.status);
                  console.log('过滤待接收样品:', item.id, status);
                  return status === '2';
                })
                .map(item => ({
                  ...item,
                  status: String(item.status)
                }));
              console.log('处理后的待接收样品:', this.pendingSamples);
              this.pendingSamplesTotal = this.pendingSamples.length;
              
              this.receivedSamples = detail.samplingRecordOperations
                .filter(item => String(item.status) === '3')
                .map(item => ({
                  ...item,
                  status: String(item.status)
                }));
              this.receivedSamplesTotal = this.receivedSamples.length;
            } else {
              // 工程师角色保持原有逻辑
              this.sampleData = detail.samplingRecordOperations.map((item, index) => ({
                ...item,
                index: index + 1,
                status: String(item.status)
              }));
            }
          }
 
          // 如果是详情模式,禁用所有输入
          if (this.pageType == 'detail') {
            this.$nextTick(() => {
              const inputs = document.querySelectorAll('input, textarea, select');
              inputs.forEach(input => {
                input.disabled = true;
              });
            });
          }
        }
      } catch (error) {
        console.error('获取详情失败:', error);
        this.$message.error('获取详情失败,请重试');
      }
    },
    handleAddTime(processTime) {
      const newRow = {
        index: this.sampleData.length + 1,
        processTime,
        samplingName: "",
        sampleCode: "",
        temperature: "",
        samplePh: "",
        waterAddition: "",
        addAuxiliaryOne: "",
        addAuxiliaryTwo: "",
        addAuxiliaryThree: "",
        addAuxiliaryFour: "",
        addAuxiliaryFive: "",
        addAuxiliarySix: "",
        addAuxiliarySeven: "",
        addAuxiliaryEight: "",
        addAuxiliaryNine: "",
        addAuxiliaryTen: "",
        sampleAmount: "",
        pictures: "",
        handlePersonId: "",
        status: 1 // 1=待发送
      };
      this.sampleData.push(newRow);
      this.$message.success("添加工艺时间成功");
    },
    handleSave() {
      // 验证是否选择了实验调度
      if (!this.schedulingData || this.schedulingData.length == 0) {
        this.$message.warning('请选择所属实验调度');
        return;
      }
 
      // 验证是否有取样操作记录
      if (!this.sampleData || this.sampleData.length == 0) {
        this.$message.warning('请至少添加一条取样操作记录');
        return;
      }
 
      this.$refs.form.validate(async (valid) => {
        if (valid) {
          try {
            // 获取当前用户信息
            const userInfo = JSON.parse(sessionStorage.getItem('userInfo') || '{}');
            
            // 构建提交数据
            const submitData = {
              ...this.form,
              dispatchId: this.schedulingData[0].id,
              status: 1, // 正常保存状态为1
              samplingRecordOperations: this.sampleData.map(item => ({
                ...item,
                handlePersonId: userInfo.userId,
                status: 1 // 1=待发送
              })),
              remark: this.form.remark,
          samplingCode: this.form.sampleCode,
          id: this.form.id,
            };
 
            // 打印提交数据
            console.log('保存提交数据:',submitData);
 
            let res;
            if (this.pageType == 'edit') {
              // 编辑模式调用update接口
              res = await update(submitData);
            } else {
              // 新增模式调用add接口
              res = await add(submitData);
            }
 
            if (res.code == 200) {
              this.$message.success(this.pageType == 'edit' ? '编辑成功' : '保存成功');
              this.$router.go(-1);
            } else {
              this.$message.error(res.msg || (this.pageType == 'edit' ? '编辑失败' : '保存失败'));
            }
          } catch (error) {
            console.error(this.pageType == 'edit' ? '编辑失败:' : '保存失败:', error);
            this.$message.error(this.pageType == 'edit' ? '编辑失败,请重试' : '保存失败,请重试');
          }
        }
      });
    },
    // 添加存草稿方法
    async handleSaveDraft() {
      try {
        // 获取当前用户信息
        const userInfo = JSON.parse(sessionStorage.getItem('userInfo') || '{}');
        
        // 构建提交数据
        const submitData = {
          dispatchId: this.schedulingData?.[0]?.id || '',
          status: -1, // 存草稿状态为-1
          samplingRecordOperations: (this.sampleData || []).map(item => ({
            ...item,
            handlePersonId: userInfo.userId,
            status: 1 // 1=待发送
          })),
          remark: this.form.remark,
          samplingCode: this.form.sampleCode,
          id: this.form.id,
        };
 
        // 打印提交数据
        console.log('草稿提交数据:', submitData);
 
        let res;
        if (this.pageType == 'edit') {
          // 编辑模式调用update接口
          res = await update(submitData);
        } else {
          // 新增模式调用add接口
          res = await add(submitData);
        }
 
        if (res.code == 200) {
          this.$message.success(this.pageType == 'edit' ? '草稿保存成功' : '存草稿成功');
          this.$router.go(-1);
        } else {
          this.$message.error(res.msg || (this.pageType == 'edit' ? '草稿保存失败' : '存草稿失败'));
        }
      } catch (error) {
        console.error(this.pageType == 'edit' ? '草稿保存失败:' : '存草稿失败:', error);
        this.$message.error(this.pageType == 'edit' ? '草稿保存失败,请重试' : '存草稿失败,请重试');
      }
    },
    handlePendingSelectionChange(selection) {
      console.log("pending selection change:", selection);
      console.log("pending samples data:", this.pendingSamples);
      this.selectedSamples = selection;
      // 强制更新视图
      this.$nextTick(() => {
        this.$forceUpdate();
      });
    },
    handleReceive(row) {
      // 清空之前的选择
      this.selectedSamples = [];
      // 设置当前行为选中状态
      this.selectedSamples = [row];
      this.showReceiveConfirm = true;
    },
    handleBatchReceive() {
      if (this.selectedSamples.length == 0) {
        this.$message.warning("请先选择要接收的样品");
        return;
      }
      this.showReceiveConfirm = true;
    },
    confirmReceive(signature) {
      // 获取选中样品的ID并拼接
      const recordOperationIds = this.selectedSamples.map(item => item.id).join(',');
      
      // 调用批量收样接口
      batchCollectSamples({
        receiptsSign: signature,
        recordOperationId: recordOperationIds
      }).then(res => {
        if (res.code == 200) {
          this.$message.success(`成功接收 ${this.selectedSamples.length} 个样品`);
          // 重新获取详情数据
          this.getDetailData(this.form.id);
        } else {
          this.$message.error(res.msg || '收样失败');
        }
      }).catch(error => {
        console.error('收样失败:', error);
        this.$message.error('收样失败,请重试');
      }).finally(() => {
        // 清空选择并关闭弹窗
        this.selectedSamples = [];
        this.showReceiveConfirm = false;
      });
    },
    getStatusType(status) {
      return this.statusTypeMap[status] || 'info';
    },
    getStatusText(status) {
      return this.statusTextMap[status] || '未知状态';
    },
    handleSchedulingClose() {
      this.showScheduling = false;
    },
    handleSchedulingSubmit(data) {
      this.schedulingData = data || [];
      
    },
    isSelectable(row) {
      console.log('isSelectable row:', row);
      console.log('row status:', row.status, typeof row.status);
      const result = String(row.status) === '2';
      console.log('isSelectable result:', result);
      return result;
    },
  },
};
</script>
 
<style lang="less" scoped>
.header-title-left {
  display: flex;
  align-items: center;
  gap: 13px;
  margin-bottom: 20px;
 
  .el-button {
    margin-left: 0;
  }
 
  img {
    width: 12px;
    height: 19px;
  }
 
  div {
    flex-shrink: 0;
    font-weight: bold;
    font-size: 18px;
    color: #222222;
    line-height: 27px;
    font-family: "Source Han Sans CN Bold Bold";
 
    &:before {
      content: "*";
      color: #f56c6c;
      margin-right: 4px;
    }
  }
 
  span {
    flex-shrink: 0;
    font-weight: bold;
    font-size: 18px;
    color: #222222;
    line-height: 27px;
    font-family: "Source Han Sans CN Bold Bold";
  }
}
 
.add-project-footer {
  margin-top: 43px;
 
  button {
    width: 220px;
  }
 
  .save-btn {
    margin-right: 20px;
  }
}
 
.assayer-section {
  .sample-code {
    font-family: PingFangSC, PingFang SC;
    font-weight: 400;
    font-size: 14px;
    color: rgba(0, 0, 0, 0.88);
    margin: 20px 0;
  }
 
  .sub-title {
    font-size: 16px;
    font-weight: 500;
    color: #333;
    margin: 20px 0;
    display: inline-block;
  }
 
  .batch-receive {
    float: right;
    margin-bottom: 16px;
  }
 
  .pending-samples,
  .received-samples {
    // margin-top: 20px;
  }
}
</style>