|
@@ -2,76 +2,70 @@
|
|
|
<MainPanel>
|
|
|
<template v-slot:header>
|
|
|
<Header title="现场绘图 | 制表" :on-back="onBack" type="return">
|
|
|
- <ui-button
|
|
|
- type="primary"
|
|
|
- @click="saveHandler"
|
|
|
- width="96px"
|
|
|
- >
|
|
|
- 保存
|
|
|
- </ui-button>
|
|
|
+ <ui-button type="primary" @click="saveHandler" width="96px"> 保存 </ui-button>
|
|
|
</Header>
|
|
|
</template>
|
|
|
|
|
|
- <div class="tab-layout" v-if="roadPhoto" :class="{downMode}">
|
|
|
+ <div class="tab-layout" v-if="roadPhoto" :class="{ downMode }">
|
|
|
<div class="content" ref="layoutRef">
|
|
|
<table>
|
|
|
<tr>
|
|
|
<td class="value title" colspan="6" height="64">
|
|
|
- <span v-if="downMode">{{roadPhoto.title}}</span>
|
|
|
+ <span v-if="downMode">{{ roadPhoto.title }}</span>
|
|
|
<ui-input
|
|
|
- v-else
|
|
|
- type="text"
|
|
|
- @input="input"
|
|
|
- v-model="roadPhoto.title"
|
|
|
- @blur="history.push"
|
|
|
+ v-else
|
|
|
+ type="text"
|
|
|
+ @input="input"
|
|
|
+ v-model="roadPhoto.title"
|
|
|
+ @blur="history.push"
|
|
|
/>
|
|
|
</td>
|
|
|
</tr>
|
|
|
<tr>
|
|
|
<td class="label" width="150" height="64">到达事故现场时间</td>
|
|
|
<td class="value">
|
|
|
- <span v-if="downMode">{{history.value.arrivalTime}}</span>
|
|
|
+ <span v-if="downMode">{{ history.value.arrivalTime }}</span>
|
|
|
<ui-input
|
|
|
- v-else
|
|
|
- type="text"
|
|
|
- @input="input"
|
|
|
- v-model="history.value.arrivalTime"
|
|
|
- @blur="history.push"
|
|
|
+ v-else
|
|
|
+ type="text"
|
|
|
+ @input="input"
|
|
|
+ v-model="history.value.arrivalTime"
|
|
|
+ @blur="history.push"
|
|
|
/>
|
|
|
</td>
|
|
|
<td class="label" width="100">天气</td>
|
|
|
<td class="value" width="80">
|
|
|
- <span v-if="downMode">{{history.value.weather}}</span>
|
|
|
+ <span v-if="downMode">{{ history.value.weather }}</span>
|
|
|
<ui-input
|
|
|
- v-else
|
|
|
- type="text"
|
|
|
- @input="input"
|
|
|
- v-model="history.value.weather"
|
|
|
- @blur="history.push"
|
|
|
+ v-else
|
|
|
+ type="text"
|
|
|
+ @input="input"
|
|
|
+ v-model="history.value.weather"
|
|
|
+ @blur="history.push"
|
|
|
/>
|
|
|
</td>
|
|
|
<td class="label" width="100">路面性质</td>
|
|
|
<td class="value" width="150">
|
|
|
- <span v-if="downMode">{{history.value.conditions}}</span>
|
|
|
+ <span v-if="downMode">{{ history.value.conditions }}</span>
|
|
|
<ui-input
|
|
|
- v-else
|
|
|
- type="text"
|
|
|
- @input="input"
|
|
|
- v-model="history.value.conditions"
|
|
|
- @blur="history.push"
|
|
|
+ v-else
|
|
|
+ type="text"
|
|
|
+ @input="input"
|
|
|
+ v-model="history.value.conditions"
|
|
|
+ @blur="history.push"
|
|
|
/>
|
|
|
</td>
|
|
|
</tr>
|
|
|
<tr>
|
|
|
- <td class="label" height="64">事故发生地点</td>
|
|
|
+ <td class="label" height="64">事故发生地点</td>
|
|
|
<td class="value" colspan="5">
|
|
|
- <span v-if="downMode">{{history.value.location}}</span>
|
|
|
+ <span v-if="downMode">{{ history.value.location }}</span>
|
|
|
<ui-input
|
|
|
- v-else
|
|
|
- type="text"
|
|
|
- @input="input"
|
|
|
- v-model="history.value.location"
|
|
|
- @blur="history.push"
|
|
|
+ v-else
|
|
|
+ type="text"
|
|
|
+ @input="input"
|
|
|
+ v-model="history.value.location"
|
|
|
+ @blur="history.push"
|
|
|
/>
|
|
|
</td>
|
|
|
</tr>
|
|
@@ -79,17 +73,17 @@
|
|
|
<td class="image" colspan="6" height="360">
|
|
|
<div class="photo-layout">
|
|
|
<img
|
|
|
- :src="useStaticUrl(roadPhoto.url).value"
|
|
|
- @blur="history.push"
|
|
|
- class="photo"
|
|
|
- :style="{transform: photoCSSMatrix}"
|
|
|
- ref="photoRef"
|
|
|
+ :src="useStaticUrl(roadPhoto.url).value"
|
|
|
+ @blur="history.push"
|
|
|
+ class="photo"
|
|
|
+ :style="{ transform: photoCSSMatrix }"
|
|
|
+ ref="photoRef"
|
|
|
/>
|
|
|
<img
|
|
|
- src="/static/compass.png"
|
|
|
- class="compass"
|
|
|
- :style="{transform: compassCSSMatrix}"
|
|
|
- ref="compassRef"
|
|
|
+ src="/static/compass.png"
|
|
|
+ class="compass"
|
|
|
+ :style="{ transform: compassCSSMatrix }"
|
|
|
+ ref="compassRef"
|
|
|
/>
|
|
|
<p class="compass-info">比例1 : {{ proportion }}</p>
|
|
|
</div>
|
|
@@ -97,17 +91,17 @@
|
|
|
</tr>
|
|
|
<tr>
|
|
|
<td class="value" colspan="6" height="64">
|
|
|
- <span v-if="downMode">{{history.value.illustrate}}</span>
|
|
|
+ <span v-if="downMode">{{ history.value.illustrate }}</span>
|
|
|
<ui-input
|
|
|
- v-else
|
|
|
- type="text"
|
|
|
- @input="input"
|
|
|
- v-model="history.value.illustrate"
|
|
|
- @blur="history.push"
|
|
|
+ v-else
|
|
|
+ type="text"
|
|
|
+ @input="input"
|
|
|
+ v-model="history.value.illustrate"
|
|
|
+ @blur="history.push"
|
|
|
/>
|
|
|
</td>
|
|
|
</tr>
|
|
|
- <tr >
|
|
|
+ <tr>
|
|
|
<td class="value date" colspan="6" height="48">
|
|
|
{{ formatDate(new Date(), "yyyy年MM月dd日hh时mm分") }}
|
|
|
</td>
|
|
@@ -125,103 +119,107 @@
|
|
|
</template>
|
|
|
|
|
|
<script setup lang="ts">
|
|
|
-import { router, writeRouteName } from '@/router'
|
|
|
+import { router, writeRouteName } from "@/router";
|
|
|
import { formatDate } from "@/utils";
|
|
|
-import {computed, nextTick, ref, watchEffect} from "vue";
|
|
|
-import { useHistory } from '@/hook/useHistory'
|
|
|
-import {roadPhotos, RoadPhoto, getDefaultTable} from "@/store/roadPhotos";
|
|
|
-import {useStaticUrl} from "@/hook/useStaticUrl";
|
|
|
-import html2canvas from 'html2canvas'
|
|
|
+import { computed, nextTick, onDeactivated, ref, watchEffect } from "vue";
|
|
|
+import { useHistory } from "@/hook/useHistory";
|
|
|
+import { roadPhotos, RoadPhoto, getDefaultTable } from "@/store/roadPhotos";
|
|
|
+import { useStaticUrl } from "@/hook/useStaticUrl";
|
|
|
+import html2canvas from "html2canvas";
|
|
|
import UiButton from "@/components/base/components/button/index.vue";
|
|
|
import UiInput from "@/components/base/components/input/index.vue";
|
|
|
-import {HandMode, useHand} from '@/hook/useHand'
|
|
|
+import { HandMode, useHand } from "@/hook/useHand";
|
|
|
import Header from "@/components/photos/header.vue";
|
|
|
import MainPanel from "@/components/main-panel/index.vue";
|
|
|
-import {downloadImage, uploadImage} from "@/store/sync";
|
|
|
-import {Mode} from "@/views/graphic/menus";
|
|
|
+import { downloadImage, uploadImage } from "@/store/sync";
|
|
|
+import { Mode } from "@/views/graphic/menus";
|
|
|
import Message from "@/components/base/components/message/message.vue";
|
|
|
|
|
|
const roadPhoto = computed<RoadPhoto>(() => {
|
|
|
- let route, params, data
|
|
|
- if (((route = router.currentRoute.value).name === writeRouteName.tabulation)
|
|
|
- && (params = route.params).id
|
|
|
- && (data = roadPhotos.value.find(data => data.id === params.id))) {
|
|
|
- return data
|
|
|
+ let route, params, data;
|
|
|
+ if (
|
|
|
+ (route = router.currentRoute.value).name === writeRouteName.tabulation &&
|
|
|
+ (params = route.params).id &&
|
|
|
+ (data = roadPhotos.value.find((data) => data.id === params.id))
|
|
|
+ ) {
|
|
|
+ return data;
|
|
|
} else {
|
|
|
// router.back();
|
|
|
}
|
|
|
-})
|
|
|
+});
|
|
|
const history = computed(
|
|
|
() => roadPhoto.value && useHistory(getDefaultTable(roadPhoto.value))
|
|
|
-)
|
|
|
+);
|
|
|
|
|
|
-const input = () => history.value.state.hasRedo = false
|
|
|
+const input = () => (history.value.state.hasRedo = false);
|
|
|
|
|
|
-const compassRef = ref<HTMLImageElement>()
|
|
|
+const compassRef = ref<HTMLImageElement>();
|
|
|
const { cssMatrix: compassCSSMatrix, matrix: compassMatrix } = useHand(
|
|
|
compassRef,
|
|
|
HandMode.Angle,
|
|
|
() => {
|
|
|
- history.value.value.compassAngle = compassMatrix.value
|
|
|
- history.value.push()
|
|
|
+ history.value.value.compassAngle = compassMatrix.value;
|
|
|
+ history.value.push();
|
|
|
},
|
|
|
history.value.value.compassAngle
|
|
|
-)
|
|
|
-const photoRef = ref<HTMLImageElement>()
|
|
|
+);
|
|
|
+const photoRef = ref<HTMLImageElement>();
|
|
|
const { cssMatrix: photoCSSMatrix, matrix: photoMatrix } = useHand(
|
|
|
photoRef,
|
|
|
HandMode.MoveAndScale,
|
|
|
() => {
|
|
|
- history.value.value.imageTransform = photoMatrix.value
|
|
|
- history.value.push()
|
|
|
+ history.value.value.imageTransform = photoMatrix.value;
|
|
|
+ history.value.push();
|
|
|
},
|
|
|
history.value.value.imageTransform
|
|
|
-)
|
|
|
-
|
|
|
-const proportion = ref(1)
|
|
|
-const photoLoaded = ref(false)
|
|
|
+);
|
|
|
+onDeactivated(() => (photoLoaded.value = false));
|
|
|
+const proportion = ref(1);
|
|
|
+const photoLoaded = ref(false);
|
|
|
watchEffect(() => {
|
|
|
if (!roadPhoto.value || !photoRef.value) {
|
|
|
return;
|
|
|
}
|
|
|
if (!photoLoaded.value) {
|
|
|
- photoRef.value.onload = () => photoLoaded.value = true
|
|
|
+ photoRef.value.onload = () => (photoLoaded.value = true);
|
|
|
+ return;
|
|
|
}
|
|
|
- const scale = roadPhoto.value.data.scale || 1
|
|
|
- const martrixScale = photoMatrix.value[0]
|
|
|
- const photoWidth = photoRef.value.naturalWidth
|
|
|
- const prop = ((photoWidth / photoRef.value.offsetWidth) * scale) / martrixScale
|
|
|
- proportion.value = Math.ceil(prop * 100) / 100
|
|
|
-})
|
|
|
-
|
|
|
+ const scale = roadPhoto.value.data.scale || 1;
|
|
|
+ const martrixScale = photoMatrix.value[0];
|
|
|
+ const photoWidth = photoRef.value.naturalWidth;
|
|
|
+ const prop = ((photoWidth / photoRef.value.offsetWidth) * scale) / martrixScale;
|
|
|
+ console.log(scale, martrixScale, photoWidth, prop);
|
|
|
+ proportion.value = Math.ceil(prop * 100) / 100;
|
|
|
+});
|
|
|
|
|
|
const onBack = () => {
|
|
|
router.replace({
|
|
|
name: writeRouteName.graphic,
|
|
|
- params: {mode: Mode.Road, id: roadPhoto.value.id, action: 'update'}
|
|
|
- })
|
|
|
-}
|
|
|
+ params: { mode: Mode.Road, id: roadPhoto.value.id, action: "update" },
|
|
|
+ });
|
|
|
+};
|
|
|
|
|
|
-const downMode = ref(false)
|
|
|
-const layoutRef = ref<HTMLDivElement>()
|
|
|
+const downMode = ref(false);
|
|
|
+const layoutRef = ref<HTMLDivElement>();
|
|
|
const getLayoutImage = async () => {
|
|
|
- downMode.value = true
|
|
|
- await nextTick()
|
|
|
- const canvas = await html2canvas(layoutRef.value)
|
|
|
- Message.success({ msg: "已保存至相册", time: 2000 } )
|
|
|
- downMode.value = false
|
|
|
- const blob = await new Promise<Blob>(resolve => canvas.toBlob(resolve, "image/jpeg", 0.95))
|
|
|
- await downloadImage(blob)
|
|
|
- return await uploadImage(blob)
|
|
|
-}
|
|
|
+ downMode.value = true;
|
|
|
+ await nextTick();
|
|
|
+ const canvas = await html2canvas(layoutRef.value);
|
|
|
+ Message.success({ msg: "已保存至相册", time: 2000 });
|
|
|
+ downMode.value = false;
|
|
|
+ const blob = await new Promise<Blob>((resolve) =>
|
|
|
+ canvas.toBlob(resolve, "image/jpeg", 0.95)
|
|
|
+ );
|
|
|
+ await downloadImage(blob);
|
|
|
+ return await uploadImage(blob);
|
|
|
+};
|
|
|
const saveHandler = async () => {
|
|
|
roadPhoto.value.table = {
|
|
|
...history.value.value,
|
|
|
- url: await getLayoutImage()
|
|
|
- }
|
|
|
- router.replace({name: writeRouteName.roads})
|
|
|
-}
|
|
|
-
|
|
|
+ url: await getLayoutImage(),
|
|
|
+ };
|
|
|
+ router.replace({ name: writeRouteName.roads });
|
|
|
+};
|
|
|
</script>
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
@@ -286,7 +284,6 @@ const saveHandler = async () => {
|
|
|
height: 800px;
|
|
|
border-collapse: collapse;
|
|
|
|
|
|
-
|
|
|
tr:not(:first-child) {
|
|
|
&:nth-child(2) td {
|
|
|
border-top: 2px solid #000;
|
|
@@ -307,7 +304,7 @@ const saveHandler = async () => {
|
|
|
|
|
|
.value {
|
|
|
height: 43px;
|
|
|
- background-color: #D4E8FF;
|
|
|
+ background-color: #d4e8ff;
|
|
|
}
|
|
|
|
|
|
.title {
|