callNames.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510
  1. <template>
  2. <view>
  3. <u-navbar title="点名签到">
  4. <view class="slot-wrap" @click="getToday()">
  5. 今天
  6. </view>
  7. </u-navbar>
  8. <!-- <view class="search">
  9. <u-search placeholder="搜索班级/一对一学员" action-text="查询"></u-search>
  10. </view> -->
  11. <view class="date-box">
  12. <view class="date-picker">
  13. <view class="check" @click="beforeWeek">
  14. <u-icon name="arrow-left" size="32"></u-icon>前一周
  15. </view>
  16. <view class="date" @click="show = true">
  17. {{date}}
  18. </view>
  19. <view class="check" @click="afterWeek">
  20. 后一周<u-icon name="arrow-right" size="32"></u-icon>
  21. </view>
  22. </view>
  23. <u-picker mode="time" v-model="show" :params="params" :defaultTime="defaultTime" @confirm="confirm">
  24. </u-picker>
  25. <view class="date-item">
  26. <view class="item" v-for="(item,index) in weekDate" :key="index"
  27. :class="activeClass == index ? 'checked' : ''" @click="activeClassClick(item,index)">
  28. <view :class="item.isDotShow ? 'dot' : ''"
  29. :style="activeClass == index ? 'background-color: #fff;' : ''">
  30. </view>
  31. <view class="week ">
  32. {{item.week}}
  33. </view>
  34. <view class="day ">
  35. {{parseInt(item.day.slice(8))}}
  36. </view>
  37. </view>
  38. </view>
  39. </view>
  40. <view class="main">
  41. <!-- <view class="date">
  42. 2023-01-03 星期一
  43. </view> -->
  44. <view class="details-box" v-for="(item,index) in callList" :key="index">
  45. <view class="title-number">
  46. <view class="title">
  47. {{item.className}}
  48. </view>
  49. <view class="number">
  50. 学员数 <text>{{item.studentNum}}</text>
  51. </view>
  52. </view>
  53. <view class="location-time">
  54. <view class="location">
  55. {{item.classroomN}}
  56. </view>
  57. <view class="time">
  58. {{item.coursePeriods}}
  59. </view>
  60. </view>
  61. <view class="circumstance">
  62. <view class="date">
  63. {{item.courseDate}}
  64. </view>
  65. <view class="details">
  66. <view class="details-item">
  67. <text>到课</text>
  68. <text class="num-box">{{item.dkNum!=null?item.dkNum:'0'}}</text>
  69. </view>
  70. <!-- <view class="details-item">
  71. <text>缺课</text>
  72. <text class="num-box">{{item.qkNum!=null?item.qkNum:'0'}}</text>
  73. </view> -->
  74. <view class="details-item">
  75. <text>请假</text>
  76. <text class="num-box">{{item.qjNum!=null?item.qjNum:'0'}}</text>
  77. </view>
  78. <!-- <view class="details-item">
  79. <text>旷课</text>
  80. <text class="num-box">{{item.kkNum}}</text>
  81. </view> -->
  82. <view class="details-item">
  83. <text>停课</text>
  84. <text class="num-box">{{item.tkNum!=null?item.tkNum:'0'}}</text>
  85. </view>
  86. </view>
  87. </view>
  88. <view class="check-more">
  89. <!-- <view class="history" @click="gotoUrl('pages/teacher/callNames/callHistory')">
  90. 历史记录
  91. </view> -->
  92. <view class="call-name" @click="gotoUrl('pages/teacher/callNames/classCall?id=' + item.sheetId)"
  93. v-if="form.employeeRole == '4'">
  94. 点名签到
  95. </view>
  96. </view>
  97. </view>
  98. </view>
  99. <!-- <u-divider>没有更多数据了</u-divider> -->
  100. </view>
  101. </template>
  102. <script>
  103. import * as callNamesApi from '@/apis/teacher/callNames.js'
  104. import * as loginApi from '@/apis/login.js'
  105. export default {
  106. data() {
  107. return {
  108. date: '',
  109. weekDate: [],
  110. weekN: ["一", "二", "三", "四", "五", "六", "日"],
  111. activeClass: 0,
  112. weekDate1: '',
  113. callList: [],
  114. defaultTime: '',
  115. params: {
  116. year: true,
  117. month: true,
  118. day: true,
  119. hour: false,
  120. minute: false,
  121. second: false,
  122. timestamp: true
  123. },
  124. show: false,
  125. form: {}
  126. }
  127. },
  128. onReady() {
  129. this.getToday();
  130. this.getTeacherInfo();
  131. },
  132. methods: {
  133. getTeacherInfo() {
  134. uni.showLoading({
  135. title: "加载中",
  136. mask: true,
  137. })
  138. loginApi.findByOpenId({
  139. openId: this.carhelp.getOpenId()
  140. }).then((response) => {
  141. uni.hideLoading();
  142. if(response.data.employee != null) {
  143. this.form = response.data.employee;
  144. }
  145. }).catch(error => {
  146. uni.showToast({
  147. title: error,
  148. icon: "none"
  149. })
  150. })
  151. },
  152. confirm(params) {
  153. this.weekDate = [];
  154. let pickerDate = params.year + "-" + params.month + "-" + params.day;
  155. let year = params.year;
  156. let month = parseInt(params.month);
  157. let day = parseInt(params.day);
  158. let mydate = new Date(year, month - 1, day);
  159. let weekday = mydate.getDay();
  160. this.weekDate1 = new Date(year, month - 1, day + 1 - weekday);
  161. this.getWeekDate();
  162. for (var m = 0; m < this.weekDate.length; m++) {
  163. if (pickerDate == this.weekDate[m].day) {
  164. this.activeClass = m;
  165. this.date = this.weekDate[m].day;
  166. }
  167. }
  168. this.getCallList();
  169. },
  170. getCallList() {
  171. this.callList = [];
  172. uni.showLoading({
  173. title: "加载中",
  174. mask: true,
  175. })
  176. callNamesApi.rollCallList({
  177. queryDateStart: this.weekDate[0].day,
  178. queryDateEnd: this.weekDate[6].day
  179. }).then((response) => {
  180. uni.hideLoading();
  181. var list = response.data.dataList;
  182. for (var i = 0; i < list.length; i++) {
  183. if (this.date == list[i].courseDate) {
  184. this.callList.push(list[i]);
  185. }
  186. for (var j = 0; j < this.weekDate.length; j++) {
  187. if (this.weekDate[j].day == list[i].courseDate) {
  188. this.weekDate[j].isDotShow = true;
  189. }
  190. }
  191. }
  192. }).catch(error => {
  193. uni.showToast({
  194. title: error,
  195. icon: "none"
  196. })
  197. })
  198. },
  199. getToday() {
  200. this.weekDate = [];
  201. let date = new Date(); //当前日期
  202. let year = date.getFullYear(); //当前年
  203. let month = date.getMonth() + 1; //当前月
  204. let day = date.getDate(); //当天
  205. let mydate = new Date(year, month - 1, day);
  206. let weekday = mydate.getDay();
  207. this.weekDate1 = new Date(year, month - 1, day + 1 - weekday);
  208. this.defaultTime = this.getFormatDate(date, true);
  209. this.getWeekDate(true);
  210. },
  211. getWeekDate(bl) {
  212. let weekDate2 = new Date(this.weekDate1.getTime());
  213. for (var i = 0; i < 7; i++) {
  214. for (var j = 0; j < this.weekN.length; j++) {
  215. if (i == j) {
  216. var weekDate3=new Date(weekDate2.getTime()+i*24*60*60*1000);
  217. this.weekDate.push({
  218. week: this.weekN[j],
  219. day: this.getFormatDate(weekDate3),
  220. isDotShow: false
  221. })
  222. }
  223. }
  224. }
  225. if (bl) {
  226. let date = new Date(); //当前日期
  227. date = this.getFormatDate(date);
  228. for (var m = 0; m < this.weekDate.length; m++) {
  229. if (date == this.weekDate[m].day) {
  230. this.activeClass = m;
  231. this.date = this.weekDate[m].day;
  232. }
  233. }
  234. this.getCallList();
  235. }
  236. },
  237. getFormatDate(date) {
  238. let myyear = date.getFullYear();
  239. let mymonth = date.getMonth() + 1;
  240. let myweekday = date.getDate();
  241. if (mymonth < 10) {
  242. mymonth = "0" + mymonth;
  243. }
  244. if (myweekday < 10) {
  245. myweekday = "0" + myweekday;
  246. }
  247. return (myyear + "-" + mymonth + "-" + myweekday);
  248. },
  249. beforeWeek() {
  250. this.weekDate = [];
  251. this.weekDate1 = new Date(this.weekDate1.setDate(this.weekDate1.getDate() - 7));
  252. this.getWeekDate();
  253. for (var m = 0; m < this.weekDate.length; m++) {
  254. if (this.activeClass == m) {
  255. this.date = this.weekDate[m].day;
  256. }
  257. }
  258. this.getCallList();
  259. },
  260. afterWeek() {
  261. this.weekDate = [];
  262. this.weekDate1 = new Date(this.weekDate1.setDate(this.weekDate1.getDate() + 7));
  263. this.getWeekDate();
  264. for (var m = 0; m < this.weekDate.length; m++) {
  265. if (this.activeClass == m) {
  266. this.date = this.weekDate[m].day;
  267. }
  268. }
  269. this.getCallList();
  270. },
  271. activeClassClick(item, index) {
  272. this.activeClass = index;
  273. for (var m = 0; m < this.weekDate.length; m++) {
  274. if (index == m) {
  275. this.date = this.weekDate[m].day;
  276. }
  277. }
  278. this.getCallList();
  279. },
  280. }
  281. }
  282. </script>
  283. <style lang="scss" scoped>
  284. page{
  285. padding-bottom: 200rpx;
  286. }
  287. ::v-deep.u-slot-content {
  288. display: block;
  289. text-align: right !important;
  290. margin-right: 16px;
  291. color: #333333;
  292. }
  293. .date-box{
  294. position: fixed;
  295. top: 88rpx;
  296. left: 0;
  297. right: 0;
  298. }
  299. .date-picker {
  300. background-color: #fff;
  301. display: flex;
  302. justify-content: space-between;
  303. padding: 10px 12px 17px 12px;
  304. color: rgba(13, 186, 199, 1);
  305. .date {
  306. font-size: 16px
  307. }
  308. }
  309. .date-item {
  310. background-color: #fff;
  311. display: flex;
  312. justify-content: space-around;
  313. padding: 0 12px 16px 12px;
  314. border-radius: 0px 0px 9px 9px;
  315. box-shadow: 0px 4px 4px 0px #CFD2D5;
  316. .item {
  317. line-height: 20px;
  318. border-radius: 8px;
  319. background-color: rgba(238, 238, 238, 1);
  320. color: #1C222A;
  321. text-align: center;
  322. width: 12%;
  323. padding: 12rpx 0;
  324. position: relative;
  325. .week {
  326. font-size: 12px;
  327. }
  328. .day {
  329. font-size: 16px;
  330. font-weight: bold;
  331. }
  332. }
  333. .checked {
  334. background-color: rgba(13, 186, 199, 1);
  335. color: #fff;
  336. }
  337. .dot {
  338. width: 6px;
  339. height: 6px;
  340. background-color: rgba(13, 186, 199, 1);
  341. border-radius: 999px;
  342. position: absolute;
  343. top: 8rpx;
  344. right: 8rpx;
  345. }
  346. .dot-checked {
  347. background-color: #fff;
  348. }
  349. }
  350. .search {
  351. background-color: #fff;
  352. padding: 8px 12px;
  353. }
  354. ::v-deep.u-action {
  355. width: 17.1%;
  356. text-align: center;
  357. line-height: 28px;
  358. border-radius: 50px;
  359. background-color: rgba(13, 186, 199, 1);
  360. color: rgba(255, 255, 255, 1);
  361. }
  362. ::v-deep.u-content {
  363. background-color: #F0F4FA !important;
  364. }
  365. ::v-deep.u-input {
  366. background-color: #F0F4FA !important;
  367. }
  368. .main {
  369. margin-top:224rpx;
  370. padding: 24rpx 32rpx;
  371. text-align: center;
  372. .details-box {
  373. margin-top: 12px;
  374. background-color: #fff;
  375. padding: 12px 12px 0;
  376. border-radius: 12px;
  377. .title-number {
  378. display: flex;
  379. justify-content: space-between;
  380. align-items: center;
  381. .title {
  382. color: rgba(51, 51, 51, 1);
  383. font-size: 18px;
  384. font-weight: bold;
  385. }
  386. .number {
  387. color: rgba(119, 119, 119, 1);
  388. font-size: 16px;
  389. text {
  390. display: inline-block;
  391. text-align: center;
  392. width: 20px;
  393. line-height: 20px;
  394. border-radius: 4px;
  395. background-color: rgba(13, 186, 199, 1);
  396. color: rgba(255, 255, 255, 1);
  397. font-size: 14px;
  398. margin-left: 4px;
  399. }
  400. }
  401. }
  402. .location-time {
  403. display: flex;
  404. margin-top: 8px;
  405. .location,
  406. .time {
  407. line-height: 20px;
  408. border-radius: 4px;
  409. background-color: rgba(241, 243, 244, 1);
  410. color: rgba(136, 133, 133, 1);
  411. padding: 0px 8px;
  412. margin-right: 8px;
  413. }
  414. }
  415. }
  416. .circumstance {
  417. display: flex;
  418. margin-top: 8px;
  419. .date {
  420. color: rgba(51, 51, 51, 1);
  421. margin-right: 18px;
  422. }
  423. .details {
  424. display: flex;
  425. flex: 1;
  426. // justify-content: space-between;
  427. justify-content: space-evenly;
  428. .details-item {
  429. display: flex;
  430. align-items: center;
  431. .num-box {
  432. display: inline-block;
  433. width: 16px;
  434. height: 16px;
  435. line-height: 16px;
  436. border-radius: 4px;
  437. background-color: rgba(153, 153, 153, 1);
  438. color: rgba(255, 255, 255, 1);
  439. font-size: 12px;
  440. margin-left: 4px;
  441. }
  442. }
  443. }
  444. }
  445. .check-more {
  446. display: flex;
  447. text-align: center;
  448. font-size: 16px;
  449. margin-top: 17px;
  450. border-top: 1px solid rgba(229, 231, 234, 1);
  451. line-height: 38px;
  452. .history {
  453. flex: 1;
  454. color: rgba(119, 119, 119, 1);
  455. border-right: 1px solid rgba(229, 231, 234, 1);
  456. }
  457. .call-name {
  458. flex: 1;
  459. color: rgba(13, 186, 199, 1);
  460. }
  461. }
  462. }
  463. </style>