|
@@ -169,8 +169,9 @@
|
|
|
<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 填入输入框内
|
|
|
+ 如标题代码:<div class='news_art'>红枣滞销喂羊 电商帮忙促销</div>,标题字符串为 .news_art 填入输入框内<br />
|
|
|
+ 如标题代码:<div id='news at'>红枣滞销喂羊 电商帮忙促销</div>,标题字符串为 #news art 填入输入框内<br/>
|
|
|
+ 若是有多个,要保证“news_art"的唯一性,标题字符串更改为:标签名.class名 —— div.news_art 填入输入框内
|
|
|
</div>
|
|
|
<i class="el-icon-warning"></i>
|
|
|
</el-tooltip>
|
|
@@ -298,7 +299,7 @@
|
|
|
</div>
|
|
|
|
|
|
<div class="dialogBtn">
|
|
|
- <el-button class="cancel" @click="saveForm">保存</el-button>
|
|
|
+ <el-button class="cancel" @click="saveForm">{{ dialogBoo == 'add' ? '保存' : '取消' }}</el-button>
|
|
|
<el-button type="primary" class="submit" :loading="submitDisabled"
|
|
|
@click="submitForm('ruleForm')">确定</el-button>
|
|
|
</div>
|
|
@@ -387,27 +388,27 @@ export default {
|
|
|
callback()
|
|
|
}
|
|
|
}
|
|
|
- const validatauthor = (rule, value, callback) => {
|
|
|
- if (value.length == 0) {
|
|
|
- callback(new Error('请输入作者字符串'))
|
|
|
- } else {
|
|
|
- callback()
|
|
|
- }
|
|
|
- }
|
|
|
- const validatauthorName = (rule, value, callback) => {
|
|
|
- if (value.length == 0) {
|
|
|
- callback(new Error('请输入作者替换名称'))
|
|
|
- } else {
|
|
|
- callback()
|
|
|
- }
|
|
|
- }
|
|
|
- const validatparameter = (rule, value, callback) => {
|
|
|
- if (value.length == 0) {
|
|
|
- callback(new Error('请输入接口参数'))
|
|
|
- } else {
|
|
|
- callback()
|
|
|
- }
|
|
|
- }
|
|
|
+ // const validatauthor = (rule, value, callback) => {
|
|
|
+ // if (value.length == 0) {
|
|
|
+ // callback(new Error('请输入作者字符串'))
|
|
|
+ // } else {
|
|
|
+ // callback()
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // const validatauthorName = (rule, value, callback) => {
|
|
|
+ // if (value.length == 0) {
|
|
|
+ // callback(new Error('请输入作者替换名称'))
|
|
|
+ // } else {
|
|
|
+ // callback()
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // const validatparameter = (rule, value, callback) => {
|
|
|
+ // if (value.length == 0) {
|
|
|
+ // callback(new Error('请输入接口参数'))
|
|
|
+ // } else {
|
|
|
+ // callback()
|
|
|
+ // }
|
|
|
+ // }
|
|
|
const validatsecondWeb = (rule, value, callback) => {
|
|
|
if (value.length == 0) {
|
|
|
callback(new Error('请输入第2页网址'))
|
|
@@ -476,9 +477,9 @@ export default {
|
|
|
ruleName: [{ required: true, trigger: 'blur', validator: validateRuleName }],
|
|
|
first_url: [{ required: true, trigger: 'blur', validator: validateFirst_url }],
|
|
|
secondWeb: [{ required: true, trigger: 'blur', validator: validatsecondWeb }],
|
|
|
- // second_start:[{ required: true, trigger: 'blur', validator: validatsecondWeb }],
|
|
|
- // second_num:[{ required: true, trigger: 'blur', validator: validatsecondWeb }],
|
|
|
- // second_end:[{ required: true, trigger: 'blur', validator: validatsecondWeb }],
|
|
|
+ second_start: [{ required: true, trigger: 'blur', validator: validatsecondWeb }],
|
|
|
+ second_num: [{ required: true, trigger: 'blur', validator: validatsecondWeb }],
|
|
|
+ second_end: [{ required: true, trigger: 'blur', validator: validatsecondWeb }],
|
|
|
second_start: [{ required: true, trigger: 'blur', message: '请输入网址开头' }],
|
|
|
second_num: [{ required: true, trigger: 'blur', message: '请输入代码页数' }],
|
|
|
second_end: [{ required: true, trigger: 'blur', message: '请输入网址结束字符串' }],
|
|
@@ -490,9 +491,9 @@ export default {
|
|
|
title: [{ required: true, trigger: 'blur', validator: validatTitle }],
|
|
|
content: [{ required: true, trigger: 'blur', validator: validatcontent }],
|
|
|
source: [{ required: true, trigger: 'blur', validator: validatsource }],
|
|
|
- author: [{ required: true, trigger: 'blur', validator: validatauthor }],
|
|
|
- authorName: [{ required: true, trigger: 'blur', validator: validatauthorName }],
|
|
|
- parameter: [{ required: true, trigger: 'blur', validator: validatparameter }]
|
|
|
+ author: [{ required: true, trigger: 'blur', message: "请输入作者字符串" }],
|
|
|
+ authorName: [{ required: true, trigger: 'blur', message: "请输入作者替换名称" }],
|
|
|
+ parameter: [{ required: true, trigger: 'blur', message: "请输入接口参数" }]
|
|
|
}
|
|
|
}
|
|
|
},
|
|
@@ -505,9 +506,8 @@ export default {
|
|
|
pageSize: this.pageSize,
|
|
|
page: this.page,
|
|
|
}).then(data => {
|
|
|
- if (data.code == 200) {
|
|
|
- this.loading = false
|
|
|
- }
|
|
|
+ this.loading = false
|
|
|
+
|
|
|
console.log(data.data.rep);
|
|
|
this.tableData = data.data.rep
|
|
|
this.total = data.data.count
|
|
@@ -595,6 +595,8 @@ export default {
|
|
|
|
|
|
//1.8 设置采集规则
|
|
|
addCrawlerRule() {
|
|
|
+ this.dialogName = '设置采集规则'
|
|
|
+ this.dialogBoo = "add"
|
|
|
if (!this.webType) {
|
|
|
this.dialogTableVisible = false
|
|
|
this.$message({
|
|
@@ -735,6 +737,9 @@ export default {
|
|
|
},
|
|
|
//1.9 编辑采集规则
|
|
|
goEdit(id, val) {
|
|
|
+ this.dialogName = '编辑采集规则'
|
|
|
+ this.dialogBoo = "update"
|
|
|
+
|
|
|
console.log(id);
|
|
|
this.activeId = id
|
|
|
console.log(val);
|
|
@@ -746,7 +751,6 @@ export default {
|
|
|
})
|
|
|
return
|
|
|
} else if (this.webType == 1) {
|
|
|
- this.dialogBoo = "update"
|
|
|
this.dialogTableVisible = true
|
|
|
this.ruleForm.ruleName = val.name
|
|
|
this.ruleForm.first_url = val.first_url
|
|
@@ -768,7 +772,6 @@ export default {
|
|
|
this.ruleForm.detailPage = val.con_start
|
|
|
|
|
|
} else if (this.webType == 2) {
|
|
|
- this.dialogBoo = "update"
|
|
|
this.dialogTableVisible = true
|
|
|
this.ruleForm.ruleName = val.name
|
|
|
this.ruleForm.first_url = val.first_url
|
|
@@ -793,7 +796,6 @@ export default {
|
|
|
this.ruleForm.authorName = val.writer
|
|
|
}
|
|
|
} else if (this.webType == 3) {
|
|
|
- this.dialogBoo = "update"
|
|
|
this.dialogTableVisible = true
|
|
|
this.ruleForm.ruleName = val.name
|
|
|
this.ruleForm.diy_rule = val.diy_rule
|
|
@@ -846,7 +848,7 @@ export default {
|
|
|
this.$refs[formName].validate((valid) => {
|
|
|
if (valid) {
|
|
|
console.log('submit!');
|
|
|
- this.submitDisabled = true
|
|
|
+ // this.submitDisabled = true
|
|
|
} else {
|
|
|
console.log('error submit!!');
|
|
|
return false;
|
|
@@ -874,6 +876,7 @@ export default {
|
|
|
con_url: this.ruleForm.webSite_start.trim(), //详情页标签
|
|
|
con_start: this.ruleForm.detailPage, //详情页网址前缀
|
|
|
}).then(data => {
|
|
|
+ this.submitDisabled = true
|
|
|
this.getData()
|
|
|
console.log(data);
|
|
|
if (data.code == 200) {
|
|
@@ -884,6 +887,13 @@ export default {
|
|
|
type: 'success'
|
|
|
})
|
|
|
}
|
|
|
+ if (data.code == 0) {
|
|
|
+ this.submitDisabled = false
|
|
|
+ this.$message({
|
|
|
+ message: data.message,
|
|
|
+ type: 'error'
|
|
|
+ })
|
|
|
+ }
|
|
|
})
|
|
|
} else {
|
|
|
addRule({
|
|
@@ -914,6 +924,12 @@ export default {
|
|
|
type: 'success'
|
|
|
})
|
|
|
}
|
|
|
+ if (data.code == 0) {
|
|
|
+ this.$message({
|
|
|
+ message: data.message,
|
|
|
+ type: 'error'
|
|
|
+ })
|
|
|
+ }
|
|
|
})
|
|
|
}
|
|
|
|
|
@@ -990,6 +1006,7 @@ export default {
|
|
|
}
|
|
|
})
|
|
|
}
|
|
|
+ sessionStorage.clear();
|
|
|
}
|
|
|
//编辑
|
|
|
if (this.dialogBoo == 'update') {
|
|
@@ -1015,9 +1032,9 @@ export default {
|
|
|
content: this.ruleForm.content.trim(),//规则型1:内容标签类名 接口型2:内容标签
|
|
|
source: this.ruleForm.source, //规则型1:来源标签类名 接口型2:来源标签
|
|
|
writer_class: this.ruleForm.author,//规则型1:作者标签类名 接口型2:作者标签
|
|
|
- writer: this.ruleForm.authorName.trim(),//规则型1:接口型2:作者默认名称(若未采集到则设置默认作者)
|
|
|
+ writer: this.ruleForm.authorName,//规则型1:接口型2:作者默认名称(若未采集到则设置默认作者)
|
|
|
end_pagenum: this.ruleForm.endPage,//规则型1:列表页结束页码
|
|
|
- con_url: this.ruleForm.webSite_start.trim(), //详情页标签
|
|
|
+ con_url: this.ruleForm.webSite_start, //详情页标签
|
|
|
con_start: this.ruleForm.detailPage, //详情页网址前缀
|
|
|
}).then(data => {
|
|
|
this.getData()
|
|
@@ -1107,25 +1124,30 @@ 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); //自定义类
|
|
|
+ if (this.dialogBoo == 'add') {
|
|
|
+ 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); //自定义类
|
|
|
+ }
|
|
|
+ if (this.dialogBoo == 'update') {
|
|
|
+ this.dialogTableVisible = false
|
|
|
+ }
|
|
|
},
|
|
|
// 查看
|
|
|
goLook(id, val) {
|