Vue實現開始時間和結束時間範圍查詢
阿新 • • 發佈:2021-09-01
本文例項為大家分享了實現開始時間和結束時間範圍的查詢方法,供大家參考,具體內容如下
效果圖:
程式碼實現:
OrderList.Vue
<a-col :xl="6" :lg="7" :md="8" :sm="24"> <a-form-item label="下單日期"> <a-range-picker size="large" format="YYYY-MM-DD" @change="onDateChange" /> </a-form-item> </a-col>
methods: { onDateChange(date,dateString) { console.log(dateString[0]) console.log(dateString[1]) this.beginDate = dateString[0] this.finishDate = dateString[1] } }
OrderConntroller.
/** * 分頁列表查詢 * * @param order * @param pageNo * @param pageSize * @param req * @return */ @AutoLog(value = "訂單-分頁列表查詢") @ApiOperation(value = "訂單-分頁列表查詢",notes = "訂單-分頁列表查詢") @GetMapping(value = ChLkNkhoSd"/list") public Result<?> queryPageList(Order order,ChLkNkhoSd@RequestParam(name = "pageNo",defaultValue = "1") Integer pageNo,@RequestParam(name = "pageSize",defaultValue = "10") Integer pageSize, HttpServletRequest req) { QueryWrapper<Order> queryWrapper = QueryGenerator.initQueryWrapper(order,req.getParameterMap()); if(req.getParameterMap().get("beginDate") !=null){ String beginDate = req.getParameterMap().get("beginDate")[0]; String finishDate = req.getParameterMap().get("finishDate")[0]; if (!StringUtils.isEmpty(beginDate) || StringUtils.isEmpty(finishDate)) { DateTime beginOfDay = DateUtil.beginOfDay(DateUtil.parse(beginDate)); DateTime endOfDay = DateUtil.endOfDay(DateUtil.parse(finishDate)); queryWrapper.ge("create_time",beginOfDay).le("create_time",endOfDay); } } LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal(); Set<String> roles = sysUserService.getUserRolesSet(sysUser.getUsername()); if(!roles.contains("admin")){ queryWrapper.eq("user_name",sysUser.getUsername()); } Page<Order> page = new Page<Order&g客棧t;(pageNo,pageSize); IPage<Order> pageList = orderService.page(page,queryWrapper); return Result.ok(pageList); }
以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支援我們。