|
|
@@ -3,8 +3,9 @@ import { ref,onMounted} from "vue";
|
|
|
import { useRouter } from 'vue-router';
|
|
|
import { useDocxStore } from '../pinia/docx'
|
|
|
import axios, {AxiosResponse, AxiosError, AxiosRequestConfig} from 'axios';
|
|
|
-import { ElMessage } from 'element-plus'
|
|
|
+import {ElLoading, ElMessage} from 'element-plus'
|
|
|
import * as echarts from 'echarts';
|
|
|
+import dayjs from 'dayjs'
|
|
|
const useStore = useDocxStore()
|
|
|
const token = 'sk-HcDTZ2PXVVKd7wkLBGhaf2S3YxZ5Jr7G7SBO974cZdQ='
|
|
|
|
|
|
@@ -24,6 +25,9 @@ onMounted(()=>{
|
|
|
})
|
|
|
|
|
|
|
|
|
+type Action = {
|
|
|
+ description: String,
|
|
|
+}
|
|
|
type docxList = {
|
|
|
docxName: String,
|
|
|
docxMessageList?: Array<object>
|
|
|
@@ -35,26 +39,37 @@ const textarea = ref('')
|
|
|
|
|
|
|
|
|
//历史操作记录
|
|
|
-type ActionList = {
|
|
|
- docxName: String;
|
|
|
- description: string;
|
|
|
- };
|
|
|
-
|
|
|
-const actionList = ref<ActionList[]>([]);
|
|
|
-actionList.value = [
|
|
|
- {
|
|
|
- docxName: "文件名",
|
|
|
- description: "操作记录",
|
|
|
-
|
|
|
-}
|
|
|
-];
|
|
|
-
|
|
|
+const actionList = ref<any>([]);
|
|
|
+actionList.value = useStore.DocxList[itemIndex.value].actionList
|
|
|
|
|
|
interface InputVariable {
|
|
|
name: string;
|
|
|
value: string;
|
|
|
}
|
|
|
|
|
|
+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;
|
|
|
+}
|
|
|
+
|
|
|
const testCase = ref<any>([]);
|
|
|
// 默认展示第一个列表
|
|
|
testCase.value = useStore.DocxList[itemIndex.value].docxMessageList
|
|
|
@@ -68,10 +83,9 @@ const docxMessage = (index: number) => {
|
|
|
//细化用例
|
|
|
const handleImproveButton = (p: { row: any }) => {
|
|
|
console.log(p.row);
|
|
|
- let improve_id = p.row.id;
|
|
|
+ let improve_id = p.row.id+1;
|
|
|
|
|
|
//调接口
|
|
|
-
|
|
|
const data: {
|
|
|
inputVariables: InputVariable[];
|
|
|
volumeName: string;
|
|
|
@@ -102,27 +116,26 @@ const handleImproveButton = (p: { row: any }) => {
|
|
|
|
|
|
axios(config)
|
|
|
.then((response: AxiosResponse<any>) => {
|
|
|
- console.log(JSON.stringify(response.data));
|
|
|
+ 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,'');
|
|
|
+ //更新用例列表
|
|
|
+ useStore.DocxList[itemIndex.value].docxMessageList = parseTestCases(parsedOutput);
|
|
|
+ //更新操作记录
|
|
|
+ useStore.DocxList[itemIndex.value].actionList.push({
|
|
|
+ description: "细化用例"+improve_id
|
|
|
+ });
|
|
|
})
|
|
|
.catch((error: AxiosError<any>) => {
|
|
|
console.log(error);
|
|
|
});
|
|
|
- //Todo:更新用例列表
|
|
|
-
|
|
|
- //更新操作记录
|
|
|
- actionList.value.push({
|
|
|
- docxName: useStore.DocxList[itemIndex.value].docxName,
|
|
|
- description: "细化用例"+improve_id,
|
|
|
- })
|
|
|
};
|
|
|
|
|
|
// 删除用例
|
|
|
-const deteleList = (scope: any) => {
|
|
|
- const obj: any = {
|
|
|
- id: scope.row.id,
|
|
|
- index: itemIndex.value
|
|
|
- }
|
|
|
- let delete_id = scope.row.id;
|
|
|
+const deteleList = (scope: { row: any }) => {
|
|
|
+
|
|
|
+ const delete_id = scope.row.id+1;
|
|
|
+ console.log(delete_id)
|
|
|
const data: {
|
|
|
inputVariables: InputVariable[];
|
|
|
volumeName: string;
|
|
|
@@ -153,25 +166,27 @@ const deteleList = (scope: any) => {
|
|
|
|
|
|
axios(deleteConfig)
|
|
|
.then((response: AxiosResponse<any>) => {
|
|
|
- console.log(JSON.stringify(response.data));
|
|
|
+ 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,'');
|
|
|
+
|
|
|
+ //更新用例列表
|
|
|
+ useStore.DocxList[itemIndex.value].docxMessageList = parseTestCases(parsedOutput);
|
|
|
+ //更新操作记录
|
|
|
+ useStore.DocxList[itemIndex.value].actionList.push({
|
|
|
+ description: "删除用例"+delete_id
|
|
|
+ });
|
|
|
})
|
|
|
.catch((error: AxiosError<any>) => {
|
|
|
console.log(error);
|
|
|
});
|
|
|
- //Todo:更新用例列表
|
|
|
- useStore.DeteleDocxList(obj)
|
|
|
- //更新操作列表
|
|
|
- actionList.value.push({
|
|
|
- docxName: useStore.DocxList[itemIndex.value].docxName,
|
|
|
- description: "删除用例"+delete_id,
|
|
|
-
|
|
|
- })
|
|
|
- testCase.value = useStore.DocxList[itemIndex.value].docxMessageList
|
|
|
+
|
|
|
}
|
|
|
|
|
|
//添加用例
|
|
|
const addDocxList = () => {
|
|
|
if (textarea.value !== '') {
|
|
|
+ const loadingInstance1 = ElLoading.service({ fullscreen: true })
|
|
|
//调用接口
|
|
|
const data: {
|
|
|
inputVariables: InputVariable[];
|
|
|
@@ -204,27 +219,27 @@ 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,'');
|
|
|
+ //更新用例列表
|
|
|
+ useStore.DocxList[itemIndex.value].docxMessageList = parseTestCases(parsedOutput);
|
|
|
+ //更新操作记录
|
|
|
+
|
|
|
+ useStore.DocxList[itemIndex.value].actionList.push({
|
|
|
+ description: "添加用例"
|
|
|
+ });
|
|
|
+ loadingInstance1.close()
|
|
|
+ ElMessage({
|
|
|
+ message: '添加成功',
|
|
|
+ type: 'success'
|
|
|
+ })
|
|
|
+ textarea.value = ''
|
|
|
})
|
|
|
.catch((error: AxiosError<any>) => {
|
|
|
console.log(error);
|
|
|
});
|
|
|
- //Todo:更新用例列表
|
|
|
- let new_id: any = useStore.DocxList[itemIndex.value].docxMessageList?.length+1
|
|
|
- useStore.DocxList[itemIndex.value].docxMessageList?.push({
|
|
|
- id: new_id,
|
|
|
- description: textarea.value
|
|
|
- })
|
|
|
- //更新操作列表
|
|
|
- actionList.value.push({
|
|
|
- docxName: useStore.DocxList[itemIndex.value].docxName,
|
|
|
- description: "新增用例"+new_id,
|
|
|
|
|
|
- })
|
|
|
- ElMessage({
|
|
|
- message: '添加成功',
|
|
|
- type: 'success'
|
|
|
- })
|
|
|
- textarea.value = ''
|
|
|
+
|
|
|
} else {
|
|
|
ElMessage({
|
|
|
message: '用例描述不能为空',
|
|
|
@@ -352,7 +367,7 @@ function Showecharts() {
|
|
|
<el-timeline>
|
|
|
<el-timeline-item v-for="(activity, index) in actionList" :key="index" :timestamp="activity.time"
|
|
|
size=large>
|
|
|
- {{ activity.docxName+"+"+activity.description }}
|
|
|
+ {{ activity.description }}
|
|
|
</el-timeline-item>
|
|
|
</el-timeline>
|
|
|
</div>
|