createList.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655
  1. <template>
  2. <view class="qbox adffc">
  3. <view class="list" v-if="list.length">
  4. <up-list @scrolltolower="scrolltolower" style="height: 100%">
  5. <up-list-item class="list-item" v-for="(item, index) in list" :key="index">
  6. <view @click.prevent="showDialog(item)">
  7. <image class="expand" :src="imgBase + 'questionnaire_icon_down.png'"></image>
  8. <view class="title">{{ item.title || '' }}</view>
  9. <view class="name">团队名称:{{ item.teamName || '' }}</view>
  10. <view class="progress adfacjb">
  11. <view class="progress-left adfac">
  12. <view class="progress-left-text">作答进度:</view>
  13. <view class="progress-left-box">
  14. <view class="progress-left-box-current" :style="{ width: (item.finishNum / item.userNum) * 100 + '%' }"></view>
  15. </view>
  16. </view>
  17. <view class="progress-right">
  18. <span>{{ item.finishNum }}/</span>
  19. {{ item.userNum }}
  20. </view>
  21. </view>
  22. <view class="bottom adfacjb">
  23. <view class="bottom-left">截止时间:{{ item.endTime }}</view>
  24. <view class="bottom-right" v-if="item.status === 0 && item.type == 1" @click.stop="handleAnswer(item)">立即作答</view>
  25. <view class="bottom-right" v-else-if="item.status === 1 && !item.fileUrl" @click.stop="createReport(item)">生成报告</view>
  26. <view class="bottom-right" v-else-if="item.status === 1 && item.fileUrl" @click.stop="sendReport(item)">发送报告</view>
  27. </view>
  28. </view>
  29. </up-list-item>
  30. </up-list>
  31. </view>
  32. <view class="empty" v-else>
  33. <page-empty></page-empty>
  34. </view>
  35. <view class="dialog adffc" v-if="show">
  36. <view class="dbox">
  37. <view class="dbox-top adfacjb">
  38. <view class="dbox-top-title">{{ dto.title || '' }}</view>
  39. <image class="dbox-top-expand" :src="imgBase + 'questionnaire_icon_down.png'" @click="show = false"></image>
  40. </view>
  41. <view class="dbox-name">团队名称:{{ dto.teamName || '' }}</view>
  42. <view class="dbox-progress adfacjb">
  43. <view class="dbox-progress-left adfac">
  44. <view class="dbox-progress-left-text">作答进度:</view>
  45. <view class="dbox-progress-left-box">
  46. <view class="dbox-progress-left-box-current" :style="{ width: (dto.finishNum / dto.userNum) * 100 + '%' }"></view>
  47. </view>
  48. </view>
  49. <view class="dbox-progress-right">
  50. <span>{{ dto.finishNum }}/</span>
  51. {{ dto.userNum }}
  52. </view>
  53. </view>
  54. <view class="dbox-menu">
  55. <view class="dbox-menu-pre adffcac" v-for="(item, index) in menuListCopy" :key="index" @click="handleMenuClick(item, index)">
  56. <template v-if="item.text === '分享问卷'">
  57. <button class="share-btn" open-type="share">
  58. <image :src="item.img"></image>
  59. <text>{{ item.text }}</text>
  60. </button>
  61. </template>
  62. <template v-else>
  63. <image :src="item.img"></image>
  64. <text>{{ item.text }}</text>
  65. </template>
  66. </view>
  67. </view>
  68. </view>
  69. </view>
  70. <view class="dialog adffc" v-if="teamInfoShow">
  71. <view class="dialog-box">
  72. <view class="dialog-box-title">团队信息</view>
  73. <image class="dialog-box-close" :src="imgBase + 'remind_close.png'" @click="teamInfoShow = false"></image>
  74. <view class="dialog-box-teaminfo">
  75. <cus-team-info-fill ref="teamRef" confirmText="保存" @handleConfirm="handleConfirm"></cus-team-info-fill>
  76. </view>
  77. </view>
  78. </view>
  79. <div class="alert adffcacjc" v-if="alertShow">
  80. <div class="alert-box">
  81. <div class="alert-box-title">温馨提示</div>
  82. <image :src="imgBase + 'remind_close.png'" class="alert-box-close" @click="alertShow = false"></image>
  83. <div class="alert-box-text">
  84. 该问卷尚未生成报告
  85. <br />
  86. 请确认团队人员是否全部作答
  87. <br />
  88. 完成后点击生成报告
  89. </div>
  90. <div class="zt_btn" @click="alertShow = false">我知道了</div>
  91. </div>
  92. </div>
  93. <cus-team-user
  94. :deluser="true"
  95. :show="teamUserShow"
  96. :list="teamUserList"
  97. @close="teamUserShow = false"
  98. @addUser="addUser"
  99. @handleConfirm="userConfirm"
  100. @deleteUser="deleteUser"
  101. ></cus-team-user>
  102. </view>
  103. </template>
  104. <script>
  105. import PageEmpty from '@/components/pageEmpty/index.vue'
  106. import CusTeamUser from '@/components/CusTeamUser/index.vue'
  107. import CusTeamInfoFill from '@/components/CusTeamInfoFill/index.vue'
  108. export default {
  109. components:{ PageEmpty, CusTeamUser, CusTeamInfoFill },
  110. props:{
  111. list:{
  112. typeof:Array,
  113. default:[]
  114. }
  115. },
  116. data(){
  117. return {
  118. show:false,
  119. teamInfoShow:false,
  120. teamUserShow:false,
  121. alertShow:false,
  122. dto:null,
  123. menuList:[
  124. {
  125. img:this.$imgBase+'questionnaire_edit.png',
  126. text:'编辑问卷'
  127. },
  128. {
  129. img:this.$imgBase+'questionnaire_share.png',
  130. text:'分享问卷'
  131. },
  132. {
  133. img:this.$imgBase+'questionnaire_info.png',
  134. text:'团队信息'
  135. },
  136. {
  137. img:this.$imgBase+'questionnaire_copy.png',
  138. text:'复制链接'
  139. },
  140. {
  141. img:this.$imgBase+'questionnaire_users.png',
  142. text:'团队人员'
  143. },
  144. {
  145. img:this.$imgBase+'questionnaire_report.png',
  146. text:'生成报告'
  147. },
  148. {
  149. img:this.$imgBase+'questionnaire_send.png',
  150. text:'发送报告'
  151. }
  152. ],
  153. menuListCopy:[],
  154. teamUserList:[],
  155. originTeamUserList:[],
  156. teamScaleData:[],
  157. teamLevelData:[],
  158. categoryData:[],
  159. delMemberIds:[],
  160. }
  161. },
  162. methods:{
  163. onShareAppMessage(res) {
  164. // res.from === 'button' // 来自页面内分享按钮
  165. // res.from === 'menu' // 来自右上角菜单分享
  166. const sharerId = JSON.parse(uni.getStorageSync('userInfo'))?.id;
  167. console.log(`准备分享,团队问卷ID: ${this.dto.teamQuestionnaireId}, 分享者ID: ${sharerId}`);
  168. return {
  169. title: this.dto.title || '发现一个好物,分享给你!',
  170. path: `/pages/home?shareTQId=${this.dto.teamQuestionnaireId}&shareUserId=${sharerId}`,
  171. // imageUrl: this.$imgBase+''
  172. };
  173. },
  174. scrolltolower(){
  175. this.$emit('scrolltolower')
  176. },
  177. showDialog(item){
  178. this.dto = item;
  179. if(this.dto.type==1) this.menuListCopy = this.menuList.filter((_, index) => index !== 4);
  180. else this.menuListCopy = JSON.parse(JSON.stringify(this.menuList))
  181. this.show = true;
  182. },
  183. async getTeamScaleData(){
  184. return new Promise((resolve,reject)=>{
  185. this.$api.get('/getListByType/team_scale').then(({data:res})=>{
  186. if(res.code!==0) return this.$showToast(res.msg)
  187. this.teamScaleData = res.data.map(d=>({name:d.dictLabel,id:d.dictValue}))
  188. resolve()
  189. })
  190. })
  191. },
  192. async getTeamHierarchyData(){
  193. return new Promise((resolve,reject)=>{
  194. this.$api.get('/getListByType/team_hierarchy').then(({data:res})=>{
  195. if(res.code!==0) return this.$showToast(res.msg)
  196. this.teamLevelData = res.data.map(d=>({name:d.dictLabel,id:d.dictValue}))
  197. resolve()
  198. })
  199. })
  200. },
  201. async getUserCategoryData(){
  202. return new Promise((resolve,reject)=>{
  203. this.$api.get('/getListByType/UserCategory').then(({data:res})=>{
  204. if(res.code!==0) return this.$showToast(res.msg)
  205. this.categoryData = res.data.map(d=>({name:d.dictLabel,id:d.dictValue}))
  206. resolve()
  207. })
  208. })
  209. },
  210. async handleMenuClick(item){
  211. if(item.text==='编辑问卷'){
  212. uni.navigateTo({
  213. url:`/pagesHome/questionnaireEdit?teamQuestionnaireId=${this.dto.teamQuestionnaireId}&type=${this.dto.type}&questionnaireName=${this.dto.title}&isEdit=true`
  214. })
  215. this.show = false;
  216. }else if(item.text==='分享问卷'){
  217. }else if(item.text==='团队信息'){
  218. this.teamInfoShow = true;
  219. await this.getTeamScaleData()
  220. await this.getTeamHierarchyData()
  221. this.$api.get(`/core/user/team/${this.dto.teamId}`).then(({data:res})=>{
  222. if(res.code!==0) return this.$showToast(res.msg)
  223. this.$refs.teamRef.setTeamInfo(res.data)
  224. this.$refs.teamRef.teamInfo.functionIds = res.data.functions.map(f=>f.id);
  225. this.$refs.teamRef.teamInfo.orgIds = res.data.organizations.map(o=>o.id);
  226. this.$refs.teamRef.areaText = res.data.provinceName+res.data.cityName;
  227. this.$refs.teamRef.industryText = res.data.industryName;
  228. this.$refs.teamRef.functionTypeText = res.data.functions.map(f=>f.functionName).join('、');
  229. this.$refs.teamRef.architectureTypeText = res.data.organizations.map(f=>f.orgName).join('、');
  230. this.$refs.teamRef.teamScaleText = this.teamScaleData.find(d=>d.id==res.data.scale).name;
  231. this.$refs.teamRef.teamLevelText = this.teamLevelData.find(d=>d.id==res.data.hierarchy).name;
  232. })
  233. }
  234. else if(item.text==='复制链接') {
  235. let shareUserId = JSON.parse(uni.getStorageSync('userInfo')).id;
  236. let res = await this.$api.post('/wx/genInviteLink',{
  237. 'path': '',
  238. 'query': `shareTQId=${this.dto.teamQuestionnaireId}&shareUserId=${shareUserId}`,
  239. 'env_version': 'develop'//默认"release",正式版"release",体验版"trial",开发版"develop"
  240. });
  241. if(res.data.code!==0) return this.$showToast(res.data.msg)
  242. uni.setClipboardData({
  243. data:res.data.data.openlink,
  244. success: () => {
  245. this.$showToast('复制成功')
  246. },
  247. fail: () => {
  248. this.$showToast('复制失败')
  249. }
  250. })
  251. }
  252. else if(item.text==='团队人员'){
  253. await this.getUserCategoryData()
  254. this.$api.get(`/core/member/listByQueTeamId/${this.dto.teamQuestionnaireId}`).then(({data:res})=>{
  255. if(res.code!==0) return this.$showToast(res.msg)
  256. this.teamUserList = res.data;
  257. this.originTeamUserList = res.data;
  258. this.teamUserList.forEach(l=>{
  259. l.categoryName = this.categoryData.find(c=>c.id==l.category)?.name;
  260. })
  261. this.teamUserShow = true
  262. })
  263. }
  264. else if(item.text==='生成报告'){
  265. if(this.dto.status==0) return this.$showToast('问卷未完成,全部团队人员作答后才能生成报告')
  266. }
  267. else if(item.text==='发送报告'){
  268. if(this.dto.status==0) return this.$showToast('请先生成报告后再进行发送报告')
  269. }
  270. },
  271. handleConfirm(data){
  272. data.coachId = JSON.parse(uni.getStorageSync('userInfo')).id;
  273. this.$api.put('/core/user/team',data).then(({data:res})=>{
  274. if(res.code!==0) return this.$showToast(res.msg)
  275. this.$showToast('保存成功')
  276. this.teamInfoShow = false;
  277. })
  278. },
  279. handleAnswer(item){
  280. uni.navigateTo({
  281. url:'/pagesPublish/questionnaireFill?teamQuestionnaireId='+item.teamQuestionnaireId+'&teamId='+item.teamId+'&type='+item.type
  282. })
  283. },
  284. createReport(item){
  285. },
  286. sendReport(item){
  287. },
  288. addUser(){
  289. uni.navigateTo({
  290. url:'/pagesMy/teamUser?type=select',
  291. events:{
  292. selectUserConfirm: data => {
  293. data.forEach((d,i)=>(this.$set(data[i],'status',0)));
  294. let newUser = this.filterUsers(this.teamUserList,data)
  295. this.teamUserList = [...this.teamUserList,...newUser];
  296. }
  297. }
  298. })
  299. },
  300. filterUsers(originArr,selectArr){
  301. const aValuesToExclude = new Set(originArr.map(item => item.id));
  302. return selectArr.filter(item => {
  303. return !aValuesToExclude.has(item.id);
  304. });
  305. },
  306. userConfirm(){
  307. if(this.teamUserList.length===0) return this.$showToast('至少保留一位团队人员');
  308. this.$api.get('/core/team/questionnaire/'+this.dto.teamQuestionnaireId).then(({data:res})=>{
  309. if(res.code!==0) return this.$showToast(res.msg)
  310. let dto = res.data;
  311. dto.coachId = JSON.parse(uni.getStorageSync('userInfo')).id;
  312. dto.delMemberIds = [...new Set(this.delMemberIds)];
  313. dto.memberList = this.teamUserList;
  314. dto.type = 2;
  315. delete dto.memberInfos;
  316. this.$api.put('/core/team/questionnaire/updateMembers',dto).then(({data:resu})=>{
  317. if(resu.code!==0) return this.$showToast(resu.msg)
  318. this.$showToast('操作成功')
  319. this.teamUserShow = false;
  320. // this.show = false;
  321. })
  322. })
  323. },
  324. deleteUser(data){
  325. let u = this.originTeamUserList.find(u=>u.id===data.item.id);
  326. if(u) this.delMemberIds=[...this.delMemberIds,u.id]
  327. this.teamUserList.splice(data.index,1);
  328. }
  329. }
  330. }
  331. </script>
  332. <style scoped lang="scss">
  333. .share-btn {
  334. background-color: transparent;
  335. border: none;
  336. padding: 0;
  337. margin: 0;
  338. line-height: 1;
  339. display: flex;
  340. flex-direction: column;
  341. justify-content: center;
  342. align-items: center;
  343. &::after {
  344. border: none;
  345. }
  346. }
  347. .qbox {
  348. width: 100%;
  349. height: 100%;
  350. flex: 1;
  351. .list {
  352. flex: 1;
  353. margin-top: 20rpx;
  354. overflow: hidden;
  355. &-item {
  356. width: 100%;
  357. background: #ffffff;
  358. border-radius: 24rpx;
  359. margin-top: 20rpx;
  360. padding: 36rpx 24rpx 19rpx;
  361. box-sizing: border-box;
  362. position: relative;
  363. display: block;
  364. .expand {
  365. width: 32rpx;
  366. height: 32rpx;
  367. position: absolute;
  368. top: 36rpx;
  369. right: 32rpx;
  370. }
  371. .title {
  372. width: calc(100% - 128rpx);
  373. font-family: PingFang-SC, PingFang-SC;
  374. font-weight: bold;
  375. font-size: 32rpx;
  376. color: #002846;
  377. line-height: 32rpx;
  378. }
  379. .name {
  380. font-family: PingFangSC, PingFang SC;
  381. font-weight: 400;
  382. font-size: 24rpx;
  383. color: #667e90;
  384. line-height: 24rpx;
  385. margin-top: 35rpx;
  386. }
  387. .progress {
  388. margin-top: 36rpx;
  389. &-left {
  390. width: calc(100% - 95rpx);
  391. &-text {
  392. font-family: PingFangSC, PingFang SC;
  393. font-weight: 400;
  394. font-size: 24rpx;
  395. color: #667e90;
  396. line-height: 24rpx;
  397. }
  398. &-box {
  399. flex: 1;
  400. position: relative;
  401. height: 12rpx;
  402. background: #f0f2f8;
  403. border-radius: 6rpx;
  404. &-current {
  405. height: 12rpx;
  406. background: #7cc5c5;
  407. border-radius: 6rpx;
  408. position: absolute;
  409. top: 0;
  410. left: 0;
  411. }
  412. }
  413. }
  414. &-right {
  415. font-size: 24rpx;
  416. line-height: 24rpx;
  417. color: #95a5b1;
  418. span {
  419. font-size: 24rpx;
  420. line-height: 24rpx;
  421. color: #002846;
  422. }
  423. }
  424. }
  425. .bottom {
  426. margin-top: 30rpx;
  427. border-top: 1rpx solid #efefef;
  428. padding-top: 20rpx;
  429. &-left {
  430. font-family: PingFangSC, PingFang SC;
  431. font-weight: 400;
  432. font-size: 24rpx;
  433. color: #667e90;
  434. line-height: 24rpx;
  435. }
  436. &-right {
  437. border-radius: 32rpx;
  438. background: linear-gradient(90deg, #33a7a7 0%, #4db2b2 100%);
  439. padding: 19rpx 22rpx;
  440. font-family: PingFangSC, PingFang SC;
  441. font-weight: 400;
  442. font-size: 26rpx;
  443. color: #ffffff;
  444. line-height: 26rpx;
  445. letter-spacing: 2rpx;
  446. }
  447. }
  448. }
  449. }
  450. .empty {
  451. flex: 1;
  452. }
  453. .dialog {
  454. position: fixed;
  455. left: 0;
  456. right: 0;
  457. top: 0;
  458. bottom: 0;
  459. background: rgba(0, 0, 0, 0.4);
  460. z-index: 1001;
  461. justify-content: flex-end;
  462. .dbox {
  463. width: 100%;
  464. height: 738rpx;
  465. background: #ffffff;
  466. box-shadow: 0rpx -2rpx 6rpx 0rpx rgba(0, 0, 0, 0.07);
  467. border-radius: 24rpx 24rpx 0rpx 0rpx;
  468. padding: 48rpx 30rpx 0;
  469. box-sizing: border-box;
  470. &-top {
  471. &-title {
  472. width: calc(100% - 60rpx);
  473. font-family: PingFang-SC, PingFang-SC;
  474. font-weight: bold;
  475. font-size: 32rpx;
  476. color: #002846;
  477. line-height: 40rpx;
  478. }
  479. &-expand {
  480. width: 32rpx;
  481. height: 32rpx;
  482. transform: rotate(180deg);
  483. }
  484. }
  485. &-name {
  486. font-family: PingFangSC, PingFang SC;
  487. font-weight: 400;
  488. font-size: 24rpx;
  489. color: #667e90;
  490. line-height: 24rpx;
  491. margin-top: 24rpx;
  492. }
  493. &-progress {
  494. margin-top: 36rpx;
  495. &-left {
  496. width: calc(100% - 95rpx);
  497. &-text {
  498. font-family: PingFangSC, PingFang SC;
  499. font-weight: 400;
  500. font-size: 24rpx;
  501. color: #667e90;
  502. line-height: 24rpx;
  503. }
  504. &-box {
  505. flex: 1;
  506. position: relative;
  507. height: 12rpx;
  508. background: #f0f2f8;
  509. border-radius: 6rpx;
  510. &-current {
  511. height: 12rpx;
  512. background: #7cc5c5;
  513. border-radius: 6rpx;
  514. position: absolute;
  515. top: 0;
  516. left: 0;
  517. }
  518. }
  519. }
  520. &-right {
  521. font-size: 24rpx;
  522. line-height: 24rpx;
  523. color: #95a5b1;
  524. span {
  525. font-size: 24rpx;
  526. line-height: 24rpx;
  527. color: #002846;
  528. }
  529. }
  530. }
  531. &-menu {
  532. margin-top: 43rpx;
  533. overflow: hidden;
  534. margin-left: -30rpx;
  535. &-pre {
  536. width: calc(25% - 30rpx);
  537. background: #f7f8fa;
  538. border-radius: 24rpx;
  539. padding: 30rpx 20rpx;
  540. margin-top: 24rpx;
  541. margin-left: 30rpx;
  542. box-sizing: border-box;
  543. float: left;
  544. image {
  545. width: 42rpx;
  546. height: 42rpx;
  547. }
  548. text {
  549. font-family: PingFangSC, PingFang SC;
  550. font-weight: 400;
  551. font-size: 24rpx;
  552. color: #002846;
  553. line-height: 24rpx;
  554. text-align: center;
  555. margin-top: 24rpx;
  556. }
  557. }
  558. }
  559. }
  560. &-box {
  561. width: 100%;
  562. height: 1200rpx;
  563. background: #f7f7f7;
  564. padding-top: 38rpx;
  565. border-radius: 24rpx 24rpx 0rpx 0rpx;
  566. box-sizing: border-box;
  567. position: relative;
  568. overflow-y: auto;
  569. &-title {
  570. font-family: PingFang-SC, PingFang-SC;
  571. font-weight: bold;
  572. font-size: 32rpx;
  573. color: #002846;
  574. line-height: 32rpx;
  575. text-align: center;
  576. }
  577. &-close {
  578. width: 48rpx;
  579. height: 48rpx;
  580. position: absolute;
  581. top: 30rpx;
  582. right: 30rpx;
  583. }
  584. &-teaminfo {
  585. margin-top: 40rpx;
  586. }
  587. }
  588. }
  589. .alert {
  590. position: fixed;
  591. left: 0;
  592. right: 0;
  593. top: 0;
  594. bottom: 0;
  595. z-index: 1002;
  596. background: rgba(0, 0, 0, 0.4);
  597. &-box {
  598. width: calc(100% - 100rpx);
  599. padding: 54rpx 99rpx 48rpx;
  600. box-sizing: border-box;
  601. position: relative;
  602. background: url('https://gitee.com/hw_0302/chuang-heng-wechat-images/raw/master/alert_bg.png') no-repeat;
  603. background-size: 100% 100%;
  604. &-title {
  605. font-family: PingFang-SC, PingFang-SC;
  606. font-weight: bold;
  607. font-size: 36rpx;
  608. color: #002846;
  609. line-height: 56rpx;
  610. text-align: center;
  611. }
  612. &-close {
  613. width: 48rpx;
  614. height: 48rpx;
  615. position: absolute;
  616. top: 40rpx;
  617. right: 30rpx;
  618. }
  619. &-text {
  620. font-family: PingFangSC, PingFang SC;
  621. font-weight: 400;
  622. font-size: 30rpx;
  623. color: #002846;
  624. line-height: 48rpx;
  625. text-align: center;
  626. margin-top: 32rpx;
  627. }
  628. .zt_btn {
  629. margin-top: 66rpx;
  630. }
  631. }
  632. }
  633. }
  634. </style>