generateList.vue 15 KB

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