webCrawlerList.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563
  1. <template>
  2. <!-- 采集列表 -->
  3. <div>
  4. <div class="title">
  5. <el-row>
  6. <el-col :span="6" class="left">
  7. <div class="searchBox">
  8. <div class="searchTitle">资讯题目</div>
  9. <el-input v-model="message_name" placeholder="请输入资讯名称"></el-input>
  10. </div>
  11. </el-col>
  12. <el-col :span="6" class="left">
  13. <div class="searchBox">
  14. <div class="searchTitle">来源</div>
  15. <el-input v-model="message_from" placeholder="请输入来源"></el-input>
  16. </div>
  17. </el-col>
  18. <el-col :span="6" class="left">
  19. <div class="searchBox">
  20. <div class="searchTitle">导入状态</div>
  21. <el-select v-model="message_state" placeholder="请选择导入状态">
  22. <el-option v-for="item in statusOptions" :key="item.value" :label="item.label"
  23. :value="item.value">
  24. </el-option>
  25. </el-select>
  26. </div>
  27. </el-col>
  28. <el-col :span="6" class="right">
  29. <div class="btnList">
  30. <button class="search" @click="goSearch">搜索</button>
  31. <button class="reset" @click="goReset">重置</button>
  32. </div>
  33. </el-col>
  34. </el-row>
  35. </div>
  36. <!--表格内容 start------------------------------------------------------------>
  37. <div class="layerBox">
  38. <tableTitle :name="tableDivTitle" />
  39. <div class="btnList">
  40. <button class="navigation" @click="toNavigation">关联导航池</button>
  41. <button class="consultList" @click="importMessage">导入资讯列表</button>
  42. </div>
  43. <el-row>
  44. <template>
  45. <el-table class="my-table" v-loading="loading" :data="tableData" style="width: 100%">
  46. <el-table-column fixed prop="id" label="编号" width="80">
  47. </el-table-column>
  48. <el-table-column prop="title" label="资讯题目" width="230">
  49. </el-table-column>
  50. <el-table-column prop="oldtitle" label="原始资讯题目" width="230">
  51. </el-table-column>
  52. <el-table-column prop="category.name" label="导航池名称" width="120">
  53. </el-table-column>
  54. <el-table-column prop="source" label="来源" width="120">
  55. </el-table-column>
  56. <el-table-column label="导入状态" prop="state" width="100">
  57. </el-table-column>
  58. <el-table-column prop="author" label="作者" width="90">
  59. </el-table-column>
  60. <el-table-column prop="created_at" label="采集时间" width="160">
  61. </el-table-column>
  62. <el-table-column prop="updated_at" label="修改时间" width="160">
  63. </el-table-column>
  64. <el-table-column fixed="right" label="操作" width="200">
  65. <template slot-scope="scope">
  66. <div class="listBtnBox">
  67. <div class="listDeleteBtn" @click="deleteRow(scope.row.id, scope.row)"><i
  68. class="el-icon-delete"></i>删除</div>
  69. <div class="listEditBtn" @click="goEdit(scope.row.id, scope.row)"><i
  70. class="el-icon-edit-outline"></i>编辑</div>
  71. </div>
  72. </template>
  73. </el-table-column>
  74. </el-table>
  75. </template>
  76. </el-row>
  77. </div>
  78. <!--分页 start------------------------------------------------------------>
  79. <div class="alignBox">
  80. <el-row>
  81. <el-col :span="24">
  82. <el-pagination background @size-change="handleSizeChange" @current-change="handleCurrentChange"
  83. :current-page="page" :page-size="pageSize" layout="total, prev, pager, next, jumper"
  84. :total="total">
  85. </el-pagination>
  86. </el-col>
  87. </el-row>
  88. </div>
  89. <!--分页 end------------------------------------------------------------>
  90. <!--表格内容 end------------------------------------------------------------>
  91. <!-- 弹出框 start------------------------------------------------------------>
  92. <el-dialog title="关联导航池" :visible.sync="dialogTableVisible" width="50%" :close-on-click-modal="false">
  93. <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="120px" class="demo-ruleForm">
  94. <div class="dialogText">
  95. <el-form-item label="关联导航池:" prop="name">
  96. <el-select v-model="ruleForm.name" placeholder="请选择关联的导航池名称">
  97. <el-option v-for="item in options" :key="item.id" :label="item.name" :value="item.id">
  98. </el-option>
  99. </el-select>
  100. </el-form-item>
  101. </div>
  102. <div class="dialogBtn">
  103. <button class="cancel" @click="cancelForm">取消</button>
  104. <button class="submit" @click="submitForm">提交</button>
  105. </div>
  106. </el-form>
  107. </el-dialog>
  108. <!-- 弹出框 end------------------------------------------------------------>
  109. </div>
  110. </template>
  111. <script>
  112. //表格标题
  113. import tableTitle from './components/tableTitle.vue';
  114. //引入公用样式
  115. import '@/styles/global.less';
  116. import { getInfo, updateInfo, delInfo, addCatid, addArt } from '@/api/crawler'
  117. export default {
  118. components: {
  119. tableTitle,//表格标题
  120. },
  121. data() {
  122. return {
  123. tableDivTitle: "任务规则列表",//表格标题
  124. // searchWebName: "", //搜索网站名称
  125. // dialogName:'关联导航池',
  126. loading: true,
  127. //跳转传递的参数
  128. ruleId: "", //规则id
  129. source: "", //规则来源
  130. state: 0, //导入状态
  131. //搜索框
  132. message_name: '',//资讯名称
  133. message_from: '', //来源
  134. message_state: '', //导入状态
  135. //分页相关
  136. page: 1,
  137. pageSize: 10,
  138. total: 20,
  139. tableData: [], //表格内数据
  140. // currentPage: 4,
  141. dialogTableVisible: false,
  142. // dialogName: '',
  143. ruleForm: {
  144. name: '',
  145. },
  146. rules: { //规则
  147. name: [
  148. { required: true, message: '请选择关联的导航池名称', trigger: 'blur' },
  149. ]
  150. },
  151. // dialog 关联导航池
  152. options: [],
  153. statusOptions: [
  154. {
  155. value: '0',
  156. label: '未导入'
  157. },
  158. {
  159. value: '1',
  160. label: '已导入'
  161. },
  162. ]
  163. }
  164. },
  165. mounted() {
  166. // 接收跳转传递的参数
  167. this.ruleId = this.$route.query.id
  168. this.source = this.$route.query.source
  169. //请求数据
  170. this.getData()
  171. },
  172. methods: {
  173. //1.列表和分页相关 start ------------------------------------------------------------>
  174. //1.1 开始请求列表信息方法
  175. getData() {
  176. getInfo({
  177. // rule_id: 12,
  178. rule_id: this.ruleId,
  179. page: this.page,
  180. pageSize: this.pageSize
  181. }).then(data => {
  182. console.log(data);
  183. if (data.code == 200) {
  184. this.loading = false
  185. }
  186. this.total = data.data.count
  187. this.tableData = data.data.rep
  188. for (let item of this.tableData) {
  189. if (item.state == 1) {
  190. item.state = "已导入"
  191. } else {
  192. item.state = "未导入"
  193. }
  194. }
  195. })
  196. },
  197. //1.2 删除内容
  198. deleteRow(id, val) {
  199. this.$confirm('注意:删除后,该条信息及其绑定关系全部删除', '是否确认删除该条信息?', {
  200. confirmButtonText: '确定',
  201. cancelButtonText: '取消',
  202. }).then(() => {
  203. delInfo({
  204. art_id: id
  205. }).then(data => {
  206. console.log(data);
  207. if (data.code == 200) {
  208. this.$message({
  209. type: 'success',
  210. message: '删除成功!'
  211. });
  212. this.getData()
  213. console.log("当前删除:" + id)
  214. } else if (data.code == 0) {
  215. this.$message({
  216. type: 'error',
  217. message: data.message
  218. });
  219. }
  220. })
  221. }).catch(() => {
  222. this.$message({
  223. type: 'warning',
  224. message: '已取消删除'
  225. });
  226. });
  227. },
  228. //1.3 修改网站状态
  229. //1.4 列表内容分页
  230. //直接跳转
  231. handleSizeChange(val) {
  232. this.page = val;
  233. this.getData();
  234. },
  235. //1.5 点击分页
  236. handleCurrentChange(val) {
  237. this.page = val;
  238. this.getData();
  239. },
  240. // 1.6 搜索按钮
  241. goSearch() {
  242. getInfo({
  243. rule_id: this.ruleId,
  244. page: this.page,
  245. pageSize: this.pageSize,
  246. title: this.message_name,
  247. source: this.message_from,
  248. state: this.message_state
  249. }).then(data => {
  250. console.log(data);
  251. this.total = data.data.count
  252. this.tableData = data.data.rep
  253. })
  254. },
  255. //1.7 重置按钮
  256. goReset() {
  257. this.message_name = '',
  258. this.message_from = '',
  259. this.message_state = ''
  260. this.getData()
  261. },
  262. //列表和分页相关 end ------------------------------------------------------------>
  263. //1.8 编辑
  264. goEdit(id, val) {
  265. console.log(id, val);
  266. // this.$router.push('/webCrawlerListEdit')
  267. this.$router.push({
  268. path: '/webCrawlerListEdit',
  269. query: {
  270. ruleId: this.ruleId,
  271. source: this.source,
  272. id: id,
  273. // data: val
  274. }
  275. })
  276. },
  277. //1.9 关联导航池
  278. toNavigation() {
  279. addCatid({
  280. rule_id: this.ruleId,
  281. }).then(data => {
  282. console.log(data);
  283. if (data.code == 200) {
  284. this.dialogTableVisible = true
  285. this.options = data.data
  286. }
  287. if (data.code == 0) {
  288. this.$message({
  289. message: data.message,
  290. type: 'error'
  291. })
  292. }
  293. this.getData()
  294. })
  295. },
  296. //关联导航池的取消按钮
  297. cancelForm() {
  298. this.dialogTableVisible = false
  299. },
  300. //关联导航池的提交按钮
  301. submitForm() {
  302. addCatid({
  303. rule_id: this.ruleId,//任务规则id
  304. cat_arr_id: this.ruleForm.name,//导航池栏目id
  305. }).then(data => {
  306. console.log(this.ruleForm.name);
  307. console.log(data);
  308. if (data.code == 200) {
  309. this.dialogTableVisible = false
  310. this.$message({
  311. message: '关联成功!',
  312. type: 'success'
  313. })
  314. this.getData()
  315. }
  316. if (data.code == 0) {
  317. this.$message({
  318. message: data.message,
  319. type: 'error'
  320. })
  321. this.getData()
  322. }
  323. })
  324. },
  325. //2.0 导入资讯列表
  326. importMessage() {
  327. for (let item of this.tableData) {
  328. if (item.category.name == '') {
  329. this.$message({
  330. message: '还未关联导航池,请先关联导航池',
  331. type: 'error'
  332. })
  333. } else {
  334. this.$confirm('', '是否确认将所有未导入的信息导入资讯列表?', {
  335. confirmButtonText: '确定',
  336. cancelButtonText: '取消',
  337. }).then(() => {
  338. addArt({
  339. rule_id: this.ruleId
  340. }).then(data => {
  341. console.log(data);
  342. if (data.code == 200) {
  343. this.$message({
  344. message: '导入成功',
  345. type: 'success'
  346. })
  347. this.getData()
  348. }
  349. if (data.code == 0) {
  350. this.$message({
  351. message: data.message,
  352. type: 'error'
  353. })
  354. }
  355. })
  356. }).catch(() => {
  357. this.$message({
  358. type: 'warning',
  359. message: '已取消'
  360. });
  361. });
  362. }
  363. }
  364. }
  365. },
  366. }
  367. </script>
  368. <style scoped lang="less">
  369. .title {
  370. margin: 30px 30px 20px 30px;
  371. padding: 30px 30px 40px 30px;
  372. background-color: #fff;
  373. border-radius: 20px 20px 20px 20px;
  374. border: 1px solid #E9EDF7;
  375. .left {
  376. float: left;
  377. }
  378. .right {
  379. float: right;
  380. }
  381. .searchBox {
  382. margin-right: 30px;
  383. .searchTitle {
  384. padding-bottom: 10px;
  385. font-family: Microsoft YaHei, Microsoft YaHei;
  386. font-weight: 400;
  387. font-size: 14px;
  388. color: #999999;
  389. line-height: 16px;
  390. }
  391. .el-select {
  392. // width: 300px;
  393. display: inline-block;
  394. position: relative;
  395. }
  396. }
  397. .btnList {
  398. float: right;
  399. padding-top: 28px;
  400. button {
  401. // width: 120px;
  402. height: 38px;
  403. border: none;
  404. border-radius: 8px;
  405. padding: 0 20px;
  406. }
  407. .search {
  408. background-color: #5570f1;
  409. color: #fff;
  410. margin-right: 20px;
  411. }
  412. .reset {
  413. font-family: Microsoft YaHei, Microsoft YaHei;
  414. font-weight: 400;
  415. font-size: 16px;
  416. color: #333333;
  417. background: #F5F7FB;
  418. border-radius: 8px 8px 8px 8px;
  419. border: 1px solid rgba(85, 112, 241, 0.11);
  420. }
  421. }
  422. }
  423. .layerBox {
  424. padding: 30px 20px;
  425. position: relative;
  426. .btnList {
  427. position: absolute;
  428. top: 30px;
  429. right: 20px;
  430. height: 38px;
  431. >button {
  432. color: #fff;
  433. background-color: #5570f1;
  434. border: none;
  435. border-radius: 8px;
  436. padding: 8px 28px 9px;
  437. box-sizing: border-box;
  438. }
  439. >button:first-child {
  440. margin-right: 30px;
  441. }
  442. }
  443. .listBtnBox {
  444. justify-content: left;
  445. }
  446. .listDeleteBtn,
  447. .listEditBtn,
  448. .listLookBtn {
  449. margin-left: 0px;
  450. padding-left: 0px;
  451. margin-right: 20px;
  452. width: 76px;
  453. height: 36px;
  454. line-height: 36px;
  455. }
  456. .listLookBtn {
  457. text-align: center;
  458. border-radius: 8px;
  459. cursor: pointer;
  460. color: #999999;
  461. background-color: rgba(153, 153, 153, 0.16);
  462. >i {
  463. padding-right: 8px;
  464. }
  465. }
  466. }
  467. // 弹出层内容
  468. .dialogText {
  469. margin: 0 7px 0 3px;
  470. padding-top: 20px;
  471. padding-bottom: 1px;
  472. padding: 20px 60px 1px 20px;
  473. background-color: #f5f7fb;
  474. }
  475. // 弹出层按钮
  476. .dialogBtn {
  477. text-align: center;
  478. margin: 50px auto 20px;
  479. button {
  480. width: 184px;
  481. padding: 16px;
  482. font-family: Microsoft YaHei, Microsoft YaHei;
  483. font-weight: 400;
  484. font-size: 20px;
  485. border: none;
  486. border-radius: 12px 12px 12px 12px;
  487. }
  488. // 取消
  489. .cancel {
  490. color: #333333;
  491. background-color: #f5f7fb;
  492. border: 2px solid rgba(85, 112, 241, 0.11);
  493. }
  494. // 提交
  495. .submit {
  496. color: #fff;
  497. background-color: #5570F1;
  498. margin-left: 40px;
  499. }
  500. }
  501. ::v-deep .el-form-item {
  502. margin-bottom: 50px;
  503. }
  504. ::v-deep .el-select {
  505. width: 100%;
  506. }
  507. ::v-deep .el-input--medium,
  508. ::v-deep .el-form-item__label {
  509. line-height: 36px;
  510. font-size: 16px;
  511. }
  512. </style>