Commit 6fb553e9 by LJM

add

parent 8b6bb87e
Showing with 22 additions and 4 deletions
......@@ -5,7 +5,7 @@
<view class="time-interval-box row verCenter bothSide">
<view class="row verCenter">
<text class="iconfont icon-juxing4"></text>
<picker mode="date" @change="bindTimeChange(1, $event)">
<picker mode="date" @change="bindTimeChange(1, $event)" :value="searchParams.arrival_time_begin">
<input type="text" class="uni-input" placeholder="请选择起始时间" placeholder-style="color:#919399" v-model="searchParams.arrival_time_begin" />
</picker>
</view>
......@@ -14,7 +14,7 @@
<view class="time-interval-box row verCenter bothSide">
<view class="row verCenter">
<text class="iconfont icon-juxing4"></text>
<picker mode="date" @change="bindTimeChange(2, $event)">
<picker mode="date" @change="bindTimeChange(2, $event)" :value="searchParams.arrival_time_end">
<input type="text" class="uni-input" placeholder="请选择结束时间" placeholder-style="color:#919399" v-model="searchParams.arrival_time_end" />
</picker>
</view>
......@@ -199,6 +199,7 @@
export default {
data() {
const { startDate, endDate } = this.getDefaultDateRange(); // 获取默认日期范围
return {
user_email: uni.getStorageSync('name'),
is_focus: true, //获取焦点动态化
......@@ -216,8 +217,8 @@
hasMoreData: true, //是否分页加载
maxInputLength: 7,
searchParams: {
arrival_time_begin: '',
arrival_time_end: '',
arrival_time_begin: startDate,
arrival_time_end: endDate,
mobile_register_all_search: '', //全量搜索
stock_in_with_stock_in_items_inhouse: '', //入仓单号
box_sn: '' //箱号
......@@ -243,6 +244,23 @@
this.getData();
},
methods: {
// 获取默认的日期范围,返回最近一个月的起始和结束日期
getDefaultDateRange() {
const currentDate = new Date();
const endDate = this.formatDate(currentDate); // 结束日期为今天
currentDate.setMonth(currentDate.getMonth() - 1); // 将月份减去 1 得到一个月前的日期
const startDate = this.formatDate(currentDate); // 起始日期为一个月前
return { startDate, endDate }; // 返回一个对象,包含起始和结束日期
},
// 格式化日期为 YYYY-MM-DD 格式的字符串
formatDate(date) {
const year = date.getFullYear();
const month = (date.getMonth() + 1).toString().padStart(2, '0'); // 确保月份为两位数
const day = date.getDate().toString().padStart(2, '0'); // 确保日期为两位数
return `${year}-${month}-${day}`; // 返回格式化后的日期字符串
},
/**
* 时间选择
*/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment