22
schangxiang@126.com
2025-05-21 05c47e0a832bbd2b8bafb732fc55c1ef8e9b97e0
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
import { PropType, SetupContext, computed, defineComponent, useSlots } from 'vue'
import BaseDialog from '@/components/BaseDialog/index.vue'
import styles from './DialogPreView.module.scss'
import { useVModel } from '@vueuse/core'
import Chart from './Chart'
import Picture from './Picture'
export default defineComponent({
  name: 'DialogPreView',
  props: {
    title: {
      type: String,
      default: '预览',
    },
    isChart: {
      type: Boolean,
      default: false,
    },
    modelValue: {
      type: Boolean,
      default: false,
    },
    chartOptions: {
      type: Object,
      default: () => ({}),
    },
    picList: {
      type: Object as PropType<string[]>,
      default: () => [],
    },
  },
  emits: ['update:modelValue', 'close', 'confirm'],
  setup(props, { emit, attrs }: SetupContext) {
    const visible = useVModel(props)
    const slots = useSlots()
    const onClose = () => {
      visible.value = false
      emit('close')
    }
    const onConfirm = () => {
      emit('confirm')
    }
 
    const height = computed(() => {
      return (attrs.height as string) || '578px'
    })
 
    return () => (
      <BaseDialog
        destroy-on-close
        class={styles.drawer}
        style="background: #fff"
        width="900px"
        height="578px"
        title={props.title}
        v-model={visible.value}
        onClose={onClose}
        onConfirm={onConfirm}
        v-slots={{
          footer: () => {
            slots.footer ? slots.footer : null
          },
        }}
      >
        <div class={styles.container}>
          {props.isChart ? (
            <Chart chartOptions={props.chartOptions} />
          ) : (
            <Picture height={height.value} picList={props.picList} />
          )}
        </div>
      </BaseDialog>
    )
  },
})