From 01d12aba727904fbc1f62680edaab2912413903b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A7=8B=E4=BA=8E=E5=88=9D=E8=A7=81?= <752204717@qq.com> Date: Wed, 11 Sep 2024 16:35:18 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E8=AF=BE=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/modules/shop/curriculum.vue | 59 ++++++++++----------------- 1 file changed, 21 insertions(+), 38 deletions(-) diff --git a/src/views/modules/shop/curriculum.vue b/src/views/modules/shop/curriculum.vue index 133d833..b4b243c 100644 --- a/src/views/modules/shop/curriculum.vue +++ b/src/views/modules/shop/curriculum.vue @@ -357,6 +357,10 @@ export default { // { required: true, message: '排序不能为空', trigger: 'blur' } // ] }, + urlList:{ +edit:'/master/shopProduct/editProductDetail', +add:'/master/shopProduct/addProduct', + }, // 富文本编辑器配置 editorOption: { modules: { @@ -402,6 +406,7 @@ export default { if (op.insert && typeof op.insert !== "string") { // 如果粘贴了图片,这里会是一个对象 if (op.insert.image) { + if (op.insert.image.includes(";base64")) { let file = that.dataURLtoFile( op.insert.image, @@ -476,10 +481,24 @@ export default { // .catch(err => { // console.log(err); // }); + }else{ + console.log('op.insert.image at line 407:', op.insert.image) + // 获取光标所在位置 + var quill = that.$refs.myQuillEditor.quill; + var length = this.quillEditorIndex; + + console.log("length at line 397:", length); + + // 插入图片,res为服务器返回的图片链接地址 + quill.insertEmbed(length, "image", op.insert.image); + // 调整光标到最后 + quill.setSelection(length + 1); + this.uploadLoading = false; } } } }); + delta.ops = ops; // 不加会报错 return delta; }, @@ -686,7 +705,7 @@ export default { this.$http .request({ - url: this.$http.adornUrl("/master/shopProduct/editProductDetail"), + url: this.$http.adornUrl(this.dataForm.productId?this.urlList.edit:this.urlList.add), method: "POST", data: { ...this.dataForm, @@ -699,43 +718,7 @@ export default { } }) - // this.$http({ - // url: this.$http.adornUrl( - // `/master/shopProduct/editProductDetail/${ - // !this.dataForm.productId ? "save" : "update" - // }` - // ), - // method: "post", - // // data: this.$http.adornData({ - // // productId: this.dataForm.productId || undefined, - // // productName: this.dataForm.productName, - // // price: this.dataForm.price, - // // weight: this.dataForm.weight, - // // publishStatus: this.dataForm.publishStatus, - // // productPid: this.dataForm.poids[this.dataForm.poids.length - 1], - // // productImages: this.dataForm.productImages, - // // productImageList: this.dataForm.productImageList, - // // createTime: this.dataForm.createTime, - // // updateTime: this.dataForm.updateTime, - // // delFlag: this.dataForm.delFlag, - // // sort: this.dataForm.sort, - // // goodsType: this.dataForm.goodsType, - // // productDetails: this.dataForm.productDetails, - // // author: this.dataForm.author, - // // publisher: this.dataForm.publisher, - // // pubDate: this.dataForm.pubDate, - // // shoproudLabels: this.dataForm.tags, - // // // 'format': this.dataForm.format, // 开本 - // // isFreeMail: this.dataForm.isFreeMail, - // // isNew: this.dataForm.isNew, - // // // 'pageNum': this.dataForm.pageNum, - // // // 'quality': this.dataForm.quality, // 内文用纸 - // // productStock: this.dataForm.productStock, // 库存 - // // activityPrice: this.dataForm.hDprice, - // // bookids: this.bookidsd // 关联的图书[12,13,45] - // // // 'bookidsimages': this.dataForm.Books // 关联的图书对象 - // // }) - // }) + .then(({ data }) => { if (data && data.code === 0) {