cuijian
2023-11-16 e0cd695c11734348e1e01304bdff0696768c1fda
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
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
<template>
  <a-drawer
    :title="title"
    :width="drawerWidth"
    :visible="visible"
    @close="handleCancel"
    :confirmLoading="confirmLoading"
    :maskClosable="maskClosable"
  >
    <a-card :style="getBackground()">
      <template>
        <a-card>
          <div :style="{width: '100%',border: '1px solid #e9e9e9',padding: '10px 16px',background: '#fff',}">
            <a-row :style="{textAlign:'left'}">
              <a-button
                :style="{marginRight: '8px'}"
                @click="handleSW"
                :disabled=SWbuttonDistable
                type="primary"
              >开工</a-button>
              <a-button
                :style="{marginRight: '8px'}"
                @click="handleReport"
                :disabled="buttonDistable"
                type="primary"
              >报工</a-button>
              <a-button
                :style="{marginRight: '8px'}"
                @click="handleReset"
                :disabled="revocationDistable"
                type="primary"
              >撤销</a-button>
            </a-row>
          </div>
          <div :style="{width: '100%',border: '1px solid #e9e9e9',padding: '10px 16px',background: '#fff',}">
            <a-row :gutter="24">
              <a-col :span="6">
                <a-form-item
                  :labelCol="labelCol"
                  :wrapperCol="wrapperCol"
                  label="状态"
                  class="hightColor"
                >
                  <span
                    v-if="this.model != null"
                    class="hightColor"
                  >{{ this.model.statusName }}</span>
                  <span
                    v-else
                    class="frozenRowClass"
                  >-</span>
                </a-form-item>
              </a-col>
              <a-col :span="6">
                <a-form-item
                  :labelCol="labelCol"
                  :wrapperCol="wrapperCol"
                  label="工单号"
                  class="hightColor"
                >
                  <span
                    v-if="this.model != null"
                    class="hightColor"
                  >{{ this.model.num }}</span>
                  <span
                    v-else
                    class="frozenRowClass"
                  >-</span>
                </a-form-item>
              </a-col>
              <a-col :span="6">
                <a-form-item
                  :labelCol="labelCol"
                  :wrapperCol="wrapperCol"
                  label="使用部门"
                  class="hightColor"
                >
                  <span
                    v-if="this.model != null"
                    class="hightColor"
                  >{{ this.model.departName }}</span>
                  <span
                    v-else
                    class="frozenRowClass"
                  >-</span>
                </a-form-item>
              </a-col>
              <a-col :span="6">
                <a-form-item
                  :labelCol="labelCol"
                  :wrapperCol="wrapperCol"
                  label="点检结果"
                  class="hightColor"
                >
                  <span
                    v-if="this.model != null"
                    class="hight"
                  >{{ this.model.result }}</span>
                  <span
                    v-else
                    class="frozenRowClass"
                  >-</span>
                </a-form-item>
              </a-col>
            </a-row>
            <a-row :gutter="24">
              <!-- <a-col :span="8">
                <a-form-item
                  :labelCol="labelCol"
                  :wrapperCol="wrapperCol"
                  label="责任部门"
                  class="hightColor"
                >
                  <span
                    v-if="this.model != null"
                    class="hightColor"
                  >{{ this.model.dutyDepartName }}</span>
                  <span
                    v-else
                    class="frozenRowClass"
                  >-</span>
                </a-form-item>
              </a-col> -->
 
            </a-row>
          </div>
          <a-tabs
            type="card"
            defaultActiveKey="1"
          >
            <a-tab-pane
              tab='点检明细'
              key="1"
              class="hightColor"
            >
              <div :style="{width: '100%',border: '1px solid #e9e9e9',padding: '10px 16px',background: '#fff',}">
                <a-row :gutter="24">
                  <a-col :span="6">
                    <a-form-item
                      :labelCol="labelCol"
                      :wrapperCol="wrapperCol"
                      label="设备编号"
                      class="hightColor"
                    >
                      <span
                        v-if="this.model != null"
                        class="hightColor"
                      >{{ this.model.equipmentNum }}</span>
                      <span
                        v-else
                        class="frozenRowClass"
                      >-</span>
                    </a-form-item>
                  </a-col>
                  <a-col :span="6">
                    <a-form-item
                      :labelCol="labelCol"
                      :wrapperCol="wrapperCol"
                      label="设备名称"
                      class="hightColor"
                    >
                      <span
                        v-if="this.model != null"
                        class="hightColor"
                      >{{ this.model.equipmentName }}</span>
                      <span
                        v-else
                        class="frozenRowClass"
                      >-</span>
                    </a-form-item>
                  </a-col>
                  <a-col :span="6">
                    <a-form-item
                      :labelCol="labelCol"
                      :wrapperCol="wrapperCol"
                      label="设备型号"
                      class="hightColor"
                    >
                      <span
                        v-if="this.model != null"
                        class="hightColor"
                      >{{ this.model.equipmentModel }}</span>
                      <span
                        v-else
                        class="frozenRowClass"
                      >-</span>
                    </a-form-item>
                  </a-col>
                  <a-col :span="6">
                    <a-form-item
                      :labelCol="labelCol"
                      :wrapperCol="wrapperCol"
                      label="点检结果"
                      class="hightColor"
                    >
                      <span
                        v-if="this.model != null"
                        class="hight"
                      >{{ this.model.detailResult }}</span>
                      <span
                        v-else
                        class="frozenRowClass"
                      >-</span>
                    </a-form-item>
                  </a-col>
                </a-row>
                <a-row :gutter="24">
                  <a-col :span="12">
                    <a-pagination
                      class="hightColor"
                      v-model="currentPage"
                      :total="total"
                      :show-total="(total, range) => `共计: ${total}     台设备`"
                      :page-size="pageSize"
                      @change="onChange"
                    >
                      <!-- :showSizeChange="onShowSizeChange" -->
                    </a-pagination>
                  </a-col>
 
                </a-row>
              </div>
              <div>
                <a-table
                  ref="table"
                  size="middle"
                  bordered
                  rowKey="id"
                  :columns="columns"
                  :dataSource="dataSource"
                  :loading="loading"
                  @change="handleTableChange"
                  :pagination="ipagination"
                  :scroll="{ x: 'calc(1200px + 50%)', y: 900 }"
                >
                  <!-- :scroll="{x:true}" -->
                  <template
                    v-for="col in columns"
                    :slot="col.dataIndex"
                    slot-scope='text, record, index'
                  >
                    <div :key="col.dataIndex">
                      <span
                        v-if=" col.dataIndex == 'photo' && !text"
                        style="font-size: 12px;font-style: italic;"
                      >无图片</span>
                      <img
                        v-if="col.dataIndex == 'photo'  && text"
                        :src="getImgView(text)"
                        :preview="record.specialtyInspectionStandardDetailId"
                        height="25px"
                        alt=""
                        style="max-width:80px;font-size: 12px;font-style: italic;"
                      />
                      <a-select
                        v-if="col.dataIndex == 'inspectionProjectResult' && record.testValueType == '2'"
                        :value="text"
                        :options="record.inspectionCycles"
                        @change="(e) => handleChange(e, record.key, col, index)"
                        style="width: 100%"
                        :disabled="record.disabled"
                      />
                      <a-input-number
                        :value="text"
                        v-if="col.dataIndex == 'inspectionProjectResult' && record.testValueType == '1'"
                        :min="0"
                        :max="200"
                        @change="(e)=>handleChange(e, record.key, col, index,record)"
                        style="width: 100%"
                        :disabled="record.disabled"
                      />
                      <a-textarea
                        :value="text"
                        v-if="col.dataIndex == 'abnormalDesc'"
                        :maxLength="500"
                        auto-size
                        placeholder="请输入异常描述"
                        @change="(e)=>handleChange(e, record.key, col, index)"
                        :disabled="record.disabled"
                      />
                      <a-select
                        v-if="col.dataIndex == 'treatmentMeasure'"
                        :value="text"
                        :options="record.treatmentMeasures"
                        @change="(e) => handleChange(e, record.key, col, index)"
                        style="width: 100%"
                        :disabled="record.disabled"
                      />
 
                      <j-image-upload
                        :value="text"
                        v-if="col.dataIndex == 'abnormalPhoto'"
                        :isMultiple="false"
                        auto-size
                        placeholder="请上传图片"
                        @change="(e)=>handleChange(e, record.key, col, index)"
                        :disabled="record.disabled"
                      >
                      </j-image-upload>
 
                      <!-- <Tooltip
                        placement="top"
                        title="预览图片"
                      >
                        <img
                          v-if=" col.dataIndex == 'photo' && record.sketchPhoto.path && (record.sketchPhoto.format.toLowerCase()=='jpg'||record.sketchPhoto.format.toLowerCase()=='bmp'||record.sketchPhoto.format.toLowerCase()=='png'||record.sketchPhoto.format.toLowerCase()=='jpeg'||record.sketchPhoto.format.toLowerCase()=='gif')"
                          width="30"
                          height="14"
                          border="1"
                          draggable="false"
                          preview="1"
                          :preview-text="''"
                          :src="record.sketchPhoto.srcP"
                        />
                      </Tooltip>
 
                      <a
                        v-if=" col.dataIndex == 'photo' &&  record.sketchPhoto.path && record.sketchPhoto.format.toLowerCase()=='pdf'"
                        href="javascript:;"
                        @click="viewP(record.sketchPhoto)"
                      >
                        预览
                      </a>
                      <Tooltip
                        placement="top"
                        title="预览图片"
                      >
                        <img
                          v-if=" col.dataIndex == 'action' && record.upload.path && (record.upload.format.toLowerCase()=='jpg'||record.upload.format.toLowerCase()=='bmp'||record.upload.format.toLowerCase()=='png'||record.upload.format.toLowerCase()=='jpeg'||record.upload.format.toLowerCase()=='gif')"
                          width="30"
                          height="14"
                          border="1"
                          draggable="false"
                          preview="1"
                          :preview-text="''"
                          :src="record.upload.src"
                        />
                      </Tooltip>
 
                      <a
                        v-if=" col.dataIndex == 'action' &&  record.upload.path && record.upload.format.toLowerCase()=='pdf'"
                        href="javascript:;"
                        @click="view(record.upload)"
                      >
                        预览
                      </a>
 
                      <a-divider
                        v-if=" col.dataIndex == 'action' && record.upload.path && (record.upload.format.toLowerCase()=='jpg'||record.upload.format.toLowerCase()=='bmp'||record.upload.format.toLowerCase()=='png'||record.upload.format.toLowerCase()=='jpeg'||record.upload.format.toLowerCase()=='gif'||record.upload.format.toLowerCase()=='pdf')"
                        type="vertical"
                      />
                      <a
                        v-if=" col.dataIndex == 'action'"
                        href="javascript:;"
                        @click="handleUpload(record)"
                        :disabled="record.disabled"
                      >上传</a>
 
                      <a-divider
                        v-if=" col.dataIndex == 'action' && record.upload.path && (record.upload.format.toLowerCase()=='jpg'||record.upload.format.toLowerCase()=='bmp'||record.upload.format.toLowerCase()=='png'||record.upload.format.toLowerCase()=='jpeg'||record.upload.format.toLowerCase()=='gif'||record.upload.format.toLowerCase()=='pdf')"
                        type="vertical"
                      />
                      <a
                        v-if=" col.dataIndex == 'action'  && record.upload.path"
                        href="javascript:;"
                        @click="handleDownload(record)"
                        :disabled="record.disabled"
                      >下载</a> -->
                    </div>
 
                  </template>
 
                </a-table>
              </div>
            </a-tab-pane>
 
            <a-tab-pane
              tab='点检路线图'
              key="2"
              class="hightColor"
            >
              <div
                class="table-operator"
                style="margin:-16px"
              >
                <photo-preview :specialtyInspectionPlanId='specialtyInspectionPlanId' />
              </div>
            </a-tab-pane>
          </a-tabs>
        </a-card>
      </template>
    </a-card>
 
    <div :style="{width: '100%',border: '1px solid #e9e9e9',padding: '10px 16px',background: '#fff',}">
      <a-row :style="{textAlign:'right'}">
        <a-button
          :style="{marginRight: '8px'}"
          @click="handleCancel"
        >
          取消
        </a-button>
        <a-button
          :style="{marginRight: '8px'}"
          @click="handleTS"
          :disabled="buttonDistable"
          type="primary"
        >暂存</a-button>
        <a-button
          @click="handleOk"
          :disabled="buttonDistable"
          type="primary"
        >保存</a-button>
      </a-row>
    </div>
 
    <pdf-view ref="pdfview"></pdf-view>
    <upload-model
      ref="modalForm"
      @ok="modalFormOk"
    ></upload-model>
  </a-drawer>
