Browse Source

修改采集器bug

Jing 3 months ago
parent
commit
d5d591425c
2 changed files with 140 additions and 89 deletions
  1. 53 42
      src/views/crawler/webCrawlerList.vue
  2. 87 47
      src/views/crawler/webCrawlerListEdit.vue

+ 53 - 42
src/views/crawler/webCrawlerList.vue

@@ -6,19 +6,19 @@
                 <el-col :span="6" class="left">
                     <div class="searchBox">
                         <div class="searchTitle">资讯题目</div>
-                        <el-input v-model="message_name" placeholder="请输入资讯名称"></el-input>
+                        <el-input v-model="message_name" placeholder="请输入资讯名称" clearable></el-input>
                     </div>
                 </el-col>
                 <el-col :span="6" class="left">
                     <div class="searchBox">
                         <div class="searchTitle">来源</div>
-                        <el-input v-model="message_from" placeholder="请输入来源"></el-input>
+                        <el-input v-model="message_from" placeholder="请输入来源" clearable></el-input>
                     </div>
                 </el-col>
                 <el-col :span="6" class="left">
                     <div class="searchBox">
                         <div class="searchTitle">导入状态</div>
-                        <el-select v-model="message_state" placeholder="请选择导入状态">
+                        <el-select v-model="message_state" clearable placeholder="请选择导入状态">
                             <el-option v-for="item in statusOptions" :key="item.value" :label="item.label"
                                 :value="item.value">
                             </el-option>
@@ -145,6 +145,9 @@ export default {
             pageSize: 10,
             total: 20,
 
+
+            navigationPoolBoo: false, //是否关联导航池
+
             tableData: [], //表格内数据
             // currentPage: 4,
             dialogTableVisible: false,
@@ -190,9 +193,9 @@ export default {
                 page: this.page,
                 pageSize: this.pageSize
             }).then(data => {
-                console.log(data);
+                console.log('tableData', data.data.rep);
                 this.loading = false
-               
+
                 this.total = data.data.count
                 this.tableData = data.data.rep
 
@@ -203,8 +206,6 @@ export default {
                         item.state = "未导入"
                     }
                 }
-
-
             })
         },
         //1.2 删除内容
@@ -264,6 +265,13 @@ export default {
                 console.log(data);
                 this.total = data.data.count
                 this.tableData = data.data.rep
+                for (let item of this.tableData) {
+                    if (item.state == 1) {
+                        item.state = "已导入"
+                    } else {
+                        item.state = "未导入"
+                    }
+                }
             })
         },
         //1.7 重置按钮
@@ -345,44 +353,47 @@ export default {
         //2.0 导入资讯列表
         importMessage() {
             for (let item of this.tableData) {
-                if (item.category.name == '') {
-                    this.$message({
-                        message: '还未关联导航池,请先关联导航池',
-                        type: 'error'
-                    })
+                if (!item.category) {
+                   this.navigationPoolBoo=true
                 } else {
-                    this.$confirm('', '是否确认将所有未导入的信息导入资讯列表?', {
-                        confirmButtonText: '确定',
-                        cancelButtonText: '取消',
-                    }).then(() => {
-                        addArt({
-                            rule_id: this.ruleId
-                        }).then(data => {
-                            console.log(data);
-                            if (data.code == 200) {
-                                this.$message({
-                                    message: '导入成功',
-                                    type: 'success'
-                                })
-                                this.getData()
-                            }
-                            if (data.code == 0) {
-                                this.$message({
-                                    message: data.message,
-                                    type: 'error'
-                                })
-                            }
-                        })
-                    }).catch(() => {
-                        this.$message({
-                            type: 'warning',
-                            message: '已取消'
-                        });
-                    });
+                    this.navigationPoolBoo=false
                 }
             }
-
-
+            if (this.navigationPoolBoo) {
+                this.$message({
+                    message: '还未关联导航池,请先关联导航池',
+                    type: 'error'
+                })
+            } else {
+                this.$confirm('', '是否确认将所有未导入的信息导入资讯列表?', {
+                    confirmButtonText: '确定',
+                    cancelButtonText: '取消',
+                }).then(() => {
+                    addArt({
+                        rule_id: this.ruleId
+                    }).then(data => {
+                        console.log(data);
+                        if (data.code == 200) {
+                            this.$message({
+                                message: '导入成功',
+                                type: 'success'
+                            })
+                            this.getData()
+                        }
+                        if (data.code == 0) {
+                            this.$message({
+                                message: data.message,
+                                type: 'error'
+                            })
+                        }
+                    })
+                }).catch(() => {
+                    this.$message({
+                        type: 'warning',
+                        message: '已取消'
+                    });
+                });
+            }
         }
     },
 }

