odc.xiaohui
2023-01-11 d942877495ceea1575e64fb6d4e2972f6da10cac
src/views/systemSetting/platform/mySetting/index.vue
@@ -2,130 +2,138 @@
    <div class="mySetting">
        <!-- header 页面标题提示 -->
        <header>
            <div class="headerTitle">系统设置 >> 门户管理 > 自定义菜单设置</div>
            <div class="header-title">系统设置 >> 门户管理 > 自定义菜单设置</div>
        </header>
        <main>
            <div class="mainContent">
            <div class="main-content">
                <!-- 数据展示 -->
                <el-table ref="multipleTable"
                    :header-cell-style="{background:'#06122c','font-size':'12px',color:'#4b9bb7','font-weight':'650','line-height':'45px'}"
                    :data="menuList" style="width: 100%" row-key="id" :row-class-name="tableRowClassName">
                    <el-table-column type="selection" min-width="5">
                    </el-table-column>
                    <el-table-column prop="title" label="菜单栏" min-width="75">
                        <el-tree :data="menuList" node-key="id" :default-expanded-keys="[0]"
                            :default-checked-keys="[0]" :props="defaultProps">
                <el-row class="my-container">
                    <el-col :span="6" class="my-aside">
                        <el-tree draggable :data="menuList" @node-click="handleNodeClick" :props="defaultProps"
                            accordion node-key="id" @node-drop="handleDrop" :allow-drop="allowDrop">
                            <span class="custom-tree-node" slot-scope="{ node, data }">
                                <span>{{ node.label }}</span>
                            </span>
                        </el-tree>
                    </el-table-column>
                    <el-table-column label="操作" min-width="20">
                        <template slot-scope="scope">
                            <div class="operation">
                                <!-- <span @click="handleChangeRole(scope.row)">修改角色</span> -->
                                <span @click="handleFind(scope.row)">查看</span>
                                <span class="line">|</span>
                                <!-- <span>修改密码</span> -->
                                <!-- <span>删除</span> -->
                                <span @click="handleUpdate(scope.row)">修改角色</span>
                    </el-col>
                    <el-col :span="18" class="my-content" v-if="article.title">
                        <div class="my-header">菜单管理-{{article.title}}
                        </div>
                        <div class="my-name">
                            <div class="my-show__left">名称:</div>
                            <div class="my-show__right">{{article.title}}</div>
                        </div>
                        <div class="my-desc">
                            <div class="my-show__left">描述:</div>
                            <div class="my-show__right">{{article.title}}</div>
                        </div>
                        <div class="my-show">
                            <div class="my-show__left">是否显示菜单:</div>
                            <div class="my-show__right">
                                <el-switch class="switchStyle" v-model="article.isStart" active-color="#3fef9a"
                                    inactive-color="#000212" @change="handleChangeStatus(article)">
                                </el-switch>
                            </div>
                        </template>
                    </el-table-column>
                </el-table>
                <!-- 查看修改页面 -->
                <el-dialog :visible.sync="dialogUpdate" width="45%" :title="updateFlag ? '修改角色信息' :'查看角色信息'"
                    v-if="dialogUpdate">
                </el-dialog>
                        </div>
                    </el-col>
                </el-row>
            </div>
        </main>
        <footer>
            <!-- 新增弹窗 -->
            <el-dialog title="提示" :visible.sync="dialogAdd" v-if="dialogAdd" width="45%" :before-close="handleClose">
                <MyAdd></MyAdd>
            </el-dialog>
        </footer>
    </div>
