Преглед изворни кода

修复绿色通道创建agency出错的bug

sunjh пре 6 година
родитељ
комит
0dbf72cb02

+ 49 - 5
src/App.vue

@@ -1,7 +1,9 @@
 <template>
   <div style="height:100%;width:100%;">
     <header-container/>
-    <div class="main-container"><router-view/></div>
+    <div class="main-container">
+      <router-view/>
+    </div>
     <footer-container/>
   </div>
 </template>
@@ -9,18 +11,60 @@
 <script>
 import HeaderContainer from '@/components/commons/Header'
 import FooterContainer from '@/components/commons/Footer'
+import {getCurrentUser, storageGet, storageSave} from '@/js/index'
 
 export default {
   name: 'App',
-  components:{HeaderContainer,FooterContainer},
-  name: 'App'
+  components: {HeaderContainer, FooterContainer},
+  methods: {
+    setUserInfo () {
+      // storageGet('user').then((res)=>{
+      //   if (res == null){
+      //     this.setCurrUserByHttp()
+      //   }else{
+      //     this.fullScreenLoading = false
+      //     this.isLogin = true
+      //   }
+      // }).catch((error)=>{
+      //   this.setCurrUserByHttp()
+      // })
+
+
+      // if (storageGet('user') == null) {
+      //   storageSave('rolesPermissions', {
+      //     'isRegionManager': false,
+      //     'isIndividualUser': false,
+      //     'isEnterpriseUser': false,
+      //     'isAgency': false,
+      //     'isSystemAdministrator': false
+      //   })
+      //   console.log('本地没有用户信息,开始加载用户信息')
+      //   getCurrentUser().then((res) => {
+      //     console.log(res)
+      //     storageSave('user', res)
+      //     storageSave('rolesPermissions', getRolesPermissions(res.roleList))
+      //     console.log('用户信息加载成功')
+      //   }).catch(error => {
+      //     console.log('用户信息加载失败')
+      //     if (error.status == 401) {
+      //       notify('warning', error.data)
+      //     } else {
+      //       notify('error', error.data)
+      //     }
+      //   })
+      // } else {
+      //   this.fullScreenLoading = false
+      //   this.isLogin = true
+      // }
+    },
+  }
 }
 </script>
 
 <style>
-.main-container{
+  .main-container {
     width: 100%;
     min-height: calc(100% - 70px - 64px);
     margin: 0 auto;
-}
+  }
 </style>

+ 11 - 5
src/components/Home.vue

