一个输入框需要传多个字段的情况
解决:
在实体类新加一个字段
@Excel(name = "用来查询多个值得条件") private String Bastard;
生成对应的 get 和 set ,还有 toString
然后在相应的xml
里,加入以下配置
<if test ="Bastard != null and Bastard != ''" > and (stu.`user_name` like concat('%',#{Bastard},'%') or stu.`student_num` = #{Bastard} or stu.`phone` = #{Bastard})</if >
然后在对应的html
里写入对应的name
即可
<li > <input style ="border:none; border-bottom:2px solid #eee;outline:none" type ="text" name ="Bastard" placeholder ="学员姓名及首字母/学号/电话" /> </li >
Mybatis里面的foreach用法 <if test ="className != null and className != ''" > and cla.`class_name` in <foreach item ="item" index ="index" collection ="className.split(',')" open ="(" separator ="," close =")" > #{item} </foreach > </if >
foreach元素的属性主要有 item,index,collection,open,separator,close。
item表示集合中每一个元素进行迭代时的别名.
index指 定一个名字,用于表示在迭代过程中,每次迭代到的位置.
open表示该语句以什么开始,separator表示在每次进行迭代之间以什么符号作为分隔 符.
close表示以什么结束.
# item表示集合中每一个元素进行迭代时的别名. # index指 定一个名字,用于表示在迭代过程中,每次迭代到的位置. # collection 为传进来的collection参数的 *类型* # open表示该语句以什么开始 # separator表示在每次进行迭代之间以什么符号作为分隔符 # close表示以什么结束
SQL语句减法运算 直接通过“bai+ ”、“- ”符号运算即可; / / 第一个字段 减 第二个字段 别名SELECT (sub.`purchase_quantity` - sub.`remaining_courses`) a FROM dove_student_subgect sub
jQuery时间范围 近期遇到了一个选择时间范围的东西,直接Copy了别人的代码,进行记录
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 <li > <div class ="form-group" > <label class ="font-noraml" > 时间范围:</label > <select style ="border:none; border-bottom:2px solid #eee;outline:none;width: 100px;" id ="shijianfanwei" > <option value ="0" > 不限</option > <option value ="1" > 今天</option > <option value ="2" > 昨天</option > <option value ="3" > 本周</option > <option value ="4" > 最近7天</option > <option value ="5" > 最近30天</option > <option value ="6" > 本月</option > <option value ="7" > 上月</option > </select > </div > </li > <li class ="select-time" > <input style ="border:none; border-bottom:2px solid #eee;outline:none" type ="text" class ="time-input" id ="startTime" placeholder ="开始时间" name ="params[beginPayTime]" /> <span > 到 </span > <input style ="border:none; border-bottom:2px solid #eee;outline:none" type ="text" class ="time-input" id ="endTime" placeholder ="结束时间" name ="params[endPayTime]" /> </li >
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 $("#shijianfanwei" ).change(function (data ) { var dangqianshijian = shijiangeshizhuanhua(new Date ()); if ($(this ).val() == 0 ) { $("#startTime" ).val("1970-01-01" ) $("#endTime" ).val(dangqianshijian) } if ($(this ).val() == 1 ) { $("#startTime" ).val(dangqianshijian) $("#endTime" ).val(dangqianshijian) } if ($(this ).val() == 2 ) { $("#startTime" ).val(shijiangeshizhuanhua(new Date (new Date ().getTime() - 24 * 60 * 60 * 1000 ))) $("#endTime" ).val($("#startTime" ).val()) } if ($(this ).val() == 3 ) { var Nowdate = new Date (); var WeekFirstDay = new Date (Nowdate - (Nowdate.getDay() - 1 ) * 86400000 ); M = Number (WeekFirstDay.getMonth()) + 1 $("#startTime" ).val(WeekFirstDay.getFullYear() + "-" + M + "-" + WeekFirstDay.getDate()) var Nowdate = new Date (); var WeekFirstDay = new Date (Nowdate - (Nowdate.getDay() - 1 ) * 86400000 ); var WeekLastDay = new Date ((WeekFirstDay / 1000 + 6 * 86400 ) * 1000 ); N = Number (WeekLastDay.getMonth()) + 1 $("#endTime" ).val(WeekLastDay.getFullYear() + "-" + N + "-" + WeekLastDay.getDate()) } if ($(this ).val() == 4 ) { $("#startTime" ).val(shijiangeshizhuanhua(new Date (new Date ().getTime() - 7 * 24 * 60 * 60 * 1000 ))) $("#endTime" ).val(dangqianshijian) } if ($(this ).val() == 5 ) { $("#startTime" ).val(shijiangeshizhuanhua(new Date (new Date ().getTime() - 30 * 24 * 60 * 60 * 1000 ))) $("#endTime" ).val(dangqianshijian) } if ($(this ).val() == 6 ) { $("#startTime" ).val(dangqianshijian.slice(0 , dangqianshijian.length - 2 ) + "01" ) $("#endTime" ).val(dangqianshijian) } if ($(this ).val() == 7 ) { var currentDate = new Date (); var month = currentDate.getMonth() + (-1 ); if (month < 0 ) { var n = parseInt ((-month) / 12 ); month += n * 12 ; currentDate.setFullYear(currentDate.getFullYear() - n); } currentDate = new Date (currentDate.setMonth(month)); var currentMonth = currentDate.getMonth(); var currentYear = currentDate.getFullYear(); var currentMonthFirstDay = new Date (currentYear, currentMonth, 1 ); var currentMonthLastDay = new Date (currentYear, currentMonth + 1 , 0 ); $("#startTime" ).val(shijiangeshizhuanhua(currentMonthFirstDay)) $("#endTime" ).val(shijiangeshizhuanhua(currentMonthLastDay)) } }
若依自带的下拉框多选使用 首先引入相应的css
和js
//css <th:block th:include ="include :: select2-css" /> <th:block th:include ="include :: bootstrap-select-css" /> //js <th:block th:include ="include :: select2-js" /> <th:block th:include ="include :: bootstrap-select-js" />
对应的HTML代码
<li > <label > 校区:</label > <select class ="noselect2 selectpicker" name ="deptName" data-none-selected-text ="选择校区" multiple > <option v-for ="(bm,i) in xiaoqvlist" :value ="bm.deptName" > {{bm.deptName}}</option > </select > </li >
加入multiple
为多选,不加为单选
将double型转化为string型 简单记录代码,方便以后查看
String num2 = subgects.get(i).getDiscountamount(); Double b1 = Double.parseDouble(num2); DecimalFormat format = new DecimalFormat("0.00" ); String str= format.format(b1); subgects.get(i).setDiscountamount(str);
重置下拉框操作 点击重置按钮某些下拉框不会进行重置
js 方法 一个简单的例子
function reset1 ( ) { $("select[name='deptName']" ).selectpicker('val' , ['noneSelectedText' ]) $("select[name='deptName']" ).selectpicker('refresh' ); }
html
onclick="$.form.reset(),reset1()"
关于用String类型存储数字 使用String类型存储数字,好像默认会有三位小数点,即 1.000.类似这种
保留两位小数
for (int i = 0 ; i < stusummarize.size(); i++) { String nums = stusummarize.get(i).getDiscountamount(); Double b = Double.parseDouble(nums); DecimalFormat df = new DecimalFormat("0.00" ); String shi = df.format(b); stusummarize.get(i).setDiscountamount(shi); }
若依导出表的使用 👉👉👉 官方文档
在实体类的变量上加入注解
@Excel(name = "用户序号", prompt = "用户编号") private Long userId;@Excel(name = "用户名称") private String userName; @Excel(name = "用户性别", readConverterExp = "0=男,1=女,2=未知") private String sex;@Excel(name = "最后登陆时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss") private Date loginDate;
添加导出按钮事件
<a class ="btn btn-warning" onclick ="$.table.exportExcel()" > <i class ="fa fa-download" > </i > 导出</a >
控制器方法
@PostMapping("/export") @ResponseBody public AjaxResult export (User user) { List<User> list = userService.selectUserList(user); ExcelUtil<User> util = new ExcelUtil<User>(User.class); return util.exportExcel(list, "用户数据" ); }
前端调用封装好的方法$.table.init,传入后台exportUrl
var options = { exportUrl: prefix + "/export", //地址 columns: [{ field: 'id', title: '主键' }, { field: 'name', title: '名称' }] }; $.table.init(options);
加入导出的时候显示的名称
若依添加合计 近期遇到了这样一个需求,刚好有人(hzx)写出来了,Copy了一份,以便以后查看
首先 添加一个
在表格的第一列 添加如下代码
showFooter: true ,footerFormatter :function (value ) { return "合 计" ; }
在你想要进行合计的列下方加入以下代码
footerFormatter:function (value ) { var sumBalance = 0 ; for (var i in value) { sumBalance += parseFloat (value[i].这里填入对应的列名); } return sumBalance; }
不定时更新补充—–