You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
DS7/DSWeb/js/jsGridSysAnnounceClient.js

316 lines
11 KiB
JavaScript

3 years ago
var commonGridObj_message;
function $(id){
return document.getElementById(id);
}
function createGrid(){
//header
var headerArgs_message = new Array("<input type=\"checkbox\" id=\"ck_all\" onclick=\"checkall('ck_all')\" />","标题","发布时间");
//width
var widthArgs_message = new Array("40","180","120");
//column align
var colAlignArgs_message = new Array("center","left","left");
//column sort
var colSortArgs_message = new Array("na","str","str");
//column type
var colTypeArgs_message = new Array("ch","ro","ro");
commonGridObj_message = new TGridCommon("mygrid_container_message","form1",headerArgs_message,widthArgs_message,colAlignArgs_message,colSortArgs_message,colTypeArgs_message);
var searchJson = "";
//begin
searchJson +="{";
searchJson += "[";
var _checkState = $("sel_read").value;
var _btime = "";
var _etime = "";
var _content = "";
var _type = "";
searchJson += "\"btime\":\""+_btime+"\",";
searchJson += "\"etime\":\""+_etime+"\",";
searchJson += "\"content\":\""+_content+"\",";
searchJson += "\"type\":\""+_type+"\",";
searchJson += "\"read\":\""+_checkState+"\"";
searchJson += "]";
searchJson +="}";
commonGridObj_message.setResponseUrl("SysAnnounceClientGridSource.aspx");
commonGridObj_message.setRequest("SysAnnounceClientGridSource.aspx?handle=messagelist&show_page=15&cur_page=1&search="+escape(searchJson)+"&uid="+commonGridObj_message.newGuid());
commonGridObj_message.setSourceType("json");
commonGridObj_message.setSkin("xp");
commonGridObj_message.setImageUrl("../images/");
commonGridObj_message.initGrid();
commonGridObj_message.bind();
commonGridObj_message.setSearch(searchJson);
commonGridObj_message.initPageByHandle("messagelist");
commonGridObj_message.getGridObj().attachEvent("onSelectStateChanged", function(id)
{
$("h_messageid").value = id;
$("hdISEDIT").value = "messagelist";
//标记为已读
var readUrl = "SysAnnounceClientGridSource.aspx?id="+id+"&handle=setread&uid="+commonGridObj_message.newGuid();
var loader = dhtmlxAjax.getSync(readUrl);
var stateVal = loader.xmlDoc.responseText;
if(parseInt(stateVal) > 0)
{
}
setTimeout(postEdit,200);
});
// commonGridObj_message.getGridObj().attachEvent("onSelectStateChanged", function(id)
// {
// $("h_messageid").value = id;
// var messageObj = null;
// var url = "SysAnnounceClientGridSource.aspx?id="+id+"&handle=getmessageinfo&uid="+commonGridObj_message.newGuid();
// var loader = dhtmlxAjax.getSync(url);
// var messageVal = loader.xmlDoc.responseText;
//
//
// $("tbANNOUNCECONTENT").innerHTML = messageVal;
//
// /*
// if(messageVal.trim() != "")
// {
// messageObj = eval('(' + messageVal + ')');
//
// $("dvTitleContent").innerHTML = messageObj.message[0].desc;
// //$("dvTime").innerHTML = messageObj.message[0].time;
// $("dvMessageContent").innerHTML = messageObj.message[0].content+createRedirectUrl(messageObj.message[0].url);
//
// }
// */
// //标记为已读
// var readUrl = "SysAnnounceClientGridSource.aspx?id="+id+"&handle=setread&uid="+commonGridObj_message.newGuid();
// var loader = dhtmlxAjax.getSync(readUrl);
// var stateVal = loader.xmlDoc.responseText;
//
// if(parseInt(stateVal) > 0)
// {
// }
// });
commonGridObj_message.clickEvent = function()
{
commonGridObj_message.getGridObj().attachEvent("onSelectStateChanged", function(id)
{
$("h_messageid").value = id;
$("hdISEDIT").value = "getmessageinfo";
//标记为已读
var readUrl = "SysAnnounceClientGridSource.aspx?id="+id+"&handle=setread&uid="+commonGridObj_message.newGuid();
var loader = dhtmlxAjax.getSync(readUrl);
var stateVal = loader.xmlDoc.responseText;
if(parseInt(stateVal) > 0)
{
}
setTimeout(postEdit,200);
});
// commonGridObj_message.getGridObj().attachEvent("onSelectStateChanged", function(id)
// {
// $("h_messageid").value = id;
// var messageObj = null;
// var url = "SysAnnounceClientGridSource.aspx?id="+id+"&handle=getmessageinfo&uid="+commonGridObj_message.newGuid();
// var loader = dhtmlxAjax.getSync(url);
// var messageVal = loader.xmlDoc.responseText;
//
// $("tbANNOUNCECONTENT").innerHTML = messageVal;
//
// /*
// if(messageVal.trim() != ""){
// messageObj = eval('(' + messageVal + ')');
//
// $("dvTitle").innerHTML = messageObj.message[0].name;
// $("dvMessageContent").innerHTML = messageObj.message[0].content+messageObj.message[0].url;
// }
// */
// //标记为已读
// var readUrl = "SysAnnounceClientGridSource.aspx?id="+id+"&handle=setread&uid="+commonGridObj_message.newGuid();
// var loader = dhtmlxAjax.getSync(readUrl);
// var stateVal = loader.xmlDoc.responseText;
//
// if(parseInt(statusVal) > 0)
// {
// }
// });
}
}
//post数据
function postEdit(){
var myForm = document.getElementById("form1");
myForm.submit() ;
}
String.prototype.trim = function() { return this.replace(/(^\s*)|(\s*$)/g,""); }
function markMessageRead(){}
function checkall(id){
var checkAllState = $(id).checked;
if(checkAllState == 1){
for(var i = 0;i<commonGridObj_message.getGridObj().getRowsNum();i++){
commonGridObj_message.getGridObj().cellByIndex(i,0).setValue(1);
}
}else{
for(var i = 0;i<commonGridObj_message.getGridObj().getRowsNum();i++){
commonGridObj_message.getGridObj().cellByIndex(i,0).setValue(0);
}
}
}
function onChangeType(id){
// var selectObj = $(id);
// var selVal = selectObj.options[selectObj.selectedIndex].value;
// alert(selVal);
createGrid();
}
function deleteMsg()
{
var rowId = commonGridObj_message.getGridObj().getCheckedRows(0);//所有选中的grid的id编号
if(rowId != "")
{
var readUrl = "SysAnnounceClientGridSource.aspx?rowId="+rowId+"&handle=deletemessage&uid="+commonGridObj_message.newGuid();
var loader = dhtmlxAjax.getSync(readUrl);
var stateVal = loader.xmlDoc.responseText;
}
createGrid();
}
function bjMsg()
{
var rowId = commonGridObj_message.getGridObj().getCheckedRows(0);//所有选中的grid的id编号
if(rowId != "")
{
var readUrl = "SysAnnounceClientGridSource.aspx?rowId="+rowId+"&handle=bjmsg&uid="+commonGridObj_message.newGuid();
var loader = dhtmlxAjax.getSync(readUrl);
var stateVal = loader.xmlDoc.responseText;
}
createGrid();
}
function refreshList(){
createGrid();
}
function createRedirectUrl(url){
var tempUrl = url;
var result = "";
if(url.trim() != ""){
result += "<br/><br/>点击&nbsp;&nbsp;<a href=\"javascript:void(0)\" onclick=\"redirect('"+tempUrl+"')\">查看</a>";
}
return result;
}
function redirect(url){
//alert(parent.document.getElementById("iFrameH").contentWindow.location);
var postType = parseInt($("h_posttype").value);
if(postType == 2){
var oldUrl = parent.document.getElementById("iFrameH").contentWindow.location.href;
var doubleUrl = 0;
if(oldUrl.indexOf("//") >= 0){
doubleUrl = oldUrl.indexOf("//")+2;
}
var tempUrl = oldUrl.substring(doubleUrl,oldUrl.substring(doubleUrl,oldUrl.length).indexOf("/")+doubleUrl);
var newUrl = oldUrl.substring(0,doubleUrl)+tempUrl+"/"+url;
parent.document.getElementById("iFrameH").contentWindow.location = newUrl;
}else if(postType == 1){
var oldUrl = window.parent.opener.document.getElementById("iFrameH").contentWindow.location.href
var doubleUrl = 0;
if(oldUrl.indexOf("//") >= 0){
doubleUrl = oldUrl.indexOf("//")+2;
}
var tempUrl = oldUrl.substring(doubleUrl,oldUrl.substring(doubleUrl,oldUrl.length).indexOf("/")+doubleUrl);
var newUrl = oldUrl.substring(0,doubleUrl)+tempUrl+"/"+url;
window.parent.opener.document.getElementById("iFrameH").contentWindow.location = newUrl;
window.close();
}
}
//上一条
function upNext()
{
$("hdISEDIT").value = "messagepagelist";
var messageID = $("h_messageid").value.trim();
var messageCount = 0;
var checkType = $("sel_read").value;
//alert(messageID);
if(messageID != "")
{
var readUrl = "SysAnnounceClientGridSource.aspx?id="+messageID+"&checktype="+checkType+"&handle=getmessagecount&uid="+commonGridObj_message.newGuid();
var loader = dhtmlxAjax.getSync(readUrl);
var stateVal = loader.xmlDoc.responseText;
messageCount = parseInt(stateVal);
if(messageCount > 1)
{
$("hdiIncludeTop").value = 1;
$("hdiNotIncludeTop").value = messageCount-1;
}
else if(messageCount == 1)
{
$("hdiIncludeTop").value = 1;
$("hdiNotIncludeTop").value = 1;
}
else
{
return;
}
setTimeout(postEdit,200);
}
}
//下一条
function downNext()
{
$("hdISEDIT").value = "messagepagelist";
var messageID = $("h_messageid").value.trim();
var messageCount = 0;
var checkType = $("sel_read").value;
if(messageID != "")
{
var readUrl = "SysAnnounceClientGridSource.aspx?id="+messageID+"&handle=getmessagecount2&uid="+commonGridObj_message.newGuid();
var loader = dhtmlxAjax.getSync(readUrl);
var stateVal = loader.xmlDoc.responseText;
messageCount = parseInt(stateVal);
if(messageCount >0)
{
$("hdiIncludeTop").value = 1;
$("hdiNotIncludeTop").value = messageCount;//-1;
}
else if(messageCount == 1)
{
$("hdiIncludeTop").value = 1;
$("hdiNotIncludeTop").value = 1;
}
else
{
return;
}
setTimeout(postEdit,200);
}
}
//个人信息设置
function msgSetting(){
var openSet = "height=100, width=200, toolbar=no, menubar=no,scrollbars=no, resizable=no,location=no, status=no,Top= " +(screen.height-100)/2 + ",Left= "+(screen.width-200)/2
var openType = "_blank";
var openUrl = "../message/messagesetting.aspx";
window.open (openUrl,openType,openSet);
}