| ¶Ô±ÈÐÂÎļþ |
| | |
| | | <script setup> |
| | | import { ref } from "vue"; |
| | | |
| | | defineOptions({ |
| | | name: "æä»¶ä¸ä¼ ç»ä»¶", |
| | | }); |
| | | |
| | | const props = defineProps({ |
| | | downloadTemplate: Function, |
| | | showTips: Boolean, |
| | | accept: { |
| | | type: String, |
| | | default: ".xls, .xlsx", |
| | | }, |
| | | headers: Object, |
| | | action: String, |
| | | disabled: { |
| | | type: Boolean, |
| | | default: false, |
| | | }, |
| | | showTip: { |
| | | type: Boolean, |
| | | default: true, |
| | | }, |
| | | autoUpload: { |
| | | type: Boolean, |
| | | default: false, |
| | | }, |
| | | limit: { |
| | | type: Number, |
| | | default: 1, |
| | | }, |
| | | }); |
| | | const emits = defineEmits(["success", "remove"]); |
| | | |
| | | const uploadRef = ref(); |
| | | const fileList = ref([]); |
| | | |
| | | const uploadApi = () => { |
| | | uploadRef.value.submit(); |
| | | }; |
| | | |
| | | const handleFileSuccess = (response, file, fileList) => { |
| | | // uploadRef.value.handleRemove(file); |
| | | emits("success", response, file, fileList); |
| | | }; |
| | | |
| | | const handleRemove = (file) => { |
| | | emits("remove", file); |
| | | }; |
| | | |
| | | const clearFiles = () => { |
| | | fileList.value = []; |
| | | }; |
| | | |
| | | defineExpose({ |
| | | fileList, |
| | | uploadApi, |
| | | clearFiles, |
| | | }); |
| | | </script> |
| | | |
| | | <template> |
| | | <el-upload |
| | | ref="uploadRef" |
| | | v-model:file-list="fileList" |
| | | drag |
| | | multiple |
| | | :action="action" |
| | | :accept="accept" |
| | | :headers="headers" |
| | | :disabled="disabled" |
| | | :auto-upload="autoUpload" |
| | | :limit="limit" |
| | | :drag="true" |
| | | :on-success="handleFileSuccess" |
| | | :on-remove="handleRemove" |
| | | > |
| | | <div class="el-upload__text"> |
| | | <el-icon class="el-icon--upload"><upload-filled /></el-icon> |
| | | <div class="el-upload__text"> |
| | | å°æä»¶æå°æ¤å¤ï¼æ |
| | | <em>ç¹å»ä¸ä¼ éä»¶</em> |
| | | </div> |
| | | </div> |
| | | <template #tip> |
| | | <div v-if="showTip" class="el-upload__tip text-center"> |
| | | åªè½ä¸ä¼ xlsx/xlsæä»¶ï¼ä¸ä¸è¶
è¿10M |
| | | <el-button |
| | | type="primary" |
| | | link |
| | | class="reset-margin" |
| | | @click="props.downloadTemplate()" |
| | | > |
| | | <span style="font-size: 12px; font-weight: normal">ä¸è½½æ¨¡æ¿</span> |
| | | </el-button> |
| | | </div> |
| | | </template> |
| | | </el-upload> |
| | | </template> |