xiebaomin 2 gadi atpakaļ
vecāks
revīzija
4af1d8cec3

+ 17 - 79
src/main/resources/static/js/supplier-center/article/article-edit.js

@@ -156,29 +156,24 @@ var articleEdit = new Vue({
         },
         // 自动保存校验
         validFormRule() {
-            this.$refs.ruleForm.validate(valide=>{
-                if(valide){
-                    this.validTime = null
-                    clearTimeout(this.validTime)
-                    this.validTime = setTimeout(() => {
-                        if (this.validTime) {
-                            this.handleSave_new()
-                        }
-                        clearTimeout(this.validTime)
-                        this.validTime = null
-                    }, 2000)
+            let allow = true
+            const ruleData = Object.keys(this.rules)
+            for(let i of ruleData){
+                if (!this.formData[i]) {
+                    allow = false
+                    break
                 }
-            })
-        },
-        handlerTypeId() {
-            this.onFocused()
-            this.onBlured()
-        },
-        changeVisible($event) {
-            if ($event) {
-                this.onFocused()
-            } else {
-                this.onBlured()
+            }
+            if (allow) {
+                this.validTime = null
+                clearTimeout(this.validTime)
+                this.validTime = setTimeout(() => {
+                    if (this.validTime) {
+                        this.handleSave()
+                    }
+                    clearTimeout(this.validTime)
+                    this.validTime = null
+                }, 5000)
             }
         },
         // 设置表单初始数据
@@ -224,8 +219,6 @@ var articleEdit = new Vue({
             if (this.chooseLabels.indexOf(this.addLabelName) > -1) return this.addLabelName = '';
             this.chooseLabels.push(this.addLabelName);
             this.addLabelName = '';
-            this.onFocused()
-            this.onBlured()
         },
         // 判断标签是否被选
         checkLabel: function checkLabel(index) {
@@ -235,15 +228,12 @@ var articleEdit = new Vue({
         handleUploadSuccess: function handleUploadSuccess(response, file, fileList) {
             this.formData.guidanceImage = response.data;
             this.articleImageList = fileList;
-            this.onFocused()
-            this.onBlured()
             console.log(fileList)
         },
         // 图片移除
         handleImageRemove: function handleImageRemove(response, file, fileList) {
             this.formData.guidanceImage = "";
             this.articleImageList = [];
-            console.log('移除成功')
         },
         // 保存 提交表单
         handleSave: function handleSave() {
@@ -256,16 +246,6 @@ 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')) {
@@ -338,48 +318,6 @@ 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;

+ 27 - 128
src/main/resources/static/js/supplier-center/encyclopedia/edit.js

@@ -275,57 +275,38 @@ const edit = new Vue({
         $('.navLayout').find('.navList').eq(3).addClass("on").find('.con').show().find('a').eq(0).addClass("on");
         this.initAutoInput('.seo-auto-input', 'seoKeyword')
     },
-    watch: {
-        referenceDialog(val) {
-            if (val) {
-                setTimeout(() => {
-                    this.onFocused()
-                }, 500)
-            }
-        },
-    },
     methods: {
-        onFocused(val = 300) {
-            setTimeout(() => {
-                this.validTime = null
-                console.log(111)
-                clearTimeout(this.validTime)
-            }, val)
+        onFocused() {
+            this.validTime = null
+            console.log(111)
+            clearTimeout(this.validTime)
         },
-        onBlured(val = 200) {
-            setTimeout(() => {
-                this.isFocus = true
-                this.validFormRule()
-                console.log(222)
-            }, val)
+        onBlured() {
+            this.isFocus = true
+            this.validFormRule()
+            console.log(222)
         },
         // 自动保存校验
         validFormRule() {
-            this.$refs.ruleForm.validate(valid => {
-                if (valid) {
-                    this.validTime = null
-                    clearTimeout(this.validTime)
-                    this.validTime = setTimeout(() => {
-                        if (this.validTime) {
-                            this.handleConfirm_new()
-                        }
-                        clearTimeout(this.validTime)
-                        this.validTime = null
-                    }, 2000)
+            let allow = true
+            const ruleData = Object.keys(this.rules)
+            for(let i of ruleData){
+                if (!this.formData[i]) {
+                    allow = false
+                    console.log('数据未填写完成')
+                    break
                 }
-            })
-        },
-        handlerDiscrip() {
-            this.onFocused()
-        },
-        handlerTypeId() {
-            this.onBlured()
-        },
-        changeVisible($event) {
-            if ($event) {
-                this.onFocused()
-            } else {
-                this.onBlured()
+            }
+            if (allow) {
+                this.validTime = null
+                clearTimeout(this.validTime)
+                this.validTime = setTimeout(() => {
+                    if (this.validTime) {
+                        this.handleConfirm()
+                    }
+                    clearTimeout(this.validTime)
+                    this.validTime = null
+                }, 5000)
             }
         },
         // 获取表单数据
@@ -412,40 +393,6 @@ 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
@@ -539,7 +486,6 @@ const edit = new Vue({
                 this.referenceData = initReferenceData()
                 this.$refs.referenceForm.clearValidate()
                 this.referenceDialog = false
-                this.onBlured()
             } catch (e) {
                 console.log(e)
             }
@@ -572,7 +518,6 @@ const edit = new Vue({
             if(this.referenceData.imageUrl){
                 this.referenceImageList = [{ url: this.referenceData.imageUrl, type: 'image' }]
             }
-            console.log(1111)
         },
         // 参考资料删除
         handleReferenceDelete(item) {
@@ -595,13 +540,10 @@ const edit = new Vue({
         // 新增信息栏
         handleInfoAdd() {
             this.formData.infoList.push(this.genereateInfo())
-            this.onFocused()
         },
         // 删除信息栏
         handleInfoRemove(index) {
             this.formData.infoList.splice(index, 1)
-            this.onFocused(0)
-            this.onBlured(0)
         },
         // 正文目录数据
         genereateTextInfo(type, index) {
@@ -622,37 +564,28 @@ const edit = new Vue({
         // 添加正文目录
         handleAddTextInfo(index, type) {
             this.formData.textInfoList.splice(index + 1, 0, this.genereateTextInfo(type, index + 1))
-            this.onFocused()
         },
         // 删除正文目录
         handleRemoveTextInfo(index, type) {
             this.formData.textInfoList.splice(index, 1)
-            this.onFocused(0)
-            this.onBlured(0)
         },
         // 文件上传成功
         handleUploadSuccess(fileList) {
             this.fileList = [...this.fileList, ...fileList]
-            this.onBlured()
         },
         // 文件移除
         handleFileRemove(file) {
             this.fileList = this.fileList.filter(item => item.uuid !== file.uuid);
-            this.onFocused()
-            this.onBlured()
         },
         // 封面上传成功
         handleCoverUploadSuccess(fileList) {
             this.coverList = fileList
             this.formData.image = fileList[0].url
-            this.onBlured()
         },
         // 封面删除
         handleCoverRemove(file) {
             this.formData.image = ''
             this.coverList = this.coverList.filter(item => item.uuid !== file.uuid);
-            this.onFocused()
-            this.onBlured()
         },
         // 资料图片上传
         handleReferenceImageUploadSuccess(fileList){
@@ -697,41 +630,7 @@ 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 = []

+ 3 - 5
src/main/resources/templates/supplier-center/article/article-edit.html

@@ -81,7 +81,6 @@
                                         reserve-keyword
                                         :remote-method="fetchQueryKeywordList"
                                         :loading="remoteLoading"
-                                        @visible-change="changeVisible"
                                 >
                                     <el-option v-for="item in labelList" :key="item.id" :label="item.keyword" :value="item.id"></el-option>
                                 </el-select>
@@ -103,13 +102,13 @@
                             </el-form-item>
                             <!-- 文章内容 -->
                             <el-form-item label="文章内容" prop="articleContent" class="mint-filter">
-                                <el-input v-model="formData.articleContent" v-show="false"></el-input>
-                                <editor v-model="formData.articleContent" placeholder="请输入文章内容" @click.native="onFocused"></editor>
+                                <el-input v-model="formData.articleContent" v-show="false" @focus="onFocused" @blur="onBlured"></el-input>
+                                <editor v-model="formData.articleContent" placeholder="请输入文章内容"></editor>
                                 <div class="mint-message" v-if="formValidate.articleContent">{{formValidate.articleContent}}</div>
                             </el-form-item>
                             <!-- 文章分类 -->
                             <el-form-item label="文章分类" prop="typeId">
-                                <el-select v-model="formData.typeId" class="max-width" @change="handlerTypeId" @click.native="onFocused">
+                                <el-select v-model="formData.typeId" class="max-width">
                                     <template v-for="(typeInfo, index) in articleTypeList">
                                         <el-option :label="typeInfo.typeName" :value="typeInfo.typeId" :key="typeInfo.typeId"></el-option>
                                     </template>
@@ -126,7 +125,6 @@
                                         :on-remove="handleImageRemove"
                                         :file-list="articleImageList"
                                         :limit="1"
-                                        @click.native="onFocused"
                                 >
                                     <i class="el-icon-plus"></i>
                                     <div slot="tip" class="el-upload__tip">建议图片尺寸210px*210px,并上传白底图片</div>

+ 2 - 0
src/main/resources/templates/supplier-center/encyclopedia/edit.html

@@ -44,6 +44,7 @@
                                     @reference-edit="handleReferenceEdit"
                                     @toolbar="handleToolbarClick"
                                     v-model="formData.alias"
+                                    @focus="onFocused" @blur="onBlured"
                             ></content-edit>
                             <el-input v-model="formData.alias" placeholder="请输入义项名,简要说明该事物区别于同名事物的显著特征"
                                       v-show="false"></el-input>
@@ -55,6 +56,7 @@
                                     @reference-edit="handleReferenceEdit"
                                     @toolbar="handleToolbarClick"
                                     v-model="formData.discription"
+                                    @focus="onFocused" @blur="onBlured"
                             ></content-edit>
                             <el-input v-model="formData.discription" placeholder="请输入词条概述" v-show="false"></el-input>
                             <div class="el-form-item__error" v-if="formValidate.discription">敏感词:{{formValidate.discription}}</div>