ImportModal.vue 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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="p-5">
  17. <div class="pb-5">1. 点击下载 <el-link type="primary"
  18. @click="downloadTemplate('Task', '任务导入模板.xlsx')">任务导入模板.xlsx</el-link>
  19. </div>
  20. <div>2. 填写excel文件, 任务名称与优先级必填</div>
  21. </div>
  22. <!-- -->
  23. </el-dialog>
  24. </template>
  25. <script lang="ts" setup>
  26. import { ref, watch } from "vue";
  27. import { Props, Emits } from "./type"
  28. import { downloadTemplate } from '@/utils/tools'
  29. const props = defineProps<Props>();
  30. const emits = defineEmits<Emits>();
  31. watch(() => props.saveLoading, (newValue) => {
  32. if (!fileInputRef.value) return
  33. fileInputRef.value.value = ""
  34. if (newValue == "3") {
  35. emits("close")
  36. return
  37. }
  38. })
  39. const fileInputRef = ref<HTMLInputElement>();
  40. function getTemplate() {
  41. }
  42. function submit() {
  43. fileInputRef.value?.click()
  44. }
  45. function closeVisible() {
  46. emits("close")
  47. }
  48. function changeFile(e: any) {
  49. emits("submit", e.target.files[0])
  50. }
  51. </script>