1
lzhe
2024-10-16 e380c08a22f7546ad187b5bb8a3571db146133a2
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
<!--
 * @Date: 2024-05-20 21:43:10
 * @LastEditors: Sneed
 * @LastEditTime: 2024-06-16 16:19:14
 * @FilePath: /belleson-frontend/Users/mache/Documents/demo/cps-web/src/views/dnc/file/admin/index.vue
-->
<template>
    <el-main style="height: 100%;">
        <el-card shadow="never" style="height: 100%;" body-style="height: 100%">
            <el-container>
                <el-aside width="200px">
                    <el-tree :expand-on-click-node="false" ref="group" node-key="id" :props="{
                        label: 'name',
                        hasChildren: 'id'
                    }" :load="loadNode" @node-click="nodeClick" lazy></el-tree>
                </el-aside>
                <el-container>
                    <el-header>
                        <el-button style="margin-left: 8px;margin-right: auto;" type="danger" plain
                            :disabled="selection.length == 0" @click="del(selection)">删除</el-button>
                        <el-tree-select v-model="params.workstationId" default-expand-all clearable :data="treeData"
                            :render-after-expand="false" style="width: 240px;margin-left: auto;" :props="{
                                label: 'title',
                            }" node-key="id">
                            <template #prefix><span style="margin-right: 6px;">工位目录</span></template>
                        </el-tree-select>
                        <el-date-picker style="width: 260px;flex-grow: 0;margin-left: 8px;" v-model="params.time"
                            type="daterange" range-separator="-" start-placeholder="开始时间" end-placeholder="结束时间" />
                        <el-input v-model="params.keywords" style="width: 240px;margin-left: 8px;" placeholder="文件名称、后缀"
                            clearable>
                            <template #prefix>关键词</template>
                        </el-input>
                        <el-button style="margin-left: 8px;" @click="search" type="primary"
                            icon="el-icon-search"></el-button>
                    </el-header>
                    <el-main>
                        <scTable v-if="selectNode.id || selectNode.id === 0" 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">
                            </el-table-column>
                            <el-table-column label="工位目录" prop="workstationName"></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="updateTime"></el-table-column>
                            <el-table-column label="操作" fixed="right" align="right" width="160">
                                <template #default="scope">
                                    <el-button-group>
                                        <el-popconfirm width="220" title="确定将选择的数据删除" @confirm="del([scope.row], '0')">
                                            <template #reference>
                                                <el-button text type="primary" size="small">删除</el-button>
                                            </template>
                                        </el-popconfirm>
                                    </el-button-group>
                                </template>
                            </el-table-column>
                        </scTable>
                    </el-main>
                </el-container>
            </el-container>
 
        </el-card>
    </el-main>
</template>
 
<script>
export default {
    data() {
        return {
            selection: [],
            selectNode: {
            },
            treeData: [],
            params: {
                time: [],
                startTime: '',
                endTime: '',
                keywords: '',
                workstationId: ''
            },
            apiObj: {
                get: async (data) => {
                    let params = {
                        current: data.current,
                        size: data.size
                    }
                    let data1 = {
                        arId: this.selectNode.id,
                        ...this.params,
                        startTime: this.params.time[0] || '',
                        endTime: this.params.time[1] || ''
                    }
                    return await this.$HTTP.post(`/api/blade-dnc/dnc-archive-directory-file/page`, {}, { params, data: data1 }).then(res => {
                        return res
                    })
                }
            },
        }
    },
    mounted() {
        this.init()
    },
    methods: {
        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 => {
                if (node.level === 0) {
 
                    this.nodeClick(res.data[0])
                }
                resolve(res.data)
            })
        },
        init() {
            this.$HTTP.post(`/api/blade-cps/group/groupWorkstation`, { groupCategory: 1, groupType: 'group_workstation' }).then(res => {
                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)
                    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)
                    item.disabled = !item.isWorkstation
                    return item
                })
                return res
            }
            return newData
        },
        nodeClick(node) {
            if (!node.id && node.id !== 0) return
            this.selectNode = node
            console.log(node.id)
            this.$nextTick(() => {
                this.$refs.table?.reload()
            })
        },
        search() {
            this.$refs.table.reload()
        },
        selectionChange(selection) {
            this.selection = selection
        },
        del(selection) {
            this.$HTTP.delete(`/api/blade-dnc/dnc-archive-directory-file/remove`, {}, { data: selection.map(v => v.id) }).then(res => {
                this.search()
            })
        },
        rowClick() {
 
        },
    }
}
</script>
 
<style lang="scss" scoped></style>