index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437
  1. <template>
  2. <div class="abnormalCourse">
  3. <van-list
  4. v-model="loading"
  5. v-if="dataShow"
  6. :finished="finished"
  7. finished-text="- 没有更多了 -"
  8. :immediate-check="false"
  9. @load="getList"
  10. >
  11. <div class="cellList">
  12. <van-cell-group v-for="(item, index) in list" :key="index">
  13. <van-cell
  14. class="titleCell"
  15. title-style="display: flex;align-item: center"
  16. >
  17. <template slot="default">
  18. <div class="signImgBox">
  19. <img
  20. class="signImg"
  21. :src="getSignInIcon(item.isSignIn)"
  22. alt=""
  23. />
  24. </div>
  25. </template>
  26. <template slot="title">
  27. <div class="classTitleWrap" style="word-break: break-all">
  28. <span class="teachMode"
  29. >{{ item.teachMode == "ONLINE" ? "线上" : null
  30. }}{{ item.teachMode == "OFFLINE" ? "线下" : null }}</span
  31. >
  32. <span :class="['courseType', item.type]">{{
  33. item.type | coursesType
  34. }}</span>
  35. <span
  36. style="
  37. line-height: 1.2;
  38. vertical-align: bottom;
  39. max-width: 140px;
  40. overflow: hidden;
  41. text-overflow: ellipsis;
  42. "
  43. >{{ item.name }}</span
  44. >
  45. <!-- <img
  46. class="teacherModelImg"
  47. :src="getTeacherImg(item.teachMode)"
  48. alt=""
  49. />
  50. <span :class="['courseType', item.type]">{{
  51. item.type | coursesType
  52. }}</span>
  53. {{ item.name }} -->
  54. </div>
  55. </template>
  56. </van-cell>
  57. <van-cell>
  58. <template slot="title">
  59. <p
  60. class="studentTitle"
  61. style="word-break: break-all"
  62. v-if="item.schoolName"
  63. >
  64. 上课地点 : &nbsp;{{ item.schoolName }}
  65. </p>
  66. <p class="studentTitle" style="word-break: break-all">
  67. 上课学生 : &nbsp;{{ item.studentNames }}
  68. </p>
  69. <p
  70. class="studentTitle"
  71. style="
  72. word-break: break-all;
  73. display: flex;
  74. align-items: center;
  75. "
  76. >
  77. <img
  78. class="clockIcon"
  79. style="margin-right: 6px"
  80. :src="squrtList.squrt8"
  81. alt=""
  82. />{{
  83. item.startClassTime | formatDateExtend("YYYY-MM-DD HH:mm")
  84. }}-{{
  85. item.endClassTime | formatDateExtend("YYYY-MM-DD HH:mm")
  86. }}
  87. </p>
  88. </template>
  89. </van-cell>
  90. <van-cell
  91. style="padding: 0"
  92. title-class="title-content"
  93. value-class="value-content"
  94. :center="true"
  95. >
  96. <template slot="title">
  97. <van-button
  98. block
  99. style="border: 0"
  100. :disabled="
  101. item.type == 'VIP' || item.type == 'PRACTICE' ? false : true
  102. "
  103. @click="
  104. () => {
  105. selectDate = item;
  106. dataForm.status = true;
  107. }
  108. "
  109. >课时调整</van-button
  110. >
  111. <!-- <div class="chioseWrap"> -->
  112. <!-- <img class="clockIcon" :src="squrtList.squrt8" alt="" />
  113. <p class="timer">
  114. {{
  115. item.startClassTime | formatDateExtend("YYYY-MM-DD HH:mm")
  116. }}-{{
  117. item.endClassTime | formatDateExtend("YYYY-MM-DD HH:mm")
  118. }}
  119. </p> -->
  120. <!-- </div> -->
  121. </template>
  122. <!-- <template slot="default">
  123. <van-button type="info" round size="small">课时调整</van-button>
  124. </template> -->
  125. </van-cell>
  126. </van-cell-group>
  127. </div>
  128. </van-list>
  129. <m-empty v-else key="data" />
  130. <van-popup v-model="dataForm.status" position="bottom" round>
  131. <van-datetime-picker
  132. v-model="dataForm.currentDate"
  133. type="datetime"
  134. :min-date="dataForm.minDate"
  135. :max-date="dataForm.maxDate"
  136. :formatter="formatter"
  137. @cancel="dataForm.status = false"
  138. @confirm="onCurrentConfirm"
  139. />
  140. </van-popup>
  141. </div>
  142. </template>
  143. <script>
  144. import { queryTeacherInfo } from "@/api/app";
  145. import { superFindCourseSchedules, classStartDateAdjust } from "./api";
  146. import dayjs from "dayjs";
  147. import MEmpty from "@/components/MEmpty";
  148. import { browser } from "@/common/common";
  149. export default {
  150. name: "abnormalCourse",
  151. components: { MEmpty },
  152. data() {
  153. return {
  154. dataForm: {
  155. // 时间下拉框
  156. status: false,
  157. minDate: new Date(),
  158. maxDate: new Date(2025, 10, 1),
  159. currentDate: new Date(),
  160. },
  161. selectDate: {},
  162. squrtList: {
  163. squrt2: require("@/assets/images/squrt2.png"),
  164. squrt3: require("@/assets/images/squrt3.png"),
  165. squrt4: require("@/assets/images/squrt4.png"),
  166. squrt5: require("@/assets/images/squrt5.png"),
  167. squrt6: require("@/assets/images/squrt6.png"),
  168. squrt7: require("@/assets/images/squrt7.png"),
  169. squrt8: require("@/assets/images/squrt8.png"),
  170. },
  171. list: [],
  172. loading: false,
  173. finished: false,
  174. params: {
  175. searchType: "COURSE_TIME_ERROR",
  176. teacherIdList: "",
  177. // startTime: "",
  178. // endTime: "",
  179. page: 1,
  180. rows: 20,
  181. },
  182. dataShow: true,
  183. };
  184. },
  185. async mounted() {
  186. document.title = "异常课程";
  187. await queryTeacherInfo().then((res) => {
  188. const result = res.data || null;
  189. this.params.teacherIdList = result.data.id || 0;
  190. });
  191. this.getList();
  192. },
  193. methods: {
  194. async getList() {
  195. try {
  196. let params = this.params;
  197. try {
  198. const res = await superFindCourseSchedules({
  199. ...params,
  200. });
  201. let result = res.data;
  202. this.loading = false;
  203. if (params.page > result.pageNo) {
  204. return;
  205. }
  206. params.page = result.pageNo;
  207. const rows = result.rows;
  208. this.list = this.list.concat(rows);
  209. if (params.page >= result.totalPage) {
  210. this.finished = true;
  211. }
  212. this.params.page++;
  213. // 判断是否有数据
  214. if (this.list.length <= 0) {
  215. this.dataShow = false;
  216. }
  217. } catch {
  218. this.finished = true;
  219. this.dataShow = false;
  220. }
  221. } catch {}
  222. //
  223. },
  224. async onCurrentConfirm(value) {
  225. // 课时调整
  226. try {
  227. let selectDate = this.selectDate;
  228. let startStr =
  229. "2019/12/18 " + this.getDateInfo(selectDate.startClassTime),
  230. endStr = "2019/12/18 " + this.getDateInfo(selectDate.endClassTime);
  231. let startDate = new Date(startStr),
  232. endDate = new Date(endStr);
  233. let m = parseInt(
  234. Math.abs(endDate.getTime() - startDate.getTime()) / 1000 / 60
  235. );
  236. let currentStartDate = new Date(value),
  237. currentEndDate = new Date(value);
  238. currentEndDate.setMinutes(currentStartDate.getMinutes() + m);
  239. if (currentStartDate.toDateString() !== currentEndDate.toDateString()) {
  240. this.$toast("课时调整不允许跨天调整");
  241. return;
  242. }
  243. await classStartDateAdjust({
  244. actualTeacherId: selectDate.actualTeacherId,
  245. id: selectDate.id,
  246. classDate: this.getFormartDate(currentStartDate),
  247. startClassTimeStr: this.getDateInfo(currentStartDate),
  248. endClassTimeStr: this.getDateInfo(currentEndDate),
  249. });
  250. this.$toast("调整成功");
  251. setTimeout(() => {
  252. this.list = [];
  253. this.params.page = 1;
  254. this.getList();
  255. this.dataForm.status = false;
  256. }, 1000);
  257. } catch {
  258. //
  259. }
  260. },
  261. getFormartDate(date) {
  262. let checkDate = new Date(date);
  263. let checkDay =
  264. checkDate.getFullYear() +
  265. "-" +
  266. (checkDate.getMonth() + 1) +
  267. "-" +
  268. checkDate.getDate();
  269. return checkDay;
  270. },
  271. getDateInfo(value) {
  272. let tempValue = value;
  273. if (typeof value !== "object") {
  274. tempValue = value.replace(/-/gi, "/");
  275. }
  276. let d = new Date(tempValue);
  277. let hour = d.getHours() >= 10 ? d.getHours() : "0" + d.getHours();
  278. let minute = d.getMinutes() >= 10 ? d.getMinutes() : "0" + d.getMinutes();
  279. return hour + ":" + minute + ":00";
  280. },
  281. formatter(type, value) {
  282. if (type === "year") {
  283. return `${value}年`;
  284. } else if (type === "month") {
  285. return `${value}月`;
  286. } else if (type === "day") {
  287. return `${value}日`;
  288. } else if (type === "hour") {
  289. return `${value}时`;
  290. } else if (type === "minute") {
  291. return `${value}分`;
  292. }
  293. return value;
  294. },
  295. getSignInIcon(status) {
  296. if (status == 1) {
  297. return this.squrtList.squrt3;
  298. } else if (status == 0) {
  299. return this.squrtList.squrt5;
  300. } else {
  301. return this.squrtList.squrt4;
  302. }
  303. },
  304. getTeacherImg(mode) {
  305. if (mode == "ONLINE") {
  306. return this.squrtList.squrt6;
  307. } else {
  308. return this.squrtList.squrt7;
  309. }
  310. },
  311. },
  312. };
  313. </script>
  314. <style lang="less">
  315. @import url("../../assets/commonLess/variable.less");
  316. .abnormalCourse {
  317. min-height: 100vh;
  318. position: relative;
  319. background-color: #f3f4f8;
  320. .van-cell__title {
  321. // width: 2.58rem;
  322. -webkit-box-flex: auto;
  323. -webkit-flex: auto;
  324. flex: auto;
  325. font-size: 0.18rem;
  326. color: #333;
  327. font-weight: 500;
  328. }
  329. .van-icon-underway-o {
  330. font-size: 0.18rem;
  331. }
  332. .van-cell {
  333. line-height: inherit;
  334. }
  335. .van-cell__title {
  336. font-size: 0.16rem;
  337. color: @mFontColor;
  338. }
  339. .van-cell-group {
  340. margin-top: 0.05rem;
  341. border-radius: 0.1rem;
  342. margin: 0.1rem 0.12rem 0;
  343. overflow: hidden;
  344. }
  345. .title-content {
  346. flex: 1 auto;
  347. font-weight: bold;
  348. .van-cell__label {
  349. font-weight: 400;
  350. margin-top: 0.06rem;
  351. display: flex;
  352. align-items: center;
  353. }
  354. .van-icon-location {
  355. margin-right: 0.05rem;
  356. }
  357. }
  358. .value-content {
  359. width: 50px;
  360. }
  361. .van-button__text {
  362. color: #01c1b5;
  363. }
  364. .input-cell {
  365. padding: 0.12rem 0.16rem 0.2rem;
  366. .van-radio {
  367. justify-content: flex-end;
  368. }
  369. }
  370. .signImgBox {
  371. .signImg {
  372. margin-top: 0.04rem;
  373. width: 0.48rem;
  374. height: 0.22rem;
  375. }
  376. }
  377. .teacherModelImg {
  378. width: 0.35rem;
  379. height: 0.2rem;
  380. margin-right: 0.05rem;
  381. position: absolute;
  382. left: 0;
  383. top: 0.04rem;
  384. }
  385. .courseImg {
  386. width: 0.42rem;
  387. height: 0.18rem;
  388. position: absolute;
  389. left: 0.4rem;
  390. top: 0.05rem;
  391. }
  392. .classTitleWrap {
  393. font-size: 0.16rem;
  394. line-height: 1.5;
  395. font-weight: 500;
  396. color: #333;
  397. display: flex;
  398. align-items: center;
  399. overflow: hidden;
  400. white-space: nowrap;
  401. text-overflow: ellipsis;
  402. }
  403. .titleCell {
  404. padding-bottom: 0 !important;
  405. &:after {
  406. border-bottom: none;
  407. }
  408. }
  409. .studentTitle {
  410. font-size: 0.13rem;
  411. color: #666;
  412. line-height: 0.19rem;
  413. margin-bottom: 5px;
  414. }
  415. .clockIcon {
  416. width: 0.16rem;
  417. height: 0.16rem;
  418. }
  419. .chioseWrap {
  420. display: flex;
  421. flex-direction: row;
  422. justify-content: flex-start;
  423. align-items: center;
  424. img {
  425. position: relative;
  426. top: -0.02rem;
  427. margin-right: 0.08rem;
  428. }
  429. }
  430. }
  431. </style>