-
Notifications
You must be signed in to change notification settings - Fork 344
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
93 additions
and
26 deletions.
There are no files selected for viewing
56 changes: 56 additions & 0 deletions
56
magic-editor/src/console/src/components/common/magic-file.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<template> | ||
<div style="width: 100%"> | ||
<input type="file" style="display: none" ref="file" @change="onFileSelected" :accept="accept" :multiple="multiple"> | ||
<magic-input icon="upload" :readonly="true" style="width: 100%" placeholder="未选择文件" :onClick="choseFile" :value="filename"/> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
import MagicInput from './magic-input' | ||
export default { | ||
name: 'MagicFile', | ||
components: { MagicInput }, | ||
props: { | ||
placeholder: { | ||
type: String, | ||
default: '', | ||
}, | ||
accept: { | ||
type: String, | ||
default: null | ||
}, | ||
multiple: { | ||
type: Boolean, | ||
default: false | ||
}, | ||
value: { | ||
type: [FileList, String] | ||
}, | ||
width: { | ||
type: String | ||
} | ||
}, | ||
data(){ | ||
return { | ||
filename: null | ||
} | ||
}, | ||
methods: { | ||
getFiles(){ | ||
return this.$refs.file.files; | ||
}, | ||
getFile(){ | ||
return this.$refs.file.files[0]; | ||
}, | ||
onFileSelected(){ | ||
if (this.$refs.file.files[0]) { | ||
this.filename = Array.from(this.$refs.file.files).map(it => it.name).join(','); | ||
} | ||
this.$emit('update:value', this.$refs.file.files) | ||
}, | ||
choseFile(){ | ||
this.$refs.file.click(); | ||
} | ||
} | ||
} | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters