123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142 |
- <template>
- <Dialog class="digital-signature-dialog trackpad" :show="true" :dialogName="dialogName">
- <template #header>
- <CloseB class="close" @click="close" />
- </template>
- <div class="paint-container" ref="paintContainer">
- <canvas id="digitalTrackpadCanvas" :width="canvasWidth" :height="canvasHeight"></canvas>
- </div>
- <template #footer>
- <div class="rect-button white" @click="clear">{{ $t('signatures.clear') }}</div>
- <div class="rect-button white" @click="close">{{ $t('cancel') }}</div>
- <div class="rect-button blue" @click="save">{{ $t('ok') }}</div>
- </template>
- </Dialog>
- </template>
- <script setup>
- import { computed, watch, ref, nextTick } from 'vue'
- import { useViewerStore } from '@/stores/modules/viewer'
- import { useDocumentStore } from '@/stores/modules/document'
- import core from '@/core'
- import { isMobile } from '@/helpers/device'
- const emits = defineEmits(['modifyImage'])
- const dialogName = 'digitalSignCreatePanel'
- const useViewer = useViewerStore()
- const useDocument = useDocumentStore()
- const show = computed(() => useViewer.isElementOpen(dialogName))
- const canvasWidth = ref(578)
- const canvasHeight = ref(isMobile ? 0 : 270)
- const paintContainer = ref()
- watch(() => show.value, (newValue, oldValue) => {
- if (newValue) {
- if (isMobile) {
- nextTick(() => {
- const { clientWidth, clientHeight } = paintContainer.value
- clientWidth && canvasWidth.value !== clientWidth && (canvasWidth.value = clientWidth)
- clientHeight && canvasHeight.value !== clientHeight && (canvasHeight.value = clientHeight)
- })
- }
- }
- })
- const close = () => {
- useViewer.closeElement(dialogName)
- clear()
- }
- const clear = () => {
- core.handleSign({
- flag: 'clear'
- })
- }
- const save = () => {
- const imageBase64 = core.handleSign({
- type: 1,
- flag: 'image',
- })
- emits('modifyImage', imageBase64)
- close()
- }
- </script>
- <style lang="scss">
- .digital-signature-dialog {
- .dialog-container {
- padding: 16px 24px;
- main {
- margin-top: 40px;
- margin-bottom: 12px;
- }
- footer {
- .rect-button.white {
- border-radius: 2px;
- }
- .rect-button:first-child {
- margin-right: auto;
- }
- }
- }
- .paint-container {
- position: relative;
- display: flex;
- justify-content: center;
- align-items: center;
- height: 270px;
- background-color: #F2F3F5;
- canvas {
- z-index: 1;
- }
- p {
- position: absolute;
- font-size: 14px;
- line-height: 16px;
- color: #757780;
- pointer-events: none;
- }
- }
- }
- @media screen and (max-width: 640px) {
- .digital-signature-dialog.trackpad {
- .dialog-container {
- display: flex;
- flex-direction: column;
- width: 90vh;
- height: 90vw;
- transform: rotate(90deg);
- -ms-transform: rotate(90deg);
- -moz-transform: rotate(90deg);
- -webkit-transform: rotate(90deg);
- -o-transform: rotate(90deg);
- main {
- flex: 1;
- .paint-container {
- width: 100%;
- height: 100%;
- }
- }
- }
- }
- }
- </style>
|