generateList.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345
  1. <template>
  2. <view class="gbox">
  3. <u-list @scrolltolower="scrolltolower" height="100%">
  4. <u-list-item v-for="(item, index) in list" :key="index">
  5. <view class="gbox-item">
  6. <view class="gbox-item-top adf">
  7. <view class="gbox-item-top-type">{{typeCfg[item.type]||'个人版'}}</view>
  8. <view class="gbox-item-top-title">{{item.reportName||''}}</view>
  9. </view>
  10. <view class="gbox-item-p adf">
  11. <view class="gbox-item-p-left">团队名称:</view>
  12. <view class="gbox-item-p-right">{{item.teamName||''}}</view>
  13. </view>
  14. <view class="gbox-item-p adf">
  15. <view class="gbox-item-p-left">报告状态:</view>
  16. <view class="gbox-item-p-right" :style="{'color':stateColor[item.state]}">{{stateDict[item.state]}}</view>
  17. </view>
  18. <view class="gbox-item-p adf">
  19. <view class="gbox-item-p-left">创建时间:</view>
  20. <view class="gbox-item-p-right">{{item.createDate||''}}</view>
  21. </view>
  22. <image class="gbox-item-ask" :src="imgBase+'report_ask.png'" @click="askReport(item)" v-if="item.state==1&&item.fileUrl"></image>
  23. <view class="gbox-item-bottom adfacjb">
  24. <view class="gbox-item-bottom-left adfac"></view>
  25. <div class="gbox-item-bottom-rightbox adfac" v-if="item.type==1">
  26. <view class="gbox-item-bottom-right" @click="forwardReport(item)" v-if="item.state==1&&item.fileUrl">发送邮件</view>
  27. <view class="gbox-item-bottom-right" style="margin-left: 27rpx;" @click="reviewPdf(item)" v-if="item.state==1">预览报告</view>
  28. <view class="gbox-item-bottom-right" style="margin-left: 27rpx;" @click="reviewReport(item)" v-if="item.state==1&&item.fileUrl">查看报告</view>
  29. <view class="gbox-item-bottom-right" style="margin-left: 27rpx;" @click="reSendReport(item)" v-if="item.state==-1">重新生成</view>
  30. </div>
  31. <div class="gbox-item-bottom-rightbox adfac" v-else-if="item.type==2">
  32. <view class="gbox-item-bottom-right" @click="forwardReport(item)" v-if="item.state==1&&item.fileUrl">发送邮件</view>
  33. <view class="gbox-item-bottom-right" style="margin-left: 27rpx;" @click="reviewPdf(item)" v-if="item.state==1">预览报告</view>
  34. <view class="gbox-item-bottom-right" style="margin-left: 27rpx;" @click="reviewReport(item)" v-if="item.state==1&&item.fileUrl">查看报告</view>
  35. <view class="gbox-item-bottom-right" style="margin-left: 27rpx;" @click="sendReport(item)" v-if="item.state!=-1">发送报告</view>
  36. <view class="gbox-item-bottom-right" style="margin-left: 27rpx;" @click="reSendReport(item)" v-if="item.state==-1">重新生成</view>
  37. </div>
  38. </view>
  39. </view>
  40. </u-list-item>
  41. </u-list>
  42. <cus-select-team-user
  43. ref="selectTeamUser"
  44. :show="teamUserShow"
  45. :list="teamUserList"
  46. @close="handleClose"
  47. @changeAll="changeAll"
  48. @handleSelectUser="handleSelectUser"
  49. @handleConfirm="sendConfirm"
  50. ></cus-select-team-user>
  51. </view>
  52. </template>
  53. <script>
  54. import { getPlatformInfo } from '@/utils/platform.js';
  55. import CusSelectTeamUser from '@/components/CusSelectTeamUser/index.vue'
  56. export default {
  57. props:{
  58. list:{
  59. typeof:Array,
  60. default:[]
  61. }
  62. },
  63. components:{ CusSelectTeamUser },
  64. data(){
  65. return {
  66. typeCfg:{
  67. 1:'个人版',
  68. 2:'团队版',
  69. 0:'团队PRO版'
  70. },
  71. stateDict:{
  72. '0':'生成中',
  73. '1':'生成成功',
  74. '-1':'生成失败'
  75. },
  76. stateColor:{
  77. '0':'#FFD750',
  78. '1':'#33A7A7',
  79. '-1':'#F4657A'
  80. },
  81. teamUserShow:false,
  82. teamUserList:[],
  83. categoryData:[],
  84. sendType:1,
  85. selectItem:null,
  86. }
  87. },
  88. methods:{
  89. scrolltolower(){
  90. this.$emit('scrolltolower')
  91. },
  92. getUserCategoryData(){
  93. return new Promise((resolve,reject)=>{
  94. this.$api.get('/getListByType/UserCategory').then(({data:res})=>{
  95. if(res.code!==0) return this.$showToast(res.msg)
  96. this.categoryData = res.data.map(d=>({name:d.dictLabel,id:d.dictValue}))
  97. resolve()
  98. })
  99. })
  100. },
  101. async forwardReport(item){
  102. //发送给账号自己的邮箱
  103. if(!uni.getStorageSync('userInfo')||!JSON.parse(uni.getStorageSync('userInfo')).email) return this.$showModal('发送邮件前请先在我的-设置-用户信息中绑定邮箱')
  104. uni.showModal({
  105. title:'温馨提示',
  106. content:`是否确认将“${item.reportName||''}”下的PDF报告文件发送到账号绑定邮箱中?`,
  107. confirmText:'确认',
  108. success: (res) => {
  109. if(res.confirm){
  110. this.$api.get(`/core/report/sendToEmail/${item.reportId}`).then(({data:res})=>{
  111. if(res.code!==0) return this.$showToast(res.msg)
  112. this.$showModal('邮件发送成功,可在绑定的邮箱中查看详细内容。')
  113. })
  114. }
  115. }
  116. })
  117. // this.sendType = 1;
  118. // this.$refs.selectTeamUser.title = '发送邮件'
  119. // await this.getUserCategoryData()
  120. // this.$api.get(`/core/member/listByQueTeamId/${item.teamQueId}`).then(({data:res})=>{
  121. // if(res.code!==0) return this.$showToast(res.msg)
  122. // this.teamUserList = res.data;
  123. // this.teamUserList.forEach((l,i)=>{
  124. // l.categoryName = this.categoryData.find(c=>c.id==l.category)?.name;
  125. // this.$set(this.teamUserList[i],'select',false);
  126. // })
  127. // this.teamUserShow = true;
  128. // })
  129. },
  130. handleSelectUser(index){
  131. this.$set(this.teamUserList[index],'select',!this.teamUserList[index].select);
  132. this.dealNumAndAll()
  133. },
  134. handleClose(){
  135. this.teamUserShow = false;
  136. this.initSelectUserComponent();
  137. },
  138. changeAll(selected){
  139. this.teamUserList.forEach((l,i)=>{
  140. this.$set(this.teamUserList[i],'select',selected);
  141. })
  142. this.$refs.selectTeamUser.selectNums = this.teamUserList.filter(l=>l.select).length;
  143. },
  144. dealNumAndAll(){
  145. const selectnum = this.teamUserList.filter(l=>l.select).length;
  146. this.$refs.selectTeamUser.selectNums = selectnum;
  147. this.$refs.selectTeamUser.selectAll = selectnum === this.teamUserList.length;
  148. },
  149. sendConfirm(){
  150. if(this.teamUserList.filter(t=>t.select).length===0) return this.$showToast('请选择要发送的用户')
  151. if(this.sendType===1&&(!uni.getStorageSync('userInfo')||!JSON.parse(uni.getStorageSync('userInfo')).email)) return this.$showModal('发送前请先在我的-设置-用户信息中绑定邮箱')
  152. if(this.sendType===1){
  153. this.handleClose();
  154. } else if(this.sendType===2){
  155. const item = JSON.parse(JSON.stringify(this.selectItem));
  156. uni.showModal({
  157. title:'发送报告',
  158. content:`是否确认将“${item.reportName||''}”发送给团队成员`,
  159. confirmText:'确认',
  160. success: (res) => {
  161. if(res.confirm){
  162. this.$api.post(`/core/report/sendReport`,{
  163. reportId:item.reportId,
  164. memberList:this.teamUserList.filter(t=>t.select).map(t=>({id:t.id,mobile:t.mobile,category:t.category}))
  165. }).then(({data:res})=>{
  166. if(res.code!==0) return this.$showToast(res.msg)
  167. this.handleClose();
  168. uni.navigateTo({
  169. url:'/pagesHome/sendResult?result='+res.code
  170. })
  171. })
  172. }
  173. }
  174. })
  175. }
  176. },
  177. initSelectUserComponent(){
  178. this.$refs.selectTeamUser.selectNums = 0;
  179. this.$refs.selectTeamUser.selectAll = false;
  180. },
  181. reviewPdf(item){
  182. let url = `/pagesHome/pdf?reportId=${item.reportId}`;
  183. if(item.type==2) url = `/pagesHome/pdfZyb?reportId=${item.reportId}`
  184. uni.navigateTo({ url })
  185. },
  186. reviewReport(item){
  187. const { isPC, isMobile, platform } = getPlatformInfo();
  188. if (isPC) {
  189. this.$showModal('请在手机端该微信小程序中查看报告')
  190. } else if (isMobile||platform==='devtools') {
  191. if(!item.fileUrl) return this.$showToast('报告pdf为空,请稍后再试。')
  192. uni.navigateTo({
  193. url:'/pages/webView?src='+item.fileUrl
  194. })
  195. }
  196. },
  197. askReport(item){
  198. uni.navigateTo({
  199. url:`/pages/reportAsk?pdfUrl=${item.fileUrl}&fileName=${this.typeCfg[item.type]||'个人版'}-${item.reportName}`
  200. })
  201. },
  202. async sendReport(item){
  203. if(!item.fileUrl) return this.$showModal('该报告尚未生成PDF文件,请等待生成后发送。')
  204. this.sendType = 2;
  205. this.$refs.selectTeamUser.title = '发送报告'
  206. this.selectItem = item;
  207. await this.getUserCategoryData()
  208. this.$api.get(`/core/member/listByQueTeamId/${item.teamQueId}`).then(({data:res})=>{
  209. if(res.code!==0) return this.$showToast(res.msg)
  210. this.teamUserList = res.data;
  211. this.teamUserList.forEach((l,i)=>{
  212. l.categoryName = this.categoryData.find(c=>c.id==l.category)?.name;
  213. this.$set(this.teamUserList[i],'select',false);
  214. })
  215. this.teamUserShow = true;
  216. })
  217. },
  218. reSendReport(item){
  219. this.$api.get(`/core/report/regenerateReport/${item.reportId}`).then(({data:res})=>{
  220. if(res.code!==0) return this.$showToast(res.msg)
  221. this.$emit('reSendReport')
  222. })
  223. }
  224. }
  225. }
  226. </script>
  227. <style scoped lang="scss">
  228. .gbox{
  229. height: 100%;
  230. &-item{
  231. margin-top: 20rpx;
  232. background: #FFFFFF;
  233. border-radius: 24rpx;
  234. padding: 40rpx 24rpx 10rpx;
  235. position: relative;
  236. &-top{
  237. &-type{
  238. width: 98rpx;
  239. height: 36rpx;
  240. padding: 2rpx 13rpx;
  241. box-sizing: border-box;
  242. background: #FFF7DC;
  243. border-radius: 6rpx;
  244. font-family: PingFangSC, PingFang SC;
  245. font-weight: 400;
  246. font-size: 24rpx;
  247. color: #BA9B31;
  248. line-height: 33rpx;
  249. }
  250. &-title{
  251. width: calc(100% - 98rpx);
  252. font-family: PingFang-SC, PingFang-SC;
  253. font-weight: bold;
  254. font-size: 32rpx;
  255. color: #002846;
  256. line-height: 32rpx;
  257. text-indent: 17rpx;
  258. }
  259. }
  260. &-p{
  261. margin-top: 32rpx;
  262. &>view{
  263. font-family: PingFangSC, PingFang SC;
  264. font-weight: 400;
  265. font-size: 24rpx;
  266. color: #667E90;
  267. line-height: 24rpx;
  268. }
  269. &-left{
  270. width: 134rpx;
  271. }
  272. &-right{
  273. width: calc(100% - 134rpx);
  274. }
  275. &-progress{
  276. width: calc(100% - 134rpx);
  277. &-l{
  278. width: 410rpx;
  279. height: 12rpx;
  280. background: #F0F2F8;
  281. border-radius: 6rpx;
  282. position: relative;
  283. &-current{
  284. height: 12rpx;
  285. background: #FFDF73;
  286. border-radius: 6rpx;
  287. position: absolute;
  288. left: 0;
  289. top: 0;
  290. }
  291. }
  292. &-r{
  293. width: calc(100% - 410rpx);
  294. font-family: PingFangSC, PingFang SC;
  295. font-weight: 400;
  296. font-size: 24rpx;
  297. color: #002846;
  298. line-height: 24rpx;
  299. text-align: right;
  300. }
  301. }
  302. }
  303. &-ask{
  304. width: 64rpx;
  305. height: 64rpx;
  306. position: absolute;
  307. right: 24rpx;
  308. top: 180rpx;
  309. }
  310. &-bottom{
  311. margin-top: 30rpx;
  312. border-top: 1rpx solid #EFEFEF;
  313. padding-top: 18rpx;
  314. &-left{
  315. &>view{
  316. font-family: PingFangSC, PingFang SC;
  317. font-weight: 400;
  318. font-size: 24rpx;
  319. color: #667E90;
  320. line-height: 24rpx;
  321. }
  322. }
  323. &-right{
  324. padding: 17rpx 20rpx;
  325. background: linear-gradient( 90deg, #33A7A7 0%, #4DB2B2 100%);
  326. border-radius: 30rpx;
  327. font-family: PingFang-SC, PingFang-SC;
  328. font-weight: bold;
  329. font-size: 24rpx;
  330. color: #FFFFFF;
  331. line-height: 26rpx;
  332. letter-spacing: 2rpx;
  333. }
  334. }
  335. }
  336. }
  337. </style>