| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528 |
- <script setup lang="ts">
- import { ref,onMounted} from "vue";
- import { useRouter } from 'vue-router';
- import { DocxList,Action,useDocxStore } from '../pinia/docx'
- import axios, {AxiosResponse, AxiosError, AxiosRequestConfig} from 'axios';
- import {ElLoading, ElMessage} from 'element-plus'
- import {TestCase,InputVariable} from './upload.vue'
- import * as echarts from 'echarts';
- import dayjs from 'dayjs'
- const useStore = useDocxStore()
- const token = 'sk-HcDTZ2PXVVKd7wkLBGhaf2S3YxZ5Jr7G7SBO974cZdQ='
- //关于路由
- const router = useRouter();
- const gotoLastPage = () => {
- router.push('/upload');
- };
- const gotoNextPage = () => {
- router.push('/tcFinalList');
- };
- onMounted(()=>{
- Showecharts()
- })
- const docxList = ref<DocxList[]>([])
- docxList.value = useStore.DocxList
- const itemIndex = ref(0)
- const textarea = ref('')
- //历史操作记录
- const actionList = ref<Action[]>([])
- console.log(useStore.DocxList[itemIndex.value])
- actionList.value = useStore.DocxList[itemIndex.value].actionList;
- console.log(actionList.value)
- useStore.DocxList[itemIndex.value].actionList.push({
- description: "测试",
- time: dayjs().format('YYYY-MM-DD HH:mm:ss')
- })
- console.log(useStore.DocxList[itemIndex.value].actionList)
- function parseOutput(output: string): any[] {
- const jsonIndex = output.indexOf("json")
- console.log(jsonIndex)
- const parsedOutput = output.substring(jsonIndex).replace(/json\\n/g, '').replace(/\\n/g, '').replace(/\\/g, '').replace(/ /g,'').replace(/```"/g,'');
- console.log(parsedOutput)
- const testCaseArray: TestCase[] = JSON.parse(parsedOutput) as TestCase[];
- console.log(testCaseArray)
- return testCaseArray;
- }
- const testCase = ref<any>([]);
- // 默认展示第一个列表
- testCase.value = useStore.DocxList[itemIndex.value].docxMessageList
- console.log(testCase.value)
- console.log(actionList.value)
- const docxMessage = (index: number) => {
- itemIndex.value = index
- testCase.value = useStore.DocxList[itemIndex.value].docxMessageList
- }
- //细化用例
- const handleImproveButton = (p: { row: any }) => {
- let improve_id = p.row.编号;
- console.log(improve_id)
- const loadingImprove = ElLoading.service({
- fullscreen: true,
- text: "细化用例 "+improve_id
- })
- //调接口
- const data: {
- inputVariables: InputVariable[];
- volumeName: string;
- } = {
- inputVariables: [
- {
- name: "testCaseId",
- value: improve_id,
- },
- {
- name: "conversationId",
- value: "7",
- },
- ],
- volumeName: "文字测试用例生成",
- };
- const config: AxiosRequestConfig = {
- method: 'post',
- url: 'http://47.120.7.208:8000/api/executions?versionId=13&isAsync=false',
- headers: {
- 'User-Agent': 'Apifox/1.0.0 (https://apifox.com)',
- 'Content-Type': 'application/json',
- 'Authorization': `Bearer ${token}`,
- },
- data: data,
- };
- axios(config)
- .then((response: AxiosResponse<any>) => {
- console.log(response.data.output);
- const output = JSON.stringify(JSON.parse(response.data.output))
- //更新用例列表
- useStore.DocxList[itemIndex.value].docxMessageList = parseOutput(output);
- testCase.value = useStore.DocxList[itemIndex.value].docxMessageList;
- //更新操作记录
- console.log(actionList.value)
- useStore.DocxList[itemIndex.value].actionList.push({
- description: "细化用例 "+improve_id,
- time: dayjs().format('YYYY-MM-DD HH:mm:ss')
- })
- console.log(useStore.DocxList[itemIndex.value].actionList)
- actionList.value = useStore.DocxList[itemIndex.value].actionList;
- console.log(actionList.value)
- loadingImprove.close()
- })
- .catch((error: AxiosError<any>) => {
- console.log(error);
- });
- };
- // 删除用例
- const deteleList = (scope: { row: any }) => {
- const delete_id = scope.row.编号;
- console.log(delete_id)
- const loadingDelete = ElLoading.service({
- fullscreen: true,
- text: "删除用例 "+delete_id
- })
- const data: {
- inputVariables: InputVariable[];
- volumeName: string;
- } = {
- inputVariables: [
- {
- name: "testCaseId",
- value: delete_id,
- },
- {
- name: "conversationId",
- value: "7",
- },
- ],
- volumeName: "文字测试用例生成",
- };
- const deleteConfig: AxiosRequestConfig = {
- method: 'post',
- url: 'http://47.120.7.208:8000/api/executions?versionId=14&isAsync=false',
- headers: {
- 'User-Agent': 'Apifox/1.0.0 (https://apifox.com)',
- 'Content-Type': 'application/json',
- 'Authorization': `Bearer ${token}`,
- },
- data: data,
- };
- axios(deleteConfig)
- .then((response: AxiosResponse<any>) => {
- console.log(response.data.output);
- const output = JSON.stringify(JSON.parse(response.data.output))
- //更新用例列表
- useStore.DocxList[itemIndex.value].docxMessageList = parseOutput(output);
- testCase.value = useStore.DocxList[itemIndex.value].docxMessageList;
- //更新操作记录
- useStore.DocxList[itemIndex.value].actionList.push({
- description: "删除用例 "+delete_id,
- time: dayjs().format('YYYY-MM-DD HH:mm:ss')
- })
- console.log(useStore.DocxList[itemIndex.value].actionList)
- actionList.value = useStore.DocxList[itemIndex.value].actionList;
- console.log(actionList.value)
- loadingDelete.close()
- })
- .catch((error: AxiosError<any>) => {
- console.log(error);
- });
- }
- //添加用例
- const addDocxList = () => {
- if (textarea.value !== '') {
- const loadingAdd = ElLoading.service({
- fullscreen: true,
- text: "增加内容生成用例中"
- })
- //调用接口
- const data: {
- inputVariables: InputVariable[];
- volumeName: string;
- } = {
- inputVariables: [
- {
- name: "testCaseToAdd",
- value: textarea.value,
- },
- {
- name: "conversationId",
- value: "7",
- },
- ],
- volumeName: "文字测试用例生成",
- };
- const addConfig: AxiosRequestConfig = {
- method: 'post',
- url: 'http://47.120.7.208:8000/api/executions?versionId=15&isAsync=false',
- headers: {
- 'User-Agent': 'Apifox/1.0.0 (https://apifox.com)',
- 'Content-Type': 'application/json',
- 'Authorization': `Bearer ${token}`,
- },
- data: data,
- };
- axios(addConfig)
- .then((response: AxiosResponse<any>) => {
- console.log(JSON.stringify(response.data));
- const output = JSON.stringify(JSON.parse(response.data.output))
- //更新用例列表
- useStore.DocxList[itemIndex.value].docxMessageList = parseOutput(output);
- testCase.value = useStore.DocxList[itemIndex.value].docxMessageList
- //更新操作记录
- useStore.DocxList[itemIndex.value].actionList.push({
- description: "添加用例 ",
- time: dayjs().format('YYYY-MM-DD HH:mm:ss')
- })
- console.log(useStore.DocxList[itemIndex.value].actionList)
- actionList.value = useStore.DocxList[itemIndex.value].actionList;
- console.log(actionList.value)
- loadingAdd.close()
- ElMessage({
- message: '添加成功',
- type: 'success'
- })
- textarea.value = ''
- })
- .catch((error: AxiosError<any>) => {
- console.log(error);
- });
- } else {
- ElMessage({
- message: '用例描述不能为空',
- type: 'error'
- })
- }
- }
- // echarts-bxo
- function Showecharts() {
- var chartDom = document.getElementById('pt');
- var myChart = echarts.init(chartDom);
- var option;
- option = {
- tooltip: {
- trigger: 'item'
- },
- legend: {
- top: '5%',
- left: 'center',
- textStyle:{
- fontSize:8
- }
- },
- series: [
- {
- name: 'Access From',
- type: 'pie',
- radius: ['40%', '70%'],
- avoidLabelOverlap: false,
- padAngle: 5,
- itemStyle: {
- borderRadius: 10
- },
- label: {
- show: false,
- position: 'center',
- fontSize:12
- },
- emphasis: {
- label: {
- show: true,
- fontSize: 40,
- fontWeight:700
- }
- },
- labelLine: {
- show: false
- },
- data: [
- { value:useStore.DocxList.length, name: '.docx文件'},
- {value:5,name:'.excel文件'},
- {value:6,name:'.ppd文件'}
- ]
- }
- ]
- };
- option && myChart.setOption(option);
- }
- </script>
- <template>
- <el-container>
- <el-aside width="200px" style="overflow: hidden; margin-right:20px;">
- <el-card style="width:100%; border:0;" body-style="padding:0; margin:0;">
- <template #header>
- <div class="card-header">
- <span>文件名</span>
- </div>
- </template>
- <div class="card-item" v-for="(item, index) in docxList" :key="index" @click="docxMessage(index)"
- :class="{ active: index == itemIndex }">
- {{ item.docxName }}
- </div>
- </el-card>
- </el-aside>
- <el-container>
- <el-main style="display:flex; overflow: hidden; margin:0; padding:0;">
- <div class="root">
- <el-card class="card">
- <el-scrollbar class="scrollbar">
- <el-row class="titleTagRow">
- <el-tag class="titleTag" type="primary" effect="light" size="large" round>当前用例列表</el-tag>
- </el-row>
- <el-col class="container">
- <el-table :data="testCase" style="width: 100%" border>
- <el-table-column label="编号" prop="编号" width="100" />
- <el-table-column label="用例标题" prop="用例标题" min-width="50" />
- <el-table-column show-overflow-tooltip label="简短描述" prop="描述" min-width="150" />
- <el-table-column width="60">
- <template #default="scope">
- <el-button type="primary" link size="small" @click="handleImproveButton(scope)">细化</el-button>
- </template>
- </el-table-column>
- <el-table-column width="60">
- <template #default="scope">
- <el-button type="primary" link size="small" @click="deteleList(scope)">删除</el-button>
- </template>
- </el-table-column>
- </el-table>
- </el-col>
- </el-scrollbar>
- <div class="Pop-upBox">
- </div>
- <el-row class="input-row">
- <div style="min-width: 400px; width: 100%;">
- <el-input v-model="textarea" style="min-width: 400px; width: 100%;" :rows="4" type="textarea"
- placeholder="请输入要补充的待测功能" />
- <div>
- <el-button type="primary" class="add-button" style="margin-top:2vw;"
- @click="addDocxList">增加</el-button>
- </div>
- </div>
- </el-row>
- </el-card>
- </div>
- <div class="timeline">
- <div class="header-Box">
- <span>操作记录</span>
- <el-timeline>
- <el-timeline-item v-for="(action, index) in actionList" :key="index" :timestamp="action.time"
- size=large>
- {{ action.description }}
- </el-timeline-item>
- </el-timeline>
- </div>
- <div class="charts-box">
- <div id="pt" style="width:100%; height:100%;"></div>
- </div>
- </div>
- </el-main>
- <el-footer>
- <div class="button-container">
- <el-button type="primary" class="custom-button" @click="gotoLastPage">上一步</el-button>
- <el-button type="primary" class="custom-button" @click="gotoNextPage">下一步</el-button>
- </div>
- </el-footer>
- </el-container>
- </el-container>
- </template>
- <style scoped>
- .button-container {
- margin-top: 2vw;
- display: flex;
- position: absolute;
- left: 50%;
- transform: translate(-50%);
- /* 让按钮之间的空间均匀分布 */
- }
- .custom-button {
- width: 100px;
- /* 设置按钮的宽度为相同的固定值 */
- }
- .input-row {
- padding: 1em 3em;
- display: flex;
- flex-wrap: nowrap;
- align-items: center;
- justify-content: center;
- }
- .add-button {
- margin: auto 2em;
- }
- .titleTag {
- height: 2em;
- width: 8em;
- margin-left: 3em;
- font-size: large;
- }
- .container {
- width: 60vw;
- padding: 1em 3em;
- }
- .rowContainer {
- display: flex;
- justify-content: center;
- margin: 1em 0;
- }
- .root {
- display: flex;
- justify-content: center;
- }
- .robotMessage {
- display: flex;
- flex-direction: row-reverse;
- align-items: flex-start;
- }
- .customerMessage {
- display: flex;
- flex-direction: row;
- align-items: flex-start;
- }
- .textArea {
- display: inline-block;
- width: 300px;
- }
- .card {
- margin: auto;
- }
- .scrollbar {
- height: 400px;
- width: fit-content;
- }
- .card-item {
- margin: 0;
- padding: 0;
- width: 100%;
- height: 10vh;
- line-height: 10vh;
- text-align: center;
- background-color: #fcfcfc;
- cursor: pointer;
- }
- .Pop-upBox {
- z-index: 999;
- position: absolute;
- }
- .active {
- background-color: #409eff;
- color: #fff;
- }
- .timeline {
- width: 30vw;
- height: 100vh;
- padding-top: 2%;
- }
- .header-Box {
- width: 100%;
- height: 45vh;
- overflow: hidden;
- overflow-y: auto;
- }
- .charts-box {
- width: 100%;
- height: 50vh;
- background-color:#fff;
- }
- /* 启用滚动条样式化,需要在浏览器设置中启用 */
- ::-webkit-scrollbar {
- width: 10px; /* 滚动条的宽度 */
- }
- /* 滚动条轨道 */
- ::-webkit-scrollbar-track {
- background: #f0f0f0; /* 滚动条轨道背景颜色 */
- }
- /* 滚动条滑块 */
- ::-webkit-scrollbar-thumb {
- background: #696969; /* 滚动条滑块颜色 */
- border-radius: 10px; /* 滑块边角弧度 */
- }
- /* 滑块悬停状态 */
- ::-webkit-scrollbar-thumb:hover {
- background: #555; /* 鼠标悬停在滑块上时的颜色 */
- }
- </style>
|