江西小程序管理端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

463 lines
11 KiB

1 year ago
  1. <template>
  2. <view class="step1">
  3. <view class="card">
  4. <view class="dateBox">
  5. <view class="month-row">
  6. <view class="month" @click="show=true">{{ currentMonth }}</view>
  7. <view class="arrow">
  8. <u-icon name="arrow-down" :size="12" :color="'#1989FA'"></u-icon>
  9. </view>
  10. </view>
  11. <view class="date_row">
  12. <view class="icon left" @click="changeDateIndex(-1)">
  13. <u-icon name="arrow-left" :size="12" :color="'#fff'"></u-icon>
  14. </view>
  15. <view class="dateArr" >
  16. <view class="dateWidth" v-for="(item,index) in dateArr[currentDay]" :key="index" @click="chooseDate(item)" >
  17. <view class="date" :class="{active: chooseDay==item.date}">
  18. <!-- <view class="dian"></view> -->
  19. <view class="week">{{ item.week }}</view>
  20. <view class="num">{{ item.num }}</view>
  21. </view>
  22. </view>
  23. </view>
  24. <view class="icon right" @click="changeDateIndex(1)">
  25. <u-icon name="arrow-right" :size="12" :color="'#fff'"></u-icon>
  26. </view>
  27. </view>
  28. </view>
  29. </view>
  30. <view class="card">
  31. <view class="timeCon">
  32. <view class="h2">上午</view>
  33. <view class="time_box">
  34. <view class="time_item" v-for="(item,index) in timerArr" :key="index" @click="chooseCourse(item)" :class="{active: courseIds.indexOf(item.classTime)!=-1, disable: item.status==2}" >
  35. <view class="flex" v-if="item.status==0">
  36. <view class="lab">{{ item.appointmentAlreadyCount ||0 }} <text>/</text> {{ item.appointmentSumCount}} </view>
  37. <view class="iconArrowBg" v-if="item.appointmentAlreadyCount">
  38. <u-icon name="arrow-right" :size="10" :color="'#fff'"></u-icon>
  39. </view>
  40. </view>
  41. <view class="lab" v-else>{{ statusTxt[item.status] }}</view>
  42. <view class="time">{{ item.classTime }}</view>
  43. </view>
  44. </view>
  45. <view class="h2">下午</view>
  46. <view class="time_box">
  47. <view class="time_item" v-for="(item,index) in timerArr2" :key="index" @click="chooseCourse(item)" :class="{active: courseIds.indexOf(item.classTime)!=-1, disable: item.status==2}">
  48. <view class="flex" v-if="item.status==0">
  49. <view class="lab">{{ item.appointmentAlreadyCount ||0 }} <text>/</text> {{ item.appointmentSumCount}} </view>
  50. <view class="iconArrowBg" v-if="item.appointmentAlreadyCount">
  51. <u-icon name="arrow-right" :size="10" :color="'#fff'"></u-icon>
  52. </view>
  53. </view>
  54. <view class="lab" v-else>{{ statusTxt[item.status] }}</view>
  55. <view class="time">{{ item.classTime }}</view>
  56. </view>
  57. </view>
  58. </view>
  59. </view>
  60. <view class="card">
  61. <view class="noDate">
  62. <image src="http://192.168.1.20:81/zhili/image/20230927/ad178ebdf5394518b27b020c03ee48ab.png" mode=""></image>
  63. </view>
  64. </view>
  65. <view class="step2" v-if="step==2">
  66. <view class="">
  67. <u-radio-group
  68. v-model="radioVal"
  69. placement="row"
  70. size="14"
  71. >
  72. <u-radio
  73. :customStyle="{marginLeft: '8px'}"
  74. v-for="(item, index) in radioData"
  75. :key="index"
  76. :label="item.name"
  77. :name="item.id"
  78. labelSize="14"
  79. @change="changeRadio"
  80. >
  81. </u-radio>
  82. </u-radio-group>
  83. </view>
  84. <view class="btnBg" @click="confirmPopup">确认发布</view>
  85. </view>
  86. <u-datetime-picker
  87. :show="show"
  88. v-model="chooseMonth"
  89. :minDate="minDate"
  90. :maxDate="maxDate"
  91. mode="year-month"
  92. @confirm="changeMonth"
  93. ></u-datetime-picker>
  94. </view>
  95. </template>
  96. <script>
  97. import { getDates, getMonthsBetweenDates } from '@/config/utils.js'
  98. import { scheduleClassGetById, scheduleClassGet, getClassDateLimit } from '@/config/api.js'
  99. export default {
  100. props: ['step'],
  101. data() {
  102. return {
  103. maxDate: 0,
  104. minDate: 0,
  105. monthArr: [],
  106. show: false,
  107. dateArr: [],
  108. currentDay: 0,//当前显示的日期组索引
  109. chooseDay: '',
  110. chooseMonth: '',
  111. timerArr: [],
  112. statusTxt: ['未过期', '未排课', '已过期', '已约满'], //状态0、未过期 1、无排课,2、已过期,3已约满
  113. timerArr2: [],
  114. chooseTimerId: '',
  115. endDate: null,
  116. startDate: null,
  117. radioData: [
  118. {name: '全选', id: 0},
  119. {name: '取消选择', id: 1},
  120. ],
  121. courseIds: [],
  122. radioVal: '',
  123. }
  124. },
  125. mounted() {
  126. this.initDate()
  127. // uni.$on('refreshMySchedule',()=>{
  128. // console.log('没监听到?')
  129. // this.scheduleClassGetFn()
  130. // })
  131. },
  132. computed: {
  133. currentMonth() {
  134. let tiemr = new Date(this.chooseDay) * 1
  135. return this.$u.date(tiemr, 'yyyy.mm')
  136. }
  137. },
  138. watch: {
  139. courseIds: {
  140. handler(val) {
  141. let allTimer = [...this.timerArr,...this.timerArr2]
  142. let total = allTimer.reduce((pre, item)=>{
  143. if(item.status==1) {
  144. pre.push(item.classTime)
  145. }
  146. return pre
  147. },[])
  148. if(total.length==this.courseIds.length) {
  149. this.radioVal = 0
  150. }
  151. }
  152. }
  153. },
  154. methods: {
  155. // 获取排课日期范围
  156. async getClassDateLimitFn() {
  157. let obj = {
  158. coachId: this.vuex_coachId
  159. }
  160. const {data: res} = await getClassDateLimit(obj)
  161. this.startDate = new Date(res.beginDateLimit)
  162. this.endDate = new Date(res.endDateLimit)
  163. this.minDate = new Date(res.beginDateLimit)*1 + 86400000
  164. this.maxDate = new Date(res.endDateLimit)*1
  165. },
  166. // 获得排课
  167. async scheduleClassGetFn() {
  168. let id = this.vuex_userInfo.user.id
  169. let coachId = this.vuex_userInfo.user.coachId
  170. let deptId = this.vuex_deptId
  171. const {data: res} = await scheduleClassGet({id, coachId, classDate: this.chooseDay, deptId})
  172. this.timerArr = res.morningScheduleClass
  173. this.timerArr2 = res.afternoonScheduleClass
  174. if(this.chooseDay==this.dateArr[0][0].date) {
  175. let arr = [...this.timerArr,...this.timerArr2]
  176. arr.forEach(item=>{
  177. let timer = new Date() * 1
  178. let date = this.chooseDay+' '+(item.classTime.split('-')[0])
  179. date = date.replace(/-/g,'/');
  180. let timer2 = new Date(date).getTime();
  181. // console.log(timer)
  182. // console.log(timer2)
  183. // console.log(date)
  184. if(timer>timer2) {
  185. item.status = 2
  186. }
  187. })
  188. }
  189. },
  190. // 初始化日期
  191. async initDate() {
  192. await this.getClassDateLimitFn()
  193. this.dateArr = getDates(this.startDate, this.endDate);
  194. this.chooseDay = this.dateArr[0][0].date
  195. this.scheduleClassGetFn()
  196. },
  197. // 点击月份
  198. changeMonth(val) {
  199. let startDate = this.$u.date(val.value, 'yyyy-mm-dd')
  200. for(let i=0; i<this.dateArr.length; i++) {
  201. for(let j=0; j<this.dateArr[i].length; j++) {
  202. let date = this.dateArr[i][j].date
  203. if(startDate==date) {
  204. this.currentDay = i
  205. this.chooseDay = date
  206. }
  207. }
  208. }
  209. this.show = false
  210. },
  211. // 选择日期
  212. chooseDate(item) {
  213. this.chooseDay = item.date
  214. this.scheduleClassGetFn()
  215. console.log('*****')
  216. console.log(this.chooseDay)
  217. },
  218. changeDateIndex(num) {
  219. if(this.currentDay==0&&num==-1) return this.$u.toast('已是可选最小日期')
  220. if(this.currentDay==this.dateArr.length-1&&num==1) return this.$u.toast('已是可选最大日期')
  221. this.currentDay = this.currentDay + num
  222. this.chooseDay = this.dateArr[this.currentDay][0].date
  223. },
  224. chooseCourse(item) {
  225. if(this.step!=2) {
  226. // 如果有预约
  227. console.log(item)
  228. if(item.appointmentAlreadyCount&&item.status==0) {
  229. this.$goPage('/pages/recordEntry/operate/mySchedule/detail/detail?id='+ item.id)
  230. }
  231. }else {
  232. this.radioVal = -1
  233. if(item.status!=1) return this.$u.toast('请选择未排课选项')
  234. let index = this.courseIds.indexOf(item.classTime)
  235. if(index!==-1) {
  236. this.courseIds.splice(index, 1)
  237. }else {
  238. this.courseIds.push(item.classTime)
  239. }
  240. }
  241. },
  242. // 全选
  243. changeRadio(val) {
  244. if(val==1) {
  245. this.courseIds = []
  246. this.$emit('cancelChoose')
  247. // this.step = 1
  248. }else {
  249. let allTimer = [...this.timerArr,...this.timerArr2]
  250. let total = allTimer.reduce((pre, item)=>{
  251. if(item.status==1) {
  252. pre.push(item.classTime)
  253. }
  254. return pre
  255. },[])
  256. // console.log(total.length)
  257. // console.log(this.courseIds.length)
  258. if(total.length==this.courseIds.length) {
  259. this.courseIds = []
  260. // this.$emit('upDateCheck', [])
  261. }else {
  262. this.courseIds = total
  263. }
  264. }
  265. },
  266. // 确认发布
  267. confirmPopup() {
  268. let pickDate = {
  269. timeList: this.courseIds,
  270. classDate: this.chooseDay
  271. }
  272. this.$emit('confirmPopup', pickDate)
  273. }
  274. }
  275. }
  276. </script>
  277. <style lang="scss" scoped>
  278. .card {
  279. width: 100%;
  280. margin-bottom: 24rpx;
  281. overflow: hidden;
  282. .dateBox {
  283. padding: 36rpx 0 40rpx 0;
  284. .month-row {
  285. display: flex;
  286. justify-content: center;
  287. align-items: center;
  288. margin-bottom: 36rpx;
  289. .month {
  290. font-size: 32rpx;
  291. color: $themC;
  292. }
  293. .arrow {
  294. margin-left: 6rpx;
  295. }
  296. }
  297. .date_row {
  298. width: 100%;
  299. height: 100rpx;
  300. position: relative;
  301. .icon {
  302. width: 40rpx;
  303. height: 40rpx;
  304. background: rgba(51,51,51,0.18);
  305. backdrop-filter: blur(4rpx);
  306. position: absolute;
  307. top: 50%;
  308. transform: translateY(-50%);
  309. display: flex;
  310. align-items: center;
  311. justify-content: center;
  312. border-radius: 50%;
  313. &.left {
  314. left: 16rpx;
  315. }
  316. &.right {
  317. right: 16rpx;
  318. }
  319. }
  320. .dateArr {
  321. display: flex;
  322. padding: 0 70rpx;
  323. // justify-content: space-between;
  324. &.oneDate {
  325. justify-content: center;
  326. }
  327. .dateWidth {
  328. width: 20%;
  329. display: flex;
  330. justify-content: center;
  331. }
  332. .date {
  333. width: 74rpx;
  334. height: 100rpx;
  335. border-radius: 16rpx;
  336. display: flex;
  337. flex-direction: column;
  338. align-items: center;
  339. justify-content: center;
  340. font-size: 28rpx;
  341. color: #333;
  342. .dian {
  343. width: 12rpx;
  344. height: 12rpx;
  345. background: #D8D8D8;
  346. border-radius: 50%;
  347. &.active {
  348. background: #1989FA;
  349. }
  350. }
  351. &.active {
  352. background: rgba(25,137,250,0.1);
  353. border: 2rpx solid #1989FA;
  354. color: $themC;
  355. }
  356. .week {
  357. }
  358. .num {
  359. margin-top: 4rpx;
  360. }
  361. }
  362. }
  363. }
  364. }
  365. }
  366. .card {
  367. .timeCon {
  368. padding: 0 24rpx 40rpx 24rpx;
  369. }
  370. .h2 {
  371. line-height: 90rpx;
  372. font-weight: 500;
  373. color: #333;
  374. }
  375. .time_box {
  376. display: flex;
  377. flex-wrap: wrap;
  378. justify-content: space-between;
  379. &::after{
  380. display:block;
  381. content:"";
  382. width: 32%;
  383. height:0px;
  384. }
  385. .time_item {
  386. width: 30%;
  387. height: 120rpx;
  388. background: #F8F8F8;
  389. border-radius: 12rpx;
  390. display: flex;
  391. flex-direction: column;
  392. justify-content: center;
  393. align-items: center;
  394. border-radius: 12rpx;
  395. margin-bottom: 20rpx;
  396. color: #333;
  397. &.active {
  398. background: rgba(25,137,250,0.1);
  399. border: 2rpx solid #1989FA;
  400. color: $themC;
  401. }
  402. &.disable {
  403. opacity: 0.4;
  404. }
  405. .lab {
  406. font-size: 28rpx;
  407. font-weight: 500;
  408. }
  409. .time {
  410. font-size: 24rpx;
  411. margin-top: 4rpx;
  412. }
  413. }
  414. }
  415. }
  416. .btn {
  417. width: 47%;
  418. height: 72rpx;
  419. background: #1989FA;
  420. border-radius: 8rpx;
  421. font-size: 28rpx;
  422. color: #fff;
  423. text-align: center;
  424. line-height: 72rpx;
  425. margin: 108rpx auto 50rpx auto;
  426. }
  427. .iconArrowBg {
  428. background: #D8D8D8;
  429. width: 26rpx;
  430. height: 26rpx;
  431. border-radius: 50%;
  432. display: flex;
  433. justify-content: center;
  434. align-items: center;
  435. margin-left: 4px;
  436. }
  437. .step2 {
  438. display: flex;
  439. justify-content: space-between;
  440. align-items: center;
  441. padding-bottom: 40px;
  442. .btnBg {
  443. width: 310rpx;
  444. }
  445. }
  446. </style>