1
lzhe
2024-04-03 e7eb78c74a233f665a24e99d5a3bd847c46feee7
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="primary" @click="addPerson">密码重置</el-button>
            <el-button type="danger" plain @click="delPerson">删除</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>
@@ -73,7 +79,7 @@
      </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,6 +87,13 @@
      name: "bakalaka",
      data(){
         return {
            searchData: {
               account: "",
               realName: "",
               current: "1",
               size: "15"
            },
            total: 0,
            dialogVisible: false,
            isSaveing: false,
            groups: [],
@@ -103,51 +116,78 @@
               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: {
         addUserSuccess() {
            this.searchclick();
         },
         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() {
            this.dialogVisible = true;
         },
         searchUser() {},
         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;  //部门调整
         },
@@ -185,9 +225,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();
         }
      }
   }