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