feat: add canvas manipulation functions and integrate signature submission in MainLayout (unfinished)
This commit is contained in:
parent
dc3ec9d1c8
commit
db68bd2993
2 changed files with 23 additions and 5 deletions
|
|
@ -4,7 +4,7 @@ import { useQuasar } from 'quasar';
|
||||||
import SignaturePad from 'signature_pad';
|
import SignaturePad from 'signature_pad';
|
||||||
import Cropper from 'cropperjs';
|
import Cropper from 'cropperjs';
|
||||||
|
|
||||||
defineExpose({ clearCanvas, clearUpload });
|
defineExpose({ setCanvas, getCanvas, clearCanvas, clearUpload });
|
||||||
|
|
||||||
const $q = useQuasar();
|
const $q = useQuasar();
|
||||||
const isDarkActive = computed(() => $q.dark.isActive);
|
const isDarkActive = computed(() => $q.dark.isActive);
|
||||||
|
|
@ -44,9 +44,6 @@ async function initializeSignaturePad() {
|
||||||
|
|
||||||
if (canvas) {
|
if (canvas) {
|
||||||
signaturePad.value = new SignaturePad(canvas, {
|
signaturePad.value = new SignaturePad(canvas, {
|
||||||
backgroundColor: isDarkActive.value
|
|
||||||
? 'rgb(21,25,29)'
|
|
||||||
: 'rgb(248,249,250)',
|
|
||||||
penColor: 'blue',
|
penColor: 'blue',
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -79,6 +76,15 @@ function changeColor(color: string) {
|
||||||
currentColor.value = color;
|
currentColor.value = color;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function setCanvas() {
|
||||||
|
const data = signaturePad.value.toDataURL('image/png');
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getCanvas(signature: string) {
|
||||||
|
signaturePad.value.fromDataURL(signature);
|
||||||
|
}
|
||||||
|
|
||||||
function clearCanvas() {
|
function clearCanvas() {
|
||||||
signaturePad.value.clear();
|
signaturePad.value.clear();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -50,7 +50,6 @@ const leftDrawerMini = ref(false);
|
||||||
const unread = computed<number>(
|
const unread = computed<number>(
|
||||||
() => notificationData.value.filter((v) => !v.read).length || 0,
|
() => notificationData.value.filter((v) => !v.read).length || 0,
|
||||||
);
|
);
|
||||||
// const filterRole = ref<string[]>();
|
|
||||||
const userImage = ref<string>();
|
const userImage = ref<string>();
|
||||||
const userGender = ref('');
|
const userGender = ref('');
|
||||||
const canvasRef = ref();
|
const canvasRef = ref();
|
||||||
|
|
@ -124,6 +123,17 @@ function readNoti(id: string) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function signatureSubmit() {
|
||||||
|
const signature = canvasRef.value.setCanvas();
|
||||||
|
userStore.setSignature(signature);
|
||||||
|
canvasModal.value = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function signatureFetch() {
|
||||||
|
const ret = await userStore.getSignature();
|
||||||
|
if (ret) canvasRef.value.getCanvas(ret);
|
||||||
|
}
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
initTheme();
|
initTheme();
|
||||||
initLang();
|
initLang();
|
||||||
|
|
@ -502,6 +512,8 @@ onMounted(async () => {
|
||||||
no-app-box
|
no-app-box
|
||||||
:title="$t('menu.profile.addSignature')"
|
:title="$t('menu.profile.addSignature')"
|
||||||
:close="() => (canvasModal = false)"
|
:close="() => (canvasModal = false)"
|
||||||
|
:submit="signatureSubmit"
|
||||||
|
:show="signatureFetch"
|
||||||
>
|
>
|
||||||
<CanvasComponent ref="canvasRef" v-model:modal="canvasModal" />
|
<CanvasComponent ref="canvasRef" v-model:modal="canvasModal" />
|
||||||
<template #footer>
|
<template #footer>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue