|
@@ -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"
|
|
|
>
|