CourseDetail.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330
  1. <template>
  2. <div class="courseEvaluation">
  3. <MHeader v-if="headerStatus" />
  4. <van-cell-group>
  5. <van-cell title="课程班名称" :value="teacherClassHeadInfo.classGroupName" />
  6. </van-cell-group>
  7. <van-cell-group>
  8. <van-cell title="课程时间" :value="teacherClassHeadInfo.classTime" />
  9. </van-cell-group>
  10. <van-cell-group>
  11. <van-cell title="乐器" :value="teacherClassHeadInfo.subjectNames" />
  12. </van-cell-group>
  13. <van-cell-group>
  14. <van-cell title="班级学员" :value="teacherClassHeadInfo.studentNames" />
  15. </van-cell-group>
  16. <van-cell-group>
  17. <van-field class="textarea" maxlength="255" autosize label="教学内容" type="textarea" v-model="teachingMaterial" :readonly="teachingMaterialStatus" placeholder="请输入1-255字" />
  18. </van-cell-group>
  19. <div v-if="courseScheduleComplaints.length > 0">
  20. <div class="title">学员评价</div>
  21. <div class="evaluation-item" v-for="(item, index) in courseScheduleComplaints" :key="index">
  22. <div class="header">
  23. <img v-if="item.avatar" :src="item.avatar" alt="">
  24. <img v-else src="../../assets/images/app/icon_student.png" alt="">
  25. {{ item.username }}
  26. </div>
  27. <div class="rate">评价<van-rate v-model="item.score" readonly :size="20" /></div>
  28. <div class="content">
  29. {{ item.reason }}
  30. </div>
  31. </div>
  32. </div>
  33. <div class="title" :class="[courseScheduleComplaints.length > 0 ? 'teacher' : '']">老师评价</div>
  34. <div v-if="courseScheduleReviewList.length > 0">
  35. <van-panel v-for="(item, index) in courseScheduleReviewList" :key="index">
  36. <div slot="header" class="van-hairline--bottom" style="display: flex;">
  37. <div class="header">
  38. <img v-if="item.studentAvatar" :src="item.studentAvatar" alt="">
  39. <img v-else src="../../assets/images/app/icon_student.png" alt="">{{ item.studentName }}
  40. </div>
  41. </div>
  42. <div slot="default" class="content">{{ item.memo }}</div>
  43. </van-panel>
  44. </div>
  45. <div v-else>
  46. <van-cell center title="是否对所有学生评价">
  47. <van-switch v-model="checked" slot="right-icon" />
  48. </van-cell>
  49. <van-panel title="评论给所有学生" class="evaluation-panel" v-if="checked">
  50. <div slot="default">
  51. <van-field rows="3" maxlength="255" v-model="contentall" autosize type="textarea" placeholder="请输入1-255字" />
  52. </div>
  53. </van-panel>
  54. <div v-else>
  55. <van-panel class="evaluation-panel" v-for="(item, index) in students" :key="index">
  56. <div slot="header" class="van-hairline--bottom" style="display: flex; padding-left: .16rem">
  57. <div class="header">
  58. <img v-if="item.avatar" :src="item.avatar" alt="">
  59. <img v-else src="../../assets/images/app/icon_student.png" alt="">
  60. {{ item.username }}
  61. </div>
  62. </div>
  63. <div slot="default">
  64. <van-field rows="3" v-model="item.content" autosize type="textarea" placeholder="请输入1-255字" />
  65. </div>
  66. </van-panel>
  67. </div>
  68. </div>
  69. <div class="button-group" v-if="courseScheduleReviewList.length <= 0">
  70. <van-button type="primary" @click="onSubmit" round size="large">确认</van-button>
  71. </div>
  72. </div>
  73. </template>
  74. <script>
  75. /* eslint-disable */
  76. import MHeader from '@/components/MHeader'
  77. import { getStuAndTeaReview, batchAdd } from '@/api/app'
  78. import { browser } from '@/common/common'
  79. export default {
  80. name: 'courseEvaluation',
  81. components: { MHeader },
  82. data () {
  83. let query = this.$route.query
  84. return {
  85. headerStatus: false,
  86. checked: true,
  87. courseId: query.courseId,
  88. teachingMaterial: null,
  89. teachingMaterialStatus: false,
  90. teacherClassHeadInfo: {},
  91. courseScheduleReview: [], // 学生评价
  92. courseScheduleComplaints: [], // 老师评价
  93. courseScheduleReviewList: [],
  94. review4StudentIds: {},
  95. students: [], // 学生列表
  96. contentall: null, // 回复内容
  97. }
  98. },
  99. mounted() {
  100. let params = this.$route.query
  101. if(params.Authorization) {
  102. localStorage.setItem('Authorization', decodeURI(params.Authorization))
  103. localStorage.setItem('userInfo', decodeURI(params.Authorization))
  104. }
  105. // 判断是否在app里面
  106. if(!browser().android && !browser().iPhone) {
  107. this.headerStatus = true
  108. } else {
  109. document.title = '课程评价'
  110. }
  111. this.__init()
  112. },
  113. methods: {
  114. __init() {
  115. this.$toast.loading({
  116. duration: 0,
  117. message: '加载中...',
  118. forbidClick: true,
  119. loadingType: 'spinner'
  120. })
  121. getStuAndTeaReview({ courseId: this.courseId}).then(res => {
  122. let result = res.data
  123. this.$toast.clear()
  124. if(result.code == 200) {
  125. let tempResult = result.data
  126. if(tempResult) {
  127. this.teachingMaterial = tempResult.teachingMaterial
  128. this.teachingMaterialStatus = tempResult.teachingMaterial ? true : false
  129. this.teacherClassHeadInfo = tempResult.teacherClassHeadInfo ? tempResult.teacherClassHeadInfo : {}
  130. if(this.teacherClassHeadInfo.classDate) {
  131. this.teacherClassHeadInfo.classTime = this.teacherClassHeadInfo.classDate + ' ' + this.teacherClassHeadInfo.startClassTime + '-' + this.teacherClassHeadInfo.endClassTime
  132. }
  133. this.courseScheduleReview = tempResult.courseScheduleReview ? tempResult.courseScheduleReview : []
  134. this.courseScheduleComplaints = tempResult.courseScheduleComplaints ? tempResult.courseScheduleComplaints : []
  135. this.courseScheduleReviewList = tempResult.courseScheduleReviewList ? tempResult.courseScheduleReviewList : []
  136. this.review4StudentIds = tempResult.review4StudentIds ? tempResult.review4StudentIds : {}
  137. this.students = tempResult.students ? tempResult.students : []
  138. tempResult.students.forEach(item => {
  139. item.content = null
  140. })
  141. }
  142. } else {
  143. this.$toast(result.msg)
  144. }
  145. })
  146. },
  147. onSubmit() {
  148. let students = this.students
  149. let params = []
  150. if(!this.teachingMaterial) {
  151. this.$toast('请输入教学内容')
  152. return
  153. }
  154. if(!this.contentall && this.checked) {
  155. this.$toast('请输入学生评价')
  156. return
  157. }
  158. students.forEach(item => {
  159. if(!this.checked && !item.content) {
  160. this.$toast('请输入学生评价')
  161. return
  162. }
  163. params.push({
  164. "memo": this.checked ? this.contentall : item.content,
  165. "courseScheduleId": this.courseId,
  166. "studentId": item.id,
  167. "teachingMaterial": this.teachingMaterial
  168. })
  169. })
  170. this.$toast.loading({
  171. duration: 0,
  172. message: '加载中...',
  173. forbidClick: true,
  174. loadingType: 'spinner'
  175. })
  176. batchAdd(params).then(res => {
  177. this.$toast.clear()
  178. let result = res.data
  179. if(result.code == 200) {
  180. this.$toast('评价成功')
  181. setTimeout(() => {
  182. this.onSubmitStatus = true
  183. if(browser().iPhone) {
  184. window.webkit.messageHandlers.DAYA.postMessage(JSON.stringify({api: 'back'}))
  185. } else if(browser().android) {
  186. DAYA.postMessage(JSON.stringify({api: 'back'}))
  187. } else {
  188. this.$router.push('/business')
  189. }
  190. }, 500)
  191. } else {
  192. this.$toast(result.msg)
  193. }
  194. })
  195. }
  196. },
  197. destroyed() {
  198. this.$toast.clear()
  199. }
  200. }
  201. </script>
  202. <style lang="less" scoped>
  203. @import url("../../assets/commonLess/variable.less");
  204. .courseEvaluation {
  205. position: relative;
  206. min-height: 100vh;
  207. }
  208. /deep/.van-cell-group {
  209. margin-top: .15rem;
  210. /deep/.van-cell {
  211. padding: .14rem .16rem;
  212. }
  213. }
  214. /deep/.van-cell__title {
  215. font-size: .17rem;
  216. color: #1A1A1A;
  217. flex: auto 1;
  218. }
  219. /deep/.van-field__control, /deep/.van-cell__value {
  220. font-size: 0.17rem;
  221. color: #666;
  222. width: 70%;
  223. flex: auto;
  224. }
  225. .textarea {
  226. flex-direction: column;
  227. /deep/.van-cell__value {
  228. margin-top: .1rem;
  229. width: 100%;
  230. }
  231. /deep/.van-field__control {
  232. font-size: .15rem;
  233. }
  234. }
  235. .title {
  236. font-size: .16rem;
  237. color: #808080;
  238. line-height: .22rem;
  239. padding: .15rem .16rem .1rem;
  240. &.teacher {
  241. padding-top: 0;
  242. }
  243. }
  244. .evaluation-item {
  245. background-color: #fff;
  246. margin-bottom: .15rem;
  247. padding: .12rem .16rem;
  248. img {
  249. width: .4rem;
  250. height: .4rem;
  251. border-radius: 50%;
  252. overflow: hidden;
  253. margin-right: .08rem;
  254. }
  255. .header {
  256. display: flex;
  257. align-items: center;
  258. font-size: .18rem;
  259. color: #1A1A1A;
  260. }
  261. .rate {
  262. font-size: .14rem;
  263. color: #333333;
  264. display: flex;
  265. padding: .1rem 0;
  266. .van-rate {
  267. margin-left: .05rem;
  268. }
  269. }
  270. .content {
  271. font-size: .15rem;
  272. color: #666666;
  273. }
  274. }
  275. .van-panel {
  276. padding: .12rem .16rem;
  277. margin-top: 0;
  278. margin-bottom: .15rem;
  279. img {
  280. width: .28rem;
  281. height: .28rem;
  282. border-radius: 50%;
  283. overflow: hidden;
  284. margin-right: .08rem;
  285. }
  286. .header {
  287. display: flex;
  288. align-items: center;
  289. font-size: .14rem;
  290. color: #1A1A1A;
  291. padding: .1rem 0;
  292. margin-right: .1rem;
  293. }
  294. .content {
  295. padding-top: .1rem;
  296. font-size: .15rem;
  297. color: #666666;
  298. }
  299. }
  300. .evaluation-panel {
  301. padding: 0;
  302. margin-top: .15rem;
  303. margin-bottom: 0;
  304. /deep/.van-cell {
  305. padding: .1rem .16rem;
  306. }
  307. }
  308. .button-group {
  309. margin: .3rem .26rem .2rem;
  310. .van-button--primary {
  311. background: @mColor;
  312. font-size: .18rem;
  313. }
  314. /deep/.van-field__control {
  315. font-size: .15rem;
  316. color: #999;
  317. }
  318. }
  319. </style>