2024-12-02 05:04:45 +00:00
|
|
|
|
<template>
|
|
|
|
|
<div class="date-picker">
|
|
|
|
|
<div class="father">
|
|
|
|
|
<div v-for="(item, index) in dayList" :key="index">
|
|
|
|
|
<div class="inner" style="font-size: medium;">
|
|
|
|
|
第{{ index + 1 }}天
|
|
|
|
|
</div>
|
|
|
|
|
<!-- 时间段部分 -->
|
|
|
|
|
<div class="time-picker">
|
|
|
|
|
<div v-for="(item, row) in timeList[index]" :key="row" class="box">
|
|
|
|
|
<span>第 {{ row + 1 }} 个时间段</span>
|
|
|
|
|
<el-time-select v-model="timeList[index][row].startTime"
|
|
|
|
|
style="width: 150px"
|
|
|
|
|
:max-time="timeList[index][row].endTime"
|
|
|
|
|
placeholder="Start time" size="default"
|
|
|
|
|
start="08:30" step="00:15" end="18:30" />
|
|
|
|
|
<el-time-select v-model="timeList[index][row].endTime" style="width: 150px"
|
|
|
|
|
:min-time="timeList[index][row].startTime" placeholder="End time" size="default"
|
|
|
|
|
start="08:30" step="00:15" end="18:30" />
|
|
|
|
|
<div class="numRange">
|
|
|
|
|
<span>人数范围</span>
|
|
|
|
|
<el-select v-model="timeList[index][row].minNumValue"
|
|
|
|
|
placeholder="最小人数"
|
|
|
|
|
style="width: 100px"
|
2024-12-02 08:30:55 +00:00
|
|
|
|
@change="minNumFun(timeList[index][row].minNumValue,index,row)">
|
2024-12-02 05:04:45 +00:00
|
|
|
|
<el-option v-for="item in minOptions[index][row]"
|
|
|
|
|
:key="item"
|
|
|
|
|
:value="item" />
|
|
|
|
|
</el-select>
|
|
|
|
|
<el-select v-model="timeList[index][row].maxNunValue"
|
|
|
|
|
placeholder="最大人数"
|
|
|
|
|
style="width: 100px">
|
|
|
|
|
<el-option v-for="item in maxOptions[index][row]"
|
|
|
|
|
:key="item"
|
|
|
|
|
:value="item" />
|
|
|
|
|
</el-select>
|
|
|
|
|
<el-button circle @click="addList(index, row)"><el-icon>
|
|
|
|
|
<Plus />
|
|
|
|
|
</el-icon></el-button>
|
|
|
|
|
<el-button circle @click="subList(index, row)" v-if="row + 1 > 1"><el-icon>
|
|
|
|
|
<Minus />
|
|
|
|
|
</el-icon></el-button>
|
2024-12-02 08:30:55 +00:00
|
|
|
|
<el-checkbox v-model="timeList[index][row].isAvailable" label="此时间段可预约" style="margin-left: 10px;"/>
|
2024-12-02 05:04:45 +00:00
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2024-12-02 08:30:55 +00:00
|
|
|
|
<div class="totalButton">
|
|
|
|
|
<el-form-item>
|
|
|
|
|
<el-button type="primary" @click="onSubmit">保存</el-button>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item>
|
|
|
|
|
<el-button type="primary" @click="resetForm">重置</el-button>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</div>
|
2024-12-02 05:04:45 +00:00
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script setup lang="ts">
|
2024-12-02 08:30:55 +00:00
|
|
|
|
import { onMounted, ref , defineEmits } from 'vue'
|
2024-12-02 05:04:45 +00:00
|
|
|
|
import { Plus } from '@element-plus/icons-vue';
|
2024-12-03 04:29:33 +00:00
|
|
|
|
|
2024-12-02 05:04:45 +00:00
|
|
|
|
const dayList = ref([0, 1, 2, 3]) //今天和未来三天
|
|
|
|
|
const timeList = ref([ //时间段数组,可以直接通过timeList[index][row]访问对应的时间段
|
|
|
|
|
[
|
|
|
|
|
{
|
|
|
|
|
startTime: '',
|
|
|
|
|
endTime: '',
|
|
|
|
|
minNumValue: '',
|
2024-12-02 08:30:55 +00:00
|
|
|
|
maxNunValue: '',
|
|
|
|
|
isAvailable: false
|
2024-12-02 05:04:45 +00:00
|
|
|
|
}
|
|
|
|
|
],
|
|
|
|
|
[
|
|
|
|
|
{
|
|
|
|
|
startTime: '',
|
|
|
|
|
endTime: '',
|
|
|
|
|
minNumValue: '',
|
2024-12-02 08:30:55 +00:00
|
|
|
|
maxNunValue: '',
|
|
|
|
|
isAvailable: false
|
2024-12-02 05:04:45 +00:00
|
|
|
|
}
|
|
|
|
|
],
|
|
|
|
|
[
|
|
|
|
|
{
|
|
|
|
|
startTime: '',
|
|
|
|
|
endTime: '',
|
|
|
|
|
minNumValue: '',
|
2024-12-02 08:30:55 +00:00
|
|
|
|
maxNunValue: '',
|
|
|
|
|
isAvailable: false
|
2024-12-02 05:04:45 +00:00
|
|
|
|
}
|
|
|
|
|
],
|
|
|
|
|
[
|
|
|
|
|
{
|
|
|
|
|
startTime: '',
|
|
|
|
|
endTime: '',
|
|
|
|
|
minNumValue: '',
|
2024-12-02 08:30:55 +00:00
|
|
|
|
maxNunValue: '',
|
|
|
|
|
isAvailable: false
|
2024-12-02 05:04:45 +00:00
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
])
|
2024-12-03 04:29:33 +00:00
|
|
|
|
|
2024-12-02 05:04:45 +00:00
|
|
|
|
//人数数组,初始化好四天六个时间段的人数
|
|
|
|
|
const minOptions = ref(
|
|
|
|
|
Array.from({length:4},()=>(
|
|
|
|
|
Array.from({length:6},()=>(
|
|
|
|
|
Array.from({length:50},()=>( 0 ))
|
|
|
|
|
))
|
|
|
|
|
))
|
|
|
|
|
)
|
|
|
|
|
const maxOptions = ref(
|
|
|
|
|
Array.from({length:4},()=>(
|
|
|
|
|
Array.from({length:6},()=>(
|
|
|
|
|
Array.from({length:50},()=>( 0 ))
|
|
|
|
|
))
|
|
|
|
|
))
|
|
|
|
|
)
|
|
|
|
|
const flag = ref(0) //第一个人数下标
|
2024-12-02 08:30:55 +00:00
|
|
|
|
const appointmentDateAddRequestList = ref(
|
|
|
|
|
Array.from({length: 4},()=>(
|
|
|
|
|
{
|
|
|
|
|
timeSlot: '',
|
|
|
|
|
isAvailable: 0,
|
|
|
|
|
numberRange: ''
|
|
|
|
|
}
|
|
|
|
|
)),
|
|
|
|
|
)
|
2024-12-03 04:29:33 +00:00
|
|
|
|
|
|
|
|
|
var arr = new Array(4)
|
|
|
|
|
const init = () => {
|
|
|
|
|
for (var i = 0; i < 4; i ++ ) {
|
|
|
|
|
arr[i] = new Array(6)
|
|
|
|
|
}
|
|
|
|
|
for (var i = 0; i < 4; i ++ ) {
|
|
|
|
|
for (var j = 0; j < 6; j ++ ) {
|
|
|
|
|
arr[i][j] = {
|
|
|
|
|
timeSlot: '',
|
|
|
|
|
numberRange: '',
|
|
|
|
|
isAvailable: ''
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-12-02 08:30:55 +00:00
|
|
|
|
const emit = defineEmits(['time-Info']) //组件绑定
|
2024-12-02 05:04:45 +00:00
|
|
|
|
onMounted(()=>{
|
2024-12-03 04:29:33 +00:00
|
|
|
|
init()
|
2024-12-02 05:04:45 +00:00
|
|
|
|
for(let i=0; i<4; i++) { //开始时初始化人数的数组
|
|
|
|
|
for(let j=0; j<6; j++) {
|
|
|
|
|
for(let k=0;k<50;k++) {
|
2024-12-02 08:30:55 +00:00
|
|
|
|
minOptions.value[i][j][k] = k+5;
|
|
|
|
|
maxOptions.value[i][j][k] = k+6;
|
2024-12-02 05:04:45 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
const addList = (index: any, row: any) => {
|
|
|
|
|
if (timeList.value[index].length < 6) {
|
|
|
|
|
timeList.value[index].push({
|
|
|
|
|
startTime: '',
|
|
|
|
|
endTime: '',
|
|
|
|
|
minNumValue: '',
|
2024-12-02 08:30:55 +00:00
|
|
|
|
maxNunValue: '',
|
|
|
|
|
isAvailable: false
|
2024-12-02 05:04:45 +00:00
|
|
|
|
})
|
|
|
|
|
flag.value += 1
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
const subList = (index: number, row: number) => {
|
|
|
|
|
timeList.value[index].splice(row, 1)
|
|
|
|
|
}
|
2024-12-02 08:30:55 +00:00
|
|
|
|
const minNumFun = (number : any,index : number,row : number)=> {
|
|
|
|
|
maxOptions.value[index][row].splice(0,number-5)
|
|
|
|
|
}
|
2024-12-03 04:29:33 +00:00
|
|
|
|
import { transfer } from '../../utils/dealStringArray';
|
2024-12-02 08:30:55 +00:00
|
|
|
|
//组件传值
|
2024-12-03 04:29:33 +00:00
|
|
|
|
const onSubmit =()=> {
|
|
|
|
|
let tempArr = transfer(timeList.value, arr)
|
|
|
|
|
console.log(tempArr)
|
2024-12-02 08:30:55 +00:00
|
|
|
|
//将数组处理成后端格式
|
2024-12-03 04:29:33 +00:00
|
|
|
|
emit('time-Info',tempArr)
|
2024-12-02 08:30:55 +00:00
|
|
|
|
}
|
2024-12-03 04:29:33 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// const isNotValid = (val:any) => {
|
|
|
|
|
// const timeRegex = /^([0-1]?[0-9]|2[0-3]):([0-5]?[0-9])-(?:[0-1]?[0-9]|2[0-3]):([0-5]?[0-9])$/;
|
|
|
|
|
// const rangeRegex = /^\(\d+,\d+\)$/
|
|
|
|
|
// return timeRegex.test(val.timeSlot) && rangeRegex.test(val.numberRange)
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
// const isValidPlus = (val:any) => {
|
|
|
|
|
// const timeRegex = /^([0-1]?[0-9]|2[0-3]):([0-5]?[0-9])-(?:[0-1]?[0-9]|2[0-3]):([0-5]?[0-9])$/;
|
|
|
|
|
// const rangeRegex = /^\(\d+,\d+\)$/
|
|
|
|
|
// if(val.timeSlot === '' && val.numberRange === '') return false
|
|
|
|
|
// if(timeRegex.test(val.timeSlot) && rangeRegex.test(val.numberRange)) return false
|
|
|
|
|
// return true
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
// const transfer = (val:any) => {
|
|
|
|
|
// for (var i = 0; i < val.length; i ++ ) {
|
|
|
|
|
// for (var j = 0; j < val[i].length; j ++ ) {
|
|
|
|
|
// arr[i][j].timeSlot = val[i][j].startTime + "-" + val[i][j].endTime
|
|
|
|
|
// arr[i][j].numberRange = "(" + val[i][j].minNumValue + "," + val[i][j].maxNunValue + ")"
|
|
|
|
|
// arr[i][j].isAvailable = val[i][j].isAvailable
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// // console.log(arr)
|
|
|
|
|
// for (var i = 0; i < 4; i ++ ) {
|
|
|
|
|
// for (var j = 0; j < 6; j ++ ) {
|
|
|
|
|
// if(isValidPlus(arr[i][j])) {
|
|
|
|
|
// ElMessage({
|
|
|
|
|
// type: 'error',
|
|
|
|
|
// message: '请检查表单数据是否完整填写'
|
|
|
|
|
// })
|
|
|
|
|
// return ;
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// let newArr:any = new Array(4)
|
|
|
|
|
// for (var i = 0; i < 4; i ++ ) {
|
|
|
|
|
// newArr[i] = {
|
|
|
|
|
// timeSlot:'',
|
|
|
|
|
// numberRange: '',
|
|
|
|
|
// isAvailable: true
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
// let timeSlotArr:any = []
|
|
|
|
|
// let numberRangeArr:any = []
|
|
|
|
|
// for (var i = 0; i < val.length; i ++ ) {
|
|
|
|
|
// for (var j = 0; j < val[i].length; j ++ ) {
|
|
|
|
|
// if(isNotValid(arr[i][j])) {
|
|
|
|
|
// timeSlotArr.push(arr[i][j].timeSlot)
|
|
|
|
|
// numberRangeArr.push(arr[i][j].numberRange)
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// newArr[i].timeSlot = timeSlotArr.join(';')
|
|
|
|
|
// newArr[i].numberRange = numberRangeArr.join(';')
|
|
|
|
|
// timeSlotArr = []
|
|
|
|
|
// numberRangeArr = []
|
|
|
|
|
// }
|
|
|
|
|
// console.log(newArr)
|
|
|
|
|
// return newArr
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-12-02 08:30:55 +00:00
|
|
|
|
const resetForm=()=>{
|
2024-12-03 04:29:33 +00:00
|
|
|
|
console.log(3333)
|
2024-12-02 08:30:55 +00:00
|
|
|
|
for(let i=0;i<4;i++) {
|
|
|
|
|
timeList.value[i] = [{
|
|
|
|
|
startTime: '',
|
|
|
|
|
endTime: '',
|
|
|
|
|
minNumValue: '',
|
|
|
|
|
maxNunValue: '',
|
|
|
|
|
isAvailable: false
|
|
|
|
|
}]
|
2024-12-02 05:04:45 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
2024-12-02 08:30:55 +00:00
|
|
|
|
.date-picker {
|
|
|
|
|
height: 750px;
|
|
|
|
|
}
|
2024-12-02 05:04:45 +00:00
|
|
|
|
div {
|
|
|
|
|
font-size: 12px;
|
|
|
|
|
color: rgb(96, 98, 102);
|
|
|
|
|
}
|
|
|
|
|
.time-picker {
|
|
|
|
|
display: flex;
|
|
|
|
|
flex-wrap: wrap;
|
|
|
|
|
}
|
|
|
|
|
.box {
|
|
|
|
|
width: 380px;
|
|
|
|
|
height: 50pxpx;
|
|
|
|
|
}
|
|
|
|
|
.numRange {
|
|
|
|
|
margin-left: 26px;
|
|
|
|
|
}
|
2024-12-02 08:30:55 +00:00
|
|
|
|
.totalButton {
|
|
|
|
|
display: flex;
|
|
|
|
|
justify-content: space-evenly;
|
|
|
|
|
}
|
2024-12-02 05:04:45 +00:00
|
|
|
|
</style>
|