liding
2025-03-25 4b6d39d4e18710684bc65c5fcac6e6968e311781
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
<template>
    <el-dialog title="查看附件" :visible.sync="fileDialogVisible" width="800px" top="5vh" fullscreen append-to-body
      @close="handleClose">
      <filePreview v-if="lookDialogVisible" :fileUrl="currentInfo.fileMinioUrl" :currentFile="currentInfo"
        style="max-height: 90vh;overflow-y: auto;" />
    </el-dialog>
</template>
 
<script>
import limsTable from "@/components/Table/lims-table.vue";
import partFileList from "@/api/structural/workshop.js"
import filePreview from "@/components/Preview/filePreview.vue";
export default {
  components: {
    limsTable,
    filePreview,
  },
  props: {
    visible: {
      type: Boolean,
      default: false
    },
    partNo: {
      type: String,
      default: ''
    }
  },
  computed: {},
  data() {
    return {
      columnFile: [
        {
          dataType: 'tag',
          label: '类型',
          prop: 'type',
          formatData: (params) => {
            if (params == 1) {
              return '图片'
            } else if (params == 2) {
              return '文件'
            } else {
              return ''
            }
          },
          formatType: (params) => {
            if (params == 1) {
              return 'success'
            } else if (params == 2) {
              return 'warning'
            } else {
              return ''
            }
          }
        },
        { label: '附件名称', prop: 'fileName' },
        { label: '上传人', prop: 'name' },
        { label: '上传时间', prop: 'createTime' },
        {
          dataType: 'action',
          fixed: 'right',
          label: '操作',
          width: '170px',
          operation: [
            {
              name: '下载',
              type: 'text',
              clickFun: (row) => {
                this.handleDown(row);
              }
            },
            {
              name: '预览',
              type: 'text',
              clickFun: (row) => {
                console.log('预览文件信息:', row)
                this.currentInfo = row
                this.lookDialogVisible = true
              }
            },
          ]
        }
      ],
      tableDataFile: [],
      tableLoadingFile: false,
      lookDialogVisible: false,
      currentInfo: {},
      fileDialogVisible: false,
    }
  },
  mounted() {
    this.getFileList()
  },
  methods: {
    // 查询附件查看列表回调
    getFileList() {
      this.tableLoadingFile = true
      partFileList({ partNo: this.partNo }).then(res => {
        this.tableLoadingFile = false
        if (res.code === 200) {
          this.tableDataFile = res.data
          console.log('文件列表数据:', this.tableDataFile)
        }
      }).catch(err => {
        this.tableLoadingFile = false
      })
    },
 
    // 下载附件的文件
    handleDown(row) {
      this.$download.saveAs(row.fileUrl, row.fileName);
    },
  }
}
</script>
 
<style scoped></style>