ImportModal.vue 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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-link type="primary" style="margin-left:5px;" :underline="false" href="./upload/任务导入模板.xlsx"
  21. :download="'任务导入模板.xlsx'">任务导入模板</el-link> -->
  22. </el-dialog>
  23. </template>
  24. <script lang="ts" setup>
  25. import { ref, watch } from "vue";
  26. import { Props, Emits } from "./type"
  27. const props = defineProps<Props>();
  28. const emits = defineEmits<Emits>();
  29. watch(() => props.saveLoading, (newValue) => {
  30. if (!fileInputRef.value) return
  31. fileInputRef.value.value = ""
  32. if (newValue == "3") {
  33. emits("close")
  34. return
  35. }
  36. })
  37. const fileInputRef = ref<HTMLInputElement>();
  38. function submit() {
  39. fileInputRef.value?.click()
  40. }
  41. function closeVisible() {
  42. emits("close")
  43. }
  44. function changeFile(e: any) {
  45. emits("submit", e.target.files[0])
  46. }
  47. </script>