Browse Source

修复采美文章自动保存功能链接跳转问题

xiebaomin 2 years ago
parent
commit
1de16f9f56

+ 53 - 1
src/main/resources/static/js/supplier-center/article/article-edit.js

@@ -162,7 +162,7 @@ var articleEdit = new Vue({
                     clearTimeout(this.validTime)
                     this.validTime = setTimeout(() => {
                         if (this.validTime) {
-                            this.handleSave()
+                            this.handleSave_new()
                         }
                         clearTimeout(this.validTime)
                         this.validTime = null
@@ -256,6 +256,16 @@ var articleEdit = new Vue({
             });
         },
 
+        handleSave_new() {
+            let _this = this;
+            this.$refs.ruleForm.validate(valide=>{
+                if(!valide) return;
+                // _this.save();
+                const params = {..._this.formData, labelIds: (_this.formData.labelIds && _this.formData.labelIds.length > 0) ? _this.formData.labelIds.join(',') : ''}
+                _this.sensitiveWordsValidate_new(params)
+            });
+        },
+
         // 采美文章预览
         handlePreview() {
             if (window.localStorage.getItem('articelData')) {
@@ -328,6 +338,48 @@ var articleEdit = new Vue({
             })
         },
 
+        sensitiveWordsValidate_new(params) {
+            const whiteList = [];
+            const self = this;
+            SupplierApi.ShopBaikeProductWordsValidate({ checkPoint: 1 }, function(res){
+                let flag = true
+                for (const key in params) {
+                    if (!whiteList.includes(key)) {
+                        const target = JSON.stringify(params[key])
+                        const bool = new RegExp(res.data, 'g').test(target)
+                        if (bool) {
+                            const value = self.matchWords(target, res.data)
+                            self.formValidate[key] = value
+                            flag = false
+                        } else {
+                            self.formValidate[key] = ''
+                        }
+                    }
+                }
+                if(flag) return self.onReallySave_new(params)
+                const tip = '当前发布内容存在敏感词,已为您标记在输入框下方,请修改后,再进行保存发布,强行保存发布将会导致审核不通过!'
+                self.$confirm(tip, '提示', { confirmButtonText: '保存', cancelButtonText: '取消' }).then(function(){
+                    self.onReallySave_new(params)
+                }).catch(function(){
+                    console.log('修改敏感词')
+                    self.socrllToErrorWord() // 滚动到提示处
+                })
+            })
+        },
+
+        onReallySave_new(params) {
+            let _this = this;
+            this.formData.shopId = this.shopId;
+            SupplierApi.ArticleSubmitSave(this.formData, function (res) {
+                if (res.code === 0) {
+                    CAIMEI.dialog('自动保存成功');
+                    _this.onFocused()
+                } else {
+                    CAIMEI.Alert(res.msg, '确定', false);
+                }
+            });
+        },
+
         // 保存接口
         onReallySave: function onReallySave() {
             var _this = this;

+ 70 - 2
src/main/resources/static/js/supplier-center/encyclopedia/edit.js

@@ -307,7 +307,7 @@ const edit = new Vue({
                     clearTimeout(this.validTime)
                     this.validTime = setTimeout(() => {
                         if (this.validTime) {
-                            this.handleConfirm()
+                            this.handleConfirm_new()
                         }
                         clearTimeout(this.validTime)
                         this.validTime = null
@@ -412,6 +412,40 @@ const edit = new Vue({
                 this.socrllToErrorWord()
             }
         },
+        // 提交表单
+        async handleConfirm_new() {
+            try {
+                if(this.showAgreement){
+                    CAIMEI.dialog('请先阅读编辑须知协议', false);
+                    return
+                }
+                this.formData.shopId = GLOBAL_SHOP_ID
+                this.formData.imageList = this.filterImageList(this.fileList)
+                this.formData.videoList = this.filterVideoList(this.fileList)
+                await this.$refs.ruleForm.validate()
+                const params = {
+                    shopId: this.formData.shopId,
+                    id: this.formData.id, // 词条id
+                    name: this.formData.name, // 词条名称
+                    alias: this.formData.alias, // 义项名
+                    discription: this.formData.discription, // 词条概述
+                    image: this.formData.image, // 头图地址
+                    typeId: this.formData.typeId, // 分类id
+                    seoKeyword: this.formData.seoKeyword, // seo关键字
+                    status: this.formData.status, // 状态0保存草稿箱  1已发布
+                    infoListStr: JSON.stringify(this.formData.infoList), //  信息栏集合
+                    referenceListStr:JSON.stringify(this.formData.referenceList), // 参考资料集合
+                    textInfoListStr: JSON.stringify(this.formData.textInfoList),
+                    imageListStr: JSON.stringify(this.formData.imageList), // 概述图册集合
+                    videoListStr:JSON.stringify(this.formData.videoList), // 视频集合
+                    labelIds: this.formData.labelIds ? this.formData.labelIds.join(',') : '' // 关联标签库列表
+                };
+                this.sensitiveWordsValidate_new(params)
+            } catch (e) {
+                console.log(e)
+                this.socrllToErrorWord()
+            }
+        },
         /// 确定提交
         onReallySave(params) {
             const self = this
@@ -663,7 +697,41 @@ const edit = new Vue({
                 })
             })
         },
-
+        // 敏感词校验
+        sensitiveWordsValidate_new(params) {
+            const whiteList = [];
+            const self = this;
+            SupplierApi.ShopBaikeProductWordsValidate({checkPoint: 2}, function (res) {
+                let flag = true
+                for (const key in params) {
+                    if (!whiteList.includes(key)) {
+                        const target = JSON.stringify(params[key])
+                        const bool = new RegExp(res.data, 'g').test(target)
+                        if (bool) {
+                            const value = self.matchWords(target, res.data)
+                            self.$set(self.formValidate, key, value)
+                            flag = false
+                        } else {
+                            self.$set(self.formValidate, key, '')
+                        }
+                    }
+                }
+                if (flag) return self.onReallySave_new(params)
+                console.log(self.formValidate)
+                const tip = '当前发布内容存在敏感词,已为您标记在输入框下方,请修改后,再进行保存发布,强行保存发布将会导致审核不通过!'
+                self.$confirm(tip, '提示', {confirmButtonText: '保存', cancelButtonText: '取消'}).then(function () {
+                    self.onReallySave_new(params)
+                }).catch(function () {
+                    self.socrllToErrorWord() // 滚动到提示处
+                })
+            })
+        },
+        onReallySave_new(params) {
+            shopBikeApi.SaveEntrySumbit(params, (res) => {
+                CAIMEI.dialog('自动保存成功', false);
+                this.onFocused()
+            })
+        },
         // 匹配敏感词
         matchWords(word, validate) {
             const list = []