webCrawlerList.vue 18 KB

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