index.vue 15 KB

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