index.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625
  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="search"></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. }
  357. }).then(res=>{
  358. // console.log('res', res)
  359. this.listDataTwo = res.data.records
  360. setTimeout(()=> {
  361. this.loading = false
  362. }, 1000)
  363. }).catch(err=>{
  364. console.log('err' , err)
  365. setTimeout(()=> {
  366. this.loading = false
  367. }, 1000)
  368. })
  369. },
  370. // 选择范围触发获取数据
  371. search(data){
  372. console.log(data)
  373. this.classId = data
  374. this.getData()
  375. this.getStati()
  376. this.getList()
  377. this.getListTwo()
  378. },
  379. // 点击改变是否观察或者处理记录
  380. to(data){
  381. this.tobu = data
  382. this.getListTwo()
  383. },
  384. // 跳转新增
  385. toAdd(){
  386. uni.navigateTo({
  387. url: '/pages/addLeave/index'
  388. })
  389. },
  390. tabelOpen(){
  391. this.tabelShow = !this.tabelShow
  392. },
  393. // 获取当前时间
  394. getTime(){
  395. var date = new Date();//年 getFullYear():四位数字返回年份
  396. var year = date.getFullYear(); //getFullYear()代替getYear()
  397. var month = date.getMonth() + 1;//月 getMonth():0 ~ 11
  398. var day = date.getDate();//日 getDate():(1 ~ 31)
  399. var time = year + '-' + this.addZero(month) + '-' + this.addZero(day);
  400. this.currentDateArray[0] = time
  401. this.currentDateArray1[0] = time
  402. this.currentDateArray2[0] = time
  403. },
  404. addZero(time) {
  405. return time < 10 ? ('0' + time) : time;
  406. },
  407. onDayClicks(data) {
  408. this.currentDateArray[0] = data.date
  409. this.shows = false
  410. console.log('时间' , this.currentDateArray[0])
  411. this.getData()
  412. this.getList()
  413. this.getStati()
  414. this.getListTwo()
  415. },
  416. onDayClicks1(data){
  417. this.currentDateArray1[0] = data.date
  418. this.timeShow = false
  419. this.getListTwo()
  420. },
  421. onDayClicks2(data){
  422. this.currentDateArray1[0] = data[0]
  423. this.currentDateArray2[0] = data[1]
  424. this.timeShow = false
  425. this.getListTwo()
  426. },
  427. }
  428. }
  429. </script>
  430. <style lang="scss" scoped>
  431. page{
  432. // padding: 0 32rpx;
  433. /* background-color: #D9D9D9; */
  434. background-color: #F5F5F5 !important;
  435. }
  436. .topTwo{
  437. position: fixed;
  438. top: -2rpx;
  439. background-color: #f5f5f5;
  440. padding-bottom: 10rpx;
  441. z-index: 999;
  442. width: 100%;
  443. box-sizing: border-box;
  444. }
  445. // 暂无数据
  446. .noneData{
  447. padding-top: 200rpx;
  448. display: flex;
  449. justify-content: center;
  450. }
  451. .tesx{
  452. display: flex;
  453. align-items: center;
  454. font-size: 32rpx;
  455. color: rgba(0,0,0,0.60);
  456. height: 128rpx;
  457. padding: 0 32rpx;
  458. box-sizing: border-box;
  459. }
  460. .con{
  461. font-size: 40rpx;
  462. font-weight: 600;
  463. color: #000;
  464. }
  465. .choice{
  466. height: 96rpx;
  467. line-height: 96rpx;
  468. padding: 0 32rpx;
  469. box-sizing: border-box;
  470. border-bottom: 1px solid rgba(0,0,0,0.10);
  471. }
  472. .choice-left{
  473. float: left;
  474. overflow: hidden;
  475. display: flex;
  476. width: 250rpx;
  477. }
  478. // 概览
  479. .total{
  480. height: 302rpx;
  481. box-sizing: border-box;
  482. padding: 32rpx 32rpx;
  483. background-color: #fff;
  484. border-radius: 32rpx;
  485. margin: 20rpx 32rpx 0;
  486. font-size: 25rpx;
  487. }
  488. .total-txt{
  489. font-weight: 600;
  490. margin-top: 6rpx;
  491. margin-right: 15rpx;
  492. display: inline-block;
  493. }
  494. // 记录
  495. .record{
  496. padding: 32rpx 37rpx;
  497. box-sizing: border-box;
  498. font-size: 28rpx;
  499. color: rgba(0,0,0,0.60);
  500. border-bottom: 1px solid rgba(0,0,0,0.10);
  501. }
  502. .information{
  503. height: 47rpx;
  504. line-height: 47rpx;
  505. }
  506. .suspension{
  507. width: 96rpx;
  508. height: 96rpx;
  509. border-radius: 50px;
  510. background-color: #7b5df0;
  511. position:fixed;
  512. right: 32rpx;
  513. bottom: 168rpx;
  514. }
  515. .suspension image{
  516. width: 100%;
  517. height: 100%;
  518. }
  519. .line{
  520. margin-top: 25rpx;
  521. border-top: 1rpx solid #F0F0F0;
  522. display: flex;
  523. padding-top: 20rpx;
  524. }
  525. .student{
  526. box-sizing: border-box;
  527. padding: 36rpx 32rpx 6rpx 32rpx;
  528. background-color: #fff;
  529. border-radius: 32rpx;
  530. margin: 32rpx 32rpx 0;
  531. font-size: 25rpx;
  532. text{
  533. font-size: 32rpx;
  534. font-weight: 600;
  535. color: rgba(0,0,0,0.90);;
  536. }
  537. .icon{
  538. width: 50rpx;
  539. height: 50rpx;
  540. margin: 0 auto;
  541. line-height: 50rpx;
  542. display: flex;
  543. justify-content: center;
  544. }
  545. }
  546. .time-show{
  547. display: inline-block;
  548. float: left;
  549. }
  550. </style>