bill 8 mēneši atpakaļ
vecāks
revīzija
072eaacc3d

+ 4 - 0
src/app/fire/view/dispatch/editFire.vue

@@ -224,8 +224,12 @@ const f8 = ref(f8s);
 const searchAMapAddress = async () => {
   const data = await selectMapImage({});
   if (!data?.search) return;
+
   bindFire.value.projectAddress = data.search.text;
   bindFire.value.latlng = bindFire.value.latAndLong = `${data.search.lat},${data.search.lng}`;
+  if (!data.search.text) {
+    bindFire.value.projectAddress = bindFire.value.latAndLong;
+  }
 };
 
 defineExpose<QuiskExpose>({

+ 26 - 9
src/components/chunk-upload/index.vue

@@ -6,11 +6,13 @@
     :accept="api.accept.value"
     :show-file-list="true"
     :http-request="() => {}"
+    @remove="api.file.value = undefined"
     :file-list="api.fileList.value"
+    @exceed="() => ElMessage.error('只能上传一个文件')"
     :disable="api.percentage.value || disabled"
     :before-upload="api.upload"
   >
-    <el-button v-pdpath="'sync'" type="primary">
+    <el-button v-pdpath="'sync'" type="primary" class="upload-button">
       <el-icon><Upload /></el-icon>{{ api.percentage.value ? "文件上传中" : "上传数据" }}
     </el-button>
   </el-upload>
@@ -27,7 +29,7 @@
 
 <script setup lang="ts">
 import { useUpload } from "@/hook/upload";
-import { computed } from "vue";
+import { computed, reactive } from "vue";
 import { uploadIngs } from "./uploading";
 import SparkMD5 from "spark-md5";
 import { axios, initChunkUpload, mergeChunkUpload } from "@/request";
@@ -142,7 +144,11 @@ const chunksUpload = async (
       i * parallelCount,
       Math.min((i + 1) * parallelCount, chunks.length)
     );
-    await Promise.all(uploadChunks(chunkGroup, i * parallelCount));
+    try {
+      await Promise.all(uploadChunks(chunkGroup, i * parallelCount));
+    } catch (e) {
+      i--;
+    }
   }
 
   setPercentage();
@@ -159,10 +165,10 @@ const chunksUpload = async (
   emit("success");
 };
 
-const expose = {
-  file: null,
+const expose = reactive({
+  file: computed(() => api.value.file.value),
   upload: () => {},
-} as any;
+}) as any;
 const api = computed(() =>
   useUpload({
     maxSize: props.maxSize,
@@ -171,7 +177,6 @@ const api = computed(() =>
       if (!props.customUpload) {
         return chunksUpload(file, props.attach || {}, onPercentage);
       } else {
-        expose.file = file;
         return new Promise<string>((resolve, reject) => {
           expose.upload = async () => {
             try {
@@ -180,8 +185,7 @@ const api = computed(() =>
               reject(e);
               throw e;
             }
-
-            delete expose.file;
+            api.value.file.value = undefined;
             delete expose.upload;
             resolve("success");
           };
@@ -193,3 +197,16 @@ const api = computed(() =>
 
 defineExpose(expose);
 </script>
+
+<style lang="scss">
+.upload-demo {
+  width: 100%;
+}
+.el-upload-list {
+  width: 100%;
+
+  .el-icon--close-tip {
+    display: none !important;
+  }
+}
+</style>

+ 1 - 3
src/hook/upload.ts

@@ -52,21 +52,19 @@ export const useUpload = <T>(props: UploadProps<T>) => {
   };
 
   const upload = async (file: File) => {
-    console.error("???");
     const fileType = file.name
       .substring(file.name.lastIndexOf("."))
       .toUpperCase();
 
     if (!props.formats.some((type) => type.toUpperCase() === fileType)) {
       ElMessage.error(`请上传${format.value}`);
-      return false;
       throw `请上传${format.value}`;
     } else if (file.size > props.maxSize) {
       ElMessage.error(`请上传${size.value}以内的文件`);
       throw `请上传${size.value}以内的文件`;
     } else {
+      console.error(file);
       fileRef.value = file;
-      console.error(props.upload || defaultUpload);
       await (props.upload || defaultUpload)(
         file,
         (val) => (percentage.value = val)

+ 24 - 0
src/view/case/draw/selectMapImage.vue

@@ -87,12 +87,36 @@ watchEffect(async (onCleanup) => {
     setSearch(e.data);
     showSearch.value = false;
   });
+  let clickMarker;
 
+  map.on("click", function (e) {
+    // 获取点击位置的经纬度坐标
+    var latitude = e.lnglat.lat;
+    var longitude = e.lnglat.lng;
+
+    searchInfo.value = {
+      text: "",
+      lat: latitude,
+      lng: longitude,
+      zoom: 0,
+    };
+    clickMarker && map.remove(clickMarker);
+    clickMarker = null;
+    // 在地图上添加标记
+    clickMarker = new AMap.Marker({
+      position: [longitude, latitude],
+      title: "点击位置",
+    });
+
+    map.add(clickMarker);
+  });
   placeSearch.on("complete", function (result) {
     setTimeout(() => {
       const markers = map.getAllOverlays("marker");
       for (const marker of markers) {
         marker.on("click", () => {
+          clickMarker && map.remove(clickMarker);
+          clickMarker = null;
           setSearch(marker._data);
         });
       }

+ 2 - 2
src/view/vrmodel/upload.vue

@@ -18,7 +18,7 @@
         />
       </el-select>
     </el-form-item>
-    <el-form-item label="类型:" class="mandatory">
+    <el-form-item label="数据:" class="mandatory">
       <ChunkUpload
         :formats="ModelSupportFormats"
         :attach="uploadAttach"
@@ -123,7 +123,7 @@ export type UploadInfo = {
 
 let handler = false;
 const info = reactive({
-  name: props.name,
+  name: props.name || "",
   fileType: props.fileType,
   uploadId: -1,
 }) as UploadInfo;