gaoshp
2024-06-13 ab493128b646ede67a2bfa2e16c966eb4e5f2d94
传输文件
已修改2个文件
293 ■■■■■ 文件已修改
src/components/scForm/index.vue 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/dnc/transport/index.vue 288 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/components/scForm/index.vue
@@ -4,7 +4,7 @@
 * @Author: sakuya
 * @Date: 2021年9月22日09:26:25
 * @LastEditors: Sneed
 * @LastEditTime: 2024-06-11 19:41:06
 * @LastEditTime: 2024-06-13 22:50:27
-->
<template>
@@ -112,7 +112,8 @@
                        </template>
                        <template v-else-if="item.component == 'el-tree-select'">
                            <el-tree-select v-model="form[item.name]" :data="item.options.data"
                                :multiple="item.options.multiple" show-checkbox default-expand-all style="width: 100%"
                                :check-strictly="item.options.checkStrictly" :multiple="item.options.multiple"
                                :show-checkbox="!item.options.hidecheckbox" default-expand-all style="width: 100%"
                                :props="{
                                    label: 'title',
                                    id: 'id',
src/views/dnc/transport/index.vue
@@ -1,7 +1,7 @@
<!--
 * @Date: 2024-05-26 21:59:53
 * @LastEditors: Sneed
 * @LastEditTime: 2024-05-26 22:11:25
 * @LastEditTime: 2024-06-13 23:17:58
 * @FilePath: /belleson-frontend/Users/mache/Documents/demo/cps-web/src/views/dnc/transport/index.vue
-->
<template>
@@ -13,21 +13,49 @@
                        <el-col :span="8" :gutter="20">
                            <el-tabs v-model="activeName" type="card" class="demo-tabs" @tab-click="handleClick">
                                <el-tab-pane label="我的文档" name="1">
                                    <el-tree default-expand-all ref="tree" node-key="id" :data="treeData" :props="{
                                        label: 'name',
                                    }" @node-click="nodeClick" highlight-current :current-node-key="selectNode.id">
                                        <template #default="{ node, data }">
                                            <span :class="data.isGroup ? 'active' : ''" class="custom-tree-node">
                                                <span>{{
                                                    node.label || data.code }}</span>
                                            </span>
                                        </template>
                                    </el-tree>
                                </el-tab-pane>
                                <el-tab-pane label="工艺管理" name="2">
                                    <el-tree default-expand-all ref="tree" node-key="id" :data="treeData1" :props="{
                                        label: (data, node) => {
                                            return data.name || data.artName
                                        },
                                    }" @node-click="nodeClick" highlight-current :current-node-key="selectNode.id">
                                        <template #default="{ node, data }">
                                            <span :class="data.isGroup ? 'active' : ''" class="custom-tree-node">
                                                <span>{{
                                                    node.label || data.code }}</span>
                                            </span>
                                        </template>
                                    </el-tree>
                                </el-tab-pane>
                            </el-tabs>
                        </el-col>
                        <el-col :span="16">
                            <el-table :data="tableData" style="width: 100%">
                            <el-table :data="tableData" style="width: 100%" @selection-change="onSelectionChange">
                                <el-table-column type="selection" width="50"></el-table-column>
                                <el-table-column label="文件名称" prop="" width=""></el-table-column>
                                <el-table-column label="源路径" prop="" width=""></el-table-column>
                                <el-table-column label="大小" prop="" width=""></el-table-column>
                                <el-table-column label="文件类型" prop="" width=""></el-table-column>
                                <el-table-column label="更新时间" prop="" width=""></el-table-column>
                                <el-table-column label="文件名称" prop="filename" width="">
                                    <template #default="scope">
                                        {{ scope.row.filename || scope.row.name }}
                                    </template>
                                </el-table-column>
                                <el-table-column label="源路径" prop="sourcePath" width="">
                                    <template #default="scope">
                                        {{ scope.row.sourcePath || scope.row.allPathName }}
                                    </template>
                                </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="updateTime" width=""></el-table-column>
                            </el-table>
                        </el-col>
                    </el-row>
