|
@@ -13,20 +13,16 @@
|
|
|
:showCredit="showCredit"
|
|
|
:btnInfo="btnInfo"
|
|
|
@clickItem="onClickReportItem"
|
|
|
- @btn="onBtnClick"
|
|
|
/>
|
|
|
<template #reference>
|
|
|
<TabActionItem
|
|
|
showText
|
|
|
:direction="direction"
|
|
|
class="action-monitor"
|
|
|
- @click.native.stop="changePopoverState"
|
|
|
+ @click="changePopoverState"
|
|
|
>
|
|
|
- <!-- <van-icon
|
|
|
- slot="icon"
|
|
|
- :name="showPopover ? 'custom-report-active' : 'custom-report'"
|
|
|
- ></van-icon> -->
|
|
|
<img
|
|
|
+ v-if="btnInfo.isNew"
|
|
|
slot="tip"
|
|
|
class="action-new-tip"
|
|
|
src="@/assets/image/icon/new-img.png"
|
|
@@ -87,6 +83,7 @@ import TabActionItem from '@/views/article/ui/TabActionItem.vue'
|
|
|
import ReportDownloadCard from '@/views/article/ui/ReportDownloadCard.vue'
|
|
|
import { Popover, Dialog, Icon } from 'vant'
|
|
|
import { AppIcon } from '@/ui'
|
|
|
+import { ajaxReportEquityDeduct } from '@/api/modules/'
|
|
|
|
|
|
export default {
|
|
|
name: 'ActionReport',
|
|
@@ -153,69 +150,43 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
|
+ showLoading() {
|
|
|
+ return this.$toast.loading({
|
|
|
+ duration: 0,
|
|
|
+ forbidClick: true,
|
|
|
+ message: 'loading...'
|
|
|
+ })
|
|
|
+ },
|
|
|
onReportRedirect(type) {
|
|
|
- const {
|
|
|
- ent_report_ids = {},
|
|
|
- buyer_report_id = '',
|
|
|
- project_report_id = ''
|
|
|
- } = this.btnInfo
|
|
|
// 判断是否购买过,已购买跳转报告页,未购买跳转购买页
|
|
|
- if (type === 'project') {
|
|
|
- const buyerName = this.buyers[0]?.name
|
|
|
- if (project_report_id) {
|
|
|
- this.$router.push({
|
|
|
- path: '/report/analysis/detail',
|
|
|
- query: {
|
|
|
- id: project_report_id
|
|
|
- }
|
|
|
- })
|
|
|
- } else {
|
|
|
- // 项目分析报告 name: 项目名称(下单页展示用),buyer:采购单位名称(下单接口参数用)
|
|
|
- this.$router.push({
|
|
|
- path: '/order/create/analysis-report/project',
|
|
|
- query: {
|
|
|
- name: this.projectName,
|
|
|
- id: this.id,
|
|
|
- buyer: buyerName
|
|
|
- }
|
|
|
- })
|
|
|
- }
|
|
|
- } else if (type === 'unit') {
|
|
|
- const buyerName = this.buyers[0]?.name
|
|
|
- if (buyer_report_id) {
|
|
|
- this.$router.push({
|
|
|
- path: '/report/analysis/detail',
|
|
|
- query: {
|
|
|
- id: buyer_report_id
|
|
|
- }
|
|
|
- })
|
|
|
- } else {
|
|
|
- this.$router.push({
|
|
|
- path: '/order/create/analysis-report/unit',
|
|
|
- query: {
|
|
|
- name: buyerName,
|
|
|
- id: this.id
|
|
|
- }
|
|
|
- })
|
|
|
- }
|
|
|
- } else if (type === 'competitor') {
|
|
|
- const entName = this.winners[0]?.name
|
|
|
- if (Object.keys(ent_report_ids).length > 0 && ent_report_ids[entName]) {
|
|
|
- this.$router.push({
|
|
|
- path: '/report/analysis/detail',
|
|
|
- query: {
|
|
|
- id: ent_report_ids[entName]
|
|
|
- }
|
|
|
- })
|
|
|
- } else {
|
|
|
- this.$router.push({
|
|
|
- path: '/order/create/analysis-report/competitor',
|
|
|
- query: {
|
|
|
- name: entName,
|
|
|
- id: this.id
|
|
|
- }
|
|
|
- })
|
|
|
- }
|
|
|
+ const reportId = this.getReportId(type)
|
|
|
+ if (reportId) {
|
|
|
+ this.$router.push({
|
|
|
+ path: '/report/analysis/detail',
|
|
|
+ query: {
|
|
|
+ id: reportId
|
|
|
+ }
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ const url = this.getReportOrderUrl(type)
|
|
|
+ const params = this.getDeductParams(type)
|
|
|
+ // console.log(url, params)
|
|
|
+ this.deductPackage(params, (code, data) => {
|
|
|
+ if (code === 0 && data) {
|
|
|
+ // 抵扣成功
|
|
|
+ this.$router.push({
|
|
|
+ path: '/report/analysis/detail',
|
|
|
+ query: {
|
|
|
+ id: data
|
|
|
+ }
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ // 抵扣失败 || 没开通权益,进购买页
|
|
|
+ this.$router.push({
|
|
|
+ path: url
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
}
|
|
|
},
|
|
|
onClickReportItem(type) {
|
|
@@ -225,9 +196,9 @@ export default {
|
|
|
// 投标企业信用报告
|
|
|
location.href = `/jy_mobile/common/pdfview?buyer=${buyerName}`
|
|
|
break
|
|
|
- case 'unit':
|
|
|
+ case 'buyer':
|
|
|
// 采购单位分析
|
|
|
- this.onReportRedirect('unit')
|
|
|
+ this.onReportRedirect('buyer')
|
|
|
break
|
|
|
case 'competitor':
|
|
|
// 供应商分析
|
|
@@ -255,17 +226,36 @@ export default {
|
|
|
}
|
|
|
})
|
|
|
} else {
|
|
|
- this.$router.push({
|
|
|
- path: '/order/create/analysis-report/competitor',
|
|
|
- query: {
|
|
|
- name: entName,
|
|
|
- id: this.id
|
|
|
+ this.deductPackage(
|
|
|
+ {
|
|
|
+ type: 'competitor',
|
|
|
+ entName,
|
|
|
+ bId: this.id
|
|
|
+ },
|
|
|
+ (code, data) => {
|
|
|
+ if (code === 0 && data) {
|
|
|
+ // 抵扣成功
|
|
|
+ this.$router.push({
|
|
|
+ path: '/report/analysis/detail',
|
|
|
+ query: {
|
|
|
+ id: data
|
|
|
+ }
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ // 抵扣失败 || 没开通权益,进购买页
|
|
|
+ this.$router.push({
|
|
|
+ path: '/order/create/analysis-report/competitor',
|
|
|
+ query: {
|
|
|
+ name: entName,
|
|
|
+ id: this.id
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
}
|
|
|
- })
|
|
|
+ )
|
|
|
}
|
|
|
this.showDialog = false
|
|
|
},
|
|
|
- onBtnClick() {},
|
|
|
async changePopoverState() {
|
|
|
this.showPopover = true
|
|
|
},
|
|
@@ -278,6 +268,98 @@ export default {
|
|
|
await this.changePopoverState()
|
|
|
}
|
|
|
}
|
|
|
+ },
|
|
|
+ getReportMold(type) {
|
|
|
+ let mold = 0
|
|
|
+ switch (type) {
|
|
|
+ case 'project':
|
|
|
+ mold = 1
|
|
|
+ break
|
|
|
+ case 'competitor':
|
|
|
+ mold = 2
|
|
|
+ break
|
|
|
+ case 'buyer':
|
|
|
+ mold = 3
|
|
|
+ break
|
|
|
+ }
|
|
|
+ return mold
|
|
|
+ },
|
|
|
+ getReportId(type) {
|
|
|
+ let reportId = ''
|
|
|
+ const {
|
|
|
+ ent_report_ids = {},
|
|
|
+ buyer_report_id = '',
|
|
|
+ project_report_id = ''
|
|
|
+ } = this.btnInfo
|
|
|
+ if (type === 'competitor') {
|
|
|
+ const entName = this.winners[0]?.name
|
|
|
+ reportId = ent_report_ids[entName]
|
|
|
+ } else if (type === 'buyer') {
|
|
|
+ reportId = buyer_report_id
|
|
|
+ } else if (type === 'project') {
|
|
|
+ reportId = project_report_id
|
|
|
+ }
|
|
|
+ return reportId
|
|
|
+ },
|
|
|
+ getReportOrderUrl(type) {
|
|
|
+ let url = ''
|
|
|
+ const winnerName = this.winners[0]?.name
|
|
|
+ const buyerName = this.buyers[0]?.name
|
|
|
+ const projectName = this.projectName
|
|
|
+ const id = this.id
|
|
|
+ if (type === 'competitor') {
|
|
|
+ url = `/order/create/analysis-report/competitor?name=${winnerName}&id=${id}`
|
|
|
+ } else if (type === 'buyer') {
|
|
|
+ url = `/order/create/analysis-report/unit?name=${buyerName}&id=${id}`
|
|
|
+ } else if (type === 'project') {
|
|
|
+ url = `/order/create/analysis-report/project?name=${projectName}&id=${id}&buyer=${buyerName}`
|
|
|
+ }
|
|
|
+ return url
|
|
|
+ },
|
|
|
+ getDeductParams(type) {
|
|
|
+ let params = {}
|
|
|
+ if (type === 'competitor') {
|
|
|
+ params = {
|
|
|
+ type,
|
|
|
+ entName: this.winners[0]?.name,
|
|
|
+ bId: this.id
|
|
|
+ }
|
|
|
+ } else if (type === 'buyer') {
|
|
|
+ params = {
|
|
|
+ type,
|
|
|
+ buyerName: this.buyers[0]?.name,
|
|
|
+ bId: this.id
|
|
|
+ }
|
|
|
+ } else if (type === 'project') {
|
|
|
+ params = {
|
|
|
+ type,
|
|
|
+ projectName: this.projectName,
|
|
|
+ bId: this.id,
|
|
|
+ buyerName: this.buyers[0]?.name
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return params
|
|
|
+ },
|
|
|
+ async deductPackage(
|
|
|
+ { entName, buyerName, projectName, bId, type },
|
|
|
+ callback
|
|
|
+ ) {
|
|
|
+ const params = {
|
|
|
+ ent_name: entName,
|
|
|
+ buyer: buyerName,
|
|
|
+ report_mold: this.getReportMold(type),
|
|
|
+ project_name: projectName,
|
|
|
+ bidding_id: bId
|
|
|
+ }
|
|
|
+ const loading = this.showLoading()
|
|
|
+ try {
|
|
|
+ const { error_code: code, data } = await ajaxReportEquityDeduct(params)
|
|
|
+ loading?.clear()
|
|
|
+ callback && callback(code, data)
|
|
|
+ } catch (error) {
|
|
|
+ loading?.clear()
|
|
|
+ callback && callback()
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|