Fixiaobai
2023-10-13 e8308ddac0ba4a1f406e8f63d7e6b6f2541cb770
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
<template>
  <div>
    <el-alert
      v-if="!operationTasks || operationTasks.length == 0"
      title="还没有工单下发到此机台!"
      type="warning"
      effect="dark"
    >
    </el-alert>
    <el-card
      v-for="(item, index) in operationTasks"
      @click.native="setCheckFlag(item)"
      shadow="hover"
      :key="index"
      :class="['task-item', item.checkFlag ? 'card-checked' : 'card-unchecked']"
    >
      <img class="selectedImg" src="/img/workbench/icon_selected.png" />
      <div class="header">
        <div>工单号:{{ item.taskNo }}</div>
        <div>计划号:{{ item.mpsNo }}</div>
        <div
          :class="[
            'status-change-div',
            item.checkFlag ? 'card-checked-status' : 'card-status'
          ]"
        >
          <el-select
            v-if="permissions.product_operationTask_state"
            v-model="item.statusAction"
            placeholder="功能菜单"
            @change="
              changeTaskState(item.statusAction, item.status, item.id, item)
            "
          >
            <el-option
              v-for="ele in statusActions"
              :key="ele.value"
              :label="ele.label"
              :value="ele.value"
              :disabled="ele.disabled"
            >
            </el-option>
          </el-select>
        </div>
      </div>
      <div class="body">
        <div class="row">
          <div class="l">零件名称:</div>
          <div class="r">{{ item.partName }}</div>
        </div>
        <div class="row">
          <div class="l">零件号:</div>
          <div class="r">{{ item.partNo }}</div>
        </div>
        <div class="row">
          <div class="l">成品:</div>
          <div class="r">{{ item.productName }}</div>
        </div>
        <div class="row">
          <div class="l">计划完成时间:</div>
          <div class="r">{{ item.planFinishDay }}</div>
        </div>
      </div>
 
      <el-progress
        class="task-progress"
        :text-inside="true"
        :stroke-width="20"
        :percentage="
          Number((item.completedQuantity / item.plannedQuantity).toFixed(2)) *
            100 >
          100
            ? 100
            : Number(
                (item.completedQuantity / item.plannedQuantity).toFixed(2)
              ) * 100
        "
        :format="formatPercentage(item.completedQuantity, item.plannedQuantity)"
      ></el-progress>
    </el-card>
  </div>
