generateList.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462
  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-ps">
  11. <view class="gbox-item-p adfac">
  12. <view class="gbox-item-p-left">团队名称:</view>
  13. <view class="gbox-item-p-right">{{item.teamName||''}}</view>
  14. </view>
  15. <view class="gbox-item-p adf">
  16. <view class="gbox-item-p-left">报告状态:</view>
  17. <view class="gbox-item-p-right" :style="{'color':stateColor[item.state]}">{{stateDict[item.state]}}</view>
  18. </view>
  19. <view class="gbox-item-p adf">
  20. <view class="gbox-item-p-left">创建时间:</view>
  21. <view class="gbox-item-p-right">{{item.createDate||''}}</view>
  22. </view>
  23. <!-- <image class="gbox-item-ask" :src="imgBase+'report_ask.png'" @click="askReport(item)" v-if="item.state==1&&item.fileUrl"></image> -->
  24. <image class="gbox-item-ask" :src="imgBase+'report_ask.png'" @click="testShow=true" v-if="item.state==1&&item.fileUrl"></image>
  25. </view>
  26. <view class="gbox-item-bottom adfacjb">
  27. <view class="gbox-item-bottom-rightbox adfac" v-if="item.type==1">
  28. <view class="gbox-item-bottom-right" @click="reviewPdf(item)" v-if="item.state==1">预览报告</view>
  29. <view class="gbox-item-bottom-right" @click="reviewReport(item)" v-if="item.state==1&&item.fileUrl">查看报告</view>
  30. <view class="gbox-item-bottom-right" @click="reSendReport(item)" v-if="item.state==-1">重新生成</view>
  31. </view>
  32. <view class="gbox-item-bottom-rightbox adfac" v-else-if="item.type==2">
  33. <view class="gbox-item-bottom-right" @click="forwardReport(item)" v-if="item.state==1&&item.fileUrl">发送邮件</view>
  34. <view class="gbox-item-bottom-right" @click="reviewPdf(item)" v-if="item.state==1">预览报告</view>
  35. <view class="gbox-item-bottom-right" @click="reviewReport(item)" v-if="item.state==1&&item.fileUrl">查看报告</view>
  36. <view class="gbox-item-bottom-right" @click="sendReport(item)" v-if="item.state!=-1">发送报告</view>
  37. <view class="gbox-item-bottom-right" @click="reSendReport(item)" v-if="item.state==-1">重新生成</view>
  38. </view>
  39. </view>
  40. </view>
  41. </u-list-item>
  42. </u-list>
  43. <view class="kind-reminder adffcacjc" v-if="testShow">
  44. <view class="kr-box adffcac">
  45. <view class="kr-title">温馨提示</view>
  46. <view class="kr-p" style="margin-top: 54rpx;">功能测试中,即将上线,敬请期待!</view>
  47. <view class="kr-btn" @click="testShow=false">确定</view>
  48. </view>
  49. </view>
  50. <cus-select-team-user
  51. ref="selectTeamUser"
  52. :show="teamUserShow"
  53. :list="teamUserList"
  54. @close="handleClose"
  55. @changeAll="changeAll"
  56. @handleSelectUser="handleSelectUser"
  57. @handleConfirm="sendConfirm"
  58. ></cus-select-team-user>
  59. </view>
  60. </template>
  61. <script>
  62. import { getPlatformInfo } from '@/utils/platform.js';
  63. import CusSelectTeamUser from '@/components/CusSelectTeamUser/index.vue'
  64. export default {
  65. props:{
  66. list:{
  67. typeof:Array,
  68. default:[]
  69. }
  70. },
  71. components:{ CusSelectTeamUser },
  72. data(){
  73. return {
  74. typeCfg:{
  75. 1:'个人版',
  76. 2:'团队版',
  77. 0:'团队PRO版'
  78. },
  79. stateDict:{
  80. '0':'生成中',
  81. '1':'生成成功',
  82. '-1':'生成失败'
  83. },
  84. stateColor:{
  85. '0':'#FFD750',
  86. '1':'#33A7A7',
  87. '-1':'#F4657A'
  88. },
  89. teamUserShow:false,
  90. teamUserList:[],
  91. categoryData:[],
  92. sendType:1,
  93. selectItem:null,
  94. testShow:false
  95. }
  96. },
  97. methods:{
  98. scrolltolower(){
  99. this.$emit('scrolltolower')
  100. },
  101. getUserCategoryData(){
  102. return new Promise((resolve,reject)=>{
  103. this.$api.get('/getListByType/UserCategory').then(({data:res})=>{
  104. if(res.code!==0) return this.$showToast(res.msg)
  105. this.categoryData = res.data.map(d=>({name:d.dictLabel,id:d.dictValue}))
  106. resolve()
  107. })
  108. })
  109. },
  110. async forwardReport(item){
  111. //发送给账号自己的邮箱
  112. if(!uni.getStorageSync('userInfo')||!JSON.parse(uni.getStorageSync('userInfo')).email) return this.$showModal('发送邮件前请先在我的-设置-用户信息中绑定邮箱')
  113. uni.showModal({
  114. title:'温馨提示',
  115. content:`是否确认将“${item.reportName||''}”下的PDF报告文件发送到账号绑定邮箱中?`,
  116. confirmText:'确认',
  117. success: (res) => {
  118. if(res.confirm){
  119. this.$api.get(`/core/report/sendToEmail/${item.reportId}`).then(({data:res})=>{
  120. if(res.code!==0) return this.$showToast(res.msg)
  121. this.$showModal('邮件发送成功,可在绑定的邮箱中查看详细内容。')
  122. })
  123. }
  124. }
  125. })
  126. // this.sendType = 1;
  127. // this.$refs.selectTeamUser.title = '发送邮件'
  128. // await this.getUserCategoryData()
  129. // this.$api.get(`/core/member/listByQueTeamId/${item.teamQueId}`).then(({data:res})=>{
  130. // if(res.code!==0) return this.$showToast(res.msg)
  131. // this.teamUserList = res.data;
  132. // this.teamUserList.forEach((l,i)=>{
  133. // l.categoryName = this.categoryData.find(c=>c.id==l.category)?.name;
  134. // this.$set(this.teamUserList[i],'select',false);
  135. // })
  136. // this.teamUserShow = true;
  137. // })
  138. },
  139. handleSelectUser(index){
  140. this.$set(this.teamUserList[index],'select',!this.teamUserList[index].select);
  141. this.dealNumAndAll()
  142. },
  143. handleClose(){
  144. this.teamUserShow = false;
  145. this.initSelectUserComponent();
  146. },
  147. changeAll(selected){
  148. this.teamUserList.forEach((l,i)=>{
  149. this.$set(this.teamUserList[i],'select',selected);
  150. })
  151. this.$refs.selectTeamUser.selectNums = this.teamUserList.filter(l=>l.select).length;
  152. },
  153. dealNumAndAll(){
  154. const selectnum = this.teamUserList.filter(l=>l.select).length;
  155. this.$refs.selectTeamUser.selectNums = selectnum;
  156. this.$refs.selectTeamUser.selectAll = selectnum === this.teamUserList.length;
  157. },
  158. sendConfirm(){
  159. if(this.teamUserList.filter(t=>t.select).length===0) return this.$showToast('请选择要发送的用户')
  160. if(this.sendType===1&&(!uni.getStorageSync('userInfo')||!JSON.parse(uni.getStorageSync('userInfo')).email)) return this.$showModal('发送前请先在我的-设置-用户信息中绑定邮箱')
  161. if(this.sendType===1){
  162. this.handleClose();
  163. } else if(this.sendType===2){
  164. const item = JSON.parse(JSON.stringify(this.selectItem));
  165. uni.showModal({
  166. title:'发送报告',
  167. content:`是否确认将“${item.reportName||''}”发送给团队成员`,
  168. confirmText:'确认',
  169. success: (res) => {
  170. if(res.confirm){
  171. this.$api.post(`/core/report/sendReport`,{
  172. reportId:item.reportId,
  173. memberList:this.teamUserList.filter(t=>t.select).map(t=>({id:t.id,mobile:t.mobile,category:t.category}))
  174. }).then(({data:res})=>{
  175. if(res.code!==0) return this.$showToast(res.msg)
  176. this.handleClose();
  177. uni.navigateTo({
  178. url:'/pagesHome/sendResult?result='+res.code
  179. })
  180. })
  181. }
  182. }
  183. })
  184. }
  185. },
  186. initSelectUserComponent(){
  187. this.$refs.selectTeamUser.selectNums = 0;
  188. this.$refs.selectTeamUser.selectAll = false;
  189. },
  190. reviewPdf(item){
  191. let url = `/pagesHome/pdf?reportId=${item.reportId}`;
  192. if(item.type==2) url = `/pagesHome/pdfZyb?reportId=${item.reportId}`
  193. uni.navigateTo({ url })
  194. },
  195. reviewReport(item){
  196. const { isPC, isMobile, platform } = getPlatformInfo();
  197. console.log(platform,'platform');//android
  198. if (isPC) {
  199. this.$showModal('请在手机端该微信小程序中查看报告')
  200. } else if (isMobile||platform==='devtools') {
  201. if(!item.fileUrl) return this.$showToast('报告pdf为空,请稍后再试。')
  202. this.openPdf(item.fileUrl)
  203. // uni.navigateTo({
  204. // url:'/pages/webView?src='+item.fileUrl
  205. // })
  206. }
  207. },
  208. async openPdf(pdfUrl) {
  209. try {
  210. // 1. 显示加载提示
  211. uni.showLoading({ title: '加载中...' });
  212. // 2. 先下载PDF文件到本地(解决安卓直接预览网络文件慢的问题)
  213. const downloadRes = await uni.downloadFile({
  214. url: pdfUrl,
  215. // 可选:设置超时时间,避免长时间等待
  216. timeout: 30000
  217. });
  218. const dres = downloadRes[1]||null;
  219. if (dres.statusCode !== 200) {
  220. uni.hideLoading();
  221. uni.showToast({ title: '文件下载失败', icon: 'none' });
  222. return;
  223. }
  224. // 3. 用微信原生API打开本地PDF
  225. const openRes = await uni.openDocument({
  226. filePath: dres.tempFilePath,
  227. fileType: 'pdf',
  228. showMenu: true // 允许用户转发/保存等
  229. });
  230. uni.hideLoading();
  231. } catch (error) {
  232. uni.hideLoading();
  233. uni.showToast({ title: '加载失败,请重试', icon: 'none' });
  234. }
  235. },
  236. askReport(item){
  237. uni.navigateTo({
  238. url:`/pages/reportAsk?pdfUrl=${item.fileUrl}&fileName=${this.typeCfg[item.type]||'个人版'}-${item.reportName}`
  239. })
  240. },
  241. async sendReport(item){
  242. if(!item.fileUrl) return this.$showModal('该报告尚未生成PDF文件,请等待生成后发送。')
  243. this.sendType = 2;
  244. this.$refs.selectTeamUser.title = '发送报告'
  245. this.selectItem = item;
  246. await this.getUserCategoryData()
  247. this.$api.get(`/core/member/listByQueTeamId/${item.teamQueId}`).then(({data:res})=>{
  248. if(res.code!==0) return this.$showToast(res.msg)
  249. this.teamUserList = res.data;
  250. this.teamUserList.forEach((l,i)=>{
  251. l.categoryName = this.categoryData.find(c=>c.id==l.category)?.name;
  252. this.$set(this.teamUserList[i],'select',false);
  253. })
  254. this.teamUserShow = true;
  255. })
  256. },
  257. reSendReport(item){
  258. this.$api.get(`/core/report/regenerateReport/${item.reportId}`).then(({data:res})=>{
  259. if(res.code!==0) return this.$showToast(res.msg)
  260. this.$emit('reSendReport')
  261. })
  262. }
  263. }
  264. }
  265. </script>
  266. <style scoped lang="scss">
  267. .gbox{
  268. height: 100%;
  269. &-item{
  270. margin-top: 20rpx;
  271. background: #FFFFFF;
  272. border-radius: 24rpx;
  273. padding: 40rpx 20rpx 20rpx;
  274. &-top{
  275. &-type{
  276. width: 98rpx;
  277. height: 36rpx;
  278. padding: 2rpx 13rpx;
  279. box-sizing: border-box;
  280. background: #FFF7DC;
  281. border-radius: 6rpx;
  282. font-family: PingFangSC, PingFang SC;
  283. font-weight: 400;
  284. font-size: 24rpx;
  285. color: #BA9B31;
  286. line-height: 33rpx;
  287. }
  288. &-title{
  289. width: calc(100% - 98rpx);
  290. font-family: PingFang-SC, PingFang-SC;
  291. font-weight: bold;
  292. font-size: 32rpx;
  293. color: #002846;
  294. line-height: 32rpx;
  295. text-indent: 17rpx;
  296. }
  297. }
  298. &-ps{
  299. margin-top: 20rpx;
  300. background: #F5F8FA;
  301. border-radius: 5px;
  302. padding: 20rpx 20rpx 30rpx;
  303. position: relative;
  304. }
  305. &-p{
  306. margin-top: 32rpx;
  307. &:first-child{
  308. margin-top: 0;
  309. }
  310. &>view{
  311. font-family: PingFangSC, PingFang SC;
  312. font-weight: 400;
  313. font-size: 24rpx;
  314. color: #667E90;
  315. line-height: 24rpx;
  316. }
  317. &-left{
  318. width: 134rpx;
  319. }
  320. &-right{
  321. width: calc(100% - 134rpx);
  322. }
  323. &-progress{
  324. width: calc(100% - 134rpx);
  325. &-l{
  326. width: 410rpx;
  327. height: 12rpx;
  328. background: #F0F2F8;
  329. border-radius: 6rpx;
  330. position: relative;
  331. &-current{
  332. height: 12rpx;
  333. background: #FFDF73;
  334. border-radius: 6rpx;
  335. position: absolute;
  336. left: 0;
  337. top: 0;
  338. }
  339. }
  340. &-r{
  341. width: calc(100% - 410rpx);
  342. font-family: PingFangSC, PingFang SC;
  343. font-weight: 400;
  344. font-size: 24rpx;
  345. color: #002846;
  346. line-height: 24rpx;
  347. text-align: right;
  348. }
  349. }
  350. }
  351. &-ask{
  352. width: 64rpx;
  353. height: 64rpx;
  354. position: absolute;
  355. right: 20rpx;
  356. bottom: 42rpx;
  357. }
  358. &-bottom{
  359. margin-top: 20rpx;
  360. overflow: hidden;
  361. &-rightbox{
  362. flex: 1;
  363. margin-left: -35rpx;
  364. justify-content: flex-end;
  365. }
  366. &-left{
  367. &>view{
  368. font-family: PingFangSC, PingFang SC;
  369. font-weight: 400;
  370. font-size: 24rpx;
  371. color: #667E90;
  372. line-height: 24rpx;
  373. }
  374. }
  375. &-right{
  376. width: calc(25% - 35rpx);
  377. padding: 15rpx;
  378. text-align: center;
  379. box-sizing: border-box;
  380. background: linear-gradient( 90deg, #33A7A7 0%, #4DB2B2 100%);
  381. border-radius: 20rpx;
  382. font-family: PingFang-SC, PingFang-SC;
  383. font-size: 24rpx;
  384. color: #FFFFFF;
  385. margin-left: 35rpx;
  386. }
  387. }
  388. }
  389. .kind-reminder{
  390. position: fixed;
  391. left: 0;
  392. right: 0;
  393. top: 0;
  394. bottom: 0;
  395. z-index: 1000;
  396. background: rgba(0, 0, 0, .6);
  397. .kr-box{
  398. width: calc(100% - 100rpx);
  399. padding: 54rpx 60rpx 48rpx;
  400. box-sizing: border-box;
  401. background: url('https://gitee.com/hw_0302/chuang-heng-wechat-images/raw/master/remind_bg.png') no-repeat;
  402. background-size: 100% 100%;
  403. position: relative;
  404. image{
  405. width: 48rpx;
  406. height: 48rpx;
  407. position: absolute;
  408. top: 40rpx;
  409. right: 30rpx;
  410. }
  411. .kr-title{
  412. font-family: PingFang-SC, PingFang-SC;
  413. font-weight: bold;
  414. font-size: 36rpx;
  415. color: #002846;
  416. line-height: 56rpx;
  417. text-align: center;
  418. }
  419. .kr-p{
  420. font-family: PingFangSC, PingFang SC;
  421. font-weight: 400;
  422. font-size: 30rpx;
  423. color: #002846;
  424. line-height: 48rpx;
  425. text-align: center;
  426. span{
  427. font-weight: bold;
  428. margin: 0 10rpx;
  429. }
  430. }
  431. .kr-btn{
  432. width: calc(100% - 80rpx);
  433. height: 88rpx;
  434. background: linear-gradient( 90deg, #33A7A7 0%, #64BBBB 100%);;
  435. border-radius: 44rpx;
  436. font-family: PingFang-SC, PingFang-SC;
  437. font-weight: bold;
  438. font-size: 32rpx;
  439. color: #FFFFFF;
  440. line-height: 88rpx;
  441. text-align: center;
  442. letter-spacing: 2rpx;
  443. margin-top: 66rpx;
  444. }
  445. }
  446. }
  447. }
  448. </style>