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.

262 lines
9.5 KiB
JavaScript

12 months ago
var commonGridObj_attrlist;
function $(id){
return document.getElementById(id);
}
function createGrid(){
//header
var headerArgs_attrlist = new Array("<input type=\"checkbox\" id=\"ck_all\" onclick=\"checkAll()\" />","参数名称","参数描述信息","参数类型","参数默认值","创建人","创建时间");
//width
var widthArgs_attrlist = new Array("40","250","200","120","120","120","120");
//column align
var colAlignArgs_attrlist = new Array("center","center","center","center","center","center","center");
//column sort
var colSortArgs_attrlist = new Array("na","str","str","str","str","str","str");
//column type
var colTypeArgs_attrlist = new Array("ch","ro","ro","ro","ro","ro","ro");
commonGridObj_attrlist = new TGridCommon("mygrid_container_attributelist","form1",headerArgs_attrlist,widthArgs_attrlist,colAlignArgs_attrlist,colSortArgs_attrlist,colTypeArgs_attrlist);
commonGridObj_attrlist.setResponseUrl("AttributeGridSource.aspx");
commonGridObj_attrlist.setRequest("AttributeGridSource.aspx?handle=attrlist&show_page=15&cur_page=1&uid="+commonGridObj_attrlist.newGuid());
commonGridObj_attrlist.setSourceType("json");
commonGridObj_attrlist.setSkin("xp");
commonGridObj_attrlist.setImageUrl("../images/");
commonGridObj_attrlist.initGrid();
commonGridObj_attrlist.bind();
commonGridObj_attrlist.initPageByHandle("attrlist");
commonGridObj_attrlist.getGridObj().attachEvent("onRowDblClicked", function(rId,cInd){
var openSet = "height=200, width=700, toolbar=no, menubar=no,scrollbars=no, resizable=no,location=no, status=no,Top= " +(screen.height-200)/2 + ",Left= "+(screen.width-700)/2
var openType = "_blank";
var openUrl = "AttributeEdit.aspx?handle=edit&id="+rId;
window.open (openUrl,openType,openSet);
});
commonGridObj_attrlist.dbclickEvent = function(){
commonGridObj_attrlist.getGridObj().attachEvent("onRowDblClicked", function(rId,cInd){
var openSet = "height=200, width=700, toolbar=no, menubar=no,scrollbars=no, resizable=no,location=no, status=no,Top= " +(screen.height-200)/2 + ",Left= "+(screen.width-700)/2
var openType = "_blank";
var openUrl = "AttributeEdit.aspx?handle=edit&id="+rId;
window.open (openUrl,openType,openSet);
});
}
}
//删除参数
function deleteAttribute(){
var totalCount = 0;
var sucCount = 0;
var falCount = 0;
var nullCount = 0;
var delArg = new Array();
var iDelCount = 0;
for(var i=0;i<commonGridObj_attrlist.getGridObj().getRowsNum();i++){
var checkState = commonGridObj_attrlist.getGridObj().cellByIndex(i,0).getValue();
var rId = commonGridObj_attrlist.getGridObj().getRowId(i);
if(checkState == 1){
iDelCount++;
delArg.push(rId);
}
}
if(iDelCount > 0){
if(window.confirm("确定要将选择的参数删除?")){
for(var j=0;j<delArg.length;j++){
var url = "AttributeGridSource.aspx?handle=deleteattr&attrid="+delArg[j]+"&uid="+commonGridObj_attrlist.newGuid();
var loader = dhtmlxAjax.getSync(url);
var stateInfo = loader.xmlDoc.responseText;
var state = parseInt(stateInfo);
}
createGrid();
}
}
}
function refreshList(){
createGrid();
}
//根据条件查询付费申请信息
function search(){
var _begintime = $("txt_beginDate").value.trim();
if(_begintime.trim() != ""){
if(!validateDateTime(_begintime)){
alert("起始时间格式错误");
return;
}
}
var _endtime = $("txt_endDate").value.trim();
if(_endtime.trim() != ""){
if(!validateDateTime(_endtime)){
alert("结束时间格式错误");
return;
}
}
var _customer = $("h_customer").value.trim();
var _checkno = $("txt_billno").value.trim();
var searchJson = "";
//begin
searchJson +="{";
searchJson += "[";
//如果查询条件设置了起始时间和结束时间则判断结束时间是否大于起始时间
if(_begintime != "" && _endtime != ""){
if(_begintime.length > 9 && _endtime.length > 9){
var status = DateTimeEqual(_begintime,_endtime);
if(status == 0){
searchJson += "\"btime\":\""+_begintime+"\","
searchJson += "\"etime\":\""+_endtime+"\","
}else if(status == -1){
alert("时间设置错误,起始时间不能大于结束时间,请修改!");
return;
}
// else if(status == -2){
// alert("时间设置错误,起始时间不能等于结束时间,请修改!");
// return;
// }
}
else{
alert("时间格式有问题,长度应大于9个字符,请修改!");
return;
}
}else{
searchJson += "\"btime\":\""+_begintime+"\","
searchJson += "\"etime\":\""+_endtime+"\","
}
searchJson += "\"cus\":\""+_customer+"\",";
searchJson += "\"no\":\""+_checkno+"\"";
searchJson += "]";
searchJson +="}";//alert(searchJson);
commonGridObj_invoicelist.initGrid();
commonGridObj_invoicelist.setRequest("InvoiceApplicationGridSource.aspx?handle=makeoutlist&show_page=15&cur_page=1&search="+escape(searchJson)+"&uid="+commonGridObj_invoicelist.newGuid());
commonGridObj_invoicelist.bind();
commonGridObj_invoicelist.setSearch(searchJson);
commonGridObj_invoicelist.initPageByHandle("makeoutlist");
commonGridObj_invoicelist.getGridObj().attachEvent("onEditCell",function(stage,rId,cInd,nValue,oValue){
if(stage == 0){
if(cInd == 2 || cInd == 3){
return false;
}else{
return true;
}
}
});
commonGridObj_invoicelist.getGridObj().attachEvent("onRowDblClicked", function(rId,cInd){
var rId = commonGridObj_invoicelist.getGridObj().getSelectedRowId();
var openSet = "height=500, width=960, toolbar=no, menubar=no,scrollbars=no, resizable=no,location=no, status=no,Top= " +(screen.height-710)/2 + ",Left= "+(screen.width-960)/2
var openType = "_blank";
var openUrl = "InvoiceMakeOutEdit.aspx?id="+rId+"&handle=edit";
window.open (openUrl,openType,openSet);
});
}
//校验时间格式
function validateDateTime(dateTimeObj){
var isValid = false;
var parseToObj = new Date(dateTimeObj.replace(/-/g, "/"));
if(!isNaN(parseToObj)){
isValid = true;
}
return isValid;
}
function DateTimeEqual(beginObj,endObj){
var isEqual = 0;
var begin = new Date(beginObj.replace(/-/g, "/"));
var end = new Date(endObj.replace(/-/g, "/"));
if(Date.parse(begin) - Date.parse(end) > 0){
isEqual = -1;//起始时间大于结束时间
}else if(Date.parse(begin) - Date.parse(end) == 0){
isEqual = -2;//起始时间与结束时间相等
}
return isEqual;
}
String.prototype.trim = function() { return this.replace(/(^\s*)|(\s*$)/g,""); }
//初始化界面
function initGrid(){
$("h_customer").value = "";
comboCustomer.setComboText($("h_customer").value);
$("txt_beginDate").value = "";
$("txt_endDate").value = "";
$("txt_billno").value = "";
createGrid();
}
function checkInfo(){
var checkRowID = "";
var iCheckCount = 0;
for(var i=0;i<commonGridObj_attrlist.getGridObj().getRowsNum();i++){
var rowId = commonGridObj_attrlist.getGridObj().getRowId(i);
var rowIndex = commonGridObj_attrlist.getGridObj().getRowIndex(rowId);
var checkState = commonGridObj_attrlist.getGridObj().cellByIndex(rowIndex,0).getValue();
if(checkState == 1){
if(iCheckCount > 0){
commonGridObj_attrlist.getGridObj().cellByIndex(rowIndex,0).setValue(0);
}else{
iCheckCount++;
checkRowID = rowId;
}
}
}
if(checkRowID != ""){
var openSet = "height=200, width=700, toolbar=no, menubar=no,scrollbars=no, resizable=no,location=no, status=no,Top= " +(screen.height-200)/2 + ",Left= "+(screen.width-700)/2
var openType = "_blank";
var openUrl = "TypeEdit.aspx?handle=edit&id="+checkRowID;
var tempWin = window.open ("about:blank",openType,openSet);
tempWin.location = openUrl;
}
}
function checkAll(){
if(commonGridObj_attrlist != null){
for(var i=0;i<commonGridObj_attrlist.getGridObj().getRowsNum();i++){
var rowId = commonGridObj_attrlist.getGridObj().getRowId(i);
var rowIndex = commonGridObj_attrlist.getGridObj().getRowIndex(rowId);
if($("ck_all").checked){
commonGridObj_attrlist.getGridObj().cellByIndex(rowIndex,0).setValue(1);
}else{
commonGridObj_attrlist.getGridObj().cellByIndex(rowIndex,0).setValue(0);
}
}
}
}
function addAttribute(){
var openSet = "height=200, width=700, toolbar=no, menubar=no,scrollbars=no, resizable=no,location=no, status=no,Top= " +(screen.height-200)/2 + ",Left= "+(screen.width-700)/2
var openType = "_blank";
var openUrl = "AttributeEdit.aspx?handle=add";
var tempWin = window.open ("about:blank",openType,openSet);
tempWin.location = openUrl;
}