|
57 | 57 | <div class="op-image popup-dropdown" v-show="s_img_dropdown_open"> |
58 | 58 | <div class="dropdown-item" @click.stop="$toggle_imgLinkAdd('imagelink')" title="ctrl+alt+l"><span>{{d_words.tl_image}}</span></div> |
59 | 59 | <div class="dropdown-item" style="overflow: hidden"> |
60 | | - <input type="file" accept="image/gif,image/jpeg,image/jpg,image/png,image/svg" @change="$imgAdd($event)" :key="img_file[0][0]"/>{{d_words.tl_upload}} |
| 60 | + <input type="file" accept="image/gif,image/jpeg,image/jpg,image/png,image/svg" @change="$imgAdd($event)" :key="img_file[0][0]" multiple="multiple"/>{{d_words.tl_upload}} |
61 | 61 | </div> |
62 | 62 |
|
63 | 63 | <div class="dropdown-item dropdown-images" v-if="index > 0" v-for="(item, index) in img_file" @click.stop="$imgFileListClick(index)"> |
|
128 | 128 | d_words: { |
129 | 129 | type: Object, |
130 | 130 | required: true |
| 131 | + }, |
| 132 | + image_filter: { |
| 133 | + type: Function, |
| 134 | + default: null, |
131 | 135 | } |
132 | 136 | }, |
133 | 137 | data() { |
|
166 | 170 | this.num = this.num + 1; |
167 | 171 | this.$emit('imgAdd', this.img_file[1][0], $file); |
168 | 172 | }, |
| 173 | + $imgFilesAdd($files) { |
| 174 | + // valid means if the image_filter exist. |
| 175 | + let valid = (typeof this.image_filter == 'function'); |
| 176 | + for(let i = 0;i < $files.length;i++) { |
| 177 | + if(valid && this.image_filter($files[i]) === true) { |
| 178 | + this.$imgFileAdd($files[i]); |
| 179 | + } else if(!valid && $files[i].type.match(/^image\//i)) { |
| 180 | + this.$imgFileAdd($files[i]); |
| 181 | + } |
| 182 | + } |
| 183 | + }, |
169 | 184 | $imgAdd($e) { |
170 | | - // 新增加 |
171 | | - this.$imgFileAdd($e.target.files[0]); |
| 185 | + this.$imgFilesAdd($e.target.files); |
172 | 186 | }, |
173 | 187 | $imgDel(pos) { |
174 | 188 | this.$emit('imgDel', this.img_file[pos]); |
|
179 | 193 | var pos = 0; |
180 | 194 | while (this.img_file.length > pos) { |
181 | 195 | if (this.img_file[pos][0] == filename) { |
182 | | - this.$emit('imgDel', filename); |
183 | | - this.img_file.splice(pos, 1); |
| 196 | + this.$imgDel(pos); |
184 | 197 | return true; |
185 | 198 | } |
186 | 199 | pos += 1; |
|
0 commit comments