jobdiaryMyReceiveTimeLine.js 3.5 KB
Newer Older
doc_wei's avatar
doc_wei 已提交
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

layui.config({
	base: basePath, 
	version: skyeyeVersion
}).extend({
    window: 'js/winui.window'
}).define(['window', 'jquery', 'winui', 'form', 'flow', 'laydate'], function (exports) {
	
	winui.renderColor();
	
	var $ = layui.$,
		laydate = layui.laydate,
		flow = layui.flow;
	
	// 选取时间段表格
    laydate.render({
        elem: '#createTime',
        range: '~'
    });
	
	// 时间线日志列表模板
	var timeTreeJobDiary = $("#timeTreeJobDiary").html();
	
	inboxTimeTreeJobDiary();
	// 加载时间线日志
	function inboxTimeTreeJobDiary(){
		flow.load({
			elem: '#timeTreeJobDiaryList', //指定列表容器
			scrollElem: '#timeTreeJobDiaryList',
			isAuto: true,
			done: function(page, next) { //到达临界点(默认滚动触发),触发下一页
				var lis = [];
				var params = {
                    page: page,
                    limit: 12,
                    createName: $("#createName").val(),
                };
                if(isNull($("#createTime").val())){//一定要记得,当createTime为空时
                    params.firstTime = "";
                    params.lastTime = "";
                }else {
                    params.firstTime = $("#createTime").val().split('~')[0].trim();
                    params.lastTime = $("#createTime").val().split('~')[1].trim();
                }
				//以jQuery的Ajax请求为例,请求下一页数据(注意:page是从2开始返回)
doc_wei's avatar
doc_wei 已提交
46
				AjaxPostUtil.request({url: sysMainMation.jobdiaayBasePath + "diary023", params: params, type: 'json', callback: function (json) {
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
					var jsonStr = "";//实体json对象
					$.each(json.rows, function(index, bean) {
						if(index == 0 && page == 1){
							bean.showClass = 'first';
						} else {
							bean.showClass = 'date02';
						}
						$.each(bean.dayChild, function(i, item){
							var content = "已完成工作:" + item.completedJob + "<br>";
							if(!isNull(item.incompleteJob)){//未完成工作
								content += "未完成工作:" + item.incompleteJob + "<br>";
							}
							if(!isNull(item.workSummary)){//工作总结
								if(item.jobType === '2'){//周报
									content += "本周工作总结:" + item.workSummary + "<br>";
								}else if(item.jobType === '3'){//月报
									content += "本月工作总结:" + item.workSummary + "<br>";
								}
							}
							if(!isNull(item.nextPlan)){//工作计划
								if(item.jobType === '2'){//周报
									content += "下周工作计划:" + item.nextPlan + "<br>";
								}else if(item.jobType === '3'){//月报
									content += "下月工作计划:" + item.nextPlan + "<br>";
								}
							}
							if(!isNull(item.coordinaJob)){//需协调工作
								content += "需协调工作:" + item.coordinaJob + "<br>";
							}
							if(!isNull(item.jobRemark)){//备注
								content += "备注:" + item.jobRemark + "<br>";
							}
							item.content = content;
doc_wei's avatar
doc_wei 已提交
80
						});
81 82 83 84 85 86 87 88 89
						jsonStr = {
							bean: bean
						};
						lis.push(getDataUseHandlebars(timeTreeJobDiary, jsonStr));
					});
					matchingLanguage();
					//执行下一页渲染,第二参数为:满足“加载更多”的条件,即后面仍有分页
					//pages为Ajax返回的总页数,只有当前页小于总页数的情况下,才会继续出现加载更多
					next(lis.join(''), (page * 12) < json.total);
doc_wei's avatar
doc_wei 已提交
90 91 92 93 94 95
		   		}});
			}
		});
	}
	
	// 搜索
doc_wei's avatar
doc_wei 已提交
96
    $("body").on("click", "#formSearch", function() {
doc_wei's avatar
doc_wei 已提交
97 98 99 100 101 102
        $("#timeTreeJobDiaryList").html("");
        inboxTimeTreeJobDiary();
    });
	
    exports('jobdiaryMyReceiveTimeLine', {});
});