questionnaireEdit.vue 9.7 KB

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