gaoshp
2024-06-13 fd7586c8d91473d2850af1e48b12f1a289e6b8d1
新增文件
已修改2个文件
已添加1个文件
504 ■■■■■ 文件已修改
src/views/dnc/craft/document/Children.vue 103 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/dnc/craft/document/File.vue 388 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/dnc/craft/document/index.vue 13 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/dnc/craft/document/Children.vue
@@ -1,64 +1,75 @@
<!--
 * @Date: 2024-05-26 21:50:26
 * @LastEditors: Sneed
 * @LastEditTime: 2024-06-11 22:19:59
 * @LastEditTime: 2024-06-12 23:57:38
 * @FilePath: /belleson-frontend/Users/mache/Documents/demo/cps-web/src/views/dnc/craft/document/Children.vue
-->
<template>
    <el-tabs v-model="activeName" type="card" class="demo-tabs" @tab-click="handleClick">
        <el-tab-pane label="程序" name="1">
            <el-button type="primary" @click="addFile">添加文件</el-button>
            <el-table :data="tableData" style="width: 100%">
                <el-table-column label="文件名" prop="filename" width=""></el-table-column>
                <el-table-column label="文件大小" prop="contentLength" width=""></el-table-column>
                <el-table-column label="文件类型" prop="suffix" width=""></el-table-column>
    <div>
        <el-tabs v-model="activeName" type="card" class="demo-tabs" @tab-click="handleClick">
            <el-tab-pane label="程序" name="1">
                <el-button type="primary" @click="addFile(1)">添加文件</el-button>
                <el-table :data="tableData" style="width: 100%">
                    <el-table-column label="文件名" prop="filename" 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="" width="">
                    <template #default="scope">
                        <el-button-group>
                            <el-popconfirm v-if="!scope.row.isSet" title="确定删除吗?"
                                @confirm="table_del(scope.row, scope.$index)">
                                <template #reference>
                                    <el-button text type="primary" size="small">删除</el-button>
                                </template>
                            </el-popconfirm>
                        </el-button-group>
                    </template>
                </el-table-column>
            </el-table>
        </el-tab-pane>
        <el-tab-pane label="文档" name="2">
            <el-button type="primary" @click="addFile">添加文件</el-button>
            <el-table :data="tableData1" style="width: 100%">
                <el-table-column label="文件名" prop="filename" 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="" width="">
                        <template #default="scope">
                            <el-button-group>
                                <el-popconfirm v-if="!scope.row.isSet" title="确定删除吗?"
                                    @confirm="table_del(scope.row, scope.$index)">
                                    <template #reference>
                                        <el-button text type="primary" size="small">删除</el-button>
                                    </template>
                                </el-popconfirm>
                            </el-button-group>
                        </template>
                    </el-table-column>
                </el-table>
            </el-tab-pane>
            <el-tab-pane label="文档" name="2">
                <el-button type="primary" @click="addFile(2)">添加文件</el-button>
                <el-table :data="tableData1" style="width: 100%">
                    <el-table-column label="文件名" prop="filename" 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="" width="">
                    <template #default="scope">
                        <el-button-group>
                            <el-popconfirm v-if="!scope.row.isSet" title="确定删除吗?"
                                @confirm="table_del(scope.row, scope.$index)">
                                <template #reference>
                                    <el-button text type="primary" size="small">删除</el-button>
                                </template>
                            </el-popconfirm>
                        </el-button-group>
                    </template>
                </el-table-column>
            </el-table>
        </el-tab-pane>
    </el-tabs>
                    <el-table-column label="操作" prop="" width="">
                        <template #default="scope">
                            <el-button-group>
                                <el-popconfirm v-if="!scope.row.isSet" title="确定删除吗?"
                                    @confirm="table_del(scope.row, scope.$index)">
                                    <template #reference>
                                        <el-button text type="primary" size="small">删除</el-button>
                                    </template>
                                </el-popconfirm>
                            </el-button-group>
                        </template>
                    </el-table-column>
                </el-table>
            </el-tab-pane>
        </el-tabs>
        <File ref="file" @success="success"></File>
    </div>