+ 87 - 47
src/views/crawler/webCrawlerListEdit.vue

@@ -21,16 +21,16 @@
                             <el-option label="区域二" value="beijing"></el-option>
                         </el-select>
                     </el-form-item>
-                    <el-form-item label="推荐等级:" prop="grade">
-                        <el-select v-model="ruleForm.grade" placeholder="请选择推荐等级">
+                    <el-form-item label="推荐等级:" prop="">
+                        <el-select v-model="ruleForm.grade" clearable placeholder="请选择推荐等级">
                             <el-option v-for="item in options" :key="item.value" :label="item.label"
                                 :value="item.value">
                             </el-option>
                         </el-select>
                     </el-form-item>
                     <!-- 缩略图 -->
-                    <el-form-item label="缩略图:" prop="imgSrc" :label-width="formLabelWidth"
-                        :class="['custom-form-item']" class="custom-align-right">
+                    <el-form-item label="缩略图:" prop="" :label-width="formLabelWidth" :class="['custom-form-item']"
+                        class="custom-align-right">
                         <div class="uploaderBox">
                             <!--图片上传组件 start ------------------------------------------------------------>
                             <div class="avatar-upload-container" @mouseenter="hovering = true"
@@ -100,8 +100,8 @@
                         <el-input v-model="ruleForm.author" placeholder="请输入发布资讯的作者"></el-input>
                     </el-form-item>
                     <el-form-item label="浏览量:" prop="">
-                        <el-input-number v-model="ruleForm.count" @change="handleChange" :min="1" :max="10"
-                            label="描述文字"></el-input-number>
+                        <el-input-number v-model="ruleForm.count" @change="handleChange" :min="0" :max="100000"
+                            :step="1" label="描述文字"></el-input-number>
                     </el-form-item>
                     <el-form-item label="是否原创:" prop="original">
                         <el-radio v-model="ruleForm.original" label="true">是</el-radio>
