patrol_data_unit_edit.jsp
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <%@ page language="java" isELIgnored="false" import="java.util.*" pageEncoding="utf-8"%> <%@ page import="com.sinosoft.common.Constant"%> <%@ include file="/jsp/common/meta.jsp"%> <%@ include file="/jsp/common/taglibs.jsp"%> <% String path = request.getContextPath(); String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; %> <html> <head> <c:if test="${param.type eq '1'}"><title>新增页面</title></c:if> <c:if test="${param.type eq '2'}"><title>编辑页面</title></c:if> <script type="text/javascript"> //表单校验 $(function(){ if("${param.type}" == 2){ $("#lineInfoId").attr("disabled","true"); $("#alias").attr("disabled","true"); } $('#frm').validateForm({ rules:{ 'patrolDataUnit.lineName':{required:true}, 'patrolDataUnit.alias':{required:true}, 'patrolDataUnit.title':{required:true}, }, messages:{ 'patrolDataUnit.lineName':{required:'线路不能为空'}, 'patrolDataUnit.alias':{required:'单位工程不能为空'}, 'patrolDataUnit.title':{required:'标题不能为空'}, } }); init(); }) /* function toQuery(){ var id = $("#id").val(); $.post("/patrol/patrolDataContent!pdcList.action",{"patrolDataContent.patrolUnitId":id},toCallback); $("tr[name='row']").remove();//将所有name=row的tr去除 } function toCallback(data){ var array = eval("("+data+")"); var list = array.list; $(".table-content").remove(); if(list != null){ for(var i = 0; i < list.length; i++){ var record = "<tr class='table-row table-content'>"; record += "<td class='table-cell'>"+getItemName(list[i].contentType)+"</td>";//巡查内容分类 record += "<td title='"+list[i].contentName+"' class='table-cell'>"+list[i].contentName+"</td>"; record += "<td title='"+list[i].patrolResult+"' class='table-cell'>"+list[i].patrolResult+"</td>"; record += "<td title='"+list[i].describe+"' class='table-cell'>"+list[i].describe+"</td>"; record += "<td class='table-cell'><a>查看图片</a></td>";//巡查时间 record += "<td class='table-cell op'><input type='radio' id='rid"+i+"' name='id' value='"+list[i].id+"'/></td>"; record += "</tr>"; $("#orderTable").append(record); } $(".table-content .table-cell:not('.op')").click(function(){ toView($(this).parent().find(":radio").val()); }); } } */ //新增 function toAdd(){ var patrolUnitId = $("#id").val(); var returnValue = art.dialog.open("/patrol/patrolDataContent!create.action?patrolDataContent.patrolUnitId="+patrolUnitId,{ id: "id", title: "新增", width: "800px", height: "400px", lock: true, fixed: true, drag: false, okVal: "保 存", ok: function(){ var iframe = this.iframe.contentWindow; iframe.toSave(); return false; }, cancelVal: "关 闭", cancel: function(){ } }); } /* 保存 */ function toSave(){ if($("#frm").valid()){//若表单校验通过 jquerySubmit("frm","/patrol/patrolDataUnit!save.action",function(data){ tips(data.msg); $("#id").val(data.id); $("#zstatus").val(data.zstatus); window.opener.toQuery(); window.location.href="/patrol/patrolDataUnit!edit.action?type=2&patrolDataUnit.id="+$("#id").val(); }); } } function toEdit(){ var id = $("input[type='radio'][name='id']:checked"); var ids = ""; $.each(id,function(index,o){ ids = ids + $(o).val()+","; }); ids = ids.substring(0,ids.length-1); var returnValue = art.dialog.open("/patrol/patrolDataContent!edit.action?patrolDataContent.id="+ids,{ id: "id", title: "新增", width: "800px", height: "400px", lock: true, fixed: true, drag: false, okVal: "保 存", ok: function(){ var iframe = this.iframe.contentWindow; iframe.toUpdate(); return false; }, cancelVal: "关 闭", cancel: function(){ } }); } function toUpdate(){ jquerySubmit("frm","/patrol/patrolDataUnit!update.action",function(data){ tips(data.msg); window.opener.toQuery(); }); setTimeout("window.location.reload();",1000); } function toDelete(){ var arr = $("input[type='radio'][name='id']:checked"); var ids = ""; $.each(arr,function(index,o){ ids = ids + $(o).val()+","; }); ids = ids.substring(0,ids.length-1); if(ids.indexOf("$") > -1){ alert("该记录属于巡查模板,不能删除!"); }else{ confirm("确定要删除该条记录吗?",function(){ $.post("/patrol/patrolDataContent!deleteContent.action",{"ids":ids},function(data){ tips(eval("("+data+")").msg); }); }) } } /* 选择单位工程信息 */ function selectBUPI(){ if($('#lineInfoId').val() == ''){ alert("请先选择线路!"); return false; } selectBasicUnitProjectInfo($('#lineInfoId').val(),"0","",function(data){ $("#projectInfoId").val(data[0].projectId); $("#alias").val(data[0].projectName); if("${param.unitType}" != 2){ query(data[0].projectId); } }); } //逐行添加时选择隐患项 function getItemcName(i){ var returnValue = art.dialog.open("/jsp/module/civilizationconstruction/checkreform/cc_standard_item_tree.jsp",{ id: "id", title: "检查项目选择", width: "500px", height: "300px", lock: true, fixed: true, drag: false, okVal: "确 定", ok: function(){ var iframe = this.iframe.contentWindow; var reval = iframe.document.getElementById("returnValue").value; if(reval == ""){ iframe.alert("请选择检查项目,不要选择检查类型!"); return false; }else{ var arr = reval.split(","); document.getElementById('inspectItemId'+i).value = arr[0]; document.getElementById("itemcName"+i+"").value = arr[1]; art.dialog.close(); } }, cancelVal: "取 消", cancel: function(){ art.dialog.close(); } }); } //上传图片 function uploadAffixes(i,t){ var rid = $("#id").val(); openUpload('RISK','PATROL_PIC',rid,'PATROL_DATA_UNIT','2',function (data){ if(data!=undefined){ var affixIds = ""; for(var j=0;j<data.length;j++){ affixIds += data[j].id+","; } affixIds = affixIds.substring(0,affixIds.length-1); if($("#affixIds"+t+i).val() != null && $("#affixIds"+t+i).val() != ""){ affixIds += ","+$("#affixIds"+t+i).val(); $("#affixIds"+t+i).val(affixIds);//总的附件id们 if(affixIds.length>0)$("#vp"+t+i).show(); }else{ $("#affixIds"+t+i).val(affixIds);//总的附件id们 if(affixIds.length>0)$("#vp"+t+i).show(); } } }); } function look(index,t){ var affixIds = $("#affixIds"+t+index).val(); var patrolContentId = $("#patrolContentId"+t+index).val(); var contentId = $("#pk"+t+index).val(); openwindow("/patrol/patrolDataUnit!viewPicture.action?ids="+affixIds+"&patrolContentId="+patrolContentId+"&contentId="+contentId+"&view=edit","图片",1000,600); } /* 上传附件 */ function uploadAffix(){ var id = $("#id").val(); openUpload('RISK','PDU',id,'PATROL_DATA_UNIT','1',function (data){ if(data!=undefined){ for(var i=0;i<data.length;i++){ $("#affixName").append("<li> <a title='点击进行下载' href='###' onclick='downloadFile(\""+data[i].id+"\",\""+data[i].modlename+"\")'>"+data[i].fileTitle+"</a> <a href='###' onclick='removeAffix(this,\""+data[i].id+"\")'>[删除]</a></li>"); $("#affixBtn").clearTip(); } } }); } /* 下载附件 */ function downloadAffix(affixId){ downloadFile(affixId,'CIVILIZATION'); } /* 删除附件 */ function removeAffix(obj,affixId){ delFile(affixId,"CIVILIZATION",function(data){ $(obj).parent().remove(); _tip("附件删除成功!"); }); } ///模板带出1 function query(projectInfoId){ $.post("/patrol/patrolContentInfo!getListByEm.action",{"projectInfoId":projectInfoId},function(data){ $(".table-content").remove(); var arr = eval("("+data+")"); var list = arr.list; if(list != null){ for(var i = 0;i < list.length;i++){ var record = "<tr class='table-row table-content' ><input type='hidden' id='pk1"+i+"' name='patrolDataUnit.pdcList["+i+"].id'/>"; record += "<td style='text-align: center;'>"+getItemName(list[i].contentType)+"</td>"; record += "<td style='text-align: center;'>"+list[i].contentName+"<input type='hidden' id='patrolContentId1"+i+"' name='patrolDataUnit.pdcList["+i+"].patrolContentId' value='"+list[i].id+"'/></td>"; record += "<td style='text-align: center;'><select id='patrolResult"+i+"' name='patrolDataUnit.pdcList["+i+"].patrolResult'><option value='1'>正常</option><option value='0'>异常</option></select>"; record += "<td style='text-align: center;'><input type='text' id='describe"+i+"' name='patrolDataUnit.pdcList["+i+"].describe' class='required'/></td>"; record += "<td style='text-align: center;'><input type='button' class='btn btn-default' value='上传图片' onclick='uploadAffixes("+i+",1);'> <input type='button' id='vp1"+i+"' class='btn btn-default' value='查看图片' onclick='look("+i+",1);'><input type='hidden' id='affixIds1"+i+"' name='patrolDataUnit.pdcList["+i+"].affixIds' /></td>"; record += "<td style='text-align: center;'></td>"; record += "</tr>"; $("#orderTable").append(record); var pk = getUuid(); $("#pk1"+i).val(pk+"$"); $("#vp1"+i).hide(); } } }); } //动态添加2 $(function(){ var i = 0; $('#insert').click(function(){ /*行*/ var tr = "<tr height='30' id='row"+i+"' name='row'><input type='hidden' id='pk2"+i+"' name='patrolDataUnit.dynamicList["+i+"].id'/>"; /*巡查分类*/ tr += "<td><select id='ct"+i+"' name='patrolDataUnit.dynamicList["+i+"].contentType' class='required' onchange='changePC("+i+");'></select></td>"; /*巡查内容*/ tr += "<td><select id='patrolContentId2"+i+"' name='patrolDataUnit.dynamicList["+i+"].patrolContentId' class='required' /></select></td>"; /*巡查结果*/ tr += "<td><select id='patrolResult"+i+"' name='patrolDataUnit.dynamicList["+i+"].patrolResult'><option value='1'>正常</option><option value='0'>异常</option></select></td>"; /*情况说明*/ tr += "<td><input type='text' id='describe"+i+"' name='patrolDataUnit.dynamicList["+i+"].describe' class='required'/></td>"; /*图片*/ tr += "<td style='text-align: center;'><input type='button' class='btn btn-default' value='上传图片' onclick='uploadAffixes("+i+",2);'> <input type='button' id='vp2"+i+"' class='btn btn-default' value='查看图片' onclick='look("+i+",2);'><input type='hidden' id='affixIds2"+i+"' name='patrolDataUnit.dynamicList["+i+"].affixIds' /></td>"; /*操作*/ tr += "<td><img id='del"+i+"' src='/jsp/module/patrol/dailypatrol/img/del.jpg' style='height:22px;width:22px;cursor:pointer'/></td>"; tr += "</tr>"; $("#orderTable").append(tr); //取数据字典值 var ctValue = ""; var ct = getDataItemOption("巡查内容分类",ctValue); $("#ct"+i).append(ct); var pk = getUuid(); $("#pk2"+i).val(pk); $("#del"+i).attr("onclick","delContent(\'"+i+"\',\'"+$("#pk2"+i).val()+"\');"); $("#vp2"+i).hide(); i++; }); }); function delContent(index,pk){ $("#row"+index).remove(); var delIds = $("#delIds").val(); delIds += pk+","; $("#delIds").val(delIds); } function delContent2(index,pk){ $("#rowE"+index).remove(); var delIds = $("#delIds").val(); delIds += pk+","; $("#delIds").val(delIds); } //通过巡查内容分类获取巡查内容 function changePC(index){ var contentType = $("#ct"+index).val(); $.post("/patrol/patrolContentInfo!getPCList.action",{"patrolContentInfo.contentType":contentType},function(data){ var arr = eval("("+data+")"); var list = arr.pciList; document.getElementsByName("patrolDataUnit.dynamicList["+index+"].patrolContentId")[0].length = 0;//移除已有选项 for(var i = 0;i<list.length;i++){ var options = "<option value='"+list[i].id+"'>"+list[i].contentName+"</option>"; $("#patrolContentId2"+index).append(options); } }); } //通过巡查内容分类获取巡查内容2 function changePC2(index,patrolContentId){ var contentType = $("#ctE"+index).val(); if(contentType != undefined){ $.post("/patrol/patrolContentInfo!getPCList.action",{"patrolContentInfo.contentType":contentType},function(data){ var arr = eval("("+data+")"); var list = arr.pciList; document.getElementsByName("patrolDataUnit.editList["+index+"].patrolContentId")[0].length = 0;//移除已有选项 for(var i = 0;i<list.length;i++){ var options = "<option value='"+list[i].id+"'>"+list[i].contentName+"</option>"; $("#patrolContentIdE"+index).append(options); checkOption("patrolContentIdE"+index,patrolContentId); } }); } } //默认选中下拉列表 function checkOption(id,value){ var select = document.getElementById(id); var options = select.options; for(var i=0;i<options.length;i++){ if (options[i].value == value){ options[i].selected = true; break; } } } /*预警*/ function preWarn(){ if("${patrolDataUnit.warningInfoId}" != null && "${patrolDataUnit.warningInfoId}".length>0){ var c_e = "edit"; var type = 2; }else{ var c_e = "create"; var type = 1; } openwindow("/warning/warningInfo!"+c_e+".action?warningInfo.monitorPatrolId="+$("#id").val()+"&warningInfo.projectInfoId="+$("#projectInfoId").val()+"&warningInfo.lineId="+$("#lineInfoId").val()+"&warningInfo.warningType=2&warningInfo.id=${patrolDataUnit.warningInfoId}&type="+type,"prewarn",1200,750); } /*取数据字典值*/ function init(){ var weather = getDataItemOption("天气",$("#weatherId").val()); $("#weather").append(weather); } </script> <script type="text/javascript"> function getUuid(){ var len=32;//32长度 var radix=16;//16进制 var chars='0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.split('');var uuid=[],i;radix=radix||chars.length;if(len){for(i=0;i<len;i++)uuid[i]=chars[0|Math.random()*radix];}else{var r;uuid[8]=uuid[13]=uuid[18]=uuid[23]='-';uuid[14]='4';for(i=0;i<36;i++){if(!uuid[i]){r=0|Math.random()*16;uuid[i]=chars[(i==19)?(r&0x3)|0x8:r];}}} return uuid.join(''); } </script> </head> <body> <s:form id="frm" name="frm" method="post" theme="simple"> <s:hidden id="id" name="patrolDataUnit.id"/> <s:hidden name="patrolDataUnit.creUserId"/> <s:hidden name="patrolDataUnit.creTime"/> <s:hidden id="zstatus" name="patrolDataUnit.zstatus"/> <s:hidden name="patrolDataUnit.creDeptId"/> <s:hidden name="patrolDataUnit.creDeptName"/> <s:hidden name="patrolDataUnit.companyType"/> <s:hidden name="patrolDataUnit.companyId"/> <s:hidden name="patrolDataUnit.companyName"/> <s:hidden name="#session.CURRE_DEPT" id="deptId"/> <s:hidden name="#session.officeId" id ="deptPid"/> <s:hidden name="patrolDataUnit.delIds" id ="delIds"/> <div class="table-container"> <div class="table2014"> <div class="table-title-container"> <div class="table-title-icon table-icon-default"></div> <div class="table-title-text">基本信息</div> </div> <div class="hrline"></div> <div class="table-content-container table-fixed"> <table width="100%" border="0" cellpadding="0" cellspacing="0" class="form-table"> <tr> <td class="form-td-L" width="18%"><font color="red">*</font>线路</td> <td class="form-td-T" width="32%"> <s:select name="patrolDataUnit.lineInfoId" list="#request.lineMap" headerKey="" headerValue="--请选择--" id="lineInfoId" /> </td> <td class="form-td-L" width="20%"><font color="red">*</font>工程名称</td> <td class="form-td-T" width="30%"> <s:hidden name="patrolDataUnit.projectInfoId" id="projectInfoId"/> <s:textfield name="patrolDataUnit.alias" onclick="selectBUPI();" readonly="true" id="alias" cssStyle="width:97%" cssClass="picTextField"/> </td> </tr> <tr> <td class="form-td-L" width="20%"><font color="red">*</font>标题</td> <td class="form-td-T" width="80%" colspan="3"> <s:textfield id="creDeptName" name="patrolDataUnit.title" maxlength="50" /></td> </tr> <tr> <td class="form-td-L">天气</td> <td class="form-td-T"> <select class="inputselect" id="weather" name="patrolDataUnit.weather" value="${patrolDataUnit.weather}"></select> <input type="hidden" id="weatherId" value="${patrolDataUnit.weather}" /> </td> <td class="form-td-L">巡查时间</td> <td class="form-td-T"><input type="text" id="checkTime" name="patrolDataUnit.patrolTime" class="Wdate" onFocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',autoPickDate:true, maxDate: '%y-%M-%d'}); " value="<fmt:formatDate value="${patrolDataUnit.patrolTime }" pattern="yyyy-MM-dd HH:mm:ss"/>" style="width:97%"/></td> </tr> <tr> <td class="form-td-L"><font color="red">*</font>巡查人</td> <td class="form-td-T"> <s:textfield name="patrolDataUnit.patrolManName" id="patrolManName" cssClass="user" onclick="userTree('patrolMan', 'patrolManName','companyId','1','deptId','phone');" title="检查人" /> <s:hidden name="patrolDataUnit.patrolMan" id="patrolMan"/></td> <td class="form-td-L" width="20%">巡查单位</td> <td class="form-td-T" width="30%"><s:textfield id="companyName" name="patrolDataUnit.companyName" maxlength="20" cssStyle="width:97%" disabled="true"/></td> </tr> <tr> <td class="form-td-L">附件</td> <td class="form-td-T" colspan="3" align="right"> <input type="button" class="btn btn-default" value="上传附件" onclick="uploadAffix();" name="affixBtn" id="affixBtn"/> <ul class="affix-list" id="affixName"> <s:if test="patrolDataUnit.affixList!=null"> <s:iterator value="patrolDataUnit.affixList" id="list"> <li> <a href="###" title="点击进行下载" onclick="downloadFile('${list.affixId}','RISK');">${list.title}</a> <a href="###" onclick="removeAffix(this,'${list.affixId}');">[删除]</a> </li> </s:iterator> </s:if> </ul> </td> </tr> <tr> <td class="form-td-L">备注</td> <td class="form-td-T" colspan="3" style="height:75px"> <s:textarea id="memo" name="patrolDataUnit.memo"/> </td> </tr> </table> <div class="table-container"> <div class="table2014"> <div class="table-title-container"> <div class="table-title-icon table-icon-default"></div> <div class="table-title-text">巡查内容信息</div> <div class="btn-toolbar" style="float: right;"> <div class="btn-group" id="btn"> <img id="insert" class="btn btn-default" src="/jsp/module/patrol/dailypatrol/img/add.png" style="height: 22px;width: 22px"/> </div> </div> <div class="hrline"></div> </div> </div> <table id="orderTable" class="form-table" style="width:100%"> <tr class="table-row table-header"> <td class="form-td-L" style="width:16%">巡查内容分类</td> <td class="form-td-L" style="width:20%">巡查内容</td> <td class="form-td-L" style="width:16%">巡查结果</td> <td class="form-td-L" style="width:20%" >情况说明</td> <td class="form-td-L" style="width:16%">现场图片</td> <td class="form-td-L" style="width:12%">操作</td> </tr> <c:forEach var="bean" items="${editList}" varStatus="vs"> <tr id="rowE${vs.index}"><input type="hidden" id="pkE${vs.index }" name="patrolDataUnit.editList[${vs.index }].id" value="${bean.id}" /> <!--巡查分类--> <td> <c:if test='${fn:indexOf(bean.id,"$") lt "0"}'> <select id='ctE${vs.index}' name='patrolDataUnit.editList[${vs.index }].contentType' value='${bean.contentType }' onchange="changePC2('${vs.index}');" ></select> </c:if> <c:if test='${fn:indexOf(bean.id,"$") ne "-1"}'> ${bean.contentTypeName} </c:if> </td> <!--巡查内容--> <td> <c:if test='${fn:indexOf(bean.id,"$") lt "0"}'> <select id='patrolContentIdE${vs.index}' name='patrolDataUnit.editList[${vs.index }].patrolContentId' value='${bean.patrolContentId }' /> </c:if> <c:if test='${fn:indexOf(bean.id,"$") ne "-1"}'> ${bean.contentName} </c:if> </td> <!--正常/异常--> <td><select id='patrolResult${vs.index}' name='patrolDataUnit.editList[${vs.index }].patrolResult' ><option value='${bean.patrolResult }' selected='selected'>${bean.normal}</option><c:if test="${bean.patrolResult eq '1'}"><option value='0'>异常</option></c:if><c:if test="${bean.patrolResult eq '0'}"><option value='1' >正常</option></c:if></select></td> <!--情况说明--> <td><input type="text" id="describe${vs.index }" name="patrolDataUnit.editList[${vs.index }].describe" value="${bean.describe }"/></td> <!--现场图片--> <td> <input type='button' class="btn btn-default" value="上传图片" onclick="uploadAffixes(${vs.index },'E');"> <input type="button" id='vpE${vs.index }' class="btn btn-default" value="查看图片" onclick="look(${vs.index },'E');" > <input type="hidden" id="affixIdsE${vs.index }" name="patrolDataUnit.editList[${vs.index }].affixIds" value="${bean.affixIds}"/> </td> <!-- 操作 --> <td> <c:if test='${fn:indexOf(bean.id,"$") lt "0"}'> <img src='/jsp/module/patrol/dailypatrol/img/del.jpg' style='height:22px;width:22px;cursor:pointer' onclick="delContent2('${vs.index }','${bean.id}');"/> </c:if> </td> </tr> <!-- 每循环一次执行一次 --> <script> var ctValue = "${bean.contentType}"; var ct = getDataItemOption("巡查内容分类",ctValue); $("#ctE${vs.index}").append(ct); changePC2("${vs.index}","${bean.patrolContentId }"); if(!"${bean.affixIds}".length>0)$("#vpE${vs.index}").hide(); </script> </c:forEach> </table> <table class="btn-table" border="0" cellpadding="0" cellspacing="0" width="100%"> <tr> <td align="center"> <c:if test="${param.type eq '2' && patrolDataUnit.patrolResult ne null}"><input type="button" id="pw" class="btn btn-danger" value="预 警" onclick="preWarn();"></c:if> <c:if test="${param.type eq '1'}"><input type="button" class="btn btn-default" value="保 存" onclick="toSave();"></c:if> <c:if test="${param.type eq '2'}"><input type="button" class="btn btn-default" value="保 存 " onclick="toUpdate();"></c:if> <input type="button" class="btn btn-default" value="关 闭" onclick="window.close();"> </td> </tr> </table> </div> </div> </div> </div> </s:form> </body> </html>