projectLifeCircle.js 16.3 KB
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 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479
//layer.msg(result.message,{icon: 2});失败
//layer.msg("取回成功",{icon: 1});成功
var status = "projectLifeCircle";
var currentPage = 1;// 当前页
var totalpage = 0;// 总页数
var pageNum = 5;// 最多显示页数
var pageSize = 8;//列表显示行数
var stageId = null;

$(function () {
	$(".el-timeline-item__wrapper").click(function () {
		var currentPid = $("#projectId").val();
		//获取点击项目的pid
		var flownameDom = $(this).children(".el-timeline-item__content")[0];
		var pid = $(flownameDom).children(".pid:first").text();
		if (currentPid == pid) {
			layer.msg("当前正处在该项目中,无须跳转!", { icon: 3 });
		} else {
			for (var key in vm.projectListByCasCode) {
				var project = vm.projectListByCasCode[key];
				if (pid == project.PROJECTID) {
					openApproveDetail(project);
					break;
				}
			}
		}
	});
	$(".el-step__title").click(function () {
		//获取阶段的id
		var dom = $(this).next(".el-step__description");
		var stageid = $(dom).children(".stageid:first").text();
		stageId = stageid;
		getApproveList(currentPage, vm.casecode, stageId);
	});
	$(".el-step__icon").click(function () {
		var dom = $(this).parent(".el-step__head").next(".el-step__main").children(".el-step__description");
		var stageid = $(dom).children(".stageid:first").text();
		stageId = stageid;
		getApproveList(currentPage, vm.casecode, stageId);
	});
})

var vm = new Vue({
	el: "#app",
	data: function () {
		return {
			stageArr: [],//阶段集合
			projectListByCasCode: [],//报建编号下的项目集合
			casecode: ""//报建编号
		}
	},
	methods: {
		getProjectByStageId: function (stageid) {
			stageId = stageid;
			getApproveList(currentPage, this.casecode, stageId);
		}
	},
	computed: {
		//标记项目进展阶段并装载需要的数据
		signActiveStage: function () {
			var position = 0;
			var nearestProject = this.projectListByCasCode[this.projectListByCasCode.length - 1];
			for (var i = 0; i < this.stageArr.length; i++) {
				var stage = this.stageArr[i];
				var projectInStage = [];
				for (var j = 0; j < stage.children.length; j++) {
					var stageFlow = stage.children[j];
					for (var k = 0; k < this.projectListByCasCode.length; k++) {
						var project = this.projectListByCasCode[k];
						var pid = $("#projectId").val();
						//项目属于该业务,装入该业务所属的阶段的集合中
						if (stageFlow.flowid == project.FLOWID) {
							project.REGISTERTIME = new Date(project.REGISTERTIME).format("yyyy-MM-dd hh:mm:ss").split("00:00:00")[0];
							projectInStage.push(project);
						}
						//如果项目为当前打开项目,标记
						if (project.PROJECTID == pid) {
							project.type = "primary";
						}
						//标记项目当前进展的最新阶段
						if (stageFlow.flowid == nearestProject.FLOWID) {
							position = i + 1;
						}
					}
				}
				stage.project = projectInStage;
			}
			return position;
		}
	},
	//初始化方法
	created: function () {
		getActiveStageRevision(this);
		if (this.stageArr) {
			getProjectListByPid(this);
			if (this.projectListByCasCode) {
				getApproveList(currentPage, this.casecode, stageId);
			}
		}
	}
});

/**
 * 获取激活的阶段集合版本
 */
function getActiveStageRevision(vm) {
	$.ajax({
		async: false,
		url: CONF_BACK_SERVERURL + "/mvc/stage/getStagesActive.do",
		headers: {
			"token": $.cookie('ftoken')
		},
		success: function (result) {
			if (result.length == 0) {
				layer.msg("没有激活的版本,请联系管理员激活!", { icon: 2 });
				vm.stageArr = [];
				return;
			}
			vm.stageArr = result;
		},
		error: function () {
			layer.msg("请求出错!", { icon: 2 });
			vm.stageArr = [];
		}
	});
}

