addScan.vue 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <script setup lang="ts">
  2. import {defineComponent, ref} from "vue";
  3. import KuiInput from "@/components/public/kui/kui-input.vue";
  4. import message from "@/components/public/kui/message";
  5. import {selectScanDir} from "@/apis/musicControl.ts";
  6. defineComponent({
  7. name: "addScanDialog"
  8. })
  9. const emits = defineEmits<{
  10. (e: 'close' ): void,
  11. (e: 'submit'): void
  12. }>()
  13. const dirPath = ref('');
  14. function closeDialog() {
  15. emits('close');
  16. }
  17. async function selectPathHandle() {
  18. let responseData = await selectScanDir(dirPath.value);
  19. // console.log(responseData)
  20. if (responseData.code === 0) {
  21. dirPath.value = responseData.data;
  22. // message.success(`选择目录: ${responseData.data}`);
  23. } else {
  24. message.error(responseData.msg);
  25. }
  26. }
  27. </script>
  28. <template>
  29. <div class="dialog-content form-dialog">
  30. <div class="dialog-title">
  31. 添加扫描路径
  32. <div
  33. class="close-btn"
  34. @click="closeDialog()">
  35. X
  36. </div>
  37. </div>
  38. <div class="dialog-show">
  39. <div class="form-row" >
  40. <kui-input label="扫描路径"
  41. placeholder="点击选择文件"
  42. @firstClick="selectPathHandle"
  43. :value="dirPath"
  44. />
  45. </div>
  46. </div>
  47. <div class="dialog-footer">
  48. <div class="btn cancel-btn mr-2" @click="closeDialog()">取消</div>
  49. <div class="btn primary-btn" @click="emits('submit')">确定</div>
  50. </div>
  51. </div>
  52. </template>
  53. <style scoped>
  54. .form-row{
  55. width: 100%;
  56. height: 40px;
  57. display: flex;
  58. align-items: center;
  59. }
  60. </style>