|
|
@@ -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>
|