|
@@ -0,0 +1,685 @@
|
|
|
+<template>
|
|
|
+ <div class="app-container">
|
|
|
+ <div class="title h1" style="margin-top: 10px;">测试用例管理</div>
|
|
|
+ <div class="filter-container">
|
|
|
+ <el-select v-model="listQueryParam.selectedTaskCode" filterable :filter-method="dataFilter" @click.native="eqNoClick">
|
|
|
+ <el-option
|
|
|
+ v-for="task in searchTasks"
|
|
|
+ :key="task.code"
|
|
|
+ :label="task.name"
|
|
|
+ :value="task.code"
|
|
|
+ />
|
|
|
+ </el-select>
|
|
|
+ <el-select v-model="listQueryParam.testStatus">
|
|
|
+ <el-option value="" label="---测试结论---"/>
|
|
|
+ <el-option value="WAIT" label="待测试"/>
|
|
|
+ <el-option value="PASS" label="通过"/>
|
|
|
+ <el-option value="NO_PASS" label="不通过"/>
|
|
|
+ </el-select>
|
|
|
+ <el-select v-model="listQueryParam.examStatus" v-if="!testCaseCanEdit">
|
|
|
+ <el-option value="" label="---审核结果---"/>
|
|
|
+ <el-option value="WAIT" label="待审核"/>
|
|
|
+ <el-option value="VALID" label="有效"/>
|
|
|
+ <el-option value="INVALID" label="无效"/>
|
|
|
+ </el-select>
|
|
|
+<!-- <el-input v-model="listQuery.title" placeholder="用例名" style="width: 200px;" class="filter-item" @keyup.enter.native="handleFilter" />-->
|
|
|
+<!-- <el-input v-model="listQuery.title" placeholder="用例编号" style="width: 200px;" class="filter-item" @keyup.enter.native="handleFilter" />-->
|
|
|
+<!-- <el-button v-waves class="filter-item" type="primary" icon="el-icon-search" @click="handleSearch">-->
|
|
|
+<!-- Search-->
|
|
|
+<!-- </el-button>-->
|
|
|
+ <el-button class="filter-item" style="margin-left: 10px;" type="primary" @click="handleCreate" v-if="testCaseCanEdit">
|
|
|
+ 新增测试用例
|
|
|
+ </el-button>
|
|
|
+ <el-button class="filter-item" style="margin-left: 10px;" type="success" @click="handleSubmitAudit" v-if="testCaseCanEdit">
|
|
|
+ 提交审核
|
|
|
+ </el-button>
|
|
|
+ <span style="display: block; float: right; color: indianred; margin-right: 20px">提交状态:{{isCommitted ? '已提交' : '未提交'}}</span>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <el-table
|
|
|
+ ref="testCaseTable"
|
|
|
+ :key="tableKey"
|
|
|
+ v-loading="listLoading"
|
|
|
+ :data="testCaseDatas"
|
|
|
+ border
|
|
|
+ fit
|
|
|
+ highlight-current-row
|
|
|
+ style="width: 100%"
|
|
|
+ >
|
|
|
+ <el-table-column type="expand" align="center" min-width="1%">
|
|
|
+ <template slot-scope="{row}">
|
|
|
+ <el-table
|
|
|
+ :key="'innerTableKey' + row.id"
|
|
|
+ :data="row.defects"
|
|
|
+ border
|
|
|
+ fit
|
|
|
+ style="width: 100%"
|
|
|
+ >
|
|
|
+ <el-table-column label="编号" align="center" min-width="15%">
|
|
|
+ <template slot-scope="{row}">
|
|
|
+ <span>{{ row.code }}</span>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="缺陷描述" align="center" :show-overflow-tooltip="true" min-width="35%">
|
|
|
+ <template slot-scope="{row}">
|
|
|
+ <span>{{ row.descr }}</span>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="严重等级" align="center" min-width="12%">
|
|
|
+ <template slot-scope="{row}">
|
|
|
+ <span>{{ toSeriousnessCn(row.seriousness) }}</span>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="优先级" align="center" min-width="10%">
|
|
|
+ <template slot-scope="{row}">
|
|
|
+ <span>{{ toPriorityCn(row.priority) }}</span>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="缺陷类型" align="center" min-width="12%">
|
|
|
+ <template slot-scope="{row}">
|
|
|
+ <span>{{ toDefectTypeCn(row.defectType) }}</span>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="操作步骤" align="center" :show-overflow-tooltip="true" min-width="35%">
|
|
|
+ <template slot-scope="{row}">
|
|
|
+ <span>{{ row.opeSteps }}</span>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="输入数据" align="center" :show-overflow-tooltip="true" min-width="35%">
|
|
|
+ <template slot-scope="{row}">
|
|
|
+ <span>{{ row.inputDatas }}</span>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="预期结果" align="center" :show-overflow-tooltip="true" min-width="35%">
|
|
|
+ <template slot-scope="{row}">
|
|
|
+ <span>{{ row.expectedResult }}</span>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="测试结果" align="center" :show-overflow-tooltip="true" min-width="35%">
|
|
|
+ <template slot-scope="{row}">
|
|
|
+ <span>{{ row.testResult }}</span>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="操作" align="center" class-name="small-padding fixed-width" min-width="20%">
|
|
|
+ <template slot-scope="{row,$index}">
|
|
|
+ <i class="el-icon-tickets mini-margin" @click="handleDefectDetail(row)" v-if="!testCaseCanEdit" style="cursor: pointer;" title="查看详情"></i>
|
|
|
+ <i class="el-icon-edit mini-margin " @click="handleUpdateDefect(row)" v-if="testCaseCanEdit" style="cursor: pointer;" title="编辑"></i>
|
|
|
+ <i class="el-icon-delete mini-margin " @click="handleDeleteDefect(row,$index)" v-if="testCaseCanEdit" style="cursor: pointer;" title="删除"></i>
|
|
|
+ <i class="el-icon-document-copy mini-margin " @click="handleCopyDefect(row)" v-if="testCaseCanEdit" style="cursor: pointer;" title="复制"></i>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ </el-table>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="编号" prop="code" sortable="custom" align="center" min-width="3%">
|
|
|
+ <template slot-scope="{row}">
|
|
|
+ <span>{{ row.code }}</span>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="用例名称" align="center" :show-overflow-tooltip="true" min-width="6%">
|
|
|
+ <template slot-scope="{row}">
|
|
|
+ <span>{{ row.name }}</span>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="优先级" align="center" min-width="3%">
|
|
|
+ <template slot-scope="{row}">
|
|
|
+ <span>{{ toPriorityCn(row.priority) }}</span>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="描述" align="center" :show-overflow-tooltip="true" min-width="10%">
|
|
|
+ <template slot-scope="{row}">
|
|
|
+ <span>{{ row.descr }}</span>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="关联需求" align="center" :show-overflow-tooltip="true" min-width="10%">
|
|
|
+ <template slot-scope="{row}">
|
|
|
+ <span>{{ row.demand }}</span>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="预期结果" align="center" :show-overflow-tooltip="true" min-width="8%">
|
|
|
+ <template slot-scope="{row}">
|
|
|
+ <span>{{ row.expectedResult }}</span>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="测试结果" align="center" :show-overflow-tooltip="true" min-width="8%">
|
|
|
+ <template slot-scope="{row}">
|
|
|
+ <span>{{ row.testResult }}</span>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="测试结论" align="center" min-width="4%">
|
|
|
+ <template slot-scope="{row}">
|
|
|
+ <span>{{ toTestStatusCn(row.testStatus) }}</span>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="缺陷数量(个)" align="center" min-width="4%">
|
|
|
+ <template slot-scope="{row}">
|
|
|
+ <a href="javascript:void(0)" @click="toogleExpand2(row)" style="color: indianred;">{{ row.defects.length }}</a>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="审核结果" align="center" min-width="4%" v-if="!testCaseCanEdit">
|
|
|
+ <template slot-scope="{row}">
|
|
|
+ <span>{{ toExamStatusCn(row.examStatus) }}</span>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="审核结果说明" align="center" :show-overflow-tooltip="true" min-width="8%" v-if="!testCaseCanEdit">
|
|
|
+ <template slot-scope="{row}">
|
|
|
+ <span>{{ row.examDescr }}</span>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+<!-- <el-table-column v-if="showReviewer" label="Reviewer" width="110px" align="center">-->
|
|
|
+<!-- <template slot-scope="{row}">-->
|
|
|
+<!-- <span style="color:red;">{{ row.reviewer }}</span>-->
|
|
|
+<!-- </template>-->
|
|
|
+<!-- </el-table-column>-->
|
|
|
+<!-- <el-table-column label="Imp" width="80px">-->
|
|
|
+<!-- <template slot-scope="{row}">-->
|
|
|
+<!-- <svg-icon v-for="n in + row.importance" :key="n" icon-class="star" class="meta-item__icon" />-->
|
|
|
+<!-- </template>-->
|
|
|
+<!-- </el-table-column>-->
|
|
|
+ <el-table-column label="操作" align="center" min-width="5%">
|
|
|
+ <template slot-scope="{row,$index}">
|
|
|
+ <i class="el-icon-tickets mini-margin" @click="handleDetail(row)" v-if="!testCaseCanEdit" style="cursor: pointer;" title="查看详情"></i>
|
|
|
+ <i class="el-icon-edit mini-margin" @click="handleUpdate(row)" v-if="testCaseCanEdit" style="cursor: pointer;" title="编辑"></i>
|
|
|
+ <i class="el-icon-delete mini-margin" @click="handleDelete(row,$index)" v-if="testCaseCanEdit" style="cursor: pointer;" title="删除"></i>
|
|
|
+ <i class="el-icon-document-copy mini-margin" @click="handleCopy(row)" v-if="testCaseCanEdit" style="cursor: pointer;" title="复制"></i>
|
|
|
+ <i class="el-icon-document-add mini-margin" @click="handleCreateDefect(row)" v-if="testCaseCanEdit && row.testStatus === 'NO_PASS'" style="cursor: pointer;" title="新增缺陷"></i>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ </el-table>
|
|
|
+
|
|
|
+ <pagination v-show="total>0" :total="total" :page.sync="listQueryParam.pageNo" :limit.sync="listQueryParam.pageSize" @pagination="getList" />
|
|
|
+
|
|
|
+ <el-dialog :title="textMap[dialogStatus]" :visible.sync="dialogFormVisible">
|
|
|
+ <testcase-form ref="testCaseForm" style="width: 600px;" :test-case-data="testCaseData" :read-only="!testCaseCanEdit"></testcase-form>
|
|
|
+ <div slot="footer" class="dialog-footer">
|
|
|
+ <el-button @click="dialogFormVisible = false">
|
|
|
+ 取消
|
|
|
+ </el-button>
|
|
|
+ <el-button type="primary" @click="submitData()">
|
|
|
+ 提交
|
|
|
+ </el-button>
|
|
|
+ </div>
|
|
|
+ </el-dialog>
|
|
|
+
|
|
|
+ <el-dialog :title="textMap[dialogStatus]" :visible.sync="defectDialogFormVisible">
|
|
|
+ <defect-form ref="defectForm" style="width: 600px;" :defect-data="defectData"></defect-form>
|
|
|
+ <div slot="footer" class="dialog-footer">
|
|
|
+ <el-button @click="defectDialogFormVisible = false">
|
|
|
+ 取消
|
|
|
+ </el-button>
|
|
|
+ <el-button type="primary" @click="submitDefectData()">
|
|
|
+ 提交
|
|
|
+ </el-button>
|
|
|
+ </div>
|
|
|
+ </el-dialog>
|
|
|
+
|
|
|
+ <el-dialog title="用例详情" :visible.sync="testCaseDetailDialogFormVisible">
|
|
|
+ <testcase-detail ref="testCaseDetail" style="width: 600px;" :test-case-data="testCaseData" :can-audit="false"></testcase-detail>
|
|
|
+ <div slot="footer" class="dialog-footer">
|
|
|
+ <el-button @click="testCaseDetailDialogFormVisible = false">
|
|
|
+ 取消
|
|
|
+ </el-button>
|
|
|
+ </div>
|
|
|
+ </el-dialog>
|
|
|
+
|
|
|
+ <el-dialog title="缺陷详情" :visible.sync="defectDetailDialogFormVisible">
|
|
|
+ <defect-detail ref="defectDetail" style="width: 600px;" :defect-data="defectData"></defect-detail>
|
|
|
+ <div slot="footer" class="dialog-footer">
|
|
|
+ <el-button @click="defectDetailDialogFormVisible = false">
|
|
|
+ 取消
|
|
|
+ </el-button>
|
|
|
+ </div>
|
|
|
+ </el-dialog>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+import waves from '@/directive/waves' // waves directive
|
|
|
+import Pagination from '@/components/Pagination' // secondary package based on el-pagination
|
|
|
+import TestcaseForm from './components/testcase_form'
|
|
|
+import DefectForm from './components/defect_form'
|
|
|
+import TestcaseDetail from './components/testcase_detail'
|
|
|
+import DefectDetail from './components/defect_detail'
|
|
|
+import Http from '@/js/http'
|
|
|
+import Api from '@/js/api'
|
|
|
+import {notify} from '@/constants'
|
|
|
+import TestCaseUtils from './utils'
|
|
|
+
|
|
|
+export default {
|
|
|
+ name: 'ComplexTable',
|
|
|
+ components: { Pagination, TestcaseForm, DefectForm, TestcaseDetail, DefectDetail },
|
|
|
+ directives: { waves },
|
|
|
+ data () {
|
|
|
+ return {
|
|
|
+ testCaseData: {},
|
|
|
+ defectData: {},
|
|
|
+ testCaseDatas: [],
|
|
|
+ tableKey: 0,
|
|
|
+ total: 0,
|
|
|
+ listQueryParam: {
|
|
|
+ pageNo: 1,
|
|
|
+ pageSize: 20,
|
|
|
+ selectedTaskCode: this.$route.params.taskCode,
|
|
|
+ testStatus: '',
|
|
|
+ examStatus: ''
|
|
|
+ },
|
|
|
+ listLoading: true,
|
|
|
+ showReviewer: false,
|
|
|
+ dialogFormVisible: false,
|
|
|
+ defectDialogFormVisible: false,
|
|
|
+ testCaseDetailDialogFormVisible: false,
|
|
|
+ defectDetailDialogFormVisible: false,
|
|
|
+ dialogStatus: '',
|
|
|
+ textMap: {
|
|
|
+ update: '编辑测试用例',
|
|
|
+ create: '新建测试用例',
|
|
|
+ create_defect: '新建缺陷',
|
|
|
+ update_defect: '编辑缺陷',
|
|
|
+ detail: '测试用例详情',
|
|
|
+ defect_detail: '缺陷详情'
|
|
|
+ },
|
|
|
+ selectedTaskCode: '',
|
|
|
+ tasks: [],
|
|
|
+ searchTasks: [],
|
|
|
+ testCaseCanEdit: false,
|
|
|
+ isCommitted: false
|
|
|
+ }
|
|
|
+ },
|
|
|
+ watch: {
|
|
|
+ 'listQueryParam.selectedTaskCode': function (newVal, oldVal) {
|
|
|
+ this.getList()
|
|
|
+ this.handleStatus()
|
|
|
+ },
|
|
|
+ 'listQueryParam.testStatus': function (newVal, oldVal) {
|
|
|
+ this.getList()
|
|
|
+ },
|
|
|
+ 'listQueryParam.examStatus': function (newVal, oldVal) {
|
|
|
+ this.getList()
|
|
|
+ }
|
|
|
+ },
|
|
|
+ created () {
|
|
|
+ this.initData()
|
|
|
+ this.initDefectData()
|
|
|
+ this.getSimpleTaskDatas()
|
|
|
+ this.getList()
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ ...TestCaseUtils,
|
|
|
+ handleStatus () {
|
|
|
+ let task = this.tasks.find(task => {
|
|
|
+ return task.code === this.listQueryParam.selectedTaskCode
|
|
|
+ })
|
|
|
+ this.testCaseCanEdit = !(task.isCommitted) && task.status !== 5
|
|
|
+ this.isCommitted = task.isCommitted && true
|
|
|
+ },
|
|
|
+ getList () {
|
|
|
+ this.showListLoading()
|
|
|
+ let url = Api.TESTCASE.USER_TEST_CASES.replace('{taskCode}', this.listQueryParam.selectedTaskCode)
|
|
|
+ .replace('{designerId}', '0')
|
|
|
+ .replace('{pageNo}', this.listQueryParam.pageNo - 1)
|
|
|
+ .replace('{pageSize}', this.listQueryParam.pageSize)
|
|
|
+ if (this.listQueryParam.testStatus || this.listQueryParam.examStatus) {
|
|
|
+ if (url.indexOf('?') === -1) {
|
|
|
+ url = url + '?'
|
|
|
+ }
|
|
|
+ if (this.listQueryParam.testStatus) {
|
|
|
+ url = url + 'testStatus=' + this.listQueryParam.testStatus + '&'
|
|
|
+ }
|
|
|
+ if (this.listQueryParam.examStatus) {
|
|
|
+ url = url + 'examStatus=' + this.listQueryParam.examStatus + '&'
|
|
|
+ }
|
|
|
+ url = url.substring(0, url.length - 1)
|
|
|
+ }
|
|
|
+ Http.get(url).then((res) => {
|
|
|
+ const testCasePage = res.data
|
|
|
+ this.total = testCasePage.totalCount
|
|
|
+ this.listQueryParam.pageNo = testCasePage.pageNo + 1
|
|
|
+ this.listQueryParam.pageSize = testCasePage.pageSize
|
|
|
+ this.testCaseDatas = testCasePage.datas
|
|
|
+ }).catch((error) => {
|
|
|
+ console.error(error)
|
|
|
+ notify('error', '获取测试用例数据失败:' + error)
|
|
|
+ })
|
|
|
+ this.hideListLoading()
|
|
|
+ },
|
|
|
+ // handleSearch () {
|
|
|
+ // this.listQueryParam.pageNo = 1
|
|
|
+ // this.getList()
|
|
|
+ // },
|
|
|
+ initData () {
|
|
|
+ this.testCaseData = {
|
|
|
+ demand: '',
|
|
|
+ descr: '',
|
|
|
+ envConfig: '',
|
|
|
+ evaCriteria: '',
|
|
|
+ testStatus: '',
|
|
|
+ expectedResult: '',
|
|
|
+ files: [],
|
|
|
+ id: undefined,
|
|
|
+ inputDatas: '',
|
|
|
+ name: '',
|
|
|
+ opeSteps: '',
|
|
|
+ others: '',
|
|
|
+ preconditions: '',
|
|
|
+ priority: '',
|
|
|
+ screenshots: [],
|
|
|
+ taskCode: '',
|
|
|
+ testResult: ''
|
|
|
+ }
|
|
|
+ },
|
|
|
+ initDefectData () {
|
|
|
+ this.defectData = {
|
|
|
+ descr: '',
|
|
|
+ envConfig: '',
|
|
|
+ expectedResult: '',
|
|
|
+ files: [],
|
|
|
+ id: undefined,
|
|
|
+ inputDatas: '',
|
|
|
+ opeSteps: '',
|
|
|
+ others: '',
|
|
|
+ preconditions: '',
|
|
|
+ priority: '',
|
|
|
+ seriousness: '',
|
|
|
+ defectType: '',
|
|
|
+ screenshots: [],
|
|
|
+ taskCode: '',
|
|
|
+ testCaseCode: '',
|
|
|
+ testResult: ''
|
|
|
+ }
|
|
|
+ },
|
|
|
+ handleSubmitAudit () {
|
|
|
+ this.$confirm('提交任务之后将不能再编辑测试用例,您确定要提交该任务吗', '提示', {
|
|
|
+ confirmButtonText: '确定',
|
|
|
+ cancelButtonText: '取消',
|
|
|
+ type: 'warning',
|
|
|
+ center: true,
|
|
|
+ closeOnClickModal: false
|
|
|
+ }).then(() => {
|
|
|
+ this.showListLoading()
|
|
|
+ Http.put(Api.TASK.COMMIT_TASK.replace('{taskCode}', this.listQueryParam.selectedTaskCode), {}).then((res) => {
|
|
|
+ this.hideListLoading()
|
|
|
+ if (res.code === 20000) {
|
|
|
+ this.$notify({
|
|
|
+ title: 'Success',
|
|
|
+ message: '提交成功',
|
|
|
+ type: 'success',
|
|
|
+ duration: 2000
|
|
|
+ })
|
|
|
+ this.testCaseCanEdit = false
|
|
|
+ } else {
|
|
|
+ this.$notify({
|
|
|
+ title: 'Error',
|
|
|
+ message: '提交失败:' + res.data,
|
|
|
+ type: 'Error',
|
|
|
+ duration: 2000
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }).catch((error) => {
|
|
|
+ this.hideListLoading()
|
|
|
+ notify('error', '提交失败:' + error)
|
|
|
+ })
|
|
|
+ }).catch(() => {
|
|
|
+ })
|
|
|
+ },
|
|
|
+ handleCreate () {
|
|
|
+ this.initData()
|
|
|
+ this.dialogStatus = 'create'
|
|
|
+ this.dialogFormVisible = true
|
|
|
+ this.testCaseData.taskCode = this.listQueryParam.selectedTaskCode
|
|
|
+ this.$nextTick(() => {
|
|
|
+ this.$refs['testCaseForm'].clearValidate()
|
|
|
+ })
|
|
|
+ },
|
|
|
+ handleCreateDefect (testCase) {
|
|
|
+ this.initDefectData()
|
|
|
+ this.dialogStatus = 'create_defect'
|
|
|
+ this.defectDialogFormVisible = true
|
|
|
+ this.defectData.taskCode = this.listQueryParam.selectedTaskCode
|
|
|
+ this.defectData.testCaseCode = testCase.code
|
|
|
+ this.defectData.priority = testCase.priority
|
|
|
+ this.defectData.preconditions = testCase.preconditions
|
|
|
+ this.defectData.envConfig = testCase.envConfig
|
|
|
+ this.defectData.opeSteps = testCase.opeSteps
|
|
|
+ this.defectData.inputDatas = testCase.inputDatas
|
|
|
+ this.defectData.expectedResult = testCase.expectedResult
|
|
|
+ this.defectData.testResult = testCase.testResult
|
|
|
+ this.$nextTick(() => {
|
|
|
+ this.$refs['defectForm'].clearValidate()
|
|
|
+ })
|
|
|
+ },
|
|
|
+ submitData () {
|
|
|
+ let callback = null
|
|
|
+ if (this.testCaseData.id) {
|
|
|
+ callback = this.getList
|
|
|
+ } else {
|
|
|
+ callback = () => {
|
|
|
+ this.listQueryParam.pageNo = Math.ceil((this.total + 1) / this.listQueryParam.pageSize)
|
|
|
+ this.getList()
|
|
|
+ }
|
|
|
+ }
|
|
|
+ this.$refs.testCaseForm.submitForm(callback)
|
|
|
+ },
|
|
|
+ submitDefectData () {
|
|
|
+ this.$refs.defectForm.submitForm(this.getList)
|
|
|
+ },
|
|
|
+ handleDetail (row) {
|
|
|
+ this.testCaseDetailDialogFormVisible = true
|
|
|
+ this.deepClone(this.testCaseData, row)
|
|
|
+ },
|
|
|
+ handleDefectDetail (row) {
|
|
|
+ this.defectDetailDialogFormVisible = true
|
|
|
+ this.deepClone(this.defectData, row)
|
|
|
+ },
|
|
|
+ handleUpdate (row) {
|
|
|
+ this.dialogStatus = 'update'
|
|
|
+ this.dialogFormVisible = true
|
|
|
+ this.deepClone(this.testCaseData, row)
|
|
|
+ this.$nextTick(() => {
|
|
|
+ this.$refs['testCaseForm'].clearValidate()
|
|
|
+ })
|
|
|
+ },
|
|
|
+ handleUpdateDefect (row) {
|
|
|
+ this.dialogStatus = 'update_defect'
|
|
|
+ this.defectDialogFormVisible = true
|
|
|
+ this.deepClone(this.defectData, row)
|
|
|
+ this.$nextTick(() => {
|
|
|
+ this.$refs['defectForm'].clearValidate()
|
|
|
+ })
|
|
|
+ console.log(this.defectData)
|
|
|
+ },
|
|
|
+ handleDelete (row, index) {
|
|
|
+ this.$confirm('您确定要删除该条数据吗?', '提示', {
|
|
|
+ confirmButtonText: '确定',
|
|
|
+ cancelButtonText: '取消',
|
|
|
+ type: 'warning',
|
|
|
+ center: true,
|
|
|
+ closeOnClickModal: false
|
|
|
+ }).then(() => {
|
|
|
+ this.showListLoading()
|
|
|
+ Http.delete(Api.TESTCASE.DELETE.replace('{id}', row.id), {}).then((res) => {
|
|
|
+ this.hideListLoading()
|
|
|
+ if (res.code === 20000) {
|
|
|
+ this.$notify({
|
|
|
+ title: 'Success',
|
|
|
+ message: '删除成功',
|
|
|
+ type: 'success',
|
|
|
+ duration: 2000
|
|
|
+ })
|
|
|
+ this.getList()
|
|
|
+ } else {
|
|
|
+ this.$notify({
|
|
|
+ title: 'Error',
|
|
|
+ message: '删除失败' + res.msg,
|
|
|
+ type: 'Error',
|
|
|
+ duration: 2000
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }).catch((error) => {
|
|
|
+ this.hideListLoading()
|
|
|
+ notify('error', '删除失败:' + error)
|
|
|
+ })
|
|
|
+ }).catch(() => {
|
|
|
+ })
|
|
|
+ },
|
|
|
+ handleDeleteDefect (row, index) {
|
|
|
+ this.$confirm('您确定要删除该条数据吗?', '提示', {
|
|
|
+ confirmButtonText: '确定',
|
|
|
+ cancelButtonText: '取消',
|
|
|
+ type: 'warning',
|
|
|
+ center: true,
|
|
|
+ closeOnClickModal: false
|
|
|
+ }).then(() => {
|
|
|
+ this.showListLoading()
|
|
|
+ Http.delete(Api.TESTCASE.DELETE_DEFECT.replace('{id}', row.id), {}).then((res) => {
|
|
|
+ this.hideListLoading()
|
|
|
+ if (res.code === 20000) {
|
|
|
+ this.$notify({
|
|
|
+ title: 'Success',
|
|
|
+ message: '删除成功',
|
|
|
+ type: 'success',
|
|
|
+ duration: 2000
|
|
|
+ })
|
|
|
+ for (let i in this.testCaseDatas) {
|
|
|
+ let testCase = this.testCaseDatas[i]
|
|
|
+ if (testCase.defects.length > index) {
|
|
|
+ if (testCase.defects[index].id === row.id) {
|
|
|
+ testCase.defects.splice(index, 1)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ this.$notify({
|
|
|
+ title: 'Error',
|
|
|
+ message: '删除失败' + res.msg,
|
|
|
+ type: 'Error',
|
|
|
+ duration: 2000
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }).catch((error) => {
|
|
|
+ this.hideListLoading()
|
|
|
+ notify('error', '删除失败:' + error)
|
|
|
+ })
|
|
|
+ }).catch(() => {
|
|
|
+ })
|
|
|
+ },
|
|
|
+ handleCopy (row) {
|
|
|
+ this.dialogStatus = 'create'
|
|
|
+ this.dialogFormVisible = true
|
|
|
+ this.deepClone(this.testCaseData, row)
|
|
|
+ this.testCaseData.id = undefined
|
|
|
+ this.$nextTick(() => {
|
|
|
+ this.$refs['testCaseForm'].clearValidate()
|
|
|
+ })
|
|
|
+ console.log(this.testCaseData)
|
|
|
+ },
|
|
|
+ handleCopyDefect (row) {
|
|
|
+ this.dialogStatus = 'create_defect'
|
|
|
+ this.defectDialogFormVisible = true
|
|
|
+ this.deepClone(this.defectData, row)
|
|
|
+ this.defectData.id = undefined
|
|
|
+ this.$nextTick(() => {
|
|
|
+ this.$refs['defectForm'].clearValidate()
|
|
|
+ })
|
|
|
+ console.log(this.defectData)
|
|
|
+ },
|
|
|
+ getSortClass: function (key) {
|
|
|
+ const sort = this.listQuery.sort
|
|
|
+ return sort === `+${key}` ? 'ascending' : 'descending'
|
|
|
+ },
|
|
|
+ dataFilter (val) {
|
|
|
+ if (val) {
|
|
|
+ this.searchTasks = this.tasks.filter(task => {
|
|
|
+ return task.name.includes(val)
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ this.searchTasks = this.tasks
|
|
|
+ }
|
|
|
+ },
|
|
|
+ eqNoClick () {
|
|
|
+ this.searchTasks = this.tasks
|
|
|
+ },
|
|
|
+ getSimpleTaskDatas () {
|
|
|
+ Http.get(Api.TASK.GET_SIMPLE_USER_TASK_DATAS).then((res) => {
|
|
|
+ this.tasks = res.data
|
|
|
+ this.tasks.forEach(task => {
|
|
|
+ if (task.status === 4) {
|
|
|
+ task.name = task.name + '(已结束)'
|
|
|
+ } else if (task.status === 5) {
|
|
|
+ task.name = task.name + '(已超时)'
|
|
|
+ }
|
|
|
+ })
|
|
|
+ this.searchTasks = this.tasks
|
|
|
+ this.handleStatus()
|
|
|
+ }).catch((error) => {
|
|
|
+ this.hideLoading()
|
|
|
+ notify('error', '获取任务数据失败:' + error.data)
|
|
|
+ })
|
|
|
+ },
|
|
|
+ deepClone: function (oldData, newData) {
|
|
|
+ if (newData instanceof Array) {
|
|
|
+ if (oldData.length !== newData.length) {
|
|
|
+ oldData = new Array(newData.length)
|
|
|
+ }
|
|
|
+ for (var i = 0; i < newData.length; i++) {
|
|
|
+ if (newData[i] instanceof Array) {
|
|
|
+ oldData[i] = new Array(newData[i].length)
|
|
|
+ this.deepClone(oldData[i], newData[i])
|
|
|
+ } else if (newData[i] instanceof Object) {
|
|
|
+ oldData[i] = {}
|
|
|
+ this.deepClone(oldData[i], newData[i])
|
|
|
+ } else {
|
|
|
+ oldData[i] = newData[i]
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else if (newData instanceof Object) {
|
|
|
+ if (oldData.length > 0) {
|
|
|
+ oldData = {}
|
|
|
+ }
|
|
|
+ for (var key in newData) {
|
|
|
+ if (newData[key] instanceof Array) {
|
|
|
+ oldData[key] = new Array(newData[key].length)
|
|
|
+ this.deepClone(oldData[key], newData[key])
|
|
|
+ } else if (newData[key] instanceof Object) {
|
|
|
+ oldData[key] = {}
|
|
|
+ this.deepClone(oldData[key], newData[key])
|
|
|
+ } else {
|
|
|
+ oldData[key] = newData[key]
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ console.log('deepClone')
|
|
|
+ console.log(oldData)
|
|
|
+ },
|
|
|
+ showListLoading () {
|
|
|
+ this.listLoading = true
|
|
|
+ },
|
|
|
+ hideListLoading () {
|
|
|
+ this.listLoading = false
|
|
|
+ },
|
|
|
+ toogleExpand2 (row) {
|
|
|
+ let testCaseTable = this.$refs.testCaseTable
|
|
|
+ testCaseTable.toggleRowExpansion(row)
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+</script>
|
|
|
+
|
|
|
+<style scoped>
|
|
|
+ .filter-container {
|
|
|
+ margin-bottom: 4px;
|
|
|
+ padding-left: 6px;
|
|
|
+ }
|
|
|
+ .mini-margin {
|
|
|
+ margin-left: 6px;
|
|
|
+ margin-right: 6px;
|
|
|
+ }
|
|
|
+</style>
|
|
|
+<style>
|
|
|
+.el-table__expanded-cell {
|
|
|
+ background-color: #eee!important;
|
|
|
+}
|
|
|
+.el-table__expanded-cell:hover {
|
|
|
+ background-color: #eee!important;
|
|
|
+}
|
|
|
+</style>
|