fix[create]: 预览题目统一

- 预览题目跟随pc, 取 title 值
This commit is contained in:
Huangzhe
2025-03-23 17:40:09 +08:00
parent 678c0cd6e2
commit 0d8123ffda
22 changed files with 77 additions and 166 deletions

View File

@@ -6,7 +6,7 @@ const element = defineModel<question>('element', { default: {} });
// 属性框是否激活
const active = defineModel<boolean>('active', { default: false });
// 题目索引
const index = defineModel<number>('index', { default: 0 });
const index = defineModel<number | string>('index', { default: 0 });
// 答案
const answer = defineModel<string>('answer', { default: '' });
// 错误信息
@@ -188,7 +188,7 @@ const emitValue = () => {
/**
* 上传文件
*/
async function handleUploadImg() {
async function handleUploadImg () {
const file = new File([saveCanvas('blob')!], 'sign.png', { type: 'image/png' });
const { url } = await CommonApi.cosUpload(file);
// 传递答案
@@ -197,44 +197,23 @@ async function handleUploadImg() {
</script>
<template>
<van-field
:label="element.stem"
:required="element.config.is_required === 1"
label-align="top"
:border="false"
readonly
>
<van-field :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 #label>
<contenteditable
v-model="element.stem"
className="contenteditable-label"
:active="active"
@blur="emitValue"
:errorMessage="errorMessage"
></contenteditable>
<contenteditable v-model="element.stem" className="contenteditable-label" :active="active" @blur="emitValue"
:errorMessage="errorMessage"></contenteditable>
</template>
<template #input>
<div class="sign-question">
<canvas
ref="signatureCanvas"
:width="canvasWidth"
:height="canvasHeight"
style="border: 1px dashed #ccc; border-radius: 4px"
>
<canvas ref="signatureCanvas" :width="canvasWidth" :height="canvasHeight"
style="border: 1px dashed #ccc; border-radius: 4px">
</canvas>
<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"
:class="isEraser ? 'mobilefont-huabi' : 'mobilefont-rubber'"
@click="togglePen"
></span>
<span class="icon mobilefont" :class="isEraser ? 'mobilefont-huabi' : 'mobilefont-rubber'"
@click="togglePen"></span>
<span class="icon mobilefont mobilefont-shangchuan" @click="handleUploadImg"></span>
</div>
<div class="sign-tips">请在空白区域书写您的签名</div>