123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295 |
- <%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
- <%@include file="/pages/includes/taglibs.jsp" %>
- <head>
- <script type="text/javascript" src="<%=request.getContextPath() %>/resource/js/jquery-1.8.3.js"></script>
- <script type="text/ecmascript" src="<%=request.getContextPath() %>/resource/plugin/jqgrid/js/jquery.jqGrid.min.js"></script>
- <script type="text/ecmascript" src="<%=request.getContextPath() %>/resource/plugin/jqgrid/js/i18n/grid.locale-cn.js"></script>
-
- <script type="text/ecmascript" src="<%=request.getContextPath()%>/resource/js/system/jqdatagridpage.js"></script><script src="<%=request.getContextPath()%>/resource/js/datePicker/WdatePicker.js" type="text/javascript"></script>
- <link rel="stylesheet" type="text/css" href="<%=request.getContextPath() %>/resource/plugin/jqueryui/css/custom-theme/jquery-ui-1.9.2.custom.css" />
- <link rel="stylesheet" type="text/css" media="screen" href="<%=request.getContextPath() %>/resource/plugin/jqgrid/css/ui.jqgrid.css" />
- <script type="text/javascript">
- function queryData(){
- // 编码
- var targetCode = $("#targetCode").val();
- // 名称
- var targetName = $("#targetName").val();
-
- $("#targetCodeQ").val(targetCode);
- $("#targetNameQ").val(targetName);
- jQuery("#gridTable").jqGrid('setGridParam',{url:encodeURI(encodeURI("/singleMachineAnalysis/singleMachineAnalysisMainList.action?targetName="+targetName+"&targetCode="+targetCode))}).trigger("reloadGrid");
- }
-
- function queryClear(){
- $("#targetCode").val("");
- $("#targetName").val("");
- $("#targetCodeQ").val("");
- $("#targetNameQ").val("");
- }
-
- function requestAction(url){
-
- // 判断指标体系数据是否已经保存
- var index = url.indexOf('tid=jqg');
- if(index>-1){
- alert('请先保存指标体系数据!');
- return false;
- }
-
- // 编码
- var targetCodeQ = $("#targetCodeQ").val();
- // 名称
- var targetNameQ = $("#targetNameQ").val();
- $("#f1").attr("action",encodeURI(encodeURI(url+ "&targetCodeQS=" + targetCodeQ + "&targetNameQS=" + targetNameQ)) );
- $("#f1").submit();
- }
-
- $(function(){
- // 编码
- var targetCodeQ = $("#targetCodeQ").val();
- // 名称
- var targetNameQ = $("#targetNameQ").val();
- $("#targetCode").val(targetCodeQ);
- $("#targetName").val(targetNameQ);
- showJqGrid();
-
- $("#addBtn").click(function() {
- jQuery("#gridTable").jqGrid('editGridRow', "new", {
- height : 300,
- reloadAfterSubmit : false
- });
- });
- });
-
- // 删除选中行
- function delData(){
- var selectedRowIds = jQuery("#gridTable").jqGrid('getGridParam', 'selarrrow');
- var len = selectedRowIds.length;
- if(len!=0){
- confirm_ = confirm('确认删除选中的记录吗?');
- if(confirm_){
- $.ajax({
- type:"POST",
- url:encodeURI(encodeURI("/singleMachineAnalysis/delTargetSystem.action?ids="+selectedRowIds)),
- success:function(data){
- var d = eval("("+data+")");
- if(d.action=='success'){
- for(var i=selectedRowIds.length-1;i>=0;i--) {
- $("#gridTable").jqGrid("delRowData", selectedRowIds[i]);
- }
- alert("记录删除成功!");
- }else if(d.action=='fail'){
- alert("所选记录存在定性或定量指标数据,不能直接删除!");
- }else{
- alert("删除失败!");
- }
- }
- });
- }
- }else{
- alert("请选择要删除的记录!");
- }
- return false;
- }
-
- // 判断输入内容是否合法,不能包括逗号(,)和斜杠(/). 结果true校验通过
- function judgeFormat(objStr){
- var result = false;
- var countone = objStr.indexOf('●');
- var counttwo = objStr.indexOf('★');
- if(countone==-1 && counttwo==-1){
- result = true;
- }
- return result;
- }
-
- function saveAddData(){
- var selectedRowIds = jQuery("#gridTable").jqGrid('getGridParam', 'selarrrow');
- var len = selectedRowIds.length;
- if(len!=0){
- confirm_ = confirm('确认要保存选中的记录吗?');
- if(confirm_){
- var judge = false;//输入得编码和名称中不能包含逗号和斜杠, true校验通过
- var codejudge = false;//编码校验,必须以字母开头,后跟字母、数字或下划线构成。true通过
- var params = '';
- for(var i=selectedRowIds.length-1;i>=0;i--) {
- var rowData = $("#gridTable").jqGrid('getRowData',selectedRowIds[i]);
- var id = rowData.id;
- var targetCode = rowData.targetCode;
- var name = rowData.name;
- var equipmentId = rowData.equipmentId;
- var windPowerstationId = rowData.windPowerstationId;
- var projectId = rowData.projectId;
- var lineId = rowData.lineId;
-
- // 校验指标编码输入是否合法
- var regx=/^[a-zA-Z]{1}[a-zA-Z0-9]*$/;
- codejudge =regx.test(targetCode);
- if(!codejudge){
- judge = false;
- break;
- }
-
- judge = judgeFormat(targetCode+name);
- if(!judge){
- break;
- }
- var index = id.indexOf('jqg');
- if(index>-1){
- if(params==''){
- params = targetCode+'●'+name+'●'+equipmentId+'●'+windPowerstationId+'●'+projectId+'●'+lineId;
- } else {
- params = params + '★' + targetCode+'●'+name+'●'+equipmentId+'●'+windPowerstationId+'●'+projectId+'●'+lineId;
- }
- }
- }
- if(judge){
- if(params==''){
- alert('选中的数据中没有未被保存的数据!');
- } else {
- $.ajax({
- type:"POST",
- url:encodeURI(encodeURI("/singleMachineAnalysis/saveTargetSystem.action?records="+params)),
- success:function(data){
- var d = eval("("+data+")");
- if(d.action=='success'){
- queryData();
- alert("保存成功!");
- }else if(d.action=='fail'){
- alert("编码重复,不能重复添加相同编码的记录!");
- }else{
- alert("保存失败!");
- }
- }
- });
- }
- }else{
- if(!codejudge){
- alert('编码格式错误,必须以字母开头,由字母、数字或下划线构成!');
- }else{
- alert('输入的编码或名称格式错误,不能包含特殊符号(●、★)');
- }
- }
- }
- } else {
- alert("请选择要保存的记录!");
- }
- return false;
- }
-
- // 加载jqgrid表格
- function showJqGrid(){
- // 编码
- var targetCodeQ = $("#targetCodeQ").val();
- // 名称
- var targetNameQ = $("#targetNameQ").val();
-
- jQuery("#gridTable").jqGrid({
- url:encodeURI(encodeURI('/singleMachineAnalysis/singleMachineAnalysisMainList.action?targetCode='+targetCodeQ+'&targetName='+targetNameQ)),
- datastr: 'data.json',
- datatype: "json",
- colNames:['编号', '编码','名称','设备型号','场站','工程','线路','操作'],
- colModel:[
- { name: 'id', index: 'id', width: 200, align: 'center', hidden: true},
- { name: 'targetCode', index: 'targetCode', width: 200, align: 'center',editable : true,editoptions : {size : 25}},
- { name: 'name', index: 'name', width: 200, align: 'center',editable : true,editoptions : {size : 25}},
- { name: 'equipmentId', index: 'equipmentId', width: 200, align: 'center',editable : true,edittype : "select",editoptions : {value : "${equipmentSelect}"}},
- { name: 'windPowerstationId', index: 'windPowerstationId', width: 200, align: 'center',editable : true,edittype : "select",editoptions : {value : "${windPowerStationSelect}"}},
- { name: 'projectId', index: 'projectId', width: 200, align: 'center',editable : true,edittype : "select",editoptions : {value : "${projectSelect}"}},
- { name: 'lineId', index: 'lineId', width: 200, align: 'center',editable : true,edittype : "select",editoptions : {value : "${lineSelect}"}},
- { name: 'operate', index: 'operate', width: 200, align: 'center'}
- ],
- rowNum:10,
- rowList:[10,20,30],
- height:'670',
- width:'1610',
- multiselect : true,
- pager: '#gridPager',
- sortname: 'id',
- viewrecords: true,
- autowidth: true,
- sortorder: "desc",
- editurl:encodeURI(encodeURI('/singleMachineAnalysis/singleMachineAnalysisMainList.action?targetCode='+targetCodeQ+'&targetName='+targetNameQ)),
- caption: "指标体系列表",
- jsonReader: {
-
- repeatitems: false,
-
- root: function (obj) { return obj.rows; },
-
- page: function (obj) { return obj.pageindex; },
-
- total: function (obj) { return obj.pagecount; },
-
- records: function (obj) { return obj.total; }
- },
- prmNames: {
- page: 'page',
-
- rows: 'pageSize'
-
- },
- afterInsertRow:function(rowid,rowdata,rowelem){
- var operateLink = "<a href=\"#\" onclick=\"requestAction('/singleMachineAnalysis/natureAnalysisTargetMain.action?tid=" + rowdata.id + "')\">定性指标</a> / "+
- "<a href=\"#\" onclick=\"requestAction('/singleMachineAnalysis/measureAnalysisTargetMain.action?tid=" + rowdata.id + "')\">定量指标</a>";
- jQuery("#gridTable").jqGrid('setRowData',rowdata.id,{operate:operateLink});
- }
-
- });
- }
- </script>
- <style type="text/css">
- fieldset legend {
- color:#302A2A;
- font: bold 16px/2 Verdana, Geneva, sans-serif;
- font-weight: bold;
- text-align: left;
- text-shadow: 2px 2px 2px rgb(88, 126, 156);
- }
- </style>
- </head>
- <body>
- <fieldset id="fst">
- <legend class="item_Name">查询条件</legend>
- <table width="1000px" cellpadding="0" cellspacing="0" class="dataform">
- <tr>
- <td style="width: 50px" align="right">
- 编码:
- </td>
- <td width="100px">
- <input type="text" id="targetCode" value="" />
- <input type="text" id="targetCodeQ" value="${targetCodeQS}" style="display: none;"/>
- </td>
- <td style="width: 100px" align="right">
- 名称:
- </td>
- <td style="width: 50px;">
- <input type="text" id="targetName" value="" />
- <input type="text" id="targetNameQ" value="${targetNameQS}" style="display: none;"/>
- </td>
- <td style="padding-left: 50px;">
- <input type="button" class="button" onclick="javascript:queryData();" value="查询"/>
- <input type="button" class="button" onclick="javascript:queryClear();" value="清空"/>
- </td>
- </tr>
- </table>
- </fieldset>
- <br/>
- <table id='gridTable'></table>
- <div id='gridPager'></div>
- <table>
- <tr>
- <td width="100%">
- <input type="button" class="button" id="addBtn" value="增加"/>
- <input type="button" class="button" onclick="delData();" value="删除"/>
- <input type="button" class="button" onclick="saveAddData();" value="保存"/>
- </td>
- </tr>
- </table>
- <form action="" method="post" id="f1">
- </body>
|