Просмотр исходного кода

后台企业更换管理员申请列表页面

huxz 8 лет назад
Родитель
Сommit
0c81dcaf13

+ 149 - 22
sso-manage-console-web/src/components/admin/ChangeAdmin.vue

@@ -1,34 +1,161 @@
 <template>
-  <div class="hello">
-    <h1>{{ msg }}123</h1>
+  <div>
+    <div class="x-container">
+      <div class="container">
+        <div class="row">
+          <div class="x-content-wrap clearfix">
+            <div class="col-sm-12 col-md-9 x-content">
+              <!-- tab切换 start-->
+              <ul class="nav nav-tabs x-nav-tabs x-navbar-right hidden-xs">
+                <!-- Tabs start -->
+                <li :class="{active: selectedStatus === 'UNAPPLY'}"><a @click="switchStatus('UNAPPLY')">未通过</a></li>
+                <li :class="{active: selectedStatus === 'ENABLED'}"><a @click="switchStatus('ENABLED')">已通过</a></li>
+                <li :class="{active: selectedStatus === 'UNAUDIT'}"><a @click="switchStatus('UNAUDIT')">待审批</a></li>
+                <!-- Tabs end -->
+
+                <!-- Title with search dialog -->
+                <search-dialog :title="'企业'" :visible="isShowSearchDialog" :pageSizes="[10, 20, 50]" v-model.number="pageParams.size" @search="beginSearchChanges()">
+                  <div class="form-group">
+                    <label>名称</label> <input type="text" class="form-control" name="spaceName" placeholder="输入企业名称关键字" v-model="pageParams.spaceName">
+                  </div>
+                  <div class="form-group">
+                    <label>营业执照</label> <input type="text" class="form-control" name="businessCode" placeholder="输入营业执照" v-model="pageParams.businessCode">
+                  </div>
+                  <div class="form-group">
+                    <label>申请人</label> <input type="text" class="form-control" name="userName" placeholder="输入申请人姓名" v-model="pageParams.userName">
+                  </div>
+                </search-dialog>
+                <!-- Title with search dialog -->
+              </ul>
+              <!-- tab切换 end-->
+              <!-- 列表 start -->
+              <div class="x-mod x-list x-data-list-wrap">
+                <div class="x-mod-body">
+                  <data-list>
+                    <div class="x-data-list" v-if="changesList.length > 0">
+                      <div class="x-item" v-for="change in changesList">
+                        <div class="x-icon"><a class="x-btn-image" href="javascript:void(0}">
+                          <img src="http://dfs.ubtob.com/group1/M00/4F/38/CgpkyFnKB9qAUhrXAAvqH_kipG8228.jpg"
+                          width="50px" height="50px"/></a>
+                        </div>
+                        <p><a class="x-title x-editor-trigger" href="javascript:void(0)">{{ change.userspace.spaceName || '企业名称' }}</a>
+                          <span class="pull-right x-text-muted">{{ change.submitDate | date }}</span>
+                        </p>
+                        <div class="x-text-muted">{{change.userspace.businessCode || '营业执照'}}<span
+                          class="pull-right x-text-muted">{{change.submitterName}}</span></div>
+                      </div>
+                    </div>
+                  </data-list>
+                </div>
+                <div class="x-mod-footer">
+                  <page-bar :pageParams="pageParams" :totalPages="totalPages" :total="totalElements" @changePage="jumpPage"/>
+                </div>
+              </div>
+              <!-- 列表 end -->
+            </div>
+          </div>
+        </div>
+      </div>
+    </div>
   </div>
 </template>
 
 <script>