</template>
<script>
import File from './File.vue'
export default {
    components: {
        File
    },
    props: {
        list: {
            type: Array,
            default() {
                return []
            }
        },
        id: {
            type: String,
        }
    },
    computed: {
@@ -75,6 +86,9 @@
        }
    },
    methods: {
        addFile(fileType) {
            this.$refs.file.open(fileType, this.id)
        },
        handleClick() {
        },
@@ -84,6 +98,9 @@
                    this.$emit('delete')
                }
            })
        },
        success() {
            this.$emit('success')
        }
    }
}
src/views/dnc/craft/document/File.vue
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,388 @@
<!--
 * @Date: 2024-06-12 22:07:23
 * @LastEditors: Sneed
 * @LastEditTime: 2024-06-13 00:07:27
 * @FilePath: /belleson-frontend/Users/mache/Documents/demo/cps-web/src/views/dnc/craft/document/File.vue
-->
<template>
    <div>
        <scDialog style="min-height: 400px;" v-model="visible">
            <el-tabs v-model="activeName" type="card" class="demo-tabs" @tab-click="handleClick">
                <el-tab-pane label="我的文档" name="1">
                    <el-container v-if="activeName == '1'">
                        <el-aside width="220px">
                            <el-row>
                                <el-col>
                                    <el-input style="width: 180px;" v-model="filterText" placeholder="请输入关键词进行过滤" />
                                </el-col>
                                <el-col style="margin-top: 8px;">
                                    <el-tree ref="treeRef" default-expand-all node-key="id" :data="treeData" :props="{
                                        label: 'name',
                                    }" @node-click="nodeClick" :filter-node-method="filterNode" 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-col>
                            </el-row>
                        </el-aside>
                        <el-container>
                            <el-header>
                                <el-input style="width: 180px;" v-model="searchKey" placeholder="请输入关键词进行过滤" />
                            </el-header>
                            <el-main v-if="selectNode?.id !== ''">
                                <scTable highlight-current-row ref="table" :apiObj="apiObj1"
                                    @selection-change="selectionChange" stripe>
                                    <el-table-column type="selection" width="50"></el-table-column>
                                    <el-table-column label="文件名称" prop="name">
                                    </el-table-column>
                                    <el-table-column label="文件路径" prop="allPathName"></el-table-column>
                                    <el-table-column label="大小" prop="contentLength"></el-table-column>
                                    <el-table-column label="版本" prop="version"></el-table-column>
                                    <el-table-column label="文件类型" prop="suffix"></el-table-column>
                                    <el-table-column label="更新时间" prop="updateTime"></el-table-column>
                                </scTable>
                            </el-main>
                        </el-container>
                    </el-container>
                </el-tab-pane>
                <el-tab-pane label="工位文件" name="2">
                    <el-container v-if="activeName == '2'">
                        <el-aside width="220px">
                            <el-row>
                                <el-col>
                                    <el-input style="width: 180px;" v-model="filterText" placeholder="请输入关键词进行过滤" />
                                </el-col>
                                <el-col style="margin-top: 8px;">
                                    <el-tree :load="loadNode" ref="treeRef" default-expand-all node-key="id" :props="{
                                        label: 'name',
                                        hasChildren: 'id'
                                    }" @node-click="nodeClick" :filter-node-method="filterNode" highlight-current
                                        :current-node-key="selectNode?.id" lazy>
                                        <template #default="{ node, data }">
                                            <span :class="data.isGroup ? 'active' : ''" class="custom-tree-node">
                                                <span>{{
                                                    node.label || data.code }}</span>
                                            </span>
                                        </template>
                                    </el-tree>
                                </el-col>
                            </el-row>
                        </el-aside>
                        <el-container>
                            <el-header>
                                <el-input style="width: 180px;" v-model="searchKey" placeholder="请输入关键词进行过滤" />
                            </el-header>
                            <el-main v-if="selectNode?.id !== ''">
                                <scTable highlight-current-row ref="table" :apiObj="apiObj2"
                                    @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="contentLength"></el-table-column>
                                    <el-table-column label="版本" prop="version"></el-table-column>
                                    <el-table-column label="文件类型" prop="suffix"></el-table-column>
                                    <el-table-column label="文件归属" prop="documentOwnershipDesc"></el-table-column>
                                    <el-table-column label="存储时间" prop="storageSpaceDec"></el-table-column>
                                </scTable>
                            </el-main>
                        </el-container>
                    </el-container>
                </el-tab-pane>
                <el-tab-pane label="归档文件" name="3">
                    <el-container v-if="activeName == '3'">
                        <el-aside width="220px">
                            <el-row>
                                <el-col>
                                    <el-input style="width: 180px;" v-model="filterText" placeholder="请输入关键词进行过滤" />
                                </el-col>
                                <el-col style="margin-top: 8px;">
                                    <el-tree :load="loadNode1" ref="treeRef" default-expand-all node-key="id" :props="{
                                        label: 'name',
                                        hasChildren: 'id'
                                    }" @node-click="nodeClick" :filter-node-method="filterNode" highlight-current
                                        :current-node-key="selectNode?.id" lazy>
                                        <template #default="{ node, data }">
                                            <span :class="data.isGroup ? 'active' : ''" class="custom-tree-node">
                                                <span>{{
                                                    node.label || data.name }}</span>
                                            </span>
                                        </template>
                                    </el-tree>
                                </el-col>
                            </el-row>
                        </el-aside>
                        <el-container>
                            <el-header>
                                <el-input style="width: 180px;" v-model="searchKey" placeholder="请输入关键词进行过滤" />
                            </el-header>
                            <el-main v-if="selectNode?.id !== ''">
                                <scTable highlight-current-row ref="table" :apiObj="apiObj3"
                                    @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="contentLength"></el-table-column>
                                    <el-table-column label="版本" prop="version"></el-table-column>
                                    <el-table-column label="文件类型" prop="suffix"></el-table-column>
                                </scTable>
                            </el-main>
                        </el-container>
                    </el-container>
                </el-tab-pane>
                <el-tab-pane label="本地上传" name="4">
                    <el-upload style="margin-left: 8px;" :show-file-list="false" class="upload" :http-request="request">
                        <el-button type="primary">上传文件</el-button>
                    </el-upload>
                </el-tab-pane>
            </el-tabs>
            <template #footer>
                <el-button type="primary" @click="save">确定</el-button>
            </template>
        </scDialog>
    </div>
