Pārlūkot izejas kodu

角色管理添加角色加分页,角色管理角色拉取管理的角色分页去掉

huahaiyan 6 gadi atpakaļ
vecāks
revīzija
87fa1f9a79

+ 7 - 10
src/dashoo.cn/backend/api/controllers/casbin/role.go

@@ -129,8 +129,8 @@ func (this *RoleController) OrgAllList() {
 // @router /getauditerbydept/:deptId [get]
 func (this *RoleController) GetAuditerByDept() {
 	Id := this.Ctx.Input.Param(":deptId")
-
-	var users []userRole.Base_RoleList
+	page := this.GetPageInfoForm()
+	var users []userRole.Base_User
 	rsvc := auditsetting.GetOilAuditSettingService(utils.DBE)
 	organsvc := organize.GetOrganizeService(utils.DBE)
 	where := "1=1"
@@ -144,15 +144,12 @@ func (this *RoleController) GetAuditerByDept() {
 	//	where += " and DepartmentId in (" + depids + ")"
 	//}
 	where += " and IsCompanyUser = 0"
-	rsvc.GetEntitysByWhere(BaseUserName, where, &users)
-	var datainfo ErrorDataInfo
-	if users == nil {
-		datainfo.Code = 0
-	} else {
-		datainfo.Code = 1
-	}
 
-	datainfo.Item = users
+	total := rsvc.GetPagingEntitiesWithSortCode(page.CurrentPage, page.Size, "Id asc", &users, where)
+	//rsvc.GetEntitysByWhere(BaseUserName, where, &users)
+	var datainfo DataInfo
+	datainfo.Items = users
+	datainfo.CurrentItemCount = total
 	this.Data["json"] = &datainfo
 	this.ServeJSON()
 }

+ 58 - 16
src/dashoo.cn/frontend_web/src/pages/system/userrole.vue

@@ -118,11 +118,11 @@
       </div>
     </el-dialog>
     <!-- 超级添加用户 -->
-    <el-dialog title="添加用户" :visible.sync="adminadduser" top="5vh" width="800px">
-      <el-form label-width="110px">
+    <el-dialog title="添加用户" :visible.sync="adminadduser" top="5vh" width="900px">
+      <el-form label-width="110px" style="text-align:right">
         <el-row :gutter="10">
-          <el-col :span="12">
-            <el-card style="width: 100%;height: calc(100vh - 283px);overflow: auto;margin-top:0px">
+          <el-col :span="10">
+            <el-card style="width: 100%;height: calc(100vh - 283px);margin-top:0px">
               <div slot="header" class="clearfix">
                 <span>请选择部门</span>
               </div>
@@ -130,12 +130,12 @@
             </el-card>
           </el-col>
 
-          <el-col :span="12">
-            <el-card style="width: 100%;height: calc(100vh - 283px);overflow: auto;margin-top:0px">
-              <el-table :data="userOptions" style="width: 100%" ref="multipleTable"
+          <el-col :span="14">
+            <el-card style="width: 100%;height: calc(100vh - 283px);margin-top:0px">
+              <el-table :data="userOptions" style="width: 100%;" height="calc(100vh - 353px)" ref="multipleTable"
                 @selection-change="handleSelectionChange">
                 <el-table-column type="selection" width="55"></el-table-column>
-                <el-table-column prop="realname" label="可选用户">
+                <el-table-column prop="Realname" label="可选用户">
                   <!-- <template slot="header">
                     <el-button type="primary" style="float: right;" size="small" @click="toggleSelection">
                       选择用户 <el-icon class="el-icon-d-arrow-right"></el-icon>
@@ -143,14 +143,20 @@
                   </template> -->
                 </el-table-column>
               </el-table>
+              <el-pagination small @size-change="handleSetRoleChange" @current-change="handleSetRoleCurrentChange"
+                :current-page="currentSetRolePage" :page-sizes="[10, 15, 20, 25]" :page-size="setrolesize"
+                layout="total, sizes, prev, pager, next" :total="currentSetRoleItemCount">
+               </el-pagination>
             </el-card>
           </el-col>
         </el-row>
-      </el-form>
-      <span style="float: right;margin-top:0px;">
+        <el-row :gutter="10">
+          <span style="margin-top:10px;">
         <el-button size="small" @click="adminadduser = false">取 消</el-button>
         <el-button type="primary" size="small" @click="toggleSelection()">确 定</el-button>
       </span>
+        </el-row>
+      </el-form>
     </el-dialog>
     <!-- 添加用户 -->
     <el-dialog title="添加用户" :visible.sync="addUserShow" width="360px">
@@ -234,7 +240,7 @@
       </el-checkbox>
       <div style="margin-top:20px;">
         <el-checkbox-group v-model="selectedrole">
-          <el-checkbox v-for="role in list" @change="handlecheckedrolechange" :label="role.Id" :value="role.Id"
+          <el-checkbox v-for="role in setrolelist" @change="handlecheckedrolechange" :label="role.Id" :value="role.Id"
             :key="role.Id">{{role.Realname}}</el-checkbox>
         </el-checkbox-group>
       </div>
@@ -307,8 +313,12 @@
         currentPage: 1,
         size: 10,
         list: [],
+        setrolelist:[],
         rolelist: [],
-
+        currentSetRoleItemCount: 0,
+        currentSetRolePage: 1,
+        setrolesize: 10,
+        setroledepid:'',
         currentUserItemCount: 0,
         currentUserPage: 1,
         userSize: 10,
@@ -367,6 +377,7 @@
       //this.getallequipmentlist()
       this.getallrolelist()
       this.getadminpermission()
+      this.getroleData()
     },
     methods: {
       initData() {
@@ -393,6 +404,19 @@
             _this.exportloading = false
           })
       },
+      getroleData() {
+        let _this = this
+        // request
+        this.$axios.get('role/list', {})
+          .then(res => {
+            // response
+            _this.setrolelist = res.data.items
+          })
+          .catch(err => {
+            // handle error
+            console.error(err)
+          })
+      },
       getadminpermission() {
         this.$axios.get('role/getAdminPermi', {})
           .then(res => {
@@ -486,12 +510,21 @@
           })
       },
       handleNodeClick(data) {
+        this.setroledepid = data.id
+        this.currentSetRolePage = 1
+        this.getauditerbydept(data.id)
+      },
+      getauditerbydept (deptid) {
         this.userOptions = []
-        this.$axios.get('role/getauditerbydept/' + data.id, ).then(res => {
-          if (res.data.code === 1) {
-            this.userOptions = res.data.item
+        const params = {
+          _currentPage: this.currentSetRolePage,
+          _size: this.setrolesize
+        }
+        this.$axios.get('role/getauditerbydept/' + deptid, {params}).then(res => {
+          console.log(res, 'res')
+          this.userOptions = res.data.items
+          this.currentSetRoleItemCount = res.data.currentItemCount
             //this.adminuserlistfilter()
-          }
         }).catch(err => {
           console.error(err)
         })
@@ -1314,6 +1347,15 @@
         this.currentPage = value
         this.initData()
       },
+      handleSetRoleChange(value) {
+        this.setrolesize = value
+        this.currentSetRolePage = 1
+        this.getauditerbydept(this.setroledepid)
+      },
+      handleSetRoleCurrentChange(value) {
+        this.currentSetRolePage = value
+        this.getauditerbydept(this.setroledepid)
+      },
 
       handleUserSizeChange(value) {
         this.userSize = value