|
@@ -23,7 +23,7 @@
|
|
|
<button class="btn" @click="addCrawlerRule">设置采集规则</button>
|
|
|
<el-row>
|
|
|
<template>
|
|
|
- <el-table class="my-table" :data="tableData" style="width: 100%">
|
|
|
+ <el-table class="my-table" v-loading="loading" :data="tableData" style="width: 100%">
|
|
|
<el-table-column fixed prop="id" label="编号" width="100">
|
|
|
</el-table-column>
|
|
|
<el-table-column prop="name" label="任务规则名" width="">
|
|
@@ -99,17 +99,17 @@
|
|
|
</el-form-item>
|
|
|
<div class="pageTwo">
|
|
|
<el-form-item label="第2页网址:" required class="keywords">
|
|
|
- <el-col :span="6">
|
|
|
+ <el-col :span="8">
|
|
|
<el-form-item prop="second_start">
|
|
|
<el-input v-model="ruleForm.second_start" placeholder="请输入网址开头"></el-input>
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
- <el-col :span="6">
|
|
|
+ <el-col :span="8">
|
|
|
<el-form-item prop="second_num">
|
|
|
<el-input v-model="ruleForm.second_num" placeholder="请输入代码页数"></el-input>
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
- <el-col :span="6" class="el_col_6_end">
|
|
|
+ <el-col :span="8" class="el_col_6_end">
|
|
|
<el-form-item prop="second_end">
|
|
|
<el-input v-model="ruleForm.second_end" placeholder="请输入网址结束字符串"
|
|
|
class="lastInput"></el-input>
|
|
@@ -129,8 +129,8 @@
|
|
|
<el-tooltip placement="top-start">
|
|
|
<div slot="content">
|
|
|
起始代码为文章列表第一篇文章上面几行代码中一段代码<br />
|
|
|
- 如<'div class="ej list box clear">,输入为 .ej list box clear 埴入输入框内<br />
|
|
|
- 如<'ul class="ej list box clear">,输入为 .ej list box clearul 埴入输入框内
|
|
|
+ 如<div class="ej list box clear"><ul><li>,输入为 .ej list box clear ul li
|
|
|
+ 埴入输入框内
|
|
|
</div>
|
|
|
<i class="el-icon-warning"></i>
|
|
|
</el-tooltip>
|
|
@@ -159,7 +159,7 @@
|
|
|
<el-tooltip placement="top-start">
|
|
|
<div slot="content">
|
|
|
详情页两边有除资讯详情内容时,此项需要填写<br />
|
|
|
- 标签内容为<'div class="news_details">,详情页标签填入.news_details 填入框内
|
|
|
+ 标签内容为<div class="news_details">,详情页标签填入.news_details 填入框内
|
|
|
</div>
|
|
|
<i class="el-icon-warning"></i>
|
|
|
</el-tooltip>
|
|
@@ -169,8 +169,8 @@
|
|
|
<el-input v-model="ruleForm.title" placeholder="请输入标题字符串"></el-input>
|
|
|
<el-tooltip placement="top-start">
|
|
|
<div slot="content">
|
|
|
- 如标题代码:<'h1 class='news_art'>红枣滞销喂羊 电商帮忙促销</'h1>,标题字符串为 .news_art 填入输入框内<br />
|
|
|
- 如标题代码:<'h1 id='news at'>红枣滞销喂羊 电商帮忙促销</'h1>,标题字符串为 #news art 填入输入框内
|
|
|
+ 如标题代码:<h1 class='news_art'>红枣滞销喂羊 电商帮忙促销</h1>,标题字符串为 .news_art 填入输入框内<br />
|
|
|
+ 如标题代码:<h1 id='news at'>红枣滞销喂羊 电商帮忙促销</h1>,标题字符串为 #news art 填入输入框内
|
|
|
</div>
|
|
|
<i class="el-icon-warning"></i>
|
|
|
</el-tooltip>
|
|
@@ -179,10 +179,10 @@
|
|
|
<el-input v-model="ruleForm.content" placeholder="请输入内容字符串"></el-input>
|
|
|
<el-tooltip placement="top-start">
|
|
|
<div slot="content">
|
|
|
- 如内容代码:<'h1 class='news box'>
|
|
|
- <' /h1>,内容字符串为.news box 填入输入框内<br />
|
|
|
- 如内容代码:<'h1 id='news_box'>
|
|
|
- <' /h1>,内容字符串为 #news_box 填入输入框内
|
|
|
+ 如内容代码:<h1 class='news box'>
|
|
|
+ </h1>,内容字符串为.news box 填入输入框内<br />
|
|
|
+ 如内容代码:<h1 id='news_box'>
|
|
|
+ </h1>,内容字符串为 #news_box 填入输入框内
|
|
|
</div>
|
|
|
<i class="el-icon-warning"></i>
|
|
|
</el-tooltip>
|
|
@@ -298,8 +298,9 @@
|
|
|
</div>
|
|
|
|
|
|
<div class="dialogBtn">
|
|
|
- <button class="cancel" @click="saveForm">保存</button>
|
|
|
- <button class="submit" @click="submitForm">确定</button>
|
|
|
+ <el-button class="cancel" @click="saveForm">保存</el-button>
|
|
|
+ <el-button type="primary" class="submit" :loading="submitDisabled"
|
|
|
+ @click="submitForm('ruleForm')">确定</el-button>
|
|
|
</div>
|
|
|
</el-form>
|
|
|
</el-dialog>
|
|
@@ -427,6 +428,8 @@ export default {
|
|
|
dialogName: '设置采集规则', //弹窗名称
|
|
|
dialogBoo: 'add',//判断当前是添加还是编辑
|
|
|
searchRuleName: '', //任务规则名
|
|
|
+ loading: true, //表格加载中
|
|
|
+ submitDisabled: false, //添加按钮防抖
|
|
|
|
|
|
// 建立网站页面传递的参数
|
|
|
webId: '',
|
|
@@ -464,7 +467,7 @@ export default {
|
|
|
author: '', // 作者字符串
|
|
|
authorName: '', // 作者替换名称
|
|
|
parameter: '', //接口类2 接口参数
|
|
|
- diy_rule: '',//自定义类
|
|
|
+ diy_rule: '', //自定义类
|
|
|
},
|
|
|
|
|
|
rules: { //规则
|
|
@@ -502,6 +505,9 @@ export default {
|
|
|
pageSize: this.pageSize,
|
|
|
page: this.page,
|
|
|
}).then(data => {
|
|
|
+ if (data.code == 200) {
|
|
|
+ this.loading = false
|
|
|
+ }
|
|
|
console.log(data.data.rep);
|
|
|
this.tableData = data.data.rep
|
|
|
this.total = data.data.count
|
|
@@ -599,24 +605,132 @@ export default {
|
|
|
}
|
|
|
if (this.webType) {
|
|
|
this.dialogTableVisible = true
|
|
|
- this.ruleForm.ruleName = ''
|
|
|
- this.ruleForm.first_url = ''
|
|
|
- this.ruleForm.collect = ''
|
|
|
- this.ruleForm.second_start = ''
|
|
|
- this.ruleForm.second_num = ''
|
|
|
- this.ruleForm.second_end = ''
|
|
|
- this.ruleForm.startCode = ''
|
|
|
- this.ruleForm.startLabel = ''
|
|
|
- this.ruleForm.endPage = ''
|
|
|
- this.ruleForm.title = ''
|
|
|
- this.ruleForm.content = ''
|
|
|
- this.ruleForm.source = ''
|
|
|
- this.ruleForm.author = ''
|
|
|
- this.ruleForm.authorName = ''
|
|
|
- this.ruleForm.parameter = ''
|
|
|
- this.ruleForm.diy_rule = ''
|
|
|
- this.ruleForm.webSite_start = ""
|
|
|
- this.ruleForm.detailPage = ''
|
|
|
+ //任务规则名 ruleName
|
|
|
+ const ruleName = sessionStorage.getItem("ruleName");
|
|
|
+ if (ruleName !== null) {
|
|
|
+ this.ruleForm.ruleName = ruleName
|
|
|
+ } else {
|
|
|
+ this.ruleForm.ruleName = ''
|
|
|
+ }
|
|
|
+ //第1页网址 接口类的开始采集地址 first_url
|
|
|
+ const first_url = sessionStorage.getItem("first_url");
|
|
|
+ if (first_url !== null) {
|
|
|
+ this.ruleForm.ruleName = first_url
|
|
|
+ } else {
|
|
|
+ this.ruleForm.first_url = ''
|
|
|
+ }
|
|
|
+ //接口类 采集地址 collect
|
|
|
+ const collect = sessionStorage.getItem("collect");
|
|
|
+ if (collect !== null) {
|
|
|
+ this.ruleForm.ruleName = collect
|
|
|
+ } else {
|
|
|
+ this.ruleForm.collect = ''
|
|
|
+ }
|
|
|
+ //第2页网址开头 second_start
|
|
|
+ const second_start = sessionStorage.getItem("second_start");
|
|
|
+ if (second_start !== null) {
|
|
|
+ this.ruleForm.ruleName = second_start
|
|
|
+ } else {
|
|
|
+ this.ruleForm.second_start = ''
|
|
|
+ }
|
|
|
+ //第2页代码页数 second_num
|
|
|
+ const second_num = sessionStorage.getItem("second_num");
|
|
|
+ if (second_num !== null) {
|
|
|
+ this.ruleForm.ruleName = second_num
|
|
|
+ } else {
|
|
|
+ this.ruleForm.second_num = ''
|
|
|
+ }
|
|
|
+ //第2页网址结束字符串 second_end
|
|
|
+ const second_end = sessionStorage.getItem("second_end");
|
|
|
+ if (second_end !== null) {
|
|
|
+ this.ruleForm.ruleName = second_end
|
|
|
+ } else {
|
|
|
+ this.ruleForm.second_end = ''
|
|
|
+ }
|
|
|
+ //startCode: '', 起始代码
|
|
|
+ const startCode = sessionStorage.getItem("startCode");
|
|
|
+ if (startCode !== null) {
|
|
|
+ this.ruleForm.ruleName = startCode
|
|
|
+ } else {
|
|
|
+ this.ruleForm.startCode = ''
|
|
|
+ }
|
|
|
+ // startLabel: '',列表开始标签
|
|
|
+ const startLabel = sessionStorage.getItem("startLabel");
|
|
|
+ if (startLabel !== null) {
|
|
|
+ this.ruleForm.ruleName = startLabel
|
|
|
+ } else {
|
|
|
+ this.ruleForm.startLabel = ''
|
|
|
+ }
|
|
|
+ //endPage: '', //结束页数
|
|
|
+ const endPage = sessionStorage.getItem("endPage");
|
|
|
+ if (endPage !== null) {
|
|
|
+ this.ruleForm.ruleName = endPage
|
|
|
+ } else {
|
|
|
+ this.ruleForm.endPage = ''
|
|
|
+ }
|
|
|
+ //title: '', //标题字符串
|
|
|
+ const title = sessionStorage.getItem("title");
|
|
|
+ if (title !== null) {
|
|
|
+ this.ruleForm.ruleName = title
|
|
|
+ } else {
|
|
|
+ this.ruleForm.title = ''
|
|
|
+ }
|
|
|
+ // content: '', //内容字符串
|
|
|
+ const content = sessionStorage.getItem("content");
|
|
|
+ if (content !== null) {
|
|
|
+ this.ruleForm.ruleName = content
|
|
|
+ } else {
|
|
|
+ this.ruleForm.content = ''
|
|
|
+ }
|
|
|
+ // detailPage: '', //详情页标签
|
|
|
+ const detailPage = sessionStorage.getItem("detailPage");
|
|
|
+ if (detailPage !== null) {
|
|
|
+ this.ruleForm.ruleName = detailPage
|
|
|
+ } else {
|
|
|
+ this.ruleForm.detailPage = ''
|
|
|
+ }
|
|
|
+ // webSite_start: '', //详情页网址前缀
|
|
|
+ const webSite_start = sessionStorage.getItem("webSite_start");
|
|
|
+ if (webSite_start !== null) {
|
|
|
+ this.ruleForm.ruleName = webSite_start
|
|
|
+ } else {
|
|
|
+ this.ruleForm.webSite_start = ''
|
|
|
+ }
|
|
|
+ //source: '', // 来源字符串
|
|
|
+ const source = sessionStorage.getItem("source");
|
|
|
+ if (source !== null) {
|
|
|
+ this.ruleForm.ruleName = source
|
|
|
+ } else {
|
|
|
+ this.ruleForm.source = ''
|
|
|
+ }
|
|
|
+ //author: '', // 作者字符串
|
|
|
+ const author = sessionStorage.getItem("author");
|
|
|
+ if (author !== null) {
|
|
|
+ this.ruleForm.ruleName = author
|
|
|
+ } else {
|
|
|
+ this.ruleForm.author = ''
|
|
|
+ }
|
|
|
+ //authorName: '', // 作者替换名称
|
|
|
+ const authorName = sessionStorage.getItem("authorName");
|
|
|
+ if (authorName !== null) {
|
|
|
+ this.ruleForm.ruleName = authorName
|
|
|
+ } else {
|
|
|
+ this.ruleForm.authorName = ''
|
|
|
+ }
|
|
|
+ //parameter: '', //接口类2 接口参数
|
|
|
+ const parameter = sessionStorage.getItem("parameter");
|
|
|
+ if (parameter !== null) {
|
|
|
+ this.ruleForm.ruleName = parameter
|
|
|
+ } else {
|
|
|
+ this.ruleForm.parameter = ''
|
|
|
+ }
|
|
|
+ //diy_rule: '',自定义类
|
|
|
+ const diy_rule = sessionStorage.getItem("diy_rule");
|
|
|
+ if (diy_rule !== null) {
|
|
|
+ this.ruleForm.ruleName = diy_rule
|
|
|
+ } else {
|
|
|
+ this.ruleForm.diy_rule = ''
|
|
|
+ }
|
|
|
}
|
|
|
},
|
|
|
//1.9 编辑采集规则
|
|
@@ -684,8 +798,6 @@ export default {
|
|
|
this.ruleForm.ruleName = val.name
|
|
|
this.ruleForm.diy_rule = val.diy_rule
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
},
|
|
|
//采集
|
|
|
goCollect(id, status) {
|
|
@@ -730,7 +842,16 @@ export default {
|
|
|
// },
|
|
|
// 弹出层相关方法
|
|
|
// 提交表单
|
|
|
- submitForm() {
|
|
|
+ submitForm(formName) {
|
|
|
+ this.$refs[formName].validate((valid) => {
|
|
|
+ if (valid) {
|
|
|
+ console.log('submit!');
|
|
|
+ this.submitDisabled = true
|
|
|
+ } else {
|
|
|
+ console.log('error submit!!');
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ });
|
|
|
//添加
|
|
|
if (this.dialogBoo == 'add') {
|
|
|
if (this.webType == 1) {
|
|
@@ -757,15 +878,11 @@ export default {
|
|
|
console.log(data);
|
|
|
if (data.code == 200) {
|
|
|
this.dialogTableVisible = false
|
|
|
+ this.submitDisabled = false
|
|
|
this.$message({
|
|
|
message: '添加成功',
|
|
|
type: 'success'
|
|
|
})
|
|
|
- } else if (data.code == 0) {
|
|
|
- this.$message({
|
|
|
- message: data.message,
|
|
|
- type: 'error'
|
|
|
- })
|
|
|
}
|
|
|
})
|
|
|
} else {
|
|
@@ -791,15 +908,11 @@ export default {
|
|
|
console.log(data);
|
|
|
if (data.code == 200) {
|
|
|
this.dialogTableVisible = false
|
|
|
+ this.submitDisabled = false
|
|
|
this.$message({
|
|
|
message: '添加成功',
|
|
|
type: 'success'
|
|
|
})
|
|
|
- } else if (data.code == 0) {
|
|
|
- this.$message({
|
|
|
- message: data.message,
|
|
|
- type: 'error'
|
|
|
- })
|
|
|
}
|
|
|
})
|
|
|
}
|
|
@@ -821,17 +934,13 @@ export default {
|
|
|
this.getData()
|
|
|
console.log(data);
|
|
|
if (data.code == 200) {
|
|
|
+ this.submitDisabled = false
|
|
|
this.dialogTableVisible = false
|
|
|
this.$message({
|
|
|
message: '添加成功',
|
|
|
type: 'success'
|
|
|
})
|
|
|
this.ruleForm.authorName = ''
|
|
|
- } else if (data.code == 0) {
|
|
|
- this.$message({
|
|
|
- message: data.message,
|
|
|
- type: 'error'
|
|
|
- })
|
|
|
}
|
|
|
})
|
|
|
|
|
@@ -853,16 +962,12 @@ export default {
|
|
|
console.log(data);
|
|
|
if (data.code == 200) {
|
|
|
this.dialogTableVisible = false
|
|
|
+ this.submitDisabled = false
|
|
|
this.$message({
|
|
|
message: '添加成功',
|
|
|
type: 'success'
|
|
|
})
|
|
|
this.ruleForm.author = ''
|
|
|
- } else if (data.code == 0) {
|
|
|
- this.$message({
|
|
|
- message: data.message,
|
|
|
- type: 'error'
|
|
|
- })
|
|
|
}
|
|
|
})
|
|
|
|
|
@@ -877,17 +982,12 @@ export default {
|
|
|
this.getData()
|
|
|
if (data.code == 200) {
|
|
|
this.dialogTableVisible = false
|
|
|
+ this.submitDisabled = false
|
|
|
this.$message({
|
|
|
message: '添加成功',
|
|
|
type: 'success'
|
|
|
})
|
|
|
- } else if (data.code == 0) {
|
|
|
- this.$message({
|
|
|
- message: data.message,
|
|
|
- type: 'error'
|
|
|
- })
|
|
|
}
|
|
|
-
|
|
|
})
|
|
|
}
|
|
|
}
|
|
@@ -924,15 +1024,11 @@ export default {
|
|
|
console.log(data);
|
|
|
if (data.code == 200) {
|
|
|
this.dialogTableVisible = false
|
|
|
+ this.submitDisabled = false
|
|
|
this.$message({
|
|
|
message: '修改成功',
|
|
|
type: 'success'
|
|
|
})
|
|
|
- } else if (data.code == 0) {
|
|
|
- this.$message({
|
|
|
- message: data.message,
|
|
|
- type: 'error'
|
|
|
- })
|
|
|
}
|
|
|
})
|
|
|
} else if (this.webType == 2 && this.radio == 'true') {
|
|
@@ -953,16 +1049,12 @@ export default {
|
|
|
console.log(data);
|
|
|
if (data.code == 200) {
|
|
|
this.dialogTableVisible = false
|
|
|
+ this.submitDisabled = false
|
|
|
this.$message({
|
|
|
message: '修改成功',
|
|
|
type: 'success'
|
|
|
})
|
|
|
this.ruleForm.authorName = ""
|
|
|
- } else if (data.code == 0) {
|
|
|
- this.$message({
|
|
|
- message: data.message,
|
|
|
- type: 'error'
|
|
|
- })
|
|
|
}
|
|
|
})
|
|
|
} else if (this.webType == 2 && this.radio == 'false') {
|
|
@@ -984,16 +1076,12 @@ export default {
|
|
|
console.log(data);
|
|
|
if (data.code == 200) {
|
|
|
this.dialogTableVisible = false
|
|
|
+ this.submitDisabled = false
|
|
|
this.$message({
|
|
|
message: '修改成功',
|
|
|
type: 'success'
|
|
|
})
|
|
|
this.ruleForm.author = ""
|
|
|
- } else if (data.code == 0) {
|
|
|
- this.$message({
|
|
|
- message: data.message,
|
|
|
- type: 'error'
|
|
|
- })
|
|
|
}
|
|
|
})
|
|
|
} else if (this.webType == 3) {
|
|
@@ -1007,15 +1095,11 @@ export default {
|
|
|
this.getData()
|
|
|
if (data.code == 200) {
|
|
|
this.dialogTableVisible = false
|
|
|
+ this.submitDisabled = false
|
|
|
this.$message({
|
|
|
message: '修改成功',
|
|
|
type: 'success'
|
|
|
})
|
|
|
- } else if (data.code == 0) {
|
|
|
- this.$message({
|
|
|
- message: data.message,
|
|
|
- type: 'error'
|
|
|
- })
|
|
|
}
|
|
|
})
|
|
|
}
|
|
@@ -1024,6 +1108,24 @@ export default {
|
|
|
//保存
|
|
|
saveForm() {
|
|
|
this.dialogTableVisible = false
|
|
|
+ sessionStorage.setItem('ruleName', this.ruleForm.ruleName); //任务规则名
|
|
|
+ sessionStorage.setItem('first_url', this.ruleForm.first_url); //第一页网址
|
|
|
+ sessionStorage.setItem('collect', this.ruleForm.collect); //接口类 采集地址
|
|
|
+ sessionStorage.setItem('second_start', this.ruleForm.second_start); //第2页网址开头
|
|
|
+ sessionStorage.setItem('second_num', this.ruleForm.second_num); //第2页代码页数
|
|
|
+ sessionStorage.setItem('second_end', this.ruleForm.second_end);//第2页网址结束字符串
|
|
|
+ sessionStorage.setItem('startCode', this.ruleForm.startCode); //起始代码
|
|
|
+ sessionStorage.setItem('startLabel', this.ruleForm.startLabel); //列表开始标签
|
|
|
+ sessionStorage.setItem('endPage', this.ruleForm.endPage); //结束页数
|
|
|
+ sessionStorage.setItem('title', this.ruleForm.title); //标题字符串
|
|
|
+ sessionStorage.setItem('content', this.ruleForm.content); //内容字符串
|
|
|
+ sessionStorage.setItem('detailPage', this.ruleForm.detailPage); //详情页标签
|
|
|
+ sessionStorage.setItem('webSite_start', this.ruleForm.webSite_start); //详情页网址前缀
|
|
|
+ sessionStorage.setItem('source', this.ruleForm.source); // 来源字符串
|
|
|
+ sessionStorage.setItem('author', this.ruleForm.author); // 作者字符串
|
|
|
+ sessionStorage.setItem('authorName', this.ruleForm.authorName); // 作者替换名称
|
|
|
+ sessionStorage.setItem('parameter', this.ruleForm.parameter); //接口类2 接口参数
|
|
|
+ sessionStorage.setItem('diy_rule', this.ruleForm.diy_rule); //自定义类
|
|
|
},
|
|
|
// 查看
|
|
|
goLook(id, val) {
|
|
@@ -1219,6 +1321,10 @@ export default {
|
|
|
background-color: #f5f7fb;
|
|
|
|
|
|
.pageTwo {
|
|
|
+ ::v-deep .el-col-8 {
|
|
|
+ height: 32px;
|
|
|
+ }
|
|
|
+
|
|
|
::v-deep .el-col-6 {
|
|
|
width: 31%;
|
|
|
height: 32px;
|