index.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637
  1. <template>
  2. <view>
  3. <view>
  4. <view class="topTwo">
  5. <!-- 头部导航 -->
  6. <view class="tesx">
  7. <view :class="tobu == 1 ? 'con' : ''" @click="to(1)" style="margin-right: 20rpx;">概览</view>
  8. <view :class="tobu == 2 ? 'con' : ''" @click="to(2)">记录</view>
  9. </view>
  10. <view class="choice" style="border: 0;" v-if="tobu == 1">
  11. <Sever v-if="classData.length != 0" :classData="classData" @search="search"></Sever>
  12. <div @click="shows=true">
  13. {{currentDateArray[0]}} <u-icon name="arrow-down" style="margin-left: 17rpx; display: inline-block;"></u-icon>
  14. </div>
  15. <u-popup :show="shows" mode="bottom" safe-area-inset-bottom :closeOnClickOverlay="true" @close="shows = false" >
  16. <timeSever @onDateClick="getSelectDatatemp" @onDayClick="onDayClicks" />
  17. </u-popup>
  18. </view>
  19. <view class="choice" v-if="tobu == 2">
  20. <Sever v-if="classData.length != 0" :classData="classData" @search="searchTwo"></Sever>
  21. <div @click="timeShow=true" class="time-show">
  22. {{currentDateArray1[0]}}~{{currentDateArray2[0]}}
  23. </div>
  24. <!-- 时间范围选择 -->
  25. <!-- <u-popup :show="timeShow" mode="bottom" safe-area-inset-bottom :closeOnClickOverlay="true" @close="timeShow = false" >
  26. <timeSever @onDateClick="getSelectDatatemp" @onDayClick="onDayClicks1" />
  27. </u-popup> -->
  28. <!-- <text style="float: left;"> ~ </text>
  29. <div @click="timeShow=true" class="time-show">
  30. {{currentDateArray2[0]}}
  31. </div> -->
  32. <!-- 时间范围选择 -->
  33. <u-popup :show="timeShow" mode="bottom" safe-area-inset-bottom :closeOnClickOverlay="true" @close="timeShow = false" >
  34. <timeSever2 @onDateClick="getSelectDatatemp1" @onDayClick="onDayClicks2" />
  35. </u-popup>
  36. <u-icon name="arrow-down" style="margin-left: 10rpx; display: inline-block;"></u-icon>
  37. </view>
  38. </view>
  39. </view>
  40. <view style="height: 235rpx;"></view>
  41. <!-- 概览 -->
  42. <view v-if="tobu == 1">
  43. <!-- <view class="choice" style="border: 0;">
  44. <Sever v-if="classData.length != 0" :classData="classData" @search="search"></Sever>
  45. <div @click="shows=true">
  46. {{currentDateArray[0]}} <u-icon name="arrow-down" style="margin-left: 17rpx; display: inline-block;"></u-icon>
  47. </div>
  48. <u-popup :show="shows" mode="bottom" safe-area-inset-bottom :closeOnClickOverlay="true" @close="shows = false" >
  49. <timeSever @onDateClick="getSelectDatatemp" @onDayClick="onDayClicks" />
  50. </u-popup>
  51. </view> -->
  52. <!-- 总人数 -->
  53. <view class="total">
  54. <view style="margin-bottom: 5rpx">总请假人数</view>
  55. <text class="total-txt" style="font-size: 49rpx;">{{leaveData.hj || 0}}</text>人
  56. <view class="line">
  57. <view style="margin-right: 235rpx;">
  58. <view style="margin-bottom: 5rpx; color: rgba(0,0,0,0.60);">病假</view>
  59. <text class="total-txt" style="font-size: 36rpx;">{{leaveData.bj || 0}}</text>人
  60. </view>
  61. <view>
  62. <view style="margin-bottom: 5rpx; color: rgba(0,0,0,0.60);" >事假</view>
  63. <text class="total-txt" style="font-size: 36rpx;">{{leaveData.sj || 0}}</text>人
  64. </view>
  65. </view>
  66. </view>
  67. <view class="student">
  68. <text style="display: block; margin-bottom: 32rpx;">病假类型</text>
  69. <Echarts v-if="Chart.length != 0" :Chart="Chart"></Echarts>
  70. </view>
  71. <view class="student" style="margin-bottom: 20rpx;">
  72. <text style="display: block; margin-bottom: 32rpx;">请假学生</text>
  73. <view v-if="listData.length == 0">
  74. <view style="text-align: center; line-height: 150rpx;">
  75. 暂无数据
  76. </view>
  77. </view>
  78. <Table v-if="listData.length < 3" :tableEye="tableEye" :eyeData="eyeDataOpen" />
  79. <Table v-else :tableEye="tableEye" :eyeData="tabelShow ? eyeDataOpen : eyeData" />
  80. <view class="icon" v-if="eyeDataOpen.length > 3">
  81. <u-icon v-if="tabelShow" name="arrow-up" @click="tabelOpen"></u-icon>
  82. <u-icon v-else name="arrow-down" @click="tabelOpen"></u-icon>
  83. </view>
  84. </view>
  85. </view>
  86. <!-- 记录 -->
  87. <view v-if="tobu == 2">
  88. <!-- <view class="choice">
  89. <Sever v-if="classData.length != 0" :classData="classData" @search="search"></Sever>
  90. <div @click="timeShow=true" class="time-show">
  91. {{currentDateArray1[0]}}
  92. </div>
  93. <text style="float: left;"> ~ </text>
  94. <div @click="timeShow=true" class="time-show">
  95. {{currentDateArray2[0]}}
  96. </div> -->
  97. <!-- 时间范围选择 -->
  98. <!-- <u-popup :show="timeShow" mode="bottom" safe-area-inset-bottom :closeOnClickOverlay="true" @close="timeShow = false" >
  99. <timeSever2 @onDateClick="getSelectDatatemp1" @onDayClick="onDayClicks2" />
  100. </u-popup>
  101. <u-icon name="arrow-down" style="margin-left: 17rpx; display: inline-block;"></u-icon>
  102. </view> -->
  103. <view v-if="listDataTwo.length != 0">
  104. <view class="record" v-for="item in listDataTwo">
  105. <view style="color: #000; font-weight: 600; margin-bottom: 23rpx;">
  106. {{item.studentName}}的请假
  107. <text style="color: rgba(0,0,0,0.60); font-weight: 500; float: right; display: inline-block;">{{item.applyTime}}</text>
  108. </view>
  109. <view class="information">
  110. <text>请假类型:</text>
  111. <text>{{item.leaveType}}</text>
  112. </view>
  113. <view class="information">
  114. <text>学生姓名:</text>
  115. <text>{{item.studentName}}</text>
  116. </view>
  117. <view class="information">
  118. <text>所在班级:</text>
  119. <text>{{item.className}}</text>
  120. </view>
  121. <view class="information">
  122. <text>开始时间:</text>
  123. <text>{{item.startTimeStr}}</text>
  124. </view>
  125. <view class="information">
  126. <text>结束时间:</text>
  127. <text>{{item.endTimeStr}}</text>
  128. </view>
  129. <view class="information">
  130. <text>请假天数:</text>
  131. <text>{{item.daysOff}}天</text>
  132. </view>
  133. </view>
  134. </view>
  135. <view v-else>
  136. <view class="noneData">
  137. <view style="text-align: center;">
  138. <image style="width: 79px;height: 94px;" src="../../static/nodata.png" mode=""></image>
  139. <br>暂无数据
  140. </view>
  141. </view>
  142. </view>
  143. </view>
  144. <!-- 悬浮按钮 -->
  145. <view class="suspension" @click="toAdd" v-if="tobu == 1">
  146. <image src="../../static/icon.svg"></image>
  147. </view>
  148. <u-loading-page :loading="loading" loading-text="加载中" bg-color="rgba(0,0,0,0.60)" style="z-index: 999999;"></u-loading-page>
  149. </view>
  150. </template>
  151. <script>
  152. import Table from "../../conponents/table/tabel.vue"
  153. import Echarts from "../../conponents/Echar/ring.vue"
  154. import Sever from "../../conponents/Sever/Sever.vue"
  155. import timeSever from "../../conponents/Sever/timeSever.vue"
  156. import timeSever2 from "../../conponents/Sever/timeSever2.vue"
  157. export default {
  158. components:{
  159. Table,
  160. Echarts,
  161. Sever,
  162. timeSever,
  163. timeSever2,
  164. },
  165. computed: {
  166. // 计算时间
  167. dateRange() {
  168. let startName = this.currentDateArray[0]
  169. return [startName]
  170. },
  171. },
  172. data() {
  173. return {
  174. providerList: [],
  175. version: '',
  176. handle: 'Mba',
  177. tobu: '1',
  178. dato: [{}, {}],
  179. shows: false, // 时间选择
  180. timeShow: false, // 时间范围选择一 显隐
  181. timeShow2: false, // 时间范围选择二 显隐
  182. currentDateArray: [], // 时间选择
  183. currentDateArray1: [], // 时间范围选择 开始值
  184. currentDateArray2: [], // 时间范围选择 结束值
  185. classData: [], // 班级信息
  186. classId: '', // 选中范围id
  187. leaveData: '', // 请假数据
  188. listData: [], // 列表数据
  189. listDataTwo: [], // 记录列表数据
  190. tableEye: [
  191. {label: '班级', span: 4, title: 'className',},
  192. {label: '姓名', span: 3, title: 'studentName',},
  193. {label: '类型', span: 3, title: 'leaveType',},
  194. {label: '请假天数', span: 2, title: 'daysOff',},
  195. ], // 眼科 屈光度 列表头部 !label为表头名字 span为此列占据位置 title为数据的键
  196. eyeDataOpen: [], // 眼科 屈光度 列表头部 数据 !注意该条数据前面加个空值用于循环渲染出表格表头
  197. // 表格展开数据
  198. eyeData: [],
  199. // 表格折叠时数据
  200. tabelShow: false, // 控制表格显隐
  201. loading: false, // 加载动画
  202. Chart: [
  203. ], // 图表
  204. }
  205. },
  206. onShow() {
  207. this.getClass()
  208. this.getTime()
  209. },
  210. methods: {
  211. // 获取数据
  212. getData(){
  213. this.loading = true
  214. this.$request({
  215. url: this.$api.leave.orgStudentWork,
  216. header: {
  217. contentType: "application/json"
  218. },
  219. data:{
  220. classId: this.classId,
  221. endTime: this.currentDateArray[0],
  222. startTime: this.currentDateArray[0],
  223. }
  224. }).then(res=>{
  225. console.log('res', res)
  226. // this.leaveData = res.data[0]
  227. if(this.classId){
  228. this.leaveData = res.data[1]
  229. }else{
  230. this.leaveData = res.data[0]
  231. }
  232. setTimeout(()=> {
  233. this.loading = false
  234. }, 1000)
  235. }).catch(err=>{
  236. console.log('err' , err)
  237. setTimeout(()=> {
  238. this.loading = false
  239. }, 1000)
  240. })
  241. },
  242. // 获取学校年级班级等数据
  243. getClass(){
  244. let tenantId = localStorage.getItem('tenant_id')
  245. this.$request({
  246. url: this.$api.classesTree.getClassesTree,
  247. header: {
  248. contentType: "application/json"
  249. },
  250. data:{
  251. tenantId: tenantId
  252. }
  253. }).then(res=>{
  254. let arr = res.data[0].children
  255. arr.unshift({
  256. label: res.data[0].label,
  257. id: res.data[0].id,
  258. children: [''],
  259. })
  260. this.classData = arr
  261. // this.classId = arr[0].id
  262. // 获取班级信息之后请求数据
  263. this.getData()
  264. this.getStati()
  265. this.getList()
  266. // console.log(this.classData)
  267. }).catch(err=>{
  268. console.log('err' , err)
  269. })
  270. },
  271. // 获取统计数据
  272. getStati(){
  273. let tenantId = localStorage.getItem('tenant_id')
  274. this.$request({
  275. url: this.$api.leave.orgStudentWorkDistri,
  276. header: {
  277. contentType: "application/json"
  278. },
  279. data:{
  280. classId: this.classId,
  281. endTime: this.currentDateArray[0],
  282. startTime: this.currentDateArray[0],
  283. }
  284. }).then(res=>{
  285. // console.log('res', res)
  286. let arr = []
  287. for(let item of res.data.list){
  288. if(item.num != 0){
  289. arr.push({
  290. name: item.type,
  291. value: item.num
  292. })
  293. }
  294. }
  295. if(arr.length == 0){
  296. this.Chart = []
  297. this.Chart.push({
  298. name: '暂无数据',
  299. value: 0
  300. })
  301. }else{
  302. this.Chart = arr
  303. }
  304. }).catch(err=>{
  305. console.log('err' , err)
  306. })
  307. },
  308. // 获取列表数据
  309. getList(){
  310. let tenantId = localStorage.getItem('tenant_id')
  311. this.$request({
  312. url: this.$api.leave.page,
  313. header: {
  314. contentType: "application/json"
  315. },
  316. data:{
  317. classId: this.classId,
  318. endTimeStr: this.currentDateArray[0],
  319. startTimeStr: this.currentDateArray[0],
  320. size: 10,
  321. current: 1,
  322. status: 1,
  323. }
  324. }).then(res=>{
  325. // console.log('res', res)
  326. this.listData = res.data.records
  327. this.eyeDataOpen = res.data.records
  328. if(this.listData.length > 2){
  329. this.eyeData = [
  330. this.listData[0],
  331. this.listData[1]
  332. ]
  333. }
  334. console.log('listData', this.listData, res)
  335. // this.eyeData.unshift({})
  336. // this.eyeDataOpen.unshift({})
  337. }).catch(err=>{
  338. console.log('err' , err)
  339. })
  340. },
  341. // 记录获取列表数据
  342. getListTwo(){
  343. this.loading = true
  344. let tenantId = localStorage.getItem('tenant_id')
  345. this.$request({
  346. url: this.$api.leave.page,
  347. header: {
  348. contentType: "application/json"
  349. },
  350. data:{
  351. classId: this.classId,
  352. startTimeStr: this.currentDateArray1[0],
  353. endTimeStr: this.currentDateArray2[0],
  354. size: 999,
  355. current: 1,
  356. status: 1,
  357. }
  358. }).then(res=>{
  359. // console.log('res', res)
  360. this.listDataTwo = res.data.records
  361. setTimeout(()=> {
  362. this.loading = false
  363. }, 1000)
  364. }).catch(err=>{
  365. console.log('err' , err)
  366. setTimeout(()=> {
  367. this.loading = false
  368. }, 1000)
  369. })
  370. },
  371. // 选择范围触发获取数据
  372. search(data){
  373. console.log(data)
  374. this.classId = data
  375. this.getData()
  376. this.getStati()
  377. this.getList()
  378. // this.getListTwo()
  379. },
  380. searchTwo(data){
  381. console.log(data)
  382. this.classId = data
  383. this.getListTwo()
  384. },
  385. // 点击改变是否观察或者处理记录
  386. to(data){
  387. this.tobu = data
  388. // this.getListTwo()
  389. if(data == 1){
  390. this.getList()
  391. }else if(data == 2){
  392. this.getListTwo()
  393. }
  394. },
  395. // 跳转新增
  396. toAdd(){
  397. uni.navigateTo({
  398. url: '/pages/addLeave/index'
  399. })
  400. },
  401. tabelOpen(){
  402. this.tabelShow = !this.tabelShow
  403. },
  404. // 获取当前时间
  405. getTime(){
  406. var date = new Date();//年 getFullYear():四位数字返回年份
  407. var year = date.getFullYear(); //getFullYear()代替getYear()
  408. var month = date.getMonth() + 1;//月 getMonth():0 ~ 11
  409. var day = date.getDate();//日 getDate():(1 ~ 31)
  410. var time = year + '-' + this.addZero(month) + '-' + this.addZero(day);
  411. this.currentDateArray[0] = time
  412. this.currentDateArray1[0] = time
  413. this.currentDateArray2[0] = time
  414. },
  415. addZero(time) {
  416. return time < 10 ? ('0' + time) : time;
  417. },
  418. onDayClicks(data) {
  419. this.currentDateArray[0] = data.date
  420. this.shows = false
  421. console.log('时间' , this.currentDateArray[0])
  422. this.getData()
  423. this.getList()
  424. this.getStati()
  425. // this.getListTwo()
  426. },
  427. onDayClicks1(data){
  428. this.currentDateArray1[0] = data.date
  429. this.timeShow = false
  430. this.getListTwo()
  431. },
  432. onDayClicks2(data){
  433. this.currentDateArray1[0] = data[0]
  434. this.currentDateArray2[0] = data[1]
  435. this.timeShow = false
  436. this.getListTwo()
  437. },
  438. }
  439. }
  440. </script>
  441. <style lang="scss" scoped>
  442. page{
  443. // padding: 0 32rpx;
  444. /* background-color: #D9D9D9; */
  445. background-color: #F5F5F5 !important;
  446. }
  447. .topTwo{
  448. position: fixed;
  449. top: -2rpx;
  450. background-color: #f5f5f5;
  451. padding-bottom: 10rpx;
  452. z-index: 999;
  453. width: 100%;
  454. box-sizing: border-box;
  455. }
  456. // 暂无数据
  457. .noneData{
  458. padding-top: 200rpx;
  459. display: flex;
  460. justify-content: center;
  461. }
  462. .tesx{
  463. display: flex;
  464. align-items: center;
  465. font-size: 32rpx;
  466. color: rgba(0,0,0,0.60);
  467. height: 128rpx;
  468. padding: 0 32rpx;
  469. box-sizing: border-box;
  470. }
  471. .con{
  472. font-size: 40rpx;
  473. font-weight: 600;
  474. color: #000;
  475. }
  476. .choice{
  477. height: 96rpx;
  478. line-height: 96rpx;
  479. padding: 0 32rpx;
  480. box-sizing: border-box;
  481. border-bottom: 1px solid rgba(0,0,0,0.10);
  482. }
  483. .choice-left{
  484. float: left;
  485. overflow: hidden;
  486. display: flex;
  487. width: 250rpx;
  488. }
  489. // 概览
  490. .total{
  491. height: 302rpx;
  492. box-sizing: border-box;
  493. padding: 32rpx 32rpx;
  494. background-color: #fff;
  495. border-radius: 32rpx;
  496. margin: 20rpx 32rpx 0;
  497. font-size: 25rpx;
  498. }
  499. .total-txt{
  500. font-weight: 600;
  501. margin-top: 6rpx;
  502. margin-right: 15rpx;
  503. display: inline-block;
  504. }
  505. // 记录
  506. .record{
  507. padding: 32rpx 37rpx;
  508. box-sizing: border-box;
  509. font-size: 28rpx;
  510. color: rgba(0,0,0,0.60);
  511. border-bottom: 1px solid rgba(0,0,0,0.10);
  512. }
  513. .information{
  514. height: 47rpx;
  515. line-height: 47rpx;
  516. }
  517. .suspension{
  518. width: 96rpx;
  519. height: 96rpx;
  520. border-radius: 50px;
  521. background-color: #7b5df0;
  522. position:fixed;
  523. right: 32rpx;
  524. bottom: 168rpx;
  525. }
  526. .suspension image{
  527. width: 100%;
  528. height: 100%;
  529. }
  530. .line{
  531. margin-top: 25rpx;
  532. border-top: 1rpx solid #F0F0F0;
  533. display: flex;
  534. padding-top: 20rpx;
  535. }
  536. .student{
  537. box-sizing: border-box;
  538. padding: 36rpx 32rpx 6rpx 32rpx;
  539. background-color: #fff;
  540. border-radius: 32rpx;
  541. margin: 32rpx 32rpx 0;
  542. font-size: 25rpx;
  543. text{
  544. font-size: 32rpx;
  545. font-weight: 600;
  546. color: rgba(0,0,0,0.90);;
  547. }
  548. .icon{
  549. width: 50rpx;
  550. height: 50rpx;
  551. margin: 0 auto;
  552. line-height: 50rpx;
  553. display: flex;
  554. justify-content: center;
  555. }
  556. }
  557. .time-show{
  558. display: inline-block;
  559. float: left;
  560. }
  561. </style>