|
5 | 5 | <input v-bind:disabled="uploading" v-bind:id="'g-core-upload-input-' + formID" v-bind:name="name" v-bind:multiple="multiple" type="file" v-bind:accept="inputAccept" v-on:change="change" style="width: 100%; height: 100%;">
|
6 | 6 | </form>
|
7 | 7 | <div class="g-core-image-corp-container" v-bind:id="'vciu-modal-' + formID" v-show="hasImage">
|
8 |
| - <div class="image-aside"> |
9 |
| - <div class="g-crop-image-box"> |
10 |
| - <crop :form-id="formID" ref="cropBox" :ratio="cropRatio"></crop> |
| 8 | + <div class="image-aside"> |
| 9 | + <div class="g-crop-image-box"> |
| 10 | + <crop :form-id="formID" ref="cropBox" :ratio="cropRatio"></crop> |
| 11 | + </div> |
| 12 | + </div> |
| 13 | + <div class="info-aside"> |
| 14 | + <p class="btn-groups"> |
| 15 | + <button type="button" v-on:click="doCrop" class="btn btn-upload">{{cropBtn.ok}}</button> |
| 16 | + <button type="button" v-on:click="cancel()" class="btn btn-cancel">{{cropBtn.cancel}}</button> |
| 17 | + </p> |
11 | 18 | </div>
|
12 |
| - </div> |
13 |
| - <div class="info-aside"> |
14 |
| - <p class="btn-groups"> |
15 |
| - <button type="button" v-on:click="doCrop" class="btn btn-upload">{{cropBtn.ok}}</button> |
16 |
| - <button type="button" v-on:click="cancel()" class="btn btn-cancel">{{cropBtn.cancel}}</button> |
17 |
| - </p> |
18 |
| - </div> |
19 |
| -</div> |
20 | 19 | </div>
|
21 |
| - |
22 |
| - |
| 20 | +</div> |
23 | 21 | </template>
|
24 | 22 |
|
25 | 23 | <style src="./style/style.css">
|
|
99 | 97 | if(this.crop) {
|
100 | 98 | this.__showImage();
|
101 | 99 | return;
|
102 |
| -
|
103 | 100 | }
|
104 | 101 | this. __dispatch('imagechanged',this.files[0]);
|
105 | 102 | this.tryAjaxUpload();
|
|
137 | 134 | let btn = e.target;
|
138 | 135 | btn.value = btn.value + '...';
|
139 | 136 | btn.disabled = true;
|
140 |
| - if(typeof this.data !== 'object') { |
| 137 | + if (typeof this.data !== 'object') { |
141 | 138 | this.data = {};
|
142 | 139 | }
|
143 |
| -
|
144 |
| - let $selectCrop = this.__find('.select-recorte'); |
145 | 140 | this.data["request"] = "crop";
|
| 141 | + const cropBox = this.$refs.cropBox; |
| 142 | + const newCSSObj = cropBox.getCropData(); |
146 | 143 |
|
147 |
| - this.data["toCropImgX"] = parseInt(window.getComputedStyle($selectCrop).left) * this.imgChangeRatio; |
148 |
| - this.data["toCropImgY"] = parseInt(window.getComputedStyle($selectCrop).top) * this.imgChangeRatio; |
149 |
| - this.data["toCropImgW"] = parseInt(window.getComputedStyle($selectCrop).width) * this.imgChangeRatio; |
150 |
| - this.data["toCropImgH"] = parseInt(window.getComputedStyle($selectCrop).height) * this.imgChangeRatio; |
151 |
| - this.tryAjaxUpload(function() { |
152 |
| - btn.value = btn.value.replace('...',''); |
153 |
| - btn.disabled = false; |
154 |
| - }); |
| 144 | + for (const k of Object.keys(newCSSObj)) { |
| 145 | + console.log(k); |
| 146 | + this.data[k] = newCSSObj[k]; |
| 147 | + } |
| 148 | + if (this.maxWidth) { |
| 149 | + this.data['maxWidth'] = this.maxWidth; |
| 150 | + } |
| 151 | + if (this.maxHeight) { |
| 152 | + this.data['maxHeight'] = this.maxHeight; |
| 153 | + } |
| 154 | + const upload = () => { |
| 155 | + this.tryAjaxUpload(() => { |
| 156 | + btn.value = btn.value.replace('...',''); |
| 157 | + btn.disabled = false; |
| 158 | + }); |
| 159 | + }; |
| 160 | + if (this.crop === 'local') { |
| 161 | + const targetImage = cropBox.getCropImage(); |
| 162 | + this.data.compress = 100 - this.compress; |
| 163 | + return canvasHelper.crop(targetImage, this.data, () => { |
| 164 | + // upload(); |
| 165 | + }) |
| 166 | + } |
| 167 | + upload(); |
155 | 168 |
|
156 | 169 | },
|
157 | 170 | cancel() {
|
|
175 | 188 | data.append(self.inputOfFile, this.files[i]);
|
176 | 189 | }
|
177 | 190 | if (typeof this.data === 'object') {
|
178 |
| -
|
179 | 191 | for(let k in this.data) {
|
180 | 192 | if(this.data[k] !== undefined) {
|
181 | 193 | data.append(k,this.data[k]);
|
|
194 | 206 | self.__dispatch('imageuploaded',res);
|
195 | 207 | });
|
196 | 208 | },
|
197 |
| - // resize and drag move |
198 |
| - resize(e) { |
199 |
| - e.stopPropagation(); |
200 |
| - let $el = e.target.parentElement; |
201 |
| - let $container = this.__find('.g-crop-image-principal'); |
202 |
| - let resizedObj = new Resize($el,$container,this.cropRatio,e); |
203 |
| - }, |
204 |
| -
|
205 |
| - drag(e) { |
206 |
| - e.preventDefault(); |
207 |
| - let $el = e.target; |
208 |
| - let $container = this.__find('.g-crop-image-principal'); |
209 |
| - let dragObj = new Drag($el,$container,e); |
210 |
| - } |
211 | 209 | },
|
212 | 210 |
|
213 | 211 | };
|
|
0 commit comments