fangyuan
2022-12-16 9ff66017debadfc89bc0c1b796684a4d1dbe2bc3
src/views/systemSetting/baseSetting/role/index.vue
@@ -13,7 +13,7 @@
                    <el-button class="addBtn" type="primary" @click="dialogCreate = true">新建角色</el-button>
                    <el-dialog :visible.sync="dialogCreate" title="新增角色" width="45%" v-if="dialogCreate"
                        :before-close="handleClose2">
                        <createUser :refresh="context==='' ? getUserList : search" />
                        <createUser :refresh="context==='' ? getRoleList : search" />
                    </el-dialog>
                </div>
            </div>
@@ -27,59 +27,51 @@
                    @selection-change="tableChange">
                    <el-table-column type="selection" min-width="5">
                    </el-table-column>
                    <!-- <el-table-column label="用户ID" min-width="5">
                        <template slot-scope="scope">{{ scope.row.id }}</template>
                    </el-table-column> -->
                    <el-table-column prop="name" label="角色名称" min-width="10">
                    </el-table-column>
                    <el-table-column prop="sort" label="角色类型" min-width="10">
                    </el-table-column>
                    <el-table-column prop="adminCount" label="默认角色" min-width="10">
                    <el-table-column prop="typeText" label="角色类型" min-width="10">
                    </el-table-column>
                    <el-table-column prop="description" label="备注" min-width="10">
                    </el-table-column>
                    <el-table-column prop="status" label="启用" min-width="5">
                        <template slot-scope="scope">
                            <el-switch class="switchStyle" v-model="scope.row.status" active-text="开" inactive-text="关"
                                active-color="#3fef9a" inactive-color="#000212" @change="handleChangeStatus(scope.row)">
                            <el-switch class="switchStyle" v-model="scope.row.status"
                                active-color="#3fef9a" inactive-color="#000212" disabled>
                            </el-switch>
                        </template>
                    </el-table-column>
                    <el-table-column prop="operation" label="操作" min-width="15">
                        <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>
                                <span class="line">|</span>
                                <span @click="handleStop(scope.row)">停用</span>
                                <span @click="handleChangeStatus(scope.row)">{{scope.row.status === true ?'停用':'启用' }}</span>
                                <span class="line">|</span>
                                <span @click="handleDelete([scope.row.id])">删除</span>
                            </div>
                        </template>
                    </el-table-column>
                </el-table>
                </el-table>
                <!-- 修改页面 -->
                <el-dialog :visible.sync="dialogUpdate" width="45%" :title="updateFlag ? '权限设置' :'查看角色信息'"
                    v-if="dialogUpdate" :before-close="handleClose">
                    <updateUser :updateFlag="updateFlag" :userInfo=userInfo
                        :getUserList=" context ? getUserList : getUserList" @changeDialog="changeDialog" />
                        :getRoleList=" context ? getRoleList : getRoleList" @changeDialog="changeDialog" />
                </el-dialog>
                <!-- 查看页面 -->
                <el-dialog :visible.sync="dialogView" width="45%" title="查看角色信息"
                    v-if="dialogView" :before-close="handleClose">
                <el-dialog :visible.sync="dialogView" width="45%" title="查看角色信息" v-if="dialogView"
                    :before-close="handleClose">
                    <MyView :userInfo=userInfo @changeDialog="changeDialog" />
                </el-dialog>
                <!-- tools -->
                <div class="tools">
                    <div class="funs">
                        <!-- <div class="funsItem">
                         <div class="funsItem funs-sp">
                            <el-checkbox v-model="all" @change="selectAll()">全选</el-checkbox>
                        </div>
                        <div class="funsItem">
                        <div class="funsItem funs-sp">
                            <el-checkbox v-model="unsame" @change="disSame(tableData)">反选</el-checkbox>
                        </div>
                        <div class="funsItem">
@@ -88,7 +80,7 @@
                                    :value="item.value" :disabled="item.disabled">
                                </el-option>
                            </el-select>
                        </div> -->
                        </div>
                    </div>
                    <div class="pagination">
                        <el-pagination background :current-page="currentPage" layout="prev, pager, next"
@@ -106,9 +98,10 @@
import updateUser from "./updateUser"
import helper from "@/utils/mydate.js"
import MyView from './viewRole'
import MyTable from '@/components/Table'
export default {
    components: {
        createUser, updateUser,MyView
        createUser, updateUser, MyView, MyTable
    },
    data() {
        return {
@@ -116,7 +109,7 @@
            context: "",
            dialogCreate: false,
            dialogUpdate: false,
            dialogView:false,
            dialogView: false,
            updateFlag: false,
            userInfo: '',
            totalNum: null,
@@ -145,11 +138,11 @@
                    label: '批量删除',
                }
            ],
            tempList: []
            tempList: [],
        }
    },
    created() {
        this.getUserList();
        this.getRoleList();
    },
    methods: {
        async selectChange(list) {
@@ -185,14 +178,13 @@
                                    type: 'success',
                                    message: '更改用户状态成功',
                                })
                                this.getUserList();
                                this.getRoleList();
                            } else {
                                this.$message({
                                    type: 'error',
                                    message: res.message
                                })
                            }
                            console.log(res);
                        })
                })
                .catch(err => { console.log(err) })
