webCrawlerList.vue 18 KB

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