|
@@ -1,7 +1,7 @@
|
|
<template>
|
|
<template>
|
|
<a-modal
|
|
<a-modal
|
|
v-model:open="visible"
|
|
v-model:open="visible"
|
|
- :width="718"
|
|
|
|
|
|
+ width="100%"
|
|
:footer="false"
|
|
:footer="false"
|
|
:closable="false"
|
|
:closable="false"
|
|
:mask="false"
|
|
:mask="false"
|
|
@@ -9,33 +9,51 @@
|
|
wrapClassName="recog-edit-dialog"
|
|
wrapClassName="recog-edit-dialog"
|
|
>
|
|
>
|
|
<div class="recog-edit">
|
|
<div class="recog-edit">
|
|
- <a-row align="top" :gutter="8" class="m-b-8px">
|
|
|
|
- <a-col :span="4">
|
|
|
|
|
|
+ <div class="recog-row">
|
|
|
|
+ <div class="recog-col is-static is-col1">
|
|
<div class="modal-box">
|
|
<div class="modal-box">
|
|
<p class="box-title">{{ recogTitle }}</p>
|
|
<p class="box-title">{{ recogTitle }}</p>
|
|
<p class="box-cont">{{ recogTitleDesc }}</p>
|
|
<p class="box-cont">{{ recogTitleDesc }}</p>
|
|
</div>
|
|
</div>
|
|
- </a-col>
|
|
|
|
- <a-col :span="16">
|
|
|
|
|
|
+ </div>
|
|
|
|
+ <div class="recog-col is-grow">
|
|
<div class="modal-box modal-origin">
|
|
<div class="modal-box modal-origin">
|
|
- <img v-if="recogData.areaSrc" :src="recogData.areaSrc" alt="截图" />
|
|
|
|
|
|
+ <div class="modal-origin-body" :style="areaImgStyle">
|
|
|
|
+ <img
|
|
|
|
+ v-if="recogData.areaImg"
|
|
|
|
+ ref="areaImgRef"
|
|
|
|
+ :src="recogData.areaImg"
|
|
|
|
+ alt="截图"
|
|
|
|
+ @load="areaImgLoad"
|
|
|
|
+ />
|
|
|
|
+ <div
|
|
|
|
+ v-for="(option, index) in recogData.options.slice(1)"
|
|
|
|
+ :key="option"
|
|
|
|
+ :class="[
|
|
|
|
+ 'select-option',
|
|
|
|
+ { 'is-active': selectResult.includes(option) },
|
|
|
|
+ ]"
|
|
|
|
+ :style="getOptionStyle(index)"
|
|
|
|
+ @click="selectOption(option)"
|
|
|
|
+ ></div>
|
|
|
|
+ </div>
|
|
</div>
|
|
</div>
|
|
- </a-col>
|
|
|
|
- <a-col :span="4">
|
|
|
|
- <div class="modal-box" @click="close">
|
|
|
|
|
|
+ </div>
|
|
|
|
+ <div class="recog-col is-static is-col1">
|
|
|
|
+ <div class="modal-box is-btn" @click="close">
|
|
<p class="box-title">Esc键</p>
|
|
<p class="box-title">Esc键</p>
|
|
<p class="box-cont">关闭</p>
|
|
<p class="box-cont">关闭</p>
|
|
</div>
|
|
</div>
|
|
- </a-col>
|
|
|
|
- </a-row>
|
|
|
|
- <a-row align="top" :gutter="8">
|
|
|
|
- <a-col :span="4">
|
|
|
|
|
|
+ </div>
|
|
|
|
+ </div>
|
|
|
|
+ <div class="recog-row">
|
|
|
|
+ <div class="recog-col is-static is-col1">
|
|
<div class="modal-box">
|
|
<div class="modal-box">
|
|
<p class="box-title">识别结果</p>
|
|
<p class="box-title">识别结果</p>
|
|
<p class="box-cont">{{ recogResult }}</p>
|
|
<p class="box-cont">{{ recogResult }}</p>
|
|
</div>
|
|
</div>
|
|
- </a-col>
|
|
|
|
- <a-col :span="16">
|
|
|
|
|
|
+ </div>
|
|
|
|
+ <div class="recog-col is-grow">
|
|
<div class="modal-box modal-options">
|
|
<div class="modal-box modal-options">
|
|
<a-button
|
|
<a-button
|
|
v-for="option in recogData.options"
|
|
v-for="option in recogData.options"
|
|
@@ -45,14 +63,14 @@
|
|
>{{ option }}</a-button
|
|
>{{ option }}</a-button
|
|
>
|
|
>
|
|
</div>
|
|
</div>
|
|
- </a-col>
|
|
|
|
- <a-col :span="4">
|
|
|
|
- <div class="modal-box" @click="onConfirm">
|
|
|
|
|
|
+ </div>
|
|
|
|
+ <div class="recog-col is-static is-col1">
|
|
|
|
+ <div class="modal-box is-btn" @click="onConfirm">
|
|
<p class="box-title">Enter键</p>
|
|
<p class="box-title">Enter键</p>
|
|
<p class="box-cont">保存</p>
|
|
<p class="box-cont">保存</p>
|
|
</div>
|
|
</div>
|
|
- </a-col>
|
|
|
|
- </a-row>
|
|
|
|
|
|
+ </div>
|
|
|
|
+ </div>
|
|
</div>
|
|
</div>
|
|
</a-modal>
|
|
</a-modal>
|
|
</template>
|
|
</template>
|
|
@@ -62,6 +80,8 @@ import { ref, computed, watch } from "vue";
|
|
import { message } from "ant-design-vue";
|
|
import { message } from "ant-design-vue";
|
|
import useModal from "@/hooks/useModal";
|
|
import useModal from "@/hooks/useModal";
|
|
import { RecogBlock } from "@/utils/recog/recog";
|
|
import { RecogBlock } from "@/utils/recog/recog";
|
|
|
|
+import { getBoxImageSize } from "@/utils/tool";
|
|
|
|
+import { transform } from "lodash-es";
|
|
|
|
|
|
defineOptions({
|
|
defineOptions({
|
|
name: "RecogEditDialog",
|
|
name: "RecogEditDialog",
|
|
@@ -103,6 +123,43 @@ const recogResult = computed(() => {
|
|
return "";
|
|
return "";
|
|
});
|
|
});
|
|
|
|
|
|
|
|
+function getOptionStyle(index: number): Record<string, any> {
|
|
|
|
+ const offTop = props.recogData.fillSize.h;
|
|
|
|
+ const offLeft = props.recogData.fillSize.w;
|
|
|
|
+ const optionSize = props.recogData.optionSizes[index];
|
|
|
|
+ return {
|
|
|
|
+ width: `${optionSize.w}px`,
|
|
|
|
+ height: `${optionSize.h}px`,
|
|
|
|
+ left: `${optionSize.x + offLeft}px`,
|
|
|
|
+ top: `${offTop}px`,
|
|
|
|
+ };
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+const areaImgRef = ref();
|
|
|
|
+const areaImgStyle = ref({});
|
|
|
|
+function areaImgLoad() {
|
|
|
|
+ const areaImgDom = areaImgRef.value as HTMLImageElement;
|
|
|
|
+ const boxDom = areaImgDom.parentNode?.parentNode as HTMLDivElement;
|
|
|
|
+
|
|
|
|
+ const imgSize = getBoxImageSize({
|
|
|
|
+ box: {
|
|
|
|
+ width: boxDom.offsetWidth - 22,
|
|
|
|
+ height: boxDom.offsetHeight - 22,
|
|
|
|
+ },
|
|
|
|
+ img: {
|
|
|
|
+ width: areaImgDom.naturalWidth,
|
|
|
|
+ height: areaImgDom.naturalHeight,
|
|
|
|
+ },
|
|
|
|
+ rotate: 0,
|
|
|
|
+ });
|
|
|
|
+ const rate = imgSize.width / areaImgDom.naturalWidth;
|
|
|
|
+ areaImgStyle.value = {
|
|
|
|
+ width: `${areaImgDom.naturalWidth}px`,
|
|
|
|
+ height: `${areaImgDom.naturalHeight}px`,
|
|
|
|
+ transform: `scale(${rate}) translate(-50%, -50%)`,
|
|
|
|
+ };
|
|
|
|
+}
|
|
|
|
+
|
|
function selectOption(option: string) {
|
|
function selectOption(option: string) {
|
|
if (!props.recogData) return;
|
|
if (!props.recogData) return;
|
|
|
|
|