|
@@ -1,6 +1,6 @@
|
|
|
<script lang="ts" setup>
|
|
|
import { ref, onMounted, reactive } from "vue";
|
|
|
-import { ElMessage ,ElLoading} from "element-plus";
|
|
|
+import { ElMessage, ElLoading } from "element-plus";
|
|
|
import { genFileId } from "element-plus";
|
|
|
import axios from "axios";
|
|
|
|
|
@@ -17,7 +17,7 @@ const disableFlag = ref<boolean>(false);
|
|
|
const upload = ref<any>();
|
|
|
|
|
|
//load标志
|
|
|
-const load =ref<any>();
|
|
|
+const load = ref<any>();
|
|
|
|
|
|
const formData = ref<any>();
|
|
|
|
|
@@ -31,9 +31,10 @@ const car_type = ref<string>("");
|
|
|
|
|
|
//文件的对象
|
|
|
const currentFile = ref<any>();
|
|
|
-const uploadFile = (file: any) => {
|
|
|
- currentFile.value = file.file;
|
|
|
- let name = file.file.name;
|
|
|
+
|
|
|
+const onBeforeUploadImage = (file: any) => {
|
|
|
+ currentFile.value = file.raw;
|
|
|
+ let name = file.raw.name;
|
|
|
let index = name.lastIndexOf(".");
|
|
|
fileType.value = name.substr(index + 1);
|
|
|
// fileType.value = e.target.files[0].name;
|
|
@@ -48,17 +49,20 @@ const uploadFile = (file: any) => {
|
|
|
upload.value.clearFiles();
|
|
|
currentFile.value = null;
|
|
|
fileType.value = "";
|
|
|
- return;
|
|
|
+ return false;
|
|
|
+ } else {
|
|
|
+ return true;
|
|
|
}
|
|
|
};
|
|
|
+const uploadFile = (file: any) => {};
|
|
|
const startFun = () => {
|
|
|
- //判断是否上传文件
|
|
|
- if(currentFile.value==''||currentFile.value==null){
|
|
|
+ //判断是否上传文件
|
|
|
+ if (currentFile.value == "" || currentFile.value == null) {
|
|
|
ElMessage({
|
|
|
- message: `请选择文件`,
|
|
|
- type: "error",
|
|
|
- });
|
|
|
- return
|
|
|
+ message: `请选择文件`,
|
|
|
+ type: "error",
|
|
|
+ });
|
|
|
+ return;
|
|
|
}
|
|
|
const formData = new FormData();
|
|
|
formData.append("file", currentFile.value);
|
|
@@ -71,11 +75,11 @@ const startFun = () => {
|
|
|
|
|
|
formData.append("taskType", taskType.value);
|
|
|
disableFlag.value = true;
|
|
|
- load.value=ElLoading.service({
|
|
|
+ load.value = ElLoading.service({
|
|
|
lock: true,
|
|
|
- text: '努力检测中',
|
|
|
- background: 'rgba(0, 0, 0, 0.7)',
|
|
|
- })
|
|
|
+ text: "努力检测中",
|
|
|
+ background: "rgba(0, 0, 0, 0.7)",
|
|
|
+ });
|
|
|
axios
|
|
|
.post(`/v1/record/create`, formData)
|
|
|
.then((res) => {
|
|
@@ -83,7 +87,6 @@ const startFun = () => {
|
|
|
disableFlag.value = false;
|
|
|
//如果结果是返回的是正确的
|
|
|
if (res?.data?.code == 200) {
|
|
|
-
|
|
|
flag.value = res.data.data;
|
|
|
// chartList = arr2;
|
|
|
//开始调用 //查询记录详情
|
|
@@ -92,7 +95,7 @@ const startFun = () => {
|
|
|
}
|
|
|
})
|
|
|
.catch((err) => {
|
|
|
- load.value.close()
|
|
|
+ load.value.close();
|
|
|
disableFlag.value = false;
|
|
|
});
|
|
|
// formData.append("userName", params.name);
|
|
@@ -101,7 +104,7 @@ const startFun = () => {
|
|
|
|
|
|
const queryDetail = () => {
|
|
|
axios.get(`/v1/record/${flag.value}/find`, {}).then((res) => {
|
|
|
- load.value.close()
|
|
|
+ load.value.close();
|
|
|
if (res.data.code == 200) {
|
|
|
//当结果为空时
|
|
|
// ElMessage({
|
|
@@ -115,25 +118,22 @@ const queryDetail = () => {
|
|
|
message: `解析结果为空`,
|
|
|
type: "success",
|
|
|
});
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
//查看是否包含;
|
|
|
//判断字符串中是否包含分号 ;
|
|
|
- let a =res.data.data.Result;
|
|
|
- if( a.includes(';')){
|
|
|
- let b = res.data.data.Result.split(';')
|
|
|
- car_type.value = b[0];
|
|
|
-
|
|
|
- }else{
|
|
|
- car_type.value = res.data.data.Result;
|
|
|
-
|
|
|
+ let a = res.data.data.Result;
|
|
|
+ if (a.includes(";")) {
|
|
|
+ let b = res.data.data.Result.split(";");
|
|
|
+ car_type.value = b[0];
|
|
|
+ } else {
|
|
|
+ car_type.value = res.data.data.Result;
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
ElMessage({
|
|
|
- message: `解析失败`,
|
|
|
- type: "error",
|
|
|
- });
|
|
|
+ message: `解析失败`,
|
|
|
+ type: "error",
|
|
|
+ });
|
|
|
}
|
|
|
// console.log(res.data.data.Result !== "");
|
|
|
});
|
|
@@ -177,14 +177,14 @@ onMounted(() => {
|
|
|
<div style="margin-bottom: 10px">选择文件</div>
|
|
|
<el-upload
|
|
|
ref="upload"
|
|
|
- auto-upload="false"
|
|
|
+ :auto-upload="false"
|
|
|
class="upload-demo"
|
|
|
- :on-change="handleChange"
|
|
|
+ :on-change="onBeforeUploadImage"
|
|
|
:file-list="fileList"
|
|
|
drag
|
|
|
:limit="1"
|
|
|
:on-exceed="handleExceed"
|
|
|
- action="https://run.mocky.io/v3/9d059bf9-4660-45f2-925d-ce80ad6c4d15"
|
|
|
+ action=""
|
|
|
:http-request="uploadFile"
|
|
|
>
|
|
|
<el-icon class="el-icon--upload"><upload-filled /></el-icon>
|