index.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531
  1. <template>
  2. <view>
  3. <view class="work" :style="{height: `${windowHeight}px`}">
  4. <uni-nav-bar title="课表" :background-color="backgroundColor" :border="navborder" :leftWidth="leftwith+'rpx'" statusBar='true' fixed="true" >
  5. <block slot="left">
  6. <view class="work_top" @click="getApply" v-if="checkPermi(['course:change:add'])">
  7. <image :src="wtopimg"></image>
  8. <view>申请调课</view>
  9. </view>
  10. </block>
  11. </uni-nav-bar>
  12. <!-- 主体 -->
  13. <block v-if="dataflag">
  14. <view class="flex0 w_top" >
  15. <view class="tab">
  16. <view class="tabl">
  17. <view class="tit" :class="tabidx==idx?'act':''" @click="getTab(idx)" v-for="(ite,idx) in tablist" :key="idx">
  18. <view class="f15 tits" >{{ite.className}}</view>
  19. <image :src="tapline" class="line"></image>
  20. </view>
  21. </view>
  22. <view class="curbox" @click="getCourFn" v-if="checkPermi(['course:table:add','course:time:add'])">
  23. <image :src="curimg"></image>
  24. <view class="f12 co16">课程管理</view>
  25. </view>
  26. </view>
  27. <view class="box flexc">
  28. <block v-for="(ite,idx) in titlist" :key="idx">
  29. <!-- v-if="checkPermi([ite.limt])" -->
  30. <view class="tit flex1 pr" :class="titidx==idx?'act':''" @click="getTit(idx)" >
  31. <view class="f15" >{{ite.tit}}</view>
  32. <view class="cirt" v-if="ite.val==1"></view>
  33. </view>
  34. </block>
  35. </view>
  36. </view>
  37. <view class="flex1 workbox">
  38. <!-- &&checkPermi(['course:table:list']) -->
  39. <view v-if="titidx==0">
  40. <time-table :timetables="timetables" :roles="roles" :timelist='timelist' @getChose="getChose"></time-table>
  41. </view>
  42. <view v-if="titidx==1" class="workboxr">
  43. <scroll-view scroll-y class="scroll-view" upper-threshold="40" lower-threshold="40" @scrolltolower="bot_btn">
  44. <view style="padding: 30rpx 36rpx;">
  45. <sh-list :datalist='tklist' :wtdt="wtdt" zhtype="5" :week="week"></sh-list>
  46. </view>
  47. </scroll-view>
  48. </view>
  49. </view>
  50. </block>
  51. <!-- 暂无信息 -->
  52. <block v-else><no-data ></no-data></block>
  53. <!-- 日历 -->
  54. <uni-calendar :startDate="startDate" ref="calendar" :tit="tit" :weekdata="weekdata" :insert="false" @confirm="confirm" />
  55. <pop-up :type='type' :formdata="formdata" @getClose="getClose" @getConfirm="getConfirm"></pop-up>
  56. </view>
  57. <footers v-if="isfootflag" :footlist="footlist" :footerindex="footerindex" :color_checked="color_checked" :color_nochecked="color_nochecked" :isHomeIndex="true"></footers>
  58. </view>
  59. </template>
  60. <script>
  61. import popUp from "@/components/popup/popup.vue"
  62. import noData from "@/components/nodata/nodata.vue"
  63. import tabList from "@/components/toptab/tab.vue"
  64. import shList from "@/components/shlist/list.vue"
  65. import timeTable from "@/components/timetable/timetable.vue"
  66. import footers from '@/components/footer/footer.vue'
  67. import {getCourselistFn,getTimelistFn,getChangetklistFn,getChangeAddFn} from "@/api/work/index.js"
  68. import {getDeptList,getselfList} from "@/api/mine/mine.js"
  69. import {getDictionaryFn} from '@/api/mine/register.js'
  70. import {getInfo } from '@/api/login'
  71. import { checkPermi, checkRole } from "@/utils/permission"; // 权限判断函数
  72. export default {
  73. components:{tabList,shList,timeTable,noData,popUp,footers},
  74. data(){
  75. return{
  76. footlist:[
  77. {module:'home',title:'首页',icon_checked:require('@/static/images/tabbar/home_.png'),icon_nochecked:require('@/static/images/tabbar/home.png'),},
  78. {module:'work',title:'课表',icon_checked:require('@/static/images/tabbar/work_.png'),icon_nochecked:require('@/static/images/tabbar/work.png'),limit:'course:table:list'},
  79. {module:'trends',title:'动态',icon_checked:require('@/static/images/tabbar/trends_.png'),icon_nochecked:require('@/static/images/tabbar/trends.png'),limit:'xiaoYuan:notice:list'},
  80. {module:'mine',title:'我的',icon_checked:require('@/static/images/tabbar/mine_.png'),icon_nochecked:require('@/static/images/tabbar/mine.png')},
  81. ],
  82. footerindex:'work',
  83. isfootflag:true,
  84. color_checked :'161616',
  85. color_nochecked :'666666',
  86. windowHeight: 0,
  87. wtopimg:require("@/static/images/wtop.png"),
  88. tapline:require("@/static/images/hline.png"),
  89. curimg:require("@/static/images/wcurimg.png"),
  90. backgroundColor:'#ffffff',
  91. navborder:false,
  92. leftwith:'200',
  93. tabidx:0,
  94. titidx:0,
  95. list:[],
  96. tablist:[],
  97. // limt:'course:table:list'
  98. titlist:[{tit:'课程表',val:0,},{tit:'调课通知',val:1,limt:''}],
  99. timetables: [],
  100. timelist:[],//时间
  101. classId:'',
  102. schoolId:'',
  103. teacherClass:[],
  104. dataflag:true,
  105. roles:'',
  106. tklist:[],
  107. pageSize: 10,
  108. pageNum: 1,
  109. reachflag:true,
  110. wtdt:'',
  111. week:[],
  112. weekdata:'',//选择的星期
  113. type:0,
  114. tiaotype:1,
  115. tit:'调课日期',
  116. startDate:'',
  117. formdata:{
  118. "subjectClassId": "",
  119. "subjectClass": "",
  120. "subject": "",
  121. "isNum":"",
  122. "subjectTime":"",
  123. "subjectWeek":"",
  124. "beSubject": "",
  125. "beIsNum": "",
  126. "beSubjectTime":"",
  127. "week": "",
  128. "content":''
  129. }
  130. }
  131. },
  132. onShow:function(){
  133. return
  134. // 判断角色是否一样
  135. var choseroles=this.$store.state.user.choseroles;
  136. this.tiaotype=1;
  137. if(this.roles&&choseroles&&this.roles!=choseroles){
  138. this.getClassFn()
  139. }else{
  140. var newArr=this.$store.state.user.refreshflag
  141. if(newArr&&newArr.length){
  142. if(newArr[1]){
  143. this.getClassFn()
  144. newArr[1]=false
  145. this.$store.dispatch('checkRefresh', newArr).then(() => {
  146. }).catch(() => {
  147. })
  148. }
  149. }
  150. }
  151. },
  152. onUnload(){
  153. uni.$off('refreshdatalis')
  154. },
  155. onPullDownRefresh:function(){
  156. this.reachflag=true;
  157. this.pageNum=1;
  158. this.list=[];
  159. if(this.titidx==1){
  160. this.getDataFn();
  161. this.init();
  162. }else{
  163. this.getClassFn();
  164. }
  165. setTimeout(function () {
  166. uni.stopPullDownRefresh();
  167. }, 1000);
  168. },
  169. onLoad: function() {
  170. this.getClassFn();
  171. this.init();
  172. this.startDate = this.getNowFormatDate();
  173. // uni.$emit('refreshdatalistzd','ldps');
  174. uni.$on('refreshdatalis',(e) => {
  175. this.reachflag=true;
  176. this.pageNum=1;
  177. this.list=[];
  178. this.getClassFn();
  179. // if(e&&e=='ldps'){
  180. // }else{
  181. // this.getCommonCensus();
  182. // }
  183. })
  184. },
  185. methods:{
  186. checkPermi, checkRole,
  187. getClose(){
  188. this.type=0;
  189. this.tiaotype=1;
  190. var newobj={
  191. subjectClassId:this.formdata.subjectClassId,
  192. subjectClass:this.formdata.subjectClass,
  193. }
  194. this.formdata=JSON.parse(JSON.stringify(newobj))
  195. },
  196. bot_btn() {
  197. if (this.reachflag&&this.titidx==1) {
  198. this.pageNum++
  199. this.getDataFn()
  200. }
  201. },
  202. getNowFormatDate(){
  203. let date = new Date();
  204. let y = date.getFullYear();
  205. let m = date.getMonth() + 1;
  206. m = m < 10 ? "0" + m : m;
  207. let d = date.getDate();
  208. d = d < 10 ? "0" + d : d;
  209. const timeday = y + "-" + m + "-" + d;
  210. this.year=y;
  211. this.month=m;
  212. return timeday;
  213. },
  214. getTfn(e){
  215. this.tiaotype=e
  216. },
  217. getConfirm(e){
  218. var that=this;
  219. var params=JSON.parse(JSON.stringify(this.formdata))
  220. params.content=e;
  221. getChangeAddFn(params).then(res=>{
  222. if(res.code==200){
  223. that.$toast("新增成功");
  224. that.type=0;
  225. that.tiaotype=1;
  226. var newobj={
  227. subjectClassId:that.formdata.subjectClassId,
  228. subjectClass:that.formdata.subjectClass,
  229. }
  230. that.formdata=JSON.parse(JSON.stringify(newobj))
  231. setTimeout(function(){
  232. that.reachflag=true;
  233. that.pageNum=1;
  234. that.list=[];
  235. that.getClassFn();
  236. },1500)
  237. }else{
  238. that.$toast(res.msg)
  239. }
  240. })
  241. },
  242. getApply(){
  243. this.tiaotype=1;
  244. this.$toast('请在课表中选择调课科目')
  245. // this.$refs.calendar.open()
  246. // this.$tab.navigateTo('/work/pages/examine/applyclass')
  247. },
  248. confirm(e){
  249. var fulldate=e.fulldate;
  250. if(this.tiaotype==1){
  251. this.formdata.subjectTime=fulldate;
  252. this.$toast('请选择被调课日期')
  253. this.tiaotype=2;
  254. }else{
  255. // 二次确认弹窗
  256. this.formdata.beSubjectTime=fulldate;
  257. this.type=7
  258. }
  259. },
  260. getChose(data){
  261. // 选择的课表
  262. if(this.tiaotype==1){
  263. this.tit='调课日期';
  264. var newdata=JSON.parse(JSON.stringify(data))
  265. this.formdata.subject=newdata.subject;
  266. this.formdata.isNum=newdata.isNum;
  267. this.formdata.subjectWeek=newdata.subjectWeek;
  268. }else{
  269. this.tit='被调课日期';
  270. var newdata=JSON.parse(JSON.stringify(data))
  271. this.formdata.beSubject=newdata.subject;
  272. this.formdata.beIsNum=newdata.isNum;
  273. this.formdata.week=newdata.subjectWeek;
  274. }
  275. this.weekdata=data.subjectWeek
  276. this.$refs.calendar.open()
  277. },
  278. getCourFn(){
  279. this.$tab.navigateTo('/work/pages/examine/course')
  280. },
  281. init(){
  282. // 星期
  283. getDictionaryFn('sys_week').then(res=>{
  284. if(res.code==200){
  285. this.week = res.data.map(v => {
  286. return {
  287. dictLabel: v.dictLabel,
  288. dictValue: v.dictValue
  289. }
  290. })
  291. }
  292. })
  293. },
  294. getTab(idx){
  295. this.tabidx=idx;
  296. this.classId=this.tablist[idx].classId;
  297. this.schoolId=this.tablist[idx].schoolId;
  298. this.formdata.subjectClassId=this.tablist[idx].classId;
  299. this.formdata.subjectClass=this.tablist[idx].className;
  300. // 获取课表
  301. this.getCourselistFn()
  302. },
  303. getTit(idx){
  304. this.titidx=idx;
  305. if(idx==1){
  306. this.getDataFn()
  307. }else{
  308. this.getCourselistFn()
  309. }
  310. },
  311. getDataFn(){
  312. var params={
  313. pageSize:this.pageSize,
  314. pageNum: this.pageNum,
  315. isPass:2,
  316. }
  317. getChangetklistFn(params).then(res=>{
  318. if(res.code==200){
  319. if (res.rows.length < this.pageSize) {
  320. this.reachflag = false
  321. this.wtdt = '到底了~';
  322. } else {
  323. var num = parseInt(res.rows.length) + parseInt(this.pageSize) * parseInt(this.pageNum - 1)
  324. if (num < res.total) {
  325. this.reachflag = true
  326. this.wtdt = '上拉加载更多'
  327. } else {
  328. this.reachflag = false
  329. this.wtdt = '到底了~';
  330. }
  331. }
  332. if (this.pageNum == 1) {
  333. this.tklist = res.rows;
  334. } else {
  335. this.tklist = this.tklist.concat(res.rows)
  336. }
  337. }else{
  338. this.$toast(res.msg)
  339. }
  340. })
  341. },
  342. getCourselistFn(){
  343. var that=this;
  344. var params={
  345. classId:this.classId,
  346. schoolId:this.schoolId
  347. }
  348. params['params[role]']=this.$store.state.user.choseroles
  349. getCourselistFn(params).then(res=>{
  350. if(res.code==200){
  351. that.timetables=res.rows;
  352. }else{
  353. that.$toast(res.msg)
  354. }
  355. })
  356. var newObj={
  357. schoolId:this.schoolId
  358. }
  359. getTimelistFn(newObj).then(res=>{
  360. if(res.code==200){
  361. var newArr=[]
  362. if(res.rows.length>0){
  363. var data=res.rows[0];
  364. newArr=[
  365. {val:'1',time:(data.oneStartTime||'')+'-'+(data.oneEndTime||'')},
  366. {val:'2',time:(data.twoStartTime||'')+'-'+(data.twoEndTime||'')},
  367. {val:'3',time:(data.threeStartTime||'')+'-'+(data.threeEndTime||'')},
  368. {val:'4',time:(data.fourStartTime||'')+'-'+(data.fourEndTime||'')},
  369. {val:'5',time:(data.fiveStartTime||'')+'-'+(data.fiveEndTime||'')},
  370. {val:'6',time:(data.sixStartTime||'')+'-'+(data.sixEndTime||'')},
  371. {val:'7',time:(data.sevenStartTime||'')+'-'+(data.sevenEndTime||'')},
  372. {val:'8',time:(data.eightStartTime||'')+'-'+(data.eightEndTime||'')},
  373. ]
  374. }else{
  375. newArr=[{ val: '1'},{ val: '2'}, { val: '3'},{ val: '4'},{ val: '5'},{ val: '6'},{ val: '7'},{ val: '8'}]
  376. }
  377. that.timelist=JSON.parse(JSON.stringify(newArr));
  378. }else{
  379. that.$toast(res.msg)
  380. }
  381. })
  382. },
  383. getclassListFn(id){
  384. var that=this;
  385. getDeptList(id).then(res=>{
  386. if(res.code==200){
  387. if(res.data&&res.data.length){
  388. that.tablist = res.data.map(v => {
  389. return {
  390. className: v.deptName,
  391. classId: v.deptId,
  392. schoolId:v.parentId
  393. }
  394. })
  395. that.classId=res.data[0].deptId;
  396. that.formdata.subjectClassId=that.classId;
  397. that.formdata.subjectClass=res.data[0].deptName;
  398. that.schoolId=res.data[0].parentId;
  399. that.dataflag=true;
  400. that.getCourselistFn()
  401. }
  402. }else{
  403. that.$toast(res.msg)
  404. }
  405. })
  406. },
  407. getselfList(id){
  408. var that=this;
  409. var params={
  410. parentId:id,
  411. }
  412. params['params[role]']=this.$store.state.user.choseroles
  413. getselfList(params).then(res=>{
  414. if(res.code==200){
  415. var newArr=res.data;
  416. if(newArr&&newArr.length){
  417. this.tablist = newArr.map(v => {
  418. return {
  419. className: v.deptName,
  420. classId: v.deptId,
  421. schoolId:v.parentId
  422. }
  423. })
  424. that.classId=res.data[0].deptId;
  425. that.formdata.subjectClassId=that.classId;
  426. that.formdata.subjectClass=res.data[0].deptName;
  427. that.schoolId=res.data[0].parentId;
  428. that.dataflag=true;
  429. that.getCourselistFn()
  430. }
  431. }else{
  432. this.$toast(res.msg)
  433. }
  434. })
  435. },
  436. getClassFn(){
  437. var that=this;
  438. var roles=that.$store.state.user.choseroles;
  439. that.roles=roles;
  440. if(roles=='teacher'){
  441. var id=that.$store.state.user.schoolId;
  442. this.getselfList(id)
  443. }else if(roles=='parents'){
  444. this.$store.dispatch('GetInforoles').then(resd => {
  445. if(resd.code==200){
  446. var res=resd.data;
  447. if(res.user&&res.user.parentsStudent&&res.user.parentsStudent.length){
  448. var newArr = [];
  449. const map = new Map();
  450. newArr = res.user.parentsStudent.filter(v => !map.has(v.classId) && map.set(v.classId, 1));
  451. that.tablist = newArr.map(v => {
  452. return {
  453. className: v.className,
  454. classId: v.classId,
  455. schoolId:v.schoolId
  456. }
  457. })
  458. this.classId=newArr[0].classId;
  459. that.schoolId=newArr[0].schoolId;
  460. that.formdata.subjectClassId=that.classId;
  461. that.formdata.subjectClass=newArr[0].className;
  462. that.dataflag=true;
  463. that.getCourselistFn()
  464. }else{
  465. that.dataflag=false
  466. }
  467. }
  468. })
  469. }else{
  470. // 学校
  471. that.classId='';
  472. that.formdata.subjectClassId='';
  473. that.formdata.subjectClass='';
  474. var id=that.$store.state.user.deptId||'';
  475. that.schoolId=id;
  476. that.getselfList(0)
  477. }
  478. },
  479. },
  480. mounted() {
  481. var systemInfo=uni.getSystemInfoSync();
  482. this.windowHeight=Number(systemInfo.windowHeight);
  483. },
  484. }
  485. </script>
  486. <style lang="scss" scoped>
  487. .work_top{display: flex;align-items: center;font-size: 30rpx;font-weight: 500;color: #4775EA;padding: 0 10rpx;
  488. image{width: 30rpx;height: 30rpx;margin-right: 14rpx;flex: 0 0 auto;}
  489. }
  490. .work{display: flex;flex-direction: column;overflow: hidden;
  491. .w_top{background-color: #ffffff;
  492. .tab{
  493. border-bottom: 2rpx solid #E6E6E6;display: flex;overflow-x: auto;align-items: center;position: relative;
  494. .tabl{flex: 1;overflow: auto;display: flex;align-items: center;}
  495. .tit{position: relative;padding:32rpx 36rpx;color: #666666 ;flex: 0 0 auto;
  496. &.act{
  497. .tits{font-size: 32rpx;font-weight: bold;}
  498. .line{display: block;}
  499. }
  500. }
  501. .line{width: 40rpx;height: 12rpx;position: absolute;left: 50%;margin-left: -20rpx;bottom: 16rpx;display: none;}
  502. .curbox{min-width: 96rpx;height: 100rpx;background: #FFFFFF;box-shadow: -10rpx 0px 10rpx 0px rgba(196,191,191,0.22);flex: 0;flex: 0 0 auto;padding:0 8rpx;box-sizing: border-box;display: flex;align-items: center;justify-content: center;flex-wrap: wrap;flex-direction: column;
  503. image{width: 30rpx;height: 32rpx;}
  504. }
  505. }
  506. .box{
  507. .tit{text-align: center;line-height: 100rpx;color: #666666 ;display: flex;justify-content: center;align-items: center;
  508. .cirt{width: 12rpx;height: 12rpx;background: #EB5663;border-radius: 50%;margin: -24rpx 0 0 -6rpx;}
  509. &.act{font-weight: bold;color: #4775EA;}
  510. }
  511. }
  512. }
  513. .workbox{overflow: auto;
  514. .workboxr{height: 100%;display: flex;}
  515. .scroll-view{width: 100%;height: 100%;box-sizing: border-box;}
  516. }
  517. }
  518. </style>