123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194 |
- var grid;
- var fdObjectId=null;
- function resolveUrl(){
- var encondeCondition=window.location.search;
- var condition= decodeURI(encondeCondition.substring(1,encondeCondition.length));
- var conditionArr=condition.split("&");
- var condJson={};
- for(var item in conditionArr){
- var temArr=conditionArr[item].split("=");
- condJson[temArr[0]]=temArr[1];
- }
- return condJson;
- }
- var option={
- columns: [
- {name: 'FD_OBJECTID', hide : true},
- {display : '标题',name : 'TITLENAME', align : 'center',width :'20%' },
- {display : '内容',name : 'PLANKINFO', align : 'center',width : '60%'},
- {display : '时间',name : 'PLANKDATE', align : 'center',width : '20%'}
- ],
- data:[],
- rownumbers:true,
- checkbox:true,
- height: '100%',
- width:"100%",
- pageSize: '10',
- percentWidthMode:true,
- //顶部图标按钮栏
- toolbar:
- {
- items: [
- { text: '新增', click: onAdd, iconClass: 'icon_add', disabled: false },
- { line: true },
- { text: '修改', click: onEdit, iconClass: 'icon_edit', disabled: false },
- { line: true }
- ]
- }
- };
- //初始化列表
- /*function createGrid(){
-
-
- }*/
- /*
- * 加载数据表格
- */
- function loadGridData() {
- if (fdObjectId == null)
- return;
- $.post($.pathname()+ "/ws/IntelligenceService/IntelligenceService/getIntelligencInfo",
- {
- fdObjectId : fdObjectId
- },
- function(result) {
- if (result.state == "FAILURE")
- throw new Error("查询失败");
- if(grid==null){
- option.data=result;
- grid = $("#i_main_grid").quiGrid(option);
- }else{
- grid.setOptions({
- data : result
- });
- grid.loadData();
- }
- }, "json");
- }
-
-
- /**
- * 新增
- */
- function onAdd(){
- var url = "add_intelligence.jsp?fdObjectId="+fdObjectId;
- window.parent.document.getElementById("frmright").
- setAttribute("src", "/nwyj/page/system/externalSystem/"+encodeURI(url));
- }
-
- /**
- * 返回主页面
- */
- function goBack() {
- //获取iframe中的元素值
- var iframe =parent.document.getElementsByName("frmright")[0];
- iframe.src = $.pathname()+"/page/system/externalSystem/intelligence.jsp";
- }
- function init(){
- $.post("/nwyj/ws/IntelligenceService/IntelligenceService/getTitle",{},function(result){
- if(result.state=="FAILURE") throw new Error("查询失败");
- $("#Ititle").val(result.rows[0].TITLENAME);
- fdObjectId=result.rows[0]["FD_OBJECTID"];
- loadGridData();
-
- },"json");};
- /**
- * 初始化
- */
- $(function(){
- var params=resolveUrl();
- fdObjectId=params.fdObjectId;
- init();
- $("#Isave").on("click",function(){
- checkTitle();
- });
-
- });
- /**
- * 判断title是否存在
- */
- function checkTitle(){
- $.post($.pathname() + '/ws/IntelligenceService/IntelligenceService/getIntelligencId',{title:$("#Ititle").val()},function(result){
- if(result.state=="FAILURE") throw new Error("查询失败");
- if(result.rows=="null"){
- top.Dialog.confirm("尚未查询到"+$("#Ititle").val()+";请问是否增加"+$("#Ititle").val(),function(){
- save($("#Ititle").val());},function(){return false;});
- }else{
- fdObjectId=result.rows;
- loadGridData();
- }
- },"json");
- }
- /**
- * 保存title
- * @param title
- */
- function save(title){
- $.post($.pathname() + "/ws/IntelligenceService/IntelligenceService/saveIntelligencInfo",{title:title},function(result){
- if(result.state=="FAILURE") throw new Error("查询失败");
- fdObjectId=result.rows;
- loadGridData();
- },"json");
- }
- /**
- * 增加
- */
- function addExternal(){
- $form = $('#fillForm');
- var url = $.pathname() + '/ws/crud/CRUDService/create';
- $.ajax({
- url : url,
- type : 'post',
- data : $form.serialize(),
- dataType : 'text',
- timeout : 60000,
- success : function(data){
- goBack();
- $.messager.alert("保存成功",null,null,null,1);
- },
- error : function(){
- $.messager.alert('操作失败');
- }
- });
- };
- /**
- * 修改
- */
- function onEdit(){
- var rows = grid.getSelectedRows();
- if(rows.length==0){
- top.Dialog.alert("请选择一条记录");
- return;
- }
- if(rows.length>1){
- top.Dialog.alert("只能选择一条记录");
- return;
- }
- var fd_id = rows[0].FD_OBJECTID;
- var iframe =parent.document.getElementsByName("frmright")[0];
- var url = "edit_intelligence.jsp?fdObjectId="+fdObjectId+"&id="+fd_id;
- iframe.src = $.pathname()+"/page/system/externalSystem/"+encodeURI(url);
- };
|