“dzb”
2022-09-21 091618590e16bc7e3f989944494b49ab6e98b626
src/views/systemSetting/baseSetting/role/index.vue
@@ -4,14 +4,14 @@
            <div class="headerContent">
                <div class="search">
                    <span>筛选条件:</span>
                    <el-input placeholder="请输入内容"></el-input>
                    <el-input placeholder="请输入内容" v-model="context"></el-input>
                    <div class="findBtn">
                        <el-button type="primary">查询</el-button>
                        <el-button type="primary" @click="search">查询</el-button>
                    </div>
                </div>
                <div class="addUser">
                    <el-button class="addBtn" type="primary" @click="dialogCreate = true">添加用户</el-button>
                    <el-dialog :visible.sync="dialogCreate" width="45%">
                    <el-button class="addBtn" type="primary" @click="dialogCreate = true">新建角色</el-button>
                    <el-dialog :visible.sync="dialogCreate" title="新增角色" width="45%" v-if="dialogCreate">
                        <createUser :refresh="getUserList" />
                    </el-dialog>
                </div>
@@ -25,22 +25,16 @@
                    :data="tableData" style="width: 100%" :row-class-name="tableRowClassName">
                    <el-table-column type="selection" min-width="5">
                    </el-table-column>
                    <el-table-column label="用户ID" min-width="5">
                    <!-- <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="nickName" label="用户名称" min-width="10">
                    <el-table-column prop="username" label="角色类型" min-width="10">
                    </el-table-column>
                    <el-table-column prop="username" label="所属姓名" min-width="10">
                    <el-table-column prop="mobile" label="默认角色" min-width="10">
                    </el-table-column>
                    <el-table-column prop="mobile" label="联系方式" min-width="10">
                    </el-table-column>
                    <el-table-column prop="note" label="所属角色" min-width="10">
                    </el-table-column>
                    <el-table-column prop="departName" label="所属部门" min-width="10">
                    </el-table-column>
                    <el-table-column prop="jobTitle" label="所属职务" min-width="10">
                    </el-table-column>
                    <el-table-column prop="createTime" label="创建时间" min-width="10">
                    <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">
@@ -57,19 +51,20 @@
                                <span class="line">|</span>
                                <!-- <span>修改密码</span> -->
                                <!-- <span>删除</span> -->
                                <span @click="handleUpdate(scope.row)">修改部门</span>
                                <span @click="handleUpdate(scope.row)">修改角色</span>
                            </div>
                        </template>
                    </el-table-column>
                </el-table>
                <!-- 查看修改页面 -->
                <el-dialog :visible.sync="dialogUpdate" width="45%">
                    <updateUser :updateFlag="updateFlag" :userInfo=userInfo />
                <el-dialog :visible.sync="dialogUpdate" width="45%" :title="updateFlag ? '修改角色信息' :'查看角色信息'" v-if="dialogUpdate">
                    <updateUser :updateFlag="updateFlag" :userInfo=userInfo :getUserList=getUserList @changeDialog="changeDialog"  />
                </el-dialog>
                <!-- 分页 -->
                <div class="pagination">
                    <el-pagination background :current-page="currentPage" layout="prev, pager, next" :total="totalNum"
                        :page-size="pageSize" @current-change="changeCurrentPage" @prev-click="handlePrev" @next-click="handleNext">
                        :page-size="pageSize" @current-change="changeCurrentPage" @prev-click="handlePrev"
                        @next-click="handleNext">
                    </el-pagination>
                </div>
            </div>
@@ -87,11 +82,12 @@
    data() {
        return {
            tableData: [],
            context: "",
            dialogCreate: false,
            dialogUpdate: false,
            updateFlag: false,
            userInfo: '',
            totalNum: 200,
            totalNum: null,
            pageSize: 10,
            currentPage: 1,
        }
@@ -111,7 +107,7 @@
            let { id, status } = obj;
            status == true ? status = 1 : status = 0;
            console.log(id, status);
            this.$axios.post(`sccg/admin/updateStatus/` + id + '?status=' + status).then(res => {
            this.$axios.post(`/sccg/role/updateStatus/` + id + '?status=' + status).then(res => {
                console.log(res);
            })
        },
@@ -120,14 +116,30 @@
            const that = this;
            this.dialogCreate = false;
            // 获取所有用户信息
            this.$axios.get('sccg/admin/list').then(res => {
            this.$axios.get('sccg/role/listAll').then(res => {
                console.log(res)
                if (res.code === 200) {
                    res.data.records.forEach(item => {
                    res.data.forEach(item => {
                        item.createTime = helper(item.createTime);
                        item.status == 1 ? item.status = true : item.status = false;
                    })
                    that.totalNum = res.data.records.length;
                    that.tableData = res.data.records.slice((that.currentPage-1)*10,that.currentPage*10)
                    that.tableData = res.data
                    this.totalNum=res.data.length
                }
            })
        },
        search() {
            const that = this;
            this.dialogCreate = false;
            // 获取所有用户信息
            this.$axios.get('sccg/role/list',{params:{pageNum:this.currentPage,pageSize:this.pageSize,keyword:this.context}}).then(res => {
                if (res.code === 200) {
                    res.data.list.forEach(item => {
                        item.createTime = helper(item.createTime);
                        item.status == 1 ? item.status = true : item.status = false;
                    })
                     this.totalNum=this.
                     this.totalNum=res.data.list.length
                }
            })
        },
@@ -153,20 +165,45 @@
            this.userInfo = rowData
        },
        // 当前页改变触发事件
        changeCurrentPage(page){
        changeCurrentPage(page) {
            this.currentPage = page;
            this.getUserList();
            this.search();
        },
        // 上一页点击事件
        handlePrev(page){
        handlePrev(page) {
            this.currentPage = page;
            this.getUserList();
            this.search();
        },
        // 下一页点击事件
        handleNext(page){
        handleNext(page) {
            this.currentPage = page;
            this.getUserList();
            this.search();
        },
        // 用户查询(暂时支持电话号码)
        handlePhone() {
            const { search, getUserList } = this;
            const that = this;
            if (search == '') {
                getUserList();
                return;
            }
            this.dialogCreate = false;
            // 获取所有用户信息
            this.$axios.get(`sccg/admin/list?mobile=${search}`).then(res => {
                if (res.code === 200) {
                    res.data.records.forEach(item => {
                        item.createTime = helper(item.createTime);
                        item.status == 1 ? item.status = true : item.status = false;
                    })
                    that.totalNum = res.data.records.length;
                    that.tableData = res.data.records.slice((that.currentPage - 1) * 10, that.currentPage * 10)
                }
            })
        },
        changeDialog(val){
            this.dialogUpdate = val.dialogUpdate;
            console.log(val);
        }
    }
}
</script>
@@ -257,6 +294,14 @@
            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;
@@ -312,5 +357,23 @@
    &::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;
    }
}
</style>