function getProjectListByPid(vm) {
	var projectId = $("#projectId").val();
	$.ajax({
		type: "POST",
		async: false,
		url: CONF_BACK_SERVERURL + "/mvc/project/list/getByProjectCasecodeForLifeCircle.do",
		headers: {
			"token": $.cookie('ftoken')
		},
		data: { projectId: projectId },
		dataType: 'json',
		success: function (result) {
			if (result.status && result.status == "error") {
				layer.msg(result.message, { icon: 2 });
			} else {
				vm.projectListByCasCode = result.data;
				vm.casecode = result.casecode;
			}
		},
		error: function () {
			layer.msg("请求出错!", { icon: 2 });
			vm.projectListByCasCode = [];
		}
	});
}

// postDataToServe  by  wj
function getApproveList(pageIndex, casCode, stageId) {
	currentPage = pageIndex;
	var para = {
		pageIndex: pageIndex,
		pageSize: pageSize,
		casCode: casCode
	};
	if (stageId) {
		para.stageId = stageId;
	}

	$.ajax({
		type: "POST",
		url: CONF_BACK_SERVERURL + "/mvc/project/list/approveByCasCode.do",
		headers: {
			"token": $.cookie('ftoken')
		},
		data: para,
		dataType: 'json',
		beforeSend: function () {
			$.showLoading();
		},
		complete: function () {
			$.hideLoading();
		},
		success: function (result) {
			// $.ajax({
			// 	type: "POST",
			// 	dataType: 'json',
			// 	contentType: "application/json;charset=utf-8",
			// 	url: CONF_NEWGHSC_SERVERURL + '/xm/getLcList',
			// 	data: JSON.stringify({data: JSON.stringify(result.Data)}),
			// 	// headers:{"token":$.cookie('ftoken')},
			// 	success: function (res) {
			// 		if (res.code == 200 && res.data) {
			// 			for (var i = 0; i < result.Data.length; i++) {
			// 				for (var k = 0; k < result.Data[i].length; k++) {
			// 					for (var j = 0; j < res.length; j++) {
			// 						if (result.Data[i][k].PROJECTID == res[j].id) {
			// 							result.Data[i][k].BINDINGUNIT = res[j].dqhj || ''
			// 							result.Data[i][k].REGISTERTIME = res[j].rwjssj
			// 							result.Data[i][k].PROJECTNAME = res[j].xmmc || ''
			// 							result.Data[i][k].BINDINGASSIGNEE = res[j].jbr || ''
			// 							result.Data[i][k].BUILDUNIT = res[j].bm || ''
			// 						}
			// 					}
			// 				}
			// 			}
			// 			zuiData(result);
			// 		}
			// 	},
			// 	error: function () {
			// 		// FIXME:页面报错:'layer.msg is not a fonction' 暂时注掉
			// 		// layer.msg('请求错误,请联系管理员!');
			// 	}
			// });
			if (result.message) {
				parent.layer.msg(result.message);
				return;
			} else if (result.status == "error") {
				parent.layer.msg("查询失败!请联系管理员!", { icon: 2 });
				return;
			}
			zuiData(result);
		}
	});
	$.ajax({
		type: "POST",
		url: CONF_BACK_SERVERURL + "/mvc/project/list/approveByCasCodeCount.do",
		headers: {
			"token": $.cookie('ftoken')
		},
		data: {
			pageIndex: pageIndex,
			pageSize: pageSize,
			casCode: casCode
		},
		dataType: 'json',
		success: function (result) {
			var totalre = result["total"];
			if (totalre == 0) {
				$('#msg').css("display", "block");
				$('#nvaTab').css("visibility", "hidden");
				$('#promptDiv').css('display', 'none');
			} else {
				$('#msg').css("display", "none");
				$('#nvaTab').css("visibility", 'visible');
				$('#promptDiv').css('display', 'none');
			}
			layuiPage(totalre, casCode);
		}
	});
}

