gaoshp
2024-11-19 f29900986f01cf5d39b5755cec674825cef27961
src/views/console/system/user.vue
@@ -2,7 +2,7 @@
 * @Author: lzhe lzhe@example.com
 * @Date: 2024-03-26 10:28:33
 * @LastEditors: lzhe lzhe@example.com
 * @LastEditTime: 2024-03-29 16:20:06
 * @LastEditTime: 2024-04-03 18:22:26
 * @FilePath: /smart-web/src/views/master/person/main/index.vue
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
@@ -11,22 +11,27 @@
      <div class="user-top">
         <div class="right-bottom"> 
            <el-button type="primary" @click="addPerson">新建</el-button>
            <el-button type="danger" plain @click="delPerson">删除</el-button>
            <el-button type="primary" @click="resetPerson">密码重置</el-button>
            <el-button type="danger" plain @click="delData">删除</el-button>
         </div>
         <div>
            <el-input v-model="input" placeholder="请输入内容" style="width: 180px;margin-right: 8px;"></el-input>
            <el-input v-model="input" placeholder="请输入内容" style="width: 180px;margin-right: 8px;"></el-input>
            <el-button type="primary" @click="searchUser">搜索</el-button>
            <el-input v-model="searchData.account" placeholder="账号" style="width: 180px;margin-right: 8px;" clearable></el-input>
            <el-input v-model="searchData.realName" placeholder="账号昵称" style="width: 180px;margin-right: 8px;" clearable></el-input>
            <el-button type="primary" @click="searchclick">搜索</el-button>
         </div>
      </div>
      <div class="user-table">
         <el-table ref="multipleTableRef" :data="tableData" border style="width: 100%" class="multipleTableRef" @selection-change="handleSelectionChange">
            <el-table-column type="selection" width="55" />
            <el-table-column prop="date" label="账号"></el-table-column>
            <el-table-column prop="name" label="账号昵称"></el-table-column>
            <el-table-column prop="name" label="所属角色"></el-table-column>
            <el-table-column prop="name" label="数据权限"></el-table-column>
            <el-table-column prop="name" label="账号状态"></el-table-column>
            <el-table-column prop="account" label="账号"></el-table-column>
            <el-table-column prop="realName" label="账号昵称"></el-table-column>
            <el-table-column prop="roleName" label="所属角色"></el-table-column>
            <el-table-column prop="deptName" label="数据权限"></el-table-column>
            <el-table-column prop="name" label="账号状态">
               <template #default="scope">
                  <el-switch v-model="scope.row.status" @click="changeStatus(scope.row)" />
               </template>
            </el-table-column>
            <el-table-column fixed="right" label="操作">
               <template #default="scope">
                  <el-button type="text" size="small" @click="table_edit(scope.row, scope.$index)">编辑</el-button>
@@ -35,13 +40,14 @@
            </el-table-column>
         </el-table>
         <el-pagination
            style="margin-top: 12px;"
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
            :current-page="currentPage4"
            :page-sizes="[100, 200, 300, 400]"
            :page-size="100"
            :page-sizes="[15, 50, 100]"
            :page-size="15"
            layout="total, sizes, prev, pager, next, jumper"
            :total="400">
            :total="total">
         </el-pagination>
      </div>
   </div>
@@ -64,16 +70,7 @@
      </template>
   </el-dialog>
   <el-dialog v-model="dialogVisible" width="500" :before-close="handleClose">
      <span>确定将选择账号解锁?</span>
      <template #footer>
      <div class="dialog-footer">
         <el-button @click="dialogVisible = false">取消</el-button>
         <el-button type="primary" @click="dialogVisible = false">确定</el-button>
      </div>
      </template>
   </el-dialog>
   <save-dialog v-if="dialog.save" ref="saveDialog" @success="handleSuccess" @closed="dialog.save=false"></save-dialog>
   <save-dialog v-if="dialog.save" ref="saveDialog" @success="addUserSuccess" @closed="dialog.save=false"></save-dialog>
</template>
<script>
   import saveDialog from './addUser'
