commentPanel.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. <template>
  2. <div class="cp-container" v-if="panelVisible">
  3. <div class="cp-title">
  4. <span class="back" @click="back"></span>
  5. <span class="title">评课</span>
  6. <span class="btn" v-if="type == 1" @click="addPz(type)">提交</span>
  7. </div>
  8. <div class="cp-box">
  9. <div class="type-nav">
  10. <div class="type-nav-box" :class="{ active: type == 1 }" @click="setType(1)">
  11. <img src="@/assets/images/course/text.png" />
  12. </div>
  13. <div class="type-nav-box" :class="{ active: type == 2 }" @click="setType(2)">
  14. <img src="@/assets/images/course/audio.png" />
  15. </div>
  16. </div>
  17. <div class="cp-conent" v-if="type == 1">
  18. <van-field v-model="message" rows="20" autosize type="textarea" placeholder="请输入..." />
  19. <div style="margin: 0 10px;margin-top: 10px;">
  20. <image-component @getImage="getImage" :imgList.sync="imgList"></image-component>
  21. </div>
  22. </div>
  23. <div class="cp-audio" v-if="type == 2">
  24. <audio-component @addPz="addPz"></audio-component>
  25. </div>
  26. </div>
  27. </div>
  28. </template>
  29. <script>
  30. import ImageComponent from './ImageComponent.vue'
  31. import AudioComponent from './AudioComponent.vue'
  32. import { addPz2 } from '@/api/course'
  33. import { mapGetters } from 'vuex'
  34. export default {
  35. props: {
  36. panelVisible: {
  37. type: Boolean
  38. },
  39. courseid: {
  40. type: String,
  41. default: ''
  42. },
  43. courseType: {
  44. type: Number,
  45. default: 0
  46. },
  47. taskCount: {
  48. type: Number,
  49. default: 0
  50. }
  51. },
  52. components: {
  53. AudioComponent,
  54. ImageComponent
  55. },
  56. data() {
  57. return {
  58. type: 1,
  59. message: '',
  60. imgList: []
  61. }
  62. },
  63. computed: {
  64. ...mapGetters(['userinfo'])
  65. },
  66. methods: {
  67. back() {
  68. this.$emit('setPanelVisible', false)
  69. },
  70. setType(type) {
  71. this.type = type
  72. },
  73. getImage(imgList) {
  74. this.imgList = imgList
  75. this.$forceUpdate()
  76. },
  77. addPz(type, content) {
  78. var a = ''
  79. if (type === 1 && this.message === '' && !this.imgList.length) {
  80. this.$toast({ message: '批注不能为空!', type: 'fail' })
  81. return
  82. }
  83. if (type === 1 && (this.message !== '' || this.imgList.length)) {
  84. var img = ''
  85. for (var i = 0; i < this.imgList.length; i++) {
  86. img += "<img src='" + this.imgList[i] + "' />"
  87. }
  88. a = this.message.replaceAll(/%/g, '%25') + img
  89. }
  90. const params = [
  91. {
  92. cid: this.courseid,
  93. uid: this.userinfo.userid,
  94. s: this.courseType,
  95. t: this.taskCount,
  96. c: type === 1 ? a : content,
  97. type: type
  98. }
  99. ]
  100. addPz2(params)
  101. .then(res => {
  102. this.$toast({
  103. message: '添加成功',
  104. type: 'success'
  105. })
  106. this.imgList = []
  107. this.message = ''
  108. this.$emit('setPanelVisible', false)
  109. })
  110. .catch(err => {
  111. console.error(err)
  112. })
  113. }
  114. }
  115. }
  116. </script>
  117. <style lang="scss" scoped>
  118. .cp-container {
  119. width: 100vw;
  120. height: 100vh;
  121. position: fixed;
  122. top: 0;
  123. background: #fff;
  124. z-index: 2;
  125. .cp-title {
  126. height: 1.5rem;
  127. width: 100%;
  128. border-bottom: 1px solid #cecece;
  129. display: flex;
  130. align-items: center;
  131. justify-content: center;
  132. box-sizing: border-box;
  133. position: relative;
  134. .back {
  135. width: 0.3rem;
  136. height: 0.3rem;
  137. border-top: 2px solid #000000;
  138. border-left: 2px solid #000000;
  139. position: absolute;
  140. transform: rotate(-45deg) translateY(-50%);
  141. top: 47%;
  142. left: 0.8rem;
  143. cursor: pointer;
  144. }
  145. .title {
  146. font-size: 16px;
  147. }
  148. .btn {
  149. font-size: 14px;
  150. transform: translateY(-50%);
  151. top: 50%;
  152. right: 0.8rem;
  153. position: absolute;
  154. color: #2274ff;
  155. cursor: pointer;
  156. }
  157. }
  158. .cp-box {
  159. width: 100%;
  160. height: calc(100% - 1.5rem);
  161. .type-nav {
  162. height: 60px;
  163. width: 100%;
  164. display: flex;
  165. align-items: center;
  166. padding: 10px 0.3rem;
  167. box-sizing: border-box;
  168. .type-nav-box {
  169. height: 100%;
  170. opacity: 0.5;
  171. transition: all 0.5s;
  172. + .type-nav-box {
  173. margin-left: 0.3rem;
  174. }
  175. &.active {
  176. opacity: 1;
  177. }
  178. > img {
  179. height: 100%;
  180. }
  181. }
  182. }
  183. .cp-conent {
  184. height: calc(100% - 60px);
  185. overflow: auto;
  186. font-size: 14px;
  187. width: 100%;
  188. /deep/ .van-field__control {
  189. height: 399px !important;
  190. }
  191. }
  192. .cp-audio {
  193. height: calc(100% - 60px);
  194. position: relative;
  195. width: 100%;
  196. }
  197. }
  198. }
  199. </style>