Pārlūkot izejas kodu

添加了一些等待中的反馈提示

chen xueyi 2 gadi atpakaļ
vecāks
revīzija
baa2bac8b8

+ 7 - 0
components.d.ts

@@ -12,6 +12,7 @@ declare module 'vue' {
     ElCard: typeof import('element-plus/es')['ElCard']
     ElCol: typeof import('element-plus/es')['ElCol']
     ElContainer: typeof import('element-plus/es')['ElContainer']
+    ElDialog: typeof import('element-plus/es')['ElDialog']
     ElDivider: typeof import('element-plus/es')['ElDivider']
     ElDropdown: typeof import('element-plus/es')['ElDropdown']
     ElDropdownItem: typeof import('element-plus/es')['ElDropdownItem']
@@ -26,6 +27,9 @@ declare module 'vue' {
     ElMenu: typeof import('element-plus/es')['ElMenu']
     ElMenuItem: typeof import('element-plus/es')['ElMenuItem']
     ElMenuItemGroup: typeof import('element-plus/es')['ElMenuItemGroup']
+    ElPopconfirm: typeof import('element-plus/es')['ElPopconfirm']
+    ElRadio: typeof import('element-plus/es')['ElRadio']
+    ElRadioGroup: typeof import('element-plus/es')['ElRadioGroup']
     ElRow: typeof import('element-plus/es')['ElRow']
     ElScrollbar: typeof import('element-plus/es')['ElScrollbar']
     ElSubmenu: typeof import('element-plus/es')['ElSubmenu']
@@ -35,15 +39,18 @@ declare module 'vue' {
     ElTag: typeof import('element-plus/es')['ElTag']
     ElTimeline: typeof import('element-plus/es')['ElTimeline']
     ElTimelineItem: typeof import('element-plus/es')['ElTimelineItem']
+    ElUpload: typeof import('element-plus/es')['ElUpload']
     History: typeof import('./src/components/History.vue')['default']
     HistoryList: typeof import('./src/components/HistoryList.vue')['default']
     Home: typeof import('./src/components/Home.vue')['default']
     Layout: typeof import('./src/components/Layout.vue')['default']
     Login: typeof import('./src/components/Login.vue')['default']
     LoginView: typeof import('./src/components/Login.vue')['default']
+    MyPrompt: typeof import('./src/components/utils/MyPrompt.vue')['default']
     Register: typeof import('./src/components/Register.vue')['default']
     RouterLink: typeof import('vue-router')['RouterLink']
     RouterView: typeof import('vue-router')['RouterView']
+    Settings: typeof import('./src/components/Settings.vue')['default']
     TaskList: typeof import('./src/components/TaskList.vue')['default']
     TCFinalList: typeof import('./src/components/TCFinalList.vue')['default']
     TCList: typeof import('./src/components/TCList.vue')['default']

+ 0 - 0
src/api/users.ts


+ 6 - 2
src/components/Home.vue

@@ -17,7 +17,7 @@
         </el-header>
         <el-container>
           <!-- 侧边栏 -->
-          <el-aside :width="'200px'">
+          <el-aside :width="'200px'" >
             <!-- 侧边栏菜单区域 -->
             <!-- 侧边栏菜单区域 -->
             <el-menu
@@ -26,6 +26,7 @@
                 @open="handleOpen"
                 @close="handleClose"
                 router
+
             >
               <el-menu-item index="taskList" >
                 <el-icon><House /></el-icon>
@@ -41,7 +42,6 @@
                 <template #title>
                   <el-icon><Collection /></el-icon><span  style="font-size: large">当前任务列表</span>
                 </template>
-
                   <el-menu v-for="(item, index) in items" :key="index">
                     <el-sub-menu  v-if="item.tcFinalList.length===0" index="">
                       <template #title>{{ item.docxName }}</template>
@@ -54,6 +54,10 @@
                 <el-icon><Collection /></el-icon>
                 <span style="font-size: large">历史任务</span>
               </el-menu-item>
+              <el-menu-item index="settings">
+                <el-icon><Setting /></el-icon>
+                <span style="font-size: large">设置</span>
+              </el-menu-item>
             </el-menu>
           </el-aside>
           <!-- 右侧内容主体区域 -->

+ 60 - 0
src/components/Settings.vue

@@ -0,0 +1,60 @@
+<template>
+  <div  class="PrupBox">
+  <div class="radio-wrapper">
+    <label class="custom-radio">
+      <span class="radio-label">测试用例格式</span>
+      <el-radio-group v-model="radio1">
+        <el-radio value="1" size="large" border>文本</el-radio>
+        <el-radio value="2" size="large" border>代码</el-radio>
+      </el-radio-group>
+    </label>
+  </div>
+  <div class="radio-wrapper">
+    <label class="custom-radio">
+      <span class="radio-label">底层模型</span>
+      <el-radio-group v-model="radio1">
+        <el-radio value="1" size="large" border>glm</el-radio>
+        <el-radio value="2" size="large" border>通义千问</el-radio>
+      </el-radio-group>
+    </label>
+  </div>
+  </div>
+</template>
+
+<script lang="ts" setup>
+import {ref, onMounted, defineProps} from "vue";
+const radio1 = ref('1')
+</script>
+
+<style scoped>
+.custom-radio {
+  display: inline-block;
+  position: relative;
+  padding-bottom: 20px;
+  padding-top: 20px;
+}
+
+.radio-label {
+  position: absolute;
+  left: -100px; /* 根据实际情况调整距离 */
+  top: 30px; /* 根据实际对齐情况调整上下偏移 */
+  color: #606266; /* 文本颜色,根据你的设计调整 */
+  font-size: 14px; /* 文本大小,根据需要调整 */
+  white-space: nowrap; /* 防止文本换行 */
+  pointer-events: none; /* 确保点击提示词不会影响单选框的选择 */
+}
+
+.PrupBox {
+  z-index: 999;
+  position: absolute;
+  top: 50%;
+  left: 50%;
+  transform: translate(-50%, -50%);
+  width: 50%;
+  height: 50vh;
+  background-color: white;
+  border-radius: 10px;
+  border: 1px solid #efefef;
+}
+
+</style>

+ 6 - 4
src/components/TCList.vue

@@ -9,7 +9,7 @@ import * as echarts from 'echarts';
 import dayjs from 'dayjs'
 const useStore = useDocxStore()
 const token = 'sk-HcDTZ2PXVVKd7wkLBGhaf2S3YxZ5Jr7G7SBO974cZdQ='
-
+import { InfoFilled } from '@element-plus/icons-vue'
 //关于路由
 const router = useRouter();
 const route = useRoute();
@@ -502,9 +502,11 @@ const addDocxList = () => {
                     </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>
+                      <template #default="scope">
+                        <el-button type="primary" link size="small" @confirm="deteleList(scope)">删除</el-button>
+                      </template>
+
+
                   </el-table-column>
                 </el-table>
               </el-col>

+ 276 - 94
src/components/Upload.vue

@@ -4,16 +4,31 @@
 <!--    <transition name="el-fade-in-linear">-->
      <div  class="PrupBox">
         <el-form label-width="80px" style="max-width:350px; margin:0 auto; margin-top:5vw;">
-
           <el-form-item label="上传文件:" style="white-space: pre-wrap; ">
             <div class="boxjia" @click="uploadDocx">
-              <input ref='uploadInput' type="file" class="dl-none" name="icon" @change="dealfilechange"
+              <input ref='uploadInput' type="file" class="dl-none" name="icon" @change="upload"
                 style="display:none;" accept=".txt" multiple />
             </div>
           </el-form-item>
           <span>文件仅限txt格式<br/>这里应该还有点信息提示,暂时没想好写啥,或者配置</span>
-
         </el-form>
+       <el-dialog v-model="dialogTableVisible" title="信息确认" width=100% height=100%>
+         <el-form ref="formRef" label-width="80px" style="height: 100%">
+           <el-form-item label="需求文档">
+             <el-input type="textarea" v-model="fileContent"  ></el-input>
+           </el-form-item>
+           <el-form-item label="提示词">
+             <el-input type="textarea" v-model="tip"></el-input>
+           </el-form-item>
+         </el-form>
+         <template #footer>
+           <div class="dialog-footer">
+             <el-button type="primary" @click="dealFile">
+               确认
+             </el-button>
+           </div>
+         </template>
+       </el-dialog>
      </div>
 
     <el-container>
@@ -31,21 +46,26 @@
 import dayjs from 'dayjs'
 import { ArrowRight } from '@element-plus/icons-vue';
 import { useRouter } from 'vue-router';
-import { ref } from 'vue'
+import {reactive, ref} from 'vue'
 import { useDocxStore } from '../pinia/docx'
-import { ElMessage } from 'element-plus';
+import { ElMessage , ElMessageBox } from 'element-plus';
 import { ElLoading } from 'element-plus'
 import axios, {AxiosError, AxiosRequestConfig, AxiosResponse} from "axios";
 import FormData from 'form-data';
 
+
 const useStore = useDocxStore()
 
 const router = useRouter()
 const uploadInput = ref<HTMLDivElement | null>(null);
 
-const showBox = ref(false)
-const token = 'sk-HcDTZ2PXVVKd7wkLBGhaf2S3YxZ5Jr7G7SBO974cZdQ='
 
+const token = 'sk-HcDTZ2PXVVKd7wkLBGhaf2S3YxZ5Jr7G7SBO974cZdQ='
+const dialogTableVisible = ref(false)
+const formData = ref({
+  input1: '',
+  input2: '',
+});
 
 export interface InputVariable {
   name: string;
@@ -58,10 +78,164 @@ export interface TestCase {
   描述: string;
 };
 
+const fileContent = ref("")
+const tip = ref("你是一位经验丰富的测试用例编写人员,请识别该需求文档中可能包含的全部测试用例,给出测试用例列表(包含编号、用例标题和对应的简短描述),结果以json格式返回。")
+const upload = async (event: Event) =>{
+  const target = event.target as HTMLInputElement;
+  const files = target.files;
+
+  if (files && files.length > 0) {
+    for (let i = 0; i < files.length; i++) {
+      const file = files[i];
+      // 检查文件扩展名是否以 .txt 结尾
+      const fileExtension = file.name.toLowerCase().split('.').pop();
+      if (fileExtension === 'txt') {
+        console.log(file);
+        //调用上传接口
+        const data = new FormData()
+        data.append('file', file)
+        fileContent.value = (await file.text()).toString()
+        console.log(fileContent.value)
+
+        const uploadConfig: AxiosRequestConfig = {
+          method: 'put',
+          url: 'http://47.120.7.208:8000/api/volumes/2/files?path=.',
+          headers: {
+            'User-Agent': 'Apifox/1.0.0 (https://apifox.com)',
+            ...data.getHeaders ? data.getHeaders() : {'Content-Type': 'multipart/form-data'},
+            'Authorization': `Bearer ${token}`,
+          },
+          data: data,
+        };
 
+        axios(uploadConfig)
+            .then((uploadResponse: AxiosResponse<any>) => {
+              let file_id = uploadResponse.data.id;
+              console.log(file_id);
+              console.log(JSON.stringify(uploadResponse.data));
+              ElMessage({
+                message: '上传文件成功,请确认本次任务信息',
+                type: 'success'
+              });
+
+              dialogTableVisible.value = true
+            })
+      }else {
+        ElMessage({
+          message: '请上传.txt文件',
+          type: 'warning'
+        })
+      }
+    }
+  } else {
+    ElMessage({
+      message: '你还没有选择文件',
+      type: 'error'
+    })
+  }
+}
+
+function dealFile(){
+  dialogTableVisible.value = false;
+  const loadingInstance1 = ElLoading.service({
+    fullscreen: true,
+    text: "生成测试用例中"
+  })
+
+  // const data2: {
+  //   inputVariables: InputVariable[];
+  //   volumeName: string;
+  // } = {
+  //   inputVariables: [
+  //     {
+  //       name: "filePath",
+  //       value: file.name,
+  //     },
+  //     {
+  //       name: "conversationId",
+  //       value: "7",
+  //     },
+  //   ],
+  //   volumeName: "文字测试用例生成",
+  // };
+  //
+  // const processConfig: axios.AxiosRequestConfig = {
+  //   method: 'post',
+  //   url: 'http://47.120.7.208:8000/api/executions?versionId=12&isAsync=false',
+  //   headers: {
+  //     'User-Agent': 'Apifox/1.0.0 (https://apifox.com)',
+  //     'Content-Type': 'application/json',
+  //     'Authorization': `Bearer ${token}`,
+  //   },
+  //   data: data2,
+  // };
+  //
+  // const action = [{description: "生成用例",times: dayjs().format('YYYY-MM-DD HH:mm:ss')}]
+  // axios(processConfig)
+  //      .then((response) => {
+  //        console.log(response.data.output)
+  //        const output = JSON.stringify(JSON.parse(response.data.output))
+  //        const leftIndex = output.indexOf("[")
+  //        const rightIndex = output.indexOf("]")
+  //
+  //        const parsedOutput = output.substring(leftIndex,rightIndex+1).replace(/\\n/g, '').replace(/\\/g, '').replace(/ /g,'')
+  //
+  //        console.log(parsedOutput)
+  //        const testCaseArray = JSON.parse(parsedOutput);
+  //        console.log(testCaseArray)
+  //        useStore.DocxList.push({docxName: file.name, docxMessageList: testCaseArray, time: dayjs().format('YYYY-MM-DD HH:mm:ss'), actionList: action, testCaseList: []})
+  //        //持久化存储
+  //        useStore.saveDocxList()
+  //        //添加进数据库
+  //        axios({
+  //          url: "http://localhost:8081/testCaseList/add",               // 请求地址
+  //          method: "post",                       // 请求方法
+  //          headers: {                            // 请求头
+  //            "Content-Type": "application/json",
+  //          },
+  //          data: {                             // 请求参数
+  //            userId: Number(useStore.userInfo.user_id),
+  //            creatTime: dayjs().format('YYYY-MM-DD HH:mm:ss'),
+  //            docxName: file.name,
+  //            testCaseList: parsedOutput,
+  //            actionList: JSON.stringify(action)
+  //          },
+  //        }).then((res) => {
+  //          if(res.data.msg !== "添加成功!"){
+  //            ElMessage({
+  //              message: '数据库出错',
+  //              type: 'warning'
+  //            });
+  //          }else{
+  //            axios({
+  //              url: "http://localhost:8081/testCaseList/testList",               // 请求地址
+  //              method: "post",                       // 请求方法
+  //              headers: {                            // 请求头
+  //                "Content-Type": "application/json",
+  //              },
+  //              params: {                             // 请求参数
+  //                user_id: Number(useStore.userInfo.user_id)
+  //              },
+  //            }).then((res) => {
+  //              localStorage.setItem("taskList", JSON.stringify(res.data.data));
+  //
+  //            });
+  //          }
+  //        });
+  loadingInstance1.close()
+  ElMessage({
+    message: '测试用例已生成,即将跳转',
+    type: 'success'
+  });
+  // })
+  // .catch((error) => {
+  //   console.log(error);
+  // });
+}
 const dealfilechange = async (event: Event) => {
   const target = event.target as HTMLInputElement;
   const files = target.files;
+
   if (files && files.length > 0) {
     for (let i = 0; i < files.length; i++) {
       const file = files[i];
@@ -72,6 +246,10 @@ const dealfilechange = async (event: Event) => {
         //调用上传接口
         const data = new FormData()
         data.append('file',file)
+        fileContent.value = (await file.text()).toString()
+        console.log(fileContent.value)
+
+        dialogTableVisible.value = true
         const uploadConfig: AxiosRequestConfig = {
           method: 'put',
           url: 'http://47.120.7.208:8000/api/volumes/2/files?path=.',
@@ -89,102 +267,104 @@ const dealfilechange = async (event: Event) => {
               console.log(file_id);
               console.log(JSON.stringify(uploadResponse.data));
               // 上传文件成功,现在可以调用处理接口
+
               const loadingInstance1 = ElLoading.service({
                 fullscreen: true,
                 text: file.name + " 生成测试用例中"
               })
-              const data2: {
-                inputVariables: InputVariable[];
-                volumeName: string;
-              } = {
-                inputVariables: [
-                  {
-                    name: "filePath",
-                    value: file.name,
-                  },
-                  {
-                    name: "conversationId",
-                    value: "7",
-                  },
-                ],
-                volumeName: "文字测试用例生成",
-              };
-
-              const processConfig: axios.AxiosRequestConfig = {
-                method: 'post',
-                url: 'http://47.120.7.208:8000/api/executions?versionId=12&isAsync=false',
-                headers: {
-                  'User-Agent': 'Apifox/1.0.0 (https://apifox.com)',
-                  'Content-Type': 'application/json',
-                  'Authorization': `Bearer ${token}`,
-                },
-                data: data2,
-              };
-
-              const action = [{description: "生成用例",times: dayjs().format('YYYY-MM-DD HH:mm:ss')}]
-              axios(processConfig)
-                   .then((response) => {
-                     console.log(response.data.output)
-                     const output = JSON.stringify(JSON.parse(response.data.output))
-                     const leftIndex = output.indexOf("[")
-                     const rightIndex = output.indexOf("]")
-
-                     const parsedOutput = output.substring(leftIndex,rightIndex+1).replace(/\\n/g, '').replace(/\\/g, '').replace(/ /g,'')
-
-                     console.log(parsedOutput)
-                     const testCaseArray = JSON.parse(parsedOutput);
-                     console.log(testCaseArray)
-                     useStore.DocxList.push({docxName: file.name, docxMessageList: testCaseArray, time: dayjs().format('YYYY-MM-DD HH:mm:ss'), actionList: action, testCaseList: []})
-                     //持久化存储
-                     useStore.saveDocxList()
-                     //添加进数据库
-                     axios({
-                       url: "http://localhost:8081/testCaseList/add",               // 请求地址
-                       method: "post",                       // 请求方法
-                       headers: {                            // 请求头
-                         "Content-Type": "application/json",
-                       },
-                       data: {                             // 请求参数
-                         userId: Number(useStore.userInfo.user_id),
-                         creatTime: dayjs().format('YYYY-MM-DD HH:mm:ss'),
-                         docxName: file.name,
-                         testCaseList: parsedOutput,
-                         actionList: JSON.stringify(action)
-                       },
-                     }).then((res) => {
-                       if(res.data.msg !== "添加成功!"){
-                         ElMessage({
-                           message: '数据库出错',
-                           type: 'warning'
-                         });
-                       }else{
-                         axios({
-                           url: "http://localhost:8081/testCaseList/testList",               // 请求地址
-                           method: "post",                       // 请求方法
-                           headers: {                            // 请求头
-                             "Content-Type": "application/json",
-                           },
-                           params: {                             // 请求参数
-                             user_id: Number(useStore.userInfo.user_id)
-                           },
-                         }).then((res) => {
-                           localStorage.setItem("taskList", JSON.stringify(res.data.data));
-
-                         });
-                       }
-                     });
+
+              // const data2: {
+              //   inputVariables: InputVariable[];
+              //   volumeName: string;
+              // } = {
+              //   inputVariables: [
+              //     {
+              //       name: "filePath",
+              //       value: file.name,
+              //     },
+              //     {
+              //       name: "conversationId",
+              //       value: "7",
+              //     },
+              //   ],
+              //   volumeName: "文字测试用例生成",
+              // };
+              //
+              // const processConfig: axios.AxiosRequestConfig = {
+              //   method: 'post',
+              //   url: 'http://47.120.7.208:8000/api/executions?versionId=12&isAsync=false',
+              //   headers: {
+              //     'User-Agent': 'Apifox/1.0.0 (https://apifox.com)',
+              //     'Content-Type': 'application/json',
+              //     'Authorization': `Bearer ${token}`,
+              //   },
+              //   data: data2,
+              // };
+              //
+              // const action = [{description: "生成用例",times: dayjs().format('YYYY-MM-DD HH:mm:ss')}]
+              // axios(processConfig)
+              //      .then((response) => {
+              //        console.log(response.data.output)
+              //        const output = JSON.stringify(JSON.parse(response.data.output))
+              //        const leftIndex = output.indexOf("[")
+              //        const rightIndex = output.indexOf("]")
+              //
+              //        const parsedOutput = output.substring(leftIndex,rightIndex+1).replace(/\\n/g, '').replace(/\\/g, '').replace(/ /g,'')
+              //
+              //        console.log(parsedOutput)
+              //        const testCaseArray = JSON.parse(parsedOutput);
+              //        console.log(testCaseArray)
+              //        useStore.DocxList.push({docxName: file.name, docxMessageList: testCaseArray, time: dayjs().format('YYYY-MM-DD HH:mm:ss'), actionList: action, testCaseList: []})
+              //        //持久化存储
+              //        useStore.saveDocxList()
+              //        //添加进数据库
+              //        axios({
+              //          url: "http://localhost:8081/testCaseList/add",               // 请求地址
+              //          method: "post",                       // 请求方法
+              //          headers: {                            // 请求头
+              //            "Content-Type": "application/json",
+              //          },
+              //          data: {                             // 请求参数
+              //            userId: Number(useStore.userInfo.user_id),
+              //            creatTime: dayjs().format('YYYY-MM-DD HH:mm:ss'),
+              //            docxName: file.name,
+              //            testCaseList: parsedOutput,
+              //            actionList: JSON.stringify(action)
+              //          },
+              //        }).then((res) => {
+              //          if(res.data.msg !== "添加成功!"){
+              //            ElMessage({
+              //              message: '数据库出错',
+              //              type: 'warning'
+              //            });
+              //          }else{
+              //            axios({
+              //              url: "http://localhost:8081/testCaseList/testList",               // 请求地址
+              //              method: "post",                       // 请求方法
+              //              headers: {                            // 请求头
+              //                "Content-Type": "application/json",
+              //              },
+              //              params: {                             // 请求参数
+              //                user_id: Number(useStore.userInfo.user_id)
+              //              },
+              //            }).then((res) => {
+              //              localStorage.setItem("taskList", JSON.stringify(res.data.data));
+              //
+              //            });
+              //          }
+              //        });
                      loadingInstance1.close()
                      ElMessage({
                        message: '测试用例已生成,即将跳转',
                        type: 'success'
                      });
 
-                   })
-                   .catch((error) => {
-                     console.log(error);
-                   });
+                   // })
+                   // .catch((error) => {
+                   //   console.log(error);
+                   // });
 
-             })
+              })
         ElMessage({
           message: '上传文件成功,正在为您生成测试用例',
           type: 'success'
@@ -225,8 +405,8 @@ function uploadDocx() {
   top: 50%;
   left: 50%;
   transform: translate(-50%, -50%);
-  width: 50vw;
-  height: 50vh;
+  width: 70%;
+  height: 70%;
   background-color: #fff;
   border-radius: 10px;
   border: 1px solid #efefef;
@@ -240,4 +420,6 @@ function uploadDocx() {
   background-size: 50%;
   border: 1px solid #efefef;
 }
+
+
 </style>

+ 6 - 1
src/router/index.ts

@@ -9,7 +9,7 @@ import TCListVue from '../components/TCList.vue'
 import TCFinalListVue from '../components/TCFinalList.vue'
 import TaskListVue from '../components/TaskList.vue'
 import HistoryListVue from '../components/HistoryList.vue'
-
+import SettingsVue from '../components/Settings.vue'
 const router = createRouter({
     history: createWebHistory(import.meta.env.BASE_URL),
     routes: [{
@@ -46,6 +46,11 @@ const router = createRouter({
                 path: '/historyList',
                 name: 'historyList',
                 component: HistoryListVue
+            },
+            {
+                path: '/settings',
+                name: 'settings',
+                component: SettingsVue
             }
         ]
     },