diff --git a/src/layout/components/appointTime.vue b/src/layout/components/appointTime.vue index da0919d..dbfb2b3 100644 --- a/src/layout/components/appointTime.vue +++ b/src/layout/components/appointTime.vue @@ -4,10 +4,13 @@
第{{ index + 1 }}天 - +
+ + +
第 {{ row + 1 }} 个时间段 - +
@@ -120,8 +123,16 @@ const maxOptions = ref( const flag = ref(0) //第一个人数下标 var arr = new Array(4) const emit = defineEmits(['time-Info']) //组件绑定 + +const initTimeList = () => { + for (var i = 0; i < 4; i ++ ) { + timeList.value[i].splice(0) + } +} + onMounted(()=>{ init() + initTimeList() for(let i=0; i<4; i++) { //开始时初始化人数的数组 for(let j=0; j<6; j++) { for(let k=0;k<50;k++) { @@ -164,12 +175,7 @@ const onSubmit =()=> { } const resetForm=()=>{ for(let i=0;i<4;i++) { - timeList.value[i] = [{ - startTime: '', - endTime: '', - minNumValue: '', - maxNumValue: '', - }] + timeList.value[i].splice(0, timeList.value[i].length) isAvailableArray.value[i] = false } } diff --git a/src/utils/dealStringArray.js b/src/utils/dealStringArray.js index a773855..12b962a 100644 --- a/src/utils/dealStringArray.js +++ b/src/utils/dealStringArray.js @@ -15,13 +15,14 @@ const isValidPlus = (val) => { } export const transfer = (val, arr, isAvailableArr) => { + console.log('这是val:', val) 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].maxNumValue + ")" } } - // console.log(arr) + console.log('这是arr:', arr) for (var i = 0; i < 4; i ++ ) { for (var j = 0; j < 6; j ++ ) { if(isValidPlus(arr[i][j])) { @@ -51,9 +52,15 @@ export const transfer = (val, arr, isAvailableArr) => { numberRangeArr.push(arr[i][j].numberRange) } } - newArr[i].timeSlot = timeSlotArr.join(';') - newArr[i].numberRange = numberRangeArr.join(';') - newArr[i].isAvailable = isAvailableArr[i] ? 1 : 0 + if(val[i].length == 0){ + newArr[i].timeSlot = "00:00-00:00" + newArr[i].numberRange = "(0,0)" + newArr[i].isAvailable = 0 + }else{ + newArr[i].timeSlot = timeSlotArr.join(';') + newArr[i].numberRange = numberRangeArr.join(';') + newArr[i].isAvailable = isAvailableArr[i] ? 1 : 0 + } timeSlotArr = [] numberRangeArr = [] }