ImportModal.vue 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <template>
  2. <el-dialog v-model="props.visible" width="500px" :show-close="false" :close-on-click-modal="false" top="10vh"
  3. class="importModal">
  4. <template #header="{ titleId, titleClass }">
  5. <div class="flex justify-between items-center border-b pb-3">
  6. <h4 :id="titleId" :class="titleClass">导入任务</h4>
  7. <div>
  8. <el-button type="primary" :loading="['2'].includes(props.saveLoading)" @click="submit()">
  9. <input type="file" v-show="false" ref="fileInputRef" @change="changeFile" accept=".xls,.xlsx" />
  10. 导入
  11. </el-button>
  12. <el-button @click="closeVisible()">取消</el-button>
  13. </div>
  14. </div>
  15. </template>
  16. <div class="text-lg p-5">
  17. <div class="pb-5">1. 点击下载 <a href="###" download class="text-[#79BBFF]">任务导入模板</a></div>
  18. <div>2. 填写excel文件, 任务名称与优先级必填</div>
  19. </div>
  20. </el-dialog>
  21. </template>
  22. <script lang="ts" setup>
  23. import { ref, watch } from "vue";
  24. import { Props, Emits } from "./type"
  25. const props = defineProps<Props>();
  26. const emits = defineEmits<Emits>();
  27. watch(() => props.saveLoading, (newValue) => {
  28. if (!fileInputRef.value) return
  29. fileInputRef.value.value = ""
  30. if (newValue == "3") {
  31. emits("close")
  32. return
  33. }
  34. })
  35. const fileInputRef = ref<HTMLInputElement>();
  36. function submit() {
  37. fileInputRef.value?.click()
  38. }
  39. function closeVisible() {
  40. emits("close")
  41. }
  42. function changeFile(e: any) {
  43. emits("submit", e.target.files[0])
  44. }
  45. </script>