index.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645
  1. <template>
  2. <view>
  3. <view class="title">
  4. 学生信息
  5. </view>
  6. <!-- 基本信息 -->
  7. <template>
  8. <view class="content">
  9. <u-cell :value="classId.label || '请选择'" isLink @click="classShow=true">
  10. <view
  11. slot="title"
  12. class="u-slot-title"
  13. >
  14. <text class="u-cell-text">
  15. <RedDot text="班级" :required="true"></RedDot>
  16. </text>
  17. </view>
  18. </u-cell>
  19. <SeverOne v-if="classData.length != 0" :classData="classData" :classShow="classShow" @search="search" @cancelClass="cancelClass"></SeverOne>
  20. </view>
  21. <view class="content">
  22. <u-cell :value="studentId.label || '请选择'" isLink @click="nameClik">
  23. <view
  24. slot="title"
  25. class="u-slot-title"
  26. >
  27. <text class="u-cell-text">
  28. <RedDot text="姓名" :required="true"></RedDot>
  29. </text>
  30. </view>
  31. </u-cell>
  32. <u-picker
  33. :show="nameShow"
  34. :columns="nameList"
  35. keyName="label"
  36. @cancel="nameShow=false"
  37. @confirm="choiceName"
  38. :closeOnClickOverlay="true"
  39. @close="nameShow=false"
  40. ></u-picker>
  41. </view>
  42. </template>
  43. <!-- 请假类型 -->
  44. <template>
  45. <view class="content">
  46. <u-cell :value="LeaveTypeData || '请选择'" isLink @click="leaveTypeShow=true">
  47. <view
  48. slot="title"
  49. class="u-slot-title"
  50. >
  51. <text class="u-cell-text">
  52. <RedDot text="请假类型" :required="true"></RedDot>
  53. </text>
  54. </view>
  55. </u-cell>
  56. <u-picker
  57. :show="leaveTypeShow"
  58. :columns="leaveType"
  59. keyName="name"
  60. @cancel="leaveTypeShow=false"
  61. :closeOnClickOverlay="true"
  62. @close="leaveTypeShow=false"
  63. @confirm="choiceLeaveType"
  64. ></u-picker>
  65. </view>
  66. <view class="content" v-if="LeaveTypeData == '病假'">
  67. <u-cell :value="formData.VerData.type || '请选择'" isLink @click="VerShow=true">
  68. <view
  69. slot="title"
  70. class="u-slot-title"
  71. >
  72. <text class="u-cell-text">
  73. <RedDot text="病假类型" :required="true"></RedDot>
  74. </text>
  75. </view>
  76. </u-cell>
  77. <u-picker :show="VerShow" :columns="leaveData" keyName="type" @cancel="VerShow=false" @confirm="choiceVer"></u-picker>
  78. </view>
  79. <view class="content" v-if="LeaveTypeData == '病假'">
  80. <u-cell>
  81. <view
  82. slot="title"
  83. class="u-slot-title"
  84. style="position: relative;"
  85. >
  86. <text class="u-cell-text">
  87. <RedDot text="体温" :required="true"></RedDot>
  88. <input
  89. placeholder="请输入"
  90. border="none"
  91. v-model="formData.temperature"
  92. style="width: 150rpx; position: absolute; top:10rpx; left:520rpx; float: right; text-align: right; overflow: hidden;"
  93. ></input>
  94. </text>
  95. </view>
  96. </u-cell>
  97. </view>
  98. </template>
  99. <view class="title">
  100. 请假时间
  101. </view>
  102. <!-- 请假时间 -->
  103. <template>
  104. <view class="content">
  105. <u-cell :value="startTime || '请选择'" isLink @click="timeShow1=true">
  106. <view
  107. slot="title"
  108. class="u-slot-title"
  109. >
  110. <text class="u-cell-text">
  111. <RedDot text="开始时间" :required="true"></RedDot>
  112. </text>
  113. </view>
  114. </u-cell>
  115. <u-popup :show="timeShow1" mode="bottom" safe-area-inset-bottom :closeOnClickOverlay="true" @close="timeShow1 = false">
  116. <timeSever @onDateClick="getSelectDatatemp" @onDayClick="onDayClicks" :itemData="currentDateArray[0]" />
  117. </u-popup>
  118. </view>
  119. <view class="content">
  120. <u-cell :value="formData.dayData || '请选择'" isLink @click="dayShow=true">
  121. <view
  122. slot="title"
  123. class="u-slot-title"
  124. >
  125. <text class="u-cell-text">
  126. <RedDot text="天数" :required="true"></RedDot>
  127. </text>
  128. </view>
  129. </u-cell>
  130. <u-picker
  131. :show="dayShow"
  132. :columns="dayList"
  133. @cancel="dayShow=false"
  134. @confirm="choiceDay"
  135. :closeOnClickOverlay="true"
  136. @close="dayShow=false"
  137. ></u-picker>
  138. </view>
  139. <view class="content">
  140. <u-cell :value="endTime || ' '" >
  141. <view
  142. slot="title"
  143. class="u-slot-title"
  144. >
  145. <text class="u-cell-text">
  146. 结束时间
  147. </text>
  148. </view>
  149. </u-cell>
  150. <!-- <u-popup :show="timeShow2" mode="bottom" safe-area-inset-bottom>
  151. <timeSever @onDateClick="getSelectDatatemp" @onDayClick="onDayClicks1" />
  152. </u-popup> -->
  153. </view>
  154. </template>
  155. <!-- 请假事由 -->
  156. <view class="symptom">
  157. <text class="u-cell-text">
  158. <!-- 请假事由 -->
  159. <RedDot text="请假事由" :required="true"></RedDot>
  160. </text>
  161. <u--textarea border="none" style="margin: 32rpx 0 72rpx 0; padding: 0;" v-model="formData.reason" placeholder="请输入" autoHeight ></u--textarea>
  162. </view>
  163. <!-- 照片 -->
  164. <view class="symptom">
  165. <text class="u-cell-text" style="color: rgba(0,0,0,0.60);">
  166. 照片
  167. </text>
  168. <upImage :img="symptomImgs" @addImg='addImg'></upImage>
  169. </view>
  170. <!-- 提交按钮 -->
  171. <view class="submit">
  172. <u-button
  173. @click="add"
  174. shape="circle"
  175. type="primary"
  176. text="提交"
  177. color="#7B5DF0"
  178. style="width: 550rpx;"
  179. ></u-button>
  180. </view>
  181. <!-- 选择上午下午 -->
  182. <u-picker
  183. :closeOnClickOverlay="true"
  184. @close="timeShow=false"
  185. :show="timeShow"
  186. :columns="timeOptions"
  187. keyName="name"
  188. @cancel="timeShow=false"
  189. @confirm="timeSelect"
  190. ></u-picker>
  191. <u-loading-page :loading="loading" loading-text="加载中" bg-color="rgba(0,0,0,0.60)" style="z-index: 999999;"></u-loading-page>
  192. </view>
  193. </template>
  194. <script>
  195. import RedDot from '../../conponents/red-dot.vue'
  196. import Sever from "../../conponents/Sever/SeverTwo.vue"
  197. import SeverOne from "../../conponents/Sever/severOne.vue"
  198. import timeSever from "../../conponents/Sever/timeSever.vue"
  199. import upImage from '../../conponents/upload/upImage.vue'
  200. export default {
  201. components:{
  202. RedDot,
  203. Sever,
  204. SeverOne,
  205. timeSever,
  206. upImage,
  207. },
  208. data() {
  209. return {
  210. user:"请选择",
  211. show:false,
  212. nameShow: false, // 姓名选择显隐
  213. symptom: "", // 症状文本
  214. currentDateArray: [], // 时间
  215. timeShow1: false, // 开始时间选择显隐
  216. timeShow2: false, // 结束时间选择显隐
  217. classData: [], // 班级数据
  218. classId: {},
  219. classShow: false, // 班级显隐
  220. startStr: '', // 开始时间
  221. endStr: '', // 开始时间
  222. startTime: '', // 开始时间
  223. endTime: '', // 结束时间
  224. timeData: '', // 上午或者下午
  225. dayData: '', // 天数
  226. tempEnd: '',
  227. timeShow: false, // 显示上下午弹窗
  228. timeOptions:[[{name:'上午'},{name:'下午'}]], // 上下午选择
  229. symptomImgs: [], // 照片
  230. img: [],
  231. fileList3: [{
  232. url: 'https://cdn.uviewui.com/uview/swiper/1.jpg',
  233. }],
  234. columns:[],
  235. leaveTypeShow: false, // 请假类型显隐
  236. LeaveTypeData: '', // 请假类型
  237. leaveType: [
  238. [{name: '事假',},{name: '病假',},]
  239. ], // 请假类型
  240. leaveData: [],
  241. VerShow: false,
  242. studentId: {}, // 学生id
  243. nameList: [],
  244. dayShow: false, // 天数显隐
  245. dayList: [], // 天数选择
  246. formData: {
  247. temperature: '', // 体温
  248. VerData: '',
  249. reason: '', // 请假事由
  250. },
  251. loading: false, // 加载动画
  252. }
  253. },
  254. created() {
  255. this.getClass()
  256. this.leavetype()
  257. this.day()
  258. },
  259. methods: {
  260. choiceUser(e){
  261. console.log("e==>",e)
  262. this.show=false;
  263. this.user=e.value[0].name;
  264. },
  265. // 请假类型确定
  266. choiceLeaveType(e){
  267. console.log("e==>",e)
  268. this.leaveTypeShow=false;
  269. this.LeaveTypeData=e.value[0].name;
  270. if(e.value[0].name == '事假'){
  271. this.formData.VerData = ''
  272. }
  273. },
  274. choiceVer(e){
  275. console.log("e==>",e)
  276. this.VerShow=false;
  277. this.formData.VerData=e.value[0];
  278. },
  279. // 天数选择
  280. choiceDay(e){
  281. console.log("e==>",e)
  282. this.dayShow=false;
  283. this.formData.dayData = e.value[0];
  284. this.dayData = e.value[0];
  285. // this.currentDateArray[1] = this.time(this.currentDateArray[0], e.value)
  286. this.timeSelect()
  287. },
  288. // 学生选择
  289. choiceName(e){
  290. this.nameShow = false
  291. this.studentId = e.value[0]
  292. },
  293. onDayClicks(data) {
  294. this.currentDateArray[0] = data.date
  295. this.timeShow1 = false
  296. console.log('时间' , this.currentDateArray[0])
  297. this.thimeST()
  298. },
  299. onDayClicks1(data) {
  300. this.currentDateArray[1] = data.date
  301. this.timeShow2 = false
  302. console.log('时间' , this.currentDateArray[1])
  303. },
  304. // 获取学校年级班级等数据
  305. getClass(){
  306. let tenantId = localStorage.getItem('tenant_id')
  307. this.$request({
  308. url: this.$api.classesTree.getClassesTree,
  309. header: {
  310. contentType: "application/json"
  311. },
  312. data:{
  313. tenantId: tenantId
  314. }
  315. }).then(res=>{
  316. let arr = res.data[0].children
  317. // arr.unshift({
  318. // label: res.data[0].label,
  319. // id: res.data[0].id,
  320. // children: [''],
  321. // })
  322. this.classData = arr
  323. }).catch(err=>{
  324. console.log('err' , err)
  325. })
  326. },
  327. getName(){
  328. this.$request({
  329. url: this.$api.addHandle.getNameSelectVos,
  330. header: {
  331. contentType: "application/json"
  332. },
  333. data:{
  334. classId: this.classId.id
  335. }
  336. }).then(res=>{
  337. this.nameList = []
  338. this.nameList.push(res.data)
  339. })
  340. },
  341. leavetype(){
  342. this.$request({
  343. url: this.$api.leave.leavetype,
  344. header: {
  345. contentType: "application/json"
  346. },
  347. data:{
  348. current: 1,
  349. size: 999,
  350. }
  351. }).then(res=>{
  352. this.leaveData.push(res.data.records)
  353. })
  354. },
  355. addImg(img){
  356. console.log('img' , img)
  357. this.img = []
  358. for(let item of img){
  359. this.img.push(item.url)
  360. }
  361. },
  362. add(){
  363. // wx.chooseImage({})
  364. // return
  365. if(!this.classId.label){
  366. this.$u.toast('未选择班级')
  367. return
  368. }else if(!this.studentId.value){
  369. this.$u.toast('未选择学生')
  370. return
  371. }else if(this.LeaveTypeData == ''){
  372. this.$u.toast('未选择请假类型')
  373. return
  374. }else if(this.LeaveTypeData == '病假' && !this.formData.VerData.type){
  375. this.$u.toast('未选择病症类型')
  376. return
  377. }else if(this.LeaveTypeData == '病假' && this.formData.temperature == ''){
  378. this.$u.toast('未输入体温')
  379. return
  380. }else if(!this.currentDateArray[0]){
  381. this.$u.toast('未选择开始时间')
  382. return
  383. }else if(this.dayData == ''){
  384. this.$u.toast('未选择请假天数')
  385. return
  386. }else if(this.formData.reason == ''){
  387. this.$u.toast('填写请假事由')
  388. return
  389. }
  390. // return
  391. const date = new Date()
  392. const y = date.getFullYear()
  393. const m = (date.getMonth()+1)<10? `0${date.getMonth()+1}`: date.getMonth()+1
  394. const d = (date.getDate())<10? `0${date.getDate()}`: date.getDate()
  395. const h = (date.getHours())<10? `0${date.getHours()}` : date.getHours()
  396. const mm = (date.getMinutes())<10? `0${date.getMinutes()}` : date.getMinutes()
  397. const ss =(date.getSeconds())<10? `0${date.getSeconds()}`: date.getSeconds()
  398. const applyTime = `${y}-${m}-${d} ${h}:${mm}:${ss}`
  399. this.$request({
  400. url: this.$api.leave.add,
  401. header: {
  402. contentType: "application/json"
  403. },
  404. method: 'POST',
  405. data:{
  406. daysOff: this.dayData,
  407. startStr: this.timeData,
  408. endStr: this.endTime.split(' ')[1],
  409. startTime: this.currentDateArray[0] + ' 00:00:00',
  410. temperature: this.formData.temperature,
  411. endTime: this.tempEnd,
  412. enclosure: this.img.join(','),
  413. applyTime: applyTime,
  414. reason: this.formData.reason,
  415. studentId: this.studentId.value,
  416. leaveType: this.LeaveTypeData,
  417. disease: this.formData.VerData.type,
  418. }
  419. }).then(res=>{
  420. this.$u.toast('添加成功')
  421. setTimeout(()=>{
  422. uni.switchTab({
  423. url: '/pages/leave/index'
  424. });
  425. }, 2000)
  426. }).catch(err => {
  427. this.$u.toast(err.msg)
  428. })
  429. },
  430. // 选择班级触发获取数据
  431. search(data){
  432. console.log(data)
  433. this.classShow = false
  434. this.classId = data
  435. this.getName()
  436. },
  437. cancelClass(){
  438. this.classShow = false
  439. },
  440. // 循环生成天数
  441. day(){
  442. let arr = []
  443. var da = 0
  444. for(var i = 1; i<=60; i++){
  445. arr.push(da += 0.5)
  446. }
  447. this.dayList.push(arr)
  448. },
  449. time(time, data){
  450. var x = new Date(time);
  451. var time1 = x.getTime();
  452. let date = time1 + data * 86400000
  453. let item = new Date(date)
  454. var year = item.getFullYear(); //getFullYear()代替getYear()
  455. var month = item.getMonth() + 1;//月 getMonth():0 ~ 11
  456. var day = item.getDate();//日 getDate():(1 ~ 31)
  457. var time = year + '-' + this.addZero(month) + '-' + this.addZero(day);
  458. return time
  459. },
  460. addZero(time) {
  461. return time < 10 ? ('0' + time) : time;
  462. },
  463. nameClik(){
  464. if(this.classId.label == undefined){
  465. this.$u.toast('请先选择班级信息')
  466. return
  467. }
  468. this.nameShow = true
  469. },
  470. thimeST(){
  471. this.timeShow = true
  472. },
  473. // 选择上午下午
  474. timeSelect(val){
  475. if(val){
  476. this.timeData = val.value[0].name
  477. }
  478. this.startTime = this.currentDateArray[0] +' ' + this.timeData
  479. // console.log(this.timeData , this.currentDateArray[0], 'time')
  480. if(this.dayData){
  481. const day = parseFloat(this.dayData)
  482. let iosdatestr = this.currentDateArray[0]
  483. let result = uni.getSystemInfoSync()     if(result.platform == 'ios'){       iosdatestr = this.currentDateArray[0].replaceAll('-','/')     }
  484. let endTimes = new Date(iosdatestr + ' 00:00:00').getTime()
  485. if(this.timeData === '上午'){
  486. if(day > 0.5){
  487. endTimes = (endTimes + day*24*60*60*1000) - 1000
  488. }else{
  489. endTimes = endTimes + day*24*60*60*1000
  490. }
  491. } else {
  492. endTimes = (endTimes + 12*60*60*1000 + day*24*60*60*1000) - 1000
  493. }
  494. console.log(endTimes)
  495. endTimes = new Date(endTimes)
  496. const y = endTimes.getFullYear()
  497. const m = (endTimes.getMonth()+1)<10? `0${endTimes.getMonth()+1}` : endTimes.getMonth()+1
  498. const d = (endTimes.getDate())<10? `0${endTimes.getDate()}` : endTimes.getDate()
  499. const h = endTimes.getHours()
  500. const M = endTimes.getMinutes()<10? `0${endTimes.getMinutes()}` : endTimes.getMinutes()
  501. const s = endTimes.getSeconds()<10? `0${endTimes.getSeconds()}` : endTimes.getSeconds()
  502. this.tempEnd = `${y}-${m}-${d} ${h}:${M}:${s}`
  503. console.log('itme', this.tempEnd, h)
  504. if(h<=12){
  505. this.endTime = `${y}-${m}-${d}日 上午`
  506. console.log(`${y}年${m}月${d}日 上午`)
  507. } else {
  508. this.endTime = `${y}-${m}-${d}日- 下午`
  509. console.log(`${y}年${m}月${d}日 下午`)
  510. }
  511. }
  512. this.timeShow = false
  513. },
  514. }
  515. }
  516. </script>
  517. <style lang="scss" scoped>
  518. page{
  519. /* background-color: #D9D9D9; */
  520. background-color: #F5F5F5 !important;
  521. }
  522. .title{
  523. height: 80rpx;
  524. line-height: 80rpx;
  525. font-size: 23rpx;
  526. color: rgba(0,0,0,0.60);
  527. background: #f5f6f7;
  528. color: rgba(0,0,0,0.60);
  529. padding-left: 32rpx;
  530. box-sizing: border-box;
  531. }
  532. .u-cell{
  533. background-color: #fff;
  534. height: 112rpx;
  535. line-height: 73rpx;
  536. }
  537. .u-cell-text {
  538. font-size: 32rpx;
  539. overflow: hidden;
  540. }
  541. .u-cell-text image{
  542. width: 10rpx;
  543. height: 28rpx;
  544. margin-left: 15rpx ;
  545. }
  546. .symptom{
  547. margin-top: 20rpx;
  548. padding: 32rpx 32rpx;
  549. box-sizing: border-box;
  550. background-color: #fff;
  551. }
  552. .upImage{
  553. width: 160rpx;
  554. height: 160rpx;
  555. border-radius: 16rpx;
  556. border: 2rpx solid #d9d9d9;
  557. display: flex;
  558. justify-content: center;
  559. }
  560. .choice{
  561. height: 178rpx;
  562. background-color: #fff;
  563. margin-top: 20rpx;
  564. padding-top: 36rpx;
  565. box-sizing: border-box;
  566. }
  567. .submit{
  568. height: 240rpx;
  569. padding-top: 49rpx;
  570. box-sizing: border-box;
  571. }
  572. </style>