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/craft/document/File.vue     |  388 +++++++++++++++++++++++++++++++++++++++++++
 src/views/dnc/craft/document/index.vue    |   13 +
 src/views/dnc/craft/document/Children.vue |  103 ++++++----
 3 files changed, 457 insertions(+), 47 deletions(-)

diff --git a/src/views/dnc/craft/document/Children.vue b/src/views/dnc/craft/document/Children.vue
index 3ccc873..643e1f4 100644
--- a/src/views/dnc/craft/document/Children.vue
+++ b/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')
         }
     }
 }
diff --git a/src/views/dnc/craft/document/File.vue b/src/views/dnc/craft/document/File.vue
new file mode 100644
index 0000000..f9bd176
--- /dev/null
+++ b/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>
\ No newline at end of file
diff --git a/src/views/dnc/craft/document/index.vue b/src/views/dnc/craft/document/index.vue
index 6cbba5b..04e18ec 100644
--- a/src/views/dnc/craft/document/index.vue
+++ b/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()
         }
     }
 }

--
Gitblit v1.9.3