zouyu
2023-11-17 d8ac6057eaad648687699e25a575f3b7b8c1b102
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
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
<template>
  <div style="padding:0px 14px;height: 100%;overflow: auto;">
    <div class="product-record-div">
      <div class="product-record-div-left">
        <div class="product-record-list-header">
          <div>
            <el-divider class="pane-divider" direction="vertical"></el-divider>
            <span style="font-size:14px;font-weight:bold;margin-right:10px;"
              >生产记录</span
            >
            <el-checkbox
              style="margin-right:15px;"
              v-model="isDutyFilter"
              @change="getProductRecords"
              >按班次</el-checkbox
            >
            <el-checkbox v-model="isTaskFilter" @change="getProductRecords"
              >按工单</el-checkbox
            >
            <el-checkbox
              v-model="isWorkstationFilter"
              @change="getProductRecords"
              >按工作站</el-checkbox
            >
          </div>
          <!-- <div>
            <el-button
              class="record-add-btn"
              type="primary"
              icon="product-record-btn-add"
              @click="addProductRecord()"
            >
              新增
            </el-button>
          </div> -->
        </div>
        <div>
          <el-date-picker
            v-model="createDateRange"
            type="daterange"
            range-separator="至"
            start-placeholder="开始日期"
            end-placeholder="结束日期"
            value-format="yyyy-MM-dd"
            style="width:80%"
            @change="getProductRecords"
          >
          </el-date-picker>
        </div>
        <div class="product-record-list-content">
          <el-tabs v-model="currTemplateType" @tab-click="handleClick">
            <el-tab-pane
              v-for="(item, index) in templateTypeList"
              :key="item.id"
              :label="item.templateTypeName"
              :name="item.templateTypeName"
            >
              <div class="button">
                <div>
                  <el-button
                    class="record-add-btn"
                    type="primary"
                    icon="product-record-btn-add"
                    @click="addProductRecord()"
                  >
                    新增
                  </el-button>
                </div>
                <div>
                  <el-button
                    class="record-del-btn"
                    type="danger"
                    icon="product-record-btn-add"
                    @click="delAlls"
                  >
                    删除
                  </el-button>
                </div>
              </div>
              <el-table
                ref="productRecordTable"
                height="717px"
                :data="productRecords"
                :highlight-current-row="true"
                :header-cell-style="productRecordTableHeaderCellStyle"
                :row-class-name="productRecordTableRowClassName"
                class="product-record-table"
                @row-click="handleProductRecordChange"
                @select="select"
                @select-all="selectAll"
              >
                <el-table-column type="selection"></el-table-column>
 
                <el-table-column
                  label="模板名称"
                  prop="templateName"
                  align="center"
                  :show-overflow-tooltip="true"
                >
                  <template slot="header" slot-scope="scope">
                    <div style="line-height: 14px;">模板名称</div>
                    <div class="th" @click.stop>
                      <template>
                        <el-input
                          clearable
                          v-model="searchContent.templateName"
                          placeholder="模板名称"
                          style="width: 100%"
                          @input="getSearch"
                        >
                        </el-input>
                      </template>
                    </div>
                  </template>
                </el-table-column>
                <el-table-column
                  label="SN号"
                  prop="outBatchNo"
                  align="center"
                  :show-overflow-tooltip="true"
                >
                  <template slot="header" slot-scope="scope">
                    <div style="line-height: 14px;">SN号</div>
                    <div class="th" @click.stop>
                      <template>
                        <el-input
                          type="text"
                          placeholder="SN号"
                          v-model="searchContent.outBatchNo"
                          clearable
                          size="mini"
                          @input="getSearch"
                        ></el-input>
                      </template>
                    </div>
                  </template>
                </el-table-column>
 
                <el-table-column
                  label="记录时间"
                  prop="createTime"
                  align="center"
                  :show-overflow-tooltip="true"
                >
                  <!-- <template slot="header" slot-scope="scope">
                    <div style="line-height: 14px;">记录时间</div>
                    <div class="th" @click.stop>
                      <template>
                        <el-input
                          type="text"
                          placeholder="记录时间"
                          v-model="searchContent.createTime"
                          clearable
                          size="mini"
                          @input="getSearch"
                        ></el-input>
                      </template>
                    </div>
                  </template> -->
                </el-table-column>
                <el-table-column
                  label="记录人"
                  prop="createUser"
                  align="center"
                  :show-overflow-tooltip="true"
                >
                  <template slot="header" slot-scope="scope">
                    <div style="line-height: 14px;">记录人</div>
                    <div class="th" @click.stop>
                      <template>
                        <el-input
                          type="text"
                          placeholder="记录人"
                          v-model="searchContent.createUser"
                          clearable
                          size="mini"
                          @input="getSearch"
                        ></el-input>
                      </template>
                    </div>
                  </template>
                </el-table-column>
                <el-table-column align="center" width="85px" fixed="right">
                  <template slot-scope="scope">
                    <el-tooltip
                      effect="dark"
                      content="删除"
                      placement="top-start"
                    >
                      <el-button
                        type="text"
                        size="small"
                        class="red-but"
                        @click.stop="delProductrecord(scope.$index, scope.row)"
                      >
                        删除
                      </el-button>
                    </el-tooltip>
                  </template>
                </el-table-column>
              </el-table>
            </el-tab-pane>
          </el-tabs>
        </div>
      </div>
      <div class="product-record-div-right">
        <div class="product-record-info-header">
          <div>
            <el-divider class="pane-divider" direction="vertical"></el-divider>
            <span style="font-size:14px;font-weight:bold">记录详情</span>
          </div>
          <div>
            <el-button
              class="record-edit-btn"
              type="primary"
              icon="product-record-btn-edit"
              @click="updateProductRecord()"
            >
              保存
            </el-button>
          </div>
        </div>
        <div style="height:800px;">
          <el-tabs type="card" ref="tabs">
            <el-tab-pane label="参数">
              <el-table
                ref="productRecordInfoTable"
                :data="paramValues"
                height="744px"
                :row-class-name="productRecordInfoTableRowClassName"
                class="product-record-table"
              >
                <el-table-column
                  prop="code"
                  label="编号"
                  align="center"
                ></el-table-column>
                <el-table-column
                  prop="parameterItem"
                  label="名称"
                  align="center"
                >
                  <template slot-scope="scope"
                    ><span>
                      {{ scope.row.parameterItem }}({{ scope.row.unit }})</span
                    >
                  </template>
                </el-table-column>
                <!--<el-table-column
                  prop="type"
                  label="参数类型"
                  align="center"
                  :formatter="getParam"
                ></el-table-column>-->
                <el-table-column prop="paramValue" label="值" align="center">
                  <template slot-scope="scope">
                    <!-- <el-input v-model="scope.row.paramValue" placeholder="值">
                    </el-input> -->
                    <el-input
                      v-model="scope.row.paramValue"
                      placeholder="值"
                      v-if="scope.row.type != 2"
                      :ref="'reference_' + scope.$index"
                      @keyup.enter.native="nextFocus(scope.$index)"
                    ></el-input>
                    <el-select
                      v-if="scope.row.type == 2"
                      :ref="'reference_' + scope.$index"
                      v-model="scope.row.paramValue"
                      style="width:100%"
                    >
                      <el-option
                        v-for="item in scope.row.sysDictItemList"
                        :key="item.value"
                        :label="item.label"
                        :value="item.value"
                      />
                    </el-select>
                  </template>
                </el-table-column>
              </el-table>
            </el-tab-pane>
            <el-tab-pane label="附件">
              <el-upload
                ref="upload"
                action="/mes/operationTask/upload"
                :headers="headers"
                :on-preview="handlePreview"
                :on-remove="handleRemove"
                :on-change="change"
                :file-list="fileList"
                :auto-upload="false"
                list-type="picture"
              ></el-upload>
            </el-tab-pane>
          </el-tabs>
        </div>
      </div>
    </div>
    <productRecordFormDialog
      :currshowlist.sync="showProductRecordForm"
      :currOperateTask="currOperateTask"
      :currentDutyRecord="currentDutyRecord"
      :workstationId="workstationId"
      :currTemplateType="currTemplateType"
      :createDateRange="createDateRange"
      @saveProductRecordSucess="productRecordSucessCallback"
    />
  </div>
