ReportPublishPop.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. <script setup>
  2. import { showToast,showDialog } from 'vant';
  3. import apiReport from '@/api/report'
  4. import {useCachedViewsStore} from '@/store/modules/cachedViews'
  5. import {usePublicSettingStore} from '@/store/modules/publicSetting'
  6. const cachedViewsStore=useCachedViewsStore()
  7. const publicSettingStore = usePublicSettingStore()
  8. const props=defineProps({
  9. reportData:{
  10. default:''
  11. },
  12. waterMarkStr:{
  13. type:String,
  14. default:'',
  15. }
  16. })
  17. const emits=defineEmits(['close'])
  18. // 确认发布报告
  19. // type 1 仅发布 2发布且推送
  20. function handleConfirmPublish(type){
  21. if(type==2&&props.reportData.MsgIsSend==1) return
  22. apiReport.reportPublish({
  23. ReportIds:props.reportData.Id.toString(),
  24. ReportUrl:generatePdfLinks(props.reportData.ReportCode)
  25. }).then(res=>{
  26. if(res.Ret!=200) return;
  27. cachedViewsStore.removeCaches('ReportList')
  28. if(type===2){
  29. handleReportMessageSend(true)
  30. }else{
  31. if(res.Data){
  32. showDialog({ title: '发布提示', message: res.Data }).then(()=>{})
  33. }else{
  34. showToast('发布成功')
  35. }
  36. emits('close','refresh')
  37. }
  38. })
  39. }
  40. function generatePdfLinks(Code){
  41. return `${publicSettingStore.publicSetting.ReportViewUrl}/reportshare_pdf?code=${Code}&flag=${props.waterMarkStr}`
  42. }
  43. // 推送消息
  44. function handleReportMessageSend(publish){
  45. apiReport.reportMessageSend({
  46. ReportId:Number(props.reportData.Id)
  47. }).then(res=>{
  48. if(res.Ret===200){
  49. if(publish){
  50. showToast('发布且推送成功')
  51. }else{
  52. showToast('推送成功')
  53. }
  54. emits('close','refresh')
  55. }
  56. })
  57. }
  58. </script>
  59. <template>
  60. <div class="publish-report-pop-box">
  61. <div class="title">发布提示</div>
  62. <p class="tips">{{reportData.PrePublishTime?'该报告已设置定时发布,是否立即发布报告并推送模板消息?':'是否立即发布报告,并推送模板消息?'}}</p>
  63. <div class="btns">
  64. <div :class="['btn blue',reportData.MsgIsSend===1?'disabled':'']" @click="handleConfirmPublish(2)">发布&推送</div>
  65. <div class="btn" @click="handleConfirmPublish(1)">仅发布</div>
  66. <div class="btn" @click="emits('close')" style="margin-bottom: 0;">取消</div>
  67. </div>
  68. </div>
  69. </template>
  70. <style lang="scss" scoped>
  71. .publish-report-pop-box{
  72. padding: 48px;
  73. .title{
  74. font-size: 32px;
  75. text-align: center;
  76. font-weight: 600;
  77. margin-bottom: 32px;
  78. }
  79. .tips{
  80. color: $font-grey;
  81. margin-bottom: 48px;
  82. font-size: 32px;
  83. line-height: 48px;
  84. }
  85. .btns{
  86. .btn{
  87. display: block;
  88. padding: 24px 0;
  89. line-height: 48px;
  90. border-radius: 12px;
  91. text-align: center;
  92. font-size: 32px;
  93. font-weight: 600;
  94. margin-bottom: 24px;
  95. background-color: #F2F3FF;
  96. color: $theme-color;
  97. }
  98. .blue{
  99. background-color: $theme-color;
  100. color: #fff;
  101. }
  102. .disabled{
  103. background-color: #a8b0fc;
  104. }
  105. }
  106. }
  107. @media screen and (min-width:$media-width){
  108. .publish-report-pop-box{
  109. padding: 24px;
  110. .title{
  111. font-size: 22px;
  112. margin-bottom: 16px;
  113. }
  114. .tips{
  115. margin-bottom: 24px;
  116. font-size: 22px;
  117. line-height: 48px;
  118. }
  119. .btns{
  120. .btn{
  121. padding: 12px 0;
  122. border-radius: 12px;
  123. line-height: 48px;
  124. font-size: 20px;
  125. margin-bottom: 12px;
  126. }
  127. }
  128. }
  129. }
  130. </style>