“dzb”
2022-10-09 2bb0e066fdc522beb51dd13f6a72cd67bd5d6a58
src/views/systemSetting/baseSetting/user/components/main/index.vue
@@ -4,7 +4,8 @@
            <!-- 数据展示 -->
            <el-table ref="multipleTable"
                :header-cell-style="{background:'#06122c','font-size':'12px',color:'#4b9bb7','font-weight':'650','line-height':'45px'}"
                :data="tableData" style="width: 100%" :row-class-name="tableRowClassName" @selection-change="tableChange">
                :data="tableData" style="width: 100%" :row-class-name="tableRowClassName"
                @selection-change="tableChange">
                <el-table-column type="selection" min-width="5">
                </el-table-column>
                <el-table-column label="用户ID" min-width="4">
@@ -17,6 +18,9 @@
                <el-table-column prop="mobile" label="联系方式" min-width="7">
                </el-table-column>
                <el-table-column prop="note" label="所属角色" min-width="8">
                    <template slot-scope="scope">
                        <span>{{filterRole(scope.row.roles)}}</span>
                    </template>
                </el-table-column>
                <el-table-column prop="departName" label="所属部门" min-width="8">
                </el-table-column>
@@ -69,8 +73,8 @@
                    </div>
                    <div class="funsItem">
                        <el-select v-model="myIdx" placeholder="批量操作" @change="selectChange">
                            <el-option v-for="item in options" :key="item.value" :label="item.label"
                                :value="item.value" :disabled="item.disabled">
                            <el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value"
                                :disabled="item.disabled">
                            </el-option>
                        </el-select>
                    </div>
