createList.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643
  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. uni.setClipboardData({
  236. })
  237. this.$showToast('复制成功')
  238. }
  239. else if(item.text==='团队人员'){
  240. await this.getUserCategoryData()
  241. this.$api.get(`/core/member/listByQueTeamId/${this.dto.teamQuestionnaireId}`).then(({data:res})=>{
  242. if(res.code!==0) return this.$showToast(res.msg)
  243. this.teamUserList = res.data;
  244. this.originTeamUserList = res.data;
  245. this.teamUserList.forEach(l=>{
  246. l.categoryName = this.categoryData.find(c=>c.id==l.category)?.name;
  247. })
  248. this.teamUserShow = true
  249. })
  250. }
  251. else if(item.text==='生成报告'){
  252. if(this.dto.status==0) return this.$showToast('问卷未完成,全部团队人员作答后才能生成报告')
  253. }
  254. else if(item.text==='发送报告'){
  255. if(this.dto.status==0) return this.$showToast('请先生成报告后再进行发送报告')
  256. }
  257. },
  258. handleConfirm(data){
  259. data.coachId = JSON.parse(uni.getStorageSync('userInfo')).id;
  260. this.$api.put('/core/user/team',data).then(({data:res})=>{
  261. if(res.code!==0) return this.$showToast(res.msg)
  262. this.$showToast('保存成功')
  263. this.teamInfoShow = false;
  264. })
  265. },
  266. handleAnswer(item){
  267. uni.navigateTo({
  268. url:'/pagesPublish/questionnaireFill?teamQuestionnaireId='+item.teamQuestionnaireId+'&teamId='+item.teamId+'&type='+item.type
  269. })
  270. },
  271. createReport(item){
  272. },
  273. sendReport(item){
  274. },
  275. addUser(){
  276. uni.navigateTo({
  277. url:'/pagesMy/teamUser?type=select',
  278. events:{
  279. selectUserConfirm: data => {
  280. data.forEach((d,i)=>(this.$set(data[i],'status',0)));
  281. let newUser = this.filterUsers(this.teamUserList,data)
  282. this.teamUserList = [...this.teamUserList,...newUser];
  283. }
  284. }
  285. })
  286. },
  287. filterUsers(originArr,selectArr){
  288. const aValuesToExclude = new Set(originArr.map(item => item.id));
  289. return selectArr.filter(item => {
  290. return !aValuesToExclude.has(item.id);
  291. });
  292. },
  293. userConfirm(){
  294. if(this.teamUserList.length===0) return this.$showToast('至少保留一位团队人员');
  295. this.$api.get('/core/team/questionnaire/'+this.dto.teamQuestionnaireId).then(({data:res})=>{
  296. if(res.code!==0) return this.$showToast(res.msg)
  297. let dto = res.data;
  298. dto.coachId = JSON.parse(uni.getStorageSync('userInfo')).id;
  299. dto.delMemberIds = [...new Set(this.delMemberIds)];
  300. dto.memberList = this.teamUserList;
  301. dto.type = 2;
  302. delete dto.memberInfos;
  303. this.$api.put('/core/team/questionnaire/updateMembers',dto).then(({data:resu})=>{
  304. if(resu.code!==0) return this.$showToast(resu.msg)
  305. this.$showToast('操作成功')
  306. this.teamUserShow = false;
  307. // this.show = false;
  308. })
  309. })
  310. },
  311. deleteUser(data){
  312. let u = this.originTeamUserList.find(u=>u.id===data.item.id);
  313. if(u) this.delMemberIds=[...this.delMemberIds,u.id]
  314. this.teamUserList.splice(data.index,1);
  315. }
  316. }
  317. }
  318. </script>
  319. <style scoped lang="scss">
  320. .share-btn {
  321. background-color: transparent;
  322. border: none;
  323. padding: 0;
  324. margin: 0;
  325. line-height: 1;
  326. display: flex;
  327. flex-direction: column;
  328. justify-content: center;
  329. align-items: center;
  330. &::after {
  331. border: none;
  332. }
  333. }
  334. .qbox {
  335. width: 100%;
  336. height: 100%;
  337. flex: 1;
  338. .list {
  339. flex: 1;
  340. margin-top: 20rpx;
  341. overflow: hidden;
  342. &-item {
  343. width: 100%;
  344. background: #ffffff;
  345. border-radius: 24rpx;
  346. margin-top: 20rpx;
  347. padding: 36rpx 24rpx 19rpx;
  348. box-sizing: border-box;
  349. position: relative;
  350. display: block;
  351. .expand {
  352. width: 32rpx;
  353. height: 32rpx;
  354. position: absolute;
  355. top: 36rpx;
  356. right: 32rpx;
  357. }
  358. .title {
  359. width: calc(100% - 128rpx);
  360. font-family: PingFang-SC, PingFang-SC;
  361. font-weight: bold;
  362. font-size: 32rpx;
  363. color: #002846;
  364. line-height: 32rpx;
  365. }
  366. .name {
  367. font-family: PingFangSC, PingFang SC;
  368. font-weight: 400;
  369. font-size: 24rpx;
  370. color: #667e90;
  371. line-height: 24rpx;
  372. margin-top: 35rpx;
  373. }
  374. .progress {
  375. margin-top: 36rpx;
  376. &-left {
  377. width: calc(100% - 95rpx);
  378. &-text {
  379. font-family: PingFangSC, PingFang SC;
  380. font-weight: 400;
  381. font-size: 24rpx;
  382. color: #667e90;
  383. line-height: 24rpx;
  384. }
  385. &-box {
  386. flex: 1;
  387. position: relative;
  388. height: 12rpx;
  389. background: #f0f2f8;
  390. border-radius: 6rpx;
  391. &-current {
  392. height: 12rpx;
  393. background: #7cc5c5;
  394. border-radius: 6rpx;
  395. position: absolute;
  396. top: 0;
  397. left: 0;
  398. }
  399. }
  400. }
  401. &-right {
  402. font-size: 24rpx;
  403. line-height: 24rpx;
  404. color: #95a5b1;
  405. span {
  406. font-size: 24rpx;
  407. line-height: 24rpx;
  408. color: #002846;
  409. }
  410. }
  411. }
  412. .bottom {
  413. margin-top: 30rpx;
  414. border-top: 1rpx solid #efefef;
  415. padding-top: 20rpx;
  416. &-left {
  417. font-family: PingFangSC, PingFang SC;
  418. font-weight: 400;
  419. font-size: 24rpx;
  420. color: #667e90;
  421. line-height: 24rpx;
  422. }
  423. &-right {
  424. border-radius: 32rpx;
  425. background: linear-gradient(90deg, #33a7a7 0%, #4db2b2 100%);
  426. padding: 19rpx 22rpx;
  427. font-family: PingFangSC, PingFang SC;
  428. font-weight: 400;
  429. font-size: 26rpx;
  430. color: #ffffff;
  431. line-height: 26rpx;
  432. letter-spacing: 2rpx;
  433. }
  434. }
  435. }
  436. }
  437. .empty {
  438. flex: 1;
  439. }
  440. .dialog {
  441. position: fixed;
  442. left: 0;
  443. right: 0;
  444. top: 0;
  445. bottom: 0;
  446. background: rgba(0, 0, 0, 0.4);
  447. z-index: 1001;
  448. justify-content: flex-end;
  449. .dbox {
  450. width: 100%;
  451. height: 738rpx;
  452. background: #ffffff;
  453. box-shadow: 0rpx -2rpx 6rpx 0rpx rgba(0, 0, 0, 0.07);
  454. border-radius: 24rpx 24rpx 0rpx 0rpx;
  455. padding: 48rpx 30rpx 0;
  456. box-sizing: border-box;
  457. &-top {
  458. &-title {
  459. width: calc(100% - 60rpx);
  460. font-family: PingFang-SC, PingFang-SC;
  461. font-weight: bold;
  462. font-size: 32rpx;
  463. color: #002846;
  464. line-height: 40rpx;
  465. }
  466. &-expand {
  467. width: 32rpx;
  468. height: 32rpx;
  469. transform: rotate(180deg);
  470. }
  471. }
  472. &-name {
  473. font-family: PingFangSC, PingFang SC;
  474. font-weight: 400;
  475. font-size: 24rpx;
  476. color: #667e90;
  477. line-height: 24rpx;
  478. margin-top: 24rpx;
  479. }
  480. &-progress {
  481. margin-top: 36rpx;
  482. &-left {
  483. width: calc(100% - 95rpx);
  484. &-text {
  485. font-family: PingFangSC, PingFang SC;
  486. font-weight: 400;
  487. font-size: 24rpx;
  488. color: #667e90;
  489. line-height: 24rpx;
  490. }
  491. &-box {
  492. flex: 1;
  493. position: relative;
  494. height: 12rpx;
  495. background: #f0f2f8;
  496. border-radius: 6rpx;
  497. &-current {
  498. height: 12rpx;
  499. background: #7cc5c5;
  500. border-radius: 6rpx;
  501. position: absolute;
  502. top: 0;
  503. left: 0;
  504. }
  505. }
  506. }
  507. &-right {
  508. font-size: 24rpx;
  509. line-height: 24rpx;
  510. color: #95a5b1;
  511. span {
  512. font-size: 24rpx;
  513. line-height: 24rpx;
  514. color: #002846;
  515. }
  516. }
  517. }
  518. &-menu {
  519. margin-top: 43rpx;
  520. overflow: hidden;
  521. margin-left: -30rpx;
  522. &-pre {
  523. width: calc(25% - 30rpx);
  524. background: #f7f8fa;
  525. border-radius: 24rpx;
  526. padding: 30rpx 20rpx;
  527. margin-top: 24rpx;
  528. margin-left: 30rpx;
  529. box-sizing: border-box;
  530. float: left;
  531. image {
  532. width: 42rpx;
  533. height: 42rpx;
  534. }
  535. text {
  536. font-family: PingFangSC, PingFang SC;
  537. font-weight: 400;
  538. font-size: 24rpx;
  539. color: #002846;
  540. line-height: 24rpx;
  541. text-align: center;
  542. margin-top: 24rpx;
  543. }
  544. }
  545. }
  546. }
  547. &-box {
  548. width: 100%;
  549. height: 1200rpx;
  550. background: #f7f7f7;
  551. padding-top: 38rpx;
  552. border-radius: 24rpx 24rpx 0rpx 0rpx;
  553. box-sizing: border-box;
  554. position: relative;
  555. overflow-y: auto;
  556. &-title {
  557. font-family: PingFang-SC, PingFang-SC;
  558. font-weight: bold;
  559. font-size: 32rpx;
  560. color: #002846;
  561. line-height: 32rpx;
  562. text-align: center;
  563. }
  564. &-close {
  565. width: 48rpx;
  566. height: 48rpx;
  567. position: absolute;
  568. top: 30rpx;
  569. right: 30rpx;
  570. }
  571. &-teaminfo {
  572. margin-top: 40rpx;
  573. }
  574. }
  575. }
  576. .alert {
  577. position: fixed;
  578. left: 0;
  579. right: 0;
  580. top: 0;
  581. bottom: 0;
  582. z-index: 1002;
  583. background: rgba(0, 0, 0, 0.4);
  584. &-box {
  585. width: calc(100% - 100rpx);
  586. padding: 54rpx 99rpx 48rpx;
  587. box-sizing: border-box;
  588. position: relative;
  589. background: url('https://gitee.com/hw_0302/chuang-heng-wechat-images/raw/master/alert_bg.png') no-repeat;
  590. background-size: 100% 100%;
  591. &-title {
  592. font-family: PingFang-SC, PingFang-SC;
  593. font-weight: bold;
  594. font-size: 36rpx;
  595. color: #002846;
  596. line-height: 56rpx;
  597. text-align: center;
  598. }
  599. &-close {
  600. width: 48rpx;
  601. height: 48rpx;
  602. position: absolute;
  603. top: 40rpx;
  604. right: 30rpx;
  605. }
  606. &-text {
  607. font-family: PingFangSC, PingFang SC;
  608. font-weight: 400;
  609. font-size: 30rpx;
  610. color: #002846;
  611. line-height: 48rpx;
  612. text-align: center;
  613. margin-top: 32rpx;
  614. }
  615. .zt_btn {
  616. margin-top: 66rpx;
  617. }
  618. }
  619. }
  620. }
  621. </style>