index.vue 15 KB

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