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

main
wu.jian2 1 year ago
parent d810a96fba
commit e65c5049ce

@ -339,69 +339,57 @@ 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) {
if (showSize(dataUrl) > 200) { console.info(error)
const url = dataURLtoBlob(dataUrl) }
// 500KB,500, console.log(dataUrl)
imageConversion if (dataUrl) {
.compressAccurately(url, { if (showSize(dataUrl) > 200) {
size: 200, // 100kb const url = dataURLtoBlob(dataUrl)
width: 1280, // 1280 // 500KB,500,
height: 720 // 720 imageConversion.compressAccurately(
}) url,
.then((res) => { {
translateBlobToBase64(res, function (e) { size: 200, // 100kb
this.form.coverPicture = e.result width: 1280, // 1280
updateBizComponent(this.form) height: 720 // 720
.then(() => { }
this.$message({ ).then((res) => {
message: '保存成功', translateBlobToBase64(res, (e) => {
type: 'success', this.form.coverPicture = e.result
duration: 800, })
onClose: () => { })
// } else {
if (pageJump) { this.form.coverPicture = dataUrl
this.pageJump() }
} } else {
} this.form.coverPicture = ''
}) }
}) updateBizComponent(this.form).then(() => {
.finally(() => { this.$message({
that.loading = false message: '保存成功',
}) type: 'success',
}) duration: 800,
}) onClose: () => {
} else { //
this.form.coverPicture = dataUrl if (pageJump) {
updateBizComponent(this.form) this.pageJump()
.then(() => { }
this.$message({
message: '保存成功',
type: 'success',
duration: 800,
onClose: () => {
//
if (pageJump) {
this.pageJump()
}
}
})
})
.finally(() => {
this.loading = false
})
} }
}) })
.catch(() => { this.loading = false
this.loading = false }).catch((error) => {
}) console.info(error)
this.loading = false
})
}, },
createdImg () { createdImg () {
this.loading = true this.loading = true
@ -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