江西小程序管理端
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.

472 lines
12 KiB

1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
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. // let obj = {
  195. // date: "2023-10-24",
  196. // num: "24",
  197. // week: "二"
  198. // }
  199. // this.dateArr[0][0] = obj
  200. this.chooseDay = this.dateArr[0][0].date
  201. console.log(this.dateArr)
  202. this.scheduleClassGetFn()
  203. },
  204. // 点击月份
  205. changeMonth(val) {
  206. let startDate = this.$u.date(val.value, 'yyyy-mm-dd')
  207. for(let i=0; i<this.dateArr.length; i++) {
  208. for(let j=0; j<this.dateArr[i].length; j++) {
  209. let date = this.dateArr[i][j].date
  210. if(startDate==date) {
  211. this.currentDay = i
  212. this.chooseDay = date
  213. }
  214. }
  215. }
  216. this.show = false
  217. },
  218. // 选择日期
  219. chooseDate(item) {
  220. this.chooseDay = item.date
  221. this.scheduleClassGetFn()
  222. // console.log('*****')
  223. // console.log(this.chooseDay)
  224. },
  225. changeDateIndex(num) {
  226. if(this.currentDay==0&&num==-1) return this.$u.toast('已是可选最小日期')
  227. if(this.currentDay==this.dateArr.length-1&&num==1) return this.$u.toast('已是可选最大日期')
  228. this.currentDay = this.currentDay + num
  229. this.chooseDay = this.dateArr[this.currentDay][0].date
  230. },
  231. chooseCourse(item) {
  232. // this.$goPage('/pages/recordEntry/operate/mySchedule/detail/detail?id='+ item.id)
  233. // return
  234. if(this.step!=2) {
  235. // 如果有预约
  236. console.log(item)
  237. if(item.appointmentAlreadyCount&&item.status==0) {
  238. this.$goPage('/pages/recordEntry/operate/mySchedule/detail/detail?id='+ item.id)
  239. }
  240. }else {
  241. this.radioVal = -1
  242. if(item.status!=1) return this.$u.toast('请选择未排课选项')
  243. let index = this.courseIds.indexOf(item.classTime)
  244. if(index!==-1) {
  245. this.courseIds.splice(index, 1)
  246. }else {
  247. this.courseIds.push(item.classTime)
  248. }
  249. }
  250. },
  251. // 全选
  252. changeRadio(val) {
  253. if(val==1) {
  254. this.courseIds = []
  255. this.$emit('cancelChoose')
  256. // this.step = 1
  257. }else {
  258. let allTimer = [...this.timerArr,...this.timerArr2]
  259. let total = allTimer.reduce((pre, item)=>{
  260. if(item.status==1) {
  261. pre.push(item.classTime)
  262. }
  263. return pre
  264. },[])
  265. // console.log(total.length)
  266. // console.log(this.courseIds.length)
  267. if(total.length==this.courseIds.length) {
  268. this.courseIds = []
  269. // this.$emit('upDateCheck', [])
  270. }else {
  271. this.courseIds = total
  272. }
  273. }
  274. },
  275. // 确认发布
  276. confirmPopup() {
  277. let pickDate = {
  278. timeList: this.courseIds,
  279. classDate: this.chooseDay
  280. }
  281. this.$emit('confirmPopup', pickDate)
  282. }
  283. }
  284. }
  285. </script>
  286. <style lang="scss" scoped>
  287. .card {
  288. width: 100%;
  289. margin-bottom: 24rpx;
  290. overflow: hidden;
  291. .dateBox {
  292. padding: 36rpx 0 40rpx 0;
  293. .month-row {
  294. display: flex;
  295. justify-content: center;
  296. align-items: center;
  297. margin-bottom: 36rpx;
  298. .month {
  299. font-size: 32rpx;
  300. color: $themC;
  301. }
  302. .arrow {
  303. margin-left: 6rpx;
  304. }
  305. }
  306. .date_row {
  307. width: 100%;
  308. height: 100rpx;
  309. position: relative;
  310. .icon {
  311. width: 40rpx;
  312. height: 40rpx;
  313. background: rgba(51,51,51,0.18);
  314. backdrop-filter: blur(4rpx);
  315. position: absolute;
  316. top: 50%;
  317. transform: translateY(-50%);
  318. display: flex;
  319. align-items: center;
  320. justify-content: center;
  321. border-radius: 50%;
  322. &.left {
  323. left: 16rpx;
  324. }
  325. &.right {
  326. right: 16rpx;
  327. }
  328. }
  329. .dateArr {
  330. display: flex;
  331. padding: 0 70rpx;
  332. // justify-content: space-between;
  333. &.oneDate {
  334. justify-content: center;
  335. }
  336. .dateWidth {
  337. width: 20%;
  338. display: flex;
  339. justify-content: center;
  340. }
  341. .date {
  342. width: 74rpx;
  343. height: 100rpx;
  344. border-radius: 16rpx;
  345. display: flex;
  346. flex-direction: column;
  347. align-items: center;
  348. justify-content: center;
  349. font-size: 28rpx;
  350. color: #333;
  351. .dian {
  352. width: 12rpx;
  353. height: 12rpx;
  354. background: #D8D8D8;
  355. border-radius: 50%;
  356. &.active {
  357. background: #1989FA;
  358. }
  359. }
  360. &.active {
  361. background: rgba(25,137,250,0.1);
  362. border: 2rpx solid #1989FA;
  363. color: $themC;
  364. }
  365. .week {
  366. }
  367. .num {
  368. margin-top: 4rpx;
  369. }
  370. }
  371. }
  372. }
  373. }
  374. }
  375. .card {
  376. .timeCon {
  377. padding: 0 24rpx 40rpx 24rpx;
  378. }
  379. .h2 {
  380. line-height: 90rpx;
  381. font-weight: 500;
  382. color: #333;
  383. }
  384. .time_box {
  385. display: flex;
  386. flex-wrap: wrap;
  387. justify-content: space-between;
  388. &::after{
  389. display:block;
  390. content:"";
  391. width: 32%;
  392. height:0px;
  393. }
  394. .time_item {
  395. width: 30%;
  396. height: 120rpx;
  397. background: #F8F8F8;
  398. border-radius: 12rpx;
  399. display: flex;
  400. flex-direction: column;
  401. justify-content: center;
  402. align-items: center;
  403. border-radius: 12rpx;
  404. margin-bottom: 20rpx;
  405. color: #333;
  406. &.active {
  407. background: rgba(25,137,250,0.1);
  408. border: 2rpx solid #1989FA;
  409. color: $themC;
  410. }
  411. &.disable {
  412. opacity: 0.4;
  413. }
  414. .lab {
  415. font-size: 28rpx;
  416. font-weight: 500;
  417. }
  418. .time {
  419. font-size: 24rpx;
  420. margin-top: 4rpx;
  421. }
  422. }
  423. }
  424. }
  425. .btn {
  426. width: 47%;
  427. height: 72rpx;
  428. background: #1989FA;
  429. border-radius: 8rpx;
  430. font-size: 28rpx;
  431. color: #fff;
  432. text-align: center;
  433. line-height: 72rpx;
  434. margin: 108rpx auto 50rpx auto;
  435. }
  436. .iconArrowBg {
  437. background: #D8D8D8;
  438. width: 26rpx;
  439. height: 26rpx;
  440. border-radius: 50%;
  441. display: flex;
  442. justify-content: center;
  443. align-items: center;
  444. margin-left: 4px;
  445. }
  446. .step2 {
  447. display: flex;
  448. justify-content: space-between;
  449. align-items: center;
  450. padding-bottom: 40px;
  451. .btnBg {
  452. width: 310rpx;
  453. }
  454. }
  455. </style>