|
20 | 20 | </span> |
21 | 21 | <input v-else-if="schema.format === 'email'" :value="modelValue" @input="updateValue($event.target.value)" :id="name" type="email" /> |
22 | 22 | <input v-else-if="schema.format === 'password'" :value="modelValue" @input="updateValue($event.target.value)" :id="name" type="password" /> |
| 23 | + <div v-else-if="schema.format === 'binary'"> |
| 24 | + <div class="upload"> |
| 25 | + <label class="link"> |
| 26 | + <i class="fas fa-file-upload"></i> |
| 27 | + <span v-if="filename" class="custom-mx-8">{{ filename }}</span> |
| 28 | + <span v-else class="custom-mx-8">{{ $t("Select file") }}</span> |
| 29 | + <input type="file" autocomplete="off" @change="readFile" :id="name" /> |
| 30 | + </label> |
| 31 | + </div> |
| 32 | + </div> |
23 | 33 | <input v-else :value="modelValue" @input="updateValue($event.target.value)" :id="name" type="text" class="long" /> |
24 | 34 | </span> |
25 | 35 | <input v-else-if="schema.type === 'integer'" :value="modelValue" @input="updateValue($event.target.value)" :id="name" type="number" /> |
@@ -132,7 +142,8 @@ export default { |
132 | 142 | }, |
133 | 143 | data() { |
134 | 144 | return { |
135 | | - l_value: {} |
| 145 | + l_value: {}, |
| 146 | + filename: null |
136 | 147 | }; |
137 | 148 | }, |
138 | 149 | created() { |
@@ -167,6 +178,19 @@ export default { |
167 | 178 | this.$emit('update:modelValue', val); |
168 | 179 | this.$emit('updated'); |
169 | 180 | }, |
| 181 | + readFile: function (event) { |
| 182 | + if (event.target.files.length == 0) { |
| 183 | + return; |
| 184 | + } |
| 185 | + const file = event.target.files[0]; |
| 186 | + if (Object.prototype.toString.call(file) !== '[object File]') { |
| 187 | + return; |
| 188 | + } |
| 189 | + const reader = new FileReader(); |
| 190 | + reader.onload = e => this.updateValue(e.target.result); |
| 191 | + reader.readAsBinaryString(file); |
| 192 | + this.filename = file.name; |
| 193 | + }, |
170 | 194 | updateArrValue: function (val, index) { |
171 | 195 | this.l_value[index] = val; |
172 | 196 | this.$emit('update:modelValue', Object.values(this.l_value)); |
|
0 commit comments