</template>
<script>
import helper from "@/utils/mydate.js"
import MyAdd from './create'
export default {
    components: {
        MyAdd
    },
    data() {
        return {
            menuList: [],
            article: [],
            article: {},
            defaultProps: {
                children: 'menuVoArrayList',
                label: 'title'
            },
            count: 1,
            menuList: [],
            context: "",
            dialogCreate: false,
            dialogUpdate: false,
            updateFlag: false,
            userInfo: '',
            dialogAdd: false,
        }
    },
    created() {
        this.getMenuList();
    },
    methods: {
        // 点击节点
        handleNodeClick(data) {
            this.article = { ...data };
            this.article.isStart === 0 ? this.article.isStart = false : this.article.isStart = true
        },
        // 修改状态
        handleChangeStatus(data) {
            let { isStart, relationId } = data;
            isStart ? isStart = 1 : isStart = 0;
            this.$axios({
                method: 'put',
                url: `sccg/system/portal/menu/modification_myself?relationId=${relationId}&status=${isStart}`
            })
                .then(res => {
                    this.$message({
                        type: res.code === 200 ? 'success' : 'error',
                        message: res.message
                    })
                    this.getMenuList();
                    this.article = {};
                })
        },
        handleDelete(data) {
            this.$confirm('您确认要删除订单吗?')
                .then(_ => {
                    this.$axios({
                        method: 'post',
                        url: `sccg/menu/delete/${data.id}`
                    })
                        .then(res => {
                            this.$message({
                                type: res.code === 200 ? 'success' : 'error',
                                message: res.code === 200 ? '删除菜单成功' : res.message
                            })
                            if (res.code === 200) {
                                this.getMenuList();
                            }
                        })
                })
                .catch(err => {
                })
        },
        // 获取菜单列表
        getMenuList() {
            this.$axios({
                method: 'get',
                url: 'sccg/system/portal/menu/search',
                url: 'sccg/system/portal/menu/search_myself',
            }).then(res => {
                this.menuList = res.data.records;
                this.getContent(0);
                this.menuList = res.data.menu;
            })
        },
        // 切换菜单内容展示
        getContent(index, sonIndex = null) {
            if (sonIndex === null) {
                this.article = this.menuList[index];
                return;
            }
            this.article = this.menuList[index].menuVoArrayList[sonIndex];
        // 拖拽
        handleDrop(before, after, inner, event) {
        },
        // 设置表格斑马纹
        tableRowClassName({ row, rowIndex }) {
            if ((rowIndex + 1) % 2 == 0) {
                return 'warning-row';
            } else {
                return 'success-row';
            }
            return '';
        },
        handleCheckChange(data, checked, indeterminate) {
            console.log(data, checked, indeterminate);
        },
        handleNodeClick(data) {
            console.log(data);
        },
        loadNode(node, resolve) {
            if (node.level === 0) {
                return resolve([{ name: 'region1' }, { name: 'region2' }]);
            }
            if (node.level > 3) return resolve([]);
            var hasChild;
            if (node.data.name === 'region1') {
                hasChild = true;
            } else if (node.data.name === 'region2') {
                hasChild = false;
            } else {
                hasChild = Math.random() > 0.5;
            }
            setTimeout(() => {
                var data;
                if (hasChild) {
                    data = [{
                        name: 'zone' + this.count++
                    }, {
                        name: 'zone' + this.count++
                    }];
        // 获取是否可以放置
        allowDrop(before, inner, next) {
            if (before.data.level === inner.data.level) {
                if (before.data.parentId === inner.data.parentId) {
                    return next === "prev" || next === "next";
                } else {
                    data = [];
                    return false;
                }
                resolve(data);
            }, 500);
            } else {
                // 不同级进行处理
                return false;
            }
        }
    }
@@ -140,57 +148,62 @@
    header {
        line-height: 60px;
        padding: 0 20px;
        display: flex;
        justify-content: space-between;
        align-items: center;
        .header-add {
            .el-button {
                background-color: #eb5d01;
                border: none;
            }
        }
    }
    main {
        background-color: #09152f;
        // background-color: #09152f;
        margin-top: 20px;
        padding-bottom: 50px;
        border: 1pox solid #fff;
        .mainTitle {
            line-height: 60px;
        }
        .main-content {
            .my-container {
                ::v-deep .el-tree-node__content {
                    height: 36px;
                }
        .el-table {
            color: #4b9bb7;
            font-size: 10px;
            &::v-deep .el-table__cell {
                text-align: center;
                ::v-deep .el-tree-node__label {
                    line-height: 20px;
                }
            }
            &::v-deep .el-table__empty-block {
                background-color: #09152f;
                color: #4b9bb7;
            }
            &::v-deep .el-table__row:hover{
                background-color: #4b9bb7;
            }
            .el-tree {
                background-color: #071f39;
            }
            .operation {
            .my-header {
                line-height: 60px;
                display: flex;
                justify-content: center;
                .line {
                    padding: 0 5px;
                }
                span:hover {
                    cursor: pointer;
                }
            }
        }
        .el-table::v-deep .warning-row {
            background: #06122c;
        }
            .my-name,
            .my-desc,
            .my-show {
                line-height: 40px;
                display: flex;
                justify-content: center;
                align-items: center;
            }
        .el-table::v-deep .success-row {
            background: #071f39;
            .my-show__right {
                margin-left: 10px;
            }
            .custom-tree-node {
                flex: 1;
                display: flex;
                align-items: center;
                justify-content: space-between;
                font-size: 14px;
                line-height: 20px;
                padding-right: 8px;
            }
        }
        &::v-deep .switchStyle .el-switch__label {
@@ -250,4 +263,8 @@
        padding: 0;
    }
}
.my-aside{
    border-right: 1px solid #d3d3d3  ;
}
</style>