Procházet zdrojové kódy

add.还差生成完整用例并导出有点问题,需要调一下

chen xueyi před 2 roky
rodič
revize
3ce7714191
3 změnil soubory, kde provedl 30 přidání a 29 odebrání
  1. 8 9
      src/components/TCFinalList.vue
  2. 20 19
      src/components/TCList.vue
  3. 2 1
      src/pinia/docx.ts

+ 8 - 9
src/components/TCFinalList.vue

@@ -30,7 +30,7 @@ type testCase = {
      预期结果: String,
 }
 
-let tableData: testCase[] = []
+const tableData = ref<any>([])
 //生成完整测试用例
 const docxMessage = (index: number) => {
   itemIndex.value = index
@@ -69,13 +69,14 @@ function parse() {
     },
     data: data,
   };
-
+  //这里还有点问题
   axios(fullConfig)
       .then((response: AxiosResponse<any>) => {
         console.log(JSON.stringify(response.data.output));
         const parsedOutput = JSON.stringify(JSON.parse(response.data.output)).replace(/"```json\\n/g, '').replace(/\\n/g, '').replace(/\\/g, '').replace(/ /g,'');
         //Todo:更新table
-        tableData = parseTestCases(parsedOutput);
+        tableData.value = parseTestCases(parsedOutput);
+        console.log(tableData.value)
       })
       .catch((error: AxiosError<any>) => {
         console.log(error);
@@ -85,10 +86,10 @@ function parse() {
 }
 
 //解析后端传回的测试用例数据
-function parseTestCases(testCaseString: string): any[] {
+function parseTestCases(testCaseString: string) {
   const regex = /\{"编号":"([^"]*)","用例标题":"([^"]*)","前置条件":"([^"]*)","步骤描述":"([^"]*)","预期结果":"([^"]*)"\}/g;
   let match;
-
+  const res = ref<any>([])
   // 使用正则表达式循环查找匹配项
   while ((match = regex.exec(testCaseString)) !== null) {
 
@@ -100,7 +101,7 @@ function parseTestCases(testCaseString: string): any[] {
     const result = match[5];
 
     // 创建一个对象来保存用例信息,并添加到数组中
-    tableData.push({
+    res.value.push({
       编号: number,
       用例标题: title,
       前置条件: front,
@@ -108,9 +109,7 @@ function parseTestCases(testCaseString: string): any[] {
       预期结果:result
     });
   }
-
-
-  return tableData;
+  return res;
 }
 
 

+ 20 - 19
src/components/TCList.vue

@@ -25,9 +25,6 @@ onMounted(()=>{
 })
 
 
-type Action = {
-  description: String,
-}
 type docxList = {
   docxName: String,
   docxMessageList?: Array<object>
@@ -40,7 +37,10 @@ const textarea = ref('')
 
 //历史操作记录
 const actionList = ref<any>([]);
-actionList.value = useStore.DocxList[itemIndex.value].actionList
+
+// actionList.value = [{
+//   description: "操作记录"
+// }]
 
 interface InputVariable {
   name: string;
@@ -82,9 +82,9 @@ const docxMessage = (index: number) => {
 
 //细化用例
 const handleImproveButton = (p: { row: any }) => {
-  console.log(p.row);
-  let improve_id = p.row.id+1;
 
+  let improve_id = p.row.编号;
+  console.log(improve_id)
   //调接口
   const data: {
     inputVariables: InputVariable[];
@@ -121,10 +121,11 @@ const handleImproveButton = (p: { row: any }) => {
         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);
+        testCase.value = useStore.DocxList[itemIndex.value].docxMessageList;
         //更新操作记录
-        useStore.DocxList[itemIndex.value].actionList.push({
-          description: "细化用例"+improve_id
-        });
+        actionList.value.push({description: "细化用例"+improve_id});
+        useStore.DocxList[itemIndex.value].actionList = actionList;
+
       })
       .catch((error: AxiosError<any>) => {
         console.log(error);
@@ -134,7 +135,7 @@ const handleImproveButton = (p: { row: any }) => {
 // 删除用例
 const deteleList = (scope: { row: any }) => {
 
-  const delete_id = scope.row.id+1;
+  const delete_id = scope.row.编号;
   console.log(delete_id)
   const data: {
     inputVariables: InputVariable[];
@@ -172,10 +173,10 @@ const deteleList = (scope: { row: any }) => {
 
         //更新用例列表
         useStore.DocxList[itemIndex.value].docxMessageList = parseTestCases(parsedOutput);
+        testCase.value = useStore.DocxList[itemIndex.value].docxMessageList;
         //更新操作记录
-        useStore.DocxList[itemIndex.value].actionList.push({
-          description: "删除用例"+delete_id
-        });
+        actionList.value.push({description: "删除用例"+delete_id})
+        useStore.DocxList[itemIndex.value].actionList = actionList;
       })
       .catch((error: AxiosError<any>) => {
         console.log(error);
@@ -223,11 +224,10 @@ const addDocxList = () => {
           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);
+          testCase.value = useStore.DocxList[itemIndex.value].docxMessageList
           //更新操作记录
-
-          useStore.DocxList[itemIndex.value].actionList.push({
-            description: "添加用例"
-          });
+          actionList.value.push({description: "添加用例"})
+          useStore.DocxList[itemIndex.value].actionList = actionList;
           loadingInstance1.close()
           ElMessage({
             message: '添加成功',
@@ -331,8 +331,8 @@ function Showecharts() {
               </el-row>
               <el-col class="container">
                 <el-table :data="testCase" style="width: 100%" border>
-                  <el-table-column label="编号" prop="编号" width="80" />
-                  <el-table-column label="用例标题" prop="用例标题" min-width="200" />
+                  <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">
@@ -364,6 +364,7 @@ function Showecharts() {
         </div>
         <div class="timeline">
           <div class="header-Box">
+            <span>操作记录</span>
             <el-timeline>
               <el-timeline-item v-for="(activity, index) in actionList" :key="index" :timestamp="activity.time"
                 size=large>

+ 2 - 1
src/pinia/docx.ts

@@ -6,12 +6,13 @@ import { ElMessage } from 'element-plus'
 
 type Action = {
     description: String,
+
 }
 interface DocxList {
     docxName: String,
     docxMessageList?: Array<object>,
     time?:String,
-    actionList?: ref<Action[]>
+    actionList?: ref<Action[]>,
 }