研发图纸文件管理系统-前端项目
he wei
2024-01-03 c52f7f5736836d447832f8fc6cf0f540ef854f15
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
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
<template>
  <div class="main">
    <div class="inner" ref="wraper">
      <a-spin class="" :spinning="spinning" tip="拼命加载中...">
        <a-card>
          <advance-table
            ref="table"
            class="doc-center-table"
            :data-source="dataSource"
            :columns="columns"
            title=" "
            :row-key="(record, index) => index"
            @search="onSearch"
            @refresh="onRefresh"
            @reset="onReset"
            :format-conditions="true"
            :scroll="{ y }"
            :pagination="{
              current: pageCurr,
              pageSize: pageSize,
              total: total,
              showSizeChanger: true,
              showLessItems: true,
              showQuickJumper: true,
              pageSizeOptions: ['10', '20', '50', '100'],
              showTotal: (total, range) =>
                `第 ${range[0]}-${range[1]} 条,总计 ${total} 条`,
              onChange: onPageChange,
              onShowSizeChange: onSizeChange,
            }"
          >
            <template slot="action" slot-scope="{ record }">
              <a-popover v-if="!record.currentFlag" title="" trigger="hover">
                <div class="" slot="content" style="width: 450px">
                  <a-table
                    size="small"
                    :scroll="{ y: 300 }"
                    bordered
                    :columns="prodsColumns"
                    :data-source="record.sopProductList"
                    :pagination="false"
                    :expandRowByClick="true"
                    :row-key="(record1, index) => index"
                  >
                    <!-- <template slot="action" slot-scope="record1">
                                            123{{ record1 }}
                                        </template> -->
                  </a-table>
                </div>
                <a>适用产品</a>
              </a-popover>
              <a-tag v-else class="tag-all" color="#f50"> 适用全部 </a-tag>
              <template v-if="canDownload">
                <a-divider type="vertical"></a-divider>
                <a
                  v-if="record.isCanPreview"
                  :disabled="!record.status"
                  @click="downloadFile(record)"
                  >预览</a
                >
                <a
                  v-else
                  :disabled="!record.status"
                  @click="downloadFile(record)"
                  >下载</a
                >
              </template>
            </template>
          </advance-table>
        </a-card>
      </a-spin>
    </div>
    <pop
      :visible.sync="popVisible"
      :x="popPosition.x"
      :y="popPosition.y"
      :position="popPosition.dir"
      :info="popInfo"
    ></pop>
    <a-modal
      :visible="uploadShow"
      :footer="null"
      :width="800"
      title="上传SOP"
      :destroyOnClose="true"
      :maskClosable="false"
      @cancel="uploadCancel"
    >
      <div class="">
        <template v-if="!onlyXls">
          <a-row type="flex" class="row">
            <a-col flex="6em" class="label">sop文件</a-col>
            <a-col :flex="1">
              <a-upload
                class="upload"
                :before-upload="beforeUpload"
                @change="uploadChange"
                accept=".zip,.rar"
              >
                <a-button type="primary">选文件</a-button>
              </a-upload>
            </a-col>
          </a-row>
        </template>
        <a-row type="flex" class="row">
          <a-col flex="6em" class="label">SOP说明</a-col>
          <a-col :flex="1">
            <a-upload
              class="upload"
              :before-upload="beforeUpload"
              @change="uploadChange1"
              accept=".xls,.xlsx"
            >
              <a-button type="primary">说明文件</a-button>
            </a-upload>
          </a-col>
        </a-row>
        <div class="sub-title">说明文件解析结果</div>
        <div class="res-content">
          <desc-res :info="resObj"></desc-res>
        </div>
        <div class="modal-footer">
          <a-button type="danger" @click="uploadCancel"> 取消 </a-button>
          <a-button v-if="!onlyXls" type="primary" @click="uploadSop">
            提交
          </a-button>
          <a-button v-else type="primary" @click="applyModel"> 提交 </a-button>
        </div>
      </div>
    </a-modal>
    <a-modal
      :visible="emailShow"
      :footer="null"
      :width="760"
      title="邮件发送"
      :destroyOnClose="true"
      :maskClosable="false"
      @cancel="emailCancel"
    >
      <email-card
        :visible.sync="emailShow"
        :users="userList"
        :title="emailInfo.title"
        :content="emailInfo.content"
        :type="2"
        v-if="emailShow"
      ></email-card>
    </a-modal>
    <!-- 操作原因 -->
    <a-modal
      :visible="reasonVisible"
      :width="460"
      title="操作原因"
      :destroyOnClose="true"
      :maskClosable="false"
      @cancel="reasonCancel"
      @ok="reasonOk"
    >
      <a-form-model-item ref="name" label="操作原因">
        <a-input
          type="textarea"
          v-model="reason"
          placeHolder="请输入操作原因"
        />
      </a-form-model-item>
    </a-modal>
    <!-- 日志 -->
    <a-modal
      :visible="logVisible"
      :footer="null"
      :width="800"
      title="操作日志"
      :destroyOnClose="true"
      @cancel="logCancel"
    >
      <div class="log-content">
        <a-timeline v-if="logList.length">
          <a-timeline-item
            v-for="(item, idx) in logList"
            :key="'log_' + idx"
            :color="item.status == 0 ? 'red' : 'green'"
          >
            <div>
              <span class="user">{{ item.userName }}</span> 在
              <span class="time">{{ item.createTime }}</span>
              {{ item.status == 0 ? "锁定" : "解锁" }}了版本
              <span class="version">{{ item.fileVersion }}</span>
            </div>
            <div>操作原因: {{ item.reason ? item.reason : "无" }}</div>
          </a-timeline-item>
        </a-timeline>
        <a-empty v-else />
      </div>
    </a-modal>
 
    <!-- 日志 -->
    <a-modal
      :visible="pdfInfo.visible"
      :footer="null"
      :width="960"
      title="文件预览"
      :destroyOnClose="true"
      @cancel="pdfCancel"
    >
      <div style="height:600px; overflow-y: auto">
        <iframe :src="pdfInfo.src"></iframe>
      </div>
    </a-modal>
  </div>
