Explorar el Código

修复机构认证无法显示能力的问题

sunjh hace 6 años
padre
commit
34005baaf3

+ 78 - 64
src/components/Square.vue

@@ -2,87 +2,88 @@
   <div class="square-container">
     <div class="title">全部任务</div>
 
-    <div class="square-list-container">
-      <task-item v-for="(item,index) in list" :key="index" :task="item" />
-      <div v-if="loading" class="loading">
-        <span></span>
-        <span></span>
-        <span></span>
-        <span></span>
-        <span></span>
-        <span></span>
-        <span></span>
-      </div>
-      <div v-if="nomore" class="nomore">没有更多</div>
+    <div class="square-list-container" v-loading="loading">
+      <task-item v-if="list!=null&&list.length>0" v-for="(item,index) in list" :key="index" :task="item"/>
+      <!--<div v-if="loading" class="loading">-->
+      <!--<span></span>-->
+      <!--<span></span>-->
+      <!--<span></span>-->
+      <!--<span></span>-->
+      <!--<span></span>-->
+      <!--<span></span>-->
+      <!--<span></span>-->
+      <!--</div>-->
+      <div v-if="list==null || list.length === 0" class="nomore">暂无任务</div>
     </div>
   </div>
 </template>
 
 <script>
-import TaskItem from "@/components/commons/TaskItem";
-import Http from '@/js/http.js';
-import Apis from '@/js/api.js';
+import TaskItem from '@/components/commons/TaskItem'
+import Http from '@/js/http.js'
+import Apis from '@/js/api.js'
 import {notify} from '@/constants/index'