@@ -81,7 +78,14 @@
      name: "bakalaka",
      data(){
         return {
            dialogVisible: false,
            selection: [],
            searchData: {
               account: "",
               realName: "",
               current: "1",
               size: "15"
            },
            total: 0,
            isSaveing: false,
            groups: [],
            departmentFrom: {
@@ -103,51 +107,91 @@
               label: '黄金糕'
            }],
            input3: '',
            tableData: [{
               date: '2016-05-02',
               name: '王小虎',
               province: '上海',
               city: '普陀区',
               address: '上海市普陀区金沙江路 1518 弄',
               zip: 200333
               }, {
               date: '2016-05-04',
               name: '王小虎',
               province: '上海',
               city: '普陀区',
               address: '上海市普陀区金沙江路 1517 弄',
               zip: 200333
               }, {
               date: '2016-05-01',
               name: '王小虎',
               province: '上海',
               city: '普陀区',
               address: '上海市普陀区金沙江路 1519 弄',
               zip: 200333
               }, {
               date: '2016-05-03',
               name: '王小虎',
               province: '上海',
               city: '普陀区',
               address: '上海市普陀区金沙江路 1516 弄',
               zip: 200333
            }]
            tableData: []
         }
      },
      created(){
         
      },
      mounted(){
         this.searchUser();
      },
      components: {
         saveDialog
      },
      methods: {
         table_unlock() {
            this.dialogVisible = true;
         addUserSuccess() {
            this.searchclick();
         },
         searchUser() {},
         changeStatus(row) {
            row.status = !row.status;
            var obj = {
               enable: true,
               id: row.id
            }
            var str = "";
            if(row.status) {
               obj.enable = false;
               str = "停用";
            }else {
               obj.status = true;
               str = "启用";
            }
            this.$confirm('确定要'+str+row.account+'?','提示', {
               type: 'warning',
            }).then(() => {
               //const loading = this.$loading()
               //loading.close()
               this.$HTTP.post("/api/blade-user/changeStatus?"+this.$TOOL.qsStringify(obj)).then(res=> {
                  this.isSaveing = false;
                  if(res.code == 200) {
                     this.searchclick();
                     this.$message.success("操作成功");
                  }else {
                     this.$alert(res.message, "提示", {type: 'error'});
                  }
               })
            }).catch(() => {
               //取消
            })
         },
         table_unlock(row) {
            this.$confirm('确定将选择账号解锁??','提示', {
               type: 'warning',
            }).then(() => {
               this.$HTTP.post("/api/blade-user/unlock?userId="+row.id).then(res=> {
                  if(res.code == 200) {
                     this.searchclick();
                     this.$message.success("操作成功");
                  }else {
                     this.$alert(res.message, "提示", {type: 'error'});
                  }
               })
            }).catch(() => {
               //取消
            })
         },
         searchclick() {
            this.searchData.current = "1";
            this.searchData.size = "15";
            this.searchUser();
         },
         searchUser() {
            this.$HTTP.get("/api/blade-user/page",this.searchData).then(res=> {
               if(res.code == 200) {
                  res.data.records.forEach(item=> {
                     if(item.status == "1") {
                        item.status = true;
                     }else {
                        item.status = false;
                     }
                  })
                  this.tableData = res.data.records;
                  this.total = res.data.total;
                  console.log(this.tableData)
               }
            })
         },
         departmentSubmit() {
            this.departmentVisible=false;  //部门调整
         },
@@ -171,8 +215,67 @@
               this.$refs.saveDialog.open('show').setData(row)
            })
         },
         handleSelectionChange() {},
         delPerson() {},
         handleSelectionChange(selection) {
            this.selection = selection;
         },
         resetPerson() {
            if(this.selection.length == 0) {
               this.$message({
                   message: '请选择至少一条数据',
                   type: 'warning'
                 });
                 return;
            }
            var selStr = "";
            this.selection.map(item=> {
               selStr += item.id + ","
            })
            selStr = selStr.replace(/,$/, '');
            var that = this;
            this.$confirm('是否确认删除选中账号?','提示', {
               type: 'warning',
            }).then(() => {
               that.$HTTP.post("/api/blade-user/reset-password?userIds="+selStr).then(res=> {
                  if(res.code == 200) {
                     that.$message.success("操作成功");
                     that.searchUser();
                  }
               })
            }).catch(() => {
               //取消
            })
         },
         delData() {
            if(this.selection.length == 0) {
               this.$message({
                   message: '请选择至少一条数据',
                   type: 'warning'
                 });
                 return;
            }
            var selStr = "";
            this.selection.map(item=> {
               selStr += item.id + ","
            })
            selStr = selStr.replace(/,$/, '');
            var that = this;
            this.$HTTP.get("/api/blade-user/check-user-is-bind-employee?userIds="+selStr).then(res=> {
               if(res.code == 200) {
                  this.$confirm('是否确认删除选中账号?','提示', {
                     type: 'warning',
                  }).then(() => {
                     that.$HTTP.post("/api/blade-user/remove?ids="+selStr).then(res=> {
                        if(res.code == 200) {
                           that.$message.success("操作成功");
                           that.searchUser();
                        }
                     })
                  }).catch(() => {
                     //取消
                  })
               }
            })
         },
         changeDepartment() {
            this.departmentVisible = true;
         },
@@ -185,9 +288,14 @@
         },
         handleSizeChange(val) {
            console.log(`每页 ${val} 条`);
            this.searchData.current = "1";
            this.searchData.size = val;
            this.searchUser();
         },
         handleCurrentChange(val) {
            console.log(`当前页: ${val}`);
            this.searchData.current = val;
            this.searchUser();
         }
      }
   }