|
|
@@ -1,9 +1,10 @@
|
|
|
<script setup lang="ts">
|
|
|
import { ref,onMounted} from "vue";
|
|
|
import { useRouter } from 'vue-router';
|
|
|
-import { useDocxStore } from '../pinia/docx'
|
|
|
+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()
|
|
|
@@ -18,63 +19,42 @@ const gotoNextPage = () => {
|
|
|
router.push('/tcFinalList');
|
|
|
};
|
|
|
|
|
|
-
|
|
|
onMounted(()=>{
|
|
|
Showecharts()
|
|
|
-
|
|
|
})
|
|
|
|
|
|
-
|
|
|
-type docxList = {
|
|
|
- docxName: String,
|
|
|
- docxMessageList?: Array<object>
|
|
|
-}
|
|
|
-const docxList = ref<docxList[]>([])
|
|
|
+const docxList = ref<DocxList[]>([])
|
|
|
docxList.value = useStore.DocxList
|
|
|
const itemIndex = ref(0)
|
|
|
const textarea = ref('')
|
|
|
|
|
|
-
|
|
|
//历史操作记录
|
|
|
-const actionList = ref<any>([]);
|
|
|
-
|
|
|
-// actionList.value = [{
|
|
|
-// description: "操作记录"
|
|
|
-// }]
|
|
|
-
|
|
|
-interface InputVariable {
|
|
|
- name: string;
|
|
|
- value: string;
|
|
|
-}
|
|
|
+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')
|
|
|
+})
|
|
|
|
|
|
-function parseTestCases(testCaseString: string): any[] {
|
|
|
- const testCases: any[] = [];
|
|
|
- const regex = /\{"编号":"([^"]*)","用例标题":"([^"]*)","简短描述":"([^"]*)"\}/g;
|
|
|
- let match;
|
|
|
-
|
|
|
- // 使用正则表达式循环查找匹配项
|
|
|
- while ((match = regex.exec(testCaseString)) !== null) {
|
|
|
- // 提取编号、用例标题和简短描述
|
|
|
- const number = match[1];
|
|
|
- const title = match[2];
|
|
|
- const description = match[3];
|
|
|
-
|
|
|
- // 创建一个对象来保存用例信息,并添加到数组中
|
|
|
- testCases.push({
|
|
|
- 编号: number,
|
|
|
- 用例标题: title,
|
|
|
- 简短描述: description
|
|
|
- });
|
|
|
- }
|
|
|
|
|
|
- return testCases;
|
|
|
+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)
|
|
|
-
|
|
|
+console.log(testCase.value)
|
|
|
+console.log(actionList.value)
|
|
|
const docxMessage = (index: number) => {
|
|
|
itemIndex.value = index
|
|
|
testCase.value = useStore.DocxList[itemIndex.value].docxMessageList
|
|
|
@@ -85,6 +65,10 @@ 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[];
|
|
|
@@ -117,15 +101,20 @@ const handleImproveButton = (p: { row: any }) => {
|
|
|
axios(config)
|
|
|
.then((response: AxiosResponse<any>) => {
|
|
|
console.log(response.data.output);
|
|
|
- const output = response.data.output;
|
|
|
- const parsedOutput = JSON.stringify(JSON.parse(output)).replace(/"```json\\n/g, '').replace(/\\n/g, '').replace(/\\/g, '').replace(/ /g,'');
|
|
|
+ const output = JSON.stringify(JSON.parse(response.data.output))
|
|
|
//更新用例列表
|
|
|
- useStore.DocxList[itemIndex.value].docxMessageList = parseTestCases(parsedOutput);
|
|
|
+ useStore.DocxList[itemIndex.value].docxMessageList = parseOutput(output);
|
|
|
testCase.value = useStore.DocxList[itemIndex.value].docxMessageList;
|
|
|
//更新操作记录
|
|
|
- actionList.value.push({description: "细化用例"+improve_id});
|
|
|
- useStore.DocxList[itemIndex.value].actionList = actionList;
|
|
|
-
|
|
|
+ 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);
|
|
|
@@ -134,9 +123,12 @@ const handleImproveButton = (p: { row: any }) => {
|
|
|
|
|
|
// 删除用例
|
|
|
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;
|
|
|
@@ -168,15 +160,19 @@ const deteleList = (scope: { row: any }) => {
|
|
|
axios(deleteConfig)
|
|
|
.then((response: AxiosResponse<any>) => {
|
|
|
console.log(response.data.output);
|
|
|
- const output = response.data.output;
|
|
|
- const parsedOutput = JSON.stringify(JSON.parse(output)).replace(/"```json\\n/g, '').replace(/\\n/g, '').replace(/\\/g, '').replace(/ /g,'');
|
|
|
-
|
|
|
+ const output = JSON.stringify(JSON.parse(response.data.output))
|
|
|
//更新用例列表
|
|
|
- useStore.DocxList[itemIndex.value].docxMessageList = parseTestCases(parsedOutput);
|
|
|
+ useStore.DocxList[itemIndex.value].docxMessageList = parseOutput(output);
|
|
|
testCase.value = useStore.DocxList[itemIndex.value].docxMessageList;
|
|
|
//更新操作记录
|
|
|
- actionList.value.push({description: "删除用例"+delete_id})
|
|
|
- useStore.DocxList[itemIndex.value].actionList = actionList;
|
|
|
+ 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);
|
|
|
@@ -187,7 +183,10 @@ const deteleList = (scope: { row: any }) => {
|
|
|
//添加用例
|
|
|
const addDocxList = () => {
|
|
|
if (textarea.value !== '') {
|
|
|
- const loadingInstance1 = ElLoading.service({ fullscreen: true })
|
|
|
+ const loadingAdd = ElLoading.service({
|
|
|
+ fullscreen: true,
|
|
|
+ text: "增加内容生成用例中"
|
|
|
+ })
|
|
|
//调用接口
|
|
|
const data: {
|
|
|
inputVariables: InputVariable[];
|
|
|
@@ -220,15 +219,20 @@ const addDocxList = () => {
|
|
|
axios(addConfig)
|
|
|
.then((response: AxiosResponse<any>) => {
|
|
|
console.log(JSON.stringify(response.data));
|
|
|
- const output = response.data.output;
|
|
|
- const parsedOutput = JSON.stringify(JSON.parse(output)).replace(/"```json\\n/g, '').replace(/\\n/g, '').replace(/\\/g, '').replace(/ /g,'');
|
|
|
+ const output = JSON.stringify(JSON.parse(response.data.output))
|
|
|
+
|
|
|
//更新用例列表
|
|
|
- useStore.DocxList[itemIndex.value].docxMessageList = parseTestCases(parsedOutput);
|
|
|
+ useStore.DocxList[itemIndex.value].docxMessageList = parseOutput(output);
|
|
|
testCase.value = useStore.DocxList[itemIndex.value].docxMessageList
|
|
|
//更新操作记录
|
|
|
- actionList.value.push({description: "添加用例"})
|
|
|
- useStore.DocxList[itemIndex.value].actionList = actionList;
|
|
|
- loadingInstance1.close()
|
|
|
+ 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'
|
|
|
@@ -238,8 +242,6 @@ const addDocxList = () => {
|
|
|
.catch((error: AxiosError<any>) => {
|
|
|
console.log(error);
|
|
|
});
|
|
|
-
|
|
|
-
|
|
|
} else {
|
|
|
ElMessage({
|
|
|
message: '用例描述不能为空',
|
|
|
@@ -247,7 +249,6 @@ const addDocxList = () => {
|
|
|
})
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
// echarts-bxo
|
|
|
function Showecharts() {
|
|
|
var chartDom = document.getElementById('pt');
|
|
|
@@ -298,9 +299,7 @@ function Showecharts() {
|
|
|
}
|
|
|
]
|
|
|
};
|
|
|
-
|
|
|
option && myChart.setOption(option);
|
|
|
-
|
|
|
}
|
|
|
</script>
|
|
|
|
|
|
@@ -333,7 +332,7 @@ function Showecharts() {
|
|
|
<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 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>
|
|
|
@@ -366,9 +365,9 @@ function Showecharts() {
|
|
|
<div class="header-Box">
|
|
|
<span>操作记录</span>
|
|
|
<el-timeline>
|
|
|
- <el-timeline-item v-for="(activity, index) in actionList" :key="index" :timestamp="activity.time"
|
|
|
+ <el-timeline-item v-for="(action, index) in actionList" :key="index" :timestamp="action.time"
|
|
|
size=large>
|
|
|
- {{ activity.description }}
|
|
|
+ {{ action.description }}
|
|
|
</el-timeline-item>
|
|
|
</el-timeline>
|
|
|
</div>
|