gaoshp
2024-06-16 5be78f8d80e78ad76f5f322a0ea1f47105fffe6f
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
<!--
 * @Date: 2024-05-26 16:12:09
 * @LastEditors: Sneed
 * @LastEditTime: 2024-06-16 16:19:02
 * @FilePath: /belleson-frontend/Users/mache/Documents/demo/cps-web/src/views/dnc/craft/document/index.vue
-->
<!--
 * @Date: 2024-05-21 22:46:05
 * @LastEditors: Sneed
 * @LastEditTime: 2024-05-26 21:50:37
 * @FilePath: /belleson-frontend/Users/mache/Documents/demo/cps-web/src/views/dnc/craft/document/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'
                    }" @node-click="nodeClick" highlight-current :current-node-key="selectNode.id" :load="loadNode"
                        lazy></el-tree>
                </el-aside>
                <el-container>
                    <el-header>
                        <el-button style="margin-left: 8px;" type="danger" plain :disabled="selection.length === 0"
                            @click="del">删除</el-button>
                        <el-button style="margin-left: 8px;margin-right: auto;" type="primary"
                            @click="addNew">新增</el-button>
                        <!-- <el-select v-model="params.type" style="width: 240px;margin-left: 8px;">
                            <template #prefix>
                                查询目标
                            </template>
<el-option v-for="item in options.type" :key="item.value" :label="item.label" :value="item.value" />
</el-select>
<el-input style="width: 240px;margin-left: 8px;" v-model="params.keyword" placeholder="请输入检索内容"></el-input>
<el-button @click="search" style="margin-left: 8px;" type="primary" icon="el-icon-search"></el-button> -->
                    </el-header>
                    <el-main v-if="selectNode.id || selectNode.id == 0">
                        <el-row :gutter="20">
                            <el-col :span="12">
                                <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="name" width="160">
                                    </el-table-column>
                                    <el-table-column label="工艺包编号" prop="code" width="160"></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="table_edit(scope.row, scope.$index)">编辑</el-button>
                                                <el-button text type="primary" size="small"
                                                    @click="openLog(scope.row)">变更日志</el-button>
                                            </el-button-group>
                                        </template>
                                    </el-table-column>
                                </scTable>
                            </el-col>
                            <el-col :span="12">
                                <h2 style="background-color: var(--el-color-primary);color: #fff;padding: 4px 20px;">
                                    工艺包详情</h2>
                                <el-row style="margin: 14px 0;">
                                    <el-col :span="12">
                                        工艺包名称:{{ info.name }}
                                    </el-col>
                                    <el-col :span="12">
                                        工艺包编号:{{ info.code }}
                                    </el-col>
                                    <el-col :span="12">
                                        工艺包所在目录:{{ info.sourcePath }}
                                    </el-col>
                                    <el-col :span="24" style="margin: 14px 0;">
                                        <Children @success="success" :list="list" @delete="searchFile" :id="info.id">
                                        </Children>
                                    </el-col>
                                </el-row>
                            </el-col>
                        </el-row>
 
                    </el-main>
                </el-container>
            </el-container>
        </el-card>
        <scDialog v-model="newVisible">
            <scForm ref="form" :config="config" :rules="rules" v-model="form" @submit="submit">
            </scForm>
        </scDialog>
        <scDialog v-model="logVisible">
            <el-container>
                <el-header>
                    <el-button type="primary" @click="exportExcel">导出</el-button>
                    <el-input v-model="searchParams.fileName" style="width: 240px;margin-left: 8px;" placeholder="">
                        <template #prefix>文件名称</template>
                    </el-input>
                    <el-select v-model="searchParams.fileClass" style="width: 240px;margin-left: 8px;">
                        <template #prefix>
                            文件类型
                        </template>
                        <el-option v-for="item in options.fileClass" :key="item.value" :label="item.label"
                            :value="item.value" />
                    </el-select>
                    <el-select v-model="searchParams.fileType" style="width: 240px;margin-left: 8px;">
                        <template #prefix>
                            文件属性
                        </template>
                        <el-option v-for="item in options.fileType" :key="item.value" :label="item.label"
                            :value="item.value" />
                    </el-select>
                </el-header>
                <el-main>
                    <scTable highlight-current-row ref="table1" :apiObj="apiObj1" @selection-change="selectionChange"
                        stripe>
                        <el-table-column label="文件名称" prop="fileName" width="160">
                        </el-table-column>
                        <el-table-column label="版本号" prop="version" width="160"></el-table-column>
                        <el-table-column label="文件类型" prop="suffix" width="160"></el-table-column>
                        <el-table-column label="文件属性" prop="fileType" width="160"></el-table-column>
                        <el-table-column label="操作类型" prop="operationType" width="160"></el-table-column>
                        <el-table-column label="操作人员" prop="operatorName" width="160"></el-table-column>
                        <el-table-column label="操作时间" prop="operationTime" width="160"></el-table-column>
                    </scTable>
                </el-main>
            </el-container>
        </scDialog>
 
    </el-main>
</template>
 
