From fd7586c8d91473d2850af1e48b12f1a289e6b8d1 Mon Sep 17 00:00:00 2001
From: gaoshp <291585735@qq.com>
Date: 星期四, 13 六月 2024 00:10:43 +0800
Subject: [PATCH] 新增文件

---
 src/views/dnc/document/index.vue |  111 ++++++++++++++++++++++++++++++++++++++++++++-----------
 1 files changed, 89 insertions(+), 22 deletions(-)

diff --git a/src/views/dnc/document/index.vue b/src/views/dnc/document/index.vue
index 61033c6..b18cdcc 100644
--- a/src/views/dnc/document/index.vue
+++ b/src/views/dnc/document/index.vue
@@ -1,7 +1,7 @@
 <!--
  * @Date: 2024-05-16 22:40:01
  * @LastEditors: Sneed
- * @LastEditTime: 2024-05-19 19:52:38
+ * @LastEditTime: 2024-06-11 19:19:41
  * @FilePath: /belleson-frontend/Users/mache/Documents/demo/cps-web/src/views/dnc/document/index.vue
 -->
 <template>
@@ -41,15 +41,19 @@
                                 </el-dropdown-menu>
                             </template>
                         </el-dropdown>
-                        <el-button type="primary" style="margin-left: 8px;">涓婁紶鏂囦欢</el-button>
+                        <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-button type="primary" style="margin-left: 8px;">涓婁紶鏂囦欢</el-button> -->
                         <el-dropdown style="margin-left: 8px;" :disabled="selection.length == 0">
                             <el-button type="primary">
                                 鏇村鎿嶄綔<el-icon class="el-icon--right"><el-icon-arrow-down /></el-icon>
                             </el-button>
                             <template #dropdown>
                                 <el-dropdown-menu>
-                                    <el-dropdown-item @click="copy">澶嶅埗</el-dropdown-item>
-                                    <el-dropdown-item @click="move">绉诲姩</el-dropdown-item>
+                                    <el-dropdown-item @click="action(1)">澶嶅埗</el-dropdown-item>
+                                    <el-dropdown-item @click="action(2)">绉诲姩</el-dropdown-item>
                                 </el-dropdown-menu>
                             </template>
                         </el-dropdown>
@@ -84,9 +88,14 @@
                             <el-table-column type="selection" width="50"></el-table-column>
                             <el-table-column label="鏂囦欢鍚嶇О" prop="name">
                                 <template #default="scope">
+                                    <el-icon style="margin-right: 4px;">
+                                        <el-icon-folder v-if="scope.row.fileType === 1" />
+                                        <el-icon-document v-else />
+                                    </el-icon>
                                     <a v-if="scope.row.fileType === 1" @click="goCurrent(scope.row)"
                                         style="color: var(--el-color-primary);cursor: pointer;">{{ scope.row.name }}</a>
-                                    <span v-else>{{ scope.row.name }}</span>
+                                    <a v-else @click="viewHis(scope.row)"
+                                        style="color: var(--el-color-primary);cursor: pointer;">{{ scope.row.name }}</a>
                                 </template>
                             </el-table-column>
                             <el-table-column label="鏂囦欢璺緞" prop="allPathName"></el-table-column>
@@ -99,7 +108,7 @@
                                         <el-button text type="primary" size="small"
                                             @click="table_edit(scope.row, scope.$index)">缂栬緫</el-button>
                                         <el-button text type="primary" size="small"
-                                            @click="del([scope, row])">鍒犻櫎</el-button>
+                                            @click="del([scope.row])">鍒犻櫎</el-button>
                                     </el-button-group>
                                 </template>
                             </el-table-column>
@@ -110,13 +119,32 @@
         </el-card>
         <el-dialog v-model="visible" title="鏂板缓鏂囦欢澶�" width="500">
             <el-form :model="form" :rules="rules" ref="dialogForm" label-width="120px" label-position="center">
-                <el-form-item label="鏂囦欢澶瑰悕绉�" prop="name">
+                <el-form-item v-if="form.fileType == 1 || !form.id" label="鏂囦欢澶瑰悕绉�" prop="name">
+                    <el-input v-model="form.name" />
+                </el-form-item>
+                <el-form-item v-else label="鏂囦欢鍚嶇О" prop="name">
                     <el-input v-model="form.name" />
                 </el-form-item>
             </el-form>
             <template #footer>
                 <div class="dialog-footer">
                     <el-button type="primary" @click="saveFolder">
+                        纭畾
+                    </el-button>
+                </div>
+            </template>
+        </el-dialog>
+        <el-dialog v-model="visibleFile" title="鏂板缓鏂囦欢澶�" width="500">
+            <el-form :model="formFile" :rules="rulesFile" ref="dialogForm" label-width="120px" label-position="center">
+                <el-form-item label="鏂囦欢浣嶇疆" prop="id">
+                    <el-tree-select v-model="formFile.id" :props="{
+                        label: 'name',
+                    }" :data="treeData" filter style="width: 240px" @node-click="clickNode" node-key="id" />
+                </el-form-item>
+            </el-form>
+            <template #footer>
+                <div class="dialog-footer">
+                    <el-button type="primary" @click="saveFile">
                         纭畾
                     </el-button>
                 </div>
