123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275 |
- <%@ 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();
- // 指标体系ID
- var tid = $("#tid").val();
- jQuery("#gridTable").jqGrid('setGridParam',{url:encodeURI(encodeURI("/singleMachineAnalysis/natureAnalysisTargetMainList.action?targetName="+targetName+"&targetCode="+targetCode+"&tid="+tid))}).trigger("reloadGrid");
- }
-
- function queryClear(){
- $("#targetCode").val("");
- $("#targetName").val("");
- }
-
- // 返回主页
- function returnAction(){
- var targetCodeQS = $("#targetCodeQS").val();
- var targetNameQS = $("#targetNameQS").val();
- $("#f1").attr("action",encodeURI(encodeURI("/singleMachineAnalysis/singleMachineAnalysisMain.action?targetCodeQS=" + targetCodeQS + "&targetNameQS=" + targetNameQS)));
- $("#f1").submit();
- }
-
- $(function(){
- showJqGrid();
-
- $("#addBtn").click(function() {
- jQuery("#gridTable").jqGrid('editGridRow', "new", {
- height : 300,
- reloadAfterSubmit : false
- });
- });
- });
-
- // 加载jqgrid表格
- function showJqGrid(){
- // 指标体系ID
- var tid = $("#tid").val();
- jQuery("#gridTable").jqGrid({
- url:encodeURI('/singleMachineAnalysis/natureAnalysisTargetMainList.action?tid='+tid),
- 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: 'aname', index: 'aname', width: 200, align: 'center',editable : true,editoptions : {size : 25}},
- { name: 'cid', index: 'cid', width: 200, align: 'center',editable : true,edittype : "select",editoptions : {value : "${analysisClassSelect}"}},
- { name: 'wid', index: 'wid', width: 200, align: 'center',editable : true,edittype : "select",editoptions : {value : "${analysisWeightSelect}"}},
- { name: 'operate', index: 'operate', width: 200, align: 'center'}
- ],
- rowNum:10,
- height:'670',
- width:'1610',
- rowList:[10,20,30],
- multiselect : true,
- pager: '#gridPager',
- sortname: 'id',
- viewrecords: true,
- autowidth: true,
- sortorder: "desc",
- editurl : '/singleMachineAnalysis/natureAnalysisTargetMainList.action?tid='+tid,
- 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 = "<input type='button' value='修改' onclick=\"jQuery('#gridTable').editRow('" + rowdata.id + "');\" />" +
- "<input type='button' value='确定' onclick=\"jQuery('#gridTable').saveRow('" + rowdata.id + "');\" />" +
- "<input type='button' value='取消' onclick=\"jQuery('#gridTable').restoreRow('" + rowdata.id + "');\" />";
-
- jQuery("#gridTable").jqGrid('setRowData',rowdata.id,{operate:operateLink});
- }
-
- });
- }
-
-
- // 删除选中行
- 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/delNatureTarget.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{
- alert("删除失败!");
- }
- }
- });
- }
- }else{
- alert("请选择要删除的记录!");
- }
- return false;
- }
- // 判断输入内容是否合法,不能包括逗号(,)和斜杠(/). 结果true校验通过
- function judgeFormat(objStr){
- var result = false;
- var countone = objStr.indexOf('●');
- var counttwo = objStr.indexOf('★');
- var countEdit = objStr.indexOf('role="textbox" class="editable">');
- if(countone==-1 && counttwo==-1 && countEdit==-1){
- result = true;
- }
- return result;
- }
-
- function saveAddData(){
- // 指标体系ID
- var tid = $("#tid").val();
- 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 aname = rowData.aname;
- var cid = rowData.cid;
- var wid = rowData.wid;
- // 校验指标编码输入是否合法
- var regx=/^[a-zA-Z]{1}[a-zA-Z0-9]*$/;
- codejudge =regx.test(targetCode);
- if(!codejudge){
- judge = false;
- break;
- }
-
- judge = judgeFormat(targetCode+name+aname);
- if(!judge){
- break;
- }
-
- if(params==''){
- params = id+'●'+targetCode+'●'+name+'●'+aname+'●'+cid+'●'+wid;
- } else {
- params = params + '★' + id+'●'+targetCode+'●'+name+'●'+aname+'●'+cid+'●'+wid;
- }
- }
- if(judge){
- $.ajax({
- type:"POST",
- url:encodeURI(encodeURI("/singleMachineAnalysis/saveNatureTarget.action?records="+params+"&tid="+tid)),
- 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;
- }
- </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="100%" cellpadding="0" cellspacing="0" class="dataform">
- <tr>
- <td style="width: 50px" align="right">
- 编码:
- </td>
- <td width="100px">
- <input type="text" id="targetCode" value="" />
- </td>
- <td style="width: 100px" align="right">
- 名称:
- </td>
- <td style="width: 50px;">
- <input type="text" id="targetName" value="" />
- </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 width="100%">
- <tr>
- <td style="width: 50%;">
- <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>
- <td align="right" style="width: 50%;">
- <a href="#" onclick="returnAction();"><<返回</a>
- </td>
- </tr>
- </table>
- <input type="text" id="targetCodeQS" value="${targetCodeQS}" style="display: none;"/>
- <input type="text" id="targetNameQS" value="${targetNameQS}" style="display: none;"/>
- <input type="text" id="tid" value="${tid}" style="display: none;"/>
- <form action="" method="post" id="f1">
- </body>
|