index.tsx 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. import { PropType, defineComponent, onMounted, ref, toRefs, watch } from 'vue';
  2. import styles from './index.module.less';
  3. import { NModal } from 'naive-ui';
  4. import AttendClass from '../attend-class';
  5. export default defineComponent({
  6. name: 'preview-window',
  7. props: {
  8. show: {
  9. type: Boolean,
  10. default: false
  11. },
  12. type: {
  13. type: String,
  14. default: ''
  15. },
  16. params: {
  17. type: Object as PropType<any>,
  18. default: () => ({})
  19. }
  20. },
  21. emit: ['update:show'],
  22. setup(props, { emit }) {
  23. const { show, type, params } = toRefs(props);
  24. watch(
  25. () => props.show,
  26. () => {
  27. show.value = props.show;
  28. }
  29. );
  30. watch(
  31. () => props.type,
  32. () => {
  33. type.value = props.type;
  34. }
  35. );
  36. watch(
  37. () => props.params,
  38. () => {
  39. params.value = props.params;
  40. }
  41. );
  42. return () => (
  43. <>
  44. <NModal
  45. v-model:show={show.value}
  46. onUpdate:show={() => {
  47. emit('update:show', show.value);
  48. }}
  49. class={styles.previewWindow}
  50. showIcon={false}
  51. displayDirective="show">
  52. <>
  53. {show.value ? (
  54. type.value == 'attend' ? (
  55. <AttendClass
  56. type={params.value.type || ''}
  57. subjectId={params.value.subjectId || ''}
  58. detailId={params.value.detailId || ''}
  59. classGroupId={params.value.classGroupId || ''}
  60. onClose={() => emit('update:show', false)}
  61. />
  62. ) : type.value == 'notation' ? (
  63. <iframe src={params.value.src}></iframe>
  64. ) : (
  65. ''
  66. )
  67. ) : (
  68. ''
  69. )}
  70. </>
  71. </NModal>
  72. </>
  73. );
  74. }
  75. });