فهرست منبع

修改制卷导出

wangfumin 2 ماه پیش
والد
کامیت
8695d45976

+ 2 - 2
src/core/Scene.js

@@ -298,7 +298,7 @@ export default class Scene extends Mitt {
             console.log(`Width: ${offset}`);
             if (index === slides) {
               console.log("last");
-              that.emit("submitScreenshot", true);
+              that.emit("submitScreenshot", isSaveJpg);
             }
           }, index * 500);
         })(i, this); // 传递当前迭代的索引i给setTimeout的回调函数
@@ -309,7 +309,7 @@ export default class Scene extends Mitt {
         console.log("total", total);
         this.player.floorplanControls.reset();
         this.screenshot(-0.3, 227);
-        this.emit("submitScreenshot", true);
+        this.emit("submitScreenshot", isSaveJpg);
       }
     }
   }

+ 2 - 0
src/view/case/newphotos/index.vue

@@ -268,6 +268,8 @@ const renderCanvas = () => {
             if (save) {
               // debugger;
               // saveAs(data.imgUrl, title);
+            } else {
+              window.open(data.imgUrl, '_blank');
             }
           }
           window.scene.endScreenshot();

+ 60 - 3
src/view/newFireCase/newFireDetails/components/headerTop.vue

@@ -4,12 +4,19 @@
       <el-icon v-if="showSave" class="back-icon" @click="$emit('back')">
         <ArrowLeft />
       </el-icon>
-      <span v-if="isPreview != 'abstract'" class="edit-title">编辑<span v-if="isPreview != 'abstract'" class="line">|</span></span><span>{{ headerTitle }}</span>
+      <span v-if="isPreview != 'abstract'" class="edit-title">{{ typeName || '编辑' }}<span v-if="isPreview != 'abstract'" class="line">|</span></span><span>{{ headerTitle }}</span>
     </div>
     <div class="right-title" v-if="editOrShow === 'edit'">
       <span class="change-btn" v-if="!showSave" @click="openRenameDialog"><i class="iconfont icon-rename" /></span>
       <el-button plain v-if="!showSave" type="primary" @click="preview">预览</el-button>
       <el-button type="primary" v-if="showSave" @click="$emit('save')">保存</el-button>
+      <el-button
+        type="primary"
+        v-if="showSave && exportReady"
+        @click="handleExport"
+        :loading="!isSenseLoaded"
+        :disabled="!isSenseLoaded"
+      >导出</el-button>
     </div>
   </div>
   <el-dialog
@@ -29,7 +36,7 @@
 </template>
 
 <script setup lang="ts">
-import { ref, computed, onMounted } from "vue";
+import { ref, computed, onMounted, onUnmounted } from "vue";
 import { ArrowLeft } from "@element-plus/icons-vue";
 import { useRoute, useRouter } from 'vue-router';
 import { RouteName, router } from "@/router";
@@ -43,6 +50,13 @@ const props = defineProps<{
 const appId = import.meta.env.VITE_APP_APP || 'fire'
 const route = useRoute();
 const vueRouter = useRouter();
+const typeName = computed(() => {
+  let type = route.query.type as string || route.query.editSub as string;
+  if (type === 'inquest') return '勘验笔录';
+  else if (type === 'extraction') return '提取笔录';
+  else if (type === 'photoEdit') return '照片制卷';
+  return '编辑';
+});
 const renameVisible = ref(false);
 const renameTitle = ref("");
 const isPreview = computed(() => route.query.preview as string || '');
@@ -78,14 +92,57 @@ const confirmRename = () => {
   renameVisible.value = false;
 }
 onMounted(() => {
-  
+  // 轮询并订阅场景状态,控制导出按钮的展示与禁用
+  const update = () => {
+    try {
+      const sc: any = (window as any).scene;
+      isSenseLoaded.value = !!sc;
+      exportReady.value = !!(sc && sc.boxManager && sc.boxManager.model && Array.isArray(sc.boxManager.model.children) && sc.boxManager.model.children.length > 0);
+    } catch (e) {
+      isSenseLoaded.value = false;
+      exportReady.value = false;
+    }
+  };
+  update();
+  timer = setInterval(update, 1000);
+  const sc: any = (window as any).scene;
+  if (sc && typeof sc.on === 'function') {
+    sc.on('loaded', () => { isSenseLoaded.value = true; });
+    sc.on('submitScreenshot', () => { isSenseLoaded.value = true; });
+    sc.on('devicePixelRatio', () => { isSenseLoaded.value = true; });
+  }
 });
 
+onUnmounted(() => { if (timer) clearInterval(timer); });
+
 const emit = defineEmits<{
   save: [],
   back: []
 }>()
 
+// 导出相关状态与方法(复用 photos/index 的逻辑)
+const isSenseLoaded = ref(true);
+const exportReady = ref(false);
+let timer: any = null;
+const handleExport = () => {
+  const sc: any = (window as any).scene;
+  if (!sc) {
+    ElMessage.warning('当前页面暂未就绪,稍后再试');
+    return;
+  }
+  if ((window as any).isExportScreenshot) {
+    ElMessage.warning('正在导出,请稍候');
+    return;
+  }
+  isSenseLoaded.value = false;
+  try {
+    sc.exportScreenshot(false); // 不保存,交由提交事件在新窗口打开
+  } catch (e) {
+    console.error('导出失败', e);
+    isSenseLoaded.value = true;
+  }
+};
+
 </script>
 
 <style lang="scss" scoped>

+ 7 - 6
src/view/newFireCase/newFireDetails/editFilePage.vue

@@ -1,8 +1,8 @@
 <template>
   <div v-if="visible" class="edit-file-page">
     <div class="page-body">
-      <template v-if="type === 'inquest'">
-        <h3 class="title">勘验笔录</h3>
+      <div v-if="type === 'inquest'">
+        <h3 class="title">基本信息</h3>
         <div class="content">
           <div class="line">
             <span>勘验次数:</span>
@@ -129,10 +129,10 @@
             <el-button class="btn" @click="addWitness">+新增</el-button>
           </div>
         </div>
-      </template>
+      </div>
 
-      <template v-else>
-        <h3 class="title">提取清单</h3>
+      <div v-if="type === 'extraction'">
+        <h3 class="title">基本信息</h3>
         <div class="content">
           <div class="line">
             <span>起火单位/地址:</span>
@@ -192,7 +192,7 @@
             <div class="btn-container"><el-button class="btn" @click="addWitnessExtract">+新增</el-button></div>
           </div>
         </div>
-      </template>
+      </div>
     </div>
   </div>
 </template>
@@ -429,6 +429,7 @@ defineExpose({ handleSave });
 
 .title {
   text-align: center;
+  margin-bottom: 20px;
 }
 
 .sub-tit {

+ 2 - 1
src/view/newFireCase/newFireDetails/editInspection.vue

@@ -1,6 +1,7 @@
 <template>
   <div v-if="visible" class="edit-inspection-page">
     <div class="records">
+      <h3 class="title">基本信息</h3>
       <div class="content">
         <div class="line">
           <span>起火单位/地址:</span>
@@ -223,7 +224,7 @@ defineExpose({ handleSave });
   }
 }
 
-.title { text-align: center; }
+.title { text-align: center;margin-bottom: 20px; }
 .sub-tit { display: inline-block; padding-bottom: 20px; }
 
 .detail {