瀏覽代碼

fix: bug fixed

haifeng.zhang 2 天之前
父節點
當前提交
afc3794330

+ 1 - 1
src/api/download.ts

@@ -84,7 +84,7 @@ export const postImportAssessmentTemplate = async data => {
 // 上传文件获取回显的数据
 export const getListTable = async data => {
   const token = localStorage.getItem("token") || "";
-  return axios.post(`${FLIE_URL}/quota/importQuotaDisplayBackData`, data, {
+  return axios.post(`${FLIE_URL}quota/importQuotaDisplayBackData`, data, {
     headers: {
       "Content-Type": "multipart/form-data", // 指定内容类型
       satoken: token // 将 Token 添加到请求头

+ 2 - 58
src/components/import/index.vue

@@ -43,67 +43,11 @@ const handleUploadChange = async (file: File) => {
     uploadShow.value = false; // 隐藏上传区域,显示数据表
     tableData.value = data.data;
     ElMessage.success("导入成功");
-    // reader.onload = e => {
-    //   const data = new Uint8Array(e.target?.result as ArrayBuffer);
-    //   const workbook = XLSX.read(data, { type: "array" }); // 读取 Excel 文件
-    //   const firstSheetName = workbook.SheetNames[0]; // 获取第一个工作表名
-    //   const worksheet = workbook.Sheets[firstSheetName]; // 获取第一个工作表
-    //   const jsonData = XLSX.utils.sheet_to_json(worksheet, { header: 1 }); // 将工作表转为 JSON
-    //   if (
-    //     jsonData[1].length == 6 &&
-    //     (query.value.assessmentType == 0 || query.value.assessmentType == 1)
-    //   ) {
-    //     tableHeaders.value = jsonData[1];
-    //     const arr = jsonData.slice(2).map(row => {
-    //       if (row[0] && row[1] && row[2] && row[3]) {
-    //         const rowData = {};
-    //         tableHeaders.value.forEach((header, index) => {
-    //           if (row[index]) {
-    //             rowData[header] = row[index];
-    //           }
-    //         });
-    //         return rowData;
-    //       }
-    //     });
-    //     tableData.value = arr.filter(item => item);
-    //     ElMessage.success("文件上传成功");
-    //     uploadShow.value = false; // 隐藏上传区域,显示数据表
-    //   } else if (query.value.assessmentType == 2) {
-    //     tableHeaders.value = [
-    //       "用户组",
-    //       "用户组编号",
-    //       "考核模板",
-    //       "指标名称",
-    //       "完成值",
-    //       "得分"
-    //     ]; // 表头
-    //     const arr = jsonData.slice(2).map(row => {
-    //       if (row[0] && row[1] && row[2] && row[3]) {
-    //         const rowData = {};
-    //         tableHeaders.value.forEach((header, index) => {
-    //           if (row[index]) {
-    //             rowData[header] = row[index];
-    //           }
-    //         });
-    //         return rowData;
-    //       }
-    //     });
-    //     tableData.value = arr.filter(item => item);
-    //     ElMessage.success("文件上传成功");
-    //     uploadShow.value = false; // 隐藏上传区域,显示数据表
-    //   } else {
-    //     ElMessage.error("文件为空或格式不正确");
-    //   }
-    // };
-    console.log(data);
   } else {
     ElMessage.error(data.msg);
   }
-  // } else {
-  //   ElMessage.error("请上传xlsx文件");
-  // }
-
   reader.readAsArrayBuffer(file); // 读取文件为 ArrayBuffer
+  return false; // 阻止默认上传行为
 };
 // 上传
 const postImportAssessmentTemplateApi = async data => {
@@ -213,7 +157,7 @@ const backupUrl3 =
           <el-upload
             class="upload-demo"
             drag
-            action="https://run.mocky.io/v3/9d059bf9-4660-45f2-925d-ce80ad6c4d15"
+            action="#"
             :before-upload="file => handleUploadChange(file)"
             :show-file-list="false"
           >

+ 2 - 2
src/views/draw/children/department/departmentRank.vue

@@ -64,7 +64,7 @@ const averageScore = ref<number | string>(0);
 const tableData = ref<any>([]);
 const getPageScoreInfoByAssessmentApi = async (
   obj: any = {},
-  sort: any = { type: 1 }
+  sort: any = { type: 2 }
 ) => {
   const params = {
     assessmentId: obj.id,
@@ -122,7 +122,7 @@ const fetchSortedData = sortOrder => {
   if (sortOrder) {
     params.type = sortOrder === "ascending" ? 1 : 2; // 1 从低到高 2从高到底
   } else {
-    params.type = 1;
+    params.type = 2;
   }
   getPageScoreInfoByAssessmentApi(activeObj.value, params);
 };

+ 2 - 2
src/views/draw/children/head/headRank.vue

@@ -64,7 +64,7 @@ const averageScore = ref<number | string>(0);
 const tableData = ref<any>([]);
 const getPageScoreInfoByAssessmentApi = async (
   obj: any = {},
-  sort: any = { type: 1 }
+  sort: any = { type: 2 }
 ) => {
   const params = {
     assessmentId: obj.id,
@@ -122,7 +122,7 @@ const fetchSortedData = sortOrder => {
   if (sortOrder) {
     params.type = sortOrder === "ascending" ? 1 : 2; // 1 从低到高 2从高到底
   } else {
-    params.type = 1;
+    params.type = 2;
   }
   getPageScoreInfoByAssessmentApi(activeObj.value, params);
 };

+ 2 - 2
src/views/draw/children/health/healthRank.vue

@@ -64,7 +64,7 @@ const averageScore = ref<number | string>(0);
 const tableData = ref<any>([]);
 const getPageScoreInfoByAssessmentApi = async (
   obj: any = {},
-  sort: any = { type: 1 }
+  sort: any = { type: 2 }
 ) => {
   const params = {
     assessmentId: obj.id,
@@ -122,7 +122,7 @@ const fetchSortedData = sortOrder => {
   if (sortOrder) {
     params.type = sortOrder === "ascending" ? 1 : 2; // 1 从低到高 2从高到底
   } else {
-    params.type = 1;
+    params.type = 2;
   }
   getPageScoreInfoByAssessmentApi(activeObj.value, params);
 };

+ 2 - 2
src/views/draw/children/worker/workerRank.vue

@@ -64,7 +64,7 @@ const averageScore = ref<number | string>(0);
 const tableData = ref<any>([]);
 const getPageScoreInfoByAssessmentApi = async (
   obj: any = {},
-  sort: any = { type: 1 }
+  sort: any = { type: 2 }
 ) => {
   const params = {
     assessmentId: obj.id,
@@ -122,7 +122,7 @@ const fetchSortedData = sortOrder => {
   if (sortOrder) {
     params.type = sortOrder === "ascending" ? 1 : 2; // 1 从低到高 2从高到底
   } else {
-    params.type = 1;
+    params.type = 2;
   }
   getPageScoreInfoByAssessmentApi(activeObj.value, params);
 };

+ 1 - 39
src/views/indexDefine/children/import/index.vue

@@ -90,51 +90,13 @@ const handleUploadChange = async (file: File) => {
     if (data.code === 200) {
       tableData.value = data.data;
     }
-    // reader.onload = e => {
-    //   const data = new Uint8Array(e.target?.result as ArrayBuffer);
-    //   const workbook = XLSX.read(data, { type: "array" }); // 读取 Excel 文件
-    //   const firstSheetName = workbook.SheetNames[0]; // 获取第一个工作表名
-    //   const worksheet = workbook.Sheets[firstSheetName]; // 获取第一个工作表
-    //   const jsonData = XLSX.utils.sheet_to_json(worksheet, { header: 1 }); // 将工作表转为 JSON
-    //   if (jsonData[1].length == 6) {
-    //     tableHeaders.value = [
-    //       "指标名称",
-    //       "指标定义",
-    //       "指标口径",
-    //       "指标分类",
-    //       "来源",
-    //       "状态"
-    //     ]; // 表头
-
-    //     const arr = jsonData.slice(3).map(row => {
-    //       if (row[0] && row[1] && row[2] && row[3]) {
-    //         const rowData = {};
-    //         tableHeaders.value.forEach((header, index) => {
-    //           if (row[index] && row[index].trim().length > 0) {
-    //             rowData[header] = row[index];
-    //           } else if (header == "来源") {
-    //             rowData[header] = "-";
-    //           } else if (header == "状态") {
-    //             rowData[header] = "草稿";
-    //           }
-    //         });
-    //         return rowData;
-    //       }
-    //     });
-    //     tableData.value = arr.filter(item => item);
-    //     console.log("111", tableData.value)
-
-    //     ElMessage.success("文件上传成功");
     uploadShow.value = false; // 隐藏上传区域,显示数据表
-    //   } else {
-    //     ElMessage.error("文件为空或格式不正确");
-    //   }
-    // };
   } else {
     ElMessage.error("请上传xlsx文件");
   }
 
   reader.readAsArrayBuffer(file); // 读取文件为 ArrayBuffer
+  return false; // 阻止默认上传行为
 };
 
 const stateDone = state => {