@@ -35,9 +63,9 @@
                <div class="main-container-item">
                    <el-row>
                        <el-col :span="8" :gutter="20">
                            <el-tabs v-model="activeName" type="card" class="demo-tabs" @tab-click="handleClick">
                            <el-tabs v-model="activeName1" type="card" class="demo-tabs" @tab-click="handleClick">
                                <el-tab-pane label="以太网" name="1">
                                    <MYTree v-model="treeChecked"></MYTree>
                                </el-tab-pane>
                                <el-tab-pane label="内部存储" name="2">
@@ -46,30 +74,255 @@
                        </el-col>
                        <el-col :span="8">
                            <h3>程序</h3>
                            <el-table :data="tableData" style="width: 100%">
                            <el-button type="primary" @click="copy">传输至当前目标</el-button>
                            <!-- <el-button type="primary" @click="copy1">上传至上方路径</el-button> -->
                            <el-table :data="list1" style="width: 100%">
                                <el-table-column type="selection" width="50"></el-table-column>
                                <el-table-column label="文件名称" prop="" width=""></el-table-column>
                                <el-table-column label="存储空间" prop="" width=""></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="fixSpaceLocation" width=""></el-table-column>
                                <el-table-column label="大小" prop="contentLength" width=""></el-table-column>
                            </el-table>
                        </el-col>
                        <el-col :span="8">
                            <h3>文件</h3>
                            <el-table :data="tableData" style="width: 100%">
                            <el-button type="primary" @click="copy3">传输至当前目标</el-button>
                            <!-- <el-button type="primary">上传至上方路径</el-button> -->
                            <el-table :data="list2" style="width: 100%">
                                <el-table-column type="selection" width="50"></el-table-column>
                                <el-table-column label="文件名称" prop="" width=""></el-table-column>
                                <el-table-column label="存储空间" prop="" width=""></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="fixSpaceLocation" width=""></el-table-column>
                                <el-table-column label="大小" prop="contentLength" width=""></el-table-column>
                            </el-table>
                        </el-col>
                    </el-row>
                </div>
            </div>
        </el-card>
        <scDialog v-model="visible">
            <scForm ref="form" :config="config" :rules="rules" v-model="form" @submit="submit">
            </scForm>
        </scDialog>
    </el-main>
