增加测试平台功能,系统设置,支持多个角色,分配菜单
This commit is contained in:
82
src/components/TestPlatform/DataFactory/BuilderEditor.vue
Normal file
82
src/components/TestPlatform/DataFactory/BuilderEditor.vue
Normal file
@@ -0,0 +1,82 @@
|
||||
<template>
|
||||
<div class="page-wrap">
|
||||
<page-section title="造数器编辑">
|
||||
<el-form :model="form" label-width="120px" size="small">
|
||||
<el-form-item label="项目ID">
|
||||
<el-input v-model="projectId" style="width: 200px;"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="名称">
|
||||
<el-input v-model="form.name"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="类型">
|
||||
<el-select v-model="form.builder_type">
|
||||
<el-option label="流程编排" :value="1"></el-option>
|
||||
<el-option label="SQL" :value="2"></el-option>
|
||||
<el-option label="脚本" :value="3"></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="描述">
|
||||
<el-input v-model="form.description" type="textarea" :rows="3"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="定义(JSON)">
|
||||
<el-input v-model="definitionText" type="textarea" :rows="14"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="输入Schema(JSON)">
|
||||
<el-input v-model="inputSchemaText" type="textarea" :rows="8"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" :loading="saving" @click="submitForm">保存</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</page-section>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import PageSection from '@/components/TestPlatform/common/PageSection'
|
||||
import { createBuilder } from '@/api/dataFactoryApi'
|
||||
|
||||
export default {
|
||||
name: 'BuilderEditor',
|
||||
components: { PageSection },
|
||||
data() {
|
||||
return {
|
||||
saving: false,
|
||||
projectId: this.$route.query.projectId || 1,
|
||||
definitionText: '{\n "steps": [],\n "output": {}\n}',
|
||||
inputSchemaText: '{\n "type": "object",\n "properties": {}\n}',
|
||||
form: {
|
||||
name: '',
|
||||
builder_type: 1,
|
||||
description: ''
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
submitForm() {
|
||||
let definition = {}
|
||||
let input_schema = {}
|
||||
try {
|
||||
definition = JSON.parse(this.definitionText || '{}')
|
||||
input_schema = JSON.parse(this.inputSchemaText || '{}')
|
||||
} catch (e) {
|
||||
this.$message({ type: 'error', message: 'JSON 格式错误' })
|
||||
return
|
||||
}
|
||||
this.saving = true
|
||||
createBuilder(this.projectId, Object.assign({}, this.form, { definition, input_schema })).then(() => {
|
||||
this.$message({ type: 'success', message: '造数器保存成功' })
|
||||
this.$router.push({ path: '/test-platform/data-factory/builders', query: { projectId: this.projectId } })
|
||||
}).finally(() => {
|
||||
this.saving = false
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.page-wrap {
|
||||
padding: 20px;
|
||||
}
|
||||
</style>
|
||||
100
src/components/TestPlatform/DataFactory/BuilderList.vue
Normal file
100
src/components/TestPlatform/DataFactory/BuilderList.vue
Normal file
@@ -0,0 +1,100 @@
|
||||
<template>
|
||||
<div class="page-wrap">
|
||||
<page-section title="造数工厂">
|
||||
<template slot="extra">
|
||||
<el-button type="primary" size="small" @click="goEditor()">新建造数器</el-button>
|
||||
<el-button size="small" @click="goTasks">任务历史</el-button>
|
||||
<el-button size="small" @click="goMock">Mock服务</el-button>
|
||||
</template>
|
||||
<el-form :inline="true" size="small">
|
||||
<el-form-item label="项目ID">
|
||||
<el-input v-model="projectId" style="width: 120px;"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" @click="fetchList">查询</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<el-table v-loading="loading" :data="tableData" border style="margin-top: 16px;">
|
||||
<el-table-column prop="name" label="名称" min-width="160"></el-table-column>
|
||||
<el-table-column prop="builder_type" label="类型" width="120"></el-table-column>
|
||||
<el-table-column prop="description" label="描述" min-width="220"></el-table-column>
|
||||
<el-table-column label="操作" width="240">
|
||||
<template slot-scope="scope">
|
||||
<el-button type="text" @click="goEditor(scope.row)">编辑</el-button>
|
||||
<el-button type="text" @click="execute(scope.row)">执行</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<div style="margin-top: 16px; text-align: right;">
|
||||
<el-pagination
|
||||
:current-page="pageNo"
|
||||
:page-size="pageSize"
|
||||
:page-sizes="[10, 20, 50, 100]"
|
||||
:total="total"
|
||||
layout="total, sizes, prev, pager, next, jumper"
|
||||
@size-change="handleSizeChange"
|
||||
@current-change="handleCurrentChange">
|
||||
</el-pagination>
|
||||
</div>
|
||||
</page-section>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import PageSection from '@/components/TestPlatform/common/PageSection'
|
||||
import { executeBuilder, getBuilderList } from '@/api/dataFactoryApi'
|
||||
|
||||
export default {
|
||||
name: 'BuilderList',
|
||||
components: { PageSection },
|
||||
data() {
|
||||
return {
|
||||
loading: false,
|
||||
projectId: this.$route.query.projectId || 1,
|
||||
tableData: []
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
fetchList() {
|
||||
this.loading = true
|
||||
getBuilderList(this.projectId, {
|
||||
pageNo: this.pageNo,
|
||||
pageSize: this.pageSize
|
||||
}).then(res => {
|
||||
const data = (res && res.data) || res || []
|
||||
this.tableData = data.items || data.list || data.data || data || []
|
||||
this.total = data.total || data.totalCount || this.tableData.length
|
||||
}).catch(() => {
|
||||
this.tableData = []
|
||||
this.total = 0
|
||||
}).finally(() => {
|
||||
this.loading = false
|
||||
})
|
||||
},
|
||||
goEditor(row) {
|
||||
this.$router.push({ path: '/test-platform/data-factory/editor', query: { projectId: this.projectId, builderId: row && row.id } })
|
||||
},
|
||||
goTasks() {
|
||||
this.$router.push({ path: '/test-platform/data-factory/tasks', query: { projectId: this.projectId } })
|
||||
},
|
||||
goMock() {
|
||||
this.$router.push({ path: '/test-platform/data-factory/mock', query: { projectId: this.projectId } })
|
||||
},
|
||||
execute(row) {
|
||||
executeBuilder(this.projectId, row.id, { params: { count: 1 }, async: true }).then(() => {
|
||||
this.$message({ type: 'success', message: '造数任务已提交' })
|
||||
})
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.fetchList()
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.page-wrap {
|
||||
padding: 20px;
|
||||
}
|
||||
</style>
|
||||
style>
|
||||
72
src/components/TestPlatform/DataFactory/MockService.vue
Normal file
72
src/components/TestPlatform/DataFactory/MockService.vue
Normal file
@@ -0,0 +1,72 @@
|
||||
<template>
|
||||
<div class="page-wrap">
|
||||
<page-section title="Mock 服务">
|
||||
<el-form :model="form" label-width="120px" size="small">
|
||||
<el-form-item label="项目ID">
|
||||
<el-input v-model="projectId" style="width: 200px;"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="Path">
|
||||
<el-input v-model="form.path"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="Method">
|
||||
<el-select v-model="form.method">
|
||||
<el-option label="GET" value="GET"></el-option>
|
||||
<el-option label="POST" value="POST"></el-option>
|
||||
<el-option label="PUT" value="PUT"></el-option>
|
||||
<el-option label="DELETE" value="DELETE"></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="状态码">
|
||||
<el-input v-model="form.status_code"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="延迟(ms)">
|
||||
<el-input v-model="form.delay_ms"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="响应体(JSON)">
|
||||
<el-input v-model="responseBodyText" type="textarea" :rows="10"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" :loading="saving" @click="submitForm">创建 Mock</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<el-alert v-if="mockUrl" :title="'Mock 地址:' + mockUrl" type="success" :closable="false"></el-alert>
|
||||
</page-section>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import PageSection from '@/components/TestPlatform/common/PageSection'
|
||||
|
||||
export default {
|
||||
name: 'MockService',
|
||||
components: { PageSection },
|
||||
data() {
|
||||
return {
|
||||
saving: false,
|
||||
mockUrl: '',
|
||||
projectId: this.$route.query.projectId || 1,
|
||||
responseBodyText: '{\n "code": 0,\n "message": "success"\n}',
|
||||
form: {
|
||||
path: '',
|
||||
method: 'POST',
|
||||
status_code: 200,
|
||||
delay_ms: 0
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
submitForm() {
|
||||
this.$message({
|
||||
type: 'warning',
|
||||
message: '当前后端未提供 Mock 服务接口,页面暂为占位状态'
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.page-wrap {
|
||||
padding: 20px;
|
||||
}
|
||||
</style>
|
||||
55
src/components/TestPlatform/DataFactory/TaskHistory.vue
Normal file
55
src/components/TestPlatform/DataFactory/TaskHistory.vue
Normal file
@@ -0,0 +1,55 @@
|
||||
<template>
|
||||
<div class="page-wrap">
|
||||
<page-section title="造数任务历史">
|
||||
<el-form :inline="true" size="small">
|
||||
<el-form-item label="项目ID">
|
||||
<el-input v-model="projectId" style="width: 120px;"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="任务ID">
|
||||
<el-input v-model="taskId" style="width: 160px;"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" @click="fetchStatus">查询状态</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<json-viewer :value="taskResult"></json-viewer>
|
||||
</page-section>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import PageSection from '@/components/TestPlatform/common/PageSection'
|
||||
import JsonViewer from '@/components/TestPlatform/common/JsonViewer'
|
||||
import { getDataTaskStatus } from '@/api/dataFactoryApi'
|
||||
|
||||
export default {
|
||||
name: 'TaskHistory',
|
||||
components: { PageSection, JsonViewer },
|
||||
data() {
|
||||
return {
|
||||
projectId: this.$route.query.projectId || 1,
|
||||
taskId: this.$route.query.taskId || '',
|
||||
taskResult: {}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
fetchStatus() {
|
||||
if (!this.taskId) {
|
||||
this.$message({ type: 'warning', message: '请输入任务ID' })
|
||||
return
|
||||
}
|
||||
getDataTaskStatus(this.projectId, this.taskId).then(res => {
|
||||
this.taskResult = (res && res.data) || res || {}
|
||||
}).catch(() => {
|
||||
this.taskResult = {}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.page-wrap {
|
||||
padding: 20px;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user