lzhe
2024-06-14 963a2313f4f8959715293d38f69894078150d508
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
<!--
 * @Date: 2024-05-20 21:43:10
 * @LastEditors: Sneed
 * @LastEditTime: 2024-06-06 23:11:22
 * @FilePath: /belleson-frontend/Users/mache/Documents/demo/cps-web/src/views/dnc/factory-file/index.vue
-->
<template>
    <el-main style="height: 100%;">
        <el-card shadow="never" style="height: 100%;" body-style="height: 100%">
            <el-container>
                <el-header>
                    <el-upload style="margin-left: 8px;" :show-file-list="false" class="upload" :http-request="request">
                        <el-button type="primary">上传文件</el-button>
                    </el-upload>
                    <el-button style="margin-left: 8px;margin-right: auto;" type="danger" plain
                        :disabled="selection.length == 0" @click="del(selection)">删除</el-button>
                </el-header>
                <el-main>
                    <scTable highlight-current-row @dataChange="dataChange" @row-click="rowClick" ref="table"
                        :params="params" :apiObj="apiObj" @selection-change="selectionChange" stripe>
                        <el-table-column type="selection" width="50"></el-table-column>
                        <el-table-column label="文件名称" prop="filename">
                            <!-- <template #default="scope">
                                <el-icon style="margin-right: 4px;">
                                    <el-icon-folder v-if="scope.row.fileType === 1" />
                                    <el-icon-document v-else />
                                </el-icon>
                                <a v-if="scope.row.fileType === 1" @click="goCurrent(scope.row)"
                                    style="color: var(--el-color-primary);cursor: pointer;">{{ scope.row.name }}</a>
                                <a v-else @click="viewHis(scope.row)"
                                    style="color: var(--el-color-primary);cursor: pointer;">{{ scope.row.name }}</a>
                            </template> -->
                        </el-table-column>
                        <el-table-column label="版本" prop="versionDesc"></el-table-column>
                        <el-table-column label="文件大小" prop="contentLength"></el-table-column>
                        <el-table-column label="文件类型" prop="suffix"></el-table-column>
                        <el-table-column label="创建人" prop="createUserName"></el-table-column>
                        <el-table-column label="创建时间" prop="createTime"></el-table-column>
                        <el-table-column label="操作" fixed="right" align="right" width="160">
                            <template #default="scope">
                                <el-button-group>
                                    <el-button text type="primary" size="small" @click="del([scope.row])">删除</el-button>
                                </el-button-group>
                            </template>
                        </el-table-column>
                    </scTable>
                </el-main>
            </el-container>
        </el-card>
    </el-main>
</template>
 
<script>
export default {
    data() {
        return {
            selection: [],
            params: {},
            apiObj: {
                get: async (data) => {
                    let params = {
                        ...data,
                        ...this.params
                    }
                    return await this.$HTTP.get(`/api/blade-dnc/dnc-factory-file/page`, {}, { params }).then(res => {
                        return res
                    })
                }
            },
        }
    },
    methods: {
        selectionChange(selection) {
            this.selection = selection
        },
        del(selection) {
            this.$HTTP.delete(`/api/blade-dnc/dnc-factory-file/remove`, {}, { data: selection.map(v => v.id) }).then(res => {
                this.$refs.table.reload()
            })
        },
        request(options) {
            const formData = new FormData()
            formData.append('file', options.file)
            console.log(options)
            this.$HTTP.post(`/api/blade-resource/oss/endpoint/put-file`, formData).then(res => {
                this.$HTTP.post(`/api/blade-dnc/dnc-factory-file/insert`, {
                    contentLength: options.file.size,
                    contentType: options.file.type,
                    filename: options.file.name,
                    link: res.data.link,
                    objectKey: res.data.name,
                    originalFilename: options.file.name,
                    suffix: res.data.originalName.split('.').pop(),
                }).then(res => {
                    this.$refs.table.reload()
                })
            })
        }
    }
}
</script>
 
<style lang="scss" scoped></style>