function zuiData(result) {
	var data = [];
	var result_map = result["Data"];
	var listpath = [];
	listObject = [];
	for (var i = 0; i < result_map.length; i++) {
		var map_result = result_map[i];
		//if (list_re.length > 0) {
		//for (var j = 0; j < list_re.length; j++) {
		//var map_result = list_re[j];
		var lamp = "";
		var bjqx = "";
		var cqStr = "";
		var flowid = map_result["FLOWID"];
		var username = map_result["USER_ID_"];
		var assignee = map_result["ASSIGNEE_"];
		var taskkey = map_result["TASK_DEF_KEY_"];
		var attachpath = map_result["ATTACHPATH"];
		var description = map_result["DESCRIPTION"];
		var projectid = map_result["PROJECTID"] == null ? ""
			: map_result["PROJECTID"]
		var instanceid = map_result["INSTANCEID"] == null ? ""
			: map_result["INSTANCEID"]
		var taskid = map_result["TASKID"] == null ? "null"
			: map_result["TASKID"]
		var recevietime = new Date(map_result["CREATETIME"]);
		var projectcode = map_result["PROJECTCODE"] == null ? ""
			: map_result["PROJECTCODE"];
		var casecode = map_result["CASECODE"] == null ? ""
			: map_result["CASECODE"];
		var registertime = map_result["REGISTERTIME"] == null ? ""
			: new Date(map_result["REGISTERTIME"]);
		var buildadddress = map_result["BUILDADDRESS"] == null ? ""
			: map_result["BUILDADDRESS"];
		var projectname = map_result["PROJECTNAME"] == null ? ""
			: map_result["PROJECTNAME"];
		var flowname = map_result["FLOWNAME"] == null ? ""
			: map_result["FLOWNAME"];
		var buildunit = map_result["BUILDUNIT"] == null ? ""
			: map_result["BUILDUNIT"];
		/*ljy--20170929*/
		var bindingassignee = map_result["BINDINGASSIGNEE"] == null ? "-" : map_result["BINDINGASSIGNEE"];
		var bindingunit = map_result["BINDINGUNIT"] == null ? "-" : map_result["BINDINGUNIT"];
		var activityName = map_result["ACTIVITYNAME"] == null ? "结束"
			: map_result["ACTIVITYNAME"];
		var status = map_result["PROJECTSTATUS"] == null ? "-"//hyh 2017/10/24
			: map_result["PROJECTSTATUS"];

		// 根据流程版本获取总时限
		var timelimitDays = map_result["FINISHTIME"] == null ? 0
			: map_result["FINISHTIME"];
		var suptotaltime = map_result["SUPTOTALTIME"] == null ? 0 : map_result["SUPTOTALTIME"];
		var officialdate = getAddDate(new Date(map_result["CREATETIME"]).format("yyyy-MM-dd hh:mm:ss"), timelimitDays, suptotaltime)//hyh 新增,根据办结天数算出办结时间  2017、10、13
		bjqx = lefttime(new Date(), new Date(officialdate));
		var flowItemType = map_result["FLOWITEMTYPE"] ? map_result["FLOWITEMTYPE"] : null;
		if (taskid == "null") {
			if (status == "-") {
				status = "办结";
			}
		}

		if (status == "办结") {
			cqStr += '<div style=" display: inline-block; margin-right: 5px; "><img src="../../image/projecttask/over.png" title="办结" style="width:18px;height:18px;margin-top: 4px"></div>';
		} else if (status == "退件办结") {
			cqStr += '<div style=" display: inline-block; margin-right: 5px; "><img src="../../image/projecttask/over.png" title="退件办结" style="width:18px;height:18px;margin-top: 4px"></div>';
		} else if (status == "回退") {
			cqStr += '<div style=" display: inline-block; margin-right: 5px; "><img src="../../image/projecttask/rollback.png" title="回退" style="width:18px;height:18px;margin-top: 4px"></div>';
		} else if (status == "退件") {
			cqStr += '<div style=" display: inline-block; margin-right: 5px; "><img src="../../image/projecttask/return.png" title="退件" style="width:18px;height:18px;margin-top: 4px"></div>';
		} else if (bjqx == "超时") {
			cqStr += '<div style="display: inline-block; margin-right: 5px;"><img src="../../image/projecttask/redhint.png" title="超时-' + officialdate + '" style="width:16px;height:16px; margin-top: 4px"></div>'  //hyh 修改,谢文洲要求改审批图标    2017/10/23
			if (status == "办结") {
				officialdate = '<span>' + officialdate + '</span>';
			} else {
				officialdate = '<span style="color:red;font-weight:bold;">' + officialdate + '</span>';
			}
		} else if (bjqx == "快超时") {
			cqStr += '<div style=" display: inline-block; margin-right: 5px;"><img src="../../image/projecttask/grayhint.png" title="快超时-' + officialdate + '" style="width:16px;height:16px;margin-top: 4px"></div>'//hyh 修改,谢文洲要求改审批图标    2017/10/23
		} else if (status == "在办") {
			cqStr += '<div style=" display: inline-block; margin-right: 5px; "><img src="../../image/projecttask/process.png" title="在办" style="width:18px;height:18px;margin-top: 4px"></div>';
		}
		var flowrevisionid = map_result["FLOWREVISIONID"] == null ? "" : map_result["FLOWREVISIONID"];
		listObject.push(map_result);
		listpath.push(attachpath);
		var row = {
			"PROJECTID": projectid,
			"INSTANCEID": instanceid,
			"TASKID": taskid,
			"BJQX": cqStr,
			"PROJECTSTATUS": status,
			"ACTIVITYNAME": activityName,
			"FLOWNAME": flowname,
			"PROJECTCODE": projectcode,
			"CASECODE": casecode,
			"PROJECTNAME": projectname,
			"BUILDADDRESS": buildadddress,
			"REGISTERTIME": registertime ? registertime.format("yyyy-MM-dd hh:mm:ss").split("00:00:00")[0] : "",
			"BUILDUNIT": buildunit,
			"BINDINGASSIGNEE": bindingassignee,
			"BINDINGUNIT": bindingunit,
			"RECEIVETIME": recevietime ? recevietime.format("yyyy-MM-dd hh:mm:ss") : "",
			"FINISHTIME": officialdate,
			"FLOWREVISIONID": flowrevisionid,
			"ATTACHPATH": attachpath,
			"TASK_DEF_KEY_": taskkey,
			"AGENT": username == null ? assignee : username,
			"FLOWITEMTYPE": flowItemType
		}
		data.push(row);
		//}
		//}
	}
	setLayuiData(data);
}

