1
李喆(开发组)
2025-03-18 122deb4a51475b271bd5d4de36593c1c5f925f1d
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
<!--
 * @Date: 2024-05-22 23:37:07
 * @LastEditors: Sneed
 * @LastEditTime: 2024-06-16 16:19:33
 * @FilePath: /belleson-frontend/Users/mache/Documents/demo/cps-web/src/views/dnc/station-file/File.vue
-->
<template>
    <el-container>
        <el-header>
            <el-button :disabled="selectionFile.length == 0 && selection.length == 0" type="primary"
                @click="archive">归档</el-button>
            <el-tree-select v-model="storageSpaceId" :data="treeData" :props="{
                label: 'name',
            }" node-key="id" default-expand-all check-strictly style="width: 240px">
                <template #prefix>
                    FTP目录
                </template>
            </el-tree-select>
        </el-header>
        <el-main>
            <h2 style="background-color: var(--el-color-primary);color: #fff;padding: 4px 20px;">程序</h2>
            <el-table :data="tableData" style="width: 100%" @selection-change="onSelectionChange">
                <el-table-column type="selection"></el-table-column>
                <el-table-column label="文件名称" prop="filename" width=""></el-table-column>
                <el-table-column label="版本" prop="versionDesc" width=""></el-table-column>
                <el-table-column label="大小" prop="contentLength" width=""></el-table-column>
                <el-table-column label="文件类型" prop="suffix" width=""></el-table-column>
                <el-table-column label="文件位置" prop="fileLocation" width=""></el-table-column>
                <el-table-column label="归档状态" prop="whetherArchiveDesc" width=""></el-table-column>
                <el-table-column label="更新人" prop="updateUserName" width=""></el-table-column>
                <el-table-column label="更新时间" prop="updateTime" width=""></el-table-column>
                <el-table-column label="操作" prop="" width="">
                    <template #default="scope">
                        <el-button-group>
                            <el-button text type="primary" size="small"
                                @click="download(scope.row, scope.$index)">下载</el-button>
                            <el-popconfirm width="220" title="确定将选择的数据删除" @confirm="table_del(scope.row)">
                                <template #reference>
                                    <el-button text type="primary" size="small">删除</el-button>
                                </template>
                            </el-popconfirm>
                        </el-button-group>
                    </template>
                </el-table-column>
            </el-table>
            <h2 style="margin-top: 10px;background-color: var(--el-color-primary);color: #fff;padding: 4px 20px;">文件
            </h2>
            <el-table :data="tableDataFile" style="width: 100%" @selection-change="onSelectionChangeFile">
                <el-table-column type="selection"></el-table-column>
                <el-table-column label="文件名称" prop="filename" width=""></el-table-column>
                <el-table-column label="版本" prop="versionDesc" width=""></el-table-column>
                <el-table-column label="大小" prop="contentLength" width=""></el-table-column>
                <el-table-column label="文件类型" prop="suffix" width=""></el-table-column>
                <el-table-column label="文件位置" prop="fileLocation" width=""></el-table-column>
                <el-table-column label="归档状态" prop="whetherArchiveDesc" width=""></el-table-column>
                <el-table-column label="更新人" prop="updateUserName" width=""></el-table-column>
                <el-table-column label="更新时间" prop="updateTime" width=""></el-table-column>
                <el-table-column label="操作" prop="" width="">
                    <template #default="scope">
                        <el-button-group>
                            <el-button text type="primary" size="small"
                                @click="download(scope.row, scope.$index)">下载</el-button>
                            <el-popconfirm width="220" title="确定将选择的数据删除" @confirm="table_del(scope.row)">
                                <template #reference>
                                    <el-button text type="primary" size="small">删除</el-button>
                                </template>
                            </el-popconfirm>
                        </el-button-group>
                    </template>
                </el-table-column>
            </el-table>
        </el-main>
        <scDialog v-model="visible">
            <el-tabs v-model="activeName" type="card" class="demo-tabs">
                <el-tab-pane label="归档目录" name="1">
                    <el-tree :expand-on-click-node="false" v-if="activeName === '1'" ref="group" node-key="id" :props="{
                        label: 'name',
                        hasChildren: 'id'
                    }" show-checkbox :load="loadNode" lazy></el-tree>
                </el-tab-pane>
                <el-tab-pane label="工艺管理" name="2">
                    <el-tree :expand-on-click-node="false" v-if="activeName === '2'" ref="group" node-key="id" :props="{
                        label: 'name',
                        hasChildren: 'id'
                    }" show-checkbox :load="loadNode1" lazy></el-tree>
                </el-tab-pane>
            </el-tabs>
            <template #footer>
                <div style="text-align: right;">
                    <el-button type="primary" @click="confirm">确定</el-button>
                </div>
            </template>
 
        </scDialog>
    </el-container>
</template>
 
