| | |
| | | type: Boolean, |
| | | default: false, |
| | | }, |
| | | showTip: { |
| | | type: Boolean, |
| | | default: true, |
| | | }, |
| | | autoUpload: { |
| | | type: Boolean, |
| | | default: false, |
| | | }, |
| | | limit: { |
| | | type: Number, |
| | | default: 1, |
| | | }, |
| | | }); |
| | | const emits = defineEmits(["success", "error"]); |
| | | const emits = defineEmits(["success", "remove"]); |
| | | |
| | | const uploadRef = ref(); |
| | | const fileList = ref([]); |
| | |
| | | }; |
| | | |
| | | const handleFileSuccess = (response, file, fileList) => { |
| | | upload.open = false; |
| | | upload.isUploading = false; |
| | | uploadRef.value.handleRemove(file); |
| | | // uploadRef.value.handleRemove(file); |
| | | emits("success", response, file, fileList); |
| | | }; |
| | | |
| | | const handleRemove = (file) => { |
| | | emits("remove", file); |
| | | }; |
| | | |
| | | defineExpose({ |
| | |
| | | :accept="accept" |
| | | :headers="headers" |
| | | :disabled="disabled" |
| | | :auto-upload="false" |
| | | :limit="1" |
| | | :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> |
| | | </div> |
| | | <template #tip> |
| | | <div class="el-upload__tip text-center"> |
| | | <div v-if="showTip" class="el-upload__tip text-center"> |
| | | 只能上传xlsx/xls文件,且不超过10M |
| | | <el-button |
| | | type="primary" |