<script>
import Children from './Children.vue'
export default {
    components: {
        Children
    },
    watch: {
        searchParams: {
            handler() {
                this.$refs?.table1?.reload()
            },
            deep: true
        }
    },
    data() {
        return {
            treeData: [],
            selection: [],
            params: {
                type: 'BAG_OR_PROCESS'
            },
            selectNode: {
                // id: 0
            },
            apiObj: {
                get: async (data) => {
                    let params = {
                        ...data,
                        catalogueId: this.selectNode.id,
                        // ...this.params
                    }
                    return await this.$HTTP.get(`/api/blade-dnc/dnc-art-bag/cur-sub-page`, {}, { params }).then(res => {
                        return res
                    })
                }
            },
            apiObj1: {
                get: async (data) => {
                    let params = {
                        ...data,
                        catalogueId: this.selectNode.id,
                        // ...this.params
                    }
                    return await this.$HTTP.post(`/api/blade-dnc/dnc-art-bag-log/page`, {}, { params, data: { ...this.searchParams } }).then(res => {
                        return res
                    })
                }
            },
            newVisible: false,
            config: {
                labelWidth: 120,
                formItems: [
                    {
                        component: 'input',
                        label: '工艺包名称',
                        name: 'name',
                        options: {
                            placeholder: '',
                            maxlength: 100,
                        }
                    },
                    {
                        component: 'input',
                        label: '工艺包编号',
                        name: 'code',
                        options: {
                            multiple: false,
                            data: []
                        },
                        disabled: false
                    }
                ]
            },
            form: {
            },
            rules: {
                name: [
                    { required: true, message: '请输入' },
                ],
                code: [
                    { required: true, message: '请输入' },
                ]
            },
            selection: [],
            logVisible: false,
            row: {},
            options: {
                type: [
                    {
                        value: 'BAG_OR_PROCESS',
                        label: '工艺包和程序文档'
                    },
                    {
                        value: 'ONLY_BAG',
                        label: '仅工艺包'
                    },
                    {
                        value: 'ONLY_PROCESS',
                        label: '仅程序文档'
                    },
                ],
                fileType: [
                    {
                        value: 1,
                        label: '程序'
                    },
                    {
                        value: 2,
                        label: '文档'
                    },
                ]
            },
            searchParams: {
                fileName: '',
                fileClass: '',
                fileType: '',
            },
            info: {},
            list: []
        }
    },
    created() {
        this.init()
    },
    methods: {
        init() {
            this.$HTTP.get(`/api/blade-system/param/detail?paramKey=dnc.support.file.suffix.list`).then(res => {
                this.options.fileClass = res.data.paramValue.split(',').map(v => {
                    return {
                        value: v,
                        label: v
                    }
                })
            })
        },
        loadNode(node, resolve) {
            console.log(node, '>>>>>>')
            let id = node.level === 0 ? '' : node.data.id
            this.$HTTP.get(`/api/blade-dnc/dnc-process-catalogue/lazy-list?parentId=${id}`).then(res => {
                if (node.level === 0) {
                    this.$nextTick(() => {
                        this.nodeClick(res.data[0])
                    })
                }
                resolve(res.data)
            })
        },
        addNew() {
            this.$refs?.form?.resetFields()
            this.form = {
                name: '',
                code: ''
            }
            this.config.formItems[1].disabled = false
            this.newVisible = true
        },
        submit() {
            if (this.form.id) {
                return this.$HTTP.put(`/api/blade-dnc/dnc-art-bag/update?id=${this.form.id}&name=${this.form.name}`).then(res => {
                    if (res.success) {
                        this.newVisible = false
                        this.$refs.table.reload()
                    }
                })
            }
            this.$HTTP.post(`/api/blade-dnc/dnc-art-bag/insert`, {
                catalogueId: this.selectNode.id,
                ...this.form
            }).then(res => {
                if (res.success) {
                    this.newVisible = false
                    this.$refs.table.reload()
                } else {
                    this.$message.error(res.msg)
                }
 
            })
        },
        table_edit(row) {
            this.$refs?.form?.resetFields()
            this.form = {
                name: row.name,
                code: row.code,
                id: row.id,
            }
            this.config.formItems[1].disabled = true
            this.newVisible = true
        },
        selectionChange(selection) {
            this.selection = selection
        },
        del() {
            this.$confirm(`是否确认删除?`, '提示', {
                type: 'warning',
            }).then(() => {
                this.$HTTP.delete(`/api/blade-dnc/dnc-art-bag/remove`, {}, { data: this.selection.map(v => v.id) }).then(res => {
                    this.$message.success("操作成功");
                    this.$refs.table.reload()
                })
            }).catch(() => {
                return false
            })
 
        },
        nodeClick(node, treeNode) {
            console.log(node, treeNode)
            this.selectNode = {
                ...node,
                parentName: treeNode?.parent?.data?.name || '-'
            }
            this.$refs?.table?.reload()
        },
        openLog(row) {
            this.logVisible = true
            this.row = row
        },
        dataChange(data) {
            console.log(data, '>>>>>>>>dataChange')
            this.rowClick(data.data.records[0])
        },
        rowClick(row) {
            if (!row) return this.info = {}
            this.$HTTP.get(`/api/blade-dnc/dnc-art-bag/get/${row.id}`).then(res => {
                if (res.success) {
                    this.info = res.data
                    this.searchFile()
                } else {
                    this.info = {}
                }
            })
 
        },
        searchFile() {
            this.$HTTP.get(`/api/blade-dnc/dnc-art-file/list?artBagId=${this.info.id}`).then(res => {
                if (res.success) {
                    this.list = res.data
                }
            })
        },
        exportExcel() {
 
        },
        search() {
 
        },
        success() {
            this.searchFile()
        }
    }
}
</script>
 
<style lang="scss" scoped></style>