Jelajahi Sumber

修复报告不显示问题

郭超 3 tahun lalu
induk
melakukan
1134feb21e

+ 1 - 0
src/components/Mine.vue

@@ -215,6 +215,7 @@
             roleList: []
           }
         },
+        crowdReportVOS: [],
         isLogin: false,
         agency: false,
         part: false,

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

@@ -31,7 +31,7 @@
 export default {
   name: 'report-list',
   props: {
-    reports: {},
+    reports: [],
     projectId: '',
     taskId: ''
   },

+ 34 - 5
src/components/task/Task.vue

@@ -268,7 +268,7 @@
     <div class="create-body" v-if="!isModifyMode">
       <div class="title h2">用户报告列表</div>
       <el-collapse accordion style="margin: 0 30px">
-        <el-collapse-item v-for="(item,index) in acceptedUserList" :key="item.id">
+        <el-collapse-item v-for="(item) in acceptedUserList" :key="item.id">
           <template slot="title">
             <el-row style="width: 100%;font-size: 16px">
               <el-col :span="6">{{ item.userVO.userName }}</el-col>
@@ -290,6 +290,25 @@
       <!--      <report-list v-bind:reports="reportList" v-bind:taskId="taskId" v-bind:projectId="projectId"/>-->
     </div>
 
+    <div class="create-body" v-if="!isModifyMode&&task.needTestcase&&((rolesPermissions.isRegionManager&&!rolesPermissions.isAgency)||(taskOperationControl.uploadReport))">
+      <div class="title h2">测试用例列表</div>
+      <testcase-list v-bind:testcases="testCaseList" v-bind:testcaseToUsers="testCaseToUserList" v-bind:taskId="taskId" v-bind:projectId="projectId" />
+<!--      <el-collapse accordion style="margin: 0 30px">-->
+<!--        <div v-for="(testCaseItem,testCaseIndex) in testCaseList" :key="testCaseItem.id">-->
+<!--          <h1>用例{{testCaseIndex+1}}</h1>-->
+<!--          <div v-for="(testActionItem) in testCaseItem.testActions" :key="testActionItem.id">-->
+<!--            <div>{{ testActionItem.description }}</div>-->
+<!--          </div>-->
+<!--          <div v-for="(testActionItem) in testCaseItem.testActions" :key="testActionItem.id">-->
+<!--            <img :src="testActionItem.screenShot" style="width: 200px"/>-->
+<!--          </div>-->
+<!--        </div>-->
+<!--      </el-collapse>-->
+
+      <!--      <report-list v-if="isAgency" v-bind:reports="reportList" v-bind:taskId="taskId" v-bind:projectId="projectId"/>-->
+      <!--      <report-list v-bind:reports="reportList" v-bind:taskId="taskId" v-bind:projectId="projectId"/>-->
+    </div>
+
     <el-dialog title="请输入任务接收码" :visible.sync="showTaskCodeModal">
       <el-input v-model="taskValidCode" autocomplete="off" placeholder="请输入任务接收码"></el-input>
       <div slot="footer" class="dialog-footer">
@@ -312,6 +331,7 @@
 import ResourceType from '@/constants/enum/resource-type.js'
 import provincecity from '@/components/commons/ProvinceCity'
 import ReportList from '@/components/report/ReportList'
+import TestCaseList from '@/components/testcase/TestCaseList'
 import TaskCloud from '@/components/task/TaskCloud'
 import Http from '@/js/http.js'
 import Apis from '@/js/api.js'
@@ -337,12 +357,15 @@ import {
   refreshToken
 } from '@/js/index'
 import {AxiosInstance as axios} from "axios";
+import TestcaseList from '../testcase/TestCaseList'
 
 export default {
   name: 'Task',
   components: {
+    TestcaseList,
     provincecity,
     ReportList,
+    TestCaseList,
     TaskCloud
   },
   data() {
@@ -499,6 +522,8 @@ export default {
         datetime: [{required: true, message: '截止时间不可为空', trigger: 'blur'}],
       },
       acceptedUserList: [],
+      testCaseList: [],
+      testCaseToUserList: [],
       shortLink: '',
       editShortLink: false,
     }
@@ -724,6 +749,8 @@ export default {
       this.task.endPoint = {...res.crowdTaskVO.endPointVO};
       this.taskOperationControl = res.taskOperationControl;
       this.acceptedUserList = res.acceptedUserList;
+      this.testCaseList = res.testCaseList;
+      this.testCaseToUserList = res.testCaseToUserList;
       this.crowdReportUrl = res.crowdTaskVO.writeReportUrl;
       this.handleFormatReport(this.acceptedUserList);
       this.handleTestTypeChange(res.crowdTaskVO.serviceType);
@@ -836,11 +863,13 @@ export default {
       // this.task.endPoint = res.crowdTaskVO.endPointVO ? res.crowdTaskVO.endPointVO : {
       //   serverCode: '',
       // }
-      this.task.createTime = res.crowdTaskVO.createTime,
-        this.reportList = res.crowdReportVOList
-      this.crowdReportUrl = res.crowdTaskVO.writeReportUrl;
+      this.task.createTime = res.crowdTaskVO.createTime
+      this.reportList = res.crowdReportVOList
+      this.crowdReportUrl = res.crowdTaskVO.writeReportUrl
       this.acceptedUserList = res.acceptedUserList
-      this.handleTestTypeChange(res.crowdTaskVO.serviceType);
+      this.testCaseList = res.testCaseList
+      this.testCaseToUserList = res.testCaseToUserList
+      this.handleTestTypeChange(res.crowdTaskVO.serviceType)
       this.serviceName = this.getServiceByCode(res.crowdTaskVO.serviceType)
       this.getWordCloudByDescription()
       this.hideLoading()

+ 249 - 0
src/components/testcase/TestCaseList.vue

@@ -0,0 +1,249 @@
+<template>
+  <div class="testCase-container" v-loading="loading">
+    <div v-if="testcaseToUserList.length===0">
+      <div v-for="(item, index) in testCaseList" :key="index.id">
+        <div class="testCase-content">
+          <div>
+            <div style="float: left">
+              <span class="title">用例{{ index + 1 }}:{{ item.name }}</span>
+              <el-tag type="success" v-if="item.completeCount!==0">已完成{{ item.completeCount }}</el-tag>
+              <el-tag type="warring" v-else>待完成{{ item.completeCount }}</el-tag>
+            </div>
+          </div>
+          <div style="clear:both"></div>
+          <div>
+            <h3>前置条件</h3>
+            <div v-for="(testActionPreItem, testActionPreIndex) in item.testActionsPre"
+                 :key="testActionPreItem.id">
+              <div v-if="!testActionPreItem.same" :title="`${sameIndex = 0} ${stepIndex = testActionPreIndex + 1}`">
+                步骤{{ testActionPreIndex + 1 }}:{{ testActionPreItem.description }}
+              </div>
+              <div v-else :value="`${sameIndex++}`">步骤{{ stepIndex }}.{{ sameIndex }}:{{
+                  testActionPreItem.description
+                }}
+              </div>
+            </div>
+            <!--        <h3>前置条件截图</h3>-->
+            <div v-for="(testActionPreItem, testActionPreIndex) in item.testActionsPre"
+                 :key="testActionPreItem.id">
+              <div class="content" v-if="testActionPreItem.screenShot != null">
+                <h3 v-if="!testActionPreItem.same" :title="`${sameIndex = 0} ${stepIndex = testActionPreIndex + 1}`">
+                  步骤{{ testActionPreIndex + 1 }}</h3>
+                <h3 v-else :value="`${sameIndex++}`">步骤{{ stepIndex }}.{{ sameIndex }}</h3>
+                <img :src="testActionPreItem.screenShot" style="width: 200px"/>
+              </div>
+            </div>
+          </div>
+          <div style="clear:both"></div>
+          <div>
+            <h3>用例步骤</h3>
+            <div v-for="(testActionNextItem, testActionNextIndex) in item.testActionsNext"
+                 :key="testActionNextItem.id">
+              <div>步骤{{ testActionNextIndex + 1 }}:{{ testActionNextItem.description }}</div>
+            </div>
+            <!--        <h3>用例步骤截图</h3>-->
+            <div v-for="(testActionNextItem, testActionNextIndex) in item.testActionsNext"
+                 :key="testActionNextItem.id">
+              <div class="content" v-if="testActionNextItem.screenShot != null">
+                <div>
+                  <h3>步骤{{ testActionNextIndex + 1 }}</h3>
+                  <img :src="testActionNextItem.screenShot" style="width: 200px"/>
+                </div>
+              </div>
+            </div>
+          </div>
+          <div style="clear:both"></div>
+        </div>
+      </div>
+    </div>
+
+    <div v-else>
+      <div v-for="(testcaseToUserItem,testcaseToUserIndex) in testcaseToUserList" :key="testcaseToUserIndex.id">
+        <div class="testCase-content">
+          <div>
+            <div style="float: left">
+              <span class="title">用例{{ testcaseToUserIndex + 1 }}:{{ testcaseToUserItem.testCase.name }}</span>
+              <el-tag type="success" v-if="testcaseToUserItem.isCommitted">已完成</el-tag>
+              <el-tag type="warring" v-else>待完成</el-tag>
+            </div>
+            <div style="float: right">
+              <el-button type="primary" size="mini" slot="reference"
+                         v-if="!testcaseToUserItem.isCommitted"
+                         @click="complete(testcaseToUserItem.testCaseId)">提交完成
+              </el-button>
+              <div v-else>完成时间:{{ dateFormat(new Date(testcaseToUserItem.commitTime), 'yyyy-MM-dd HH:mm:ss') }}</div>
+            </div>
+          </div>
+          <div style="clear:both"></div>
+          <div>
+            <h3>前置条件</h3>
+            <div v-for="(testActionPreItem, testActionPreIndex) in testcaseToUserItem.testCase.testActionsPre"
+                 :key="testActionPreItem.id">
+              <div v-if="!testActionPreItem.same" :title="`${sameIndex = 0} ${stepIndex = testActionPreIndex + 1}`">
+                步骤{{ testActionPreIndex + 1 }}:{{ testActionPreItem.description }}
+              </div>
+              <div v-else :value="`${sameIndex++}`">步骤{{ stepIndex }}.{{ sameIndex }}:{{
+                  testActionPreItem.description
+                }}
+              </div>
+            </div>
+            <!--        <h3>前置条件截图</h3>-->
+            <div v-for="(testActionPreItem, testActionPreIndex) in testcaseToUserItem.testCase.testActionsPre"
+                 :key="testActionPreItem.id">
+              <div class="content" v-if="testActionPreItem.screenShot != null">
+                <h3 v-if="!testActionPreItem.same" :title="`${sameIndex = 0} ${stepIndex = testActionPreIndex + 1}`">
+                  步骤{{ testActionPreIndex + 1 }}</h3>
+                <h3 v-else :value="`${sameIndex++}`">步骤{{ stepIndex }}.{{ sameIndex }}</h3>
+                <img :src="testActionPreItem.screenShot" style="width: 200px"/>
+              </div>
+            </div>
+          </div>
+          <div style="clear:both"></div>
+          <div>
+            <h3>用例步骤</h3>
+            <div v-for="(testActionNextItem, testActionNextIndex) in testcaseToUserItem.testCase.testActionsNext"
+                 :key="testActionNextItem.id">
+              <div>步骤{{ testActionNextIndex + 1 }}:{{ testActionNextItem.description }}</div>
+            </div>
+            <!--        <h3>用例步骤截图</h3>-->
+            <div v-for="(testActionNextItem, testActionNextIndex) in testcaseToUserItem.testCase.testActionsNext"
+                 :key="testActionNextItem.id">
+              <div class="content" v-if="testActionNextItem.screenShot != null">
+                <div>
+                  <h3>步骤{{ testActionNextIndex + 1 }}</h3>
+                  <img :src="testActionNextItem.screenShot" style="width: 200px"/>
+                </div>
+              </div>
+            </div>
+          </div>
+          <div style="clear:both"></div>
+        </div>
+      </div>
+    </div>
+  </div>
+</template>
+<script>
+import {
+  completeTestCase
+} from '@/js/index'
+
+export default {
+  name: 'testcase-list',
+  props: {
+    testcases: {},
+    testcaseToUsers: {},
+    projectId: '',
+    taskId: '',
+  },
+  data () {
+    return {
+      editIndex: -1,
+      testCaseList: this.testcases == null ? [] : this.testcases,
+      testcaseToUserList: this.testcaseToUsers == null ? [] : this.testcaseToUsers,
+      pid: this.projectId,
+      tid: this.taskId,
+      stepIndex: 0,
+      sameIndex: 0,
+      loading: false
+    }
+  },
+  methods: {
+    //显示页面加载画面
+    showLoading () {
+      this.loading = true
+    },
+    //隐藏页面加载画面
+    hideLoading () {
+      this.loading = false
+    },
+    //提交测试用例
+    complete (testCaseId) {
+      this.$confirm('确认已完成此测试用例?', '提示', {
+        confirmButtonText: '确认提交',
+        cancelButtonText: '取消',
+        type: 'success'
+      }).then(() => {
+        this.showLoading()
+        completeTestCase(this.projectId, this.taskId, testCaseId, this.completeSuccess, this.completeFail)
+      }).catch(() => {
+
+      })
+    },
+    //拒绝任务成功时的回调函数
+    completeSuccess (res) {
+      this.hideLoading()
+      location.reload()
+      notify('success', '用例确认完成')
+    },
+    //拒绝任务失败时的回调函数
+    completeFail (error) {
+      this.hideLoading()
+      notify('error', '用例提交失败:' + error.data)
+    },
+    dateFormat (date, format) {
+      date = new Date(date)
+      let o = {
+        'M+': date.getMonth() + 1, //month
+        'd+': date.getDate(), //day
+        'H+': date.getHours(), //hour+8小时
+        'm+': date.getMinutes(), //minute
+        's+': date.getSeconds(), //second
+        'q+': Math.floor((date.getMonth() + 3) / 3), //quarter
+        'S': date.getMilliseconds() //millisecond
+      }
+      if (/(y+)/.test(format)) {
+        format = format.replace(RegExp.$1, (date.getFullYear() + '').substr(4 - RegExp.$1.length))
+      }
+
+      for (let k in o) {
+        if (new RegExp('(' + k + ')').test(format)) {
+          format = format.replace(RegExp.$1, RegExp.$1.length == 1 ? o[k] : ('00' + o[k]).substr(('' + o[k]).length))
+        }
+      }
+
+      return format
+    },
+  },
+  watch: {
+    testcases () {
+      this.testCaseList = this.testcases
+    },
+    projectId () {
+      this.pid = this.projectId
+    },
+    taskId () {
+      this.tid = this.taskId
+    }
+  }
+}
+</script>
+
+
+<style lang="scss" scoped>
+.testCase-container {
+  margin: 0 30px 0 0;
+}
+
+.testCase-content {
+  margin-bottom: 20px;
+  border: black 1px solid;
+  padding: 10px;
+}
+
+.content {
+  float: left;
+  margin-right: 20px;
+}
+
+.title {
+  font-size: 28px;
+}
+
+.el-row {
+  margin-bottom: 20px;
+}
+
+.el-collapse-item__content {
+  padding-bottom: 0 !important;
+}
+</style>

+ 2 - 1
src/js/api.js

@@ -27,7 +27,8 @@ export default {
     MORE_HOT_TASK: '/api/square/hotTasks/list',
     GET_TASK_CLOUD:'/api/project/{projectId}/task/{taskId}/word',
     GET_TASK_CLOUD_By_DESCRIPTION:'/api/project/{projectId}/task/{taskId}/word/{taskDescription}',
-    REFRESH_TOKEN:'/api/project/{projectCode}/task/{taskCode}/writerReportUrl'
+    REFRESH_TOKEN:'/api/project/{projectCode}/task/{taskCode}/writerReportUrl',
+    COMPLETE_TEST_CASE: '/api/project/{projectId}/task/{taskId}/testcase/{testCaseId}',
   },
   REPORT: {
     GET_TASK_REPORT: '/api/project/{projectId}/task/{taskId}/report/{reportId}/',

+ 2 - 0
src/js/index.js

@@ -39,6 +39,7 @@ import {
   getTask,
   receiveTaskRequest,
   rejectTask,
+  completeTestCase,
   submitTaskRequest,
   updateTask,
   getTaskWordCloud,
@@ -156,6 +157,7 @@ export {
   receiveTaskRequest,
   //测评机构拒绝任务
   rejectTask,
+  completeTestCase,
   //测评机构提交任务
   submitTaskRequest,
   //区域管理员修改任务

+ 8 - 0
src/js/taskService.js

@@ -77,6 +77,14 @@ export const rejectTask = (projectId, taskId, rejectTaskSuccess, rejectTaskFail)
   })
 }
 
+export const completeTestCase = (projectId, taskId, testCaseId, completeSuccess, completeFail) => {
+  Http.put(Apis.TASK.COMPLETE_TEST_CASE.replace('{projectId}', projectId).replace('{taskId}', taskId).replace('{testCaseId}', testCaseId), {}).then((res) => {
+    completeSuccess(res)
+  }).catch((error) => {
+    completeFail(error)
+  })
+}
+
 //区域管理员确认结束任务
 export const ensureEndTask = (projectId, taskId, endTaskSuccess, endTaskFail) => {
   Http.put(Apis.TASK.END_TASK.replace('{projectId}', projectId).replace('{taskId}', taskId), {}).then((res) => {