questionnaireEdit.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389
  1. <template>
  2. <view class="default_page" :style="{'min-height':h+'px', 'padding-top':mt+'px'}">
  3. <cus-header :title='title'></cus-header>
  4. <view class="box adfacjb" style="padding: 32rpx 24rpx 40rpx;">
  5. <view class="box-left">
  6. <view class="box-title">问卷名称</view>
  7. <view class="box-tip" style="margin-top: 32rpx;">{{questionnaireName}}</view>
  8. </view>
  9. <view class="box-right adfac" @click="handlePreview">
  10. <text>预览</text>
  11. <image :src="imgBase+'my_arrow_right.png'"></image>
  12. </view>
  13. </view>
  14. <view class="box" style="padding: 32rpx 24rpx;" @click="showTeam">
  15. <view class="box-title">选择团队</view>
  16. <view class="box-team adfacjb" @click="showTeam">
  17. <view class="box-tip">{{teamName}}</view>
  18. <image :src="imgBase+'my_arrow_right.png'"></image>
  19. </view>
  20. </view>
  21. <view class="box" style="padding: 32rpx 24rpx 0;">
  22. <view class="box-title">问卷作答时间设置</view>
  23. <view class="box-time adfacjb" style="margin-top: 32rpx;" @click="startShow=true">
  24. <view class="box-time-left">开始时间</view>
  25. <view class="box-time-right adfac">
  26. <text>{{dto.startTime}}</text>
  27. <image :src="imgBase+'my_arrow_right.png'"></image>
  28. </view>
  29. </view>
  30. <view class="box-time adfacjb" @click="endShow=true">
  31. <view class="box-time-left">截止时间</view>
  32. <view class="box-time-right adfac">
  33. <text>{{dto.endTime}}</text>
  34. <image :src="imgBase+'my_arrow_right.png'"></image>
  35. </view>
  36. </view>
  37. </view>
  38. <view class="box" style="padding: 32rpx 24rpx 18rpx;">
  39. <view class="box-title adfacjb">
  40. <text>限制每位用户提交次数</text>
  41. <u-switch v-model="limit" activeColor="#199C9C" size="38"></u-switch>
  42. </view>
  43. <view class="box-num adfacjb" v-if="limit">
  44. <view class="box-num-title">可提交次数</view>
  45. <view class="box-num-right">
  46. <cus-number-box ref="cnbRef" :min="1" :number="dto.answerSetting" @valChange="valChange"></cus-number-box>
  47. </view>
  48. </view>
  49. </view>
  50. <view class="box" style="padding: 30rpx 24rpx 0;" v-if="type>1">
  51. <view class="box-title adfacjb" style="margin-bottom: 21rpx;">
  52. <text>团队人员</text>
  53. <view class="box-add" @click="addTeamUser">+ 添加</view>
  54. </view>
  55. <view class="box-user">
  56. <view class="box-user-item adfacjb" v-for="(item,index) in dto.memberList" :key="index">
  57. <view class="box-user-item-left">
  58. <view class="box-user-item-left-name adfac">
  59. <text>{{item.realName}}</text>
  60. <view class="type">{{item.categoryName}}</view>
  61. </view>
  62. <view class="box-user-item-left-email">{{item.email}}</view>
  63. </view>
  64. <image class="box-user-item-right" :src="imgBase+'icon_delete.png'" @click="deleteTeamUser(item,index)"></image>
  65. </view>
  66. </view>
  67. </view>
  68. <view class="bottom">
  69. <view class="zt_btn" @click="confirmPublish">{{confirmText}}</view>
  70. </view>
  71. <cus-select :show="teamShow" :list="teamList" :addShow="true"
  72. @close="teamShow=false" @addTeam="addTeam" @confirmTeam="confirmTeam"></cus-select>
  73. <u-datetime-picker ref="datetimePicker1" title="开始时间" :minDate="minStartTime" itemHeight="88" :show="startShow" mode="datetime" :formatter="formatter" @cancel="startShow=false" @confirm="startConfirm"></u-datetime-picker>
  74. <u-datetime-picker ref="datetimePicker2" title="结束时间" :minDate="minEndTime" itemHeight="88" :show="endShow" mode="datetime" :formatter="formatter" @cancel="endShow=false" @confirm="endConfirm"></u-datetime-picker>
  75. </view>
  76. </template>
  77. <script>
  78. import CusNumberBox from '@/components/CusNumberBox/index.vue'
  79. import CusSelect from '@/components/CusSelect/index.vue'
  80. export default {
  81. components:{ CusNumberBox, CusSelect },
  82. data(){
  83. return {
  84. id:'',
  85. type:'',
  86. title:'编辑问卷',
  87. confirmText:'保存',
  88. questionnaireId:'',
  89. questionnaireName:'',
  90. limit:true,
  91. teamShow:false,
  92. startShow:false,
  93. endShow:false,
  94. dto:{
  95. memberList:[]
  96. },
  97. teamName:'请选择团队',
  98. teamList:[],
  99. minStartTime:new Date().getTime(),
  100. minEndTime:''
  101. }
  102. },
  103. onReady() {
  104. this.$refs.datetimePicker1.setFormatter(this.formatter)
  105. this.$refs.datetimePicker2.setFormatter(this.formatter)
  106. },
  107. onLoad(options) {
  108. this.teamQuestionnaireId = options.teamQuestionnaireId;
  109. this.questionnaireId = options.questionnaireId;
  110. this.questionnaireName = options.questionnaireName;
  111. this.type = options.type;
  112. if(this.type==2){
  113. this.title = '发布问卷';
  114. this.confirmText = '确认发布';
  115. this.dto.answerSetting = 1;
  116. }else if(this.type==1) this.getDetail()
  117. },
  118. methods:{
  119. formatter(type, value) {
  120. if (type === 'year') {
  121. return `${value}年`
  122. }
  123. if (type === 'month') {
  124. return `${value}月`
  125. }
  126. if (type === 'day') {
  127. return `${value}日`
  128. }
  129. return value
  130. },
  131. valChange(e){
  132. this.dto.answerSetting = e;
  133. },
  134. getDetail(){
  135. this.$api.get('/core/team/questionnaire/'+this.teamQuestionnaireId).then(({data:res})=>{
  136. if(res.code!==0) return this.$showToast(res.msg)
  137. this.dto = {...this.dto,...res.data}
  138. this.questionnaireId = this.dto.questionnaireId;
  139. this.$refs.cnbRef.value = this.dto.answerSetting;
  140. this.teamName = res.data.teamName;
  141. })
  142. },
  143. showTeam(){
  144. this.teamShow = true;
  145. this.$api.get('/core/user/team/page',{
  146. page:1,
  147. limit:-1,
  148. coachId:JSON.parse(uni.getStorageSync('userInfo')).id
  149. }).then(({data:res})=>{
  150. if(res.code!==0) return this.$showToast(res.msg)
  151. this.teamList = res.data.list;
  152. this.teamList.forEach(t=>t.name=t.teamName)
  153. })
  154. },
  155. handlePreview(){
  156. uni.navigateTo({
  157. url:`/pagesPublish/questionnairePreview?questionnaireName=${this.questionnaireName}&teamQuestionnaireId=${this.teamQuestionnaireId}&type=${this.type}`
  158. })
  159. },
  160. addTeam(){
  161. uni.navigateTo({
  162. url:'/pagesPublish/fillTeamInfo?type=add&questionnaireId='+this.questionnaireId,
  163. events:{
  164. saveTeamInfo: data =>{
  165. this.$api.get('/core/user/team/page',{
  166. page:1,
  167. limit:-1,
  168. coachId:JSON.parse(uni.getStorageSync('userInfo')).id
  169. }).then(({data:res})=>{
  170. if(res.code!==0) return this.$showToast(res.msg)
  171. this.teamList = res.data.list;
  172. this.teamList.forEach(t=>t.name=t.teamName)
  173. })
  174. }
  175. }
  176. })
  177. },
  178. addTeamUser(){
  179. uni.navigateTo({
  180. url:'/pagesMy/teamUser?type=select',
  181. events:{
  182. selectUserConfirm: data => {
  183. this.dto.memberList = data;
  184. }
  185. }
  186. })
  187. },
  188. deleteTeamUser(item,index){
  189. this.dto.memberList.splice(index,1);
  190. },
  191. confirmTeam(item){
  192. this.teamName = item.teamName;
  193. this.dto.teamId = item.id;
  194. this.teamShow = false;
  195. },
  196. startConfirm(e){
  197. this.dto.startTime = new Date(e.value).Format('yyyy-MM-dd hh:mm:ss');
  198. this.minEndTime = e.value;
  199. this.startShow = false;
  200. },
  201. endConfirm(e){
  202. this.dto.endTime = new Date(e.value).Format('yyyy-MM-dd hh:mm:ss');
  203. this.endShow = false;
  204. },
  205. confirmPublish(){
  206. let params = JSON.parse(JSON.stringify(this.dto));
  207. params.coachId = JSON.parse(uni.getStorageSync('userInfo')).id;
  208. params.type = this.type;
  209. if(!params?.teamId) return this.$showToast('请选择团队')
  210. if(!params?.startTime) return this.$showToast('请选择开始时间')
  211. if(!params?.endTime) return this.$showToast('请选择结束时间')
  212. if(params?.memberList.length==0) return this.$showToast('请选择团队人员')
  213. let url = '/core/team/questionnaire';
  214. if(this.type==2){
  215. url = '/core/team/questionnaire/publish';
  216. params.questionnaireId = this.questionnaireId
  217. }
  218. this.$api[this.type==2?'post':'put'](url,params).then(({data:res})=>{
  219. if(res.code!==0) return this.$showToast(res.msg)
  220. if(this.type==2){
  221. uni.navigateTo({ url:'/pagesPublish/publishResult?title='+this.questionnaireName })
  222. }else uni.navigateBack()
  223. })
  224. }
  225. }
  226. }
  227. </script>
  228. <style scoped lang="scss">
  229. .default_page{
  230. padding: 0 24rpx 182rpx;
  231. box-sizing: border-box;
  232. .box{
  233. background: #FFFFFF;
  234. box-shadow: inset 0rpx -1rpx 0rpx 0rpx rgba(229,231,235,0.5);
  235. border-radius: 24rpx;
  236. margin-top: 20rpx;
  237. overflow: hidden;
  238. &-title,&-title>text{
  239. font-family: PingFang-SC, PingFang-SC;
  240. font-weight: bold;
  241. font-size: 32rpx;
  242. color: #002846;
  243. line-height: 32rpx;
  244. }
  245. &-tip{
  246. font-family: PingFangSC, PingFang SC;
  247. font-weight: 400;
  248. font-size: 30rpx;
  249. color: #667E90;
  250. line-height: 32rpx;
  251. overflow: hidden;
  252. text-overflow: ellipsis;
  253. white-space: nowrap;
  254. }
  255. &-left{
  256. width: calc(100% - 150rpx);
  257. }
  258. &-right{
  259. &>text{
  260. font-family: PingFangSC, PingFang SC;
  261. font-weight: 400;
  262. font-size: 26rpx;
  263. color: #33A7A7;
  264. line-height: 32rpx;
  265. }
  266. &>image{
  267. width: 32rpx;
  268. height: 32rpx;
  269. margin-left: 10rpx;
  270. }
  271. }
  272. &-team{
  273. margin-top: 31rpx;
  274. &>image{
  275. width: 36rpx;
  276. height: 36rpx;
  277. }
  278. }
  279. &-time{
  280. padding: 33rpx 0;
  281. box-shadow: inset 0rpx -1rpx 0rpx 0rpx rgba(229,231,235,0.5);
  282. &-left{
  283. font-family: PingFangSC, PingFang SC;
  284. font-weight: 400;
  285. font-size: 30rpx;
  286. color: #002846;
  287. line-height: 32rpx;
  288. }
  289. &-right{
  290. &>text{
  291. font-family: PingFangSC, PingFang SC;
  292. font-weight: 400;
  293. font-size: 30rpx;
  294. color: #667E90;
  295. line-height: 32rpx;
  296. }
  297. &>image{
  298. width: 36rpx;
  299. height: 36rpx;
  300. margin-left: 10rpx;
  301. }
  302. }
  303. }
  304. &-num{
  305. margin-top: 65rpx;
  306. &-left{
  307. font-family: PingFangSC, PingFang SC;
  308. font-weight: 400;
  309. font-size: 30rpx;
  310. color: #002846;
  311. line-height: 32rpx;
  312. }
  313. }
  314. &-add{
  315. width: 120rpx;
  316. height: 54rpx;
  317. border-radius: 27rpx;
  318. border: 1rpx solid #33A7A7;
  319. font-family: PingFang-SC, PingFang-SC;
  320. font-weight: bold;
  321. font-size: 24rpx;
  322. color: #33A7A7;
  323. line-height: 54rpx;
  324. text-align: center;
  325. }
  326. &-user{
  327. &-item{
  328. box-shadow: inset 0rpx -1rpx 0rpx 0rpx #EFEFEF;
  329. border-radius: 24rpx;
  330. padding: 30rpx 0 36rpx;
  331. &-left{
  332. &-name{
  333. text{
  334. font-family: PingFangSC, PingFang SC;
  335. font-weight: 400;
  336. font-size: 30rpx;
  337. color: #002846;
  338. line-height: 32rpx;
  339. }
  340. .type{
  341. background: #FFF7DC;
  342. border-radius: 21rpx;
  343. margin-left: 20rpx;
  344. padding: 5rpx 16rpx;
  345. font-family: PingFangSC, PingFang SC;
  346. font-weight: 400;
  347. font-size: 22rpx;
  348. color: #BA9B31;
  349. line-height: 30rpx;
  350. text-align: center;
  351. }
  352. }
  353. &-email{
  354. font-family: PingFangSC, PingFang SC;
  355. font-weight: 400;
  356. font-size: 28rpx;
  357. color: #667E90;
  358. line-height: 28rpx;
  359. margin-top: 20rpx;
  360. }
  361. }
  362. &-right{
  363. width: 36rpx;
  364. height: 36rpx;
  365. }
  366. }
  367. }
  368. }
  369. .bottom{
  370. width: 100%;
  371. height: 162rpx;
  372. background: #FFFFFF;
  373. padding: 20rpx 50rpx;
  374. box-sizing: border-box;
  375. position: fixed;
  376. left: 0;
  377. bottom: 0;
  378. z-index: 888;
  379. }
  380. }
  381. </style>