Commit 8cf764fe authored by 王晓铜's avatar 王晓铜

提交场景用例模块

parent 3f04c32f
...@@ -10,4 +10,5 @@ module.exports = merge(prodEnv, { ...@@ -10,4 +10,5 @@ module.exports = merge(prodEnv, {
// HOLMES: '"//localhost:8084"', // HOLMES: '"//localhost:8084"',
QA_PLATFORM: '"//qa-platform-fe.liangkebang.net/"', QA_PLATFORM: '"//qa-platform-fe.liangkebang.net/"',
HOLMES: '"//holmes-fe.liangkebang.net/"', HOLMES: '"//holmes-fe.liangkebang.net/"',
// HOLMES: '"//192.168.29.143:8084/"'
}) })
...@@ -11,9 +11,9 @@ module.exports = { ...@@ -11,9 +11,9 @@ module.exports = {
assetsSubDirectory: 'static', assetsSubDirectory: 'static',
assetsPublicPath: '/', assetsPublicPath: '/',
proxyTable: {}, proxyTable: {},
// Various Dev Server settings // Various Dev Server settings localhost
host: 'localhost', // can be overwritten by process.env.HOST host: '0.0.0.0', // can be overwritten by process.env.HOST
port: 8080, // can be overwritten by process.env.PORT, if port is in use, a free one will be determined port: 8080, // can be overwritten by process.env.PORT, if port is in use, a free one will be determined
autoOpenBrowser: false, autoOpenBrowser: false,
errorOverlay: true, errorOverlay: true,
......
...@@ -14006,6 +14006,11 @@ ...@@ -14006,6 +14006,11 @@
"is-plain-obj": "^1.0.0" "is-plain-obj": "^1.0.0"
} }
}, },
"sortablejs": {
"version": "1.13.0",
"resolved": "https://registry.npmjs.org/sortablejs/-/sortablejs-1.13.0.tgz",
"integrity": "sha512-RBJirPY0spWCrU5yCmWM1eFs/XgX2J5c6b275/YyxFRgnzPhKl/TDeU2hNR8Dt7ITq66NRPM4UlOt+e5O4CFHg=="
},
"source-list-map": { "source-list-map": {
"version": "2.0.1", "version": "2.0.1",
"resolved": "https://registry.npmjs.org/source-list-map/-/source-list-map-2.0.1.tgz", "resolved": "https://registry.npmjs.org/source-list-map/-/source-list-map-2.0.1.tgz",
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
"echarts": "^4.8.0", "echarts": "^4.8.0",
"element-ui": "^2.13.2", "element-ui": "^2.13.2",
"less": "^3.11.1", "less": "^3.11.1",
"sortablejs": "^1.13.0",
"vue": "^2.5.2", "vue": "^2.5.2",
"vue-bus": "^1.2.1", "vue-bus": "^1.2.1",
"vue-events": "^3.1.0", "vue-events": "^3.1.0",
......
...@@ -30,3 +30,19 @@ export function getSceneCaseList(queryInfo) { ...@@ -30,3 +30,19 @@ export function getSceneCaseList(queryInfo) {
params: queryInfo params: queryInfo
}) })
} }
// 添加场景用例接口
export function addSceneCase(data) {
return request({
url: '/auto/sceneTestcase/saveOrUpdate',
method: 'post',
data
})
}
// 执行场景用例接口
export function executeScene(queryInfo) {
return request({
url: '/auto/execute/scene',
method: 'get',
params: queryInfo
})
}
// The Vue build version to load with the `import` command // The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias. // (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue' import Vue from 'vue'
import VueBus from 'vue-bus'
import App from './App' import App from './App'
import '../src/assets/css/global.css' import '../src/assets/css/global.css'
import router from './router' import router from './router'
...@@ -10,6 +9,8 @@ import 'element-ui/lib/theme-chalk/index.css' ...@@ -10,6 +9,8 @@ import 'element-ui/lib/theme-chalk/index.css'
import axios from 'axios' import axios from 'axios'
import store from './store/store' import store from './store/store'
import JsonViewer from 'vue-json-viewer' import JsonViewer from 'vue-json-viewer'
import bus from '../src/utils/bus'
// import Sortable from 'sortablejs'
import { import {
Container, Container,
Header, Header,
...@@ -55,6 +56,7 @@ Vue.prototype.$echarts = echarts ...@@ -55,6 +56,7 @@ Vue.prototype.$echarts = echarts
Vue.prototype.$message = Message Vue.prototype.$message = Message
Vue.prototype.$loading = Loading Vue.prototype.$loading = Loading
Vue.prototype.$messageBox = MessageBox Vue.prototype.$messageBox = MessageBox
Vue.prototype.$bus = bus
// axios.defaults.baseURL = 'https://qa-platform-pre.liangkebang.net' // axios.defaults.baseURL = 'https://qa-platform-pre.liangkebang.net'
// axios.defaults.baseURL = 'http://localhost:8082' // axios.defaults.baseURL = 'http://localhost:8082'
...@@ -89,8 +91,8 @@ Vue.use(RadioGroup) ...@@ -89,8 +91,8 @@ Vue.use(RadioGroup)
Vue.use(Radio) Vue.use(Radio)
Vue.use(Row) Vue.use(Row)
Vue.use(Col) Vue.use(Col)
Vue.use(VueBus)
Vue.use(JsonViewer) Vue.use(JsonViewer)
// Vue.use(Sortable)
/* eslint-disable no-new */ /* eslint-disable no-new */
new Vue({ new Vue({
el: '#app', el: '#app',
......
...@@ -24,6 +24,7 @@ import CaseList from '../views/auto/CaseList' ...@@ -24,6 +24,7 @@ import CaseList from '../views/auto/CaseList'
import AddCase from '../views/auto/AddCase' import AddCase from '../views/auto/AddCase'
import SceneList from '../views/auto/SceneList' import SceneList from '../views/auto/SceneList'
import EditScene from '../views/auto/EditScene' import EditScene from '../views/auto/EditScene'
Vue.use(Router) Vue.use(Router)
const router = new Router({ const router = new Router({
mode: 'history', mode: 'history',
......
...@@ -202,7 +202,7 @@ ...@@ -202,7 +202,7 @@
<script> <script>
import { getModulList, interfaceDetailList } from '@/api/getAotoInterface' import { getModulList, interfaceDetailList } from '@/api/getAotoInterface'
import { getInterfaceDetail, addCase, editCase } from '@/api/getAutoCase' import { getInterfaceDetail, addCase, editCase } from '@/api/getAutoCase'
import bus from '@/utils/bus' // import bus from '@/utils/bus'
export default { export default {
data() { data() {
return { return {
...@@ -272,7 +272,7 @@ export default { ...@@ -272,7 +272,7 @@ export default {
}, },
created() { created() {
this.getModelList() this.getModelList()
bus.$on('casemsg', (row) => { this.$bus.$on('casemsg', (row) => {
// console.log('接收到的信息', row) // console.log('接收到的信息', row)
if (row !== null) { if (row !== null) {
if (row === '新增') { if (row === '新增') {
...@@ -455,8 +455,6 @@ export default { ...@@ -455,8 +455,6 @@ export default {
this.caseForm.extract = JSON.stringify(responseObj) this.caseForm.extract = JSON.stringify(responseObj)
// 断言 // 断言
this.caseForm.validate = JSON.stringify(this.assertionList) this.caseForm.validate = JSON.stringify(this.assertionList)
// console.log('保存信息', this.caseForm)
if (this.caseForm.id) { if (this.caseForm.id) {
// 编辑接口 // 编辑接口
editCase(this.caseForm).then((resp) => { editCase(this.caseForm).then((resp) => {
...@@ -484,12 +482,13 @@ export default { ...@@ -484,12 +482,13 @@ export default {
}) })
} }
}, },
// 刷新列表 // 刷新列表
sendResh() { sendResh() {
// bus使用 // bus使用
this.$nextTick(function () { this.$nextTick(function () {
// DOM 现在更新了 // DOM 现在更新了
bus.$emit('refresh') this.$bus.$emit('refresh')
}) })
} }
} }
......
...@@ -169,7 +169,7 @@ import { ...@@ -169,7 +169,7 @@ import {
addInterface, addInterface,
editInterface editInterface
} from '@/api/getAotoInterface' } from '@/api/getAotoInterface'
import bus from '@/utils/bus' // import bus from '@/utils/bus'
export default { export default {
data() { data() {
return { return {
...@@ -257,7 +257,7 @@ export default { ...@@ -257,7 +257,7 @@ export default {
} }
}, },
created() { created() {
bus.$on('msg', (row) => { this.$bus.$on('msg', (row) => {
if (row !== null) { if (row !== null) {
if (row === '新增') { if (row === '新增') {
this.interfaceForm.id = '' this.interfaceForm.id = ''
...@@ -356,7 +356,7 @@ export default { ...@@ -356,7 +356,7 @@ export default {
// bus使用 // bus使用
this.$nextTick(function () { this.$nextTick(function () {
// DOM 现在更新了 // DOM 现在更新了
bus.$emit('refresh') this.$bus.$emit('refresh')
}) })
}, },
// 保存接口信息 // 保存接口信息
......
...@@ -44,7 +44,7 @@ ...@@ -44,7 +44,7 @@
<script> <script>
import { getModulList } from '@/api/getAotoInterface' import { getModulList } from '@/api/getAotoInterface'
import { singleCaseList, delCase, executeCase } from '@/api/getAutoCase' import { singleCaseList, delCase, executeCase } from '@/api/getAutoCase'
import bus from '@/utils/bus' // import bus from '@/utils/bus'
export default { export default {
data() { data() {
return { return {
...@@ -77,7 +77,7 @@ export default { ...@@ -77,7 +77,7 @@ export default {
this.isShow = false this.isShow = false
this.getModulList() this.getModulList()
this.getCaseList() this.getCaseList()
bus.$on('refresh', () => { this.$bus.$on('refresh', () => {
this.isShow = false this.isShow = false
this.getCaseList() this.getCaseList()
}) })
...@@ -110,7 +110,7 @@ export default { ...@@ -110,7 +110,7 @@ export default {
this.$nextTick(function () { this.$nextTick(function () {
// DOM 现在更新了 // DOM 现在更新了
var row = '新增' var row = '新增'
bus.$emit('casemsg', row) this.$bus.$emit('casemsg', row)
}) })
}, },
// 执行用例 // 执行用例
...@@ -130,7 +130,7 @@ export default { ...@@ -130,7 +130,7 @@ export default {
// bus使用 // bus使用
this.$nextTick(function () { this.$nextTick(function () {
// DOM 现在更新了 // DOM 现在更新了
bus.$emit('casemsg', row) this.$bus.$emit('casemsg', row)
}) })
}, },
// 对话框方法 // 对话框方法
......
...@@ -11,12 +11,14 @@ ...@@ -11,12 +11,14 @@
</el-form-item> </el-form-item>
<el-form-item> <el-form-item>
<el-button type="success" plain @click="DialogVisible = true" class="el-icon-circle-plus">添加</el-button> <el-button type="success" plain @click="DialogVisible = true" class="el-icon-circle-plus">添加</el-button>
<el-table :data="sceneCaseList" border style="width: 100%;margin-top:20px">
<el-table-column type='index' width="50px"></el-table-column> <el-table :data="sceneTestcaseList" border style="width: 100%;margin-top:20px" row-key="sequence">
<el-table-column prop="moduleName" label="模块名称" width="200px"></el-table-column> <!-- <el-table-column prop='sequence' width="50px"></el-table-column> -->
<el-table-column prop="interfaceName" label="接口名称" width="200px"></el-table-column> <!-- <el-table-column type='index' width="50px"></el-table-column> -->
<!-- <el-table-column prop="createTime" label="创建时间" width="200px"></el-table-column> <!-- <el-table-column prop="moduleName" label="模块名称" width="200px"></el-table-column>
<el-table-column prop="updateTime" label="修改时间" width="200px"></el-table-column> --> <el-table-column prop="interfaceName" label="接口名称" width="200px"></el-table-column> -->
<el-table-column v-for="(item, index) in col" :key="`col_${index}`" :prop="col[index].prop" :label="item.label" align="center"></el-table-column>
<el-table-column label="操作"> <el-table-column label="操作">
<slot slot-scope="scope"> <slot slot-scope="scope">
<el-button type="success" @click="editeSceneFrom(scope.row)">编辑</el-button> <el-button type="success" @click="editeSceneFrom(scope.row)">编辑</el-button>
...@@ -26,26 +28,27 @@ ...@@ -26,26 +28,27 @@
</el-table> </el-table>
</el-form-item> </el-form-item>
<el-form-item> <el-form-item>
<div style="margin-left:500px;margin-top:20px"> <div style="margin-top:20px;float:right;margin-right:500px">
<el-button type="primary" @click="addSceneCaseFrom">确 定</el-button> <el-button type="primary" @click="addSceneCaseFrom">确 定</el-button>
</div> </div>
</el-form-item> </el-form-item>
</el-form> </el-form>
<!-- 添加场景用例 --> <!-- 添加场景用例 -->
<el-dialog title="新增场景用例" :visible.sync="DialogVisible" width="30%"> <el-dialog title="新增场景用例" :visible.sync="DialogVisible" width="30%">
<el-form :model="sceneCaseForm" label-width="90px"> <el-form :model="sceneCaseForm" label-width="90px">
<el-form-item label="模块名称:" style="width:300px"> <el-form-item label="模块名称:" style="width:300px">
<el-select v-model="moduleFrom" value-key="id" placeholder="请选择模块" @change="selectChangeModel" clearable> <el-select v-model="sceneCaseForm.moduleFrom" value-key="id" placeholder="请选择模块" @change="selectChangeModel" clearable>
<el-option v-for="item in modelList" :key="item.id" :label="item.name" :value="item"></el-option> <el-option v-for="item in modelList" :key="item.id" :label="item.name" :value="item"></el-option>
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item label="接口名称:" style="width:500px"> <el-form-item label="接口名称:" style="width:500px">
<el-select v-model="interfaceFrom" value-key="id" placeholder="请选择接口" @change="selectChangeInterface" clearable> <el-select v-model="sceneCaseForm.interfaceFrom" value-key="id" placeholder="请选择接口" @change="selectChangeInterface" clearable>
<el-option v-for="item in interfaceList" :key="item.id" :label="item.name" :value="item"></el-option> <el-option v-for="item in interfaceList" :key="item.id" :label="item.name" :value="item"></el-option>
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item> <el-form-item>
<el-table :data="caseList" border style="width: 100%;margin-left:1px" @selection-change="handleSelectionChange"> <el-table :data="sceneCaseForm.caseList" border style="width: 100%;margin-left:1px" @selection-change="handleSelectionChange">
<el-table-column type="selection" style="width:10%"> <el-table-column type="selection" style="width:10%">
</el-table-column> </el-table-column>
<el-table-column type='index' style="width:15%"></el-table-column> <el-table-column type='index' style="width:15%"></el-table-column>
...@@ -58,20 +61,214 @@ ...@@ -58,20 +61,214 @@
<el-button type="primary" @click="addSceneFrom">确 定</el-button> <el-button type="primary" @click="addSceneFrom">确 定</el-button>
</span> </span>
</el-dialog> </el-dialog>
<!-- 编辑场景用例 -->
<el-dialog title="编辑场景用例" :visible.sync="editDialogVisible" width="60%">
<el-card>
<el-form>
<!-- <el-form-item label="用例名称:" style="width:310px;">
<el-input v-model="caseForm.name" :disabled="true"></el-input>
</el-form-item> -->
<el-collapse v-model="activeNames">
<!-- Headers -->
<el-collapse-item name="1" title="请求头">
<el-button type="success" plain @click="AddHeaderListRow()" class="el-icon-circle-plus">添加行</el-button>
<el-form-item>
<el-row>
<el-col :span="6">
<div class="grid-content" style="margin-left:15px">参数名称</div>
</el-col>
<el-col :span="6">
<div class="grid-content" style="margin-left:15px">参数值</div>
</el-col>
<el-col :span="6">
<div class="grid-content" style="margin-left:25px">操作</div>
</el-col>
</el-row>
<el-row v-for="(item,index) in headersList" :key="index">
<el-col :span="6">
<div>
<el-input v-model.trim="item.paramsName" placeholder="请输入参数名称"></el-input>
</div>
</el-col>
<el-col :span="6">
<div>
<el-input v-model.trim="item.paramsValue" placeholder="请输入参数值"></el-input>
</div>
</el-col>
<el-col :span="6">
<div>
<el-button size="mini" type="danger" @click="advanceDelss(index)" style="height:40px;margin-left:20px">删除</el-button>
</div>
</el-col>
</el-row>
</el-form-item>
</el-collapse-item>
<!-- 请求参数 -->
<el-collapse-item name="2" title="请求参数">
<el-button type="success" plain @click="AddRequestParamsListRow()" class="el-icon-circle-plus">添加行</el-button>
<el-form-item>
<el-row>
<el-col :span="6">
<div class="grid-content" style="margin-left:15px">参数名称</div>
</el-col>
<el-col :span="6">
<div class="grid-content" style="margin-left:15px">参数值</div>
</el-col>
<el-col :span="6">
<div class="grid-content" style="margin-left:25px">操作</div>
</el-col>
</el-row>
<el-row v-for="(item,index) in requestParamsList" :key="index">
<el-col :span="6">
<div>
<el-input v-model.trim="item.paramsName" placeholder="请输入参数名称"></el-input>
</div>
</el-col>
<el-col :span="6">
<div>
<el-input v-model.trim="item.paramsValue" placeholder="请输入参数值"></el-input>
</div>
</el-col>
<el-col :span="6">
<div>
<el-button size="mini" type="danger" @click="requestParamsDel(index)" style="height:40px;margin-left:20px">删除</el-button>
</div>
</el-col>
</el-row>
</el-form-item>
</el-collapse-item>
<!-- 参数列表 -->
<el-collapse-item name="3" title="参数列表">
<el-button type="success" plain @click="AddParamsListRow()" class="el-icon-circle-plus">添加行</el-button>
<el-form-item>
<el-row>
<el-col :span="6">
<div class="grid-content" style="margin-left:15px">参数名称</div>
</el-col>
<el-col :span="6">
<div class="grid-content" style="margin-left:15px">参数值</div>
</el-col>
<el-col :span="6">
<div class="grid-content" style="margin-left:25px">操作</div>
</el-col>
</el-row>
<el-row v-for="(item,index) in paramsList" :key="index">
<el-col :span="6">
<div>
<el-input v-model.trim="item.paramsName" placeholder="请输入参数名称"></el-input>
</div>
</el-col>
<el-col :span="6">
<div>
<el-input v-model.trim="item.paramsValue" placeholder="请输入参数值"></el-input>
</div>
</el-col>
<el-col :span="6">
<div>
<el-button size="mini" type="danger" @click="paramsDel(index)" style="height:40px;margin-left:20px">删除</el-button>
</div>
</el-col>
</el-row>
</el-form-item>
</el-collapse-item>
<!-- 响应解析列表 -->
<el-collapse-item name="4" title="响应列表">
<el-button type="success" plain @click="AddResponseListRow()" class="el-icon-circle-plus">添加行</el-button>
<el-form-item>
<el-row>
<el-col :span="6">
<div class="grid-content" style="margin-left:15px">参数名称</div>
</el-col>
<el-col :span="6">
<div class="grid-content" style="margin-left:15px">参数值</div>
</el-col>
<el-col :span="6">
<div class="grid-content" style="margin-left:25px">操作</div>
</el-col>
</el-row>
<el-row v-for="(item,index) in responseList" :key="index">
<el-col :span="6">
<div>
<el-input v-model.trim="item.paramsName" placeholder="请输入参数名称"></el-input>
</div>
</el-col>
<el-col :span="6">
<div>
<el-input v-model.trim="item.paramsValue" placeholder="请输入参数值"></el-input>
</div>
</el-col>
<el-col :span="6">
<div>
<el-button size="mini" type="danger" @click="responeDel(index)" style="height:40px;margin-left:20px">删除</el-button>
</div>
</el-col>
</el-row>
</el-form-item>
</el-collapse-item>
<!-- 断言 -->
<el-collapse-item name="5" title="结果断言">
<el-button type="success" plain @click="AddAssertionListRow()" class="el-icon-circle-plus">添加行</el-button>
<el-table :data="assertionList" border style="width:100%;margin-top: 15px;">
<el-table-column label="参数名称" width="150">
<template slot-scope="scope">
<el-input v-model="scope.row.paramsName">
</el-input>
</template>
</el-table-column>
<el-table-column label="参数值" width="150">
<template slot-scope="scope">
<el-input v-model="scope.row.paramsValue">
</el-input>
</template>
</el-table-column>
<el-table-column label="是否必填" width="150" style="text-align:center">
<template slot-scope="scope">
<el-switch v-model="scope.row.isRequired" active-color="#13ce66" inactive-color="#A9A9A9" active-text="是" inactive-text="否" @change="changeState()"></el-switch>
</template>
</el-table-column>
<el-table-column label="示例" width="300">
<template slot-scope="scope">
<el-input v-model="scope.row.examples"></el-input>
</template>
</el-table-column>
<el-table-column label="备注" width="300">
<template slot-scope="scope">
<el-input v-model="scope.row.remarks"></el-input>
</template>
</el-table-column>
<el-table-column label="操作">
<template slot-scope="scope">
<el-button size="mini" type="danger" @click="AssertionDelete(scope.$index)">删除</el-button>
</template>
</el-table-column>
</el-table>
</el-collapse-item>
</el-collapse>
<div style="margin-top:20px;margin-left:400px">
<el-button @click="cancelCaseFrom">取 消</el-button>
<el-button type="primary" @click="addCaseFrom">确 定</el-button>
</div>
</el-form>
</el-card>
</el-dialog>
</div> </div>
</template> </template>
<script> <script>
import bus from '@/utils/bus'
import { import {
getProjectList, getProjectList,
getModulList, getModulList,
interfaceDetailList, interfaceDetailList,
getCaseByInterface getCaseByInterface
} from '@/api/getAotoInterface' } from '@/api/getAotoInterface'
import { getSceneCaseList } from '@/api/getAutoScene' import { getSceneCaseList, addSceneCase } from '@/api/getAutoScene'
import Sortable from 'sortablejs'
export default { export default {
data() { data() {
return { return {
col: [
{ label: '模块名称', prop: 'moduleName' },
{ label: '接口名称', prop: 'interfaceName' }
],
queryProjectList: { queryProjectList: {
pageNum: 1, pageNum: 1,
pageSize: 20 pageSize: 20
...@@ -97,8 +294,32 @@ export default { ...@@ -97,8 +294,32 @@ export default {
} }
] ]
}, },
sceneCaseForm: {}, sceneCaseForm: {
sceneCaseList: [], caseDetialList: [],
moduleName: '',
moduleId: '',
interfaceName: '',
interfaceId: '',
caseList: [],
moduleFrom: {
id: '',
name: ''
},
interfaceFrom: {
id: '',
name: ''
},
sequence: 0,
caseId: '',
caseName: '',
headers: '',
parameters: '',
variables: '',
extract: '',
validate: '',
sceneId: ''
},
sceneTestcaseList: [],
sceneCaseInfo: { sceneCaseInfo: {
sceneId: '' sceneId: ''
}, },
...@@ -117,30 +338,63 @@ export default { ...@@ -117,30 +338,63 @@ export default {
caseInfo: { caseInfo: {
interfaceId: '' interfaceId: ''
}, },
moduleFrom: {}, editDialogVisible: false,
interfaceFrom: {}, activeNames: '1',
caseList: [], headersList: [],
newFrom: { requestParamsList: [],
moduleName: '', paramsList: [],
moduleId: '', responseList: [],
interfaceName: '', assertionList: [],
caseForm: {
sceneId: '',
interfaceId: '', interfaceId: '',
caseDetialList: [] name: '',
headers: '',
parameters: '',
variables: '',
extract: '',
validate: '',
sequence: '',
caseId: '',
newInterfaceId: ''
},
newIndex: 0,
newCaseIndex: 0,
newSceneForm: {
sceneId: '',
sceneTestcaseList: []
} }
} }
}, },
created() { created() {
this.getProjectList() this.getProjectList()
bus.$on('scenemsg', (row) => { this.getModelList()
this.$bus.$off('scenemsg').$on('scenemsg', (row) => {
// console.log('参数信息', row) // console.log('参数信息', row)
this.sceneForm.name = row.name this.sceneForm.name = row.name
this.sceneForm.projectId = row.projectId this.sceneForm.projectId = row.projectId
this.sceneCaseInfo.sceneId = row.id this.sceneCaseInfo.sceneId = row.id
this.getSceneCaseList() this.getSceneCaseList()
this.rowDrop()
}) })
this.getModelList() },
mounted() {
this.rowDrop()
}, },
methods: { methods: {
rowDrop() {
const tbody = document.querySelector('.el-table__body-wrapper tbody')
const _this = this
Sortable.create(tbody, {
draggable: '.el-table__row',
onEnd({ newIndex, oldIndex }) {
// console.log('索引新', newIndex)
// console.log('索引旧', oldIndex)
const currRow = _this.sceneTestcaseList.splice(oldIndex, 1)[0]
_this.sceneTestcaseList.splice(newIndex, 0, currRow)
}
})
},
// 获取项目列表 // 获取项目列表
getProjectList() { getProjectList() {
getProjectList(this.queryProjectList).then((resp) => { getProjectList(this.queryProjectList).then((resp) => {
...@@ -150,7 +404,7 @@ export default { ...@@ -150,7 +404,7 @@ export default {
// 获取场景用例列表 // 获取场景用例列表
getSceneCaseList() { getSceneCaseList() {
getSceneCaseList(this.sceneCaseInfo).then((resp) => { getSceneCaseList(this.sceneCaseInfo).then((resp) => {
this.sceneCaseList = resp.data.data.list this.sceneTestcaseList = resp.data.data
}) })
}, },
// 获取模块列表 // 获取模块列表
...@@ -161,42 +415,250 @@ export default { ...@@ -161,42 +415,250 @@ export default {
}, },
// 模块下拉框改变事件 // 模块下拉框改变事件
selectChangeModel() { selectChangeModel() {
this.interfaceInfo.moduleId = this.moduleFrom.id this.interfaceInfo.moduleId = this.sceneCaseForm.moduleFrom.id
interfaceDetailList(this.interfaceInfo).then((resp) => { interfaceDetailList(this.interfaceInfo).then((resp) => {
this.interfaceList = resp.data.data.list this.interfaceList = resp.data.data.list
}) })
}, },
// 选择接口下拉框改变事件 // 选择接口下拉框改变事件
selectChangeInterface() { selectChangeInterface() {
this.caseInfo.interfaceId = this.interfaceFrom.id this.caseInfo.interfaceId = this.sceneCaseForm.interfaceFrom.id
getCaseByInterface(this.caseInfo).then((resp) => { getCaseByInterface(this.caseInfo).then((resp) => {
this.caseList = resp.data.data this.sceneCaseForm.caseList = resp.data.data
}) })
}, },
// 选择事件 // 选择事件
handleSelectionChange(row) { handleSelectionChange(row) {
this.newFrom.caseDetialList = row this.sceneCaseForm.caseDetialList = row
}, },
// 确定按钮 // 添加确定按钮
addSceneFrom() { addSceneFrom() {
this.newFrom.moduleId = this.moduleFrom.id this.sceneTestcaseList.push({
this.newFrom.moduleName = this.moduleFrom.name moduleName: this.sceneCaseForm.moduleFrom.name,
this.newFrom.interfaceId = this.interfaceFrom.id interfaceName: this.sceneCaseForm.interfaceFrom.name,
this.newFrom.interfaceName = this.interfaceFrom.name name: this.sceneCaseForm.caseDetialList[0].name,
console.log('列表信息', this.sceneCaseList) headers: this.sceneCaseForm.caseDetialList[0].headers,
// var newCaseList = [] parameters: this.sceneCaseForm.caseDetialList[0].parameters,
this.sceneCaseList.push({ variables: this.sceneCaseForm.caseDetialList[0].variables,
moduleName: this.newFrom.moduleName, extract: this.sceneCaseForm.caseDetialList[0].extract,
interfaceName: this.newFrom.interfaceName validate: this.sceneCaseForm.caseDetialList[0].validate,
}) id: this.sceneCaseForm.caseDetialList[0].id,
console.log('新列表信息', this.sceneCaseList) interfaceId: this.sceneCaseForm.caseDetialList[0].interfaceId,
sceneId: this.sceneCaseInfo.sceneId,
sequence: this.sceneTestcaseList.length + 1
})
console.log('save----', this.sceneTestcaseList)
this.DialogVisible = false this.DialogVisible = false
this.moduleFrom = '' this.sceneCaseForm.moduleFrom = ''
this.interfaceFrom = '' this.sceneCaseForm.interfaceFrom = ''
this.caseList = [] this.sceneCaseForm.caseList = []
},
// 编辑场景用例
editeSceneFrom(row) {
console.log('11', row)
this.editDialogVisible = true
this.sceneCaseForm.sequence = row.sequence
this.sceneCaseForm.interfaceId = row.interfaceId
this.sceneCaseForm.caseId = row.id
this.sceneCaseForm.caseName = row.name
var newHeaders = JSON.parse(row.headers)
// 请求头(将json字符串转化为对象)
this.headersList = []
for (var i in newHeaders) {
this.headersList.push({
paramsName: i,
paramsValue: newHeaders[i]
})
}
// 请求参数
var newParamters = JSON.parse(row.parameters)
this.requestParamsList = []
for (var j in newParamters) {
this.requestParamsList.push({
paramsName: j,
paramsValue: newParamters[j]
})
}
// 参数列表
var newVariables = JSON.parse(row.variables)
this.paramsList = []
for (var k in newVariables) {
this.paramsList.push({
paramsName: k,
paramsValue: newVariables[k]
})
}
// 响应解析列表
var newExtract = JSON.parse(row.extract)
this.responseList = []
for (var o in newExtract) {
this.responseList.push({
paramsName: o,
paramsValue: newExtract[o]
})
}
// 返回断言
this.assertionList = JSON.parse(row.validate)
}, },
// 保存场景用例方法 // 保存场景用例方法
addSceneCaseFrom() {} addSceneCaseFrom() {
var index = 1
this.sceneTestcaseList.forEach((item) => {
item.sequence = index
index += 1
})
this.newSceneForm.sceneId = this.sceneCaseInfo.sceneId
this.newSceneForm.sceneTestcaseList = this.sceneTestcaseList
addSceneCase(this.newSceneForm).then((resp) => {
if (resp.data.data === true) {
this.$message.success('保存成功!')
// 返回列表页
this.$router.push({ path: 'SceneList' })
// 刷新列表页
this.sendResh()
} else {
this.$message.error(resp.data.msg)
}
})
},
// 刷新列表
sendResh() {
// bus使用
this.$nextTick(function () {
// DOM 现在更新了
this.$bus.$emit('refreshScene')
})
},
// 添加Header行
AddHeaderListRow() {
this.headersList.push({
paramsName: '',
paramsValue: ''
})
},
// 删除Header行
advanceDelss(index) {
this.headersList.splice(index, 1)
},
// 添加请求参数行
AddRequestParamsListRow() {
this.requestParamsList.push({
paramsName: '',
paramsValue: ''
})
},
// 删除请求参数行
requestParamsDel(index) {
this.requestParamsList.splice(index, 1)
},
// 天机参数列表行
AddParamsListRow() {
this.paramsList.push({
paramsName: '',
paramsValue: ''
})
},
// 删除参数列表行
paramsDel(index) {
this.paramsList.splice(index, 1)
},
// 添加响应解析行
AddResponseListRow() {
this.responseList.push({
paramsName: '',
paramsValue: ''
})
},
// 删除响应解析行
responeDel(index) {
this.responseList.splice(index, 1)
},
// 添加断言行
AddAssertionListRow() {
this.assertionList.push({
paramsName: '',
paramsValue: '',
isRequired: true,
examples: '',
remarks: ''
})
},
// 断言改变
changeState(e) {
if (e === true) {
this.assertionList.isRequired = e
} else {
this.assertionList.isRequired = e
}
},
// 删除断言行
AssertionDelete(index) {
this.assertionList.splice(index, 1)
},
// 修改确定按钮
addCaseFrom() {
// 将数组重新赋值(将数组转化为对象)
var headersObj = {}
this.headersList.forEach((item) => {
headersObj[item.paramsName] = item.paramsValue
})
// 将对象转化为Json
this.sceneCaseForm.headers = JSON.stringify(headersObj)
// 请求参数
var requestParamsObj = {}
this.requestParamsList.forEach((item) => {
requestParamsObj[item.paramsName] = item.paramsValue
})
this.sceneCaseForm.parameters = JSON.stringify(requestParamsObj)
// 参数列表
var paramsListObj = {}
this.paramsList.forEach((item) => {
paramsListObj[item.paramsName] = item.paramsValue
})
this.sceneCaseForm.variables = JSON.stringify(paramsListObj)
// 响应解析列表
var responseObj = {}
this.responseList.forEach((item) => {
responseObj[item.paramsName] = item.paramsValue
})
this.sceneCaseForm.extract = JSON.stringify(responseObj)
// 断言
this.sceneCaseForm.validate = JSON.stringify(this.assertionList)
// 循环数组并删除对应的数组下标的整条数据信息
// for (var i = 0; i < this.sceneTestcaseList.length; i++) {
// if (
// this.sceneTestcaseList[i].sequence === this.sceneCaseForm.sequence
// ) {
// var moduleName = this.sceneTestcaseList[i].moduleName
// var interfaceName = this.sceneTestcaseList[i].interfaceName
// this.sceneTestcaseList.splice(i, 1)
// }
// }
for (var i = 0; i < this.sceneTestcaseList.length; i++) {
if (
this.sceneTestcaseList[i].sequence === this.sceneCaseForm.sequence
) {
this.sceneTestcaseList[i].headers = this.sceneCaseForm.headers
this.sceneTestcaseList[i].parameters = this.sceneCaseForm.parameters
this.sceneTestcaseList[i].variables = this.sceneCaseForm.variables
this.sceneTestcaseList[i].extract = this.sceneCaseForm.extract
this.sceneTestcaseList[i].validate = this.sceneCaseForm.validate
}
}
this.editDialogVisible = false
console.log('新集合信息', this.sceneTestcaseList)
},
cancelCaseFrom() {
this.editDialogVisible = false
},
// 删除场景用例
deleSceneFrom(row) {
for (var i = 0; i < this.sceneTestcaseList.length; i++) {
if (this.sceneTestcaseList[i].id === row.id) {
this.sceneTestcaseList.splice(i, 1)
}
}
}
} }
} }
</script> </script>
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
</el-pagination> </el-pagination>
</el-card> </el-card>
<!-- 新增页面 /编辑页面--> <!-- 新增页面 /编辑页面-->
<el-dialog title="新增项目" :visible.sync="DialogVisible" width="30%" @close="closeEditDialog"> <el-dialog title="新增项目" :visible.sync="DialogVisible" width="30%">
<el-form ref="projectForm" :rules="rules" :model="projectForm" label-width="90px"> <el-form ref="projectForm" :rules="rules" :model="projectForm" label-width="90px">
<el-form-item label="项目名称:" prop="name" style="width:400px"> <el-form-item label="项目名称:" prop="name" style="width:400px">
<el-input v-model="projectForm.name"></el-input> <el-input v-model="projectForm.name"></el-input>
......
...@@ -55,9 +55,13 @@ ...@@ -55,9 +55,13 @@
</div> </div>
</template> </template>
<script> <script>
import { getSceneList, addSecene, delSecne } from '@/api/getAutoScene' import {
getSceneList,
addSecene,
delSecne,
executeScene
} from '@/api/getAutoScene'
import { getProjectList } from '@/api/getAotoInterface' import { getProjectList } from '@/api/getAotoInterface'
import bus from '@/utils/bus'
export default { export default {
data() { data() {
return { return {
...@@ -97,13 +101,20 @@ export default { ...@@ -97,13 +101,20 @@ export default {
delSceneForm: { delSceneForm: {
sceneId: '' sceneId: ''
}, },
isShow: false, isShow: true,
requestData: '' requestData: '',
executeScene: {
sceneId: '',
namespace: ''
}
} }
}, },
created() { created() {
this.getSecneList() this.getSecneList()
this.getProjectList() this.getProjectList()
this.$bus.$on('refreshScene', () => {
this.getSecneList()
})
}, },
methods: { methods: {
// 获取场景列表 // 获取场景列表
...@@ -124,14 +135,26 @@ export default { ...@@ -124,14 +135,26 @@ export default {
this.getSecneList() this.getSecneList()
}, },
// 执行场景 // 执行场景
executeSceneFrom() {}, executeSceneFrom(row) {
// 获取用例id
this.executeScene.sceneId = row.id
this.executeScene.namespace = window.sessionStorage.getItem('env')
// this.isShow = true
executeScene(this.executeScene).then((resp) => {
console.log('接口返回结果', resp)
this.requestData = resp.data.data
})
},
// 编辑场景 // 编辑场景
editeSceneFrom(row) { editeSceneFrom(row) {
window.sessionStorage.setItem('curScene', JSON.stringify(row))
this.$router.push({ path: 'EditScene' }) this.$router.push({ path: 'EditScene' })
// this.$router.push({ path: 'tese' })
// bus使用 // bus使用
this.$nextTick(function () { this.$nextTick(function () {
// DOM 现在更新了 // DOM 现在更新了
bus.$emit('scenemsg', row)
this.$bus.$emit('scenemsg', row)
}) })
}, },
// 对话框方法 // 对话框方法
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment