index.vue 12 KB

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