ReportDownloadDialog.vue 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363
  1. <template>
  2. <el-dialog
  3. title="市场分析定制报告下载"
  4. :visible.sync="options.visible"
  5. :close-on-click-modal="false"
  6. lock-scroll
  7. center
  8. top="15%"
  9. custom-class="market-report-download-dialog"
  10. width="1000px"
  11. style="overflow: hidden"
  12. >
  13. <div class="content" v-loading="loading">
  14. <section class="report-effect-box">
  15. <div class="left">
  16. <p class="box-label">报告作用:</p>
  17. <p class="box-desc">从市场规模、采购单位、中标单位等多个维度深度剖析行业现状与领军企业运营状况,帮助您深度挖掘市场、把握市场先机。</p>
  18. </div>
  19. <el-button type="primary" @click="viewExample">查看报告样例</el-button>
  20. </section>
  21. <section class="market-general-box" v-if="hasPower">
  22. <span class="box-label">市场概况:</span>
  23. <span v-for="item in totalList">{{item.label}}:<strong>{{ item.count + item.unit }}</strong></span>
  24. <span class="highlight view-more" @click="viewMore">查看更多</span>
  25. </section>
  26. <section class="email-box">
  27. <span class="email-label"><i class="star">*</i>接收邮箱:</span>
  28. <el-input v-model="s_email" placeholder="必填,报告将发送至邮箱" @input="showEmailError = false" @change="checkEmail"></el-input>
  29. <span class="error-tip" v-if="showEmailError">
  30. <i class="el-icon-error"></i>
  31. <span v-if="s_email">邮箱格式错误</span>
  32. <span v-else>请输入邮箱</span>
  33. </span>
  34. <span class="error-tip" v-if="s_email && !showEmailError">
  35. <i class="el-icon-success"></i>
  36. </span>
  37. </section>
  38. <section class="download-notice-box">
  39. <p class="box-label">下载须知:</p>
  40. <div class="box-desc">
  41. <p>1.“项目明细”按照成交时间排序,报告最多展示前100条,如需导出全部,请<em class="highlight t-ud" @click="openCustomer">联系客服</em>;</p>
  42. <p>2. 该报告数据来自于公开数据整理,不代表任何权威观点,仅供参考;</p>
  43. <p>3. 请在有效期内使用下载权限,逾期清零;</p>
  44. <p>4. 如有任何疑问,您可拨打<em class="highlight" style="cursor:default;">400-108-667</em>联系客服或点击<em class="highlight t-ud" @click="openCustomer">联系在线客服</em>。</p>
  45. </div>
  46. </section>
  47. </div>
  48. <div slot="footer" :class="{ 'mask': loading }">
  49. <div class="footer-con">
  50. <span class="residue">市场分析定制报告下载余额:{{ residueCount }}份</span>
  51. <span class="go-recharge" @click="goRecharge">去充值&gt;</span>
  52. <span class="deduct">本次扣除:<em>1份</em></span>
  53. <span class="zero-tip" v-if="residueCount === 0">余额不足,请先充值</span>
  54. </div>
  55. <el-button class="download-btn" :disabled="loading" type="primary" @click="downloadHandle" >立即下载</el-button>
  56. </div>
  57. </el-dialog>
  58. </template>
  59. <script>
  60. import { mapGetters } from 'vuex'
  61. import { getPDFPackBalance, sendPdfEmail, getPdfEmail, savePdfCondition, ajaxExportPdf } from '@/api/modules/'
  62. import { debounce } from '@/utils/'
  63. import { emailRegExp } from '@/utils/constant'
  64. export default {
  65. props: {
  66. options: {
  67. type: Object,
  68. default: () => {
  69. return {
  70. visible: false,
  71. totalList: [],
  72. sid: ''
  73. }
  74. }
  75. }
  76. },
  77. data () {
  78. return {
  79. // 下载余额
  80. residueCount: 0,
  81. s_email: '',
  82. showEmailError: false,
  83. loading: false
  84. }
  85. },
  86. computed: {
  87. ...mapGetters('user', ['power']),
  88. totalList () {
  89. const arr = this.options.totalList.filter(item => {
  90. return item.label !== '项目平均金额'
  91. })
  92. return arr
  93. },
  94. hasPower() {
  95. return this.power && this.power.length > 0 && this.power.indexOf(26) !== -1
  96. }
  97. },
  98. created() {
  99. this.getEmail()
  100. this.getResidueCount()
  101. },
  102. methods: {
  103. async getEmail () {
  104. const {error_code: code, data } = await getPdfEmail()
  105. if(data && code === 0) {
  106. this.s_email = data || ''
  107. }
  108. },
  109. // 获取下载余额
  110. async getResidueCount () {
  111. const {error_code: code, data } = await getPDFPackBalance()
  112. if(code === 0 && data) {
  113. this.residueCount = data.market?.total || 0
  114. }
  115. },
  116. // 查看报告样例
  117. viewExample () {
  118. window.open('/common-module/pdf/【剑鱼标讯】市场分析定制报告样例.pdf', '_blank')
  119. },
  120. // 立即下载
  121. downloadHandle: debounce(function () {
  122. if(this.residueCount > 0) {
  123. this.checkEmail()
  124. if(this.showEmailError) {
  125. return
  126. }
  127. this.ajaxPdf()
  128. } else {
  129. // 余额不足
  130. this.goRecharge()
  131. }
  132. }, 300),
  133. ajaxPdf () {
  134. const params = {
  135. type: 3,
  136. sid: this.options.sid,
  137. s_email: this.s_email
  138. }
  139. this.loading = true
  140. // 保存pdf的条件
  141. savePdfCondition(params).then(res => {
  142. const {error_code: code, data } = res
  143. if(code === 0 && data) {
  144. // 发送邮箱
  145. // 此处id是接口返回的id
  146. const params = {
  147. filterId: data
  148. }
  149. ajaxExportPdf(params).then(response => {
  150. if(response.error_code === 0 && response.data) {
  151. this.options.visible = false
  152. this.showConfirmDialog()
  153. }
  154. }).finally(() => {
  155. this.loading = false
  156. })
  157. }
  158. }).catch(() => {
  159. this.loading = false
  160. })
  161. },
  162. showConfirmDialog () {
  163. this.$emit('successConfirm')
  164. },
  165. // 查看更多
  166. viewMore () {
  167. const id = this.options.sid
  168. if(this.options.tab === 'history' && id) {
  169. this.$router.push(`/desktop/report_analysis?id=${id}`)
  170. }
  171. this.options.visible = false
  172. },
  173. // 去充值
  174. goRecharge () {
  175. window.open('/swordfish/page_big_pc/order/download-pack/market', '_self')
  176. },
  177. // 联系客服
  178. openCustomer() {
  179. this.options.visible = false
  180. this.contactCustomer(this)
  181. },
  182. checkEmail () {
  183. if (!emailRegExp.test(this.s_email)) {
  184. this.showEmailError = true
  185. } else {
  186. this.showEmailError = false
  187. }
  188. }
  189. }
  190. }
  191. </script>
  192. <style lang="scss" scoped>
  193. .market-report-download-dialog{
  194. section {
  195. margin-top:20px;
  196. }
  197. .box-label{
  198. font-size:16px;
  199. line-height:24px;
  200. color: #1d1d1d;
  201. }
  202. .box-desc{
  203. margin-top:8px;
  204. font-size:14px;
  205. color: #686868;
  206. line-height:22px;
  207. }
  208. .report-effect-box{
  209. display: flex;
  210. justify-content: space-between;
  211. align-items: center;
  212. .left{
  213. width:720px;
  214. }
  215. .el-button{
  216. padding: 7px 22px;
  217. font-size:14px;
  218. line-height: 22px;
  219. }
  220. }
  221. .market-general-box{
  222. span {
  223. margin-right:20px;
  224. }
  225. .box-label{
  226. margin-right:14px;
  227. }
  228. strong {
  229. color: #1d1d1d;
  230. font-size:18px;
  231. line-height: 28px;
  232. }
  233. .view-more{
  234. font-size:16px;
  235. line-height:24px;
  236. }
  237. }
  238. .download-notice-box{
  239. padding:20px;
  240. background: linear-gradient(180deg, #F7F9FA 0%, #fff 100%);
  241. border-radius: 8px;
  242. border: 1px solid rgba(0,0,0, 0.05);
  243. }
  244. .email-box{
  245. display: flex;
  246. align-items: center;
  247. font-size:14px;
  248. .email-label{
  249. display: inline-block;
  250. width:94px;
  251. color: #5F5E64;
  252. }
  253. .star {
  254. color: #ff3a20;
  255. margin-right:3px;
  256. }
  257. .error-tip {
  258. color: #ff3a20;
  259. display: flex;
  260. align-items: center;
  261. .el-icon-error{
  262. font-size:22px;
  263. margin:0 8px;
  264. }
  265. .el-icon-success{
  266. font-size:22px;
  267. margin-left: 8px;
  268. color: #2CB7CA;
  269. }
  270. }
  271. ::v-deep {
  272. .el-input {
  273. width: 438px;
  274. }
  275. .el-input__inner{
  276. width: 438px;
  277. height: 36px;
  278. line-height: 36px;
  279. font-size:14px;
  280. line-hieght: 22px;
  281. }
  282. }
  283. }
  284. .highlight {
  285. color: $color_main;
  286. cursor: pointer;
  287. }
  288. .t-ud {
  289. text-decoration: underline;
  290. }
  291. .el-dialog__footer{
  292. .mask {
  293. opacity: .6;
  294. }
  295. .download-btn{
  296. padding: 11px 58px;
  297. font-size:16px;
  298. line-height: 24px;
  299. }
  300. .footer-con{
  301. font-size:14px;
  302. line-height:18px;
  303. span {
  304. margin-right:20px;
  305. }
  306. .residue{
  307. color: #686868;
  308. }
  309. .go-recharge{
  310. display: inline-block;
  311. padding: 4px 12px;
  312. border: 1px solid $color_main;
  313. color: $color_main;
  314. border-radius: 20px;
  315. cursor: pointer;
  316. }
  317. .deduct{
  318. color: #1d1d1d;
  319. em{
  320. color: $color_main;
  321. }
  322. }
  323. .zero-tip {
  324. padding: 4px 12px;
  325. border-radius: 20px;
  326. color: #ff3a20;
  327. background-color: #ffecec;
  328. }
  329. }
  330. }
  331. }
  332. ::v-deep {
  333. .el-dialog{
  334. border-radius: 8px;
  335. }
  336. .el-dialog__header{
  337. padding: 32px 32px 0 32px;
  338. }
  339. .el-dialog__body {
  340. overflow-y: auto;
  341. padding: 0 32px 20px 32px;
  342. }
  343. .el-dialog__footer{
  344. padding: 11px 32px;
  345. > div{
  346. display: flex;
  347. justify-content: flex-end;
  348. align-items: center;
  349. }
  350. box-shadow: 0 -4px 8px rgba(0,0,0, 0.05);
  351. }
  352. .el-button {
  353. border-radius: 6px !important;
  354. }
  355. }
  356. </style>