@@ -75,17 +75,23 @@ export default {
   },
   methods: {
     init () {
+      // storageGet('user').then((res)=>{
+      //   if (res == null){
+      //     //notify('warning','请登录后访问')
+      //   }else{
+      //     this.user = res
+      //     this.setRolesPermissions()
+      //     this.loadData()
+      //   }
+      // }).catch((error)=>{
+      //   notify('error','用户信息获取失败')
+      // })
       this.setUserInfo()
       if(this.rolesPermissions == null){
         let NewPage = '_empty' + '?time=' + new Date().getTime()/500;
         this.$router.push(NewPage);
         this.$router.go(-1);
       }
-      //this.setRolesPermissions()
-      // if (this.user != null) {
-      // if (this.user != null) {
-      //   this.setRolesPermissions()
-      // }
       this.loadData()
     },
     //加载数据

+ 22 - 7
src/components/Mine.vue

@@ -19,7 +19,7 @@
             </p>
             <div class="username_box">
               <div class="username_icon username_"></div>
-              <span class="username">{{user.userVO.name}}</span>
+              <span class="username">{{user == null?'...':user.userVO.name}}</span>
             </div>
             <!--<p class="name">-->
             <!--<a href="javascript:;" class="login-btn btn btn-medium btn-info">登录</a>-->
@@ -95,14 +95,23 @@ import {getRolesPermissions, storageGet} from '@/js/index'
 export default {
   name: 'Mine',
   components: {TaskItem, ProjectItem},
+  watch: {
+    user (val) {
+      this.user = val
+    },
+    rolesPermissions (val) {
+      this.rolesPermissions = val
+    },
+    deep:true
+  },
   data () {
     return {
       unFinishedTaskList: [],
       finishedTaskList: [],
       appliedProjectList: [],
-      myProjects:[],
-      handlingProjects:[],
-      acceptableProjects:[],
+      myProjects: [],
+      handlingProjects: [],
+      acceptableProjects: [],
       rolesPermissions: {
         isRegionManager: false,
         isIndividualUser: false,
@@ -130,6 +139,12 @@ export default {
       this.setUserInfo()
       this.setRolesPermissions()
       this.loadData()
+      // storageGet('user').then((res)=>{
+      //   this.user = res;
+      //   this.setRolesPermissions()
+      //   this.loadData()
+      // })
+
     },
     loadData () {
       Http.get(Apis.PAGE.MY_CROWD_TEST_PAGE.replace('{userId}', this.user.userVO.id)).then((res) => {
@@ -148,9 +163,9 @@ export default {
         if (res.acceptableProjects != null && res.acceptableProjects.length > 0) {
           this.acceptableProjects = res.acceptableProjects
         }
-        if (res.userVO != null && res.userVO.length > 0) {
-          this.user = res.userVO
-        }
+        // if (res.userVO != null && res.userVO.length > 0) {
+        //   this.user = res.userVO
+        // }
       })
     },
     setUserInfo () {

+ 3 - 3
src/components/authen/AuthenticationIndex.vue

@@ -2,8 +2,8 @@
   <div class="create-container">
     <div class="create-body">
       <div class="title">选择认证类型</div>
-      <el-row style="margin-top: 100px;margin-bottom: 100px">
-        <el-col :span="6" style="margin-right: 100px;margin-left: 80px">
+      <el-row type="flex" justify="center" align="middle" style="margin-top: 100px;margin-bottom: 100px;" :gutter="50">
+        <el-col :span="6">
           <el-card :body-style="{ padding: '0px' }" style="cursor: pointer;">
             <i class="el-icon-user-solid image" style="color:#909399" @click="toIndividualAuthentication"></i>
             <div style="text-align: center;font-size: 12px"><span>认证为个人用户,可以创建项目</span></div>
@@ -12,7 +12,7 @@
             </div>
           </el-card>
         </el-col>
-        <el-col :span="6" style="margin-right: 100px">
+        <el-col :span="6">
           <el-card :body-style="{ padding: '0px' }" style="cursor: pointer;">
             <i class="el-icon-s-cooperation image" style="color:#909399" @click="toEnterpriseAuthentication"></i>
             <div style="text-align: center;font-size: 12px"><span>认证为企业用户,可以创建项目</span></div>

+ 1 - 1
src/components/cheat/AgencyAdd.vue

@@ -300,7 +300,7 @@ export default {
         this.hideLoading()
         console.log(res)
         // console.log(res.data)
-        res = res.data
+        //res = res.data
         this.agency.password = res.userVO.password
         this.agency.username = res.userVO.userName
         this.agency.mobile = res.userVO.mobile

+ 36 - 3
src/components/commons/Header.vue

@@ -1,5 +1,5 @@
 <template>
-  <nav class="navbar">
+  <nav class="navbar" v-loading.fullscreen.lock="fullScreenLoading">
     <div class="container">
       <div class="navbar-translate">
         <a class="navbar-brand">众测</a>
@@ -75,7 +75,8 @@ export default {
   name: 'header-container',
   data () {
     return {
-      loading: true,
+      fullScreenLoading: false,
+      //loading: true,
       openNavBar: false,
       userIdentity: '',
       isLogin: false,
@@ -91,7 +92,34 @@ export default {
     openNavBarFunc () {
       this.openNavBar = !this.openNavBar
     },
+    setCurrUserByHttp () {
+      // getCurrentUser().then((res) => {
+      //   console.log(res)
+      //   storageSave('user', res)
+      //   storageSave('rolesPermissions', getRolesPermissions(res.roleList))
+      //   this.isLogin = true
+      //   this.fullScreenLoading = false
+      // }).catch(error => {
+      //   this.fullScreenLoading = false
+      //   console.log(error)
+      //   if (error.status == 401) {
+      //     notify('warning', error.data)
+      //   } else {
+      //     notify('error', error.data)
+      //   }
+      // })
+    },
     setUserInfo () {
+      // storageGet('user').then((res)=>{
+      //   if (res == null){
+      //     this.setCurrUserByHttp()
+      //   }else{
+      //     this.fullScreenLoading = false
+      //     this.isLogin = true
+      //   }
+      // }).catch((error)=>{
+      //   this.setCurrUserByHttp()
+      // })
       if (storageGet('user') == null) {
         storageSave('rolesPermissions', {
           'isRegionManager': false,
@@ -100,13 +128,17 @@ export default {
           'isAgency': false,
           'isSystemAdministrator': false
         })
+        console.log('本地没有用户信息,开始加载用户信息')
         getCurrentUser().then((res) => {
           console.log(res)
           storageSave('user', res)
           storageSave('rolesPermissions', getRolesPermissions(res.roleList))
+          console.log('用户信息加载成功')
           this.isLogin = true
+          this.fullScreenLoading = false
         }).catch(error => {
-          console.log(error)
+          console.log('用户信息加载失败')
+          this.fullScreenLoading = false
           if (error.status == 401) {
             notify('warning', error.data)
           } else {
@@ -114,6 +146,7 @@ export default {
           }
         })
       } else {
+        this.fullScreenLoading = false
         this.isLogin = true
       }
     },

+ 27 - 10
src/components/project/Project.vue

@@ -1,5 +1,5 @@
 <template>
-  <div class="create-container">
+  <div class="create-container" v-loading="loading">
     <div class="title h1" v-if="!isModifyMode">项目</div>
     <div class="create-body">
       <div class="title h2" v-if="!isModifyMode">基本信息</div>
@@ -95,7 +95,7 @@
         <el-form-item label="项目可见性" prop="resource">
           <div v-if="!isModifyMode">
             <div v-if="project.resource=='1'">{{updateLocation(project.location)}}</div>
-            <div v-if="project.resource=='0'">{{project.institution}}</div>
+            <div v-if="project.resource=='0'">{{project.institution==null?'暂未被接收':project.institution}}</div>
             <div v-if="project.resource=='2'">{{resourceType[project.resource]}}</div>
           </div>
           <el-tabs :tab-position="tabPosition" v-model="project.resource" style="max-height: 200px;"
@@ -111,8 +111,8 @@
               <provincecity
                 ref="addFormProvince"
                 @selectChange="locationChange"
-                :provinceCode="project.location.provinceCode"
-                :cityCode="project.location.cityCode"
+                :provinceCode="project.location==null?'3200':project.location.provinceCode"
+                :cityCode="project.location==null?'3201':project.location.cityCode"
               ></provincecity>
             </el-tab-pane>
             <el-tab-pane :label="resourceType[2]" name="2"></el-tab-pane>
@@ -183,6 +183,7 @@
           <div class="btn btn-medium" @click="cancelMode('project')">取消</div>
         </el-form-item>
         <el-form-item v-if="!isModifyMode">
+          <div class="btn btn-medium btn-info" @click="submitProjectRequest()">发布项目</div>
           <div class="btn btn-medium btn-info" @click="submitProjectRequest()">提交项目</div>
           <div class="btn btn-medium btn-info" @click="applyProject()">接受项目</div>
           <div class="btn btn-medium btn-info" @click="modifyForm()">修改</div>
@@ -232,7 +233,7 @@
 
     <div class="create-body" v-if="!isModifyMode">
       <div class="title h2">报告列表</div>
-      <report-list v-bind:reports="project.reportList" v-bind:taskId=null v-bind:projectId="projectId"/>
+      <report-list v-bind:reports="reportList" v-bind:taskId=null v-bind:projectId="projectId"/>
     </div>
   </div>
 </template>
@@ -273,6 +274,7 @@ export default {
     return {
       projectId: 0,
       user: {},
+      loading: false,
       tabPosition: 'top',
       institutionArray: [],
       isModifyMode: false,
@@ -300,7 +302,7 @@ export default {
         usage: '',
       },
       task: [],
-      analyseDemandList: [],
+      reportList: [],
       pickerOptions: {
         shortcuts: [
           {
@@ -424,6 +426,7 @@ export default {
     },
     //提交修改
     submitForm (formName) {
+      this.showLoading()
       const newProject = {
         userId: this.user.userVO.id,
         name: this.project.name,
@@ -432,7 +435,7 @@ export default {
         desc: this.project.desc,
         resource: this.project.resource,
         location: getProvinceNameByProvinceCode(this.project.location.provinceCode, this.project.location.cityCode),
-        institution: this.project.institution.id,
+        institution: this.project.institution == null ? null : this.project.institution.id,
         contactName: this.project.contactName,
         contactPhone: this.project.contactPhone,
         doc: this.project.requireDocUrl,
@@ -442,8 +445,11 @@ export default {
         datetime: this.project.datetime,
         usage: this.project.usage,
       }
+      console.log('aa')
       console.log(newProject)
       Http.put(Apis.PROJECT.UPDATE_PROJECT.replace('{projectId}', this.projectId), newProject).then((res) => {
+        console.log('bb')
+        console.log(res)
         this.projectId = res.projectDetails.id
         this.project.name = res.projectDetails.name
         this.project.contactName = res.projectDetails.contactName
@@ -464,8 +470,9 @@ export default {
         this.project.requireDocUrl = res.projectDetails.doc
 
         this.task = res.taskList
-        this.analyseDemandList = res.reportList
+        this.reportList = res.reportList
         this.isModifyMode = false
+        this.hideLoading()
         notify('success', '项目修改成功')
       }).catch(error => {
         notify('error', error.data)
@@ -503,7 +510,7 @@ export default {
     modifyForm () {
       this.isModifyMode = true
 
-      this.setInstitutions()
+      //this.setInstitutions()
       //获得update 信息
       //this.loadData()
     },
@@ -588,6 +595,7 @@ export default {
       console.log('拒绝')
     },
     loadData () {//PROJ--2019073114009
+      this.showLoading()
       Http.get(Apis.PROJECT.GET_PROJECT.replace('{projectId}', this.projectId)).then((res) => {
         console.log(res)
         this.projectId = res.projectDetails.id
@@ -610,7 +618,10 @@ export default {
         this.project.requireDocUrl = res.projectDetails.doc
 
         this.task = res.taskList
-        this.analyseDemandList = res.reportList
+        this.reportList = res.reportList
+        this.hideLoading()
+      }).catch((error) => {
+        notify('error', error.data)
       })
     },
     locationChange (provinceId, cityId) {
@@ -676,6 +687,12 @@ export default {
     },
     setUserInfo () {
       this.user = storageGet('user')
+    },
+    showLoading () {
+      this.loading = true
+    },
+    hideLoading () {
+      this.loading = false
     }
   }
 }

+ 3 - 0
src/js/index.js

@@ -9,6 +9,9 @@ export const storageSave = (key, value) => {
 
 //取session
 export const storageGet = (key) => {
+  // return new Promise((resolve) => {
+  //   resolve(JSON.parse(sessionStorage.getItem(key)))
+  // })
   return JSON.parse(sessionStorage.getItem(key))
 }