//layui分页控件
function layuiPage(total, casCode) {
	layui.use('laypage', function () {
		var laypage = layui.laypage;
		laypage.render({
			elem: 'page'
			, count: total
			, limit: pageSize
			, curr: currentPage
			//,limits: [10, 12, 16, 20]
			, theme: "#337ab7"
			, layout: total <= pageSize ? ['count'] : ['count', 'prev', 'page', 'next', 'skip']
			, jump: function (obj, first) {
				currentPage = obj.curr;
				pageSize = obj.limit;
				//首次不执行
				if (!first) {
					getApproveList(obj.curr, casCode, stageId);
				}
			}
		});
	});
}

function setLayuiData(_data, type) {
	var fullHeight = "full-430";
	layui.use(['table', 'element'], function () {
		var table = layui.table;
		var element = layui.element;
		//展示已知数据
		table.render({
			elem: '#dataList'
			, id: 'tableRenderId'
			, cols: [[ //标题栏
				{ field: 'BJQX', event: "event2", unresize: false, width: "3%" }
				, { field: 'PROJECTSTATUS', title: '状态', width: "5%", event: "eventProjectstatus" }
				, { field: 'FLOWNAME', title: '业务类型', width: "10%", event: "eventflowname" }
				, { field: 'PROJECTCODE', title: '项目编号', width: "10%", event: "eventProjectcode" }
				, { field: 'CASECODE', title: '报建编号', width: "10%", event: "eventProjectcode" }
				, { field: 'PROJECTNAME', title: '项目名称', width: "21%", event: "eventProjectname" }
				, { field: 'BUILDADDRESS', title: '建设位置', width: "8%", event: "eventBuildadddress" }
				, { field: 'BUILDUNIT', title: '建设单位', width: "8%", event: "eventBuildunit" }
				, { field: 'REGISTERTIME', title: '接收时间', width: "10%", event: "eventRegistertime" }
				, { field: 'BINDINGASSIGNEE', title: '经办人', width: "5%", event: "eventInterconnect" }
				, { field: 'BINDINGUNIT', title: '所属部门', width: "10%", event: "eventBindingunit" }
			]]
			, data: _data
			, skin: 'line' //表格风格
			//,even: true
			, limit: pageSize //每页默认显示的数量
			, size: "sm"
			, height: fullHeight
			//,height: 'full-295'
			, done: function (res, curr, count) {
				setCell(res.data);
			}
		});

		//获取选中行
		window.getCheckStatus = function () {
			var checkStatus = table.checkStatus('tableRenderId');
			console.log("输出选中行--------");
			console.log(checkStatus);
			console.log("--------");
			return checkStatus;
		}

		var objtr; //选中行的DOM元素
		//监听单元格事件
		table.on('tool(listEvent)', function (obj) {
			var data = obj.data;
			//除了复选框单元格,点击其他单元格跳详情页
			if (obj.event == 'eventCheckbox') {
				objtr = obj.tr;
			} else {
				if (data.MEETINGPROJECTSTATE != null && data.MEETINGPROJECTSTATE != "" && parent.listName != "项目查询" && parent.listName != "已办项目") {
					parent.layer ? parent.layer.msg("项目正在" + data.MEETINGPROJECTSTATE, { icon: 7 }) : opener.parent.layer.msg("项目正在" + data.MEETINGPROJECTSTATE, { icon: 7 });
					return;
				} else {
					openApproveDetail(data);
				}
			}
		});
	});
}

