This commit is contained in:
@jyuhsin
2025-05-12 11:23:28 +08:00
parent d599b2ad4c
commit f8c3dd87bb
11 changed files with 489 additions and 666 deletions
@@ -179,11 +179,11 @@ layout("/mobile/platform.html"){
<van-action-sheet v-model="show" title="确认预约信息">
<van-cell title="预约人">{{person}}</van-cell>
<van-cell title="性别">${@shiro.getPrincipalProperty('sex')}</van-cell>
<van-cell title="工号">${@shiro.getPrincipalProperty('loginname')}</van-cell>
<van-cell title="所属单位">{{unit}}</van-cell>
<van-cell title="联系电话">{{phone}}</van-cell>
<van-cell title="预约人">{{formData.reserve_person}}</van-cell>
<van-cell title="性别">{{formData.sex}}</van-cell>
<van-cell title="工号">{{formData.loginname}}</van-cell>
<van-cell title="所属单位">{{formData.reserve_person_unit}}</van-cell>
<van-cell title="联系电话">{{formData.reserve_person_phone}}</van-cell>
<van-cell title="预约时间">
<div v-for="time in times">
<van-tag closeable size="medium" type="primary" @close="close(time.fullDay)">
@@ -192,8 +192,13 @@ layout("/mobile/platform.html"){
</div>
</van-cell>
<van-cell title="预约地点">{{site.name}}</van-cell>
<van-field name="stepper" label="预约人数">
<template #input>
<van-stepper v-model="formData.joinCount"></van-stepper>
</template>
</van-field>
<van-field
v-model="message"
v-model="formData.message"
rows="4"
autosize
label="预约事由"
@@ -204,7 +209,7 @@ layout("/mobile/platform.html"){
></van-field>
<div style="margin: 20px 0px; display: flex; justify-content: space-between;padding: 0px 22px;">
<van-button @click="message = '';show = false" color="#246fb4" style="width: 47%" size="small" plain
<van-button @click="formData.message = '';show = false" color="#246fb4" style="width: 47%" size="small" plain
type="info">关闭
</van-button>
<van-button @click="reserveDo" color="#246fb4" style="width: 47%" size="small" type="info">确认</van-button>
@@ -226,10 +231,7 @@ layout("/mobile/platform.html"){
data() {
return {
isLoad: false,
person: "${@shiro.getPrincipalProperty('username')}",
unit: "${@shiro.getPrincipalProperty('unit').getName()}",
phone: "${@shiro.getPrincipalProperty('mobile')}",
message: '',
formData: {},
show: false,
site_id: '',
site: {},
@@ -241,8 +243,7 @@ layout("/mobile/platform.html"){
selectDate: null,
//已经预约的记录
alreadyReserveRecord: [],
holidays: ['2022-06-03', '2022-06-04', '2022-06-05', '2022-09-10', '2022-09-11', '2022-09-12',
'2022-10-01', '2022-10-02', '2022-10-03', '2022-10-04', '2022-10-05', '2022-10-06', '2022-10-07',],
allowDayList: [],
}
},
computed: {
@@ -269,11 +270,6 @@ layout("/mobile/platform.html"){
},
calendarFormatter() {
return (day) => {
// 休息日不能选择
/*let week = day.date.getDay()
if (week === 0 || week === 6) {
day.type = 'disabled'
}*/
return day
}
}
@@ -307,7 +303,7 @@ layout("/mobile/platform.html"){
while (wk.length < 7) {
const addDate = moment(startDate).add(count, 'd')
let dis = false
if(this.site.openWeekTime && !this.site.openWeekTime.includes(addDate.day())) {
if(this.allowDayList.length > 0 && !this.allowDayList.includes(moment(addDate).format('YYYY-MM-DD'))) {
dis = true
}
wk.push({
@@ -331,14 +327,27 @@ layout("/mobile/platform.html"){
vant.Toast('请选择要预约的时段')
return
}
this.$set(this.formData, "reserve_person", '${@shiro.getPrincipalProperty("username")}')
this.$set(this.formData, "sex", "${@shiro.getPrincipalProperty('sex')}")
this.$set(this.formData, "loginname", "${@shiro.getPrincipalProperty('loginname')}")
this.$set(this.formData, "reserve_person_unit", '${@shiro.getPrincipalProperty("unit").getName()}')
this.$set(this.formData, "reserve_person_phone", '${@shiro.getPrincipalProperty("mobile")}')
if(this.site.reserveTarget === 1 || this.site.reserveTarget === 3) {
this.$set(this.formData, "joinCount", this.site.maxNum)
} else {
this.$set(this.formData, "joinCount", 1)
}
this.show = true
},
async reserveDo() {
const resp = await $.post('/mobile/activity/site/info/reserveDo', {
siteId: this.site_id,
times: JSON.stringify(this.times),
message: this.message,
joinUser: this.joinUser,
message: this.formData.message,
joinUser: this.formData.joinUser,
joinCount: this.formData.joinCount,
})
if (resp.code === 0) {
vant.Toast('预约成功')
@@ -361,6 +370,7 @@ layout("/mobile/platform.html"){
if (index > -1) {
this.times.splice(index, 1)
} else {
this.times = []
cloneItem.day = this.selectDate.format('YYYY-MM-DD')
cloneItem.fullDay = cloneItem.day + ' ' + cloneItem.start_time + '-' + cloneItem.end_time
this.times.push(cloneItem)
@@ -395,11 +405,7 @@ layout("/mobile/platform.html"){
if (now.getTime() >= new Date(end).getTime() && this.selectDate.format('YYYY-MM-DD') === moment().format('YYYY-MM-DD')) {
return 0
} else {
if (this.site.multiple) {
return 1
} else {
return item.hasReserve === true ? 2 : 1
}
return item.hasCount >= item.allowCount ? 2 : 1
}
},
async onLoad() {
@@ -411,16 +417,11 @@ layout("/mobile/platform.html"){
this.loading = false
},
async getReserve() {
const resp = await $.post('/mobile/activity/site/info/getReserve', {
const { data } = await $.get("/platform/activity/site/reserve/getTimesByDay", {
siteId: this.site_id,
day: moment(this.selectDate).format('YYYY-MM-DD'),
})
if (resp.code === 0) {
resp.data.forEach(item => {
item.isClick = true
})
this.timeData = resp.data
}
this.timeData = data
},
async getMyReservation() {
const resp = await $.post('/mobile/activity/site/info/getMyReservation', {
@@ -430,26 +431,23 @@ layout("/mobile/platform.html"){
this.alreadyReserveRecord = resp.data.map(v => v.reserve_day + " " + v.start_time + "-" + v.end_time)
}
},
getLatestWorkDay() {
let selectDate = moment()
if(this.site.workday === true) {
if (selectDate.day() === 0) {
//周日
selectDate = moment().add(1, 'd')
} else if (selectDate.day() === 6) {
//周六
selectDate = moment().add(2, 'd')
}
}
return selectDate
}
async getAllowTime(year = null, month = null) {
const m = moment(this.selectDate, "YYYY年M月")
const { data } = await $.get("/platform/activity/site/reserve/getAllowTime", {
siteId: this.site_id,
year: year != null ? year : m.year(),
month: month != null ? month : m.month() + 1,
})
this.allowDayList = data
},
},
async created() {
this.site_id = getQueryString('id')
this.selectDate = moment()
await this.getReserve()
await this.onLoad()
this.selectDate = this.getLatestWorkDay()
this.setWeekList(this.selectDate)
await this.getAllowTime()
await this.setWeekList(this.selectDate)
await this.getMyReservation()
this.isLoad = true
}