questionnaireEdit.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369
  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">
  31. <view class="box-time-left">截止时间</view>
  32. <view class="box-time-right adfac" @click="endShow=true">
  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">
  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.memberInfos" :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">{{'赞助人Sponsor'}}</view>
  61. </view>
  62. <view class="box-user-item-left-email">{{'123456789@qq.com'}}</view>
  63. </view>
  64. <image class="box-user-item-right" :src="imgBase+'icon_delete.png'"></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. teamName:'请选择团队',
  96. teamList:[],
  97. minStartTime:new Date().getTime(),
  98. minEndTime:''
  99. }
  100. },
  101. onReady() {
  102. this.$refs.datetimePicker1.setFormatter(this.formatter)
  103. this.$refs.datetimePicker2.setFormatter(this.formatter)
  104. },
  105. onLoad(options) {
  106. this.teamQuestionnaireId = options.teamQuestionnaireId;
  107. this.questionnaireId = options.questionnaireId;
  108. this.questionnaireName = options.questionnaireName;
  109. this.type = options.type;
  110. if(this.type==2){
  111. this.title = '发布问卷';
  112. this.confirmText = '确认发布';
  113. }else if(this.type==1) this.getDetail()
  114. },
  115. methods:{
  116. formatter(type, value) {
  117. if (type === 'year') {
  118. return `${value}年`
  119. }
  120. if (type === 'month') {
  121. return `${value}月`
  122. }
  123. if (type === 'day') {
  124. return `${value}日`
  125. }
  126. return value
  127. },
  128. valChange(e){
  129. this.dto.answerSetting = e;
  130. },
  131. getDetail(){
  132. this.$api.get('/core/team/questionnaire/'+this.teamQuestionnaireId).then(({data:res})=>{
  133. if(res.code!==0) return this.$showToast(res.msg)
  134. this.dto = {...this.dto,...res.data}
  135. this.questionnaireId = this.dto.questionnaireId;
  136. this.$refs.cnbRef.value = this.dto.answerSetting;
  137. this.teamName = res.data.teamName;
  138. })
  139. },
  140. showTeam(){
  141. this.teamShow = true;
  142. this.$api.get('/core/user/team/page',{
  143. page:1,
  144. limit:-1,
  145. coachId:JSON.parse(uni.getStorageSync('userInfo')).id
  146. }).then(({data:res})=>{
  147. if(res.code!==0) return this.$showToast(res.msg)
  148. this.teamList = res.data.list;
  149. this.teamList.forEach(t=>t.name=t.teamName)
  150. })
  151. },
  152. handlePreview(){
  153. uni.navigateTo({
  154. url:`/pagesPublish/questionnairePreview?questionnaireName=${this.questionnaireName}&teamQuestionnaireId=${this.teamQuestionnaireId}&type=${this.type}`
  155. })
  156. },
  157. addTeam(){
  158. uni.navigateTo({
  159. url:'/pagesPublish/fillTeamInfo?type=add&questionnaireId='+this.questionnaireId,
  160. events:{
  161. saveTeamInfo: data =>{
  162. this.$api.get('/core/user/team/page',{
  163. page:1,
  164. limit:-1,
  165. coachId:JSON.parse(uni.getStorageSync('userInfo')).id
  166. }).then(({data:res})=>{
  167. if(res.code!==0) return this.$showToast(res.msg)
  168. this.teamList = res.data.list;
  169. this.teamList.forEach(t=>t.name=t.teamName)
  170. })
  171. }
  172. }
  173. })
  174. },
  175. addTeamUser(){
  176. },
  177. confirmTeam(item){
  178. this.teamName = item.teamName;
  179. this.dto.teamId = item.id;
  180. this.teamShow = false;
  181. },
  182. startConfirm(e){
  183. this.dto.startTime = new Date(e.value).Format('yyyy-MM-dd hh:mm:ss');
  184. this.minEndTime = e.value;
  185. this.startShow = false;
  186. },
  187. endConfirm(e){
  188. this.dto.endTime = new Date(e.value).Format('yyyy-MM-dd hh:mm:ss');
  189. this.endShow = false;
  190. },
  191. confirmPublish(){
  192. let params = JSON.parse(JSON.stringify(this.dto));
  193. params.coachId = JSON.parse(uni.getStorageSync('userInfo')).id;
  194. params.type = this.type;
  195. let url = '/core/team/questionnaire';
  196. if(this.type==2){
  197. url = '/core/team/questionnaire/publish';
  198. }
  199. this.$api[this.type==2?'post':'put'](url,params).then(({data:res})=>{
  200. if(res.code!==0) return this.$showToast(res.msg)
  201. if(this.type==2){
  202. uni.navigateTo({ url:'/pagesPublish/publishResult' })
  203. }else uni.navigateBack()
  204. })
  205. }
  206. }
  207. }
  208. </script>
  209. <style scoped lang="scss">
  210. .default_page{
  211. padding: 0 24rpx 182rpx;
  212. box-sizing: border-box;
  213. .box{
  214. background: #FFFFFF;
  215. box-shadow: inset 0rpx -1rpx 0rpx 0rpx rgba(229,231,235,0.5);
  216. border-radius: 24rpx;
  217. margin-top: 20rpx;
  218. &-title,&-title>text{
  219. font-family: PingFang-SC, PingFang-SC;
  220. font-weight: bold;
  221. font-size: 32rpx;
  222. color: #002846;
  223. line-height: 32rpx;
  224. }
  225. &-tip{
  226. font-family: PingFangSC, PingFang SC;
  227. font-weight: 400;
  228. font-size: 30rpx;
  229. color: #667E90;
  230. line-height: 32rpx;
  231. overflow: hidden;
  232. text-overflow: ellipsis;
  233. white-space: nowrap;
  234. }
  235. &-left{
  236. width: calc(100% - 150rpx);
  237. }
  238. &-right{
  239. &>text{
  240. font-family: PingFangSC, PingFang SC;
  241. font-weight: 400;
  242. font-size: 26rpx;
  243. color: #33A7A7;
  244. line-height: 32rpx;
  245. }
  246. &>image{
  247. width: 32rpx;
  248. height: 32rpx;
  249. margin-left: 10rpx;
  250. }
  251. }
  252. &-team{
  253. margin-top: 31rpx;
  254. &>image{
  255. width: 36rpx;
  256. height: 36rpx;
  257. }
  258. }
  259. &-time{
  260. padding: 33rpx 0;
  261. box-shadow: inset 0rpx -1rpx 0rpx 0rpx rgba(229,231,235,0.5);
  262. &-left{
  263. font-family: PingFangSC, PingFang SC;
  264. font-weight: 400;
  265. font-size: 30rpx;
  266. color: #002846;
  267. line-height: 32rpx;
  268. }
  269. &-right{
  270. &>text{
  271. font-family: PingFangSC, PingFang SC;
  272. font-weight: 400;
  273. font-size: 30rpx;
  274. color: #667E90;
  275. line-height: 32rpx;
  276. }
  277. &>image{
  278. width: 36rpx;
  279. height: 36rpx;
  280. margin-left: 10rpx;
  281. }
  282. }
  283. }
  284. &-num{
  285. margin-top: 65rpx;
  286. &-left{
  287. font-family: PingFangSC, PingFang SC;
  288. font-weight: 400;
  289. font-size: 30rpx;
  290. color: #002846;
  291. line-height: 32rpx;
  292. }
  293. }
  294. &-add{
  295. width: 120rpx;
  296. height: 54rpx;
  297. border-radius: 27rpx;
  298. border: 1rpx solid #33A7A7;
  299. font-family: PingFang-SC, PingFang-SC;
  300. font-weight: bold;
  301. font-size: 24rpx;
  302. color: #33A7A7;
  303. line-height: 54rpx;
  304. text-align: center;
  305. }
  306. &-user{
  307. margin-top: 21rpx;
  308. &-item{
  309. box-shadow: inset 0rpx -1rpx 0rpx 0rpx #EFEFEF;
  310. border-radius: 24rpx;
  311. padding: 30rpx 0 36rpx;
  312. &-left{
  313. &-name{
  314. text{
  315. font-family: PingFangSC, PingFang SC;
  316. font-weight: 400;
  317. font-size: 30rpx;
  318. color: #002846;
  319. line-height: 32rpx;
  320. }
  321. .type{
  322. background: #F8F4F8;
  323. border-radius: 21rpx;
  324. margin-left: 20rpx;
  325. padding: 5rpx 16rpx;
  326. font-family: PingFangSC, PingFang SC;
  327. font-weight: 400;
  328. font-size: 22rpx;
  329. color: #9F6196;
  330. line-height: 30rpx;
  331. text-align: center;
  332. }
  333. }
  334. &-email{
  335. font-family: PingFangSC, PingFang SC;
  336. font-weight: 400;
  337. font-size: 28rpx;
  338. color: #667E90;
  339. line-height: 28rpx;
  340. margin-top: 20rpx;
  341. }
  342. }
  343. &-right{
  344. width: 36rpx;
  345. height: 36rpx;
  346. }
  347. }
  348. }
  349. }
  350. .bottom{
  351. width: 100%;
  352. height: 162rpx;
  353. background: #FFFFFF;
  354. padding: 20rpx 50rpx;
  355. box-sizing: border-box;
  356. position: fixed;
  357. left: 0;
  358. bottom: 0;
  359. z-index: 888;
  360. }
  361. }
  362. </style>