index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521
  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. <Sever v-if="classData.length != 0" :classData="classData" :classShow="classShow" @search="search" @cancelClass="cancelClass"></Sever>
  20. </view>
  21. <view class="content">
  22. <u-cell :value="studentId.label" isLink @click="nameShow=true">
  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" style="margin-top: 20rpx;">
  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">
  80. <u-cell>
  81. <view
  82. slot="title"
  83. class="u-slot-title"
  84. >
  85. <text class="u-cell-text">
  86. <RedDot text="体温" :required="true"></RedDot>
  87. <u--input
  88. placeholder="请输入"
  89. border="none"
  90. v-model="formData.temperature"
  91. style="width: 200rpx; position: absolute; top:10rpx; left:570rpx; float: right;"
  92. ></u--input>
  93. </text>
  94. </view>
  95. </u-cell>
  96. </view>
  97. </template>
  98. <view class="title">
  99. 请假时间
  100. </view>
  101. <!-- 请假时间 -->
  102. <template>
  103. <view class="content">
  104. <u-cell :value="currentDateArray[0]" isLink @click="timeShow1=true">
  105. <view
  106. slot="title"
  107. class="u-slot-title"
  108. >
  109. <text class="u-cell-text">
  110. <RedDot text="开始时间" :required="true"></RedDot>
  111. </text>
  112. </view>
  113. </u-cell>
  114. <u-popup :show="timeShow1" mode="bottom" safe-area-inset-bottom>
  115. <timeSever @onDateClick="getSelectDatatemp" @onDayClick="onDayClicks" />
  116. </u-popup>
  117. </view>
  118. <view class="content">
  119. <u-cell :value="formData.dayData || '请选择'" isLink @click="dayShow=true">
  120. <view
  121. slot="title"
  122. class="u-slot-title"
  123. >
  124. <text class="u-cell-text">
  125. <RedDot text="天数" :required="true"></RedDot>
  126. </text>
  127. </view>
  128. </u-cell>
  129. <u-picker
  130. :show="dayShow"
  131. :columns="dayList"
  132. @cancel="dayShow=false"
  133. @confirm="choiceDay"
  134. :closeOnClickOverlay="true"
  135. @close="dayShow=false"
  136. ></u-picker>
  137. </view>
  138. <view class="content">
  139. <u-cell :value="currentDateArray[1]" isLink>
  140. <view
  141. slot="title"
  142. class="u-slot-title"
  143. >
  144. <text class="u-cell-text">
  145. 结束时间
  146. </text>
  147. </view>
  148. </u-cell>
  149. <!-- <u-popup :show="timeShow2" mode="bottom" safe-area-inset-bottom>
  150. <timeSever @onDateClick="getSelectDatatemp" @onDayClick="onDayClicks1" />
  151. </u-popup> -->
  152. </view>
  153. </template>
  154. <!-- 请假事由 -->
  155. <view class="symptom">
  156. <text class="u-cell-text">
  157. 请假事由
  158. </text>
  159. <u--textarea border="none" style="margin: 32rpx 0 72rpx 0; padding: 0;" v-model="formData.reason" placeholder="请输入" autoHeight ></u--textarea>
  160. </view>
  161. <!-- 照片 -->
  162. <view class="symptom">
  163. <text class="u-cell-text" style="color: rgba(0,0,0,0.60);">
  164. 照片
  165. </text>
  166. <upImage :img="symptomImgs" @addImg='addImg'></upImage>
  167. </view>
  168. <!-- 提交按钮 -->
  169. <view class="submit">
  170. <u-button
  171. @click="add"
  172. shape="circle"
  173. type="primary"
  174. text="提交"
  175. color="#7B5DF0"
  176. style="width: 550rpx;"
  177. ></u-button>
  178. </view>
  179. </view>
  180. </template>
  181. <script>
  182. import RedDot from '../../conponents/red-dot.vue'
  183. import Sever from "../../conponents/Sever/SeverTwo.vue"
  184. import timeSever from "../../conponents/Sever/timeSever.vue"
  185. import upImage from '../../conponents/upload/upImage.vue'
  186. export default {
  187. components:{
  188. RedDot,
  189. Sever,
  190. timeSever,
  191. upImage,
  192. },
  193. data() {
  194. return {
  195. user:"请选择",
  196. show:false,
  197. nameShow: false, // 姓名选择显隐
  198. symptom: "", // 症状文本
  199. currentDateArray: ['请选择', '请选择'], // 时间
  200. timeShow1: false, // 开始时间选择显隐
  201. timeShow2: false, // 结束时间选择显隐
  202. classData: [], // 班级数据
  203. classId: {
  204. label: '请选择'
  205. },
  206. classShow: false, // 班级显隐
  207. symptomImgs: [], // 照片
  208. img: [],
  209. fileList3: [{
  210. url: 'https://cdn.uviewui.com/uview/swiper/1.jpg',
  211. }],
  212. columns:[],
  213. leaveTypeShow: false, // 请假类型显隐
  214. LeaveTypeData: '请选择', // 请假类型
  215. leaveType: [
  216. [{name: '事假',},{name: '病假',},]
  217. ], // 请假类型
  218. leaveData: [],
  219. VerShow: false,
  220. studentId: {
  221. label: '请选择'
  222. }, // 学生id
  223. nameList: [],
  224. dayShow: false, // 天数显隐
  225. dayList: [], // 天数选择
  226. formData: {
  227. temperature: '', // 体温
  228. VerData: '',
  229. reason: '', // 请假事由
  230. },
  231. }
  232. },
  233. created() {
  234. this.getClass()
  235. this.leavetype()
  236. this.day()
  237. },
  238. methods: {
  239. choiceUser(e){
  240. console.log("e==>",e)
  241. this.show=false;
  242. this.user=e.value[0].name;
  243. },
  244. // 请假类型确定
  245. choiceLeaveType(e){
  246. console.log("e==>",e)
  247. this.leaveTypeShow=false;
  248. this.LeaveTypeData=e.value[0].name;
  249. },
  250. choiceVer(e){
  251. console.log("e==>",e)
  252. this.VerShow=false;
  253. this.formData.VerData=e.value[0];
  254. },
  255. // 天数选择
  256. choiceDay(e){
  257. console.log("e==>",e)
  258. this.dayShow=false;
  259. this.formData.dayData=e.value[0];
  260. this.currentDateArray[1] = this.time(this.currentDateArray[0], e.value)
  261. },
  262. // 学生选择
  263. choiceName(e){
  264. this.nameShow = false
  265. this.studentId = e.value[0]
  266. },
  267. onDayClicks(data) {
  268. this.currentDateArray[0] = data.date
  269. this.timeShow1 = false
  270. console.log('时间' , this.currentDateArray[0])
  271. },
  272. onDayClicks1(data) {
  273. this.currentDateArray[1] = data.date
  274. this.timeShow2 = false
  275. console.log('时间' , this.currentDateArray[1])
  276. },
  277. // 获取学校年级班级等数据
  278. getClass(){
  279. let tenantId = localStorage.getItem('tenant_id')
  280. this.$request({
  281. url: this.$api.classesTree.getClassesTree,
  282. header: {
  283. contentType: "application/json"
  284. },
  285. data:{
  286. tenantId: tenantId
  287. }
  288. }).then(res=>{
  289. let arr = res.data[0].children
  290. arr.unshift({
  291. label: res.data[0].label,
  292. id: res.data[0].id,
  293. children: [''],
  294. })
  295. this.classData = arr
  296. }).catch(err=>{
  297. console.log('err' , err)
  298. })
  299. },
  300. getName(){
  301. this.$request({
  302. url: this.$api.addHandle.getNameSelectVos,
  303. header: {
  304. contentType: "application/json"
  305. },
  306. data:{
  307. classId: this.classId.id
  308. }
  309. }).then(res=>{
  310. this.nameList.push(res.data)
  311. })
  312. },
  313. leavetype(){
  314. this.$request({
  315. url: this.$api.leave.leavetype,
  316. header: {
  317. contentType: "application/json"
  318. },
  319. data:{
  320. current: 1,
  321. size: 999,
  322. }
  323. }).then(res=>{
  324. this.leaveData.push(res.data.records)
  325. })
  326. },
  327. addImg(img){
  328. console.log('img' , img)
  329. this.img = []
  330. for(let item of img){
  331. this.img.push(item.url)
  332. }
  333. },
  334. add(){
  335. const date = new Date()
  336. const y = date.getFullYear()
  337. const m = (date.getMonth()+1)<10? `0${date.getMonth()+1}`: date.getMonth()+1
  338. const d = (date.getDate())<10? `0${date.getDate()}`: date.getDate()
  339. const h = (date.getHours())<10? `0${date.getHours()}` : date.getHours()
  340. const mm = (date.getMinutes())<10? `0${date.getMinutes()}` : date.getMinutes()
  341. const ss =(date.getSeconds())<10? `0${date.getSeconds()}`: date.getSeconds()
  342. const applyTime = `${y}-${m}-${d} ${h}:${mm}:${ss}`
  343. this.$request({
  344. url: this.$api.leave.add,
  345. header: {
  346. contentType: "application/json"
  347. },
  348. method: 'POST',
  349. data:{
  350. daysOff: this.formData.dayData,
  351. startStr: '上午',
  352. endStr: '上午',
  353. startTime: this.currentDateArray[0] + ' 00:00:00',
  354. temperature: this.formData.temperature,
  355. endTime: this.currentDateArray[1] + ' 00:00:00',
  356. enclosure: this.img.join(','),
  357. applyTime: applyTime,
  358. reason: this.formData.reason,
  359. studentId: this.studentId.value,
  360. leaveType: this.LeaveTypeData,
  361. disease: this.formData.VerData.id,
  362. }
  363. }).then(res=>{
  364. this.$u.toast('添加成功')
  365. uni.switchTab({
  366. url: '/pages/leave/index'
  367. });
  368. })
  369. },
  370. // 选择班级触发获取数据
  371. search(data){
  372. console.log(data)
  373. this.classShow = false
  374. this.classId = data
  375. this.getName()
  376. },
  377. cancelClass(){
  378. this.classShow = false
  379. },
  380. // 循环生成天数
  381. day(){
  382. let arr = []
  383. var da = 0
  384. for(var i = 1; i<=60; i++){
  385. arr.push(da += 0.5)
  386. }
  387. this.dayList.push(arr)
  388. },
  389. time(time, data){
  390. var x = new Date(time);
  391. var time1 = x.getTime();
  392. let date = time1 + data * 86400000
  393. let item = new Date(date)
  394. var year = item.getFullYear(); //getFullYear()代替getYear()
  395. var month = item.getMonth() + 1;//月 getMonth():0 ~ 11
  396. var day = item.getDate();//日 getDate():(1 ~ 31)
  397. var time = year + '-' + this.addZero(month) + '-' + this.addZero(day);
  398. return time
  399. },
  400. addZero(time) {
  401. return time < 10 ? ('0' + time) : time;
  402. },
  403. }
  404. }
  405. </script>
  406. <style lang="scss" scoped>
  407. page{
  408. /* background-color: #D9D9D9; */
  409. background-color: #F5F5F5 !important;
  410. }
  411. .title{
  412. height: 80rpx;
  413. line-height: 80rpx;
  414. font-size: 23rpx;
  415. color: rgba(0,0,0,0.60);
  416. background: #f5f6f7;
  417. color: rgba(0,0,0,0.60);
  418. padding-left: 32rpx;
  419. box-sizing: border-box;
  420. }
  421. .u-cell{
  422. background-color: #fff;
  423. height: 112rpx;
  424. line-height: 73rpx;
  425. }
  426. .u-cell-text {
  427. font-size: 32rpx;
  428. position: relative;
  429. }
  430. .u-cell-text image{
  431. width: 10rpx;
  432. height: 28rpx;
  433. margin-left: 15rpx ;
  434. }
  435. .symptom{
  436. margin-top: 20rpx;
  437. padding: 32rpx 32rpx;
  438. box-sizing: border-box;
  439. background-color: #fff;
  440. }
  441. .upImage{
  442. width: 160rpx;
  443. height: 160rpx;
  444. border-radius: 16rpx;
  445. border: 2rpx solid #d9d9d9;
  446. display: flex;
  447. justify-content: center;
  448. }
  449. .choice{
  450. height: 178rpx;
  451. background-color: #fff;
  452. margin-top: 20rpx;
  453. padding-top: 36rpx;
  454. box-sizing: border-box;
  455. }
  456. .submit{
  457. height: 240rpx;
  458. padding-top: 49rpx;
  459. box-sizing: border-box;
  460. }
  461. </style>