</template>
<script>
import MYTree from '@/views/mdc/MYTree.vue'
export default {
    components: {
        MYTree,
    },
    computed: {
        list1() {
            return this.list.filter(v => v.fileType == 1)
        },
        list2() {
            return this.list.filter(v => v.fileType == 2)
        }
    },
    data() {
        return {
            activeName: '1',
            activeName1: '1',
            selectNode: {},
            treeData: [],
            treeData1: [],
            tableData: [],
            treeChecked: {},
            list: [],
            workTreeData: [],
            config: {
                labelWidth: 120,
                formItems: [
                    {
                        component: 'el-tree-select',
                        label: '文件位置',
                        name: 'storageSpaceId',
                        options: {
                            multiple: false,
                            data: [],
                            hidecheckbox: true,
                            props: {
                                label: 'name'
                            },
                            checkStrictly: true
                        }
                    }
                ]
            },
            visible: false,
            form: {},
            rules: {
                name: [
                    { required: true, message: '请输入姓名' }
                ]
            },
            selection: [],
            fileType: 1,
        }
    },
    watch: {
        activeName() {
            this.selectNode = {}
            this.selection = []
        },
        'selectNode.id'(val) {
            console.log(val, '>>>>>>>')
            if (val !== undefined && val !== '')
                if (this.activeName === '1') {
                    this.$HTTP.get(`/api/blade-dnc/folder?parent=${val}`).then(res => {
                        if (res.success) {
                            this.tableData = res.data.fileList
                        } else {
                            this.tableData = []
                        }
                    }).catch(err => {
                        this.tableData = []
                    })
                } else {
                    this.$HTTP.get(`/api/blade-dnc/dnc-art-file/list?artBagId=${val}`).then(res => {
                        if (res.success) {
                            this.tableData = res.data
                        } else {
                            this.tableData = []
                        }
                    }).catch(err => {
                        this.tableData = []
                    })
                }
        },
        treeChecked(val) {
            if (val?.length > 0) {
                this.getFileList(val?.[0])
                this.$HTTP.get(`/api/blade-dnc/dnc-fixed-space/direct-loading-space-tree?workstationId=${val?.[0]}`).then(res => {
                    if (res.success) {
                        this.workTreeData = this.formatData(res.data)
                        console.log(this.workTreeData)
                    } else {
                        this.workTreeData = []
                    }
                }).catch(err => {
                    this.workTreeData = []
                })
            }
            console.log(val)
        }
    },
    created() {
        this.init()
    },
    methods: {
        formatData(data, current) {
            let newData = []
            if (!current) {
                newData = data.filter(item => item.parentId == 0).map(v => {
                    v.children = this.formatData(data, v).sort((a, b) => {
                        return b.sort - a.sort
                    })
                    return v
                })
            } else {
                let res = data.filter(v => v.parentId === current.id)
                res = res.map(item => {
                    item.children = this.formatData(data, item).sort((a, b) => {
                        return b.sort - a.sort
                    })
                    return item
                })
                return res
            }
            return newData
        },
        init() {
            this.selectNode = {
                id: ''
            }
            this.$HTTP.get(`/api/blade-dnc/folder/folder-tree`).then(res => {
                this.treeData = [{
                    group: true,
                    id: 0,
                    name: '我的文档',
                    children: res.data
                }]
                // this.selectNode = {
                //     group: true,
                //     id: 0,
                //     name: '我的文档',
                // }
            })
            this.$HTTP.get(`/api/blade-dnc/dnc-process-catalogue/art-tree`).then(res => {
                this.treeData1 = res.data
            })
        },
        nodeClick(node) {
            this.selectNode = node
        },
        onSelectionChange(selection) {
            this.selection = selection
        },
        getFileList(workstationId) {
            this.$HTTP.post(`/api/blade-dnc/transfer-directory/fileList`, {
                fileLocations: [2],
                workstationId
            }).then(res => {
                if (res.success) {
                    this.list = res.data
                } else {
                    this.list = []
                }
            }).catch(err => {
                this.list = []
            })
        },
        copy() {
            this.fileType = 1
            this.visible = true
            this.config.formItems[0].options.data = this.workTreeData
        },
        copy3() {
            this.fileType = 2
            this.visible = true
            this.config.formItems[0].options.data = this.workTreeData
        },
        submit() {
            console.log(this.form)
            let data = {
                workstationDirectoryFileVOList: this.selection.map(v => {
                    return {
                        contentLength: v.contentLength,
                        contentMd5: v.contentMd5,
                        contentType: v.contentType,
                        fileId: v.id,
                        fileSource: v.fileType,
                        fileType: this.fileType,
                        filename: v.filename || v.name,
                        lastModified: v.lastModified || new Date().getTime(),
                        link: v.link,
                        objectKey: v.objectKey,
                        originalFilename: v.originalFilename,
                        originalFilename: v.filename || v.name,
                        storageSpace: 1,
                        storageSpaceId: this.form.storageSpaceId,
                        suffix: v.suffix,
                        workstationId: '',
                        workstationName: ''
                    }
                }),
                workstationIds: this.treeChecked
            }
            this.$HTTP.post(`/api/blade-dnc/transfer-directory/duplicate-file`, data).then(res => {
                if (res.success) {
                    this.$HTTP.post(`/api/blade-dnc/transfer-directory/file`, data).then(res => {
                        this.visible = false
                        this.getFileList(this.treeChecked?.[0])
                    })
                }
            })
        }
    },
}
</script>
@@ -80,6 +333,7 @@
    height: 100%;
    &-item {
        overflow: auto;
        height: 50%;
        flex: 0 0 auto;
    }