“dzb”
2022-10-03 4d9a35462803c7392dedca8d95fe21ff3d949466
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">
@@ -69,8 +70,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>
@@ -112,6 +113,7 @@
            all: false,
            unsame: false,
            myIdx:0,
            preMyIdx: 0,
            options:[
                {
                    value:0,
@@ -138,17 +140,90 @@
        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;
            this.tempList = [];
            list.forEach(item => {
                this.tempList.push(item.id);
            })
            if(list.length===this.tableData.length){
                this.all = true;
            }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);
@@ -300,8 +375,10 @@
        justify-content: space-between;
        align-items: center;
        padding: 0 20px;
        .funs {
            display: flex;
            .funsItem {
                line-height: 28px;
                display: flex;
@@ -310,20 +387,25 @@
                border-radius: 4px;
                font-size: 12px;
                margin-left: 10px;
                .el-checkbox{
                    width: 80px;
                    padding: 0 10px;
                }
                .el-select{
                    width: 120px;
                }
                &::v-deep .el-input__inner{
                    border: none;
                    background-color: #09152f;
                }
                &:hover{
                    border: 1px solid #4b9bb7;
                }
                &:hover .el-checkbox{
                    color: #4b9bb7;
                }
@@ -345,6 +427,7 @@
                    background-color: #071f39;
                    color: #4b9bb7;
                }
                &::v-deep .active{
                    background-color: #409eff;
                    color: #fff;