<script>
export default {
    props: {
        treeChecked: {
            type: Array,
        }
    },
    watch: {
        treeChecked(val) {
            console.log(val[0])
            if (val?.[0]) {
                this.init(val?.[0])
            } else {
                this.treeData = []
            }
        },
        storageSpaceId() {
            this.getFilelist()
        }
    },
    data() {
        return {
            treeData: [],
            storageSpaceId: '',
            tableData: [],
            tableDataFile: [],
            selection: [],
            selectionFile: [],
            visible: false,
            activeName: '1'
        }
    },
    methods: {
        init(workstationId) {
            this.$HTTP.get(`/api/blade-dnc/dnc-fixed-space/direct-loading-space-tree?workstationId=${workstationId}`).then(res => {
                this.storageSpaceId = res.data[0].id
                this.treeData = this.formatData(res.data)
            })
        },
        formatData(data, current, flag) {
            let newData = []
            if (!current) {
                newData = data.filter(item => item.parentId == 0).map(v => {
                    v.children = this.formatData(data, v, flag).sort((a, b) => {
                        return b.sort - a.sort
                    })
                    flag && (v.disabled = !v.isWorkstation)
                    return v
                })
            } else {
                let res = data.filter(v => v.parentId == current.id)
                res = res.map(item => {
                    item.children = this.formatData(data, item, flag).sort((a, b) => {
                        return b.sort - a.sort
                    })
                    flag && (item.disabled = !item.isWorkstation)
                    return item
                })
                return res
            }
            return newData
        },
        getFilelist() {
            this.$HTTP.post(`/api/blade-dnc/transfer-directory/fileList`, {
                storageSpaceId: this.storageSpaceId,
                fileLocations: [2],
                workstationId: this.treeChecked[0]
            }).then(res => {
                this.selection = []
                this.tableData = res.data.filter(v => v.fileType == 1)
                this.tableDataFile = res.data.filter(v => v.fileType == 2)
            })
        },
        onSelectionChange(selection) {
            this.selection = selection
        },
        onSelectionChangeFile(selection) {
            this.selectionFile = selection
        },
        download() {
 
        },
        table_del(row) {
            this.$HTTP.get(`/api/blade-dnc/transfer-directory/delete-file/${row.id}`).then(res => {
                this.getFilelist()
            })
        },
        loadNode(node, resolve) {
            let id = node.level === 0 ? '' : node.data.id
            this.$HTTP.get(`/api/blade-dnc/dnc-archive-directory/list?parentId=${id}`).then(res => {
                resolve(res.data)
            })
        },
        loadNode1(node, resolve) {
            let id = node.level === 0 ? '' : node.data.id
            this.$HTTP.get(`/api/blade-dnc/dnc-process-catalogue/lazy-art-list?parentId=${id}`).then(res => {
                resolve(res.data)
            })
        },
        archive() {
            this.visible = true
        },
        async confirm() {
            let archiveDirectoryIds = this.$refs.group.getCheckedNodes().map(v => v.id)
            console.log('>>>>>>', archiveDirectoryIds)
            if (archiveDirectoryIds.length === 0) {
                return this.$message.warning(`请选择文件夹`);
            }
            if (this.activeName === '1') {
                this.$HTTP.post(`/api/blade-dnc/dnc-archive-directory-file/checkFile`, {
                    archiveDirectoryIds,
                    voList: [...this.selection, ...this.selectionFile].map(v => {
                        return {
                            contentMd5: v.contentMd5,
                            filename: v.filename,
                            objectKey: v.objectKey,
                            workstationId: v.workstationId
                        }
                    })
                }).then(res => {
                    if (!res.data) {
                        this.$HTTP.post(`/api/blade-dnc/dnc-archive-directory-file/insert`, {
                            archiveDirectoryIds,
                            fileAddVOList: [...this.selection, ...this.selectionFile].map(v => {
                                return {
                                    contentLength: v.contentLength,
                                    contentMd5: v.contentMd5,
                                    contentType: v.contentType,
                                    fileOwnership: v.documentOwnerships || 1,
                                    filename: v.filename,
                                    link: v.link,
                                    objectKey: v.objectKey,
                                    originalFilename: v.originalFilename,
                                    suffix: v.suffix,
                                    workstationFileId: v.id,
                                    workstationId: v.workstationId,
                                }
                            })
                        }).then(res => {
                            this.visible = false
                            this.$message.success(res.msg);
                        })
                    }
                })
            } else {
                Promise.all(archiveDirectoryIds.map(v => {
                    return this.$HTTP.post(`/api/blade-dnc/dnc-art-file/duplicate-validation-file`, {
                        artBagId: v,
                        artFileAddVOList: [...this.selection, ...this.selectionFile].map(v => {
                            return {
                                contentMd5: v.contentMd5,
                                fileType: v.fileType,
                                filename: v.filename,
                                objectKey: v.objectKey,
                            }
                        })
                    })
                })).then(arr => {
                    let artBagIds = []
                    arr.forEach((item, index) => {
                        if (!item.data) artBagIds.push(archiveDirectoryIds[index])
                    });
                    if (artBagIds.length === 0) {
                        return this.$message.warning(`重复`);
                    }
                    this.$HTTP.post(`/api/blade-dnc/dnc-art-file/batch-insert`, {
                        artBagIds,
                        dncArtFileAddList: [...this.selection, ...this.selectionFile]
                    }).then(res => {
                        this.visible = false
                        this.$message.success(res.msg);
                    })
                })
            }
 
            // /api/blade-dnc/dnc-archive-directory-file/checkFile
        }
    },
}
</script>
 
<style lang="scss" scoped></style>