|
@@ -31,7 +31,7 @@
|
|
|
</template>
|
|
|
<script>
|
|
|
import { VueCropper } from 'vue-cropper'
|
|
|
-import { uploadFileWithBase64 } from '@/api/appTenant'
|
|
|
+import { uploadFileWithBase64, uploadFile } from '@/api/appTenant'
|
|
|
export default {
|
|
|
name: 'CropperModal',
|
|
|
components: {
|
|
@@ -86,14 +86,20 @@ export default {
|
|
|
const that = this
|
|
|
that.confirmLoading = true
|
|
|
// 获取截图的base64 数据 getCropBlob getCropData
|
|
|
- this.$refs.cropper.getCropData(async (data) => {
|
|
|
+ this.$refs.cropper.getCropBlob(async (data) => {
|
|
|
const name = (this.options.name ? this.options.name.split('.')[0] : +new Date()) + '.png'
|
|
|
let form = new FormData()
|
|
|
- form.append('base64Str', data)
|
|
|
- form.append('fileName', name)
|
|
|
- form.append('extName', 'png')
|
|
|
+ form.append('file', this.blobToFile(data), name)
|
|
|
+ // form.append('base64Str', data)
|
|
|
+ // form.append('fileName', name)
|
|
|
+ // form.append('extName', 'png')
|
|
|
try {
|
|
|
- const res = await uploadFileWithBase64(form)
|
|
|
+ const res = await uploadFile(form)
|
|
|
+ // form.append('base64Str', data)
|
|
|
+ // form.append('fileName', name)
|
|
|
+ // form.append('extName', 'png')
|
|
|
+ // try {
|
|
|
+ // const res = await uploadFileWithBase64(form)
|
|
|
that.$emit('cropper-ok', res)
|
|
|
} catch(err) {
|
|
|
that.$message.error(err)
|