fix: 默认剪裁功能丢失原图片信息

This commit is contained in:
lockingreal 2022-04-14 08:18:25 +08:00
parent 1864762de5
commit 3d09afd587

View File

@ -61,7 +61,7 @@ export interface LayUploadProps {
number?: number; number?: number;
drag?: boolean; drag?: boolean;
disabled?: boolean; disabled?: boolean;
disabledPreview?:boolean; disabledPreview?: boolean;
cut?: boolean; cut?: boolean;
cutOptions: cutOptions; cutOptions: cutOptions;
} }
@ -71,7 +71,9 @@ const getCutDownResult = () => {
const canvas = _cropper.getCroppedCanvas(); const canvas = _cropper.getCroppedCanvas();
let imgData = canvas.toDataURL('"image/png"'); let imgData = canvas.toDataURL('"image/png"');
let currentTimeStamp = new Date().valueOf(); let currentTimeStamp = new Date().valueOf();
emit("cutdone", Object.assign({ currentTimeStamp, msg: imgData })); let orgInfo = activeUploadFiles.value[0];
console.log(orgInfo);
emit("cutdone", Object.assign({ currentTimeStamp, cutResult: imgData,orginal:orgInfo }));
let newFile = dataURLtoFile(imgData); let newFile = dataURLtoFile(imgData);
commonUploadTransaction([newFile]); commonUploadTransaction([newFile]);
nextTick(() => clearAllCutEffect()); nextTick(() => clearAllCutEffect());
@ -113,7 +115,7 @@ const props = withDefaults(defineProps<LayUploadProps>(), {
number: 0, number: 0,
drag: false, drag: false,
disabled: false, disabled: false,
disabledPreview:false, disabledPreview: false,
cut: false, cut: false,
cutOptions: void 0, cutOptions: void 0,
}); });
@ -350,7 +352,10 @@ const cutTransaction = () => {};
// -> end // -> end
</script> </script>
<template> <template>
<div class="layui-upload layui-upload-wrap" :class="disabledPreview?'layui-upload-file-disabled':''"> <div
class="layui-upload layui-upload-wrap"
:class="disabledPreview ? 'layui-upload-file-disabled' : ''"
>
<input <input
class="layui-upload-file" class="layui-upload-file"
@click="clickOrgInput" @click="clickOrgInput"
@ -417,7 +422,10 @@ const cutTransaction = () => {};
/> />
</div> </div>
</lay-layer> </lay-layer>
<div class="layui-upload-list" :class="disabledPreview?'layui-upload-list-disabled':''"> <div
class="layui-upload-list"
:class="disabledPreview ? 'layui-upload-list-disabled' : ''"
>
<slot name="preview"></slot> <slot name="preview"></slot>
</div> </div>
</div> </div>