Browse Source

添加认证审核

sunjh 6 years ago
parent
commit
ac1c8ce26b

+ 150 - 61
src/components/authen/AuthenticationManage.vue

@@ -1,125 +1,214 @@
 <template>
-  <div class="create-container">
+  <div class="create-container" v-loading="loading">
     <div class="create-body">
       <div class="title">审核认证信息</div>
       <el-table
-        :data="authenticationList"
+        :data="handlingAuthList"
+        :row-class-name="rowClassName"
         stripe
         style="width: 100%">
-        <el-table-column prop="code" label="编号">
+        <el-table-column prop="id" label="编号">
           <template slot-scope="scope">
-            <span>{{scope.row.code}}</span>
+            <span>{{scope.row.id}}</span>
           </template>
         </el-table-column>
         <el-table-column prop="userInfo" label="用户信息">
           <template slot-scope="scope">
             <span style="cursor: pointer">
-              <el-link type="primary">{{scope.row.userInfo}}</el-link>
+              <el-link type="primary">{{scope.row.userName}}</el-link>
             </span>
           </template>
         </el-table-column>
         <el-table-column prop="type" label="认证类型">
           <template slot-scope="scope">
             <span>
-              <el-tag v-if="scope.row.type=='个人'" type="success">{{scope.row.type}}</el-tag>
-              <el-tag v-if="scope.row.type=='机构'">{{scope.row.type}}</el-tag>
-              <el-tag v-if="scope.row.type=='企业'" type="warning">{{scope.row.type}}</el-tag>
+              <el-tag v-if="scope.row.type=='personal'" type="success">个人</el-tag>
+              <el-tag v-if="scope.row.type=='agency'">机构</el-tag>
+              <el-tag v-if="scope.row.type=='enterprise'" type="warning">企业</el-tag>
             </span>
           </template>
         </el-table-column>
         <el-table-column prop="detail" label="认证详情">
           <template slot-scope="scope">
-            <el-link type="primary">{{scope.row.detail}}</el-link>
+            <el-link type="primary">认证详情</el-link>
           </template>
         </el-table-column>
         <el-table-column prop="status" label="认证状态">
           <template slot-scope="scope">
             <span>
-              <el-tag v-if="scope.row.status==authenticationStatusUntreated" type="info">{{scope.row.status}}</el-tag>
-              <el-tag v-if="scope.row.status==authenticationStatusPass" type="success">{{scope.row.status}}</el-tag>
-              <el-tag v-if="scope.row.status===authenticationStatusReject" type="danger">{{scope.row.status}}</el-tag>
+              <el-tag :type="scope.row.authStatus.style">{{scope.row.authStatus.text}}</el-tag>
             </span>
           </template>
         </el-table-column>
         <el-table-column prop="date" label="申请时间" width="180">
           <template slot-scope="scope">
-            <span>{{scope.row.date}}</span>
+            <span>{{reformTime(new Date(scope.row.applytime))}}</span>
           </template>
         </el-table-column>
         <el-table-column label="操作" width="180">
           <template slot-scope="scope">
-            <el-button type="primary" size="mini" @click="handleAuthenticationPass(scope.row)">通过</el-button>
-            <el-button type="warning" size="mini" @click="handleAuthenticationReject(scope.row)">驳回</el-button>
+            <el-button type="primary" size="mini" @click="handleAuthenticationPass(scope.row.userId,scope.row.type)">
+              通过
+            </el-button>
+            <el-button type="warning" size="mini" @click="handleAuthenticationReject(scope.row.userId,scope.row.type)">
+              驳回
+            </el-button>
           </template>
         </el-table-column>
       </el-table>
-      <el-pagination
-        :page-size="20"
-        hide-on-single-page
-        :pager-count="5"
-        :current-page.sync="currentPage"
-        layout="prev, pager, next"
-        @current-change="handleCurrentChange"
-        :total="100">
-      </el-pagination>
+      <!--<el-pagination-->
+      <!--:page-size="20"-->
+      <!--hide-on-single-page-->
+      <!--:pager-count="5"-->
+      <!--:current-page.sync="currentPage"-->
+      <!--layout="prev, pager, next"-->
+      <!--@current-change="handleCurrentChange"-->
+      <!--:total="100">-->
+      <!--</el-pagination>-->
     </div>
   </div>
 </template>
 
 <script>