</template>
<style lang="scss" scoped>
.button {
  display: flex;
  margin-bottom: 10px;
  div {
    margin-right: 10px;
  }
}
.product-record-div {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
 
.product-record-div-left {
  width: 40%;
}
 
.product-record-div-right {
  width: 58%;
}
 
.product-record-list-header {
  margin-top: 20px;
  margin-bottom: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
 
.product-record-list-header >>> .product-record-btn-add {
  background: url('/img/workbench/icon_xz1.png') center center no-repeat;
  background-size: cover;
}
 
.product-record-list-header >>> .product-record-btn-add:before {
  content: '增';
  font-size: 14px;
  visibility: hidden;
}
 
.pane-divider {
  width: 4px;
  background-color: #4283ee;
}
 
.record-add-btn {
  background-image: -webkit-linear-gradient(139deg, #5f6eef 0%, #2783ff 100%);
  background-image: -moz-linear-gradient(139deg, #5f6eef 0%, #2783ff 100%);
  background-image: linear-gradient(139deg, #5f6eef 0%, #2783ff 100%);
  color: #fff;
  border-color: #fbecec;
  border-radius: 15px;
  padding: 6px 15px;
}
.record-del-btn {
  color: #fff;
  border-color: rgb(240, 108, 109);
  border-radius: 15px;
  padding: 6px 15px;
}
.record-add-btn >>> span {
  margin-left: 3px;
}
 
.product-record-list-content {
  height: 772px;
}
 
.product-record-table >>> .stripe-row {
  background: #f6f9fe;
}
 
.product-record-table >>> td {
  padding: 3px 0px;
}
 
.product-record-table >>> .el-button {
  padding: 5px 0px;
}
 
.product-record-table >>> .el-input .el-input__inner {
  height: 24px;
  line-height: 24px;
}
 
.product-record-info-header {
  margin-top: 20px;
  margin-bottom: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
 
.product-record-info-header >>> .product-record-btn-edit {
  background: url('/img/workbench/icon_xg.png') center center no-repeat;
  background-size: cover;
}
 
.product-record-info-header >>> .product-record-btn-edit:before {
  content: '修';
  font-size: 14px;
  visibility: hidden;
}
 
.record-edit-btn {
  background-image: -webkit-linear-gradient(139deg, #ff3f20 0%, #f77339 100%);
  background-image: -moz-linear-gradient(139deg, #ff3f20 0%, #f77339 100%);
  background-image: linear-gradient(139deg, #ff3f20 0%, #f77339 100%);
  color: #fff;
  border-color: #fbecec;
  border-radius: 15px;
  padding: 6px 15px;
}
 
.record-edit-btn >>> span {
  margin-left: 3px;
}
 
.red-but.is-disabled {
  color: #fab6b6;
}
 
.red-but {
  color: red;
}
 
.blue-but.is-disabled {
  color: #aacfff;
}
 
.blue-but {
  color: #006eff;
}
</style>
<script>
import {
  getTemplateRecord,
  getTemplateParam,
  deleteTemplateRecord,
  delAll,
  UpdateTemplateRecord as updateProductRecord
} from '@/api/plan/operationtask'
import { remote } from '@/api/admin/dict'
import { getStore } from '../../../util/store'
import productRecordFormDialog from './product-record-form.vue'
import { removeFile } from '../../../api/plan/operationtask'
 
export default {
  components: {
    productRecordFormDialog
  },
  props: {
    currOperateTask: {
      type: Object,
      default: () => {
        return {}
      }
    },
    currentDutyRecord: {
      type: Object,
      default: () => {
        return {}
      }
    },
    workstationId: {
      type: Number
    },
    templateTypeList: {
      type: Array,
      default: () => {
        return []
      }
    }
  },
  data() {
    return {
      fileList: [],
      headers: {
        Authorization: 'Bearer ' + getStore({ name: 'access_token' })
      },
      paramValues: [],
      currProductRecordId: null,
      typeOptions: [],
      productRecords: [],
      showProductRecordForm: false,
      isDutyFilter: true,
      isTaskFilter: true,
      isWorkstationFilter: true,
      currTemplateType: null,
      createDateRange: [],
      searchContent: {
        templateName: '',
        outBatchNo: '',
        createTime: '',
        createUser: ''
      },
      idList: []
    }
  },
  mounted() {
    this.getParamType()
  },
  methods: {
    async getSearch(val) {
      let templateJson
      if (this.createDateRange != null && this.createDateRange !== '') {
        templateJson = {
          createUser: this.searchContent.createUser,
          createTime: this.searchContent.createTime,
          outBatchNo: this.searchContent.outBatchNo,
          templateName: this.searchContent.templateName,
          operationTaskId: this.isTaskFilter ? this.currOperateTask.id : null,
          dutyRecordId: this.isDutyFilter ? this.currentDutyRecord.id : null,
          workstationId: this.isWorkstationFilter ? this.workstationId : null,
          templateType: this.currTemplateType,
          startTime: this.createDateRange[0],
          endTime: this.createDateRange[1]
        }
      } else {
        templateJson = {
          createUser: this.searchContent.createUser,
          createTime: this.searchContent.createTime,
          outBatchNo: this.searchContent.outBatchNo,
          templateName: this.searchContent.templateName,
          operationTaskId: this.isTaskFilter ? this.currOperateTask.id : null,
          dutyRecordId: this.isDutyFilter ? this.currentDutyRecord.id : null,
          workstationId: this.isWorkstationFilter ? this.workstationId : null,
          templateType: this.currTemplateType
        }
      }
 
      getTemplateRecord(templateJson).then((response) => {
        this.fileList = []
        this.paramValues = []
        this.currProductRecordId = null
        if (response.data.code === 0) {
          this.productRecords = response.data.data
        } else {
          this.productRecords = []
        }
      })
      // const res = await getTemplateRecord({
      //   createUser: this.searchContent.createUser,
      //   createTime: this.searchContent.createTime,
      //   outBatchNo: this.searchContent.outBatchNo,
      //   templateName: this.searchContent.templateName,
      //   templateType: this.currTemplateType,
      //   operationTaskId: this.isTaskFilter ? this.currOperateTask.id : null,
      //   dutyRecordId: this.isDutyFilter ? this.currentDutyRecord.id : null,
      //   workstationId: this.isWorkstationFilter ? this.workstationId : null
      // })
      // console.log(val, res)
      // this.productRecords = res.data.data
    },
    // 多选删除
    select(selection, row) {
      console.log(selection, row)
      const arr = []
      // this.idList = []
      selection.forEach((item) => {
        arr.push(item.id)
      })
      this.idList = [...new Set(arr)]
      console.log(this.idList)
    },
    // 全选删除
    selectAll(selection) {
      console.log(selection)
      const arr = []
      // this.idList = []
      selection.forEach((item) => {
        arr.push(item.id)
      })
      this.idList = [...new Set(arr)]
      console.log(this.idList)
    },
    async delAlls() {
      let isContinue = true
      if (this.idList.length >= 1) {
        await this.$confirm(
          `已选${this.idList.length}条记录,是否继续`,
          '提示',
          {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            type: 'warning'
          }
        )
          .then(async () => {
            isContinue = true
            // this.idList = []
            const res = await delAll(this.idList)
            console.log(res)
            this.getProductRecords()
            this.$message.success('删除成功!')
            this.idList = []
            this.$refs.productRecordInfoTable.clearSelection()
          })
          .catch(() => {
            isContinue = false
          })
      } else {
        await this.$confirm('请选中数据', {
          confirmButtonText: '确定',
          type: 'warning'
        })
      }
    },
    productRecordTableHeaderCellStyle({ row, column, rowIndex, columnIndex }) {
      let headerStyle = 'background:#599ef4;color:#fff;'
      if (columnIndex === 0) {
        headerStyle += 'border-radius: 6px 0px 0px 0px;'
      } else if (columnIndex === 3) {
        headerStyle += 'border-radius: 0px 6px 0px 0px;'
      }
      return headerStyle
    },
    productRecordTableRowClassName({ row, rowIndex }) {
      if (rowIndex % 2 === 1) {
        return 'stripe-row'
      } else {
        return ''
      }
    },
    productRecordInfoTableRowClassName({ row, rowIndex }) {
      if (rowIndex % 2 === 1) {
        return 'stripe-row'
      } else {
        return ''
      }
    },
    // 新增生产记录成功后的回调,刷新生产记录列表
    productRecordSucessCallback(val) {
      this.getProductRecords()
    },
    handleRemove(file, fileList) {
      removeFile(file).then((response) => {
        if (response.data.code === 0) {
          this.$message.success('图片删除成功')
        }
      })
    },
    change(file, fileList) {},
    handlePreview(file) {
      window.open(file.url)
    },
    // 获取生产记录列表
    getProductRecords() {
      console.log(this.createDateRange)
      let templateJson
      if (this.createDateRange != null && this.createDateRange !== '') {
        templateJson = {
          operationTaskId: this.isTaskFilter ? this.currOperateTask.id : null,
          dutyRecordId: this.isDutyFilter ? this.currentDutyRecord.id : null,
          workstationId: this.isWorkstationFilter ? this.workstationId : null,
          templateType: this.currTemplateType,
          startTime: this.createDateRange[0],
          endTime: this.createDateRange[1]
        }
      } else {
        templateJson = {
          operationTaskId: this.isTaskFilter ? this.currOperateTask.id : null,
          dutyRecordId: this.isDutyFilter ? this.currentDutyRecord.id : null,
          workstationId: this.isWorkstationFilter ? this.workstationId : null,
          templateType: this.currTemplateType
        }
      }
 
      getTemplateRecord(templateJson).then((response) => {
        this.fileList = []
        this.paramValues = []
        this.currProductRecordId = null
        if (response.data.code === 0) {
          this.productRecords = response.data.data
        } else {
          this.productRecords = []
        }
      })
    },
    // 在页面添加一个新的点检记录或原始记录
    addProductRecord() {
      if (this.currentDutyRecord.shiftId == null) {
        this.$message.error('请完善班次信息')
      } else {
        this.showProductRecordForm = true
      }
    },
    // 点击某个生产记录触发
    handleProductRecordChange(row) {
      this.$refs.productRecordTable.forEach((item) => {
        item.toggleRowSelection(row)
      })
      const index = this.idList.indexOf(row.id)
      console.log(index)
      if (index >= 0) {
        this.idList.splice(index, 1)
      } else {
        this.idList.push(row.id)
      }
      console.log(this.idList)
      this.currProductRecordId = row.id
      this.paramValues = []
      var productRecordJson = {
        operationTaskRecordId: row.id
      }
      getTemplateParam(productRecordJson).then((response) => {
        if (response.data.code === 0) {
          this.paramValues = response.data.data
          if (response.data.data.length > 0) {
            const attachments =
              response.data.data[0].operationTaskAttachmentList
            // 渲染附件
            this.fileList = []
            if (attachments != null && attachments.length > 0) {
              let attachment
              let fileEl
              for (let i = 0; i < attachments.length; i++) {
                attachment = attachments[i]
                fileEl = {}
                fileEl.name = attachment.original
                fileEl.url = attachment.url
                fileEl.id = attachment.id
                fileEl.fileName = attachment.fileName
                this.fileList.push(fileEl)
              }
            }
          }
        } else {
          this.paramValues = []
        }
      })
    },
    // 回车换行
    nextFocus(index) {
      index++
      this.$refs['reference_' + index].focus()
      // console.log(this.i)
    },
    // 删除某条生产记录
    delProductrecord(index, row) {
      var productRecordJson = {
        id: row.id
      }
      deleteTemplateRecord(productRecordJson)
        .then((response) => {
          if (response.data.code === 0) {
            this.productRecords.splice(index, 1)
            this.currProductRecordId = null
            this.paramValues = []
            this.fileList = []
            this.$message.success('删除成功!')
          } else {
            this.$message.error('删除失败!')
          }
        })
        .catch((error) => {
          console.log('生产记录删除异常')
        })
    },
    // 修改参数值
    async updateProductRecord() {
      // var productRecord = {}
      if (this.currProductRecordId) {
        let isContinue = true
        if (this.idList.length > 1) {
          await this.$confirm(
            `已选${this.idList.length}条记录,是否继续`,
            '提示',
            {
              confirmButtonText: '确定',
              cancelButtonText: '取消',
              type: 'warning'
            }
          )
            .then(() => {
              isContinue = true
              // this.idList = []
            })
            .catch(() => {
              isContinue = false
            })
        }
        if (!isContinue) {
          return
        }
        const currProductRecord = this.productRecords.find(
          (item) => item.id === this.currProductRecordId
        )
        // var formdata = new FormData()
        var paramValueArray = []
        if (this.paramValues != null && this.paramValues.length > 0) {
          // formdata.append('id', currProductRecord.id)
          // formdata.append('operationTaskId', currProductRecord.operationTaskId)
          // formdata.append(
          //   'operationTemplateId',
          //   currProductRecord.operationTemplateId
          // )
          // formdata.append('dutyRecordId', currProductRecord.dutyRecordId)
          // formdata.append('file', this.fileList)
          var paramValue
          for (var i = 0; i < this.paramValues.length; i++) {
            paramValue = {
              id: this.paramValues[i].id,
              code: this.paramValues[i].code,
              parameterItem: this.paramValues[i].parameterItem,
              type: this.paramValues[i].type,
              unit: this.paramValues[i].unit,
              paramValue: this.paramValues[i].paramValue,
              operationTemplateId: currProductRecord.operationTemplateId,
              operationTaskRecordId: currProductRecord.id,
              operationTaskId: currProductRecord.operationTaskId,
              technologyOperationParamId: this.paramValues[i]
                .technologyOperationParamId
            }
            paramValueArray.push(paramValue)
          }
          const obj = {
            idList: this.idList,
            operationTaskParamList: JSON.stringify(paramValueArray)
          }
          // 先转成jsonarray,在把jsonarray转string,最终答应[{},{}]
          // formdata.append(
          //   'operationTaskParamList',
          //   JSON.stringify(paramValueArray)
          // )
          updateProductRecord(obj).then((response) => {
            console.log(this.idList)
            if (response.data.code === 0) {
              this.$message.success('修改成功')
              console.log(this.$refs.productRecordTable)
              this.$refs.productRecordTable.forEach((item) => {
                item.clearSelection()
              })
              this.idList = []
            } else {
              this.$message.error('修改失败')
            }
          })
        }
      } else {
        this.$message.error('请先选中生产记录')
      }
    },
    // 获取工序参数类型
    getParamType() {
      remote('technology_param').then((response) => {
        if (response.data.code === 0) {
          this.typeOptions = response.data.data
        } else {
          this.typeOptions = []
        }
      })
    },
    // 表格字段格式化
    getParam(row, column, cellValue) {
      for (let i = 0, len = this.typeOptions.length; i < len; i++) {
        if (cellValue == this.typeOptions[i].value) {
          return this.typeOptions[i].label
        }
      }
    },
    // 生产模板切换
    handleClick(tab, event) {
      // 清空数据
      this.currProductRecordId = null
      this.paramValues = []
      this.fileList = []
      this.idList = []
      this.$refs.productRecordTable.forEach((item) => {
        item.clearSelection()
      })
      // 查询生产记录
      this.getProductRecords()
    }
  },
  watch: {
    currOperateTask: {
      handler(newValue, oldValue) {
        // 清空数据
        this.currProductRecordId = null
        this.paramValues = []
        this.fileList = []
        this.$nextTick(() => {
          if (newValue.id) {
            this.currTemplateType = this.templateTypeList[0].templateTypeName
            // 查询生产记录
            this.getProductRecords()
          } else {
            this.productRecords = []
          }
        })
      },
      deep: true
    },
    'currentDutyRecord.id'(val) {
      this.$nextTick(() => {
        this.currTemplateType = this.templateTypeList[0].templateTypeName
        this.getProductRecords()
      })
    },
    workstationId() {
      this.$nextTick(() => {
        this.currTemplateType = this.templateTypeList[0].templateTypeName
        this.getProductRecords()
      })
    }
  }
}
</script>