PrintSettingDialog.vue 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <template>
  2. <div class="print-setting-popup" v-if="show">
  3. <Dialog :show="show" :dialogName="dialogName" :close="false">
  4. <!-- header -->
  5. <template #header>
  6. <p>{{ $t('compare.printSetting') }}</p>
  7. </template>
  8. <!-- content -->
  9. <div class="select-content">
  10. <div @click="printFile = 'old'" class="option"><RadioBtnSel v-if="printFile === 'old'" /><RadioBtnDis v-else />{{ $t('compare.printOldFile') }}</div>
  11. <div @click="printFile = 'new'" class="option"><RadioBtnSel v-if="printFile === 'new'" /><RadioBtnDis v-else />{{ $t('compare.printNewFile') }}</div>
  12. </div>
  13. <!-- footer -->
  14. <template #footer>
  15. <div class="rect-button white" @click="closeDialog">{{ $t('cancel') }}</div>
  16. <div class="rect-button blue" @click="handlePrint">{{ $t('ok') }}</div>
  17. </template>
  18. </Dialog>
  19. </div>
  20. </template>
  21. <script setup>
  22. import { ref, computed, watch } from 'vue'
  23. import { useViewerStore } from '@/stores/modules/viewer'
  24. import { useDocumentStore } from '@/stores/modules/document'
  25. import core from '@/core'
  26. const { triggerPrinting } = core
  27. const useViewer = useViewerStore()
  28. const useDocument = useDocumentStore()
  29. const dialogName = 'printSettingDialog'
  30. const show = computed(() => useViewer.isElementOpen(dialogName))
  31. const compareResult = computed(() => useDocument.getCompareResult)
  32. const printFile = ref('old')
  33. const closeDialog = () => {
  34. useViewer.closeElement(dialogName)
  35. }
  36. const handlePrint = async () => {
  37. let url = null
  38. if (printFile.value === 'old') {
  39. url = compareResult.value.oldFile.url
  40. } else if (printFile.value === 'new') {
  41. url = compareResult.value.newFile.url
  42. }
  43. closeDialog()
  44. useViewer.setDownloading(true)
  45. try {
  46. await triggerPrinting(url)
  47. useViewer.setDownloading(false)
  48. } catch (error) {
  49. console.log(error)
  50. }
  51. }
  52. </script>
  53. <style lang="scss">
  54. .print-setting-popup {
  55. header {
  56. padding: 4px 0;
  57. }
  58. .dialog-container {
  59. width: 325px;
  60. padding: 30px 20px;
  61. main {
  62. margin-bottom: 20px;
  63. }
  64. }
  65. }
  66. </style>