Sfoglia il codice sorgente

wip:数据导出get请求替换为post请求,防止导出量过大导致超出get请求限制

wangkaiyue 3 anni fa
parent
commit
4c90d05ccc
2 ha cambiato i file con 48 aggiunte e 21 eliminazioni
  1. 10 0
      src/api/modules/home.js
  2. 38 21
      src/components/push-list/PushList.vue

+ 10 - 0
src/api/modules/home.js

@@ -27,6 +27,16 @@ export function getExportPushList (data) {
   })
 }
 
+export function getExportSelectItems (data) {
+  data = qs.stringify(data)
+  return request({
+    baseURL: '/publicapply',
+    url: '/dataexpoet/bySelects',
+    method: 'post',
+    data: data
+  })
+}
+
 export function getSimpleFollowList (data) {
   data = qs.stringify(data)
   return request({

+ 38 - 21
src/components/push-list/PushList.vue

@@ -68,7 +68,8 @@
         </tr>
         </thead>
         <tbody>
-        <tr v-for="(item, index) in tableList" :class="{ visited: item.visited }" :key="index + '_' + item._id" @click="toDetail(item)">
+        <tr v-for="(item, index) in tableList" :class="{ visited: item.visited }" :key="index + '_' + item._id"
+            @click="toDetail(item)">
           <td width="48">{{ index + 1 }}</td>
           <td width="315" class="tt-l" v-html="calcTitle(item, index)"></td>
           <td width="84">{{ item.type }}</td>
@@ -127,11 +128,11 @@
 </template>
 
 <script>
-import { Pagination, Card, Button } from 'element-ui'
+import { Button, Card, Pagination } from 'element-ui'
 import Empty from '@/components/common/Empty.vue'
 import ArticleItem from '@/components/article-item/ArticleItem.vue'
-import { getPushList, getExportPushList } from '@/api/modules/'
-import { moneyUnit, dateFromNow, replaceKeyword } from '@/utils/'
+import { getExportPushList, getExportSelectItems, getPushList } from '@/api/modules/'
+import { dateFromNow, moneyUnit, replaceKeyword } from '@/utils/'
 import { mixinVisited } from '@/utils/mixins/visited'
 /* eslint-disable */
 export default {
@@ -223,7 +224,10 @@ export default {
       }
     },
     calcTitle (item) {
-      const { projectName, matchkeys } = item
+      const {
+        projectName,
+        matchkeys
+      } = item
       const hightLightedTitle = replaceKeyword(projectName, matchkeys, ['<span class="highlight-text">', '</span>'])
       return `${hightLightedTitle}`
     },
@@ -231,25 +235,34 @@ export default {
       const nowCheckItems = this.getCheckIds(function () {
         return $(this).attr('dataid')
       })
+      let exportDataFlag = ''
       if (nowCheckItems.length) {
-        return location.href = `/front/dataExport/superSearchExport?selectIds=${nowCheckItems.join(',')}`
-      }
-
-      console.log('all')
-      const query = {}
-      if (this.getFilters && Object.keys(this.getFilters).length > 0) {
-        Object.keys(this.getFilters).forEach(v => {
-          if (typeof this.getFilters[v] !== 'undefined') {
-            query[v] = this.getFilters[v]
+        //导出选择(因可以翻页多选,修改为post请求,防止穿参数过长,后跳转)
+        //return location.href = `/front/dataExport/superSearchExport?selectIds=${nowCheckItems.join(',')}`
+        const res = await getExportSelectItems({ selectIds: nowCheckItems.join(',') })
+        if (res.error_code === 0) {
+          exportDataFlag = res.data
+        }
+      } else {
+        //导出筛选条件
+        const query = {}
+        if (this.getFilters && Object.keys(this.getFilters).length > 0) {
+          Object.keys(this.getFilters).forEach(v => {
+            if (typeof this.getFilters[v] !== 'undefined') {
+              query[v] = this.getFilters[v]
+            }
+          })
+        }
+        const res = await getExportPushList(query)
+        if (res.error_code === 0) {
+          if (res.data._id) {
+            exportDataFlag = res.data._id
           }
-        })
-      }
-      const res = await getExportPushList(query)
-      if (res.error_code === 0) {
-        if (res.data._id) {
-          location.href = '/front/dataExport/toCreateOrderPage/' + res.data._id
         }
       }
+      if (exportDataFlag) {
+        location.href = '/front/dataExport/toCreateOrderPage/' + exportDataFlag
+      }
     },
     onClickDataCollect () {
       const nowCheckItems = this.getCheckIds(function () {
@@ -416,7 +429,11 @@ export default {
       return collBidAction(baction, binfo, callback)
     },
     onCollect (data) {
-      let { item, event, list } = data
+      let {
+        item,
+        event,
+        list
+      } = data
       let binfo = []
       if (list) {
         binfo = list.filter(v => !v.check).map(v => ({ bid: v.id }))