Browse Source

测试库

master
陈裕财 4 years ago
parent
commit
adc38a671f
  1. 3
      src/router/routes_xm.js
  2. 51
      src/views/xm/core/xmTestCasedb/XmTestCasedbEdit.vue
  3. 318
      src/views/xm/core/xmTestCasedb/XmTestCasedbInfo.vue
  4. 53
      src/views/xm/core/xmTestCasedb/XmTestCasedbMng.vue
  5. 84
      src/views/xm/core/xmTestCasedb/XmTestCasedbRoute.vue

3
src/router/routes_xm.js

@ -38,6 +38,8 @@ export default {
},
hidden:true
},
{ path: '/xm/core/testCasedbRoute', component: _import('xm/core/xmTestCasedb/XmTestCasedbRoute'), name: 'XmTestCasedbRoute', meta: { title: '测试库管理' },hidden:true},
{
path: '/xm/core',
component: Layout,
@ -54,6 +56,7 @@ export default {
{ path: 'xmQuestion/XmQuestionMng', component: _import('xm/core/xmQuestion/XmQuestionMngRoute'), name: 'XmQuestionMng', meta: { title: '缺陷管理' }},
{ path: 'xmQuestion/XmQuestionMngMy', component: _import('xm/core/xmQuestion/XmQuestionMngMy'), name: 'XmQuestionMngMy', meta: { title: '我的缺陷' }},
{ path: 'xmTestCase/XmTestCaseMng', component: _import('xm/core/xmTestCase/XmTestCaseMng'), name: 'XmTestCaseMng', meta: { title: '测试设计' }},
{ path: 'xmTestCasedb/XmTestCasedbMng', component: _import('xm/core/xmTestCasedb/XmTestCasedbMng'), name: 'XmTestCasedbMng', meta: { title: '测试库管理' }},
//{ path: 'xmTestCaseExec/XmTestCaseExecMng', component: _import('xm/core/xmTestCaseExec/XmTestCaseExecMng'), name: 'XmTestCaseExecMng', meta: { title: '测试执行' }},
{ path: 'xmQuestion/XmQuestionDetailRoute', component: _import('xm/core/xmQuestion/XmQuestionDetailRoute'), name: 'XmQuestionDetailRoute', meta: { title: '缺陷明细' },hidden:true},

51
src/views/xm/core/xmTestCasedb/XmTestCasedbEdit.vue

@ -5,30 +5,26 @@
<el-row class="page-main" :style="{overflowX:'auto',height:maxTableHeight+'px'}" ref="table">
<!--编辑界面 XmTestCasedb 测试用例库-->
<el-form :model="editForm" label-width="120px" :rules="editFormRules" ref="editFormRef">
<el-form-item label="主键" prop="id">
<el-input v-model="editForm.id" placeholder="主键" :maxlength="50" @change="editSomeFields(editForm,'id',$event)"></el-input>
</el-form-item>
<el-form-item label="用例库名称" prop="name">
<el-input v-model="editForm.name" placeholder="用例库名称" :maxlength="255" @change="editSomeFields(editForm,'name',$event)"></el-input>
</el-form-item>
<el-form-item label="创建人" prop="cuserid">
<el-input v-model="editForm.cuserid" placeholder="创建人" :maxlength="50" @change="editSomeFields(editForm,'cuserid',$event)"></el-input>
<el-form-item label="测试库编号" prop="id">
<el-input v-if="opType=='add'" v-model="editForm.id" placeholder="测试库编号" :maxlength="50" @change="editSomeFields(editForm,'id',$event)"></el-input>
<div v-else>{{editForm.id}}</div>
</el-form-item>
<el-form-item label="产品名称" prop="productName">
<xm-product-select v-if="!xmProduct" style="display:inline;" :auto-select="false" :link-project-id="selProject?selProject.id:null" @row-click="onProductSelected" @clear="clearProduct"></xm-product-select>
<div v-else>{{editForm.productName}}</div>
</el-form-item>
<el-form-item label="创建人姓名" prop="cusername">
<el-input v-model="editForm.cusername" placeholder="创建人姓名" :maxlength="255" @change="editSomeFields(editForm,'cusername',$event)"></el-input>
<el-input v-if="opType=='add'" v-model="editForm.cusername" placeholder="创建人姓名" :maxlength="255" @change="editSomeFields(editForm,'cusername',$event)"></el-input>
<div v-else>{{editForm.cusername}}</div>
</el-form-item>
<el-form-item label="创建日期" prop="ctime">
<el-date-picker type="date" placeholder="选择日期" v-model="editForm.ctime" value-format="yyyy-MM-dd HH:mm:ss" format="yyyy-MM-dd"></el-date-picker>
</el-form-item>
<el-form-item label="归属机构编号" prop="cbranchId">
<el-input v-model="editForm.cbranchId" placeholder="归属机构编号" :maxlength="50" @change="editSomeFields(editForm,'cbranchId',$event)"></el-input>
</el-form-item>
<el-form-item label="产品编号" prop="productId">
<el-input v-model="editForm.productId" placeholder="产品编号" :maxlength="50" @change="editSomeFields(editForm,'productId',$event)"></el-input>
</el-form-item>
<el-form-item label="产品名称" prop="productName">
<el-input v-model="editForm.productName" placeholder="产品名称" :maxlength="255" @change="editSomeFields(editForm,'productName',$event)"></el-input>
</el-form-item>
{{editForm.ctime}}
</el-form-item>
</el-form>
</el-row>
@ -45,16 +41,17 @@
import { initDicts, addXmTestCasedb,editXmTestCasedb,editSomeFieldsXmTestCasedb } from '@/api/xm/core/xmTestCasedb';
import { mapGetters } from 'vuex'
import XmProductSelect from '@/views/xm/core/components/XmProductSelect';//
export default {
name:'xmTestCasedbEdit',
components: {
XmProductSelect,
},
computed: {
...mapGetters([ 'userInfo' ]),
},
props:['xmTestCasedb','visible','opType'],
props:['xmTestCasedb','visible','opType','xmProduct','selProject'],
watch: {
'xmTestCasedb':function( xmTestCasedb ) {
@ -131,7 +128,10 @@
if(this.opType=='edit'){
}else{
if(this.xmProduct && this.xmProduct.id){
this.editForm.productId=this.xmProduct.id
this.editForm.productName=this.xmProduct.productName
}
}
this.editFormBak={...this.editForm}
},
@ -154,6 +154,17 @@
}
}).catch((e)=>Object.assign(this.editForm,this.editFormBak))
},
clearProduct(){
this.editForm.productId=''
this.editForm.productName=''
},
onProductSelected(product){
this.editForm.productId=product.id
this.editForm.productName=product.productName
},
},//end method
mounted() {
this.$nextTick(() => {

318
src/views/xm/core/xmTestCasedb/XmTestCasedbInfo.vue

@ -0,0 +1,318 @@
<template>
<section class="page-container border padding">
<el-row>
<xm-product-select v-if="!xmProduct" style="display:inline;" :auto-select="false" :link-project-id="selProject?selProject.id:null" @row-click="onProductSelected" @clear="clearProduct"></xm-product-select>
<el-input v-model="filters.key" style="width: 20%;" placeholder="模糊查询"></el-input>
<el-button v-loading="load.list" :disabled="load.list==true" @click="searchXmTestCasedbs" icon="el-icon-search">查询</el-button>
<span style="float:right;">
<el-button type="primary" @click="showAdd" icon="el-icon-plus" plain> </el-button>
<el-button type="danger" v-loading="load.del" @click="batchDel" :disabled="this.sels.length===0 || load.del==true" icon="el-icon-delete" plain></el-button>
</span>
</el-row>
<el-row class="padding-top">
<!--列表 XmTestCasedb 测试用例库-->
<el-table ref="xmTestCasedbTable" :data="xmTestCasedbs" :height="maxTableHeight" @sort-change="sortChange" highlight-current-row v-loading="load.list" border @selection-change="selsChange" @row-click="rowClick" style="width: 100%;">
<el-table-column type="selection" width="55" show-overflow-tooltip fixed="left"></el-table-column>
<el-table-column sortable type="index" width="55" show-overflow-tooltip fixed="left"></el-table-column>
<!--
<el-table-column sortable prop="username" width="55" show-overflow-tooltip fixed="left">
<span class="cell-text"> {{scope.row.username}}} </span>
<span class="cell-bar"><el-input style="display:inline;" v-model="scope.row.username" placeholder="" @change="editSomeFields(scope.row,'username',$event)" :maxlength="22"></el-input></span>
</el-table-column>
-->
<el-table-column prop="name" label="用例库名称" min-width="120" show-overflow-tooltip>
<template slot-scope="scope">
<span><el-link @click="goCasedbInfo">{{scope.row.name}} </el-link> </span>
</template>
</el-table-column>
<el-table-column prop="productName" label="产品名称" min-width="120" show-overflow-tooltip>
<template slot-scope="scope">
<span> {{scope.row.productName}} </span>
</template>
</el-table-column>
<el-table-column prop="cusername" label="创建人" min-width="120" show-overflow-tooltip>
<template slot-scope="scope">
<span> {{scope.row.cusername}} </span>
</template>
</el-table-column>
<el-table-column prop="ctime" label="创建日期" min-width="120" show-overflow-tooltip>
<template slot-scope="scope">
<span> {{scope.row.ctime}} </span>
</template>
</el-table-column>
<el-table-column label="操作" width="180" fixed="right">
<template scope="scope">
<el-button type="primary" @click="showEdit( scope.row,scope.$index)" icon="el-icon-edit" plain></el-button>
<el-button type="danger" @click="handleDel(scope.row,scope.$index)" icon="el-icon-delete" plain></el-button>
</template>
</el-table-column>
</el-table>
<el-pagination layout="total, sizes, prev, pager, next" @current-change="handleCurrentChange" @size-change="handleSizeChange" :page-sizes="[10,20, 50, 100, 500]" :current-page="pageInfo.pageNum" :page-size="pageInfo.pageSize" :total="pageInfo.total" style="float:right;"></el-pagination>
</el-row>
<el-row>
<!--编辑 XmTestCasedb 测试用例库界面-->
<el-drawer title="编辑测试用例库" :visible.sync="editFormVisible" size="60%" append-to-body :close-on-click-modal="false">
<xm-test-casedb-edit op-type="edit" :xm-test-casedb="editForm" :visible="editFormVisible" @cancel="editFormVisible=false" @submit="afterEditSubmit"></xm-test-casedb-edit>
</el-drawer>
<!--新增 XmTestCasedb 测试用例库界面-->
<el-drawer title="新增测试用例库" :visible.sync="addFormVisible" size="60%" append-to-body :close-on-click-modal="false">
<xm-test-casedb-edit op-type="add" :visible="addFormVisible" @cancel="addFormVisible=false" @submit="afterAddSubmit"></xm-test-casedb-edit>
</el-drawer>
</el-row>
</section>
</template>
<script>
import util from '@/common/js/util';//
import config from '@/common/config';//
import { initDicts,listXmTestCasedb, delXmTestCasedb, batchDelXmTestCasedb,editSomeFieldsXmTestCasedb } from '@/api/xm/core/xmTestCasedb';
import XmTestCasedbEdit from './XmTestCasedbEdit';//
import { mapGetters } from 'vuex'
import XmProductSelect from '@/views/xm/core/components/XmProductSelect';//
export default {
name:'xmTestCasedbMng',
components: {
XmTestCasedbEdit,XmProductSelect,
},
props:['visible','xmProduct','selProject'],
computed: {
...mapGetters(['userInfo']),
},
watch:{
visible(val){
if(val==true){
this.initData();
this.searchXmTestCasedbs()
}
}
},
data() {
return {
filters: {
key: ''
},
xmTestCasedbs: [],//
pageInfo:{//
total:0,//0>0
pageSize:10,//
count:false,//
pageNum:1,//1
orderFields:[],// ['sex','student_id']
orderDirs:[]// asc,desc ['asc','desc']
},
load:{ list: false, edit: false, del: false, add: false },//...
sels: [],//
dicts:{
//sex: [{id:'1',name:''},{id:'2',name:''}]
},// params={categoryId:'all',itemCodes:['sex']} {sex: [{id:'1',name:''},{id:'2',name:''}]}
addFormVisible: false,//xmTestCasedb
addForm: {
id:'',name:'',cuserid:'',cusername:'',ctime:'',cbranchId:'',productId:'',productName:''
},
editFormVisible: false,//
editForm: {
id:'',name:'',cuserid:'',cusername:'',ctime:'',cbranchId:'',productId:'',productName:''
},
maxTableHeight:300,
}
},//end data
methods: {
...util,
handleSizeChange(pageSize) {
this.pageInfo.pageSize=pageSize;
this.getXmTestCasedbs();
},
handleCurrentChange(pageNum) {
this.pageInfo.pageNum = pageNum;
this.getXmTestCasedbs();
},
// obj.order=ascending/descending, asc/desc ; obj.prop=,
sortChange( obj ){
if(obj.order==null){
this.pageInfo.orderFields=[];
this.pageInfo.orderDirs=[];
}else{
var dir='asc';
if(obj.order=='ascending'){
dir='asc'
}else{
dir='desc';
}
this.pageInfo.orderFields=[util.toLine(obj.prop)];
this.pageInfo.orderDirs=[dir];
}
this.getXmTestCasedbs();
},
searchXmTestCasedbs(){
this.pageInfo.count=true;
this.getXmTestCasedbs();
},
// XmTestCasedb
getXmTestCasedbs() {
let params = {
pageSize: this.pageInfo.pageSize,
pageNum: this.pageInfo.pageNum,
total: this.pageInfo.total,
count:this.pageInfo.count
};
if(this.pageInfo.orderFields!=null && this.pageInfo.orderFields.length>0){
let orderBys=[];
for(var i=0;i<this.pageInfo.orderFields.length;i++){
orderBys.push(this.pageInfo.orderFields[i]+" "+this.pageInfo.orderDirs[i])
}
params.orderBy= orderBys.join(",")
}
if(this.filters.key){
params.key=this.filters.key
}
if(this.filters.product && this.filters.product.id){
params.productId=this.filters.product.id
}
this.load.list = true;
listXmTestCasedb(params).then((res) => {
var tips=res.data.tips;
if(tips.isOk){
this.pageInfo.total = res.data.total;
this.pageInfo.count=false;
this.xmTestCasedbs = res.data.data;
}else{
this.$notify({ position:'bottom-left',showClose:true, message: tips.msg, type: 'error' });
}
this.load.list = false;
}).catch( err => this.load.list = false );
},
// XmTestCasedb
showEdit: function ( row,index ) {
this.editFormVisible = true;
this.editForm = Object.assign({}, row);
},
// XmTestCasedb
showAdd: function () {
this.addFormVisible = true;
//this.addForm=Object.assign({}, this.editForm);
},
afterAddSubmit(){
this.addFormVisible=false;
this.pageInfo.count=true;
this.getXmTestCasedbs();
},
afterEditSubmit(){
this.editFormVisible=false;
},
//xmTestCasedb
selsChange: function (sels) {
this.sels = sels;
},
//xmTestCasedb
handleDel: function (row,index) {
this.$confirm('确认删除该记录吗?', '提示', {
type: 'warning'
}).then(() => {
this.load.del=true;
let params = { id:row.id };
delXmTestCasedb(params).then((res) => {
this.load.del=false;
var tips=res.data.tips;
if(tips.isOk){
this.searchXmTestCasedbs();
}
this.$notify({ position:'bottom-left', showClose:true, message: tips.msg, type: tips.isOk?'success':'error' });
}).catch( err => this.load.del=false );
});
},
//xmTestCasedb
batchDel: function () {
if(this.sels.length<=0){
return;
}
var params=this.sels.map(i=>{
return { id:i.id}
})
this.$confirm('确认删除选中记录吗?', '提示', {
type: 'warning'
}).then(() => {
this.load.del=true;
batchDelXmTestCasedb(params).then((res) => {
this.load.del=false;
var tips=res.data.tips;
if( tips.isOk ){
this.searchXmTestCasedbs();
}
this.$notify({ position:'bottom-left',showClose:true, message: tips.msg, type: tips.isOk?'success':'error'});
}).catch( err => this.load.del=false );
});
},
editSomeFields(row,fieldName,$event){
let params={};
if(this.sels.length>0){
if(!this.sels.some(k=> k.id==row.id)){
this.$notify({position:'bottom-left',showClose:true,message:'请编辑选中的行',type:'warning'})
Object.assign(this.editForm,this.editFormBak)
return;
}
params['ids']=this.sels.map(i=>i.id)
}else{
params['ids']=[row].map(i=>i.id)
}
params[fieldName]=$event
var func = editSomeFieldsXmTestCasedb
func(params).then(res=>{
let tips = res.data.tips;
if(tips.isOk){
if(this.sels.length>0){
this.searchXmTestCasedbs();
}
this.editFormBak=[...this.editForm]
}else{
Object.assign(this.editForm,this.editFormBak)
this.$notify({position:'bottom-left',showClose:true,message:tips.msg,type:tips.isOk?'success':'error'})
}
}).catch((e)=>Object.assign(this.editForm,this.editFormBak))
},
rowClick: function(row, event, column){
this.editForm=row
this.editFormBak={...row};
this.$emit('row-click',row, event, column);// @row-click="rowClick"
},
initData: function(){
this.filters.product=this.xmProduct
},
clearProduct(){
this.filters.product=null;
this.searchXmTestCasedbs();
},
onProductSelected(product){
this.filters.product=product;
this.searchXmTestCasedbs();
},
goCasedbInfo(row){
localStorage.setItem('xm-test-casedb-info',JSON.stringify(row));
this.$route.push({path:'/xm/core/testCasedbRoute',query:{id:row.id}})
}
},//end methods
mounted() {
this.$nextTick(() => {
initDicts(this);
this.initData()
this.searchXmTestCasedbs();
this.maxTableHeight = util.calcTableMaxHeight(this.$refs.xmTestCasedbTable.$el)
});
}
}
</script>
<style scoped>
</style>

53
src/views/xm/core/xmTestCasedb/XmTestCasedbMng.vue

@ -1,6 +1,7 @@
<template>
<section class="page-container border padding">
<el-row>
<xm-product-select v-if="!xmProduct" style="display:inline;" :auto-select="false" :link-project-id="selProject?selProject.id:null" @row-click="onProductSelected" @clear="clearProduct"></xm-product-select>
<el-input v-model="filters.key" style="width: 20%;" placeholder="模糊查询"></el-input>
<el-button v-loading="load.list" :disabled="load.list==true" @click="searchXmTestCasedbs" icon="el-icon-search">查询</el-button>
<span style="float:right;">
@ -19,18 +20,17 @@
<span class="cell-bar"><el-input style="display:inline;" v-model="scope.row.username" placeholder="" @change="editSomeFields(scope.row,'username',$event)" :maxlength="22"></el-input></span>
</el-table-column>
-->
<el-table-column prop="id" label="主键" min-width="120" show-overflow-tooltip fixed="left"></el-table-column>
<el-table-column prop="name" label="用例库名称" min-width="120" show-overflow-tooltip>
<el-table-column prop="name" label="用例库名称" min-width="120" show-overflow-tooltip>
<template slot-scope="scope">
<span> {{scope.row.name}} </span>
<span><el-link @click="goCasedbInfo(scope.row)">{{scope.row.name}} </el-link> </span>
</template>
</el-table-column>
<el-table-column prop="cuserid" label="创建人" min-width="120" show-overflow-tooltip>
<el-table-column prop="productName" label="产品名称" min-width="120" show-overflow-tooltip>
<template slot-scope="scope">
<span> {{scope.row.cuserid}} </span>
<span> {{scope.row.productName}} </span>
</template>
</el-table-column>
<el-table-column prop="cusername" label="创建人姓名" min-width="120" show-overflow-tooltip>
</el-table-column>
<el-table-column prop="cusername" label="创建人" min-width="120" show-overflow-tooltip>
<template slot-scope="scope">
<span> {{scope.row.cusername}} </span>
</template>
@ -39,22 +39,7 @@
<template slot-scope="scope">
<span> {{scope.row.ctime}} </span>
</template>
</el-table-column>
<el-table-column prop="cbranchId" label="归属机构编号" min-width="120" show-overflow-tooltip>
<template slot-scope="scope">
<span> {{scope.row.cbranchId}} </span>
</template>
</el-table-column>
<el-table-column prop="productId" label="产品编号" min-width="120" show-overflow-tooltip>
<template slot-scope="scope">
<span> {{scope.row.productId}} </span>
</template>
</el-table-column>
<el-table-column prop="productName" label="产品名称" min-width="120" show-overflow-tooltip>
<template slot-scope="scope">
<span> {{scope.row.productName}} </span>
</template>
</el-table-column>
</el-table-column>
<el-table-column label="操作" width="180" fixed="right">
<template scope="scope">
<el-button type="primary" @click="showEdit( scope.row,scope.$index)" icon="el-icon-edit" plain></el-button>
@ -85,13 +70,14 @@ import config from '@/common/config';//全局公共库
import { initDicts,listXmTestCasedb, delXmTestCasedb, batchDelXmTestCasedb,editSomeFieldsXmTestCasedb } from '@/api/xm/core/xmTestCasedb';
import XmTestCasedbEdit from './XmTestCasedbEdit';//
import { mapGetters } from 'vuex'
import XmProductSelect from '@/views/xm/core/components/XmProductSelect';//
export default {
name:'xmTestCasedbMng',
components: {
XmTestCasedbEdit,
XmTestCasedbEdit,XmProductSelect,
},
props:['visible'],
props:['visible','xmProduct','selProject'],
computed: {
...mapGetters(['userInfo']),
@ -187,6 +173,9 @@ export default {
if(this.filters.key){
params.key=this.filters.key
}
if(this.filters.product && this.filters.product.id){
params.productId=this.filters.product.id
}
this.load.list = true;
listXmTestCasedb(params).then((res) => {
@ -296,9 +285,21 @@ export default {
this.$emit('row-click',row, event, column);// @row-click="rowClick"
},
initData: function(){
this.filters.product=this.xmProduct
},
clearProduct(){
this.filters.product=null;
this.searchXmTestCasedbs();
},
onProductSelected(product){
this.filters.product=product;
this.searchXmTestCasedbs();
},
goCasedbInfo(row){
localStorage.setItem('xm-test-casedb-info',JSON.stringify(row));
this.$router.push({path:'/xm/core/testCasedbRoute',query:{id:row.id}})
}
},//end methods
mounted() {
this.$nextTick(() => {

84
src/views/xm/core/xmTestCasedb/XmTestCasedbRoute.vue

@ -0,0 +1,84 @@
<template>
<section>
<xm-test-casedb-info v-if="xmTestCasedb" :xm-test-casedb="xmTestCasedb" :visible="showInfo" @edit-fields="onEditFields"></xm-test-casedb-info>
</section>
</template>
<script>
import util from '@/common/js/util';//
import { listXmTestCasedb } from '@/api/xm/core/xmTestCasedb';
import { mapGetters } from 'vuex';
import XmTestCasedbInfo from './XmTestCasedbInfo'
export default {
computed: {
...mapGetters([
'userInfo','roles'
]),
},
watch:{
},
data() {
return {
xmTestCasedb:null,
showInfo:false,
}
},//end data
methods: {
initByQueryId(){
if(this.$route.query && this.$route.query.id){
var localStorageXmTestCasedb=localStorage.getItem("xm-test-casedb-info")
var xmTestCasedb=null;
if(localStorageXmTestCasedb && localStorageXmTestCasedb!='undefined'){
xmTestCasedb=JSON.parse(localStorageXmTestCasedb)
if(xmTestCasedb && xmTestCasedb.id==this.$route.query.id){
this.xmTestCasedb=xmTestCasedb
this.showInfo=true;
}else{
this.getXmTestCasedb(this.$route.query.id);
}
}else{
this.getXmTestCasedb(this.$route.query.id);
}
}
},
getXmTestCasedb(id){
listXmTestCasedb({id:id}).then(res=>{
var tips = res.data.tips;
if(tips.isOk){
this.xmTestCasedb=res.data.data[0]
localStorage.setItem("xm-test-casedb-info",JSON.stringify(this.xmTestCasedb))
this.showInfo=true;
}else{
}
})
},
onEditFields(row) {
Object.assign(this.xmTestCasedb, row);
localStorage.setItem("xm-test-casedb-info",JSON.stringify(this.xmTestCasedb))
this.$emit("edit-fields", row);
},
},//end methods
components: {
XmTestCasedbInfo,
//
},
activated(){
this.initByQueryId();
},
mounted() {
this.initByQueryId();
}
}
</script>
<style scoped>
</style>
Loading…
Cancel
Save