- 注册时间
- 2016-5-30
- 最后登录
- 1970-1-1
- 阅读权限
- 10
- 积分
- 24
- 精华
- 0
- 帖子
- 8
|
fox546868215 发表于 2016-6-7 17:32
查询日期:
miui.parse();
var grid = miui.get("datagrid1");
var results;
var start;
var end;
var meetId;
search();
//查询
function search() {
var form = new miui.Form("#form1");
//获取表单数据
var json = form.getData(false,false);
grid.load(json);//grid查询
$.ajax({
url:"com.oa.getMeetUseApplyDatas",
type:'POST',
cache: false,
async: false,
contentType:'text/json',
success:function(text){
var returnJson = miui.decode(text);
results = returnJson.results;
}
});
}
//enter键触发查询
function onKeyEnter(e) {
search();
}
//渲染单元格内容
grid.on("drawcell",function(e) {
var field = e.field;
var column = e.column;
var record = e.record;
var value = e.value;
if(field == "carno"){
e.cellStyle = "text-align:center";
e.cellHtml = '<a href="javascript:godone(\''+ record.carid + '\')"><font color=blue>'+record.carno+'</font></a>';
}else{//未预定状态
e.cellHtml = '<span onclick="onhref(\''+field+'\')" style="border:1px solid #0f0;width:100%;height:20px;display:block;background:#0f0;text-align:center;"></span>';
}
var typeId= record.cartype;
var json = miui.encode({carTypeId:typeId});
if (field == "cartype") {
$.ajax({
url:"com.expandCarTypeById",
type:'POST',
data:json,
cache: false,
async: false,
contentType:'text/json',
success:function(text){
var returnJson = miui.decode(text).typeName;
if(returnJson.exception == null){
e.cellStyle = "text-align:left";
e.cellHtml = returnJson;
}
}
});
}
if(compareTime(new Date(),field)){//已超时状态
e.cellHtml = '<span style="border:1px solid #ddd;width:60px;height:20px;display:block;background:#ddd;text-align:center;"></span>';
}
for(var i=0;i<results.length;i++){
start = results.STARTDATE + " " + results.STARTTIME;
end = results.ENDDATE + " " + results.ENDTIME;
carId = results.CAR_ID;
if(record.carid==carId && !compareTime(start,field) && compareTime(end,field)){
if(results.IS_FILED==1){//未归档 已锁定状态
e.cellHtml = '<span style="border:1px solid #ff0;width:60px;height:20px;display:block;background:#ff0;text-align:center;"></span>';
}
if(results.IS_FILED==0){//已归档 已预定状态
e.cellHtml = '<span style="border:1px solid #f00;width:60px;height:20px;display:block;background:#f00;text-align:center;"></span>';
}
}
}
});
function compareTime(date,val){
if(val!=="carno"&&val!=="cartype"){
var searchDate = miui.get("searchDate").getValue();
var strBuff = searchDate.substring(0,10) + " " + val + ":00";
return Date.parse(strBuff)<Date.parse(date);
}
}
function onhref(val){
miui.open({
url: "<%=request.getContextPath() %>/InsertCarApply.jsp",
title: "申请", width: 800, height: 500,
onload: function () {//弹出页面加载完成
var iframe = this.getIFrameEl();
var data = {pageType:"add"};//传入页面的json数据
iframe.contentWindow.setFormData(data);
},
ondestroy: function (action) {//弹出页面关闭前
grid.reload();
}
});
}
//获取当前日期时间
function getDate(){
var myDate = new Date();
var year = myDate.getFullYear();
var month = (myDate.getMonth()+1)<10?"0"+(myDate.getMonth()+1)myDate.getMonth()+1);
var date = myDate.getDate()<10?"0"+myDate.getDate():myDate.getDate();
var hour = myDate.getHours()<10?"0"+myDate.getHours():myDate.getHours();
var minute = myDate.getMinutes()<10?"0"+myDate.getMinutes():myDate.getMinutes();
var second = myDate.getSeconds()<10?"0"+myDate.getSeconds():myDate.getSeconds();
return year + "-" + month + "-" + date + " " + hour + ":" + minute + ":" + second;
}
function godone(e){
if (e) {
miui.open({
url: "<%=request.getContextPath() %>/carManagement/carinfo/BsCarInfoDetail.jsp",
title: "查看详情",
width: 850,
height: 350,
onload: function () {
var iframe = this.getIFrameEl();
//直接从页面获取,不用去后台获取
iframe.contentWindow.setFormData(e);
},
ondestroy: function (action) {
grid.reload();
}
});
} else {
miui.alert("请选中一条记录","提示");
}
} |
|