generateList.vue 14 KB

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