leave.vue 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374
  1. <template>
  2. <view>
  3. <u-navbar title="请假条申请"></u-navbar>
  4. <view class="infos">
  5. <view class="item" @click="classShow=true">
  6. <view class="title">
  7. <text class="asterisk">*</text>
  8. <text>所属班级</text>
  9. </view>
  10. <view class="value">
  11. <text v-if="className">{{className}}</text>
  12. <text style="color: #777777;" v-else>请选择班级</text>
  13. <text class="icon">
  14. <u-icon name="arrow-right" color="#c8c8c8"></u-icon>
  15. </text>
  16. </view>
  17. </view>
  18. <u-select v-model="classShow" mode="single-column" :list="classList" @confirm="classConfirm"></u-select>
  19. <view class="item" @click="courseShow=true">
  20. <view class="title">
  21. <text class="asterisk">*</text>
  22. <text>请假课次日期</text>
  23. </view>
  24. <view class="value">
  25. <text v-if="leaveDate">{{leaveDate}}</text>
  26. <text style="color: #777777;" v-else>请选择请假课次日期</text>
  27. <text class="icon">
  28. <u-icon name="arrow-right" color="#c8c8c8"></u-icon>
  29. </text>
  30. </view>
  31. </view>
  32. <u-select v-model="courseShow" mode="mutil-column-auto" :list="courseList" @confirm="courseConfirm"></u-select>
  33. <!-- <view class="item">
  34. <view class="title indent">
  35. <text>请假课次</text>
  36. </view>
  37. <view class="value">
  38. <text>第20节</text>
  39. </view>
  40. </view> -->
  41. <view class="item">
  42. <view class="title indent">
  43. <text>授课老师</text>
  44. </view>
  45. <view class="value">
  46. <text>{{teacherName}}</text>
  47. </view>
  48. </view>
  49. </view>
  50. <view class="infos">
  51. <!-- <view class="item">
  52. <view class="title">
  53. <text class="asterisk">*</text>
  54. <text>请假类型</text>
  55. </view>
  56. <view class="value">
  57. <text>病假</text>
  58. <text class="icon">
  59. <u-icon name="arrow-right" color="#c8c8c8"></u-icon>
  60. </text>
  61. </view>
  62. </view> -->
  63. <view class="reason">
  64. <view class="title">
  65. <text class="asterisk">*</text>
  66. <text>请假事由</text>
  67. </view>
  68. <view class="value">
  69. <textarea v-model="leaveReason" name="" id="" cols="30" rows="10" placeholder="请假申请"></textarea>
  70. </view>
  71. </view>
  72. <!-- <view class="upload-pictures">
  73. <view class="title indent">
  74. <text>上传图片</text>
  75. </view>
  76. <view class="value ">
  77. <img src="../../../assets/img/fas fa-camera Copy@1x.png" alt="">
  78. </view>
  79. </view> -->
  80. </view>
  81. <view class="btn">
  82. <button @click="leaveSubmit">提交请假条</button>
  83. </view>
  84. </view>
  85. </template>
  86. <script>
  87. import * as sickNoteApi from '@/apis/youth/sickNote.js'
  88. import * as courseApi from '@/apis/youth/course.js'
  89. import * as classScheduleApi from '@/apis/youth/classSchedule.js'
  90. export default {
  91. data() {
  92. return {
  93. studentId: '',
  94. classList: [],
  95. classShow: false,
  96. teacherName: '',
  97. className: '',
  98. courseList: [],
  99. classId: '',
  100. list: [],
  101. courseShow: false,
  102. leaveDate: '',
  103. sheetId: '',
  104. leaveReason: '',
  105. startDate: '',
  106. endDate: ''
  107. }
  108. },
  109. onReady() {
  110. let myDate = new Date();
  111. let myDate2 = new Date();
  112. myDate2.setMonth(myDate2.getMonth() + 1);
  113. this.startDate = this.getData(myDate);
  114. this.endDate = this.getData(myDate2);
  115. if (this.carhelp.getNsStudentId()) {
  116. this.studentId = this.carhelp.getNsStudentId().studentId;
  117. this.getLoadMyBuyLog();
  118. }
  119. },
  120. methods: {
  121. getData(val) {
  122. var n = new Date(val);
  123. return n.toLocaleDateString().replace(/\//g, '-');
  124. },
  125. leaveSubmit() {
  126. if(!this.className) {
  127. uni.showToast({
  128. title: "请选择班级",
  129. icon: "none"
  130. })
  131. return;
  132. }
  133. if(!this.leaveDate) {
  134. uni.showToast({
  135. title: "请选择请假课次日期",
  136. icon: "none"
  137. })
  138. return
  139. }
  140. if(!this.leaveReason) {
  141. uni.showToast({
  142. title: "请填写请假事由",
  143. icon: "none"
  144. })
  145. return
  146. }
  147. uni.showLoading({
  148. title: "加载中",
  149. mask: true,
  150. })
  151. sickNoteApi.addLeave({
  152. studentId: this.studentId,
  153. scheduleId: this.sheetId,
  154. leaveReason: this.leaveReason
  155. }).then((res) => {
  156. uni.hideLoading();
  157. uni.navigateBack({
  158. })
  159. }).catch(error => {
  160. uni.showToast({
  161. title: error,
  162. icon: "none"
  163. })
  164. })
  165. },
  166. courseConfirm(e) {
  167. this.leaveDate = e[0].label + ' ' + e[1].label;
  168. this.sheetId = e[1].value;
  169. },
  170. getCourseList() {
  171. this.courseList = [];
  172. uni.showLoading({
  173. title: "加载中",
  174. mask: true,
  175. })
  176. classScheduleApi.loadMySchedule({
  177. studentId: this.studentId,
  178. classId: this.classId,
  179. startDate: this.startDate,
  180. endDate: this.endDate
  181. }).then((response) => {
  182. uni.hideLoading();
  183. var list = response.data;
  184. for (var i = 0; i < list.length; i++) {
  185. this.courseList.push({
  186. value: list[i].classId,
  187. label: list[i].courseDate,
  188. children: []
  189. })
  190. }
  191. for (var j = 0; j < list.length; j++) {
  192. for (var k = 0; k < this.courseList.length; k++) {
  193. if(this.courseList[k].label == list[j].courseDate) {
  194. if(this.courseList[k].children.length == 1) {
  195. var time1 = parseInt(this.courseList[k].children[0].label.slice(0,2));
  196. var time2 = parseInt(list[j].coursePeriods.slice(0,2));
  197. if(time1 > time2) {
  198. this.courseList[k].children.unshift({
  199. value: list[j].sheetId,
  200. label: list[j].coursePeriods
  201. })
  202. } else {
  203. this.courseList[k].children.push({
  204. value: list[j].sheetId,
  205. label: list[j].coursePeriods
  206. })
  207. }
  208. } else {
  209. this.courseList[k].children.push({
  210. value: list[j].sheetId,
  211. label: list[j].coursePeriods
  212. })
  213. }
  214. }
  215. }
  216. }
  217. for (var m = 0; m < this.courseList.length; m++) {
  218. for (var n = 0; n < this.courseList.length; n++) {
  219. if(this.courseList[m].label == this.courseList[n].label && m != n) {
  220. this.courseList.splice(n, 1);
  221. }
  222. }
  223. }
  224. }).catch(error => {
  225. uni.showToast({
  226. title: error,
  227. icon: "none"
  228. })
  229. })
  230. },
  231. classConfirm(e) {
  232. this.classId = e[0].value;
  233. this.className = e[0].label;
  234. for (var i = 0; i < this.list.length; i++) {
  235. if(this.list[i].classId == e[0].value) {
  236. this.teacherName = this.list[i].teacherName;
  237. }
  238. }
  239. this.getCourseList();
  240. },
  241. getLoadMyBuyLog() {
  242. this.classList = [];
  243. uni.showLoading({
  244. title: "加载中",
  245. mask: true,
  246. })
  247. courseApi.loadMyBuyLog({
  248. studentId: this.studentId,
  249. year: '',
  250. courseId: '',
  251. pageNum: 1,
  252. pageSize: 10000
  253. }).then((res) => {
  254. uni.hideLoading();
  255. this.list = res.data.data;
  256. var clist = res.data.data;
  257. for (var i = 0; i < clist.length; i++) {
  258. this.classList.push({
  259. value: clist[i].classId,
  260. label: clist[i].className,
  261. });
  262. }
  263. }).catch(error => {
  264. uni.showToast({
  265. title: error,
  266. icon: "none"
  267. })
  268. })
  269. },
  270. }
  271. }
  272. </script>
  273. <style lang="scss" scoped>
  274. .asterisk {
  275. color: rgba(244, 68, 68, 1);
  276. }
  277. .infos {
  278. padding: 0px 15px;
  279. background-color: #fff;
  280. margin-bottom: 12px;
  281. .item {
  282. display: flex;
  283. justify-content: space-between;
  284. border-bottom: 1px solid rgba(244, 244, 244, 1);
  285. padding: 12px 0;
  286. .title {
  287. color: #333333;
  288. // .asterisk {
  289. // color: rgba(244, 68, 68, 1);
  290. // }
  291. }
  292. .value {
  293. color: rgba(51, 51, 51, 1);
  294. .icon {
  295. margin-left: 4px;
  296. }
  297. }
  298. }
  299. .reason {
  300. .title {
  301. margin-bottom: 12px;
  302. }
  303. uni-textarea {
  304. width: 696rpx;
  305. height: 120rpx;
  306. text-indent: 8px;
  307. font-size: 14px
  308. }
  309. }
  310. .upload-pictures {
  311. padding-bottom: 29px;
  312. .value {
  313. margin-top: 12px;
  314. width: 120rpx;
  315. height: 120rpx;
  316. border-radius: 8px;
  317. background-color: rgba(232, 232, 232, 1);
  318. text-align: center;
  319. padding: 36rpx;
  320. margin-left: 20rpx;
  321. img {
  322. width: 48rpx;
  323. height: 48rpx;
  324. }
  325. }
  326. }
  327. }
  328. .indent {
  329. text-indent: 8px;
  330. }
  331. .btn {
  332. position: fixed;
  333. left: 0;
  334. right: 0;
  335. bottom: 0;
  336. padding: 10px 12px;
  337. background-color: #fff;
  338. button {
  339. border-radius: 50px;
  340. background-color: rgba(13, 186, 199, 1);
  341. color: rgba(255, 255, 255, 1);
  342. font-size: 16px;
  343. line-height: 40px;
  344. }
  345. }
  346. </style>