+import {
+  checkPassAuth,
+  checkRejectAuth,
+  getAllHandledAuthInfo,
+  getAllHandlingAuthInfo,
+  getFormalTimeFromDate,
+} from '@/js/index'
+import {notify} from '@/constants/index'
+
 export default {
   name: 'AuthenticationManage',
   data () {
     return {
       currentPage: 1,
+      loading: false,
       authenticationStatusUntreated: '审核中',
       authenticationStatusPass: '审核通过',
       authenticationStatusReject: '审核未通过',
-      authenticationList: [{
-        code: '123122',
-        userInfo: '郭超',
-        type: '个人',
-        status: '审核中',
-        detail: '查看详情',
-        date: '2016-05-04'
-      }, {
-        code: '123123',
-        userInfo: '郭超',
-        type: '企业',
-        status: '审核未通过',
-        detail: '查看详情',
-        date: '2016-05-04'
-      }, {
-        code: '123124',
-        userInfo: '郭超',
-        type: '机构',
-        status: '审核通过',
-        detail: '查看详情',
-        date: '2016-05-04'
-      }],
-      tableData: [{
-        date: '2016-05-02',
-        name: '王小虎',
-        address: '上海市普陀区金沙江路 1518 弄'
-      }, {
-        date: '2016-05-04',
-        name: '王小虎',
-        address: '上海市普陀区金沙江路 1517 弄'
-      }]
+      handlingAuthList: [],
+      handledAuthList: [],
+      authenticationList: [
+        {
+          code: '123122',
+          userInfo: '郭超',
+          type: '个人',
+          status: '审核中',
+          detail: '查看详情',
+          date: '2016-05-04'
+        }, {
+          code: '123123',
+          userInfo: '郭超',
+          type: '企业',
+          status: '审核未通过',
+          detail: '查看详情',
+          date: '2016-05-04'
+        }, {
+          code: '123124',
+          userInfo: '郭超',
+          type: '机构',
+          status: '审核通过',
+          detail: '查看详情',
+          date: '2016-05-04'
+        }],
+      tableData: [
+        {
+          date: '2016-05-02',
+          name: '王小虎',
+          address: '上海市普陀区金沙江路 1518 弄'
+        }, {
+          date: '2016-05-04',
+          name: '王小虎',
+          address: '上海市普陀区金沙江路 1517 弄'
+        }]
     }
   },
+  mounted () {
+    this.$nextTick(() => {
+      this.init()
+    })
+  },
   methods: {
+    init () {
+      this.getHandlingAuthList()
+      this.getHandledAuthList()
+    },
+    //获取所有未认证信息
+    getHandlingAuthList () {
+      this.showLoading()
+      getAllHandlingAuthInfo(this.getHandlingAuthListSuccess, this.getHandlingAuthListFail)
+    },
+    //获取所有已认证信息
+    getHandlingAuthListSuccess (res) {
+      this.handlingAuthList = res
+      this.hideLoading()
+    },
+    getHandlingAuthListFail (error) {
+      this.hideLoading()
+      notify('error', '获取认证信息失败:' + error.data)
+    },
+    getHandledAuthList () {
+      this.showLoading()
+      getAllHandledAuthInfo(this.getHandledAuthListSuccess, this.getHandledAuthListFail)
+    },
+    getHandledAuthListSuccess (res) {
+      this.handledAuthList = res
+      this.hideLoading()
+    },
+    getHandledAuthListFail (error) {
+      this.hideLoading()
+      notify('error', '获取已认证信息失败:' + error.data)
+    },
     handleCurrentChange (param) {
       console.log(param)
     },
-    handleAuthenticationPass (item) {
-      item.status = this.authenticationStatusPass
-      console.log('通过')
+    handleAuthenticationPass (userId, type) {
+      this.showLoading()
+      checkPassAuth(type, userId, this.handleAuthenticationPassSuccess, this.handleAuthenticationPassFail)
+      // item.status = this.authenticationStatusPass
+      // console.log('通过')
     },
-    handleAuthenticationReject (item) {
-      item.status = this.authenticationStatusReject
-      console.log('拒绝')
+    handleAuthenticationPassSuccess (res) {
+      this.hideLoading()
+      this.getHandlingAuthList()
+      console.log(res)
     },
+    handleAuthenticationPassFail (error) {
+      this.hideLoading()
+      console.log(error)
+      notify('error', '通过失败:' + error.data)
+    },
+    handleAuthenticationReject (userId, type) {
+      this.showLoading()
+      // console.log(userId)
+      // console.log(type)
+      checkRejectAuth(type, userId, this.handleAuthenticationRejectSuccess, this.handleAuthenticationRejectFail)
+    },
+    handleAuthenticationRejectSuccess (res) {
+      this.hideLoading()
+      this.getHandlingAuthList()
+      console.log(res)
+    },
+    handleAuthenticationRejectFail (error) {
+      this.hideLoading()
+      console.log(error)
+      notify('error', '拒绝失败:' + error.data)
+    },
+    showLoading () {
+      this.loading = true
+    },
+    hideLoading () {
+      this.loading = false
+    },
+    reformTime (date) {
+      return getFormalTimeFromDate(date)
+    },
+    rowClassName ({row, rowIndex}) {
+      //把每一行的索引放进row.id
+      row.id = rowIndex + 1
+    }
   }
 }
 </script>

+ 2 - 2
src/components/commons/Header.vue

@@ -116,12 +116,12 @@
                   认证审核中
                 </el-link>
               </el-dropdown-item>
-              <el-dropdown-item @click.native="handleClickAuthPass()" v-if="user.authStatus.text == '认证通过'">
+              <el-dropdown-item @click.native="handleClickAuthPass()" v-if="user.authStatus.text == '审核通过'">
                 <el-link type="primary" icon="el-icon-check" :underline="false">
                   已认证
                 </el-link>
               </el-dropdown-item>
-              <el-dropdown-item @click.native="handleClickAuthReject()" v-if="user.authStatus.text == '认证未通过'">
+              <el-dropdown-item @click.native="handleClickAuthReject()" v-if="user.authStatus.text == '审核未通过'">
                 <el-link type="danger" icon="el-icon-close" :underline="false">
                   认证失败
                 </el-link>

+ 8 - 0
src/js/api.js

@@ -55,6 +55,14 @@ export default {
     GET_INDIVIDUAL_AUTHENTICATION_INFO: '/api/user/{userId}/personalAuth',
     GET_ENTERPRISE_AUTHENTICATION_INFO: '/api/user/{userId}/enterpriseAuth',
     GET_AGENCY_AUTHENTICATION_INFO: '/api/user/{userId}/agency',
+    GET_ALL_HANDLING_AUTH_INFO: '/api/user/authentication/handling',
+    GET_ALL_HANDLED_AUTH_INFO: '/api/user/authentication/handled',
+    PASS_AGENCY_AUTH:'/api/user/{userId}/agency/status/accept',
+    PASS_ENTERPRISE_AUTH:'/api/user/{userId}/enterpriseAuth/status/accept',
+    PASS_INDIVIDUAL_AUTH:'/api/user/{userId}/personalAuth/status/accept',
+    REJECT_AGENCY_AUTH:'/api/user/{userId}/agency/status/reject',
+    REJECT_ENTERPRISE_AUTH:'/api/user/{userId}/enterpriseAuth/status/reject',
+    REJECT_INDIVIDUAL_AUTH:'/api/user/{userId}/personalAuth/status/reject',
   },
   PAGE: {
     HOME_PAGE: '/api/common/index/',

+ 11 - 4
src/js/index.js

@@ -1,6 +1,9 @@
 import {
+  checkPassAuth,
+  checkRejectAuth,
   deleteAuthInfo,
-  getAllAuthentications,
+  getAllHandledAuthInfo,
+  getAllHandlingAuthInfo,
   getAuthUrls,
   getCurrentAgencyAuthInfo,
   getCurrentAuthenInfo,
@@ -71,8 +74,10 @@ export {
   /*******************************************************************************/
   //TODO 尚未使用 用户放弃认证,删除用户认证信息
   deleteAuthInfo,
-  //TODO 目前使用本地数据 需要修改 获取所有认证信息
-  getAllAuthentications,
+  //获取所有未处理认证信息
+  getAllHandlingAuthInfo,
+  //获取所有已处理认证信息
+  getAllHandledAuthInfo,
   //TODO 目前使用本地数据 需要修改 获取所有可以访问的url
   getAuthUrls,
   //TODO 目前使用本地数据 需要修改 获取当前用户的认证信息
@@ -97,7 +102,9 @@ export {
   uploadIndividualAuthenticationInfo,
   getCurrentIndividualAuthenInfo,
   getCurrentEnterpriseAuthInfo,
-  getCurrentAgencyAuthInfo
+  getCurrentAgencyAuthInfo,
+  checkPassAuth,
+  checkRejectAuth,
 }
 export {
   /*******************************************************************************/

+ 63 - 9
src/js/userService.js

@@ -105,14 +105,21 @@ export const uploadAgencyAuthenticationInfo = (userId, userAuthInfo, uploadAgenc
   })
 }
 
-//获取所有认证消息
-export const getAllAuthentications = () => {
-  return [{
-    userVO: {},
-    type: '',
-    status: '',
-    authenticationDetail: {}
-  }]
+//获取所有未处理认证消息
+export const getAllHandlingAuthInfo = (getAllHandlingAuthInfoSuccess, getAllHandlingAuthInfoFail) => {
+  Http.get(Apis.USER.GET_ALL_HANDLING_AUTH_INFO).then((res) => {
+    getAllHandlingAuthInfoSuccess(res)
+  }).catch((error) => {
+    getAllHandlingAuthInfoFail(error)
+  })
+}
+//获取所有已处理认证消息
+export const getAllHandledAuthInfo = (getAllHandledAuthInfoSuccess, getAllHandledAuthInfoFail) => {
+  Http.get(Apis.USER.GET_ALL_HANDLED_AUTH_INFO).then((res) => {
+    getAllHandledAuthInfoSuccess(res)
+  }).catch((error) => {
+    getAllHandledAuthInfoFail(error)
+  })
 }
 export const getCurrentIndividualAuthenInfo = (userId, getCurrentIndividualAuthenInfoSuccess, getCurrentIndividualAuthenInfoFail) => {
   Http.get(Apis.USER.GET_INDIVIDUAL_AUTHENTICATION_INFO.replace('{userId}', userId)).then((res) => {
@@ -224,7 +231,7 @@ export const updateIndividualAuthInfo = (userId, authInfo, updateIndividualAuthI
     updateIndividualAuthInfoFail(error)
   })
 }
-export const updateAgencyAuthInfo = (userId, authInfo,updateAgencyAuthInfoSuccess,updateAgencyAuthInfoFail) => {
+export const updateAgencyAuthInfo = (userId, authInfo, updateAgencyAuthInfoSuccess, updateAgencyAuthInfoFail) => {
   Http.put(Apis.USER.UPDATE_AGENCY_AUTHENTICATION_INFO.replace('{userId}', userId), authInfo).then((res) => {
     updateAgencyAuthInfoSuccess(res)
   }).catch((error) => {
@@ -242,3 +249,50 @@ export const updateEnterpriseAuthInfo = (userId, authInfo, updateEnterpriseAuthI
     updateEnterpriseAuthInfoFail(error)
   })
 }
+
+export const checkPassAuth = (type, userId, checkPassAuthSuccess, checkPassAuthFail) => {
+  if (type == 'agency') {
+    Http.put(Apis.USER.PASS_AGENCY_AUTH.replace('{userId}',userId),{}).then((res)=>{
+      checkPassAuthSuccess(res)
+    }).catch((error)=>{
+      checkPassAuthFail(error)
+    })
+  }
+  if (type == 'personal') {
+    Http.put(Apis.USER.PASS_INDIVIDUAL_AUTH.replace('{userId}',userId),{}).then((res)=>{
+      checkPassAuthSuccess(res)
+    }).catch((error)=>{
+      checkPassAuthFail(error)
+    })
+  }
+  if (type == 'enterprise') {
+    Http.put(Apis.USER.PASS_ENTERPRISE_AUTH.replace('{userId}',userId),{}).then((res)=>{
+      checkPassAuthSuccess(res)
+    }).catch((error)=>{
+      checkPassAuthFail(error)
+    })
+  }
+}
+export const checkRejectAuth = (type, userId, checkRejectAuthSuccess, checkRejectAuthFail) => {
+  if (type == 'agency') {
+    Http.put(Apis.USER.REJECT_INDIVIDUAL_AUTH.replace('{userId}',userId),{}).then((res)=>{
+      checkRejectAuthSuccess(res)
+    }).catch((error)=>{
+      checkRejectAuthFail(error)
+    })
+  }
+  if (type == 'personal') {
+    Http.put(Apis.USER.REJECT_INDIVIDUAL_AUTH.replace('{userId}',userId),{}).then((res)=>{
+      checkRejectAuthSuccess(res)
+    }).catch((error)=>{
+      checkRejectAuthFail(error)
+    })
+  }
+  if (type == 'enterprise') {
+    Http.put(Apis.USER.REJECT_ENTERPRISE_AUTH.replace('{userId}',userId),{}).then((res)=>{
+      checkRejectAuthSuccess(res)
+    }).catch((error)=>{
+      checkRejectAuthFail(error)
+    })
+  }
+}