@@ -91,7 +95,7 @@
import MyPwd from '../password'
export default {
    components: {
        updateUser,MyPwd
        updateUser, MyPwd
    },
    data() {
        return {
@@ -111,55 +115,126 @@
            },
            all: false,
            unsame: false,
            myIdx:0,
            options:[
            myIdx: 0,
            preMyIdx: 0,
            options: [
                {
                    value:0,
                    label:'批量操作',
                    disabled:true,
                    value: 0,
                    label: '批量操作',
                    disabled: true,
                },
                {
                    value:1,
                    label:'批量启用',
                    value: 1,
                    label: '批量启用',
                },
                {
                    value:2,
                    label:'批量禁用',
                    value: 2,
                    label: '批量禁用',
                },
                {
                    value:3,
                    label:'批量删除',
                    value: 3,
                    label: '批量删除',
                }
            ],
            tempList:[]
            tempList: []
        }
    },
    created() {
        this.getUserList();
    },
    methods: {
        selectChange(list){
            console.log(list);
        async selectChange(list) {
            console.log(this.tempList);
            if (this.tempList.length !== 0) {
                this.preMyIdx = list;
                if (list === 3) {
                    await this.mulDelte(this.tempList);
                } else if (list === 2) {
                    await this.mulUpdateStatus(this.tempList, 0);
                } else {
                    await this.mulUpdateStatus(this.tempList, 1);
                }
                this.myIdx = 0;
            } else {
                this.myIdx = this.preMyIdx;
                this.$message({
                    type: 'warning',
                    message: '您还没选中任何数据',
                })
            }
        },
        tableChange(list){
            this.tempList = list;
            if(list.length===this.tableData.length){
        tableChange(list) {
            this.tempList = [];
            list.forEach(item => {
                this.tempList.push(item.id);
            })
            if (list.length === this.tableData.length) {
                this.all = true;
            }else{
            } else {
                this.all = false
            }
        },
        // 批量删除用户信息
        mulDelte(idArr) {
            console.log(idArr);
            this.$confirm("您确定要进行批量删除用户吗?")
                .then(_ => {
                    this.$axios({
                        method: 'post',
                        url: 'sccg/admin/deleteBatch?ids=' + idArr,
                    })
                        .then(res => {
                            if (res.code === 200) {
                                this.$message({
                                    type: 'success',
                                    message: '删除用户信息成功',
                                })
                                this.getUserList();
                            } else {
                                this.$message({
                                    type: 'error',
                                    message: res.message
                                })
                            }
                            console.log(res);
                        })
                })
                .catch(err => { console.log(err) })
        },
        // 批量修改账号
        mulUpdateStatus(idArr, flag) {
            console.log(flag);
            this.$confirm(flag === 1 ? "您确定要进行批量启用用户吗?" : '您确定要进行批量禁用用户吗?')
                .then(_ => {
                    this.$axios({
                        method: 'post',
                        url: 'sccg/admin/updateStatusBatch?ids=' + idArr + '&status=' + flag,
                    })
                        .then(res => {
                            if (res.code === 200) {
                                this.$message({
                                    type: 'success',
                                    message: '更改用户状态成功',
                                })
                                this.getUserList();
                            } else {
                                this.$message({
                                    type: 'error',
                                    message: res.message
                                })
                            }
                            console.log(res);
                        })
                })
                .catch(err => { console.log(err) })
        },
        changeTime({ createTime }) {
            return helper(createTime);
        },
        selectAll() {
            this.$refs.multipleTable.toggleAllSelection();
        },
        disSame(list) {
            // console.log(this.$refs.multipleTable);
            // const row = this.$refs.table.data
            list.forEach(row => {
                this.$refs.multipleTable.toggleRowSelection(row)
            })
@@ -185,12 +260,17 @@
            this.getUserList();
        },
        handleClose(done) {
            this.$confirm('确认关闭?')
                .then(_ => {
                    this.dialogUpdate = false
                    done();
                })
                .catch(_ => { });
            if (this.updateFlag) {
                this.$confirm('确认关闭?')
                    .then(_ => {
                        this.dialogUpdate = false;
                        this.updateFlag = false;
                        done();
                    })
                    .catch(_ => { });
            }else{
                done();
            }
        },
        // 当前页改变触发事件
        changeCurrentPage(page) {
@@ -236,10 +316,9 @@
            this.$axios.get(`sccg/admin/list?keyword=${search}&current=${currentPage}&pageSize=${pageSize}`).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.pages * pageSize;
                    that.totalNum = res.data.total;
                    that.tableData = res.data.records;
                    this.renderFlag = true;
                }
@@ -264,6 +343,23 @@
            }
            return '';
        },
        // 处理用户所属角色
        filterRole(arr){
            let str = '';
            if(arr.length === 0){
                return;
            }
            arr.forEach((item,index)=>{
                if(item!==null){
                    if(index<arr.length-1){
                        str+=item.name +',';
                    }else{
                        str+=item.name;
                    }
                }
            })
            return str;
        }
    },
    props: ['refresh', 'keyword', 'resetFresh'],
    watch: {
@@ -300,8 +396,10 @@
        justify-content: space-between;
        align-items: center;
        padding: 0 20px;
        .funs {
            display: flex;
            .funsItem {
                line-height: 28px;
                display: flex;
@@ -310,25 +408,30 @@
                border-radius: 4px;
                font-size: 12px;
                margin-left: 10px;
                .el-checkbox{
                .el-checkbox {
                    width: 80px;
                    padding: 0 10px;
                }
                .el-select{
                .el-select {
                    width: 120px;
                }
                &::v-deep .el-input__inner{
                &::v-deep .el-input__inner {
                    border: none;
                    background-color: #09152f;
                }
                &:hover{
                &:hover {
                    border: 1px solid #4b9bb7;
                }
                &:hover .el-checkbox{
                &:hover .el-checkbox {
                    color: #4b9bb7;
                }
            }
        }
        .pagination {
@@ -345,7 +448,8 @@
                    background-color: #071f39;
                    color: #4b9bb7;
                }
                &::v-deep .active{
                &::v-deep .active {
                    background-color: #409eff;
                    color: #fff;
                }