Explorar el Código

feat: 市场分析报告下载接口联调

zhangsiya hace 1 año
padre
commit
25266d4b9d

+ 41 - 1
apps/bigmember_pc/src/api/modules/report.js

@@ -93,11 +93,51 @@ export function isOfflineReport(data) {
 
 // 报告pdf下载包--历史记录列表
 export function getPDFDownloadRecord(data) {
-  data = qs.stringify(data)
   return request({
     url: '/bigmember/analysisReport/getPdfList',
     method: 'post',
     data: data
   })
 }
+// pdf筛选项存储
+export function savePdfCondition(data) {
+  return request({
+    url: '/bigmember/analysisReport/pdfSave',
+    method: 'post',
+    data: data
+  })
+}
+
+//pdf下载邮箱回显
+export function getPdfEmail() {
+  return request({
+    url: '/bigmember/analysisReport/getPdfEmail',
+    method: 'post',
+  })
+}
+
+//pdf下载邮箱回显
+export function sendPdfEmail(data) {
+  return request({
+    url: '/bigmember/analysisReport/pdfSendEmail',
+    method: 'post',
+    data
+  })
+}
+// 获取PDF的数据
+export function getPdfDetail(data) {
+  return request({
+    url: '/bigmember/analysisReport/getPdfDetail',
+    method: 'post',
+    data
+  })
+}
+
+
+
+
+
+
+
+
 

+ 7 - 23
apps/bigmember_pc/src/components/report-data/ReportList.vue

@@ -138,8 +138,8 @@
             <!-- 下载完成,且当前分析下查询的项目总数>0展示-->
               <span
                 class="go-info-text"
-                v-if="scope.row.state === 1"
-                @click="downloadReport(scope.row.id)"
+                v-if="scope.row.state === 1 && scope.row.marketProfile && scope.row.marketProfile.project_count > 0"
+                @click="downloadReport(scope.row)"
               >下载</span>
             <span
               class="go-info-text"
@@ -288,12 +288,8 @@ export default {
     }
   },
   computed: {
-    ...mapGetters('user', ['power']),
     showEmpty() {
       return this.listState.list.length === 0 && this.listState.loaded
-    },
-    hasPower() {
-      return this.power && this.power.length > 0 && this.power.indexOf(26) !== -1
     }
   },
   data() {
@@ -464,25 +460,13 @@ export default {
       window.open('/page_workDesktop/work-bench/app/big/push_setting', '_blank')
     },
     // 下载报告
-    async downloadReport (id) {
+    async downloadReport (item) {
+      const totalList = item.marketProfile ? this.sortMarketOverview(item.marketProfile) : []
       const options = {
-        totalList: []
-      }
-      if(!this.hasPower) {
-        this.downloadReportFun(options)
-      } else {
-        // 先请求获取市场概况数据,再弹出导出框
-        const query = {
-          rid: id,
-          flag: 1
-        }
-        const { data, error_code: code} = await getReportAnalysisInfo(query)
-        if(code === 0 && data) {
-          const totalList = this.sortMarketOverview(data.market_profile)
-          options.totalList = totalList
-          this.downloadReportFun(options)
-        }
+        totalList: totalList,
+        sid: item.id
       }
+      this.downloadReportFun(options)
     },
     // 市场概况
     sortMarketOverview(profile) {

+ 2 - 1
apps/bigmember_pc/src/views/analysisReport/MarketAnalysisResult.vue

@@ -907,7 +907,8 @@ export default {
       inWorkDeskTop: false,
       // 报告下载弹窗
       reportDownloadDialog: {
-        totalList: []
+        totalList: [],
+        sid: this.rid
       }
     }
   },

+ 126 - 23
apps/bigmember_pc/src/views/analysisReport/components/ReportDownloadDialog.vue

@@ -3,14 +3,13 @@
     title="市场分析报告下载"
     :visible.sync="options.visible"
     :close-on-click-modal="false"
-
     lock-scroll
     center
     top="15%"
     custom-class="self-report-download-dialog"
     width="1000px"
   >
-    <div class="content">
+    <div class="content" v-loading="loading">
       <section class="report-effect-box">
          <div class="left">
            <p class="box-label">报告作用:</p>
@@ -23,6 +22,15 @@
         <span v-for="item in totalList">{{item.label}}:<strong>{{ item.count + item.unit }}</strong></span>
         <span class="highlight view-more" @click="viewMore">查看更多</span>
       </section>
+      <section class="email-box">
+        <span class="email-label"><i class="star">*</i>接收邮箱:</span>
+        <el-input v-model="s_email" placeholder="必填,报告将发送至邮箱" @input="showEmailError = false" @change="checkEmail"></el-input>
+        <span class="error-tip" v-if="showEmailError">
+          <i class="el-icon-error"></i>
+          <span v-if="s_email">邮箱格式错误</span>
+          <span v-else>请输入邮箱</span>
+        </span>
+      </section>
       <section class="download-notice-box">
         <p class="box-label">下载须知:</p>
         <div class="box-desc">
@@ -33,35 +41,33 @@
         </div>
       </section>
     </div>
-    <div slot="footer">
+    <div slot="footer" >
       <div class="footer-con">
-        <span class="residue">市场分析定制报告下载余额:1份</span>
+        <span class="residue">市场分析定制报告下载余额:{{ residueCount }}份</span>
         <span class="go-recharge" @click="goRecharge">去充值&gt;</span>
         <span class="deduct">本次扣除:<em>1份</em></span>
         <span class="zero-tip" v-if="residueCount === 0">余额不足,请先充值</span>
       </div>
-      <el-button class="download-btn" type="primary" @click="downloadHandle">立即下载</el-button>
+      <el-button class="download-btn" type="primary" @click="downloadHandle" >立即下载</el-button>
     </div>
   </el-dialog>
 </template>
 
 <script>
-import { Dialog, Button } from 'element-ui'
-import { debounce } from '@/utils/'
 import { mapGetters } from 'vuex'
+import { getPDFPackBalance, sendPdfEmail, getPdfEmail, savePdfCondition } from '@/api/modules/'
+import { debounce } from '@/utils/'
+import { emailRegExp } from '@/utils/constant'
 
 export default {
-  components: {
-    [Dialog.name]: Dialog,
-    [Button.name]: Button
-  },
   props: {
     options: {
       type: Object,
       default: () => {
         return {
           visible: false,
-          totalList: []
+          totalList: [],
+          sid: ''
         }
       }
     }
@@ -69,7 +75,10 @@ export default {
   data () {
     return {
       // 下载余额
-      residueCount: 0
+      residueCount: 0,
+      s_email: '',
+      showEmailError: false,
+      loading: false
     }
   },
   computed: {
@@ -85,21 +94,69 @@ export default {
     }
   },
   created() {
+    console.log(this.options)
+    this.getEmail()
+    this.getResidueCount()
   },
   methods: {
-    // 获取下载余额
-    getResidueCount () {
+    async getEmail () {
+      const {error_code: code, data } = await getPdfEmail()
+      if(data && code === 0) {
+        this.s_email = data || ''
+      }
 
     },
+    // 获取下载余额
+    async getResidueCount () {
+      const {error_code: code, data } = await getPDFPackBalance()
+      if(code === 0 && data) {
+        this.residueCount = data.market?.total || 0
+      }
+    },
     // 查看报告样例
-    viewExample (fileUrl) {
-      // TODO 需要服务端提供链接
-      window.open('https://www.kdocs.cn/l/ctXdN3LVDdjP', '_blank')
+    viewExample () {
+      window.open('/pdf-files/markerPdf/analyze.pdf', '_blank')
     },
     // 立即下载
-    downloadHandle: debounce(function (fileUrl) {
-      this.options.visible = false
-      this.$confirm('您可前往“资产-报告下载记录”查看详情。', '报告下载成功', {
+    downloadHandle: debounce(function () {
+      if(this.residueCount > 0) {
+        if(this.showEmailError) {
+          return
+        }
+        const params = {
+          type: 3,
+          sid: this.options.sid,
+          s_email: this.s_email
+        }
+        this.loading = true
+        // 保存pdf的条件
+        savePdfCondition(params).then(res => {
+          const {error_code: code, data } = res
+          if(code === 0 && data) {
+              // 发送邮箱
+              // 此处id是接口返回的id
+              const params = {
+                sid: data
+              }
+              sendPdfEmail(params).then(response => {
+                if(response.error_code === 0 && response.data) {
+                  this.showConfirmDialog()
+                }
+              }).finally(() => {
+                this.loading = false
+              })
+          }
+        }).catch(() => {
+          this.loading = false
+        })
+      } else {
+        // 余额不足
+        this.goRecharge()
+      }
+    }, 300),
+    showConfirmDialog () {
+      const _this = this
+      this.$confirm('报告将于10分钟内发送至您的邮箱内,您也可前往“资产-报告下载记录”查看详情。', '报告下载成功', {
         confirmButtonText: '返回',
         cancelButtonText: '查看下载记录',
         center: true,
@@ -107,20 +164,28 @@ export default {
         customClass: 'download-message-tip btn-reverse',
       }).then(() => {
       }).catch(() => {
+        _this.$router.push('/report/download_record')
       })
-    }, 300),
+    },
     // 查看更多
     viewMore () {
       this.options.visible = false
     },
     // 去充值
     goRecharge () {
-
+      this.$router.push('/order/download-pack/market')
     },
     // 联系客服
     openCustomer() {
       this.options.visible = false
       this.contactCustomer(this)
+    },
+    checkEmail () {
+      if (!emailRegExp.test(this.s_email)) {
+        this.showEmailError = true
+      } else {
+        this.showEmailError = false
+      }
     }
   }
 }
@@ -177,6 +242,44 @@ export default {
       background: linear-gradient(180deg, #F7F9FA 100%, #F7F9FA 0%);
       border-radius: 8px;
       border: 1px solid rgba(0,0,0, 0.05);
+    }
+    .email-box{
+      display: flex;
+      align-items: center;
+      font-size:14px;
+      .email-label{
+        display: inline-block;
+        width:94px;
+        color: #5F5E64;
+      }
+      .star {
+        color: #ff3a20;
+        margin-right:3px;
+      }
+      .error-tip {
+        color: #ff3a20;
+        display: flex;
+        align-items: center;
+        .el-icon-error{
+          font-size:22px;
+          margin:0 8px;
+        }
+      }
+      ::v-deep {
+        .el-input {
+          width: 438px;
+        }
+        .el-input__inner{
+          width: 438px;
+          height: 36px;
+          line-height: 36px;
+          font-size:14px;
+          line-hieght: 22px;
+
+        }
+      }
+
+
     }
     .highlight {
       color: $color_main;

+ 2 - 2
apps/bigmember_pc/src/views/analysisReport/index.vue

@@ -95,8 +95,8 @@ export default {
       // 报告下载弹窗
       downloadDialogConfig: {
         visible: false,
-        power: false,
-        totalList: []
+        totalList: [],
+        sid: ''
       }
     }
   },