jtoms 4 lat temu
rodzic
commit
4a3f279c04

+ 16 - 0
src/api/statistics/popular_feelings.js

@@ -32,3 +32,19 @@ export function deleteByIds(ids) {
     data: ids
   })
 }
+
+export function startSpider(ids) {
+  return request({
+    url: '/popular/feelings/startSpider',
+    method: 'post',
+    data: ids
+  })
+}
+
+export function findDetailPage(data) {
+  return request({
+    url: '/popular/feelings/findDetailPage',
+    method: 'post',
+    data
+  })
+}

+ 90 - 0
src/views/statistics/popularFeelings/DetailPage.vue

@@ -0,0 +1,90 @@
+<template>
+  <el-dialog
+    v-if="visible"
+    title=""
+    :visible.sync="visible"
+    width="1200px"
+  >
+    <el-row :gutter="16">
+      <el-col :span="12">网站名称:{{ rowData.siteName }}</el-col>
+      <el-col :span="12">监控舆论词:{{ rowData.keywords }}</el-col>
+    </el-row>
+    <el-row :gutter="16">
+      <el-col :span="12">监控域名:{{ rowData.domain }}</el-col>
+      <el-col :span="12">
+        启动地址:
+        <el-tag v-for="tag in rowData.startUrls" :key="tag"> {{ tag }}</el-tag>
+      </el-col>
+    </el-row>
+    <el-table
+      v-loading="isLoading"
+      :data="pageData.records"
+      border
+      fit
+      highlight-current-row
+    >
+      <el-table-column label="标题" prop="title"/>
+      <el-table-column label="网址" prop="url"/>
+      <el-table-column label="采集时间" prop="spiderTime" :formatter="dateTimeFormatter" width="200"/>
+      <el-table-column label="详情" width="70">
+        <template slot-scope="scope">
+          <a :href="scope.row.url" target="_blank">详情</a>
+        </template>
+      </el-table-column>
+    </el-table>
+    <el-pagination
+      class="pagination-container"
+      background
+      layout="prev, pager, next"
+      :total="pageData.total"
+      :page-size="pageData.pageSize"
+      @current-change="paginationChange"
+    />
+    <div slot="footer" class="dialog-footer">
+      <el-button @click="visible = false">取 消</el-button>
+    </div>
+  </el-dialog>
+</template>
+<script>
+
+import { findDetailPage } from '@/api/statistics/popular_feelings'
+import { dateTimeFormatter } from '@/utils/formater'
+
+export default {
+  components: {},
+  data() {
+    return {
+      visible: false,
+      isLoading: false,
+      rowData: false,
+
+      pageData: {},
+      currentPage: 1
+    }
+  },
+  mounted() {
+  },
+  methods: {
+    dateTimeFormatter,
+    open(rowData) {
+      this.rowData = rowData
+      this.visible = true
+      this.isLoading = false
+      console.log(this.rowData)
+      this.fetchData()
+    },
+    paginationChange(val) {
+      this.currentPage = val
+      this.fetchData()
+    },
+    fetchData() {
+      this.isLoading = true
+      findDetailPage({ ...this.queryForm, current: this.currentPage, popularFeelingsId: this.rowData.id })
+        .then((response) => {
+          this.pageData = response
+        })
+        .finally(() => (this.isLoading = false))
+    }
+  }
+}
+</script>

+ 66 - 20
src/views/statistics/popularFeelings/DialogForm.vue

@@ -9,22 +9,42 @@
       <el-row :gutter="24">
         <el-col :span="12">
           <el-form-item label="标题">
-            <el-input v-model="form.title"/>
+            <el-input v-model="form.siteName"/>
           </el-form-item>
         </el-col>
-      </el-row>
-      <el-row :gutter="24">
         <el-col :span="12">
-          <el-form-item label="监控词">
+          <el-form-item label="监控舆论词">
             <el-input v-model="form.keywords"/>
           </el-form-item>
         </el-col>
-        <el-col :span="12">
-          <el-form-item label="监控网站">
-            <el-input v-model="form.siteUrl"/>
-          </el-form-item>
-        </el-col>
       </el-row>
+
+      <el-form-item label="监控域名">
+        <el-input v-model="form.domain"/>
+      </el-form-item>
+
+      <el-form-item label="启动地址">
+        <el-tag
+          v-for="tag in startUrls"
+          :key="tag"
+          closable
+          :disable-transitions="false"
+          @close="handleCloseTag(tag)"
+        >
+          {{ tag }}
+        </el-tag>
+        <el-input
+          v-if="inputTagVisible"
+          ref="saveTagInput"
+          v-model="inputStartUrl"
+          class="input-new-tag"
+          size="small"
+          @keyup.enter.native="handleInputConfirmTag"
+          @blur="handleInputConfirmTag"
+        />
+        <el-button v-else class="button-new-tag" size="small" @click="inputTagVisible=true">+ 添加地址</el-button>
+      </el-form-item>
+
     </el-form>
     <div slot="footer" class="dialog-footer">
       <el-button @click="visible = false">取 消</el-button>