</template>
 
<script>
import PhotoPreview from './PhotoPreview'
// import SpecialtyInspectionPlanDetail from './SpecialtyInspectionPlanDetail'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import { requestPut, getAction, downFile } from '@/api/manage'
import UploadModel from './UploadModel'
import Tooltip from 'ant-design-vue/es/tooltip'
 
import { preview } from 'vue-photo-preview'
import { ACCESS_TOKEN } from '@/store/mutation-types'
import Vue from 'vue'
import PdfView from '@views/common/PdfView'
import { getFileAccessHttpUrl } from '@/api/manage';
 
export default {
  name: 'SpecialyInspectionOrderExeDrawer',
  mixins: [JeecgListMixin],
  components: {
    PhotoPreview,
    // SpecialtyInspectionPlanDetail,
    PdfView,
    preview,
    UploadModel,
    Tooltip
  },
  data() {
    return {
      pageSizeOptions: ['1'],
      currentPage: 1,
      pageSize: 1,
      total: 10,
 
      title: "专业工单执行",
      visible: false,
      maskClosable: true,
      confirmLoading: false,
      drawerWidth: "100%",
      buttonDistable: false,
      SWbuttonDistable: false,
      revocationDistable: false,
      // currentNodeSelect: '',
      specialtyInspectionPlanId: '',
      dataSource: [],
      model: {},
      labelCol: {
        xs: { span: 24 },
        sm: { span: 6 },
      },
      wrapperCol: {
        xs: { span: 24 },
        sm: { span: 18 },
      },
      columns: [
        {
          title: '#',
          dataIndex: '',
          key: 'rowIndex',
          align: 'center',
          customRender: function (t, r, index) {
            return parseInt(index) + 1
          },
          width: 50,
        },
        {
          title: '部位',
          align: 'center',
          dataIndex: 'location',
        },
        // class: "notshow"
        {
          title: '示意图',
          align: 'center',
          dataIndex: 'photo',
          scopedSlots: { customRender: 'photo' },
        },
        // class: "notshow"
        {
          title: '点检项目',
          align: 'center',
          dataIndex: 'inspectionProjectName',
        },
        {
          title: '检测标准',
          align: 'center',
          dataIndex: 'detectionStandard',
        },
        {
          title: '合格范围',
          align: 'center',
          dataIndex: 'acceptabilityLimit',
        },
        {
          title: '方法',
          align: 'center',
          dataIndex: 'inspectionMethod',
        },
        {
          title: '工具',
          align: 'center',
          dataIndex: 'inspectionTool',
        },
        {
          title: '*点检结果',
          align: 'center',
          dataIndex: 'inspectionProjectResult',
          className: 'red',
          scopedSlots: { customRender: 'inspectionProjectResult' },
        },
        {
          title: '判定',
          align: 'center',
          dataIndex: 'judgmentResult',
          customRender: (text) => {
            if (text == 'pass') {
              return "正常";
            } else if (text == 'fail') {
              return "异常";
            }
          },
        },
        {
          title: '异常描述',
          align: 'center',
          dataIndex: 'abnormalDesc',
          scopedSlots: { customRender: 'abnormalDesc' },
        },
        {
          title: '异常拍照',
          align: 'center',
          dataIndex: 'abnormalPhoto',
          scopedSlots: { customRender: 'abnormalPhoto' },
          // dataIndex: 'action',
          // scopedSlots: { customRender: 'action' },
        },
        {
          title: '*异常处置',
          align: 'center',
          dataIndex: 'treatmentMeasure',
          className: 'red',
          scopedSlots: { customRender: 'treatmentMeasure' },
        },
      ],
      url: {
        save: "/eam/specialtyInspectionOrderDetail/save",
        edit: "/eam/specialtyInspectionOrderDetail/edit",
        list: "/eam/specialtyInspectionOrderDetail/getInspectionOrderDetailList",
        getEquipmentTotalByOrderId: "/eam/specialtyInspectionOrderDetail/getEquipmentTotalByOrderId",
        urlDownload: window._CONFIG['staticDomainURL'],
        download: '/sys/upload/downloadFile',
        editStatus: "/eam/specialtyInspectionOrder/editStatus",
        revocation: "/eam/specialtyInspectionOrder/revocation",
        report: "/eam/specialtyInspectionOrder/report",
      },
    }
  },
  // created() {
  //   this.equipmentRecord = {}
  // },
  methods: {
 
    onChange(page, pageSize) {
      this.queryParam.specialtyInspectionOrderId = this.specialtyInspectionOrderId
      this.queryParam.pageSize = pageSize
      this.queryParam.pageNo = page
      this.getEquipmentTotal()
    },
 
    handleShow(record) {
      this.model = Object.assign({}, record);
      this.dataSource = []
      this.visible = true;
      this.currentPage = 1
      this.specialtyInspectionPlanId = record.specialtyInspectionPlanId
      this.specialtyInspectionOrderId = record.id
      this.queryParam.specialtyInspectionOrderId = record.id
      this.queryParam.inspectionCycleId = record.inspectionCycleId
      this.queryParam.pageSize = 1
      this.queryParam.pageNo = 1
      this.getEquipmentTotal()
    },
    getEquipmentTotal() {
      var params = this.queryParam;//查询条件
      getAction(this.url.getEquipmentTotalByOrderId, params).then((res) => {
        if (res.success) {
          this.total = res.result.total
          this.model.equipmentNum = res.result.records[0].equipmentNum
          this.model.equipmentName = res.result.records[0].equipmentName
          this.model.equipmentModel = res.result.records[0].equipmentModel
          this.model.detailResult = res.result.records[0].detailResult
          this.queryParam.equipmentId = res.result.records[0].equipmentId
          this.loadData1(1)
        } else {
          this.$message.warning(res.message)
        }
      }).finally(() => {
 
      })
    },
    loadData1(arg) {
      if (!this.url.list) {
        this.$message.error("请设置url.list属性!")
        return
      }
      //加载数据 若传入参数1则加载第一页的内容
      if (arg === 1) {
        this.ipagination.current = 1;
      }
      var params = this.getQueryParams();//查询条件
      this.loading = true;
      getAction(this.url.list, params).then((res) => {
        if (res.success) {
          // for (let i = 0; i < res.result.records.length; i++) {
          //   let r = res.result.records[i].upload;
          //   r.src = this.getSrc(res.result.records[i].upload);
 
          //   let p = res.result.records[i].sketchPhoto;
          //   p.srcP = this.getSrc(res.result.records[i].sketchPhoto);
          // }
          //update-begin---author:zhangyafei    Date:20201118  for:适配不分页的数据列表------------
          this.dataSource = res.result.records || res.result;
          if (res.result.total) {
            this.ipagination.total = res.result.total;
          } else {
            this.ipagination.total = 0;
          }
          //update-end---author:zhangyafei    Date:20201118  for:适配不分页的数据列表------------
        } else {
          this.$message.warning(res.message)
        }
      }).finally(() => {
        this.loading = false
      })
    },
 
    modalFormOk() {
      this.getEquipmentTotal()
      //清空列表选中
      this.onClearSelected()
    },
    loadData() {
      // this.getEquipmentTotal()
    },
    getBackground() {
      return "background-color:rgba(127, 127, 127,0.08)";
    },
    handleCancel() {
      this.$emit('ok');
      this.alterFlag = new Date();
      this.close()
    },
    close() {
      this.visible = false;
    },
    //暂存
    handleTS() {
      const that = this;
      that.confirmLoading = true;
      let formData = Object.assign(this.model);
      formData.specialtyInspectionOrderDetails = that.dataSource
      requestPut(this.url.edit, formData).then((res) => {
        if (res.success) {
          that.$message.success("暂存成功!");
          that.getEquipmentTotal()
          that.$emit('ok');
          that.alterFlag = new Date();
        } else {
          that.$message.warning(res.message);
        }
      }).finally(() => {
        that.confirmLoading = false;
        // that.close();
      })
    },
    //开工
    handleSW() {
      const that = this;
      that.confirmLoading = true;
      this.$confirm({
        title: '专业点检工单开工',
        content: '提示:开工后无法撤回,请谨慎操作!',
        okText: '确认',
        cancelText: '取消',
        onOk() {
          requestPut(that.url.editStatus, { id: that.specialtyInspectionOrderId, status: '4' }).then((res) => {
            if (res.success) {
              that.$message.success("工单开工成功!")
              that.getEquipmentTotal()
              that.buttonDistable = false
              that.revocationDistable = true
              that.SWbuttonDistable = true
            } else {
              that.$message.warning("工单开工失败!")
            }
          }).finally(() => {
            that.confirmLoading = false;
            // that.close();
          })
        },
      })
    },
    //报工
    handleReport() {
      const that = this;
      that.confirmLoading = true;
      this.$confirm({
        title: '点检工单报工',
        content: '提示:报工后点检完工,请谨慎操作!',
        okText: '确认',
        cancelText: '取消',
        onOk() {
          requestPut(that.url.report, { id: that.specialtyInspectionOrderId, status: '5' }).then((res) => {
            if (res.success) {
              that.$message.success(res.message)
              that.getEquipmentTotal()
              that.buttonDistable = false
              that.revocationDistable = true
              that.SWbuttonDistable = true
              that.$emit('ok');
              that.alterFlag = new Date();
              that.close();
            } else {
              that.$message.warning(res.message)
            }
          }).finally(() => {
            that.confirmLoading = false;
            //
          })
        },
      })
    },
    //撤销
    handleReset() {
      const that = this;
      that.confirmLoading = true;
      this.$confirm({
        title: '完工撤销',
        content: '提示:完工撤销后可继续报工操作!',
        okText: '确认',
        cancelText: '取消',
        onOk() {
          requestPut(that.url.revocation, { id: that.specialtyInspectionOrderId, status: '4' }).then((res) => {
            if (res.success) {
              that.$message.success(res.message)
              that.getEquipmentTotal()
              that.buttonDistable = false
              that.revocationDistable = true
              that.SWbuttonDistable = true
            } else {
              that.$message.warning(res.message)
            }
          }).finally(() => {
            that.confirmLoading = false;
            // that.close();
          })
        },
      })
    },
    //保存
    handleOk() {
      const that = this;
      that.confirmLoading = true;
      let formData = Object.assign(this.model);
      for (let i = 0; i < that.dataSource.length; i++) {
        let o = this.dataSource[i]
        if (o.inspectionProjectResult == null || o.inspectionProjectResult == '') {
          that.$message.warning('请输入点检结果!')
          that.confirmLoading = false;
          return
        }
        if (o.treatmentMeasure == null || o.treatmentMeasure == '') {
          that.$message.warning('请选择异常处置!')
          that.confirmLoading = false;
          return
        }
      }
      formData.specialtyInspectionOrderDetails = that.dataSource
      requestPut(this.url.save, formData).then((res) => {
        if (res.success) {
          that.$message.success("保存成功!");
          that.getEquipmentTotal()
          that.$emit('ok');
          that.alterFlag = new Date();
        } else {
          that.$message.warning("保存失败!");
        }
      }).finally(() => {
        that.confirmLoading = false;
        // that.close();
      })
    },
 
    handleUpload: function (record) {
      this.$refs.modalForm.edit(record);
      this.$refs.modalForm.title = "文件上传";
      this.$refs.modalForm.disableSubmit = false;
    },
 
    handleChange(value, key, column, index) {
      let that = this;
      const temp = [...that.dataSource];
      const target = temp.filter(item => key === item.key)[index];
      if (target) {
 
        if (column.dataIndex == 'inspectionProjectResult') {
          if (target.testValueType == "1") {
            target[column.dataIndex] = value;
            let maxValue = target.maxValue
            let minValue = target.minValue
            if (value > minValue && value < maxValue) {
              target['judgmentResult'] = "pass";
            } else {
              target['judgmentResult'] = "fail";
            }
            if (value == null || value == "") {
              target['judgmentResult'] = "";
            }
          } else {
 
          }
        }
        if (column.dataIndex == 'abnormalDesc') {
          target[column.dataIndex] = value.target.value;
        }
        if (column.dataIndex == 'treatmentMeasure') {
          target[column.dataIndex] = value;
        }
        if ('abnormalPhoto' == column.dataIndex) {
          target['abnormalPhoto'] = value;
        }
        //显示带过来的数据
        that.dataSource = temp;
      }
    },
 
    // view(record) {
    //   this.$refs.pdfview.showPdf(record.src);
    // },
 
    viewP(record) {
      this.$refs.pdfview.showPdf(record.srcP);
    },
 
    handleDownload(record) {
      downFile(this.url.download, { id: record.upload.id }).then((res) => {
        if (!res) {
          this.$message.warning('文件下载失败')
          return
        } else {
          let fileName = record.upload.name;
          if (typeof window.navigator.msSaveBlob !== 'undefined') {
            window.navigator.msSaveBlob(new Blob([res]), fileName);
          } else {
            let url = window.URL.createObjectURL(new Blob([res]));
            let link = document.createElement('a');
            link.style.display = 'none';
            link.href = url;
            link.setAttribute('download', fileName);
            document.body.appendChild(link);
            link.click()
            document.body.removeChild(link) //下载完成移除元素
            window.URL.revokeObjectURL(url) //释放掉blob对象
          }
        }
      })
    },
 
    getSrc(record) {
 
      if (!record.path) {
        return '';
      }
      //本地:local\Minio:minio\阿里云:alioss
      if (record.uploadType == 'local') {
 
        let ssoLoginFlag = Vue.ls.get("ssoLoginFlag");
        let deployMode = Vue.ls.get("deployMode");
 
        if (ssoLoginFlag && deployMode == "container") {
          var baseProject = Vue.ls.get("baseProject");
          console.log("baseProject==>" + baseProject)
 
          var hostname = window.location.protocol + "//" + window.location.host;
          var url = hostname + '/' + baseProject + '/sys/common/static';
          return getFileAccessHttpUrl(record.path + record.encodeName, url, window._CONFIG['hyperTextTransfer'])
        } else {
          //根据发布状态修改https 或 http
          return getFileAccessHttpUrl(record.path + record.encodeName, this.url.urlDownload, window._CONFIG['hyperTextTransfer'])
        }
 
      } else if (record.uploadType == 'alioss') {
 
        const OSS = require('ali-oss')
        const client = new OSS({
          // region以杭州为例(oss-cn-hangzhou),其他region按实际情况填写。
          region: window._CONFIG['region'],
          // 阿里云主账号AccessKey拥有所有API的访问权限,风险很高。强烈建议您创建并使用RAM账号进行API访问或日常运维,请登录RAM控制台创建RAM账号。
          accessKeyId: window._CONFIG['accessKeyId'],
          accessKeySecret: window._CONFIG['accessKeySecret'],
          bucket: window._CONFIG['bucket'],
        })
        // object-key表示从OSS下载文件时需要指定包含文件后缀在内的完整路径,例如abc/efg/123.jpg。
        return client.signatureUrl(record.path)
      }
    },
  },
 
}
</script>
 
<style scoped>
@import '~@assets/less/common.less';
.hightColor {
  height: 10%;
  font-weight: bold;
  font-size: 20px;
  color: #1b1e1e;
}
.frozenRowClass {
  color: #c9c9c9;
}
.fontweight {
  font-weight: bold;
}
.hight {
  color: #f5222d;
}
/deep/ .red {
  color: red;
}
</style>