fix[design]: 修复签名异常
- 签名题目在特定情况下会出现边框溢出的问题, 现在将边框的宽度设定为 window.innerWidth * 0.8
This commit is contained in:
@@ -17,7 +17,7 @@ const errorMessage = defineModel<string>('errorMessage', { default: '' });
|
|||||||
const isPreview = defineModel('isPreview', { default: false });
|
const isPreview = defineModel('isPreview', { default: false });
|
||||||
const signatureCanvas = useTemplateRef('signatureCanvas');
|
const signatureCanvas = useTemplateRef('signatureCanvas');
|
||||||
|
|
||||||
const canvasWidth = ref(100);
|
const canvasWidth = ref(window.innerWidth * 0.8);
|
||||||
const canvasHeight = computed(() => canvasWidth.value / 1);
|
const canvasHeight = computed(() => canvasWidth.value / 1);
|
||||||
const isEraser = ref(false);
|
const isEraser = ref(false);
|
||||||
|
|
||||||
@@ -62,15 +62,13 @@ const togglePen = () => {
|
|||||||
setPenStyle();
|
setPenStyle();
|
||||||
};
|
};
|
||||||
|
|
||||||
const route = useRoute()
|
const route = useRoute();
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
// 设置页面刷新标记
|
// 设置页面刷新标记
|
||||||
sessionStorage.setItem('is_page_refresh', '1');
|
sessionStorage.setItem('is_page_refresh', '1');
|
||||||
|
|
||||||
if (!signatureCanvas.value) return;
|
if (!signatureCanvas.value) return;
|
||||||
// 将 canvas 宽度和窗口的宽度保持一致
|
|
||||||
canvasWidth.value = window.innerWidth - 60;
|
|
||||||
|
|
||||||
// 获取 canvas 上下文
|
// 获取 canvas 上下文
|
||||||
ctx = signatureCanvas.value.getContext('2d')!;
|
ctx = signatureCanvas.value.getContext('2d')!;
|
||||||
@@ -278,7 +276,10 @@ function saveCanvasState () {
|
|||||||
const tx = db.transaction('canvasState', 'readwrite');
|
const tx = db.transaction('canvasState', 'readwrite');
|
||||||
const store = tx.objectStore('canvasState');
|
const store = tx.objectStore('canvasState');
|
||||||
// 只存储 base64 字符串,而不是 ImageData 对象
|
// 只存储 base64 字符串,而不是 ImageData 对象
|
||||||
store.put({ canvasDataUrl, currentStep: currentStep.value }, element.value.id || 'default_id');
|
store.put(
|
||||||
|
{ canvasDataUrl, currentStep: currentStep.value },
|
||||||
|
element.value.id || 'default_id'
|
||||||
|
);
|
||||||
tx.oncomplete = () => {
|
tx.oncomplete = () => {
|
||||||
db.close();
|
db.close();
|
||||||
};
|
};
|
||||||
@@ -290,7 +291,7 @@ function saveCanvasState () {
|
|||||||
onUnmounted(() => {
|
onUnmounted(() => {
|
||||||
// 当组件注销时,保存状态
|
// 当组件注销时,保存状态
|
||||||
saveCanvasState();
|
saveCanvasState();
|
||||||
})
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 恢复canvas 状态
|
* 恢复canvas 状态
|
||||||
@@ -352,7 +353,7 @@ function restoreCanvasState () {
|
|||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
// 当组件加载时,恢复状态
|
// 当组件加载时,恢复状态
|
||||||
restoreCanvasState();
|
restoreCanvasState();
|
||||||
})
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 清除画布状态
|
* 清除画布状态
|
||||||
@@ -386,23 +387,44 @@ window.addEventListener('beforeunload', () => {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<van-field :label="element.stem" :required="element.config.is_required === 1" label-align="top" :border="false"
|
<van-field
|
||||||
readonly>
|
:label="element.stem"
|
||||||
|
:required="element.config.is_required === 1"
|
||||||
|
label-align="top"
|
||||||
|
:border="false"
|
||||||
|
readonly
|
||||||
|
>
|
||||||
<template #left-icon> {{ isPreview ? element.title : index + 1 }}. </template>
|
<template #left-icon> {{ isPreview ? element.title : index + 1 }}. </template>
|
||||||
<template #label>
|
<template #label>
|
||||||
<contenteditable v-model="element.stem" className="contenteditable-label" :active="active" @blur="emitValue"
|
<contenteditable
|
||||||
:errorMessage="errorMessage"></contenteditable>
|
v-model="element.stem"
|
||||||
|
className="contenteditable-label"
|
||||||
|
:active="active"
|
||||||
|
@blur="emitValue"
|
||||||
|
:errorMessage="errorMessage"
|
||||||
|
></contenteditable>
|
||||||
</template>
|
</template>
|
||||||
<template #input>
|
<template #input>
|
||||||
<div class="sign-question">
|
<div class="sign-question">
|
||||||
<canvas ref="signatureCanvas" :width="canvasWidth" :height="canvasHeight"
|
<canvas
|
||||||
style="border: 1px dashed #ccc; border-radius: 4px">
|
ref="signatureCanvas"
|
||||||
|
:width="canvasWidth"
|
||||||
|
:height="canvasHeight"
|
||||||
|
style="border: 1px dashed #ccc; border-radius: 4px"
|
||||||
|
>
|
||||||
</canvas>
|
</canvas>
|
||||||
<div class="sign-text" :class="{ show: true }">
|
<div class="sign-text" :class="{ show: true }">
|
||||||
<span class="icon mobilefont mobilefont-qingkong" title="清空" @click="clearCanvas"></span>
|
<span
|
||||||
|
class="icon mobilefont mobilefont-qingkong"
|
||||||
|
title="清空"
|
||||||
|
@click="clearCanvas"
|
||||||
|
></span>
|
||||||
<span class="icon mobilefont mobilefont-chexiao" @click="undo"></span>
|
<span class="icon mobilefont mobilefont-chexiao" @click="undo"></span>
|
||||||
<span class="icon mobilefont" :class="isEraser ? 'mobilefont-huabi' : 'mobilefont-rubber'"
|
<span
|
||||||
@click="togglePen"></span>
|
class="icon mobilefont"
|
||||||
|
:class="isEraser ? 'mobilefont-huabi' : 'mobilefont-rubber'"
|
||||||
|
@click="togglePen"
|
||||||
|
></span>
|
||||||
<span class="icon mobilefont mobilefont-shangchuan" @click="handleUploadImg"></span>
|
<span class="icon mobilefont mobilefont-shangchuan" @click="handleUploadImg"></span>
|
||||||
</div>
|
</div>
|
||||||
<div class="sign-tips">请在空白区域书写您的签名</div>
|
<div class="sign-tips">请在空白区域书写您的签名</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user