leavelist.vue 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281
  1. <template>
  2. <view class="mind">
  3. <!-- tab栏 切孩子 -->
  4. <view class="top ">
  5. <view class="top_t" @click="getTab(ite.val)" :class="[tabval==ite.val?'act':'',daflag?'top_tda':'']" v-for="(ite,idx) in tablist" :key="idx">{{ite.tit}}<image :src="tapline" class="line"></image></view>
  6. </view>
  7. <view class="pt12">
  8. <xl-list :datype='datype' :roles="roles" :qjlxrange="qjlxrange" :datalist="list" :wtdt="wtdt" @getDel="getDel"></xl-list>
  9. </view>
  10. <view style="height: 100rpx;" v-if="checkPermi(['system:leave:add'])"></view>
  11. <view class="mbtn" v-if="checkPermi(['system:leave:add'])" @click="getAdd">请假</view>
  12. </view>
  13. </template>
  14. <script>
  15. import xlList from "@/mine/components/list/list.vue"
  16. import {getleaveListFn,getleaveDelFn} from "@/api/mine/files.js"
  17. import {getDeptList} from "@/api/mine/mine.js"
  18. import {getDictionaryFn} from '@/api/mine/register.js'
  19. import {checkPermi,checkRole} from "@/utils/permission"; // 权限判断函数
  20. export default {
  21. components:{
  22. xlList
  23. },
  24. data(){
  25. return{
  26. sucimg:require("@/mine/static/score/ncheck.png"),
  27. tapline:require("@/static/images/hline.png"),
  28. list:[],
  29. datype:7,
  30. pageSize: 10,
  31. pageNum: 1,
  32. reachflag: true,
  33. wtdt: '',
  34. tabval:'',
  35. actidx:-1,
  36. daflag:false,
  37. studentlist:[],
  38. qjlxrange:[],
  39. teacherClass:[],
  40. tablist:[],
  41. roles:'',
  42. }
  43. },
  44. onUnload() {
  45. uni.$off('refreshleavelist')
  46. },
  47. onReachBottom() {
  48. if (this.reachflag) {
  49. this.pageNum++
  50. this.getDataFn()
  51. }
  52. },
  53. onLoad: function(e) {
  54. uni.$on('refreshleavelist', (e) => {
  55. this.reachflag = true;
  56. this.pageNum = 1;
  57. this.list = [];
  58. this.getDataFn();
  59. })
  60. if(e.type&&e.type=='da'){
  61. this.daflag=true;
  62. this.tabval=e.id
  63. this.tablist=[{
  64. tit:e.name,
  65. val: e.id,
  66. }]
  67. }else{
  68. var roles=this.$store.state.user.choseroles;
  69. this.roles=roles;
  70. if(roles=='parents'){
  71. var newArr=this.$store.state.user.student;
  72. if(newArr&&newArr.length){
  73. this.tabval=newArr[0].id
  74. this.tablist = newArr.map(v => {
  75. return {
  76. tit:v.studentName,
  77. val: v.id,
  78. }
  79. })
  80. }
  81. }else if(roles=='teacher'){
  82. // 选择班级
  83. var newArr=this.$store.state.user.teacherClass;
  84. if(newArr&&newArr.length){
  85. this.tabval=newArr[0].classId
  86. this.tablist = newArr.map(v => {
  87. return {
  88. tit:v.className,
  89. val: v.classId,
  90. }
  91. })
  92. }
  93. }else{
  94. var id=this.$store.state.user.deptId;
  95. this.getclassListFn(id)
  96. }
  97. }
  98. this.init()
  99. this.getDataFn()
  100. },
  101. methods:{
  102. checkPermi,checkRole,
  103. getclassListFn(id){
  104. getDeptList(id).then(res=>{
  105. if(res.code==200){
  106. var newArr=res.data;
  107. if(newArr&&newArr.length){
  108. this.tabval=newArr[0].deptId
  109. this.tablist = newArr.map(v => {
  110. return {
  111. tit: v.deptName,
  112. val: v.deptId,
  113. }
  114. })
  115. }
  116. }else{
  117. this.$toast(res.msg)
  118. }
  119. })
  120. },
  121. init(){
  122. //心理健康状态
  123. getDictionaryFn('qjlx').then(res=>{
  124. if(res.code==200){
  125. this.qjlxrange = res.data.map(v => {
  126. return {
  127. dictLabel: v.dictLabel,
  128. dictValue: v.dictValue
  129. }
  130. })
  131. }
  132. })
  133. },
  134. getLook(e) {
  135. if (this.actidx == e) {
  136. this.actidx = -1
  137. } else {
  138. this.actidx = e;
  139. }
  140. },
  141. toTree2(arr){
  142. var list=this.list;
  143. let newA = JSON.parse(JSON.stringify(arr));
  144. if(list&&list.length){
  145. list.forEach(ite=>{
  146. for(var i =0;i<newA.length;i++){
  147. if(ite.ayear === newA[i].ayear&&ite.amonth === newA[i].amonth){
  148. ite.children.push(newA[i])
  149. }else{
  150. var obj={
  151. ayear:newA[i].ayear,
  152. amonth:newA[i].amonth,
  153. check:true,
  154. children:[]
  155. }
  156. obj.children.push(newA[i])
  157. list.push(obj)
  158. }
  159. }
  160. })
  161. return list
  162. }else{
  163. var newArrs = [];
  164. var larr=[]
  165. const map = new Map();
  166. newArrs = newA.filter(v => !map.has(v.ayear)&&!map.has(v.amonth) && map.set(v.ayear, 1)&& map.set(v.amonth, 1));
  167. newArrs.forEach(ite=>{
  168. var obj={
  169. ayear:ite.ayear,
  170. amonth:ite.amonth,
  171. check:true
  172. }
  173. larr.push(obj)
  174. })
  175. larr.forEach(ite=>{
  176. ite.children = newA.filter(e => {
  177. return ite.ayear === e.ayear&&ite.amonth === e.amonth
  178. })
  179. })
  180. return larr
  181. }
  182. },
  183. getAdd(){
  184. this.$tab.navigateTo(`/mine/pages/files/leave`)
  185. },
  186. getTab(idx){
  187. this.tabval=idx;
  188. this.list=[];
  189. this.reachflag=true;
  190. this.pageNum=1;
  191. this.getDataFn();
  192. },
  193. getDel(id){
  194. var that=this;
  195. getleaveDelFn(id).then(res=>{
  196. if (res.code == 200) {
  197. that.$toast('删除成功')
  198. setTimeout(function(){
  199. that.reachflag = true;
  200. that.pageNum = 1;
  201. that.list = [];
  202. that.getDataFn();
  203. },1500)
  204. } else {
  205. that.$toast(res.msg)
  206. }
  207. })
  208. },
  209. getDataFn(a) {
  210. var params = {
  211. pageSize: this.pageSize,
  212. pageNum: this.pageNum,
  213. }
  214. if(this.roles=='parents'){
  215. params.absenteeId=this.tabval
  216. }else{
  217. params.classId=this.tabval
  218. }
  219. getleaveListFn(params).then(res => {
  220. if (res.code == 200) {
  221. this.total = res.total;
  222. if (res.rows.length < this.pageSize) {
  223. this.reachflag = false
  224. this.wtdt = '到底了~';
  225. } else {
  226. var num = parseInt(res.rows.length) + parseInt(this.pageSize) * parseInt(this.pageNum -1)
  227. if (num < res.total) {
  228. this.reachflag = true
  229. this.wtdt = '上拉加载更多'
  230. } else {
  231. this.reachflag = false
  232. this.wtdt = '到底了~';
  233. }
  234. }
  235. // 数据处理
  236. var newArr=res.rows;
  237. if(newArr&&newArr.length){
  238. var timeArr=[];
  239. Object.keys(newArr).some((key) => {
  240. if(newArr[key].submitTime){
  241. var time=newArr[key].submitTime.split(' ');
  242. var a=time[0].split('-')
  243. newArr[key].ayear=a[0];
  244. newArr[key].amonth=a[1];
  245. }
  246. })
  247. this.list=this.toTree2(newArr)
  248. }else{
  249. this.list=[]
  250. }
  251. } else {
  252. this.$toast(res.msg)
  253. }
  254. })
  255. },
  256. },
  257. }
  258. </script>
  259. <style lang="scss" scoped>
  260. .mind{padding: 100rpx 36rpx 0rpx;min-height: 100vh;background-color: #ffffff;box-sizing: border-box;
  261. .mbtn{position: fixed;left: 0;right: 0;bottom: 0;height: 100rpx;display: flex;align-items: center;justify-content: center;z-index: 2;background: #1f57e6;font-size: 34rpx;font-weight: 500;
  262. color: #FFFFFF;}
  263. .top{height: 96rpx;border-bottom: 2rpx solid #E5E5E5;position: fixed;top: 0;left: 0;right: 0;overflow-x: scroll;display: flex;align-items: center;z-index: 1;background-color: #ffffff;
  264. .top_t{position: relative;font-size: 30rpx;font-weight: 500;color: #AAAAAA;height: 94rpx;line-height: 94rpx;padding:0 20rpx;flex:1 0 auto;text-align: center;
  265. &.act{color: #161616;font-weight: bold;
  266. .line{display: block;}
  267. // &::after{content: '';width: 42rpx;height: 10rpx;background: #1f57e6;border-radius: 6rpx;position: absolute;left: 50%;margin-left: -21rpx;bottom: 12rpx;}
  268. }
  269. &.top_tda{flex: 0 0 auto !important;padding: 0 40rpx;}
  270. .line{width: 40rpx;height: 12rpx;position: absolute;left: 50%;margin-left: -20rpx;bottom: 16rpx;display: none;}
  271. }
  272. }
  273. }
  274. </style>