ArrangeWork.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. <template>
  2. <div class="arrangeWork">
  3. <m-header v-if="headerStatus" />
  4. <div class="container">
  5. <!-- <div class="formGroup">
  6. <div class="formTitle">课外训练标题</div>
  7. <van-field type="text" placeholder="请输入(1-25字)" />
  8. </div> -->
  9. <div class="formGroup">
  10. <div class="dot"></div>
  11. <div class="formTitle">作业内容</div>
  12. <van-field rows="8" v-model="content" type="textarea" placeholder="请输入(1-600字)" />
  13. </div>
  14. </div>
  15. <van-cell class="endTime" title="作业提交截止时间" @click="onEndTime" readonly placeholder="请选择截止时间" >
  16. <template #default>
  17. {{ dateSection.showStartDate }} <span class="arrowDown"></span>
  18. </template>
  19. </van-cell>
  20. <div class="button-group">
  21. <van-button type="primary" round size="large" @click="onSubmit">确定</van-button>
  22. </div>
  23. <!-- 日期开始弹窗 -->
  24. <van-popup position="bottom" v-model="dateSection.status">
  25. <van-datetime-picker
  26. v-model="dateSection.currentDate"
  27. type="date"
  28. :min-date="dateSection.minDate"
  29. :max-date="dateSection.maxDate"
  30. :formatter="formatter"
  31. @confirm="confirmStartTime()"
  32. @cancel="dateSection.status = false"
  33. />
  34. </van-popup>
  35. </div>
  36. </template>
  37. <script>
  38. import MHeader from "@/components/MHeader"
  39. import { browser, _throttle } from '@/common/common'
  40. import dayjs from "dayjs";
  41. import { addHomeWork } from '@/api/audition'
  42. export default {
  43. name: "teacherList",
  44. components: { MHeader },
  45. data() {
  46. let tempDate = new Date() // 默认显示T+3
  47. tempDate.setDate(tempDate.getDate() + 3)
  48. return {
  49. that: this,
  50. headerStatus: true,
  51. dateSection: {
  52. status: false,
  53. minDate: new Date(),
  54. maxDate: new Date(2025, 10, 1),
  55. currentDate: tempDate,
  56. showStartDate: dayjs(tempDate).format("YYYY年MM月DD日")
  57. },
  58. content: null, // 课程编号
  59. expiryDate: null, // 作业截止日期
  60. };
  61. },
  62. mounted() {
  63. let params = this.$route.query;
  64. if (params.Authorization) {
  65. localStorage.setItem("Authorization", decodeURI(params.Authorization));
  66. localStorage.setItem("userInfo", decodeURI(params.Authorization));
  67. }
  68. document.title = '布置作业'
  69. if(browser().android || browser().iPhone) {
  70. this.headerStatus = false
  71. }
  72. },
  73. methods: {
  74. formatter(type, val) {
  75. if (type === "year") {
  76. return `${val}年`
  77. } else if (type === "month") {
  78. return `${val}月`
  79. } else if (type == "day") {
  80. return `${val}日`
  81. }
  82. return val
  83. },
  84. confirmStartTime() {
  85. this.dateSection.showStartDate = dayjs(this.dateSection.currentDate).format("YYYY年MM月DD日")
  86. this.dateSection.status = false
  87. },
  88. onEndTime() {
  89. this.dateSection.status = true
  90. },
  91. onSubmit: _throttle(function() {
  92. if(!this.content) {
  93. this.$toast('请输入作业内容')
  94. return
  95. }
  96. this.$toast.loading({
  97. message: '加载中...',
  98. duration: 10000,
  99. forbidClick: true,
  100. loadingType: 'spinner',
  101. })
  102. let query = this.$route.query
  103. let params = {
  104. content: this.content,
  105. courseId: query.courseId,
  106. expiryDate: dayjs(this.dateSection.currentDate).format('YYYY-MM-DD')
  107. }
  108. addHomeWork({...params}).then(res => {
  109. let result = res.data
  110. this.$toast.clear()
  111. if(result.code == 200) {
  112. this.$toast('作业布置成功')
  113. this.$router.replace({
  114. path: '/manageEvaluation'
  115. })
  116. } else {
  117. this.$toast(result.msg)
  118. }
  119. })
  120. }, 500)
  121. }
  122. };
  123. </script>
  124. <style lang="less" scoped>
  125. @import url("../../assets/commonLess/variable.less");
  126. .arrangeWork {
  127. min-height: 100vh;
  128. overflow-y: auto;
  129. overflow-x: hidden;
  130. background-color: #F3F4F8;
  131. }
  132. /deep/.van-cell {
  133. font-size: .14rem;
  134. padding: .12rem .16rem;
  135. line-height: .24rem;
  136. }
  137. .arrowDown {
  138. display: inline-block;
  139. margin-left: .1rem;
  140. width: 0.1rem;
  141. height: 0.07rem;
  142. background: url('../../assets/images/audition/arrow_down.png') no-repeat center center;
  143. background-size: 100%;
  144. }
  145. .container {
  146. background: #ffffff;
  147. .formTitle {
  148. padding: .12rem .21rem 0;
  149. font-size: .16rem;
  150. color: #333333;
  151. font-weight: 500;
  152. }
  153. }
  154. .endTime {
  155. margin-top: .1rem;
  156. .van-cell__title {
  157. font-size: .16rem;
  158. color: #1A1A1A;
  159. }
  160. /deep/.van-cell__value {
  161. // width: 30%;
  162. justify-content: flex-end;
  163. text-align: right;
  164. font-size: .16rem;
  165. color: #1A1A1A;
  166. display: flex;
  167. align-items: center;
  168. }
  169. }
  170. .button-group {
  171. margin: 0.3rem 0.26rem 0.2rem;
  172. .van-button--primary {
  173. background: @mColor;
  174. border: 1px solid @mColor;
  175. font-size: 0.18rem;
  176. }
  177. }
  178. .dot {
  179. width: 4px;
  180. height: 0.17rem;
  181. background: #01c1b5;
  182. border-radius: 3px;
  183. position: absolute;
  184. z-index: 200;
  185. top: .15rem;
  186. left: 0.12rem;
  187. }
  188. .formGroup {
  189. position: relative;
  190. }
  191. </style>