@@ -232,13 +224,12 @@
                        .then(res => {
                            this.myIdx = 0;
                            this.preMyIdx = 0;
                            console.log(res);
                            this.$message({
                                type: 'success',
                                message: res.message
                            })
                            this.getUserList();
                            this.getRoleList();
                        })
                })
                .catch(_ => { });
@@ -252,23 +243,15 @@
        // 修改用户状态
        handleChangeStatus(obj) {
            let { id, status } = obj;
            status == true ? status = 1 : status = 0;
            console.log(id, status);
            status == true ? status = 0 : status = 1;
            this.$axios.post(`/sccg/role/updateStatus/` + id + '?status=' + status).then(res => {
                console.log(res);
                if (res.code === 200) {
                    this.search();
                }
            })
        },
        handleStop(obj) {
            // let { id, status } = obj;
            // status == true ? status = 1 : status = 0;
            // console.log(id, status);
            // this.$axios.post(`/sccg/role/updateStatus/` + id + '?status=' + status).then(res => {
            //     this.getUserList();
            // })
        },
        // 获取用户列表
        getUserList() {
            const that = this;
        getRoleList() {
            this.dialogCreate = false;
            // 获取所有用户信息
            this.$axios.get('sccg/role/listAll').then(res => {
@@ -284,7 +267,6 @@
            if (context == '') {
                this.$axios.get('sccg/role/list?keyword=' + '&pageNum=' + currentPage + '&pageSize=' + pageSize).then(res => {
                    if (res.code === 200) {
                        console.log(res);
                        res.data.list.forEach(item => {
                            // item.createTime = helper(item.createTime);
                            item.status == 1 ? item.status = true : item.status = false;
@@ -343,25 +325,26 @@
            this.currentPage = page;
            this.search();
        },
        changeDialog({flag}) {
        changeDialog({ flag }) {
            this.dialogUpdate = flag;
            this.dialogCreate = flag;
            this.dialogView = flag;
        },
        handleClose(done) {
            if(this.updateFlag){
            if (this.updateFlag) {
                this.$confirm('确认关闭?')
                .then(_ => {
                    this.dialogUpdate = false;
                    this.dialogCreate = false;
                    done();
                })
                .catch(_ => { });
            }else{
                    .then(_ => {
                        this.dialogUpdate = false;
                        this.dialogCreate = false;
                        this.updateFlag = false;
                        done();
                    })
                    .catch(_ => { });
            } else {
                done();
            }
        },
        handleClose2(done){
        handleClose2(done) {
            this.$confirm('确认关闭?')
                .then(_ => {
                    done();
@@ -445,7 +428,9 @@
            justify-content: space-between;
            align-items: center;
            padding: 0 20px;
            .funs-sp{
                border: 1px solid #17324c;
            }
            .funs {
                display: flex;
@@ -453,7 +438,6 @@
                    line-height: 28px;
                    display: flex;
                    align-items: center;
                    border: 1px solid #17324c;
                    border-radius: 4px;
                    font-size: 12px;
                    margin-left: 10px;
@@ -510,14 +494,6 @@
            color: #4b9bb7;
            font-size: 10px;
            &::v-deep .el-table__empty-block {
                background-color: #09152f;
            }
            &::v-deep .el-table__empty-block {
                color: #4b9bb7;
            }
            .operation {
                display: flex;
@@ -531,69 +507,34 @@
            }
        }
        .el-table::v-deep .warning-row {
            background: #06122c;
        }
        // &::v-deep .switchStyle .el-switch__label {
        //     position: absolute;
        //     display: none;
        //     color: #fff;
        // }
        .el-table::v-deep .success-row {
            background: #071f39;
        }
        // &::v-deep .el-switch__core {
        //     background-color: rgba(166, 166, 166, 1);
        // }
        &::v-deep .switchStyle .el-switch__label {
            position: absolute;
            display: none;
            color: #fff;
        }
        // &::v-deep .switchStyle .el-switch__label--left {
        //     z-index: 9;
        //     left: 20px;
        // }
        &::v-deep .el-switch__core {
            background-color: rgba(166, 166, 166, 1);
        }
        // &::v-deep .switchStyle .el-switch__label--right {
        //     z-index: 9;
        //     left: 4px;
        // }
        &::v-deep .switchStyle .el-switch__label--left {
            z-index: 9;
            left: 20px;
        }
        // &::v-deep .switchStyle .el-switch__label.is-active {
        //     display: block;
        // }
        &::v-deep .switchStyle .el-switch__label--right {
            z-index: 9;
            left: 4px;
        }
        &::v-deep .switchStyle .el-switch__label.is-active {
            display: block;
        }
        &::v-deep .switchStyle.el-switch .el-switch__core,
        &::v-deep .el-switch .el-switch__label {
            width: 50px !important;
        }
    }
    &::v-deep .el-dialog__header,
    &::v-deep .el-dialog__body {
        background-color: #06122c;
    }
    &::v-deep .el-dialog__header {
        display: flex;
        align-items: center;
        background-color: #fff;
        padding: 20px;
        line-height: 60px;
    }
    &::v-deep .el-dialog__title {
        color: #4b9bb7;
    }
    &::v-deep .el-dialog__close {
        width: 20px;
        height: 20px;
        // color: #fff;
    }
    &::v-deep .el-dialog__body {
        padding: 0;
        // &::v-deep .switchStyle.el-switch .el-switch__core,
        // &::v-deep .el-switch .el-switch__label {
        //     width: 50px !important;
        // }
    }
}
</style>