记不住系列

// 追加表单字段
var param = $("#searchForm").serialize();
param = $.param({'aaa':''}) + '&' + param;

// 只能正数字输入
<input type="number" onkeyup="this.value=this.value.replace(/\D/g,'')" class="form-control required" />
// js验证字段只能为数字
var regPos = /^\d+(\.\d+)?$/;
if(!regPos.test(content)){
    swal("编号只能为数字!");
    return false;
}

// 开始不能大于结束时间
function changeDate(){
  var start = $("#start").val();;
  var end = $("#end").val();
  if(start !='' && end != ''){
    if(!tab(start,end)){
      swal('开始时间必须小于结束时间');
      return false;
    }
    return true;
  }
}
function tab(date1,date2){
  var start = '2010-01-01 ' + date1;
  var end = '2010-01-01 ' + date2;
  var oDate1 = new Date(start);
  var oDate2 = new Date(end);
  if(oDate1.getTime() < oDate2.getTime()){
    return true;
  } else {
    return false;
  }
}

// checkbox默认选中已有数据
<input type="checkbox" value="1" name="week" id="checkbox1" <c:if test="${fn:contains(entity.week,'1')==true}">checked</c:if>/>周一
<input type="checkbox" value="2" name="week" id="checkbox2" <c:if test="${fn:contains(entity.week,'2')==true}">checked</c:if>/>周二
<input type="checkbox" value="3" name="week" id="checkbox3" <c:if test="${fn:contains(entity.week,'3')==true}">checked</c:if>/>周三

// radio默认选中后台传入数据
<input type="radio" name="status" <c:if test="${entity.status==false}" >checked</c:if> value="0" class="required"/>无
<input type="radio" name="status" <c:if test="${entity.status==true}" >checked</c:if> value="1" class="required"/>有

// 进入页面默认radio不可编辑
$(document).ready(function () {
  $("input[name='status']").each(function(){
    if($(this).attr("checked") != 'checked'){
      $(this).attr("disabled", "disabled");
    }
  });
})

// 获取redio值

function GetRadioValue(RadioName){
  var obj;
  obj=document.getElementsByName(RadioName);
  if(obj!=null){
    var i;
    for(i=0;i<obj.length;i++){
      if(obj[i].checked){
        return obj[i].value;
      }
    }
  }
  return null;
}

// 头标题醒目bootstrap

<div class="panel panel-primary">
<div class="panel-heading">

mybatis
// kwyword模糊查多段
id LIKE CONCAT(CONCAT('%', #{keyword}), '%') or name LIKE CONCAT(CONCAT('%', #{keyword}), '%')
// 根据开始结束时间查询
<if test="beginTime != null ">
  and beginTime &gt; DATE_FORMAT(#{beginTime},'%Y-%m-%d 00:00:00')
</if>
<if test="endTime != null ">
  and endTime &lt; DATE_FORMAT(#{endTime},'%Y-%m-%d 23:59:59')
</if>

<setting name="logImpl" value="STDOUT_LOGGING" />

 // 加载中 bootstrap

<!-- loading -->
<div class="modal fade" id="loading" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" data-backdrop='static'>
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                 <h4 class="modal-title" id="myModalLabel">更新提示</h4>
            </div>
            <div class="modal-body">
                 数据疯狂更新中,请稍候。。。<span id="result"></span>
            </div>
        </div>
    </div>
</div>
<!-- js  -->

$('#loading').modal('show');

$('#loading').modal('hide');

 // select 选择回显到另一个input

$('select[name=modelId]').change(function(){
  var label = this.options[this.options.selectedIndex]; // 回显label
  $('input[name=goodsName]').val(label.label);
});

// URL拼接参数 var obj = {}

function encodeSearchParams(obj) {
  const params = []
  Object.keys(obj).forEach((key) => {
    let value = obj[key]
    if (typeof value === '') {
      value = ''
    }
    params.push([key, encodeURIComponent(value)].join('='))
  })
  return params.join('&')

}

// 当月头一天和最后一天

function getCurrentMonthFirst(){
    var date = new Date();
    date.setDate(1);
    var month = parseInt(date.getMonth()+1);
    var day = date.getDate();
    if (month < 10) {
        month = '0' + month
    }
    if (day < 10) {
        day = '0' + day
    }
    return date.getFullYear() + '-' + month + '-' + day;
}
function getCurrentMonthLast(){
    var date=new Date();
    var currentMonth=date.getMonth();
    var nextMonth=++currentMonth;
    var nextMonthFirstDay=new Date(date.getFullYear(),nextMonth,1);
    var oneDay=1000*60*60*24;
    var lastTime = new Date(nextMonthFirstDay-oneDay);
    var month = parseInt(lastTime.getMonth()+1);
    var day = lastTime.getDate();
    if (month < 10) {
        month = '0' + month
    }
    if (day < 10) {
        day = '0' + day
    }
    return date.getFullYear() + '-' + month + '-' + day;
}

posted @ 2021-01-04 09:30  吴某1  阅读(171)  评论(0编辑  收藏  举报