@@ -32,7 +52,25 @@
     </div>
   </el-dialog>
 </template>
+<style type="text/css">
+.el-tag + .el-tag {
+  margin-left: 10px;
+}
+
+.button-new-tag {
+  margin-left: 10px;
+  height: 32px;
+  line-height: 30px;
+  padding-top: 0;
+  padding-bottom: 0;
+}
 
+.input-new-tag {
+  width: 200px;
+  margin-left: 10px;
+  vertical-align: bottom;
+}
+</style>
 <script>
 
 import { save, updateById } from '@/api/statistics/popular_feelings'
@@ -42,9 +80,11 @@ export default {
   data() {
     return {
       visible: false,
+      inputTagVisible: false,
       isLoading: false,
       form: {},
-      fileList: []
+      startUrls: [],
+      inputStartUrl: ''
     }
   },
   mounted() {
@@ -53,23 +93,29 @@ export default {
     open(data) {
       this.visible = true
       this.isLoading = false
-      this.fileList = []
+      this.startUrls = []
       this.form = {}
       console.log(data)
-      if (data.litpics) {
-        data.litpics.forEach(o => {
-          this.fileList.push({ url: o })
-        })
+      if (data.startUrls) {
+        this.startUrls = data.startUrls
       }
       this.form = Object.assign({}, data)
     },
+    handleInputConfirmTag() {
+      const inputStartUrl = this.inputStartUrl
+      if (inputStartUrl) {
+        this.startUrls.push(inputStartUrl)
+      }
+      this.inputTagVisible = false
+      this.inputStartUrl = ''
+    },
+    handleCloseTag(tag) {
+      this.startUrls.splice(this.startUrls.indexOf(tag), 1)
+    },
     handleSubmit() {
-      const litpics = []
-      this.fileList.forEach(o => {
-        litpics.push(o.url)
-      })
+      const startUrls = this.startUrls
       this.isLoading = true
-      const param = { ...this.form, 'litpics': litpics }
+      const param = { ...this.form, 'startUrls': startUrls }
       console.log(param)
       if (this.form.id) {
         updateById(this.form.id, param).then(() => {

+ 18 - 5
src/views/statistics/popularFeelings/index.vue

@@ -33,9 +33,18 @@
     >
       <el-table-column type="selection" width="55"/>
       <el-table-column label="ID" prop="id" width="150"/>
-      <el-table-column label="标题" prop="title" width="300"/>
-      <el-table-column label="关键词" prop="keywords" width="300"/>
-      <el-table-column label="监控网站" prop="siteUrl"/>
+      <el-table-column label="网站名称" prop="siteName">
+        <template slot-scope="scope">
+          <el-button type="text" @click.native="$refs.detailPage.open(scope.row)">{{ scope.row.siteName }}</el-button>
+        </template>
+      </el-table-column>
+      <el-table-column label="监控舆论词" prop="keywords"/>
+      <el-table-column label="监控域名" prop="domain"/>
+      <el-table-column label="启动地址" prop="startUrls">
+        <template slot-scope="scope">
+          <el-tag v-for="tag in scope.row.startUrls" :key="tag"> {{ tag }}</el-tag>
+        </template>
+      </el-table-column>
       <el-table-column label="操作" width="70" fixed="right">
         <template slot-scope="scope">
           <el-dropdown>
@@ -45,6 +54,7 @@
             <el-dropdown-menu slot="dropdown">
               <el-dropdown-item v-permission="['popular.feelings.edit']" type="text" @click.native="$refs.dialogForm.open(scope.row)">编辑</el-dropdown-item>
               <el-dropdown-item v-permission="['popular.feelings.delete']" @click.native="deleteByIds([scope.row.id])"> 删除</el-dropdown-item>
+              <el-dropdown-item v-permission="['popular.feelings.delete']" @click.native="startSpider([scope.row.id])"> 启动</el-dropdown-item>
             </el-dropdown-menu>
           </el-dropdown>
         </template>
@@ -59,16 +69,18 @@
       @current-change="paginationChange"
     />
     <dialog-form ref="dialogForm" @ok="fetchData"/>
+    <detail-page ref="detailPage"/>
   </div>
 </template>
 
 <script>
-import { deleteByIds, findPage } from '@/api/statistics/popular_feelings'
+import { deleteByIds, findPage, startSpider } from '@/api/statistics/popular_feelings'
 import { dateTimeFormatter } from '@/utils/formater'
 import DialogForm from './DialogForm'
+import DetailPage from './DetailPage'
 
 export default {
-  components: { DialogForm },
+  components: { DialogForm, DetailPage },
   data() {
     return {
       queryForm: {},
@@ -86,6 +98,7 @@ export default {
   },
   methods: {
     dateTimeFormatter,
+    startSpider,
     deleteByIds(ids) {
       this.$confirm('确认要删除吗?', '提示', {
         confirmButtonText: '确定',