index.tsx 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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. console.log(type.value, 'type');
  25. watch(
  26. () => props.show,
  27. () => {
  28. show.value = props.show;
  29. }
  30. );
  31. watch(
  32. () => props.type,
  33. () => {
  34. type.value = props.type;
  35. }
  36. );
  37. watch(
  38. () => props.params,
  39. () => {
  40. params.value = props.params;
  41. }
  42. );
  43. return () => (
  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. {type.value === 'attend' ? (
  53. <AttendClass
  54. type={params.value.type || ''}
  55. subjectId={params.value.subjectId || ''}
  56. detailId={params.value.detailId || ''}
  57. classGroupId={params.value.classGroupId || ''}
  58. onClose={() => emit('update:show', false)}
  59. />
  60. ) : (
  61. ''
  62. )}
  63. {/* 曲谱 */}
  64. {type.value === 'notation' ? (
  65. <iframe src={params.value.src}></iframe>
  66. ) : (
  67. ''
  68. )}
  69. </NModal>
  70. );
  71. }
  72. });