刘光辉
4 小时以前 cf11e63b659afcc9792ab3e395f1b45d844431a8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
<script lang="ts" setup>
import type { WatermarkConfig } from '#/api/x/dms/watermark';
 
import { computed, ref, watch } from 'vue';
 
import { BasicModal } from '@jnpf/ui/modal';
 
import { useWindowSize } from '@vueuse/core';
 
import PaperPreview from './PaperPreview.vue';
 
defineOptions({ name: 'DmsWatermarkPreviewModal' });
 
const props = defineProps<{ config?: WatermarkConfig; open: boolean }>();
const emit = defineEmits<{ 'update:open': [value: boolean] }>();
const selectedPaper = ref('');
const { height: viewportHeight } = useWindowSize();
const modalBodyHeight = computed(() => Math.max(1, viewportHeight.value - 62));
const positions = computed(() => props.config?.positions || []);
const paperOptions = computed(() => positions.value.map((position) => ({ fullName: position.paperType, id: position.paperType })));
const activePosition = computed(() => positions.value.find((position) => position.paperType === selectedPaper.value));
 
watch(
  () => props.config,
  (config) => {
    selectedPaper.value = config?.positions[0]?.paperType || '';
  },
  { immediate: true },
);
</script>
 
<template>
  <BasicModal
    :open="open"
    :footer="null"
    :width="1120"
    :height="modalBodyHeight"
    :centered="false"
    :keyboard="true"
    :z-index="2200"
    title="水印预览"
    wrap-class-name="watermark-preview-modal"
    destroy-on-close
    @update:open="emit('update:open', $event)">
    <div v-if="config && activePosition" class="preview-content" :style="{ minHeight: `${modalBodyHeight}px` }">
      <div class="preview-toolbar">
        <span class="preview-name">{{ config.name }}</span>
        <JnpfRadio v-if="positions.length > 1" v-model:value="selectedPaper" :options="paperOptions" option-type="button" />
        <span v-else class="paper-name">{{ activePosition.paperType }}</span>
      </div>
      <div class="preview-workspace">
        <PaperPreview :key="`${activePosition.paperType}-landscape`" :config="config" :position="activePosition" orientation="landscape" />
        <PaperPreview :key="`${activePosition.paperType}-portrait`" :config="config" :position="activePosition" orientation="portrait" />
      </div>
    </div>
  </BasicModal>
</template>
 
<style lang="scss">
.watermark-preview-modal {
  .ant-modal {
    top: 1px;
  }
 
  .ant-modal-body > .scroll-container {
    padding: 0;
  }
}
</style>
 
<style scoped>
.preview-content {
  background: #edf0f2;
  color: #252b30;
}
 
.preview-toolbar {
  min-height: 44px;
  padding: 6px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  border-bottom: 1px solid #d9dfe2;
  background: #fff;
}
 
.preview-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
}
 
.paper-name {
  font-weight: 600;
  color: #136d73;
}
 
.preview-workspace {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: start;
  gap: 32px;
  padding: 24px;
}
 
@media (max-width: 1000px) {
  .preview-workspace {
    grid-template-columns: 1fr;
  }
}
 
@media (max-width: 600px) {
  .preview-toolbar {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
    padding: 8px 16px;
  }
 
  .preview-workspace {
    padding: 16px;
  }
}
</style>