js将带T时间格式转换为时间字符串格式
function timeFormat(iTime) {
var iTime = new Date(iTime + "+08:00");//格式化时间,参数:JSON返回的时间(带T格式)
var month = iTime.getMonth() + 1 < 10 ? "0" + (iTime.getMonth() + 1) : iTime.getMonth() + 1;
var day = iTime.getDate() < 10 ? "0" + iTime.getDate() : iTime.getDate();
var milliseconds = iTime.getMilliseconds();
return iTime.getFullYear() + "-" + month + "-" + day;
}
使用js动态绑定数据到页面
function htmlStr(data, rowInt) {
var html = '<tr>'
+ '<td style="text-align: center;" id="rowIntId#{rowInt}"> #{rowInt}</td>'
+ '<td style="text-align: center;"> #{ACCEPTANCENumber}</td>'
+ '<td style="text-align: center;"> #{USERNAME}</td>'
+ '<td style="text-align: center;"> #{HandlerTime}</td>'
+ '<td style="text-align: center;"> #{PromiseTime}</td>'
+ '<td style="text-align: center;" id="DepartmentName#{rowInt}"> #{Organizer}</td>'
+ '<td style="text-align: center;"> #{HandlerState}</td>';
if (data.HandlerState == 0 && data.STATE == 1) {
html += '<td style="text-align: center;"><input type="button" class="btn green" value="签收" onclick="GoDepartmentPhone(this,#{rowInt},#{complaintId})" />| <input type="button" class="btn green" value="拒签" onclick="LinkAnswer(#{complaintId},2)" /> </td>'
}else {
html += '<td style="text-align: center;"><input type="button" class="btn green" disabled="disabled" value="签收" />| <input type="button" class="btn green" value="查看" onclick="LinkAnswer(#{complaintId},1)" /> </td>'
}
html += '</tr>';
html = html.replace(/#{rowInt}/g, rowInt);
html = html.replace(/#{complaintId}/g, data.ID);
html = html.replace(/#{OrganizerId}/g, data.OrganizerId);
html = html.replace(/#{ACCEPTANCENumber}/g, data.ACCEPTANCENumber == null ? "" : data.ACCEPTANCENumber);
html = html.replace(/#{USERNAME}/g, data.USERNAME == null ? "" : data.USERNAME);
html = html.replace(/#{HandlerTime}/g, timeFormat(data.HandlerTime == "0001-01-01T00:00:00" ? "" : data.HandlerTime));
html = html.replace(/#{PromiseTime}/g, timeFormat(data.PromiseTime == "0001-01-01T00:00:00" ? "" : data.PromiseTime));
html = html.replace(/#{Organizer}/g, data.Organizer == null || data.Organizer == "" ? "请选择" : data.Organizer);
html = html.replace(/#{HandlerState}/g, data.HandlerState == 0 ? "未处理" : (data.HandlerState == 1 ? "非受理范围" : (data.HandlerState == 2 ? "办理中" : (data.HandlerState == 3 ? "已办结" : (data.HandlerState == 4 ? "已超时" : "异常状态")))));
//$("#tblList").append(html);
return html;
}
js插件jqprint进行打印
<script src="~/Content/JQueryPrint/jquery-migrate-1.1.0.js"></script>
<script src="~/Content/JQueryPrint/jquery.jqprint-0.3.js"></script>
//打印
function DoPrint() {
$("#divPrint").jqprint({
debug: false, //如果是true则可以显示iframe查看效果(iframe默认高和宽都很小,可以再源码中调大),默认是false
importCSS: true, //true表示引进原来的页面的css,默认是true。(如果是true,先会找$("link[media=print]"),若没有会去找$("link")中的css文件)
printContainer: true, //表示如果原来选择的对象必须被纳入打印(注意:设置为false可能会打破你的CSS规则)。
operaSupport: true//表示如果插件也必须支持歌opera浏览器,在这种情况下,它提供了建立一个临时的打印选项卡。默认是true
});
}