This commit is contained in:
@jyuhsin
2025-04-24 17:35:27 +08:00
parent 8b39a3b1ff
commit d599b2ad4c
3 changed files with 196 additions and 17 deletions
@@ -91,5 +91,5 @@ public class ActivitySiteInfo {
@Column
@Comment("场地的禁用时间")
@ColDefine(type = ColType.MYSQL_JSON)
private List<String> notApplyTimeList;
private List<NutMap> notApplyTimeList;
}
@@ -166,6 +166,7 @@ layout("/mobile/platform.html"){
</span>
</div>
<div v-if="isCanRe(item) === 0" class="state">已过期</div>
<div v-if="isCanRe(item) === 4" class="state">不可预约</div>
</td>
</tr>
</table>
@@ -305,14 +306,10 @@ layout("/mobile/platform.html"){
let count = 0
while (wk.length < 7) {
const addDate = moment(startDate).add(count, 'd')
const addDateFormat = moment(addDate).format('YYYY-MM-DD')
let dis = false
if(this.site.openWeekTime && !this.site.openWeekTime.includes(addDate.day())) {
dis = true
}
if(this.site.notApplyTimeList && this.site.notApplyTimeList?.includes(addDateFormat)) {
dis = true
}
wk.push({
day: addDate,
disabled: dis
@@ -373,6 +370,25 @@ layout("/mobile/platform.html"){
const now = new Date()
const end = moment().format('YYYY-MM-DD') + ' ' + item.end_time + ':00'
const itemFullTime = this.selectDate.format('YYYY-MM-DD') + " " + item.start_time + "-" + item.end_time
if(this.site.notApplyTimeList && this.site.notApplyTimeList.length > 0) {
const sTime = this.selectDate.format('YYYY-MM-DD') + " " + item.start_time
const eTime = this.selectDate.format('YYYY-MM-DD') + " " + item.end_time
for (let i = 0; i < this.site.notApplyTimeList.length; i++) {
const notApplyStartTime = this.site.notApplyTimeList[i].date + " " + this.site.notApplyTimeList[i].startTime
const notApplyEndTime = this.site.notApplyTimeList[i].date + " " + this.site.notApplyTimeList[i].endTime
const a = moment(sTime).isAfter(moment(notApplyStartTime)) && moment(sTime).isBefore(moment(notApplyEndTime))
const b = moment(eTime).isAfter(moment(notApplyStartTime)) && moment(eTime).isBefore(moment(notApplyEndTime))
const c = moment(sTime).isBefore(moment(notApplyStartTime)) && moment(eTime).isAfter(moment(notApplyEndTime))
if(a || b || c) {
return 4
}
}
}
if (this.alreadyReserveRecord.includes(itemFullTime)) {
return 3
}
@@ -204,15 +204,9 @@ layout("/layouts/platform.html"){
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item prop="notApplyTimeList" label="禁用时间">
<el-date-picker
style="width: 100%"
v-model="formData.notApplyTimeList"
type="dates"
value-format="yyyy-MM-dd"
clearable
placeholder="请选择禁用时间">
</el-date-picker>
<el-form-item label="禁用时间">
<el-button type="primary" @click="openSetUpTime" size="small">点击设置禁用时间</el-button>
<span style="color: #c64120">您已设置{{ formData.notApplyTimeList ? formData.notApplyTimeList.length : 0 }}个禁用时间</span>
</el-form-item>
</el-col>
</el-row>
@@ -262,6 +256,88 @@ layout("/layouts/platform.html"){
<template #view>
</template>
</guava>
<el-dialog :close-on-click-modal="false" :visible.sync="setUpTimeDialog" title="设置时间" top="50px">
<vi-title title="选择日期"></vi-title>
<el-date-picker
@change="setUpDateChange"
placeholder="请选择一个或多个日期"
style="width: 100%"
type="dates"
v-model="formData.setUpDate"
value-format="yyyy-MM-dd">
</el-date-picker>
<vi-title title="设置禁用时间" class="mt20"></vi-title>
<el-row>
<el-time-select
:picker-options="{
start: '08:30',
step: '00:05',
end: '23:30'
}"
placeholder="开始时间"
v-model="timeOneKeySet.startTime">
</el-time-select>
<el-time-select
:picker-options="{
start: '08:30',
step: '00:05',
end: '23:30'
}"
placeholder="结束时间"
v-model="timeOneKeySet.endTime">
</el-time-select>
<el-button @click="oneKeySetStartEndTime" type="primary">一键设置开始/结束时间</el-button>
</el-row>
<el-table :data="formData.notApplyTimeList" class="mt10" max-height="520px" size="mini" @selection-change="handleSelectionChange">
<el-table-column
type="selection"
width="55">
</el-table-column>
<el-table-column label="日期" width="200">
<template v-slot="{row}">
<i class="el-icon-time"></i>
{{moment(row.date).format('YYYY-MM-DD')}}
</template>
</el-table-column>
<el-table-column label="开始时间">
<template v-slot="{row}">
<el-time-select
size="mini"
:picker-options="pickerOptions"
placeholder="开始时间"
v-model="row.startTime">
</el-time-select>
</template>
</el-table-column>
<el-table-column label="结束时间">
<template v-slot="{row}">
<el-time-select
size="mini"
:picker-options="pickerOptions"
placeholder="结束时间"
v-model="row.endTime">
</el-time-select>
</template>
</el-table-column>
<el-table-column label="操作" width="200">
<template v-slot="{row, $index}">
<el-button
size="mini"
@click="formData.notApplyTimeList.splice($index,0,{date:row.date,startTime:'',endTime:''})"
type="primary">
新增同天时段
</el-button>
<el-button size="mini" @click="removeSetUpTableRow(row,$index)" type="danger">删除</el-button>
</template>
</el-table-column>
</el-table>
<el-row class="mt20" justify="end" type="flex">
<el-button @click="setUpTimeDialog = false">取消</el-button>
<el-button @click="doConfirmSetUpCourse" type="primary">确定</el-button>
</el-row>
</el-dialog>
</div>
<script>
@@ -271,6 +347,15 @@ layout("/layouts/platform.html"){
el: '#app',
data() {
return {
pickerOptions: {
start: "08:30",
step: "00:05",
end: "23:30"
},
timeOneKeySet: {
startTime: "",
endTime: ""
},
activityTypeList: [],
tabKey: '',
tableLoading: false,
@@ -278,7 +363,8 @@ layout("/layouts/platform.html"){
tableData: [],
formData: {
open_hours: [{}],
sexLimit: '0'
sexLimit: '0',
notApplyTimeList: [],
},
pageForm: {
searchName: "name",
@@ -298,13 +384,86 @@ layout("/layouts/platform.html"){
state: [{required: true, message: '请选择开启状态', trigger: ['blur', 'change']}],
typeId: [{required: true, message: '请选择场地类型', trigger: ['blur', 'change']}],
openWeekTime: [{required: true, message: '请选择预约时间', trigger: ['blur', 'change']}],
}
},
setUpTimeDialog: false,
multipleSelection: [],
}
},
components: {
'guava': httpVueLoader('/components/plugins/Guava.vue'),
},
methods: {
handleSelectionChange(val) {
this.multipleSelection = val
},
doConfirmSetUpCourse() {
const courseTableData = this.formData.notApplyTimeList
/*if (courseTableData.length === 0) {
this.$message.warning("请选择禁用时间")
return
}*/
if (courseTableData && courseTableData.length > 0) {
const valid = courseTableData.every(v => v.startTime && v.endTime && (v.startTime < v.endTime))
if (!valid) {
this.$message.warning("时间不完整或者有误")
return
}
this.setUpTimeDialog = false
}
},
removeSetUpTableRow(row, index) {
this.formData.notApplyTimeList.splice(index, 1)
const courseDateArray = this.formData.notApplyTimeList.map(v => moment(v.date).format("YYYY-MM-DD"))
const scdList = this.formData.setUpDate
this.formData.setUpDate = scdList.filter(v => {
return courseDateArray.includes(moment(v).format("YYYY-MM-DD"))
})
},
oneKeySetStartEndTime() {
if(this.multipleSelection.length === 0) {
this.$message.warning('请选择需要一键设置的时间')
return
}
const { startTime, endTime } = this.timeOneKeySet
this.formData.notApplyTimeList.forEach(v => {
const o = this.multipleSelection.find(o => o.date === v.date && o.startTime === v.startTime && o.endTime === v.endTime)
if(o) {
this.$set(v, "startTime", startTime)
this.$set(v, "endTime", endTime)
}
})
this.$forceUpdate()
},
setUpDateChange(val) {
if (!val) {
this.formData.notApplyTimeList = []
return
}
if (this.formData.notApplyTimeList === undefined) {
this.$set(this.formData, "notApplyTimeList", [])
}
const ctList = new Set(this.formData.notApplyTimeList.map(v => moment(v.date).format("YYYY-MM-DD")))
val.forEach(v => {
if (!ctList.has(v)) {
this.formData.notApplyTimeList.push({
date: v, time: null
})
}
})
this.formData.notApplyTimeList = this.formData.notApplyTimeList.filter(v => {
return val.includes(moment(v.date).format("YYYY-MM-DD"))
})
this.formData.notApplyTimeList.sort((a, b) => {
return Date.parse(a["date"]) - Date.parse(b["date"])
})
},
openSetUpTime() {
if(this.formData.notApplyTimeList) {
this.$set(this.formData, 'setUpDate', this.formData.notApplyTimeList.map(o => o.date))
}
this.setUpTimeDialog = true
},
doDelete(row) {
this.$confirm('此操作将删除【' + row.name + '】场地的所有信息!', '提示', {
confirmButtonText: '确定',
@@ -358,6 +517,9 @@ layout("/layouts/platform.html"){
},
async openEdit(id) {
this.formData = await this.findOneSite(id)
if(!this.formData.notApplyTimeList) {
this.$set(this.formData, 'notApplyTimeList', [])
}
this.$refs.guava.edit()
},
openAdd() {
@@ -367,7 +529,8 @@ layout("/layouts/platform.html"){
open_hours: [{}],
create_username: '${@shiro.getPrincipalProperty("username")}',
create_time: moment().format('YYYY-MM-DD'),
sexLimit: '0'
sexLimit: '0',
notApplyTimeList: [],
}
this.$refs.guava.edit()