CourseEvaluation.vue 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342
  1. <template>
  2. <div>
  3. <van-cell-group>
  4. <van-cell title="课程班名称" :value="classGroupName" />
  5. </van-cell-group>
  6. <van-cell-group>
  7. <van-cell title="上课时间" :value="classTimer" />
  8. </van-cell-group>
  9. <van-cell-group>
  10. <van-cell title="乐器" :value="subjectNames" />
  11. </van-cell-group>
  12. <van-cell-group>
  13. <van-field
  14. required
  15. rows="4"
  16. class="textarea"
  17. v-model="teachingMaterial"
  18. maxlength="255"
  19. autosize
  20. label=" 教材内容"
  21. type="textarea"
  22. placeholder="请输入(1-255字)"
  23. />
  24. </van-cell-group>
  25. <van-cell-group>
  26. <van-field required label="曲目" input-align="right" placeholder="请输入曲目名" v-model="song" />
  27. </van-cell-group>
  28. <van-cell-group>
  29. <van-cell>
  30. <template slot="title">
  31. <div class="title-item">
  32. <span class="text">发音</span>
  33. <van-rate v-model="pronunciation" :size="25" void-color="#eee" void-icon="star" />
  34. </div>
  35. <div class="title-item">
  36. <span class="text">节奏</span>
  37. <van-rate :size="25" void-color="#eee" v-model="tempo" void-icon="star" />
  38. </div>
  39. <div class="title-item">
  40. <span class="text">乐理</span>
  41. <van-rate :size="25" v-model="musicTheory" void-color="#eee" void-icon="star" />
  42. </div>
  43. </template>
  44. </van-cell>
  45. </van-cell-group>
  46. <van-cell-group>
  47. <van-field
  48. rows="4"
  49. required
  50. class="textarea"
  51. maxlength="255"
  52. v-model="memo"
  53. autosize
  54. label="评价备注"
  55. type="textarea"
  56. placeholder="请输入(1-255字)"
  57. />
  58. </van-cell-group>
  59. <van-cell-group v-if="!isReset || (isReset && homeWork)">
  60. <van-field
  61. required
  62. rows="4"
  63. class="textarea"
  64. :disabled="isReset"
  65. maxlength="255"
  66. v-model="homeWork"
  67. autosize
  68. label="布置作业"
  69. type="textarea"
  70. placeholder="请输入(1-255字)"
  71. />
  72. </van-cell-group>
  73. <van-cell-group>
  74. <van-cell title="是否完成双向沟通" value-class="twoConnect">
  75. <template slot="default">
  76. <van-radio-group required v-model="hasLiaison" direction="horizontal">
  77. <van-radio name="1">是</van-radio>
  78. <van-radio name="0">否</van-radio>
  79. </van-radio-group>
  80. </template>
  81. </van-cell>
  82. </van-cell-group>
  83. <van-cell-group v-if="isReset && !homeWork">
  84. <van-cell title="是否完成作业" value-class="twoConnect">
  85. <template slot="default">
  86. <van-radio-group required v-model="handHomework" direction="horizontal">
  87. <van-radio name="1">是</van-radio>
  88. <van-radio name="0">否</van-radio>
  89. </van-radio-group>
  90. </template>
  91. </van-cell>
  92. </van-cell-group>
  93. <div class="button-group">
  94. <van-button type="primary" v-if="!reviewId" round size="large" @click="submitReview">提交评价</van-button>
  95. <van-button type="primary" v-if="reviewId" round size="large" @click="submitReview">修改评价</van-button>
  96. </div>
  97. </div>
  98. </template>
  99. <script>
  100. import {
  101. getCourseInfoHead,
  102. courseReviewAdd,
  103. getReviewInfo,
  104. updateReviewInfo
  105. } from "@/api/teacher";
  106. import { browser } from "@/common/common";
  107. import MHeader from "@/components/MHeader";
  108. export default {
  109. name: "teacherList",
  110. data() {
  111. return {
  112. radio: 1,
  113. voice: 0,
  114. courseId: null,
  115. reviewId: null,
  116. classTimer: null,
  117. classGroupName: null,
  118. teachingMaterial: null, //教材
  119. song: null, // 曲目
  120. pronunciation: null, // 发音
  121. tempo: null, //节奏
  122. musicTheory: null, // 乐理
  123. memo: null, // 备注
  124. homeWork: null, // 作业
  125. handHomework: null, // 是否完成作业
  126. hasLiaison: null,
  127. subjectNames: null,
  128. isReset: false,
  129. isInside: false
  130. };
  131. },
  132. created() {
  133. this.courseId = this.$route.query.id;
  134. this.reviewId = parseInt(this.$route.query.reviewId);
  135. this.isInside = this.$route.query.isInside;
  136. if (!this.courseId) {
  137. this.$toast("课程信息错误");
  138. }
  139. },
  140. mounted() {
  141. // 获取头部信息
  142. if (this.reviewId) {
  143. // 获取老评价
  144. this.isReset = true;
  145. getReviewInfo({ id: this.reviewId }).then(res => {
  146. if (res.data.code == 200) {
  147. this.classTimer =
  148. res.data.data.teacherClassHeadInfo.classDate +
  149. res.data.data.teacherClassHeadInfo.startClassTime +
  150. "-" +
  151. res.data.data.teacherClassHeadInfo.endClassTime;
  152. this.subjectNames = res.data.data.teacherClassHeadInfo.subjectNames;
  153. this.classGroupName =
  154. res.data.data.teacherClassHeadInfo.classGroupName;
  155. // 评价内容
  156. this.teachingMaterial =
  157. res.data.data.courseScheduleReview.teachingMaterial;
  158. this.song = res.data.data.courseScheduleReview.song;
  159. this.pronunciation = res.data.data.courseScheduleReview.pronunciation;
  160. this.tempo = res.data.data.courseScheduleReview.tempo;
  161. this.musicTheory = res.data.data.courseScheduleReview.musicTheory;
  162. this.memo = res.data.data.courseScheduleReview.memo;
  163. this.homeWork = res.data.data.courseScheduleReview.homeWork;
  164. this.hasLiaison = res.data.data.courseScheduleReview.hasLiaison.toString();
  165. this.handHomework = res.data.data.courseScheduleReview.handHomework.toString();
  166. }
  167. });
  168. } else {
  169. getCourseInfoHead({ courseId: this.courseId }).then(res => {
  170. if (res.data.code == 200) {
  171. this.classTimer =
  172. res.data.data.classDate +
  173. res.data.data.startClassTime +
  174. "-" +
  175. res.data.data.endClassTime;
  176. this.subjectNames = res.data.data.subjectNames;
  177. this.classGroupName = res.data.data.classGroupName;
  178. }
  179. });
  180. }
  181. },
  182. methods: {
  183. submitReview() {
  184. if (!this.teachingMaterial) {
  185. this.$toast("请填写教材");
  186. return;
  187. }
  188. if (!this.song) {
  189. this.$toast("请填写曲目");
  190. return;
  191. }
  192. if (!this.pronunciation) {
  193. this.$toast("请给发音打分");
  194. return;
  195. }
  196. if (!this.tempo) {
  197. this.$toast("请给节奏打分");
  198. return;
  199. }
  200. if (!this.musicTheory) {
  201. this.$toast("请给乐理打分");
  202. return;
  203. }
  204. if (!this.memo) {
  205. this.$toast("请输入备注");
  206. return;
  207. }
  208. // 判断是否是编辑
  209. if(!this.isReset) {
  210. if (!this.homeWork) {
  211. this.$toast("请布置作业");
  212. return;
  213. }
  214. }
  215. if (!this.hasLiaison) {
  216. this.$toast("请勾选双向沟通");
  217. return;
  218. }
  219. let obj = {
  220. teachingMaterial: this.teachingMaterial, //教材
  221. song: this.song, // 曲目
  222. pronunciation: this.pronunciation, // 发音
  223. tempo: this.tempo, //节奏
  224. musicTheory: this.musicTheory, // 乐理
  225. memo: this.memo, // 备注
  226. homeWork: this.homeWork,
  227. hasLiaison: this.hasLiaison,
  228. handHomework: this.handHomework,
  229. courseScheduleId: this.courseId
  230. };
  231. if (this.reviewId) {
  232. obj.id = this.reviewId;
  233. updateReviewInfo(obj).then(res => {
  234. this.$toast("修改成功");
  235. setTimeout(res => {
  236. if (this.isInside) {
  237. this.$router.push({ path: "/manageEvaluation" });
  238. } else {
  239. this.onAppBack();
  240. }
  241. }, 1000);
  242. });
  243. } else {
  244. courseReviewAdd(obj).then(res => {
  245. if (res.data.code == 200) {
  246. this.$toast("提交成功");
  247. setTimeout(res => {
  248. if (this.isInside) {
  249. this.$router.push({ path: "/manageEvaluation" });
  250. } else {
  251. this.onAppBack();
  252. }
  253. }, 1000);
  254. }
  255. });
  256. }
  257. },
  258. onAppBack() {
  259. if (browser().android) {
  260. DAYA.postMessage(JSON.stringify({ api: "back" }));
  261. } else if (browser().iPhone) {
  262. window.webkit.messageHandlers.DAYA.postMessage(
  263. JSON.stringify({ api: "back" })
  264. );
  265. }
  266. }
  267. }
  268. };
  269. </script>
  270. <style lang="less" scoped>
  271. @import url("../../assets/commonLess/variable.less");
  272. /deep/.van-cell-group {
  273. margin-top: 0.15rem;
  274. /deep/.van-cell {
  275. padding: 0.14rem 0.16rem;
  276. }
  277. }
  278. .title-item {
  279. display: flex;
  280. padding: 0.05rem 0;
  281. .text {
  282. margin-right: 0.15rem;
  283. font-size: 0.17rem;
  284. color: #1a1a1a;
  285. }
  286. /deep/.van-rate {
  287. line-height: 0;
  288. }
  289. }
  290. /deep/.van-cell__title {
  291. font-size: 0.17rem;
  292. color: #1a1a1a;
  293. flex: auto 1;
  294. }
  295. /deep/.van-field__control,
  296. /deep/.van-cell__value {
  297. font-size: 0.17rem;
  298. color: #666;
  299. width: 70%;
  300. flex: auto;
  301. }
  302. .textarea {
  303. flex-direction: column;
  304. /deep/.van-cell__value {
  305. margin-top: 0.1rem;
  306. width: 100%;
  307. }
  308. }
  309. .twoConnect {
  310. width: 55%;
  311. }
  312. /deep/.van-radio-group {
  313. display: flex;
  314. justify-content: flex-end;
  315. /deep/.van-radio {
  316. margin-left: 0.18rem;
  317. }
  318. }
  319. /deep/.van-radio__icon .van-icon {
  320. border-color: @sFontColor;
  321. }
  322. /deep/.van-radio__icon--checked {
  323. .van-icon {
  324. border-color: #14928a;
  325. background: #14928a;
  326. }
  327. }
  328. .button-group {
  329. margin: 0.3rem 0.26rem 0.2rem;
  330. .van-button--primary {
  331. background: @mColor;
  332. border: 1px solid @mColor;
  333. font-size: 0.18rem;
  334. }
  335. }
  336. </style>