+
 export default {
-  name: "Square",
-  components: { TaskItem },
-  data() {
+  name: 'Square',
+  components: {TaskItem},
+  data () {
     return {
       loading: true,
-      nomore:false,
+      nomore: false,
       list: [],
-    };
+    }
   },
-  mounted() {
-    window.addEventListener("scroll", this.throttle(this.setpage, 1000), false);
+  mounted () {
+    window.addEventListener('scroll', this.throttle(this.setpage, 1000), false)
   },
-  created() {
+  created () {
     this.loadData()
   },
   methods: {
-    throttle(func, wait, options) {
-      let context, args, result;
-      let timeout = null;
-      let previous = 0;
-      if (!options) options = {};
-      let later = function() {
-        previous = options.leading === false ? 0 : Number(new Date());
-        timeout = null;
-        result = func.apply(context, args);
-        if (!timeout) context = args = null;
-      };
+    throttle (func, wait, options) {
+      let context, args, result
+      let timeout = null
+      let previous = 0
+      if (!options) options = {}
+      let later = function () {
+        previous = options.leading === false ? 0 : Number(new Date())
+        timeout = null
+        result = func.apply(context, args)
+        if (!timeout) context = args = null
+      }
       return (..._args) => {
-        let now = Number(new Date());
-        if (!previous && options.leading === false) previous = now;
-        let remaining = wait - (now - previous);
-        context = this;
-        args = _args;
+        let now = Number(new Date())
+        if (!previous && options.leading === false) previous = now
+        let remaining = wait - (now - previous)
+        context = this
+        args = _args
         if (remaining <= 0 || remaining > wait) {
-          clearTimeout(timeout);
-          timeout = null;
-          previous = now;
-          result = func.apply(context, args);
-          if (!timeout) context = args = null;
+          clearTimeout(timeout)
+          timeout = null
+          previous = now
+          result = func.apply(context, args)
+          if (!timeout) context = args = null
         } else if (!timeout && options.trailing !== false) {
-          timeout = setTimeout(later, remaining);
+          timeout = setTimeout(later, remaining)
         }
-        return result;
-      };
+        return result
+      }
     },
-    setpage() {
-      if (this.nomore && !this.loading) return; //到达底部不再执行
+    setpage () {
+      if (this.nomore && !this.loading) return //到达底部不再执行
       var scrollTop =
-        document.documentElement.scrollTop || document.body.scrollTop;
+        document.documentElement.scrollTop || document.body.scrollTop
       //变量windowHeight是可视区的高度
       var windowHeight =
-        document.documentElement.clientHeight || document.body.clientHeight;
+        document.documentElement.clientHeight || document.body.clientHeight
       //变量scrollHeight是滚动条的总高度
       var scrollHeight =
-        document.documentElement.scrollHeight || document.body.scrollHeight;
-    //   console.log(scrollTop, windowHeight, scrollHeight);
+        document.documentElement.scrollHeight || document.body.scrollHeight
+      //   console.log(scrollTop, windowHeight, scrollHeight);
       //滚动条到底部的条件
       if (scrollTop + windowHeight + 5 >= scrollHeight) {
-        console.log("加载更多数据");
+        console.log('加载更多数据')
         // this.loading=true;
         //获取数据请求 请求结束后
         //成功设置 this.list =[...this.list,...this.list1];  this.loading=false;
@@ -91,27 +92,40 @@ export default {
         // console.log(this.list);},5000)
 
       }
-      else{this.loading=false;}
-      window.clearTimeout();
+      else {
+        this.loading = false
+      }
+      window.clearTimeout()
     },
-    loadData() {
-      console.log("loadData")
+    loadData () {
+      console.log('loadData')
+      this.showLoading()
       Http.get(Apis.PAGE.SQUARE_PAGE).then((res) => {
         this.list = res.crowdTaskVOList
+        this.hideLoading()
+      }).catch((error) => {
+        notify('error', '任务加载失败' + error.data)
       })
+    },
+    showLoading () {
+      this.loading = true
+    },
+    hideLoading () {
+      this.loading = false
     }
   }
-};
+}
 </script>
 
 <style lang="less" scoped>
-.square-container {
-  padding: 40px 80px;
-}
-.nomore{
+  .square-container {
+    padding: 40px 80px;
+  }
+
+  .nomore {
     text-align: center;
     font-size: 1.4rem;
     color: #8a8a8a;
     padding: 5px;
-}
+  }
 </style>

+ 5 - 1
src/components/authen/AgencyAuthentication.vue

@@ -204,7 +204,11 @@ export default {
     },
     //设置服务类型
     setServiceTypes () {
-      this.serviceTypes = getAllServiceTypes()
+      getAllServiceTypes().then((res) => {
+        this.serviceTypes = res
+      }).catch((error) => {
+        notify('error', '机构能力加载失败')
+      })
     },
     //设置机构资源类型
     setResourceTypes () {

+ 29 - 18
src/components/report/Report.vue

@@ -1,6 +1,6 @@
 <template>
   <div class="create-container">
-    <div class="create-body">
+    <div class="create-body" v-loading="loading">
       <el-form :model="report" :rules="rules" ref="report" label-width="12%" class="demo-report">
         <el-form-item label="报告名称" prop="name">
           <el-input v-if="isModifyMode" v-model="report.name"></el-input>
@@ -95,6 +95,7 @@ export default {
   data () {
     return {
       user: {},
+      loading: false,
       reportId: 0,
       projectId: '',
       taskId: '',
@@ -163,17 +164,17 @@ export default {
       if (this.taskId == null) {
         Http.put(Apis.REPORT.UPDATE_PROJECT_REPORT.replace('{projectId}', this.projectId).replace('{reportId}', this.reportId), newReport).then((res) => {
           console.log(res)
-          notify('success','修改成功')
+          notify('success', '修改成功')
           this.isModifyMode = false
-        }).catch((error)=>{
-          notify('error',error.data)
+        }).catch((error) => {
+          notify('error', error.data)
         })
       } else {
         Http.put(Apis.REPORT.UPDATE_TASK_REPORT.replace('{projectId}', this.projectId).replace('{taskId}', this.taskId).replace('{reportId}', this.reportId), newReport).then((res) => {
           console.log(res)
           this.isModifyMode = false
-        }).catch((error)=>{
-          notify('error',error.data)
+        }).catch((error) => {
+          notify('error', error.data)
         })
       }
       // this.$refs[formName].validate(valid => {
@@ -239,14 +240,10 @@ export default {
       //pro1564487183259
       //pro1564487183259_task1564487274060
       //pro1564487183259pro1564487183259_task1564487274060_rep1564488510500
-      console.log('***')
-      console.log(this.projectId)
-      console.log(this.taskId)
-      console.log(this.reportId)
-      console.log('***')
+      this.showLoading()
       if (this.taskId == null) {
         Http.get(Apis.REPORT.GET_PROJECT_REPORT.replace('{projectId}', this.projectId).replace('{reportId}', this.reportId)).then((res) => {
-          console.log(res)
+
           this.report.name = res.crowdReportVO.name
           this.report.crowdTestTaskId = res.crowdReportVO.crowdTestTaskId
           this.report.scope = res.crowdReportVO.scope
@@ -256,6 +253,10 @@ export default {
           this.report.fileUrl = res.crowdReportVO.file
           this.report.conclusion = res.crowdReportVO.conclusion
           this.report.target = res.crowdReportVO.target
+          this.hideLoading()
+          notify('success', '修改成功')
+        }).catch((error) => {
+          notify('error', '修改失败:' + error.data)
         })
       } else {
         Http.get(Apis.REPORT.GET_TASK_REPORT.replace('{projectId}', this.projectId).replace('{taskId}', this.taskId).replace('{reportId}', this.reportId)).then((res) => {
@@ -269,6 +270,10 @@ export default {
           this.report.fileUrl = res.crowdReportVO.file
           this.report.conclusion = res.crowdReportVO.conclusion
           this.report.target = res.crowdReportVO.target
+          this.hideLoading()
+          notify('success', '修改成功')
+        }).catch((error) => {
+          notify('error', '修改失败:' + error.data)
         })
       }
     },
@@ -286,22 +291,28 @@ export default {
       })
     },
     setReportType () {
-      getAllReportTypes().then((res)=>{
+      getAllReportTypes().then((res) => {
         this.reportType = res
-      }).catch((error)=>{
-        notify('error','加载报告类型失败')
+      }).catch((error) => {
+        notify('error', '加载报告类型失败')
       })
     },
     setUserInfo () {
       this.user = storageGet('user')
     },
-    updateReportSuccess(){
+    updateReportSuccess () {
 
+    },
+    showLoading () {
+      this.loading = true
+    },
+    hideLoading () {
+      this.loading = false
     }
   },
-  watch:{
+  watch: {
     reportType (val) {
-      this.reportType =val
+      this.reportType = val
     }
   }
 }

+ 1 - 1
src/components/report/ReportList.vue

@@ -43,7 +43,7 @@ export default {
   data () {
     return {
       editIndex: -1,
-      reportList: this.reports,
+      reportList: this.reports==null?[]:this.reports,
       pid: this.projectId,
       tid: this.taskId,
     }

+ 15 - 9
src/components/task/Task.vue

@@ -114,10 +114,15 @@
           <div class="btn btn-medium" @click="cancelMode('task')">取消</div>
         </el-form-item>
         <el-form-item v-if="!isModifyMode">
-          <div class="btn btn-medium btn-info" @click="submitTaskRequest()">提交任务</div>
-          <div class="btn btn-medium btn-info" @click="applyTask()">接收任务</div>
-          <div class="btn btn-medium btn-info" @click="modifyForm()">修改</div>
-          <div class="btn btn-medium btn-info" @click="createReport()">上传报告</div>
+          <div class="btn btn-medium btn-info"
+               v-if="(rolesPermissions.isRegionManager)"
+               @click="submitTaskRequest()">确认结束
+          </div>
+          <div class="btn btn-medium btn-info" v-if="(rolesPermissions.isAgency)" @click="submitTaskRequest()">结束任务
+          </div>
+          <div class="btn btn-medium btn-info" v-if="(rolesPermissions.isAgency)" @click="applyTask()">接收任务</div>
+          <div class="btn btn-medium btn-info" v-if="(rolesPermissions.isRegionManager)" @click="modifyForm()">修改</div>
+          <div class="btn btn-medium btn-info" v-if="(rolesPermissions.isAgency)" @click="createReport()">上传报告</div>
           <div class="btn btn-medium" @click="toProject()">前往项目</div>
         </el-form-item>
       </el-form>
@@ -132,7 +137,6 @@
 <script>
 import ResourceType from '@/constants/enum/resource-type.js'
 import provincecity from '@/components/commons/ProvinceCity'
-import provinceCityJSON from '@/constants/provinceCity.json'
 import ReportList from '@/components/report/ReportList'
 import Http from '@/js/http.js'
 import Apis from '@/js/api.js'
@@ -154,7 +158,8 @@ export default {
   data () {
     return {
       user: {},
-      loading:false,
+      rolesPermissions: {},
+      loading: false,
       isModifyMode: false,
       institutionArray: [],
       tabPosition: 'top',
@@ -265,7 +270,7 @@ export default {
     },
     updateLocation (location) {
       console.log(location)
-      const loactionName = getProvinceNameByProvinceCode(location.provinceCode,location.cityCode)
+      const loactionName = getProvinceNameByProvinceCode(location.provinceCode, location.cityCode)
       // var provinceName = ''
       // var cityName = ''
       // for (var item of provinceCityJSON.provinces) {
@@ -479,11 +484,12 @@ export default {
     },
     setUserInfo () {
       this.user = storageGet('user')
+      this.rolesPermissions = storageGet('rolesPermissions')
     },
-    showLoading(){
+    showLoading () {
       this.loading = true
     },
-    hideLoading(){
+    hideLoading () {
       this.loading = false
     }
   },