瀏覽代碼

测评机构

sunjh 6 年之前
父節點
當前提交
859ed8c0d4

+ 56 - 49
src/components/authen/AgencyAuthentication.vue

@@ -11,19 +11,19 @@
             :show-file-list="false"
             :http-request="uploadFile"
             :before-upload="beforeFileUpload">
-            <img v-if="authentication.photoUrl" :src="authentication.photoUrl" class="avatar">
+            <img v-if="authentication.agencyPhoto" :src="authentication.agencyPhoto" class="avatar">
             <i v-else class="el-icon-plus avatar-uploader-icon"></i>
           </el-upload>
           <span v-if="!isModifyMode">
           <el-image
             style="width: 100px;"
-            :src="authentication.photoUrl"
+            :src="authentication.agencyPhoto"
             fit="scale-down"></el-image>
         </span>
         </el-form-item>
         <el-form-item label="机构名称" prop="name">
-          <el-input v-if="isModifyMode" v-model="authentication.name"></el-input>
-          <span v-if="!isModifyMode">{{authentication.name}}</span>
+          <el-input v-if="isModifyMode" v-model="authentication.evaluationAgencyName"></el-input>
+          <span v-if="!isModifyMode">{{authentication.evaluationAgencyName}}</span>
         </el-form-item>
         <!--<el-form-item label="机构电话" prop="name">-->
         <!--<el-input v-if="isModifyMode" v-model="authentication.mobile"></el-input>-->
@@ -38,15 +38,17 @@
           <span v-if="!isModifyMode">{{authentication.address}}</span>
         </el-form-item>
         <el-form-item label="测评机构能力" prop="name">
-          <el-checkbox-group v-if="isModifyMode" v-model="authentication.ability">
+          <el-checkbox-group v-if="isModifyMode" v-model="authentication.evaluationAgencyAbilityList">
             <span v-for="(item,index) in serviceTypes" :key="index">
               <el-checkbox :label="item" name="type">{{item}}&nbsp;&nbsp;&nbsp;&nbsp;</el-checkbox>
             </span>
           </el-checkbox-group>
-          <span v-if="!isModifyMode" v-for="(item,index) in authentication.ability" :key="index"><span class="badge">{{item}}</span></span>
+          <span v-if="!isModifyMode" v-for="(item,index) in authentication.evaluationAgencyAbilityList"
+                :key="index"><span class="badge">{{item}}</span></span>
         </el-form-item>
         <el-form-item label="测评机构资源" prop="name">
-          <span v-if="isModifyMode" v-for="item in authentication.resource" :key="item.id" style="width: 2000px">
+          <span v-if="isModifyMode" v-for="item in authentication.evaluationAgencyResourceList" :key="item.id"
+                style="width: 2000px">
             资源类型:&nbsp;<el-select v-model="item.type" placeholder="请选择" style="width: 15%;margin-bottom: 10px"
                                   :value="item.type">
               <el-option
@@ -66,7 +68,7 @@
           <el-button v-if="isModifyMode" type="primary" icon="el-icon-circle-plus" plain size="small"
                      @click="addAgencyResource">添加资源
           </el-button>
-          <span v-if="!isModifyMode" v-for="item in authentication.resource" :key="item.id">
+          <span v-if="!isModifyMode" v-for="item in authentication.evaluationAgencyResourceList" :key="item.id">
             资源类型:{{item.type}};&nbsp;&nbsp;资源名称:{{item.name}};&nbsp;&nbsp;资源总量:{{item.totalNum}};&nbsp;&nbsp;可用资源:{{item.availableNum}}<br/>
           </span>
         </el-form-item>