-export default {
-  name: 'AppHome',
-  data () {
-    return {
-      msg: '更换管理员'
+  import _ from 'lodash'
+  import axios from '@/assets/js/axios'
+  import {DataList, SearchDialog} from '@/components/common'
+  import PageBar from '@/components/common/PageBar'
+
+  export default {
+    name: 'AppHome',
+    components: {
+      SearchDialog,
+      DataList,
+      PageBar
+    },
+    data () {
+      return {
+        pageParams: {
+          page: 1,
+          size: 10,
+          spaceName: null,
+          businessCode: null,
+          userName: null,
+          validCode: 1
+        },
+        isShowSearchDialog: false,
+        totalPages: 0,
+        totalElements: 0,
+        changesList: [],
+        selectedStatus: 'UNAUDIT'
+      }
+    },
+    methods: {
+      beginSearchChanges () {
+        this.loadChangeAdminList()
+      },
+      fetchData () {
+        this.loadChangeAdminList()
+      },
+      loadChangeAdminList () {
+        const params = _.defaultsDeep({}, this.pageParams)
+        params.page = params.page - 1
+
+        const success = page => {
+          this.changesList = page.content || []
+          this.totalPages = page.totalPages
+          this.totalElements = page.totalElements
+
+          console.log(page)
+        }
+        const error = response => {
+          console.log('error', response)
+        }
+
+        axios.get('/api/user/space/admin//pagination', { params }).then(success).catch(
+          error)
+      },
+      switchStatus (status) {
+        this.selectedStatus = status
+
+        switch (status) {
+          case 'UNAPPLY':
+            this.pageParams.validCode = 3
+            break
+          case 'ENABLED':
+            this.pageParams.validCode = 2
+            break
+          case 'UNAUDIT':
+            this.pageParams.validCode = 1
+            break
+          default:
+            this.selectedStatus = 'UNAUDIT'
+            this.pageParams.validCode = 1
+        }
+        this.loadChangeAdminList()
+      },
+      jumpPage (page) {
+        if (!page || page <= 0) {
+          this.pageParams.page = 1
+        } else if (page > this.totalPages) {
+          this.pageParams.page = this.totalPages
+        } else {
+          this.pageParams.page = page
+        }
+
+        this.loadChangeAdminList()
+      }
+    },
+    created () {
+      this.fetchData()
+    },
+    watch: {
+      '$route': 'fetchData'
     }
   }
-}
 </script>
 
 <!-- Add "scoped" attribute to limit CSS to this component only -->
 <style scoped>
-h1, h2 {
-  font-weight: normal;
-}
-ul {
-  list-style-type: none;
-  padding: 0;
-}
-li {
-  display: inline-block;
-  margin: 0 10px;
-}
-a {
-  color: #42b983;
-}
+
 </style>

+ 20 - 0
sso-manage-console-web/src/components/common/DataList.vue

@@ -0,0 +1,20 @@
+<template>
+  <div>
+    <slot>
+      <div class="x-empty" style="display: block;">
+        <i class="fa fa-coffee"></i>
+        <p>这里很干净!</p>
+      </div>
+    </slot>
+  </div>
+</template>
+
+<script>
+  export default {
+    name: 'DataList'
+  }
+</script>
+
+<style scoped>
+
+</style>

+ 55 - 0
sso-manage-console-web/src/components/common/SearchDialog.vue

@@ -0,0 +1,55 @@
+<template>
+  <!-- Title with search dialog -->
+  <h2 class="btn-group">
+    <span class="btn btn-lg x-btn-search" @click="visible = !visible">
+      <i class="fa fa-search"></i>
+      <span v-text="title">企业</span>
+    </span>
+    <div class="dropdown-menu" id="searchlist" style="padding: 15px; width: 240px; display: block;" v-if="visible">
+      <form>
+        <slot></slot>
+        <div class="form-group">
+          <div>
+            <label>分页设置</label>
+          </div>
+          <label class="radio-inline" v-for="pageSize in pageSizes"><input type="radio" name="pageSize" :value="pageSize" :checked="checked === pageSize" @change="$emit('change', $event.target.value)"> {{pageSize}}
+          </label>
+        </div>
+        <button class="btn btn-default btn-block btn-search" type="button" @click="beginSearch()">搜索</button>
+      </form>
+    </div>
+  </h2>
+</template>
+
+<script>
+  export default {
+    name: 'SearchDialog',
+    props: {
+      title: String,
+      pageSizes: Array,
+      checked: {
+        type: Number,
+        default: 0
+      }
+    },
+    model: {
+      prop: 'checked',
+      event: 'change'
+    },
+    data () {
+      return {
+        visible: false
+      }
+    },
+    methods: {
+      beginSearch () {
+        this.visible = false
+        this.$emit('search')
+      }
+    }
+  }
+</script>
+
+<style scoped>
+
+</style>

+ 7 - 0
sso-manage-console-web/src/components/common/index.js

@@ -0,0 +1,7 @@
+import SearchDialog from './SearchDialog'
+import DataList from './DataList'
+
+export {
+  SearchDialog,
+  DataList
+}

+ 66 - 66
sso-manage-console-web/src/components/user/UserHome.vue

@@ -149,80 +149,80 @@
   import UserEditModal from './modal/UserEditModal'
 
   export default {
-  name: 'AppHome',
-  components: {
-    PageBar,
-    UserEditModal
-  },
-  data () {
-    return {
-      pageParams: {
-        page: 1,
-        size: 20,
-        name: '',
-        phone: ''
-      },
-      showSearch: false,
-      userList: [],
-      totalPages: 1,
-      totalElements: 0,
-      showModal: false,
-      selectedUser: {}
-    }
-  },
-  created () {
-    this.fetchData()
-  },
-  watch: {
-    '$route': 'fetchData'
-  },
-  methods: {
-    fetchData () {
-      this.loadUserList()
+    name: 'AppHome',
+    components: {
+      PageBar,
+      UserEditModal
     },
-    loadUserList () {
-      const params = _.defaultsDeep({}, this.pageParams)
-      params.page = params.page - 1
-
-      const success = page => {
-        this.userList = page.content || []
-        this.totalPages = page.totalPages
-        this.totalElements = page.totalElements
+    data () {
+      return {
+        pageParams: {
+          page: 1,
+          size: 20,
+          name: '',
+          phone: ''
+        },
+        showSearch: false,
+        userList: [],
+        totalPages: 1,
+        totalElements: 0,
+        showModal: false,
+        selectedUser: {}
       }
-      const error = response => {
-        console.log('error', response)
-      }
-
-      axios.get('/api/user//showUserByPagination', { params }).then(success).catch(
-        error)
     },
-    closeSearchDialog (event) {
-      console.log(event)
+    created () {
+      this.fetchData()
     },
-    searchUserInfo () {
-      this.loadUserList()
-
-      this.showSearch = false
-      this.pageParams.name = ''
-      this.pageParams.phone = ''
+    watch: {
+      '$route': 'fetchData'
     },
-    jumpPage (page) {
-      if (!page || page <= 0) {
-        this.pageParams.page = 1
-      } else if (page > this.totalPages) {
-        this.pageParams.page = this.totalPages
-      } else {
-        this.pageParams.page = page
-      }
+    methods: {
+      fetchData () {
+        this.loadUserList()
+      },
+      loadUserList () {
+        const params = _.defaultsDeep({}, this.pageParams)
+        params.page = params.page - 1
 
-      this.loadUserList()
-    },
-    showEditDialog (user) {
-      this.selectedUser = user || {}
-      this.showModal = true
+        const success = page => {
+          this.userList = page.content || []
+          this.totalPages = page.totalPages
+          this.totalElements = page.totalElements
+        }
+        const error = response => {
+          console.log('error', response)
+        }
+
+        axios.get('/api/user//showUserByPagination', { params }).then(success).catch(
+          error)
+      },
+      closeSearchDialog (event) {
+        console.log(event)
+      },
+      searchUserInfo () {
+        this.loadUserList()
+
+        this.showSearch = false
+        this.pageParams.name = ''
+        this.pageParams.phone = ''
+      },
+      jumpPage (page) {
+        if (!page || page <= 0) {
+          this.pageParams.page = 1
+        } else if (page > this.totalPages) {
+          this.pageParams.page = this.totalPages
+        } else {
+          this.pageParams.page = page
+        }
+
+        this.loadUserList()
+      },
+      showEditDialog (user) {
+        this.selectedUser = user || {}
+        this.showModal = true
+      }
     }
   }
-}
 </script>
 
 <!-- Add "scoped" attribute to limit CSS to this component only -->

+ 28 - 28
sso-manage-console-web/src/components/user/modal/UserEditModal.vue

@@ -93,39 +93,39 @@
   import axios from '@/assets/js/axios'
 
   export default {
-  name: 'UserEditModal',
-  props: {
-    visible: Boolean,
-    user: Object
-  },
-  data () {
-    return {
-      isVisible: false,
-      showTab: 'default',
-      spaces: []
-    }
-  },
-  watch: {
-    visible: function (value) {
-      this.isVisible = value
+    name: 'UserEditModal',
+    props: {
+      visible: Boolean,
+      user: Object
     },
-    isVisible: function (value) {
-      this.$emit('update:visible', value)
-    }
-  },
-  methods: {
-    showBindApps () {
-      const success = spaces => {
-        this.showTab = 'apps'
-        this.spaces = spaces
-        console.log(spaces)
+    data () {
+      return {
+        isVisible: false,
+        showTab: 'default',
+        spaces: []
+      }
+    },
+    watch: {
+      visible: function (value) {
+        this.isVisible = value
+      },
+      isVisible: function (value) {
+        this.$emit('update:visible', value)
       }
-      const error = response => { console.log('error', response) }
+    },
+    methods: {
+      showBindApps () {
+        const success = spaces => {
+          this.showTab = 'apps'
+          this.spaces = spaces
+          console.log(spaces)
+        }
+        const error = response => { console.log('error', response) }
 
-      axios.get(`/api/user/${this.user.userUU}/findSpacesByUser`).then(success).catch(error)
+        axios.get(`/api/user/${this.user.userUU}/findSpacesByUser`).then(success).catch(error)
+      }
     }
   }
-}
 </script>
 
 <style scoped>

+ 35 - 35
sso-manage-console-web/src/components/userspace/modal/SpaceEditModal.vue

@@ -181,47 +181,47 @@
   import axios from '@/assets/js/axios'
 
   export default {
-  name: 'SpaceEditModal',
-  props: {
-    visible: Boolean,
-    data: Object
-  },
-  data () {
-    return {
-      isVisible: false,
-      showTab: 'default',
-      canBindApp: false,
-      appUid: ''
-    }
-  },
-  watch: {
-    visible: function (value) {
-      this.isVisible = value
+    name: 'SpaceEditModal',
+    props: {
+      visible: Boolean,
+      data: Object
     },
-    isVisible: function (value) {
-      this.$emit('update:visible', value)
-    }
-  },
-  methods: {
-    bindAppWithSpace (appUid) {
-      console.log(appUid)
-      const params = { appUid: appUid }
-
-      const success = status => {
-        if (status) {
-          this.isVisible = false
-          this.canBindApp = false
-        }
+    data () {
+      return {
+        isVisible: false,
+        showTab: 'default',
+        canBindApp: false,
+        appUid: ''
       }
-      const error = response => {
-        alert(response)
-        console.log('error', response)
+    },
+    watch: {
+      visible: function (value) {
+        this.isVisible = value
+      },
+      isVisible: function (value) {
+        this.$emit('update:visible', value)
       }
+    },
+    methods: {
+      bindAppWithSpace (appUid) {
+        console.log(appUid)
+        const params = { appUid: appUid }
 
-      axios.put(`/api/user/space/${this.data.spaceUU}/bindAppWithSpace`, {}, { params }).then(success).catch(error)
+        const success = status => {
+          if (status) {
+            this.isVisible = false
+            this.canBindApp = false
+          }
+        }
+        const error = response => {
+          alert(response)
+          console.log('error', response)
+        }
+
+        axios.put(`/api/user/space/${this.data.spaceUU}/bindAppWithSpace`, {}, { params }).then(success).catch(error)
+      }
     }
   }
-}
 </script>
 
 <style scoped>

+ 11 - 4
sso-manage-console/src/main/java/com/uas/sso/sso/backend/api/ChangeAdminController.java

@@ -13,6 +13,7 @@ import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
 
 /**
@@ -34,21 +35,27 @@ public class ChangeAdminController {
 
     @RequestMapping(method = RequestMethod.GET, path = "//pagination",
             produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
-    public ResultBean<Page<ChangeAdmin>> showUserByPagination(Pageable page) {
+    public ResultBean<Page<ChangeAdmin>> showUserByPagination(Pageable page, Short validCode,
+            @RequestParam(required = false) String spaceName,
+            @RequestParam(required = false) String businessCode,
+            @RequestParam(required = false) String userName) {
 
-        return new ResultBean<>(changeAdminService.showUserByPagination(page));
+        return new ResultBean<>(changeAdminService
+                .showUserByPagination(page, validCode, spaceName, businessCode, userName));
     }
 
     @RequestMapping(method = RequestMethod.POST, path = "//submitChange",
             produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
-    public ResultBean<ChangeAdmin> submitChangeAdminRequest(@RequestBody @Validated ChangeAdminCommit commit) {
+    public ResultBean<ChangeAdmin> submitChangeAdminRequest(
+            @RequestBody @Validated ChangeAdminCommit commit) {
 
         return new ResultBean<>(changeAdminService.submitChangeAdminRequest(commit));
     }
 
     @RequestMapping(method = RequestMethod.PUT, path = "//auditChange",
             produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
-    public ResultBean<Boolean> auditChangeAdminRequest(@RequestBody @Validated ChangeAdminAudit audit) {
+    public ResultBean<Boolean> auditChangeAdminRequest(
+            @RequestBody @Validated ChangeAdminAudit audit) {
 
         return new ResultBean<>(changeAdminService.auditChangeAdminRequest(audit));
     }

+ 2 - 1
sso-manage-console/src/main/java/com/uas/sso/sso/backend/service/ChangeAdminService.java

@@ -14,7 +14,8 @@ import org.springframework.data.domain.Pageable;
  */
 public interface ChangeAdminService {
 
-    Page<ChangeAdmin> showUserByPagination(Pageable page);
+    Page<ChangeAdmin> showUserByPagination(Pageable page, Short validCode,
+            String spaceName, String businessCode, String userName);
 
     /**
      * Just for testing

+ 39 - 2
sso-manage-console/src/main/java/com/uas/sso/sso/backend/service/impl/ChangeAdminServiceImpl.java

@@ -8,8 +8,12 @@ import com.uas.sso.entity.User;
 import com.uas.sso.entity.Userspace;
 import com.uas.sso.sso.backend.dto.ChangeAdminAudit;
 import com.uas.sso.sso.backend.dto.ChangeAdminCommit;
+import com.uas.sso.sso.backend.exceptions.ValidationFailedException;
 import com.uas.sso.sso.backend.service.ChangeAdminService;
+import java.util.ArrayList;
+import java.util.Collections;
 import java.util.List;
+import javax.persistence.criteria.Predicate;
 import javax.validation.constraints.NotNull;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.domain.Page;
@@ -18,6 +22,7 @@ import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.Assert;
 import org.springframework.util.CollectionUtils;
+import org.springframework.util.StringUtils;
 
 /**
  * An implementations of {@code ChangeAdminService}.
@@ -42,9 +47,41 @@ public class ChangeAdminServiceImpl implements ChangeAdminService {
     }
 
     @Override
-    public Page<ChangeAdmin> showUserByPagination(Pageable page) {
+    public Page<ChangeAdmin> showUserByPagination(Pageable page, Short validCode,
+            String spaceName, String businessCode, String userName) {
+        if (validCode == null) {
+            throw new ValidationFailedException("企业信息认证状态必须指定");
+        }
+
+        return changeAdminDao.findAll((root, query, builder) -> {
+            List<Predicate> predicates = new ArrayList<>();
+
+            // 根据企业认证状态进行过滤
+            predicates.add(builder.equal(root.get("validCode"), validCode));
+
+            if (!StringUtils.isEmpty(spaceName)) {
+                Predicate predicate = builder.like(root.get("userspace").get("spaceName"), "%" + spaceName + "%");
+                predicates.add(predicate);
+            }
+
+            if (!StringUtils.isEmpty(businessCode)) {
+                Predicate predicate = builder.like(root.get("userspace").get("businessCode"), businessCode + "%");
+                predicates.add(predicate);
+            }
+
+            if (!StringUtils.isEmpty(userName)) {
+                Predicate predicate = builder.like(root.get("submitterName"), "%" + userName + "%");
+                predicates.add(predicate);
+            }
+
+            predicates.removeAll(Collections.singletonList(null));
 
-        return changeAdminDao.findAll(page);
+            Predicate[] array = new Predicate[predicates.size()];
+            predicates.toArray(array);
+            Predicate predicate = builder.and(array);
+            query.where(predicate);
+            return null;
+        }, page);
     }
 
     @Override