</template>
<script>
export default {
    watch: {
        filterText(val) {
            this.$refs.treeRef.filter(val)
        },
        'selectNode.id'(val) {
            this.$refs.table.reload()
        },
        activeName(val) {
            this.selection = []
            if (val === '1') {
                this.init()
            }
        }
    },
    data() {
        return {
            activeName: '1',
            visible: false,
            filterText: '',
            selectNode: {
                id: ''
            },
            treeData: [],
            fileType: 1,
            searchKey: '',
            selection: [],
            apiObj1: {
                get: async (data) => {
                    let params = {
                        ...data,
                        fileType: this.fileType,
                        parent: this.selectNode.id,
                        searchKey: this.searchKey
                        // ...this.params
                    }
                    return await this.$HTTP.get(`/api/blade-dnc/folder/file-page`, {}, { params }).then(res => {
                        return res
                    })
                }
            },
            apiObj2: {
                get: async (data) => {
                    let params = {
                        ...data,
                    }
                    let newData = {
                        fileType: `${this.fileType}`,
                        keywords: this.searchKey,
                        workstationId: this.selectNode.id
                    }
                    return await this.$HTTP.post(`/api/blade-dnc/transfer-directory/page`, {}, { params, data: newData }).then(res => {
                        return {
                            success: true,
                            code: 200,
                            data: {
                                ...res
                            }
                        }
                    })
                }
            },
            apiObj3: {
                get: async (data) => {
                    let params = {
                        ...data,
                    }
                    let newData = {
                        fileType: `${this.fileType}`,
                        keywords: this.searchKey,
                        arId: this.selectNode.id
                    }
                    return await this.$HTTP.post(`/api/blade-dnc/dnc-archive-directory-file/page`, {}, { params, data: newData }).then(res => {
                        return res
                    })
                }
            },
            id: ''
        }
    },
    created() {
    },
    methods: {
        open(fileType, id) {
            this.visible = true
            this.fileType = fileType
            this.activeName = '1'
            this.id = id
            this.init()
        },
        filterNode(value, data) {
            console.log(value, data)
            if (!value) return true
            return data.name.includes(value)
        },
        nodeClick(node) {
            this.selectNode = node
        },
        init() {
            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: '我的文档',
                }
            })
        },
        loadNode(node, resolve) {
            let id = node.level === 0 ? '' : node.data.id
            if (node.level === 0) {
                return this.$HTTP.get(`/api/blade-cps/group/getRootNode?groupCategory=1&groupType=group_workstation`).then(res => {
                    this.nodeClick(res.data)
                    resolve([res.data].map(v => {
                        return {
                            ...v,
                            name: v.name,
                            id: v.id
                        }
                    }))
                })
            } else {
                this.$HTTP.get(`/api/blade-cps/group/groupWorkstation/lazy?groupId=${id}`).then(res => {
                    resolve(res.data.map(v => {
                        return {
                            ...v,
                            name: v.title
                        }
                    }))
                })
            }
        },
        loadNode1(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.map(v => {
                    return {
                        ...v,
                    }
                }))
            })
        },
        selectionChange(selection) {
            this.selection = selection
        },
        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(resFile => {
                this.$HTTP.post(`/api/blade-dnc/dnc-art-file/duplicate-validation-file`, {
                    artBagId: this.id, artFileAddVOList: [{
                        fileType: `${this.fileType}`,
                        filename: resFile.data.originalName,
                        objectKey: resFile.data.name
                    }]
                }).then(res => {
                    if (res.success) {
                        this.$HTTP.post(`/api/blade-dnc/dnc-art-file/insert`, [{
                            artBagId: this.id,
                            fileType: `${this.fileType}`,
                            contentLength: options.file.size,
                            filename: options.file.name,
                            link: resFile.data.link,
                            objectKey: resFile.data.name,
                            originalFilename: options.file.name,
                            sourceType: 3,
                            suffix: resFile.data.originalName.split('.').pop(),
                        }]).then(res => {
                            this.success(res)
                        })
                    } else {
                        this.$message.error(res.msg)
                    }
                })
            })
        },
        save() {
            console.log(this.selection)
            if (this.selection.length == 0) {
                this.visible = false
            } else {
                this.$HTTP.post(`/api/blade-dnc/dnc-art-file/duplicate-validation-file`, {
                    artBagId: this.id, artFileAddVOList: this.selection.map(v => {
                        return {
                            contentMd5: v.contentMd5,
                            fileType: `${this.fileType}`,
                            filename: v.filename,
                            objectKey: v.objectKey
                        }
                    })
                }).then(res => {
                    if (res.success) {
                        this.$HTTP.post(`/api/blade-dnc/dnc-art-file/insert`, this.selection.map(v => {
                            return {
                                artBagId: this.id,
                                contentLength: v.contentLength,
                                contentMd5: v.contentMd5,
                                contentType: v.contentType,
                                fileId: v.id,
                                fileType: `${this.fileType}`,
                                filename: v.filename,
                                link: v.link,
                                objectKey: v.objectKey,
                                suffix: v.suffix
                            }
                        })).then(res => {
                            this.success(res)
                        })
                    } else {
                        this.$message.error(res.msg)
                    }
                })
            }
        },
        success(res) {
            if (res.success) {
                this.visible = false
                this.$emit('success')
                this.$message.success(res.msg)
            }
        }
    },
}
</script>
<style lang="scss" scoped></style>
src/views/dnc/craft/document/index.vue
@@ -1,7 +1,7 @@
<!--
 * @Date: 2024-05-26 16:12:09
 * @LastEditors: Sneed
 * @LastEditTime: 2024-06-11 22:28:01
 * @LastEditTime: 2024-06-13 00:04:32
 * @FilePath: /belleson-frontend/Users/mache/Documents/demo/cps-web/src/views/dnc/craft/document/index.vue
-->
<!--
@@ -72,7 +72,8 @@
                                        å·¥è‰ºåŒ…所在目录:{{ info.sourcePath }}
                                    </el-col>
                                    <el-col :span="24" style="margin: 14px 0;">
                                        <Children :list="list" @delete="searchFile"></Children>
                                        <Children @success="success" :list="list" @delete="searchFile" :id="info.id">
                                        </Children>
                                    </el-col>
                                </el-row>
                            </el-col>
@@ -344,7 +345,7 @@
            this.row = row
        },
        dataChange(data) {
            console.log(data)
            console.log(data, '>>>>>>>>dataChange')
            this.rowClick(data.data.records[0])
        },
        rowClick(row) {
@@ -352,11 +353,12 @@
            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 = {}
                }
            })
            this.searchFile()
        },
        searchFile() {
            this.$HTTP.get(`/api/blade-dnc/dnc-art-file/list?artBagId=${this.info.id}`).then(res => {
@@ -370,6 +372,9 @@
        },
        search() {
        },
        success() {
            this.searchFile()
        }
    }
}