|
@ -8,43 +8,180 @@ |
|
|
</view> |
|
|
</view> |
|
|
您不会再接收到选择日期内的订单 |
|
|
您不会再接收到选择日期内的订单 |
|
|
</view> |
|
|
</view> |
|
|
<view class="buttom level" :style="{borderRadius:'31rpx'}"> |
|
|
|
|
|
|
|
|
<view @click="show = true" class="buttom level" :style="{borderRadius:'31rpx'}"> |
|
|
添加不接单日期 |
|
|
添加不接单日期 |
|
|
</view> |
|
|
</view> |
|
|
</view> |
|
|
</view> |
|
|
<view class="line1"> |
|
|
|
|
|
</view> |
|
|
|
|
|
<view class="level center"> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<view v-if="selectDateList.length" class="level center"> |
|
|
<view class=""> |
|
|
<view class=""> |
|
|
<view class="text1" :style="{ textAlign: 'right' }"> |
|
|
<view class="text1" :style="{ textAlign: 'right' }"> |
|
|
8天 |
|
|
|
|
|
|
|
|
{{ selectDateList.length }}天 |
|
|
</view> |
|
|
</view> |
|
|
共不接单时间 |
|
|
共不接单时间 |
|
|
</view> |
|
|
</view> |
|
|
<view class="level center_item"> |
|
|
<view class="level center_item"> |
|
|
<view class=""> |
|
|
|
|
|
<!-- <up-icon name="edit-pen" color="#2979ff" size="22"></up-icon> --> |
|
|
|
|
|
|
|
|
<!-- <view class=""> |
|
|
|
|
|
<up-icon name="edit-pen" color="#2979ff" size="22"></up-icon> |
|
|
修改 |
|
|
修改 |
|
|
</view> |
|
|
|
|
|
<view class=""> |
|
|
|
|
|
|
|
|
</view> --> |
|
|
|
|
|
<view @click="cleanDates" class=""> |
|
|
<!-- <up-icon name="trash" color="#2979ff" size="22"></up-icon> --> |
|
|
<!-- <up-icon name="trash" color="#2979ff" size="22"></up-icon> --> |
|
|
清空 |
|
|
清空 |
|
|
</view> |
|
|
</view> |
|
|
</view> |
|
|
</view> |
|
|
</view> |
|
|
</view> |
|
|
<view class="item box-size" :style="{borderRadius:'16rpx'}"> |
|
|
|
|
|
2月不接单 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<view v-if="selectDateList.length" v-for="(dates,month) in groupedDates" :key="month" class="item box-size" |
|
|
|
|
|
:style="{borderRadius:'16rpx'}"> |
|
|
|
|
|
{{ month }}不接单 |
|
|
<view class="text2"> |
|
|
<view class="text2"> |
|
|
共6天:2月19日、2月22日、2月24日、2月27日、2月28日、2月29日 |
|
|
|
|
|
|
|
|
共{{ dates.length }}天:<text v-for="(item,index) in dates" |
|
|
|
|
|
:key="index">{{ item + (index != dates.length - 1 ? "," : "") }}</text> |
|
|
</view> |
|
|
</view> |
|
|
</view> |
|
|
</view> |
|
|
<view class="buttom_ level" :style="{borderRadius:'41rpx'}"> |
|
|
|
|
|
|
|
|
<view @click="submit" class="buttom_ level" :style="{borderRadius:'41rpx'}"> |
|
|
保存 |
|
|
保存 |
|
|
</view> |
|
|
</view> |
|
|
</view> |
|
|
</view> |
|
|
|
|
|
|
|
|
|
|
|
<up-action-sheet :actions="list" @select="selectClick" :show="show" :round="10"></up-action-sheet> |
|
|
|
|
|
<up-calendar :show="calendarShow" color="#FFBF60" :round="10" :showTitle="false" :mode="mode" @confirm="confirm" |
|
|
|
|
|
@close="closeCandler" :minDate="minDate" :maxDate="maxDate"></up-calendar> |
|
|
</template> |
|
|
</template> |
|
|
|
|
|
|
|
|
<script> |
|
|
|
|
|
|
|
|
<script setup> |
|
|
|
|
|
import { |
|
|
|
|
|
ref |
|
|
|
|
|
} from "vue" |
|
|
|
|
|
|
|
|
|
|
|
import { |
|
|
|
|
|
onLoad, |
|
|
|
|
|
onShow |
|
|
|
|
|
} from '@dcloudio/uni-app' |
|
|
|
|
|
import { |
|
|
|
|
|
insertOutDate, |
|
|
|
|
|
outDateList |
|
|
|
|
|
} from "@/api/date/index.js" |
|
|
|
|
|
|
|
|
|
|
|
onLoad((options) => { |
|
|
|
|
|
addressId.value = options.addressId |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
onShow(() => { |
|
|
|
|
|
let response = outDateList(); |
|
|
|
|
|
console.log("返回数据",response) |
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
const addressId = ref(0) |
|
|
|
|
|
const list = ref([{ |
|
|
|
|
|
index: 0, |
|
|
|
|
|
name: '添加不接单日期区间' |
|
|
|
|
|
}, |
|
|
|
|
|
{ |
|
|
|
|
|
index: 1, |
|
|
|
|
|
name: '添加不接单日期' |
|
|
|
|
|
}, |
|
|
|
|
|
{ |
|
|
|
|
|
index: 2, |
|
|
|
|
|
name: '取消' |
|
|
|
|
|
} |
|
|
|
|
|
]); |
|
|
|
|
|
|
|
|
|
|
|
const show = ref(false); |
|
|
|
|
|
const calendarShow = ref(false); |
|
|
|
|
|
const mode = ref('range'); |
|
|
|
|
|
const selectDateList = ref([]); |
|
|
|
|
|
const groupedDates = ref({}); //按月分组 |
|
|
|
|
|
const d = new Date(); |
|
|
|
|
|
const currentYear = d.getFullYear(); |
|
|
|
|
|
const minDate = `${currentYear}-01-01`; |
|
|
|
|
|
const maxDate = `${currentYear}-12-31`; |
|
|
|
|
|
|
|
|
|
|
|
// 方法 |
|
|
|
|
|
const selectClick = (selectItem) => { |
|
|
|
|
|
if (selectItem.index == 0) { |
|
|
|
|
|
mode.value = 'range'; |
|
|
|
|
|
calendarShow.value = true; |
|
|
|
|
|
} else if (selectItem.index == 1) { |
|
|
|
|
|
mode.value = 'single'; |
|
|
|
|
|
calendarShow.value = true; |
|
|
|
|
|
} |
|
|
|
|
|
show.value = false; |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
const confirm = (e) => { |
|
|
|
|
|
const list = [...selectDateList.value, ...e]; |
|
|
|
|
|
selectDateList.value = [...new Set(list)]; |
|
|
|
|
|
gruopDate(selectDateList.value); |
|
|
|
|
|
calendarShow.value = false; |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
const closeCandler = () => { |
|
|
|
|
|
calendarShow.value = false; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 日期按月分组 |
|
|
|
|
|
const gruopDate = (dateList) => { |
|
|
|
|
|
groupedDates.value = {} |
|
|
|
|
|
dateList.forEach(date => { |
|
|
|
|
|
const [year, month, day] = date.split('-'); |
|
|
|
|
|
const formattedDate = `${parseInt(month)}月${parseInt(day)}日`; |
|
|
|
|
|
const monthKey = `${parseInt(month)}月`; |
|
|
|
|
|
|
|
|
|
|
|
if (!groupedDates.value[monthKey]) { |
|
|
|
|
|
groupedDates.value[monthKey] = []; |
|
|
|
|
|
} |
|
|
|
|
|
groupedDates.value[monthKey].push(formattedDate); |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
// 对键进行排序 |
|
|
|
|
|
const sortedKeys = Object.keys(groupedDates.value).sort((a, b) => { |
|
|
|
|
|
const monthA = parseInt(a.replace('月', '')); |
|
|
|
|
|
const monthB = parseInt(b.replace('月', '')); |
|
|
|
|
|
return monthA - monthB; |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
// 根据排序后的键构建新对象 |
|
|
|
|
|
const sortedGroupedDates = {}; |
|
|
|
|
|
sortedKeys.forEach(key => { |
|
|
|
|
|
sortedGroupedDates[key] = groupedDates.value[key]; |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
// 更新 groupedDates 的值 |
|
|
|
|
|
groupedDates.value = sortedGroupedDates; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const cleanDates = () => { |
|
|
|
|
|
selectDateList.value = []; |
|
|
|
|
|
gruopDate(selectDateList.value); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const submit = async () => { |
|
|
|
|
|
if (!selectDateList.value.length) { |
|
|
|
|
|
return uni.showToast({ |
|
|
|
|
|
title: '请选择日期', |
|
|
|
|
|
icon: "none" |
|
|
|
|
|
}) |
|
|
|
|
|
} else if (!addressId.value) { |
|
|
|
|
|
return uni.showToast({ |
|
|
|
|
|
title: '地址标识不能为空', |
|
|
|
|
|
icon: "none" |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
|
|
|
let response = await insertOutDate({ |
|
|
|
|
|
addressId: addressId.value, |
|
|
|
|
|
date: selectDateList.value.toString() |
|
|
|
|
|
}) |
|
|
|
|
|
if (response.code == 200) { |
|
|
|
|
|
uni.showToast({ |
|
|
|
|
|
title: response.msg, |
|
|
|
|
|
icon: "none" |
|
|
|
|
|
}) |
|
|
|
|
|
uni.navigateBack(-1); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
</script> |
|
|
</script> |
|
|
|
|
|
|
|
|
<style scoped lang="scss"> |
|
|
<style scoped lang="scss"> |
|
|