addPlayList.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. <script setup lang="ts">
  2. import {defineComponent, onMounted, PropType, ref} from "vue";
  3. import {PlayList} from "@/types/musicType.ts";
  4. import KuiInput from "@/components/public/kui/kui-input.vue";
  5. import KuiCheckbox from "@/components/public/kui/kui-checkbox.vue";
  6. defineComponent({
  7. name: "addPlayList"
  8. })
  9. const props = defineProps({
  10. playlist: {
  11. type: Object as PropType<PlayList>,
  12. default: (): PlayList => {
  13. return {
  14. id: -1,
  15. name: '',
  16. icon: '',
  17. cover: '',
  18. description: '',
  19. playCount: 0,
  20. trackCount: 0,
  21. createTime: 0,
  22. lastPlayTime: 0,
  23. isTagSearch: false,
  24. isSync: false,
  25. isPublic: false,
  26. isLike: false
  27. }
  28. }
  29. }
  30. })
  31. const emits = defineEmits<{
  32. (e: 'close' ): void,
  33. (e: 'submit'): void
  34. }>()
  35. const isEdit = ref(false);
  36. // 歌单名称
  37. const playlistName = ref('');
  38. // 歌单描述
  39. const description = ref('');
  40. // 歌单封面
  41. const cover = ref('');
  42. const isLike = ref(false);
  43. const isPublic = ref(false);
  44. onMounted(()=>{
  45. if (props.playlist && props.playlist.id > -1)
  46. {
  47. console.log(props.playlist);
  48. isEdit.value = true;
  49. playlistName.value = props.playlist.name;
  50. description.value = props.playlist.description;
  51. cover.value = props.playlist.cover;
  52. console.log(cover.value);
  53. isLike.value = !!props.playlist.isLike;
  54. isPublic.value = !!props.playlist.isPublic;
  55. }else {
  56. isEdit.value = false;
  57. }
  58. })
  59. function closeDialog() {
  60. emits('close');
  61. }
  62. async function submitHandle() {
  63. console.log('submit');
  64. }
  65. </script>
  66. <template>
  67. <div class="dialog-content form-dialog">
  68. <div class="dialog-title">
  69. {{ isEdit? '编辑歌单' : '创建歌单' }}
  70. <div
  71. class="close-btn"
  72. @click="closeDialog()">
  73. X
  74. </div>
  75. </div>
  76. <div class="dialog-show">
  77. <div class="form-row" >
  78. <kui-input label="歌单名称"
  79. placeholder="歌单的名称"
  80. v-model:value="playlistName"
  81. />
  82. </div>
  83. <div class="form-row mt-4" >
  84. <kui-input
  85. label="歌单描述"
  86. placeholder="歌单的描述"
  87. v-model:value="description"
  88. />
  89. </div>
  90. <div class="form-row mt-4">
  91. <kui-checkbox id="isPublicPlaylist" v-model:value="isPublic" >
  92. 是否公开
  93. </kui-checkbox>
  94. </div>
  95. </div>
  96. <div class="dialog-footer">
  97. <div class="btn cancel-btn mr-2" @click="closeDialog()">取消</div>
  98. <div class="btn primary-btn" @click="submitHandle">确定</div>
  99. </div>
  100. </div>
  101. </template>
  102. <style scoped>
  103. .form-row{
  104. width: 90%;
  105. height: 40px;
  106. display: flex;
  107. align-items: center;
  108. margin: 0 auto;
  109. }
  110. </style>