</template>
 
<script>
import AdvanceTable from "@/components/table/advance/AdvanceTable";
import getWebUrl from "@/assets/js/tools/getWebUrl";
import checkPermit from "@/assets/js/tools/checkPermit";
import PERMITS from "@/assets/js/const/const_permits";
import { mapGetters } from "vuex";
import EmailCard from "../../components/emailCard";
import { getUserList } from "../../permission/apis";
import {
  fileParse,
  addSop,
  getList,
  getSopType1,
  getSopType2,
  updateSop,
  sopLock,
  getLogList,
} from "./apis";
import offset from "@/assets/js/tools/offset";
import Pop from "./pop";
import DescRes from "./descRes";
import getFileTypeAndName from "@/assets/js/tools/getFileTypeAndName";
import VuePdf from "vue-pdf";
 
export default {
  props: {
    parentCode: {
      type: [String, Number],
      default: 0,
    },
  },
  components: {
    AdvanceTable,
    Pop,
    DescRes,
    EmailCard,
    VuePdf,
  },
  name: "list",
  data() {
    return {
      pdfInfo: {
        visible: false,
        src: "",
        loadedRatio: 0,
        page: 1,
        numPages: 0,
        rotate: 0,
      },
      rowFileName: "",
      logList: [],
      logVisible: false,
      currentObj: null,
      reasonVisible: false,
      reason: "",
      emailShow: false,
      emailInfo: {
        title: "",
        content: "",
      },
      userList: [],
      onlyXls: false,
      uploadShow: false,
      webUrl: getWebUrl(),
      prodsColumns: [
        {
          title: "物料编码",
          dataIndex: "code",
          align: "center",
        },
        {
          title: "型/板号",
          dataIndex: "model",
          align: "center",
          width: 180,
        },
        // {
        //   title: "操作",
        //   dataIndex: "operation",
        //   align: "center",
        //   width: 180,
        //   scopedSlots: { customRender: "action" },
        // },
      ],
      file: null,
      file1: null,
      resObj: {},
      popInfo: {},
      popVisible: false,
      popPosition: {
        x: 500,
        y: 100,
        dir: "bottom",
      },
      spinning: false,
      loading: false,
      pageCurr: 1,
      pageSize: 20,
      total: 0,
      y: 400,
      update: -1,
      conditions: {},
      columns: [
        {
          title: "文件名称",
          dataIndex: "fileName",
          align: "center",
          width: 140,
          searchAble: true,
          customCell: this.customCell,
        },
        {
          title: "发布时间",
          dataIndex: "releaseDate",
          align: "center",
          width: 160,
          customCell: this.customCell,
        },
        {
          title: "负责人",
          dataIndex: "editor",
          align: "center",
          width: 90,
          customCell: this.customCell,
        },
        {
          title: "审核人",
          dataIndex: "auditor",
          align: "center",
          width: 90,
          customCell: this.customCell,
        },
        {
          title: "发布说明",
          dataIndex: "releaseNotes",
          align: "center",
          width: 260,
          customCell: this.customCell,
        },
        {
          title: "操作",
          dataIndex: "operation",
          align: "center",
          width: 200,
          fixed: "right",
          scopedSlots: { customRender: "action" },
          noSearch: true,
        },
      ],
      dataSource: [],
    };
  },
  computed: {
    ...mapGetters("account", ["permits"]),
    ...mapGetters("setting", ["affixed"]),
    canUpload() {
      return checkPermit(PERMITS.uploadSoftware, this.permits);
    },
    canDownload() {
      return checkPermit(PERMITS.downloadSop, this.permits);
    },
  },
  watch: {
    update(n) {
      if (-1 != n && !this._inactive) {
        this.$nextTick(() => {
          const table = this.$refs.table;
          const header = document.querySelectorAll(
            ".doc-center-table .ant-table-header"
          )[0].clientHeight;
          const bar = document.querySelectorAll(".header-bar")[0].clientHeight;
          if (table.fullScreen) {
            this.y = table.$el.clientHeight - bar - header - 64;
          } else {
            const wraper = this.$refs.wraper.clientHeight;
            const card = document.querySelectorAll(".ant-card-body")[0];
            const { paddingBottom, paddingTop } = getComputedStyle(card, null);
            const h =
              wraper -
              header -
              64 -
              bar -
              parseInt(paddingBottom) -
              parseInt(paddingTop);
            this.y = h;
          }
        });
      }
    },
    affixed() {
      setTimeout(() => {
        this.update = Math.random();
      }, 200);
    },
  },
  methods: {
    searchAllUserList() {
      getUserList()
        .then((res) => {
          let rs = res.data;
          if (rs.code && rs.data) {
            this.userList = rs.data2;
          }
        })
        .catch((error) => {
          console.log(error);
        });
    },
    showUpload() {
      this.file = null;
      this.file1 = null;
      this.resObj = {};
      this.onlyXls = false;
      this.uploadShow = true;
    },
    updateDesc(row) {
      this.file = null;
      this.file1 = null;
      this.resObj = { rowId: row.id };
      this.rowFileName = row.fileName;
      this.onlyXls = true;
      this.uploadShow = true;
    },
    uploadCancel() {
      this.uploadShow = false;
    },
    handleEmailShow(record) {
      this.emailInfo.title =
        "[sop发布记录]" + record.fileName + " 版本号:" + record.fileVersion;
      let sopProductListText = record.sopProductList
        .map((item) => {
          return "物料编码:" + item.code + " 型/板号:" + item.model;
        })
        .join("\n");
      this.emailInfo.content =
        "文件基础信息\n" +
        "文件名称:" +
        record.fileName +
        "\n" +
        "文件类型:" +
        record.fileType +
        "\n" +
        "文件版本:" +
        record.fileVersion +
        "\n" +
        "关联版本:" +
        record.fileRelatedVersion +
        "\n" +
        "编制:" +
        record.editor +
        "\n" +
        "审核:" +
        record.auditor +
        "\n" +
        "发布日期:" +
        record.releaseDate +
        "\n" +
        "文件适用产品\n" +
        sopProductListText +
        "\n" +
        "发布说明:" +
        record.releaseNotes;
      this.emailShow = true;
    },
    emailCancel() {
      this.emailShow = false;
    },
    uploadSop() {
      if (!this.file) {
        this.$message.error("请选择要上传的压缩包");
        return false;
      }
      if (!this.file1) {
        this.$message.error("请选择sop说明文件");
        return false;
      }
      if (!this.resObj.fileName) {
        this.$message.error("sop说明文件解析异常");
        return false;
      }
      // 如果sop文件名称 != sop说明里的文件名称 + 文件版本  则报错拒绝
      let reg = /(.*)\..{1,5}$/;
      let name1 = this.file.name.match(reg)[1];
      let { fileName, fileVersion } = this.resObj;
      let name2 = fileName + fileVersion;
 
      if (name1.toLowerCase() != name2.toLowerCase()) {
        console.log(name1.toLowerCase() + "&&&&&&" + name2.toLowerCase());
        this.$message.error("sop与说明文件可能不匹配");
        return false;
      }
 
      let loading = this.$layer.loading();
 
      const formData = new FormData();
      formData.append("multipartFile", this.file);
      // formData.append("file2", this.file1);
      formData.append("sopStr", JSON.stringify(this.resObj));
      addSop(formData)
        .then((res) => {
          let { code, data, msg } = res.data;
          if (code) {
            this.uploadShow = false;
            this.$message.success("上传成功");
            this.searchData();
          } else {
            this.$message.error(msg);
          }
          this.$layer.close(loading);
        })
        .catch((error) => {
          this.$layer.close(loading);
          console.log(error);
        });
    },
    applyModel() {
      if (!this.file1) {
        this.$message.error("请选择sop说明文件");
        return false;
      }
      if (!this.resObj.fileName) {
        this.$message.error("sop说明文件解析异常");
        return false;
      }
 
      if (
        this.rowFileName.toLowerCase() != this.resObj.fileName.toLowerCase()
      ) {
        this.$message.error("说明文件与该条记录可能不匹配");
        return false;
      }
      let loading = this.$layer.loading();
      updateSop(this.resObj)
        .then((res) => {
          let { code, data, msg } = res.data;
          if (code) {
            this.uploadShow = false;
            this.$message.success("上传成功");
            this.searchData();
          } else {
            this.$message.error("解析失败");
          }
          this.$layer.close(loading);
        })
        .catch((error) => {
          this.$layer.close(loading);
          console.log(error);
        });
    },
    getSopType1() {
      getSopType1()
        .then((res) => {
          let { code, data } = res.data;
          let list = [];
          if (code) {
            list = data.map((v) => ({
              title: v.type1,
              value: v.type1,
            }));
          }
          this.columns[0].search.selectOptions = list;
        })
        .catch((err) => {
          console.log(err);
        });
    },
    getSopType2(type) {
      if (type) {
        getSopType2(type)
          .then((res) => {
            let { code, data } = res.data;
            let list = [];
            if (code) {
              list = data.map((v) => ({
                title: v.type2,
                value: v.type2,
              }));
            }
            this.columns[1].search.selectOptions = list;
          })
          .catch((err) => {
            console.log(err);
          });
      } else {
        this.columns[1].search.selectOptions = [];
      }
    },
    cellMouseenter(e, obj) {
      // console.log("enter", e, obj);
      const wraper = this.$refs.wraper;
      const { clientHeight, clientWidth } = wraper;
      const { target, clientX, clientY } = e;
      let { left: x, top: y } = offset(wraper);
      x = clientX - x;
      y = clientY - y;
      // 如果clientHeight 小于380 * 2 则左右布局
      let dir = "bottom";
      if (clientHeight < 380 * 2) {
        if (x + 420 + 18 > clientWidth) {
          dir = "left";
        } else {
          dir = "right";
        }
        if (y < 180) {
          y = 180;
        } else if (y > clientHeight - 378) {
          y = clientHeight / 2;
        }
      } else {
        if (y + 18 + 360 > clientHeight) {
          // y = clientHeight - 378;
          dir = "top";
        } else {
          dir = "bottom";
        }
        if (x < 400) {
          x = 400;
        }
        if (x + 400 > clientWidth) {
          x = clientWidth - 400;
        }
      }
      this.popPosition.x = x;
      this.popPosition.y = y;
      this.popPosition.dir = dir;
      this.popInfo = obj;
      this.popVisible = true;
    },
    cellMouseleave(e, obj) {
      // console.log("leave", obj);
      this.popVisible = false;
    },
    customCell(record) {
      return {
        on: {
          mouseenter: (e) => this.cellMouseenter(e, record),
          mouseleave: (e) => this.cellMouseleave(e, record),
        },
      };
    },
    beforeUpload() {
      return false;
    },
    uploadChange(data) {
      const { file, fileList } = data;
      if (fileList.length > 1) {
        fileList.shift();
      }
      if (fileList.length) {
        this.file = fileList[0].originFileObj;
      } else {
        this.file = null;
      }
    },
    uploadChange1(data) {
      const { file, fileList } = data;
      if (fileList.length > 1) {
        fileList.shift();
      }
      if (fileList.length) {
        this.file1 = fileList[0].originFileObj;
      } else {
        this.file1 = null;
        this.resObj = [];
        return false;
      }
      let loading = this.$layer.loading();
      const formData = new FormData();
      formData.append("multipartFile", this.file1);
      fileParse(formData)
        .then((res) => {
          this.$layer.close(loading);
          let { code, data, data2, msg } = res.data;
          if (code && data) {
            let rowId = this.resObj.rowId;
            this.resObj = data2;
            this.resObj.id = rowId;
            this.$message.success("解析成功");
          } else {
            this.$message.error(msg);
          }
        })
        .catch((error) => {
          this.$layer.close(loading);
          console.log(error);
        });
    },
    resize() {
      setTimeout(() => {
        this.update = Math.random();
      }, 200);
    },
    activeFN() {
      this.resize();
    },
    onSearch(conditions, searchOptions, col) {
      // console.log(conditions);
      // console.log(searchOptions, "00", col);
      this.pageCurr = 1;
      this.conditions = conditions;
      if ("parentType" == col.dataIndex) {
        this.parentTypeChange(col.search.value);
      }
      this.searchData();
    },
    onPageChange(page, pageSize) {
      this.pageCurr = page;
      this.pageSize = pageSize;
      this.searchData();
    },
    onSizeChange(current, size) {
      this.pageCurr = 1;
      this.pageSize = size;
      this.searchData();
    },
    onRefresh(conditions) {
      this.conditions = conditions;
      this.searchData();
    },
    onReset(conditions) {
      this.conditions = conditions;
      this.searchData();
    },
    // 文件类型查询条件发生变化  查询子文件类型列表 重置子文件类型值
    parentTypeChange(val) {
      let _search = this.columns[1].search;
      _search.value = [];
      this.conditions["chileType"] = [];
      this.getSopType2(val);
    },
    searchData() {
      const { pageCurr, pageSize, conditions, columns } = this;
      let params = { pageCurr, pageSize };
      let data = {};
      Object.keys(conditions).forEach((v) => {
        switch (v) {
          // case "code":
          // case "model":
          //   break;
          case "status":
            params[v] = conditions[v] ? 1 : 0;
            break;
          case "parentType":
          case "chileType":
            data[v] = conditions[v];
            break;
 
          default:
            params[v] = conditions[v];
            break;
        }
      });
      params.status = 1;
      params.code = this.parentCode;
      let list = [];
      let params2 = "{}" == JSON.stringify(data) ? [] : [data];
      getList(params, params2)
        .then((res) => {
          let { code, data, data2 } = res.data;
          let total = 0;
          if (code && data) {
            // console.log(data2);
            list = data2.list;
            total = data2.total;
          }
          this.dataSource = list.map((item) => {
            const fileInfo = getFileTypeAndName(item.fileUrl);
            item.isCanPreview = fileInfo.type === "pdf";
            return item;
          });
          this.total = total;
          this.getSopType1();
          if (-1 == this.update) {
            this.update = Math.random();
          }
        })
        .catch((err) => {
          console.log(err);
        });
    },
    downloadFile(record) {
      const fileInfo = getFileTypeAndName(record.fileUrl);
      let url = this.webUrl + record.fileUrl;
      if (fileInfo.type === "pdf") {
        // 预览
        window.open(url);
      } else {
        // 下载
        let loading = this.$layer.loading();
        let link = document.createElement("a");
        link.style.display = "none";
        let fileName = record.fileUrl.split("/").pop();
        link.href = url;
        link.download = fileName;
        document.body.appendChild(link);
        link.click();
        this.$layer.close(loading);
        document.body.removeChild(link);
      }
    },
    reasonCancel() {
      this.reasonVisible = false;
    },
    reasonOk() {
      let { id, status } = this.currentObj;
      let reason = this.reason;
      status = status == 0 ? 1 : 0;
      sopLock(id, status, reason).then((res) => {
        const { code } = res.data;
        if (code) {
          this.$message.success("操作成功");
          this.reasonVisible = false;
          this.searchData();
        } else {
          this.$message.error("操作失败");
        }
      });
    },
    lock(record) {
      this.reason = "";
      this.currentObj = record;
      this.reasonVisible = true;
    },
    viewLog(obj) {
      // console.log(obj);
      const { id, fileVersion } = obj;
      getLogList(id).then((res) => {
        const { code, data, data2 } = res.data;
        if (code) {
          this.logList = data2.map((v) => ({ ...v, fileVersion }));
          this.logVisible = true;
        } else {
          this.$message.error("日志查询失败");
        }
      });
    },
    logCancel() {
      this.logVisible = false;
    },
    pdfCancel() {
      this.pdfInfo.visible = false;
    },
    goHistory(record) {
      let { fileName } = record;
      this.$router.push({
        path: "/resource/sop-history",
        query: { fileName },
      });
    },
  },
  mounted() {
    this.searchData();
    this.searchAllUserList();
    this.getSopType1();
    window.addEventListener("resize", this.resize);
  },
  destroyed() {
    window.removeEventListener("resize", this.resize);
  },
};
</script>
 