@@ -154,7 +182,14 @@
                 }
             },
             selection: [],
-            type: 'list'
+            type: 'list',
+            visibleFile: false,
+            formFile: {},
+            rulesFile: {
+                id: [{
+                    required: true, message: '蹇呭~'
+                }]
+            }
         }
     },
     watch: {
@@ -167,6 +202,9 @@
     },
     methods: {
         init() {
+            this.selectNode = {
+                id: ''
+            }
             this.$HTTP.get(`/api/blade-dnc/folder/folder-tree`).then(res => {
                 this.treeData = [{
                     group: true,
@@ -188,21 +226,26 @@
             this.selectNode = { id: row.id }
             console.log(row)
         },
+        viewHis(row) {
+            window.open(row.link)
+            // this.$HTTP.get(`/api/blade-dnc/file/history?name=${row.name}&pid=${row.parentId}`)
+        },
         back() {
             console.log(this.$refs.tree.getCurrentNode())
             this.selectNode = { id: this.$refs.tree.getCurrentNode().parentId }
         },
         search() {
-            this.$refs?.table.reload()
+            this.$refs?.table?.reload()
         },
         // 鏂板鏂囦欢澶�
         addFolder() {
             this.visible = true
-            this.form = { isNewFile: false }
+            this.form = { fileType: 1 }
         },
         saveFolder() {
             if (this.form.id) {
                 return this.$HTTP.put(`/api/blade-dnc/file/${this.form.id}/rename`, { fileType: this.form.fileType, newName: this.form.name, parentId: this.form.parentId }).then(res => {
+                    this.visible = false
                     this.search()
                 })
             }
@@ -211,25 +254,41 @@
                 parent: this.selectNode.id
             }
             try {
-                Reflect.deleteProperty(data, 'isNewFile')
+                Reflect.deleteProperty(data, 'fileType')
             } catch (error) {
 
             }
             this.$HTTP.post(`/api/blade-dnc/folder`, data).then(res => {
+                this.visible = false
                 this.init()
             })
         },
         selectionChange(selection) {
             this.selection = selection
         },
-        action() {
-
+        action(type) {
+            this.visibleFile = true
+            this.formFile.move = type
+        },
+        clickNode(node) {
+            this.formFile.id = node.id
+        },
+        saveFile() {
+            if (this.formFile.move === 1) {
+                this.copy()
+            } else {
+                this.move()
+            }
         },
         copy() {
-            this.$HTTP.post(`/api/blade-dnc/file/copy`, { parentId: this.formFile.parentId, sourceIdList: this.selection.map(v => v.id) })
+            this.$HTTP.post(`/api/blade-dnc/file/copy`, { parentId: this.formFile.id, sourceIdList: this.selection.map(v => v.id) }).then(res => {
+                this.visibleFile = false
+            })
         },
         move() {
-            this.$HTTP.post(`/api/blade-dnc/file/move`, { parentId: this.formFile.parentId, sourceIdList: this.selection.map(v => v.id) })
+            this.$HTTP.put(`/api/blade-dnc/file/move`, { parentId: this.formFile.id, sourceIdList: this.selection.map(v => v.id) }).then(res => {
+                this.visibleFile = false
+            })
         },
         table_edit(row) {
             this.form = {
@@ -241,13 +300,18 @@
             this.visible = true
         },
         async del(selection) {
-            let confirm = await this.$HTTP.post(`/api/blade-dnc/file/exists-file`).then(res => {
-                if (res.data) {
-                    return res.data
-                }
-            })
+            let sourceIdList = selection.filter(v => v.fileType === 1).map(v => v.id)
+            let tip = false
             let delFlag = true
-            if (confirm) {
+            if (sourceIdList.length > 0) {
+                tip = await this.$HTTP.post(`/api/blade-dnc/file/exists-file`, { sourceIdList }).then(res => {
+                    if (res.data) {
+                        return res.data
+                    }
+                })
+            }
+
+            if (tip) {
                 delFlag = await this.$confirm(`姝ゆ搷浣滀細灏嗗綋鍓嶆枃浠跺す涓嬬殑鎵�鏈夋枃浠跺垹闄わ紝鏄惁缁х画??`, '鎻愮ず', {
                     type: 'warning',
                 }).then(() => {
@@ -256,10 +320,13 @@
                     return false
                 })
             }
+            console.log(delFlag, '>>>>>')
             if (!delFlag) {
                 return
             }
-            this.$HTTP.post(`/api/blade-dnc/file`, { sourceIdList: this.selection.map(v => v.id) }).then(res => {
+            console.log('------')
+            // return
+            this.$HTTP.delete(`/api/blade-dnc/file`, { sourceIdList: selection.map(v => v.id) }).then(res => {
                 this.init()
             })
         }

--
Gitblit v1.9.3