@@ -168,18 +168,16 @@ export default {
 
             activeid: '',  //当前被选中的id
 
+            formLabelWidth: '', //广告示例图相关
+
             ruleId: '',
             source: '',
 
             //3.4 上传logo图片
             logoUrl: '',
             hovering: false, // 鼠标悬浮状态 悬浮时显示删除
-            
+
             options: [
-                {
-                    value: 0,
-                    label: '未分类'
-                },
                 {
                     value: 1,
                     label: '头条'
@@ -206,13 +204,13 @@ export default {
                 title: '',     // 资讯题目
                 url: '',       // 外链地址      
                 name: '',      // 导航池名称
-                grade: [],     // 推荐等级
+                grade: 0,     // 推荐等级
                 imgSrc: '',    // 缩略图  
                 keywords: '',  // 关键词 
                 desc: '',      // 描述
                 content: '',   // 内容
                 author: '',    // 作者
-                count: 1,     // 浏览量
+                count: 0,     // 浏览量
                 original: 'false',  // 原创
                 source: '',    // 来源
                 link: ''       // 来源链接
@@ -371,37 +369,72 @@ export default {
         },
         // 提交表单
         goSubmit() {
-            updateInfo({
-                art_id: this.activeid,
-                title: this.ruleForm.title,
-                level: this.ruleForm.grade,
-                imgurl: this.ruleForm.imgSrc,
-                keyword: this.ruleForm.keywords,
-                introduce: this.ruleForm.desc,
-                content: this.ruleForm.content,
-                author: this.ruleForm.author,
-                hits: this.ruleForm.count,
-                is_original: this.ruleForm.original == 'false' ? 0 : 1, //是否原创
-                fromurl: this.ruleForm.link, //来源链接
-                copyfrom: this.ruleForm.source, //来源
-                islink: this.checked == false ? 0 : 1,
-                linkurl: this.ruleForm.url,
-            }).then(data => {
-                console.log(data);
-                if (data.code == 200) {
-                    this.$message({
-                        message: "修改成功",
-                        type: "success"
-                    })
-                    this.$router.push(`/webCrawlerList?id=${this.ruleId}&source=${this.source}`)
-                }
-                if (data.code == 0) {
-                    this.$message({
-                        message: data.message,
-                        type: "error"
-                    })
-                }
-            })
+            if (this.ruleForm.grade == "") {
+                updateInfo({
+                    art_id: this.activeid,
+                    title: this.ruleForm.title,
+                    level: 0,
+                    imgurl: this.ruleForm.imgSrc,
+                    keyword: this.ruleForm.keywords,
+                    introduce: this.ruleForm.desc,
+                    content: this.ruleForm.content,
+                    author: this.ruleForm.author,
+                    hits: this.ruleForm.count,
+                    is_original: this.ruleForm.original == 'false' ? 0 : 1, //是否原创
+                    fromurl: this.ruleForm.link, //来源链接
+                    copyfrom: this.ruleForm.source, //来源
+                    islink: this.checked == false ? 0 : 1,
+                    linkurl: this.ruleForm.url,
+                }).then(data => {
+                    console.log(data);
+                    if (data.code == 200) {
+                        this.$message({
+                            message: "修改成功",
+                            type: "success"
+                        })
+                        this.$router.push(`/webCrawlerList?id=${this.ruleId}&source=${this.source}`)
+                    }
+                    if (data.code == 0) {
+                        this.$message({
+                            message: data.message,
+                            type: "error"
+                        })
+                    }
+                })
+            } else {
+                updateInfo({
+                    art_id: this.activeid,
+                    title: this.ruleForm.title,
+                    level: this.ruleForm.grade,
+                    imgurl: this.ruleForm.imgSrc,
+                    keyword: this.ruleForm.keywords,
+                    introduce: this.ruleForm.desc,
+                    content: this.ruleForm.content,
+                    author: this.ruleForm.author,
+                    hits: this.ruleForm.count,
+                    is_original: this.ruleForm.original == 'false' ? 0 : 1, //是否原创
+                    fromurl: this.ruleForm.link, //来源链接
+                    copyfrom: this.ruleForm.source, //来源
+                    islink: this.checked == false ? 0 : 1,
+                    linkurl: this.ruleForm.url,
+                }).then(data => {
+                    console.log(data);
+                    if (data.code == 200) {
+                        this.$message({
+                            message: "修改成功",
+                            type: "success"
+                        })
+                        this.$router.push(`/webCrawlerList?id=${this.ruleId}&source=${this.source}`)
+                    }
+                    if (data.code == 0) {
+                        this.$message({
+                            message: data.message,
+                            type: "error"
+                        })
+                    }
+                })
+            }
+
         },
         //取消添加或编辑
         goCancel() {
@@ -537,15 +570,22 @@ export default {
             this.ruleForm.title = data.data.title
             this.ruleForm.url = data.data.linkurl
             this.ruleForm.name = data.data.category //导航池名称
-            this.ruleForm.grade = data.data.level
+
+            //推荐等级
+            if (data.data.level == 0) {
+                this.ruleForm.grade = ""
+            } else {
+                this.ruleForm.grade = data.data.level
+            }
+
             this.logoUrl = data.data.imgurl
             this.ruleForm.keywords = data.data.keyword
             this.ruleForm.desc = data.data.introduce
             this.ruleForm.content = data.data.content  //内容
             this.ruleForm.author = data.data.author
             this.ruleForm.count = data.data.hits
-            this.ruleForm.source = data.data.source
-            this.ruleForm.link = data.data.copyfrom
+            this.ruleForm.source = data.data.copyfrom
+            this.ruleForm.link = data.data.fromurl
         })
 
         //复制内容到富文本 start ------------------------------------------------------------>