<style scoped lang="less">
.main {
  height: 100%;
  position: relative;
  .inner {
    position: absolute;
    left: 0;
    top: 0;
    right: 0;
    bottom: 0;
  }
}
.img-wraper {
  width: 80px;
  height: 50px;
  display: inline-block;
  .image-view {
    width: 100%;
    height: 100%;
    /deep/img {
      width: 100%;
      height: 100%;
      object-fit: contain;
    }
  }
}
/deep/table {
  table-layout: fixed;
}
.modal-footer {
  text-align: right;
  button + button {
    margin-left: 8px;
  }
}
.label {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  padding-right: 0.4em;
  height: 32px;
  &::after {
    content: ":";
  }
}
.row ~ .row {
  margin-top: 10px;
}
.sub-title {
  font-size: 14px;
  font-weight: 700;
  margin-top: 10px;
}
.res-content {
  max-height: 260px;
  overflow-y: auto;
  margin-bottom: 10px;
}
.btn-grp button {
  width: 6.4em;
}
.tag-all {
  margin: 0;
}
/deep/ .ant-table-fixed-right {
  .ant-table-body-outer {
    margin-bottom: 0 !important;
  }
  .ant-table-body-inner {
    overflow-x: hidden;
  }
}
.log-content {
  max-height: 400px;
  overflow-y: auto;
 
  .user {
    color: #23aaf2;
    font-weight: 700;
  }
 
  .time {
    color: #f9be13;
    font-weight: 700;
  }
 
  .version {
    color: #0aedb2;
    font-weight: 700;
  }
 
  .ant-timeline-item:first-of-type {
    padding-top: 6px;
  }
}
</style>