1
lzhe
2024-10-16 e380c08a22f7546ad187b5bb8a3571db146133a2
src/views/dnc/file/admin/index.vue
@@ -1,7 +1,7 @@
<!--
 * @Date: 2024-05-20 21:43:10
 * @LastEditors: Sneed
 * @LastEditTime: 2024-05-20 22:18:51
 * @LastEditTime: 2024-06-16 16:19:14
 * @FilePath: /belleson-frontend/Users/mache/Documents/demo/cps-web/src/views/dnc/file/admin/index.vue
-->
<template>
@@ -9,33 +9,51 @@
        <el-card shadow="never" style="height: 100%;" body-style="height: 100%">
            <el-container>
                <el-aside width="200px">
                    <el-tree default-expand-all ref="group" node-key="id" :data="treeData" :props="{
                    <el-tree :expand-on-click-node="false" ref="group" node-key="id" :props="{
                        label: 'name',
                    }" @node-click="nodeClick" highlight-current :current-node-key="selectNode.id"></el-tree>
                        hasChildren: 'id'
                    }" :load="loadNode" @node-click="nodeClick" lazy></el-tree>
                </el-aside>
                <el-container>
                    <el-header>
                        <el-button style="margin-left: 8px;margin-right: auto;" type="danger" plain
                            :disabled="selection.length == 0" @click="del(selection)">删除</el-button>
                        <el-tree-select v-model="params.workstationId" default-expand-all clearable :data="treeData"
                            :render-after-expand="false" style="width: 240px;margin-left: auto;" :props="{
                                label: 'title',
                            }" node-key="id">
                            <template #prefix><span style="margin-right: 6px;">工位目录</span></template>
                        </el-tree-select>
                        <el-date-picker style="width: 260px;flex-grow: 0;margin-left: 8px;" v-model="params.time"
                            type="daterange" range-separator="-" start-placeholder="开始时间" end-placeholder="结束时间" />
                        <el-input v-model="params.keywords" style="width: 240px;margin-left: 8px;" placeholder="文件名称、后缀"
                            clearable>
                            <template #prefix>关键词</template>
                        </el-input>
                        <el-button style="margin-left: 8px;" @click="search" type="primary"
                            icon="el-icon-search"></el-button>
                    </el-header>
                    <el-main>
                        <scTable highlight-current-row @dataChange="dataChange" @row-click="rowClick" ref="table"
                            :params="params" :apiObj="apiObj" @selection-change="selectionChange" stripe>
                        <scTable v-if="selectNode.id || selectNode.id === 0" highlight-current-row
                            @dataChange="dataChange" @row-click="rowClick" ref="table" :params="params" :apiObj="apiObj"
                            @selection-change="selectionChange" stripe>
                            <el-table-column type="selection" width="50"></el-table-column>
                            <el-table-column label="文件名称" prop="name">
                            <el-table-column label="文件名称" prop="filename">
                            </el-table-column>
                            <el-table-column label="版本" prop="allPathName"></el-table-column>
                            <el-table-column label="工位目录" prop="workstationName"></el-table-column>
                            <el-table-column label="版本" prop="versionDesc"></el-table-column>
                            <el-table-column label="文件大小" prop="contentLength"></el-table-column>
                            <el-table-column label="文件类型" prop="suffix"></el-table-column>
                            <el-table-column label="创建人" prop="updateTime"></el-table-column>
                            <el-table-column label="创建时间" prop="updateTime"></el-table-column>
                            <el-table-column label="更新人" prop="createUserName"></el-table-column>
                            <el-table-column label="更新时间" prop="updateTime"></el-table-column>
                            <el-table-column label="操作" fixed="right" align="right" width="160">
                                <template #default="scope">
                                    <el-button-group>
                                        <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>
                                        <el-popconfirm width="220" title="确定将选择的数据删除" @confirm="del([scope.row], '0')">
                                            <template #reference>
                                                <el-button text type="primary" size="small">删除</el-button>
                                            </template>
                                        </el-popconfirm>
                                    </el-button-group>
                                </template>
                            </el-table-column>
@@ -54,10 +72,10 @@
        return {
            selection: [],
            selectNode: {
                id: ''
            },
            treeData: [],
            params: {
                time: [],
                startTime: '',
                endTime: '',
                keywords: '',
@@ -71,7 +89,9 @@
                    }
                    let data1 = {
                        arId: this.selectNode.id,
                        ...this.params
                        ...this.params,
                        startTime: this.params.time[0] || '',
                        endTime: this.params.time[1] || ''
                    }
                    return await this.$HTTP.post(`/api/blade-dnc/dnc-archive-directory-file/page`, {}, { params, data: data1 }).then(res => {
                        return res
@@ -84,36 +104,69 @@
        this.init()
    },
    methods: {
        init() {
            this.$HTTP.get(`/api/blade-dnc/dnc-archive-directory/list?parentId=`).then(res => {
                console.log(res.data, '>>>>>')
                this.treeData = res.data
                this.nodeClick(res.data[0])
        loadNode(node, resolve) {
            let id = node.level === 0 ? '' : node.data.id
            this.$HTTP.get(`/api/blade-dnc/dnc-archive-directory/list?parentId=${id}`).then(res => {
                if (node.level === 0) {
                    this.nodeClick(res.data[0])
                }
                resolve(res.data)
            })
        },
        init() {
            this.$HTTP.post(`/api/blade-cps/group/groupWorkstation`, { groupCategory: 1, groupType: 'group_workstation' }).then(res => {
                this.treeData = this.formatData(res.data)
            })
        },
        formatData(data, current, flag) {
            let newData = []
            if (!current) {
                newData = data.filter(item => item.parentId == 0).map(v => {
                    v.children = this.formatData(data, v, flag).sort((a, b) => {
                        return b.sort - a.sort
                    })
                    flag && (v.disabled = !v.isWorkstation)
                    v.disabled = !v.isWorkstation
                    return v
                })
            } else {
                let res = data.filter(v => v.parentId == current.id)
                res = res.map(item => {
                    item.children = this.formatData(data, item, flag).sort((a, b) => {
                        return b.sort - a.sort
                    })
                    flag && (item.disabled = !item.isWorkstation)
                    item.disabled = !item.isWorkstation
                    return item
                })
                return res
            }
            return newData
        },
        nodeClick(node) {
            if (!node) return
            if (!node.id && node.id !== 0) return
            this.selectNode = node
            console.log(node.id)
            this.$nextTick(() => {
                this.$refs?.table?.reload()
                this.$refs.table?.reload()
            })
        },
        search() {
            this.$refs.table.reload()
        },
        selectionChange(selection) {
            this.selection = selection
        },
        del(selection) {
        },
        table_edit() {
            this.$HTTP.delete(`/api/blade-dnc/dnc-archive-directory-file/remove`, {}, { data: selection.map(v => v.id) }).then(res => {
                this.search()
            })
        },
        rowClick() {
        },
        dataChange() {
        }
    }
}
</script>