</template>
<style lang="scss" scoped>
@mixin flex-row {
  display: flex;
  flex-direction: row;
  align-items: center;
}
@mixin flex-col {
  display: flex;
  flex-direction: column;
  align-items: center;
}
.task-item {
  width: 100%;
  border-radius: 12px;
  cursor: pointer;
  position: relative;
  box-shadow: 1px 2px 24px 1px rgba(4, 0, 0, 0.14);
  & + .task-item {
    margin-top: 10px;
  }
  &.card-checked {
    // color: white;
    background-image: -webkit-linear-gradient(
        90deg,
        rgba(12, 149, 255, 0.7) 0%,
        rgba(38, 176, 254, 0.8) 34%,
        rgba(12, 149, 255, 0.8) 100%
      ),
      -webkit-linear-gradient(#5a97fa, #5a97fa);
    background-image: -moz-linear-gradient(
        90deg,
        rgba(12, 149, 255, 0.7) 0%,
        rgba(38, 176, 254, 0.8) 34%,
        rgba(12, 149, 255, 0.8) 100%
      ),
      -moz-linear-gradient(#5a97fa, #5a97fa);
    background-image: linear-gradient(
        90deg,
        rgba(12, 149, 255, 0.7) 0%,
        rgba(38, 176, 254, 0.8) 34%,
        rgba(12, 149, 255, 0.8) 100%
      ),
      linear-gradient(#5a97fa, #5a97fa);
    background-blend-mode: normal, normal;
  }
  .selectedImg {
    position: absolute;
    top: 0px;
    right: 0px;
    height: 38px;
    width: 46px;
  }
  .header {
    @include flex-row;
    justify-content: space-between;
    font-weight: bold;
    font-size: 16px;
  }
  .body {
    font-size: 14.5px;
    padding: 5px 0;
    .row {
      @include flex-row;
      align-items: baseline;
      padding: 4px 0;
      &:last-child {
        .l {
          width: 7em;
        }
      }
      .l {
        width: 5em;
      }
      .r {
        flex: 1;
      }
    }
  }
  .task-progress {
    >>> .el-progress-bar__outer .el-progress-bar__innerText {
      font-size: 14px;
    }
  }
  &.card-unchecked {
    .task-progress {
      >>> .el-progress-bar__inner {
        background-image: -webkit-linear-gradient(
            90deg,
            rgba(64, 202, 253, 0.8) 0%,
            rgba(38, 176, 254, 0.8) 34%,
            rgba(12, 149, 255, 0.8) 100%
          ),
          -webkit-linear-gradient(#ffffff, #ffffff);
        background-image: -moz-linear-gradient(
            90deg,
            rgba(64, 202, 253, 0.8) 0%,
            rgba(38, 176, 254, 0.8) 34%,
            rgba(12, 149, 255, 0.8) 100%
          ),
          -moz-linear-gradient(#ffffff, #ffffff);
        background-image: linear-gradient(
            90deg,
            rgba(64, 202, 253, 0.8) 0%,
            rgba(38, 176, 254, 0.8) 34%,
            rgba(12, 149, 255, 0.8) 100%
          ),
          linear-gradient(#ffffff, #ffffff);
        background-blend-mode: normal, normal;
      }
      >>> .el-progress-bar__outer {
        background-color: rgba(97, 143, 245, 0.17);
      }
      >>> .el-progress-bar__outer .el-progress-bar__innerText {
        color: #272fc7;
      }
    }
  }
  &.card-checked {
    color: white;
    .task-progress {
      >>> .el-progress-bar__inner {
        background-color: #fff;
      }
      >>> .el-progress-bar__outer {
        background-color: rgba(255, 255, 255, 0.3);
      }
      >>> .el-progress-bar__outer .el-progress-bar__innerText {
        color: green;
      }
    }
  }
}
.status-change-div {
  width: 20%;
  max-width: 100px;
}
.status-change-div >>> .el-select {
  width: 100%;
}
.status-change-div >>> .el-select .el-input__inner {
  height: 28px;
  line-height: 28px;
  border: 0px;
  color: #fff;
  &::-webkit-input-placeholder {
    color: white;
  }
}
.status-change-div >>> .el-select .el-input__inner .el-input__icon {
  line-height: 28px;
}
.status-change-div >>> .el-select .el-input .el-select__caret::before {
  content: '';
  background: url('/img/workbench/icon_xl1.png') center center no-repeat;
  position: absolute;
  width: 100%;
  height: 100%;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}
.card-checked >>> .el-select .el-input__inner {
  background-color: rgba(20, 44, 93, 0.6);
}
.card-unchecked >>> .el-select .el-input__inner {
  background-color: #3ea1fc;
}
</style>
<script>
import {
  getOperationTask,
  changeBackState,
  changeOperationTaskState,
  getDraftProductOut,
  batchChange
} from '@/api/product/personboard'
import {
  getOperationTaskById,
  selectSubmitState,
  changeSubmitState
} from '@/api/plan/operationtask'
import { mapGetters } from 'vuex'
const task_storage_key = 'OPERATION_TASK_ID'
export default {
  props: {
    workstationId: {
      type: Number
    },
    productSn: {
      type: String
    },
    orderNumber: {
      type: String
    },
    spec: {
      type: String
    },
    outBatchNo: {
      type: String
    },
    mpsNo: {
      type: String
    }
  },
  data() {
    return {
      taskID: null,
      operationTasks: [],
      currOperateTask: {
        id: null,
        taskNo: null,
        technologyName: null,
        technologyRequire: null,
        partName: null,
        manufacturingOrder: null,
        status: null,
        statusDesc: null,
        saleOrder: null,
        custom: null,
        remark: null,
        partId: null,
        partNo: null,
        unit: null,
        operationName: null,
        routingId: null,
        operationId: null,
        discNum: null,
        routingOperationRemark: null,
        mpsNo: null,
        mpsId: null,
        customerName: null,
        productName: null,
        moNo: null,
        reelSpec: null,
        sunit: null,
        customerOrderNo: null
      },
      statusActions: [
        { value: 'start', label: '开始', disabled: false },
        { value: 'over', label: '结束', disabled: false }
      ]
    }
  },
  computed: {
    ...mapGetters(['permissions'])
  },
  created() {
    if (!this.defaultOperationId) {
      const opId = localStorage.getItem(task_storage_key)
      if (opId) {
        this.defaultOperationId = parseInt(opId)
        this.currOperateTask.id = this.defaultOperationId
      }
    }
    this.loadOperateTaskByWorkstation(this.currOperateTask.id)
    if (this.permissions.product_operationTask_state_submit) {
      this.statusActions.push({
        value: 'batchSubmit',
        label: '批量提交',
        disabled: false
      })
    }
  },
  methods: {
    // 点击工单,选中工单
    setCheckFlag(item) {
      if (item.checkFlag) {
        item.checkFlag = false
      } else {
        item.checkFlag = true
      }
      this.changeTask(item)
      this.currentTaskChange(item)
      // 点击工单时,触发事件,当前选中工单信息
      this.$emit('changeCurrOperateTask', this.currOperateTask)
    },
    // 修改各工单选中情况
    changeTask(item) {
      this.operationTasks.forEach(function(el) {
        if (item.id !== el.id) {
          el.checkFlag = false
        }
      })
    },
    // 为当前工单赋值
    currentTaskChange(val) {
      if (val.checkFlag) {
        var operationTask = val
        this.currOperateTask.id = operationTask.id
        this.currOperateTask.taskNo = operationTask.taskNo
        this.currOperateTask.technologyName = operationTask.technologyName
        this.currOperateTask.technologyRequire = operationTask.technologyRequire
        this.currOperateTask.partName = operationTask.partName
        this.currOperateTask.manufacturingOrder =
          operationTask.manufacturingOrder
        this.currOperateTask.status = operationTask.status
        this.currOperateTask.statusDesc = operationTask.statusDesc
        this.currOperateTask.saleOrder = operationTask.saleOrder
        this.currOperateTask.custom = operationTask.custom
        this.currOperateTask.remark = operationTask.remark
        this.currOperateTask.partNo = operationTask.partNo
        this.currOperateTask.partId = operationTask.partId
        this.currOperateTask.unit = operationTask.unit
        this.currOperateTask.operationName = operationTask.operationName
        this.currOperateTask.routingId = operationTask.routingId
        this.currOperateTask.operationId = operationTask.operationId
        this.currOperateTask.partNo = operationTask.partNo
        this.currOperateTask.moNo = operationTask.moNo
        this.currOperateTask.optaskNo = operationTask.optaskNo
        this.currOperateTask.operationName = operationTask.operationName
        this.currOperateTask.plannedQuantity = operationTask.plannedQuantity
        this.currOperateTask.completedQuantity = operationTask.completedQuantity
        this.currOperateTask.priority = operationTask.priority
        this.currOperateTask.unit = operationTask.unit
        this.currOperateTask.plannedStartDate = operationTask.plannedStartDate
        this.currOperateTask.plannedFinishDate = operationTask.plannedFinishDate
        this.currOperateTask.actualStartDate = operationTask.actualStartDate
        this.currOperateTask.actualFinishDate = operationTask.actualFinishDate
        this.currOperateTask.createTime = operationTask.createTime
        this.currOperateTask.discNum = operationTask.discNum
        this.currOperateTask.mpsNo = operationTask.mpsNo
        this.currOperateTask.mpsId = operationTask.mpsId
        this.currOperateTask.customerName = operationTask.customerName
        this.currOperateTask.productName = operationTask.productName
        this.currOperateTask.reelSpec = operationTask.reelSpec
        this.currOperateTask.sunit = operationTask.sunit
        this.currOperateTask.pcoId = operationTask.pcoId
        this.currOperateTask.customerOrderNo = operationTask.customerOrderNo
 
        if (
          operationTask.routingOperationRemark != null &&
          operationTask.routingOperationRemark != ''
        ) {
          let routingOperationRemark = operationTask.routingOperationRemark
          const imgIndex = routingOperationRemark.indexOf('<img')
          if (imgIndex >= 0) {
            routingOperationRemark =
              routingOperationRemark.slice(0, imgIndex + 4) +
              ' id="remarkImg" style="cursor:pointer;" ' +
              routingOperationRemark.slice(imgIndex + 4)
            this.currOperateTask.routingOperationRemark = routingOperationRemark
          } else {
            this.currOperateTask.routingOperationRemark =
              operationTask.routingOperationRemark
          }
        } else {
          this.currOperateTask.routingOperationRemark =
            operationTask.routingOperationRemark
        }
      } else {
        this.initOperateTask()
      }
    },
    // 格式化工单进度内容
    formatProgress(item) {
      return () => {
        return item
      }
    },
    // 更改工单状态
    changeTaskState(statusAction, taskStatus, taskId, currItem) {
      let changeFlag = false
      let changeEvent
      if (statusAction === 'start') {
        if (taskStatus === '01pending') {
          changeFlag = true
          changeEvent = 'START'
        } else {
          this.$message.error('工单不是【等待】状态,无法开始。')
        }
      }
      if (statusAction === 'over') {
        if (taskStatus === '02inProgress') {
          changeFlag = true
          changeEvent = 'COMPLETE'
        } else {
          this.$message.error('工单不是【进行中】状态,无法结束')
        }
      }
      if (changeFlag) {
        changeBackState({ id: taskId }, changeEvent).then((response) => {
          if (response.data.code === 0) {
            this.$message.success('工单状态变更成功')
            // 刷新工单列表
            this.loadOperateTaskByWorkstation(this.currOperateTask.id)
          } else {
            this.$message.success('工单状态变更失败')
          }
        })
      }
      // 批量提交
      if (statusAction === 'batchSubmit') {
        this.taskID = taskId
        selectSubmitState(taskId)
          .then((res) => {
            if (!res.data.data) {
              changeSubmitState(taskId, true).then((res) => {
                console.log(res)
              })
              getDraftProductOut(taskId).then((response) => {
                console.log(response)
                const list = response.data.data || []
                if (list.length > 0) {
                  this.batchChangeSubmit(list, 0, currItem)
                } else {
                  changeSubmitState(taskId, false).then((res) => {
                    console.log(res)
                  })
                  currItem.statusAction = null
                  this.$message.warning('没有可提交的数据')
                }
                // for (let i = 0; i < list.length; i++) {
                //   batchChange([list[i].id], event)
                //     .then((response) => {
                //       // this.submitLoading = false
                //       // if (successSize === list.length) {
                //       //   this.$message.success('提交成功')
                //       // } else {
                //       //   this.$message.error(errorMsg + '提交失败')
                //       // }
                //       // this.getBatchReport(5)
                //     })
                //     .catch((error) => {
                //       // errorMsg = errorMsg + ele.outBatchNo + ';'
                //       //     this.$message.error(errorMsg + '处理失败')
                //     })
                // }
              })
            } else {
              currItem.statusAction = null
              this.$message.error('该工单处于批量提交执行中,请勿重复操作!')
            }
          })
          .catch((error) => {
            console.log(error)
            changeSubmitState(taskId, false).then((res) => {
              console.log(res)
            })
          })
      }
    },
    batchChangeSubmit(list, i, currItem) {
      const count = i + 1
      const len = list.length
      const loading = this.$loading({
        lock: true,
        text: '正在处理 ' + count + '/' + len,
        spinner: 'el-icon-loading',
        background: 'rgba(0, 0, 0, 0.7)'
      })
      var event = 'SUBMIT'
      batchChange([list[i].mainId], event)
        .then((response) => {
          loading.close()
          if (i < list.length - 1) {
            i++
            this.batchChangeSubmit(list, i, currItem)
          } else {
            changeSubmitState(this.taskID, false).then((res) => {
              console.log(res)
            })
            // 批量提交完成,刷新报工页面数据
            this.$emit('refreshReport')
          }
        })
        .catch((error) => {
          console.log(error)
          loading.close()
          changeSubmitState(this.taskID, false).then((res) => {
            console.log(res)
          })
          const errorMsg = '报工单号' + list[i].productNo + ':'
          this.$message.error(errorMsg + '处理失败')
          // 刷新报工页面数据
          this.$emit('refreshReport')
          currItem.statusAction = null
        })
    },
    // 根据工作站,加载工单信息,选中当前工单
    loadOperateTaskByWorkstation(taskId) {
      return new Promise((resolve, reject) => {
        this.operationTasks = []
        if (this.workstationId && this.workstationId != null) {
          var query = { workstationId: this.workstationId }
          if (this.productSn && this.productSn != null) {
            query.productSn = this.productSn
          }
          if (this.orderNumber && this.orderNumber != null) {
            query.salesOrder = this.orderNumber
          }
          if (this.spec && this.spec != null) {
            query.productName = this.spec
          }
          if (this.outBatchNo && this.outBatchNo != null) {
            query.outBatchNo = this.outBatchNo
          }
          if (this.mpsNo && this.mpsNo != null) {
            query.mpsNo = this.mpsNo
          }
          getOperationTask(query)
            .then((response) => {
              var data = response.data
              if (data.code === 0) {
                var tasks = data.data
                var operationTask
                for (var i = 0; i < tasks.length; i++) {
                  operationTask = {}
                  Object.assign(operationTask, tasks[i])
                  operationTask.taskNo = tasks[i].optaskNo
                  if (tasks[i].state == '01pending') {
                    operationTask.cssStyle = 'waitClass'
                  } else if (tasks[i].state == '02inProgress') {
                    operationTask.cssStyle = 'inprogressClass'
                  } else if (tasks[i].state == '03interrupted') {
                    operationTask.cssStyle = 'pauseClass'
                  } else if (tasks[i].state == '04completed') {
                    operationTask.cssStyle = 'completeClass'
                  }
 
                  operationTask.completedQuantity =
                    tasks[i].completedQuantity == null
                      ? 0
                      : tasks[i].completedQuantity
                  operationTask.technologyRequire =
                    tasks[i].technologyRequirement
                  operationTask.status = tasks[i].state
                  operationTask.statusDesc = this.formaterState(tasks[i].state)
                  operationTask.custom = tasks[i].customer
                  operationTask.saleOrder = tasks[i].salesOrder
                  operationTask.partNo = tasks[i].partNo
                  operationTask.moNo = tasks[i].moNo
                  operationTask.optaskNo = tasks[i].optaskNo
                  operationTask.operationName = tasks[i].operationName
                  operationTask.plannedQuantity = tasks[i].plannedQuantity
                  operationTask.completedQuantity = tasks[i].completedQuantity
                  operationTask.priority = tasks[i].priority
                  operationTask.unit = tasks[i].unit
                  operationTask.plannedStartDate = tasks[i].plannedStartDate
                  operationTask.plannedFinishDate = tasks[i].plannedFinishDate
                  operationTask.actualStartDate = tasks[i].actualStartDate
                  operationTask.actualFinishDate = tasks[i].actualFinishDate
                  operationTask.createTime = tasks[i].createTime
                  operationTask.statusAction = null
                  operationTask.discNum = tasks[i].discNum
                  operationTask.routingOperationRemark =
                    tasks[i].routingOperationRemark
                  operationTask.mpsNo = tasks[i].mpsNo
                  operationTask.mpsId = tasks[i].mpsId
                  operationTask.customerName = tasks[i].customerName
                  operationTask.productName = tasks[i].productName
                  operationTask.reelSpec = tasks[i].reelSpec
                  operationTask.sunit = tasks[i].sunit
                  operationTask.pcoId = tasks[i].pcoId
                  operationTask.customerOrderNo = tasks[i].customerOrderNo
                  operationTask.checkFlag = false
 
                  this.operationTasks.push(operationTask)
                }
                // 选中当前工单
                if (
                  this.operationTasks.length > 0 &&
                  taskId != null &&
                  taskId
                ) {
                  var isResetCurrOpertionTaskFlag = true
                  for (var k = 0; k < this.operationTasks.length; k++) {
                    if (this.operationTasks[k].id === taskId) {
                      this.setCheckFlag(this.operationTasks[k])
                      isResetCurrOpertionTaskFlag = false
                      break
                    }
                  }
                  console.log(this.operationTasks)
                  // 若当前工单在工单列表未被找到且当前工单状态为已完成或已取消时,则将当前工单重置为空并抛出事件,否则不管
                  if (isResetCurrOpertionTaskFlag) {
                    getOperationTaskById(taskId).then((res) => {
                      var resData = res.data
                      if (resData.code === 0) {
                        // 当前工单状态为已完成或已取消或不存在
                        if (resData.data.status === '1') {
                          this.initOperateTask()
                          this.$emit(
                            'changeCurrOperateTask',
                            this.currOperateTask
                          )
                        }
                      }
                    })
                  }
                } else if (
                  this.operationTasks.length <= 0 &&
                  taskId != null &&
                  taskId
                ) {
                  // 工单列表为空,且taskId有值,则找到且当前工单状态为已完成或已取消时,将当前工单重置为空并抛出事件,否则不管
                  getOperationTaskById(taskId).then((res) => {
                    var resData = res.data
                    if (resData.code === 0) {
                      // 当前工单状态为已完成或已取消或不存在
                      if (resData.data.status === '1') {
                        this.initOperateTask()
                        this.$emit(
                          'changeCurrOperateTask',
                          this.currOperateTask
                        )
                      }
                    }
                  })
                }
 
                resolve()
              } else {
                this.$message.error('获取工单信息失败')
                reject()
              }
            })
            .catch((error) => {
              reject(error)
            })
        }
      })
    },
    // 刷新某个工单的信息
    updateSomeOpTask() {
      const opTask = this.operationTasks.find((item) => {
        return item.id == this.currOperateTask.id
      })
      if (opTask) {
        opTask.statusAction = 'start'
      }
    },
    // 工单状态格式化
    formaterState(val) {
      var statusDesc = ''
      if (val == '01pending') {
        statusDesc = '等待'
      } else if (val == '02inProgress') {
        statusDesc = '进行中'
      } else if (val == '03interrupted') {
        statusDesc = '已暂停'
      } else if (val == '04completed') {
        statusDesc = '已完成'
      }
      return statusDesc
    },
    // 工单进度格式化
    formatPercentage(val1, val2) {
      return () => {
        return val1 + '/' + val2
      }
    },
    // 初始化页面变量
    initOperateTask() {
      this.currOperateTask.id = null
      this.currOperateTask.taskNo = null
      this.currOperateTask.technologyName = null
      this.currOperateTask.technologyRequire = null
      this.currOperateTask.partName = null
      this.currOperateTask.manufacturingOrder = null
      this.currOperateTask.status = null
      this.currOperateTask.statusDesc = null
      this.currOperateTask.saleOrder = null
      this.currOperateTask.custom = null
      this.currOperateTask.remark = null
      this.currOperateTask.partNo = null
      this.currOperateTask.partId = null
      this.currOperateTask.unit = null
      this.currOperateTask.operationName = null
      this.currOperateTask.routingId = null
      this.currOperateTask.operationId = null
      this.currOperateTask.partNo = null
      this.currOperateTask.partId = null
      this.currOperateTask.unit = null
      this.currOperateTask.operationName = null
      this.currOperateTask.routingId = null
      this.currOperateTask.operationId = null
      this.currOperateTask.partNo = null
      this.currOperateTask.moNo = null
      this.currOperateTask.optaskNo = null
      this.currOperateTask.operationName = null
      this.currOperateTask.plannedQuantity = null
      this.currOperateTask.completedQuantity = null
      this.currOperateTask.priority = null
      this.currOperateTask.unit = null
      this.currOperateTask.plannedStartDate = null
      this.currOperateTask.plannedFinishDate = null
      this.currOperateTask.actualStartDate = null
      this.currOperateTask.actualFinishDate = null
      this.currOperateTask.createTime = null
      this.currOperateTask.discNum = null
      this.currOperateTask.routingOperationRemark = null
      this.currOperateTask.mpsNo = null
      this.currOperateTask.mpsId = null
      this.currOperateTask.customerName = null
      this.currOperateTask.productName = null
      this.currOperateTask.reelSpec = null
      this.currOperateTask.sunit = null
      this.currOperateTask.pcoId = null
      this.currOperateTask.customerOrderNo = null
    }
  },
  watch: {
    workstationId() {
      if (this.workstationId) {
        this.loadOperateTaskByWorkstation(this.currOperateTask.id)
      }
    },
    currOperateTask: {
      handler(newValue, oldValue) {
        if (newValue.id) {
          localStorage.setItem(task_storage_key, newValue.id)
        } else {
          localStorage.setItem(task_storage_key, null)
        }
      },
      deep: true
    }
  }
}
</script>