gaoshp
2024-06-17 ddbb2bd2691629336faa4491a59fdc3dc3c5934e
src/views/dnc/document/index.vue
@@ -1,7 +1,7 @@
<!--
 * @Date: 2024-05-16 22:40:01
 * @LastEditors: Sneed
 * @LastEditTime: 2024-06-16 15:35:03
 * @LastEditTime: 2024-06-17 23:43:44
 * @FilePath: /belleson-frontend/Users/mache/Documents/demo/cps-web/src/views/dnc/document/index.vue
-->
<template>
@@ -11,8 +11,8 @@
                <el-aside width="200px">
                    <el-container>
                        <el-main>
                            <el-tree expand-on-click-node default-expand-all ref="tree" node-key="id" :data="treeData"
                                :props="{
                            <el-tree :expand-on-click-node="false" 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 }">
@@ -42,8 +42,12 @@
                                </el-dropdown-menu>
                            </template>
                        </el-dropdown>
                        <el-upload style="margin-left: 8px;" :show-file-list="false" class="upload"
                        <!-- <el-upload style="margin-left: 8px;" :show-file-list="false" class="upload"
                            action="/api/blade-resource/oss/endpoint/put-file">
                            <el-button type="primary">上传文件</el-button>
                        </el-upload> -->
                        <el-upload style="margin-left: 8px;" :show-file-list="false" class="upload"
                            :http-request="request">
                            <el-button type="primary">上传文件</el-button>
                        </el-upload>
                        <!-- <el-button type="primary" style="margin-left: 8px;">上传文件</el-button> -->
@@ -246,6 +250,36 @@
        this.init()
    },
    methods: {
        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 => {
                if (resFile.success) {
                    this.$HTTP.post(`/api/blade-dnc/file/batch-save`, [{
                        name: options.file.name,
                        targetId: this.selectNode.id,
                        ossFile: {
                            attachId: resFile.data.attachId,
                            domain: resFile.data.domain,
                            link: resFile.data.link,
                            name: resFile.data.name,
                            originalName: resFile.data.originalName
                        }
                    }]).then(res => {
                        if (res.success) {
                            this.visible = false
                            this.search()
                        } else {
                            this.$message.error(res.msg)
                        }
                    })
                } else {
                    this.$message.error(res.msg)
                }
            })
        },
        addFile() {
            this.form1 = {}
            this.$refs?.form?.resetFields()