@@ -91,6 +93,7 @@ import {
   defaultValue,
   getAllAgencyResourceTypes,
   getAllServiceTypes,
+  getCurrentAgencyAuthInfo,
   getCurrentAuthenInfo,
   storageGet,
   updateAgencyAuthInfo
@@ -108,13 +111,13 @@ export default {
       serviceTypes: [],
       authentication: {
         mobile: '',
-        name: '',
+        evaluationAgencyName: '',
         bankAccount: '',
         address: '',
-        ability: [],
-        resource: [],
+        evaluationAgencyAbilityList: [],
+        evaluationAgencyResourceList: [],
         photo: [],
-        photoUrl: defaultValue.image,
+        agencyPhoto: defaultValue.image,
       },
       rules: {
         // name: [
@@ -153,20 +156,22 @@ export default {
     //加载数据
     getAuthInfo () {
       this.showLoading()
-      getCurrentAuthenInfo().then((res) => {
-        this.authentication.photo = []
-        this.authentication.photoUrl = res.agencyPhoto == null ? defaultValue.image : res.agencyPhoto
-        this.authentication.name = res.evaluationAgencyName == null ? '暂未填写' : res.evaluationAgencyName
-        this.authentication.ability = res.evaluationAgencyAbilityList == null ? [] : res.evaluationAgencyAbilityList
-        this.authentication.resource = res.evaluationAgencyResourceList == null ? [] : res.evaluationAgencyResourceList
-        this.authentication.bankAccount = res.bankAccount == null ? '暂未填写' : res.bankAccount
-        this.authentication.address = res.address == null ? '暂未填写' : res.address
-        this.hideLoading()
-        console.log(this.authentication)
-      }).catch((error) => {
-        this.hideLoading()
-        notify('error', '加载认证信息失败:' + error.data)
-      })
+      getCurrentAgencyAuthInfo(this.user.userVO.id, this.getAuthInfoSuccess, this.getAuthInfoFail)
+    },
+    getAuthInfoSuccess (res) {
+      this.hideLoading()
+      this.authentication.agencyPhoto = res.agencyPhoto == null ? defaultValue.image : res.agencyPhoto
+      this.authentication.evaluationAgencyName = res.evaluationAgencyName == null ? '暂未填写' : res.evaluationAgencyName
+      this.authentication.evaluationAgencyAbilityList = res.evaluationAgencyAbilityList == null ? [] : res.evaluationAgencyAbilityList
+      this.authentication.evaluationAgencyResourceList = res.evaluationAgencyResourceList == null ? [] : res.evaluationAgencyResourceList
+      this.authentication.bankAccount = res.bankAccount == null ? '暂未填写' : res.bankAccount
+      this.authentication.address = res.address == null ? '暂未填写' : res.address
+
+      console.log(this.authentication)
+    },
+    getAuthInfoFail (error) {
+      this.hideLoading()
+      notify('error', '加载认证信息失败:' + error.data)
     },
     //表单进入可编辑状态,可修改表单,不再使用
     modifyInfo () {
@@ -177,24 +182,26 @@ export default {
       //this.isModifyMode = false
       this.showLoading()
       const newAuthentication = {
-        mobile: this.authentication.mobile,
-        evaluationAgencyName: this.authentication.name,
+        userId: this.user.userVO.id,
+        evaluationAgencyName: this.authentication.evaluationAgencyName,
         bankAccount: this.authentication.bankAccount,
         address: this.authentication.address,
-        evaluationAgencyAbilityList: this.authentication.ability,
-        evaluationAgencyResourceList: this.authentication.resource,
-        agencyPhoto: this.authentication.photoUrl,
+        evaluationAgencyAbilityList: this.authentication.evaluationAgencyAbilityList,
+        evaluationAgencyResourceList: this.authentication.evaluationAgencyResourceList,
+        agencyPhoto: this.authentication.agencyPhoto,
       }
       //console.log(newAuthentication)
-      updateAgencyAuthInfo(this.user.userVO.id, newAuthentication).then((res) => {
-        console.log(res)
-        this.hideLoading()
-        this.cancelModify()
-        notify('success', '认证信息修改成功')
-      }).catch(error => {
-        this.hideLoading()
-        notify('error', error.data)
-      })
+      updateAgencyAuthInfo(this.user.userVO.id, newAuthentication, this.updateAuthInfoSuccess, this.updateAuthInfoFail)
+    },
+    updateAuthInfoSuccess (res) {
+      console.log(res)
+      this.hideLoading()
+      this.cancelModify()
+      notify('success', '认证信息修改成功')
+    },
+    updateAuthInfoFail (error) {
+      this.hideLoading()
+      notify('error', error.data)
     },
     //取消修改表单,表单进入不可编辑状态,不再使用
     cancelModify () {
@@ -229,7 +236,7 @@ export default {
       formData.append('file', param.file)
       Http.upload(Apis.FILE.UPLOAD_IMAGE.replace('{userId}', this.user.userVO.id), formData, config).then((res) => {
         console.log('上传成功')
-        this.authentication.photoUrl = res.data
+        this.authentication.agencyPhoto = res.data
         console.log(res.data)
         notify('success', '上传成功')
       }).catch(error => {
@@ -251,28 +258,28 @@ export default {
     //添加一项测评机构资源
     addAgencyResource () {
       const tmpResource = {
-        id: this.authentication.resource.length,
+        id: this.authentication.evaluationAgencyResourceList.length,
         type: this.resourceTypes[0],
         name: '',
         totalNum: 0,
         availableNum: 0,
       }
-      this.authentication.resource.push(tmpResource)
+      this.authentication.evaluationAgencyResourceList.push(tmpResource)
     },
     //删除一项测评机构资源
     removeAgencyResource (id) {
-      this.authentication.resource.splice(id, 1)
-      for (var i = 0; i < this.authentication.resource.length; i++) {
-        this.authentication.resource[i].id = i
+      this.authentication.evaluationAgencyResourceList.splice(id, 1)
+      for (var i = 0; i < this.authentication.evaluationAgencyResourceList.length; i++) {
+        this.authentication.evaluationAgencyResourceList[i].id = i
       }
     },
     //检测测评机构资源填写是否有效
     checkAgencyResourceVaild () {
-      if (this.authentication.resource.length === 0) {
+      if (this.authentication.evaluationAgencyResourceList.length === 0) {
         return true
       }
-      for (var i = 0; i < this.authentication.resource.length; i++) {
-        const item = this.authentication.resource[i]
+      for (var i = 0; i < this.authentication.evaluationAgencyResourceList.length; i++) {
+        const item = this.authentication.evaluationAgencyResourceList[i]
         if (item.type === '') {
           notify('error', '资源类型不能为空')
           return false

+ 45 - 38
src/components/authen/AgencyAuthenticationCreate.vue

@@ -10,7 +10,7 @@
             :show-file-list="false"
             :http-request="uploadFile"
             :before-upload="beforeFileUpload">
-            <img v-if="authentication.photoUrl" :src="authentication.photoUrl" class="avatar">
+            <img v-if="authentication.agencyPhoto" :src="authentication.agencyPhoto" class="avatar">
             <i v-else class="el-icon-plus avatar-uploader-icon"></i>
           </el-upload>
           <!--<div v-if="!isModifyMode">-->
@@ -20,7 +20,7 @@
           <!--</div>-->
         </el-form-item>
         <el-form-item label="机构名称" prop="name">
-          <el-input v-if="isModifyMode" v-model="authentication.name"></el-input>
+          <el-input size="small" v-if="isModifyMode" v-model="authentication.evaluationAgencyName"></el-input>
           <!--<span v-if="!isModifyMode">{{authentication.name}}</span>-->
         </el-form-item>
         <!--<el-form-item label="机构电话" prop="name">-->
@@ -28,15 +28,15 @@
         <!--&lt;!&ndash;<span v-if="!isModifyMode">{{authentication.name}}</span>&ndash;&gt;-->
         <!--</el-form-item>-->
         <el-form-item label="对公账户" prop="name">
-          <el-input v-if="isModifyMode" v-model="authentication.bankAccount"></el-input>
+          <el-input size="small" v-if="isModifyMode" v-model="authentication.bankAccount"></el-input>
           <!--<span v-if="!isModifyMode">{{authentication.bankAccount}}</span>-->
         </el-form-item>
         <el-form-item label="地址" prop="name">
-          <el-input v-if="isModifyMode" v-model="authentication.address"></el-input>
+          <el-input size="small" v-if="isModifyMode" v-model="authentication.address"></el-input>
           <!--<span v-if="!isModifyMode">{{authentication.address}}</span>-->
         </el-form-item>
         <el-form-item label="测评机构能力" prop="name">
-          <el-checkbox-group v-if="isModifyMode" v-model="authentication.ability">
+          <el-checkbox-group v-if="isModifyMode" v-model="authentication.evaluationAgencyAbilityList">
             <span v-for="(item,index) in serviceTypes" :key="index">
               <el-checkbox :label="item" name="type">{{item}}&nbsp;&nbsp;&nbsp;&nbsp;</el-checkbox>
             </span>
@@ -44,8 +44,9 @@
           <!--<span v-if="!isModifyMode">{{authentication.ability}}</span>-->
         </el-form-item>
         <el-form-item label="测评机构资源" prop="name">
-          <span v-for="item in authentication.resource" :key="item.id">
-            资源类型:&nbsp;<el-select v-model="item.type" placeholder="请选择" style="width: 150px;margin-bottom: 10px"
+          <span v-for="item in authentication.evaluationAgencyResourceList" :key="item.id">
+            资源类型:&nbsp;<el-select size="small" v-model="item.type" placeholder="请选择"
+                                  style="width: 150px;margin-bottom: 10px"
                                   :value="item.type">
               <el-option
                 v-for="item in resourceTypes"
@@ -54,10 +55,12 @@
                 :value="item">
               </el-option>
             </el-select>
-            资源名称:&nbsp;<el-input v-model="item.name" style="width: 150px"></el-input>
-            总量:&nbsp;<el-input-number :min="0" v-model="item.totalNum"></el-input-number>
-            可用数量:&nbsp;<el-input-number :min="0" :max="item.totalNum" v-model="item.availableNum"></el-input-number>
-            <el-button type="danger" icon="el-icon-delete" @click="removeAgencyResource(item.id)"></el-button>
+            资源名称:&nbsp;<el-input size="small" v-model="item.name" style="width: 150px"></el-input>
+            总量:&nbsp;<el-input-number size="small" :min="0" v-model="item.totalNum"></el-input-number>
+            可用数量:&nbsp;<el-input-number size="small" :min="0" :max="item.totalNum"
+                                        v-model="item.availableNum"></el-input-number>
+            <el-button size="small" type="danger" icon="el-icon-delete"
+                       @click="removeAgencyResource(item.id)"></el-button>
             <br/>
           </span>
           <el-button type="primary" icon="el-icon-circle-plus" plain size="small" @click="addAgencyResource">添加资源
@@ -70,7 +73,8 @@
         <!--<div class="btn btn-medium" @click="cancelModify()">返回</div>-->
         <!--</el-form-item>-->
         <el-form-item v-if="isModifyMode">
-          <div class="btn btn-primary btn-info" @click="submitInfo()">提交</div>
+          <el-button type="primary" size="small" @click="submitInfo()">提交</el-button>
+          <!--<div  class="btn btn-primary btn-info" @click="submitInfo()">提交</div>-->
           <!--<div class="btn btn-primary" @click="cancelModify()">取消</div>-->
         </el-form-item>
       </el-form>
@@ -82,7 +86,7 @@
 import Http from '@/js/http'
 import Apis from '@/js/api'
 import {notify} from '@/constants/index'
-import {getAllAgencyResourceTypes, getAllServiceTypes, storageGet} from '@/js/index'
+import {getAllAgencyResourceTypes, getAllServiceTypes, storageGet, uploadAgencyAuthenticationInfo} from '@/js/index'
 
 export default {
   name: 'AgencyAuthenticationCreate',
@@ -96,13 +100,13 @@ export default {
       serviceTypes: [],
       authentication: {
         mobile: '',
-        name: '',
+        evaluationAgencyName: '',
         bankAccount: '',
         address: '',
-        ability: [],
-        resource: [],
+        evaluationAgencyAbilityList: [],
+        evaluationAgencyResourceList: [],
         photo: [],
-        photoUrl: '',
+        agencyPhoto: '',
       },
       rules: {
         // name: [
@@ -149,22 +153,25 @@ export default {
       //this.isModifyMode = false
       this.showLoading()
       const newAuthentication = {
-        mobile: this.authentication.mobile,
-        evaluationAgencyName: this.authentication.name,
+        userId: this.user.userVO.id,
+        evaluationAgencyName: this.authentication.evaluationAgencyName,
         bankAccount: this.authentication.bankAccount,
         address: this.authentication.address,
-        evaluationAgencyAbilityList: this.authentication.ability,
-        evaluationAgencyResourceList: this.authentication.resource,
-        agencyPhoto: this.authentication.photoUrl,
+        evaluationAgencyAbilityList: this.authentication.evaluationAgencyAbilityList,
+        evaluationAgencyResourceList: this.authentication.evaluationAgencyResourceList,
+        agencyPhoto: this.authentication.agencyPhoto,
       }
       console.log(newAuthentication)
-      Http.post(Apis.USER.SUBMIT_AGENCY_AUTHENTICATION_INFO.replace('{userId}', this.user.userVO.id), newAuthentication).then((res) => {
-        console.log(res)
-        this.hideLoading()
-        notify('success', '认证信息上传成功')
-      }).catch(error => {
-        notify('error', error.data)
-      })
+      uploadAgencyAuthenticationInfo(this.user.userVO.id, newAuthentication, this.submitInfoSuccess, this.submitInfoFail)
+    },
+    submitInfoSuccess (res) {
+      console.log(res)
+      this.hideLoading()
+      notify('success', '认证信息上传成功')
+    },
+    submitInfoFail (error) {
+      this.hideLoading()
+      notify('error', error.data)
     },
     //取消修改表单,表单进入不可编辑状态,不再使用
     cancelModify () {
@@ -199,7 +206,7 @@ export default {
       formData.append('file', param.file)
       Http.upload(Apis.FILE.UPLOAD_IMAGE.replace('{userId}', this.user.userVO.id), formData, config).then((res) => {
         console.log('上传成功')
-        this.authentication.photoUrl = res.data
+        this.authentication.agencyPhoto = res.data
         console.log(res.data)
         notify('success', '上传成功')
       }).catch(error => {
@@ -221,28 +228,28 @@ export default {
     //添加一项测评机构资源
     addAgencyResource () {
       const tmpResource = {
-        id: this.authentication.resource.length,
+        id: this.authentication.evaluationAgencyResourceList.length,
         type: this.resourceTypes[0],
         name: '',
         totalNum: 0,
         availableNum: 0,
       }
-      this.authentication.resource.push(tmpResource)
+      this.authentication.evaluationAgencyResourceList.push(tmpResource)
     },
     //删除一项测评机构资源
     removeAgencyResource (id) {
-      this.authentication.resource.splice(id, 1)
-      for (var i = 0; i < this.authentication.resource.length; i++) {
-        this.authentication.resource[i].id = i
+      this.authentication.evaluationAgencyResourceList.splice(id, 1)
+      for (var i = 0; i < this.authentication.evaluationAgencyResourceList.length; i++) {
+        this.authentication.evaluationAgencyResourceList[i].id = i
       }
     },
     //检测测评机构资源填写是否有效
     checkAgencyResourceVaild () {
-      if (this.authentication.resource.length === 0) {
+      if (this.authentication.evaluationAgencyResourceList.length === 0) {
         return true
       }
-      for (var i = 0; i < this.authentication.resource.length; i++) {
-        const item = this.authentication.resource[i]
+      for (var i = 0; i < this.authentication.evaluationAgencyResourceList.length; i++) {
+        const item = this.authentication.evaluationAgencyResourceList[i]
         if (item.type === '') {
           notify('error', '资源类型不能为空')
           return false

+ 1 - 0
src/js/api.js

@@ -54,6 +54,7 @@ export default {
     UPDATE_AGENCY_AUTHENTICATION_INFO: '/api/user/{userId}/agency/',
     GET_INDIVIDUAL_AUTHENTICATION_INFO: '/api/user/{userId}/personalAuth',
     GET_ENTERPRISE_AUTHENTICATION_INFO: '/api/user/{userId}/enterpriseAuth',
+    GET_AGENCY_AUTHENTICATION_INFO: '/api/user/{userId}/agency',
   },
   PAGE: {
     HOME_PAGE: '/api/common/index/',

+ 4 - 2
src/js/index.js

@@ -2,7 +2,9 @@ import {
   deleteAuthInfo,
   getAllAuthentications,
   getAuthUrls,
+  getCurrentAgencyAuthInfo,
   getCurrentAuthenInfo,
+  getCurrentEnterpriseAuthInfo,
   getCurrentIndividualAuthenInfo,
   getCurrentUser,
   getRolesPermissions,
@@ -13,7 +15,6 @@ import {
   uploadAgencyAuthenticationInfo,
   uploadEnterpriseAuthenticationInfo,
   uploadIndividualAuthenticationInfo,
-  getCurrentEnterpriseAuthInfo,
 } from './userService'
 import {
   createProject,
@@ -94,7 +95,8 @@ export {
   //TODO 尚未使用 代码未实现 上传个人认证信息
   uploadIndividualAuthenticationInfo,
   getCurrentIndividualAuthenInfo,
-  getCurrentEnterpriseAuthInfo
+  getCurrentEnterpriseAuthInfo,
+  getCurrentAgencyAuthInfo
 }
 export {
   /*******************************************************************************/

+ 19 - 9
src/js/userService.js

@@ -97,8 +97,12 @@ export const uploadEnterpriseAuthenticationInfo = (userId, userAuthInfo, uploadE
 }
 
 //上传机构认证信息
-export const uploadAgencyAuthenticationInfo = () => {
-
+export const uploadAgencyAuthenticationInfo = (userId, userAuthInfo, uploadAgencyAuthenticationInfoSuccess, uploadAgencyAuthenticationInfoFail) => {
+  Http.post(Apis.USER.SUBMIT_AGENCY_AUTHENTICATION_INFO.replace('{userId}', userId), userAuthInfo).then((res) => {
+    uploadAgencyAuthenticationInfoSuccess(res)
+  }).catch(error => {
+    uploadAgencyAuthenticationInfoFail(error)
+  })
 }
 
 //获取所有认证消息
@@ -125,7 +129,13 @@ export const getCurrentEnterpriseAuthInfo = (userId, getCurrentEnterpriseAuthInf
     getCurrentEnterpriseAuthInfoFail(error)
   })
 }
-
+export const getCurrentAgencyAuthInfo = (userId, getCurrentEnterpriseAuthInfoSuccess, getCurrentEnterpriseAuthInfoFail) => {
+  Http.get(Apis.USER.GET_AGENCY_AUTHENTICATION_INFO.replace('{userId}', userId)).then((res) => {
+    getCurrentEnterpriseAuthInfoSuccess(res)
+  }).catch((error) => {
+    getCurrentEnterpriseAuthInfoFail(error)
+  })
+}
 export const getCurrentAuthenInfo = () => {
   const individualData = {
     type: '个人',//企业、机构、个人
@@ -214,12 +224,12 @@ export const updateIndividualAuthInfo = (userId, authInfo, updateIndividualAuthI
     updateIndividualAuthInfoFail(error)
   })
 }
-export const updateAgencyAuthInfo = (userId, authInfo) => {
-  // const data = {}
-  // return new Promise((resolve) => {
-  //   resolve(data)
-  // })
-  return Http.put(Apis.USER.UPDATE_AGENCY_AUTHENTICATION_INFO.replace('{userId}', userId), authInfo)
+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) => {
+    updateAgencyAuthInfoFail(error)
+  })
 }
 export const updateEnterpriseAuthInfo = (userId, authInfo, updateEnterpriseAuthInfoSuccess, updateEnterpriseAuthInfoFail) => {
   // const data = {}