fix: 修复业务组件开发时,组件渲染出错导致数据无法保存的情况,仅将封面字段数据传入空值

main
wu.jian2 1 year ago
parent d810a96fba
commit e65c5049ce

@ -339,49 +339,41 @@ export default {
} }
}) })
}, },
save (pageJump = false) { async save (pageJump = false) {
this.loading = true this.loading = true
let dataUrl = ''
const node = document.querySelector('.remote-preview-inner-wrap') const node = document.querySelector('.remote-preview-inner-wrap')
// node // node
const childrenNode = node.children[0] const childrenNode = node.children[0]
toJpeg(childrenNode, { quality: 0.2 }) try {
.then((dataUrl) => { dataUrl = await toJpeg(childrenNode, { quality: 0.2 })
const that = this } catch (error) {
console.info(error)
}
console.log(dataUrl)
if (dataUrl) {
if (showSize(dataUrl) > 200) { if (showSize(dataUrl) > 200) {
const url = dataURLtoBlob(dataUrl) const url = dataURLtoBlob(dataUrl)
// 500KB,500, // 500KB,500,
imageConversion imageConversion.compressAccurately(
.compressAccurately(url, { url,
{
size: 200, // 100kb size: 200, // 100kb
width: 1280, // 1280 width: 1280, // 1280
height: 720 // 720 height: 720 // 720
})
.then((res) => {
translateBlobToBase64(res, function (e) {
this.form.coverPicture = e.result
updateBizComponent(this.form)
.then(() => {
this.$message({
message: '保存成功',
type: 'success',
duration: 800,
onClose: () => {
//
if (pageJump) {
this.pageJump()
} }
} ).then((res) => {
}) translateBlobToBase64(res, (e) => {
}) this.form.coverPicture = e.result
.finally(() => {
that.loading = false
})
}) })
}) })
} else { } else {
this.form.coverPicture = dataUrl this.form.coverPicture = dataUrl
updateBizComponent(this.form) }
.then(() => { } else {
this.form.coverPicture = ''
}
updateBizComponent(this.form).then(() => {
this.$message({ this.$message({
message: '保存成功', message: '保存成功',
type: 'success', type: 'success',
@ -393,13 +385,9 @@ export default {
} }
} }
}) })
})
.finally(() => {
this.loading = false this.loading = false
}) }).catch((error) => {
} console.info(error)
})
.catch(() => {
this.loading = false this.loading = false
}) })
}, },
@ -421,7 +409,8 @@ export default {
}) })
this.loading = false this.loading = false
}) })
.catch(() => { .catch((error) => {
console.info(error)
this.$message.warning('出现未知错误,请重试') this.$message.warning('出现未知错误,请重试')
this.loading = false this.loading = false
}) })

Loading…
Cancel
Save