function setCell(data) {
	$(".layui-table-body tr td").each(function () {
		var text = $(this).first()[0].innerText.trim();
		if (text == "") text = "";
		$(this).attr("title", text);
	})
}

function openApproveDetail(data) {
	data.stats = status;
	jumpdetailPage(data);
}

function jumpdetailPage(data) {
	var taskid = data.TASKID;
	var projectid = data.PROJECTID;
	var flowInstanceId = data.INSTANCEID;
	var titleEncode = encodeURI(encodeURI(data.PROJECTNAME));
	var stats = data.stats ? data.stats : '';
	var PROJECTSTATUS = encodeURI(encodeURI(data.PROJECTSTATUS));
	var projectcode = data.PROJECTCODE;
	var FLOWREVISIONID = data.FLOWREVISIONID;
	var flowItemTypeKvStr = data.FLOWITEMTYPE ? "&flowItemTypeId=" + data.FLOWITEMTYPE : "";
	var url = CONF_FRONT_SERVERURL
		+ 'view/projecttask/detailproject.jsp?projectid=' + projectid + "&referer=''&stats="
		+ stats + "&projectcode=" + projectcode + "&taskId=" + taskid + "&flowInstanceId=" + flowInstanceId + '&titleEncode='
		+ titleEncode + "&projectStatus=" + PROJECTSTATUS + "&flowRevisionId=" + FLOWREVISIONID + flowItemTypeKvStr;

	window.open(handleJumpUrl(url));
}