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.

177 lines
7.2 KiB
JavaScript

12 months ago
var comboAttribute;
function $(id){
return document.getElementById(id);
}
function initType(){
var attributeObj = null;
// if($("h_attrid").value.trim() == ""){
// $("h_attrid").value = comboAttribute.getComboValue();
// }
var url = "../FeeCodes/AttributeAdapter.aspx?handle=attrinfo&attrid="+$("h_attrid").value+"&uid="+newGuid();
var loader = dhtmlxAjax.getSync(url);
var attributeVal = loader.xmlDoc.responseText;//alert(opInfo);
var attributeObj = eval('(' + attributeVal + ')');
if(attributeObj.attr.length > 0){
var selType = $("sel_type");
selType.options.length = 0;
selType.add(new Option(attributeObj.attr[0].type,attributeObj.attr[0].type));
$("h_attrid").value = attributeObj.attr[0].id;
$("h_type").value = attributeObj.attr[0].type;
$("txt_description").value = attributeObj.attr[0].name;
switch(attributeObj.attr[0].type){
case "bool":
var tempTrueVal = $("h_attrval").value.trim() == "true"?"checked":"";
var tempFalseVal = $("h_attrval").value.trim() == "true"?"":"checked";
$("txt_attrval").innerHTML = "<div style=\"width:30px;float:left;\"><input type=\"checkbox\" name=\"ck_true\" id=\"ck_true\" "+tempTrueVal+" onclick=\"switchCheckBox('ck_true','ck_false')\"/></div><div style=\"width:30px;float:left;padding-top:3px;\">是</div>"
+ "<div style=\"width:30px;float:left;\"><input type=\"checkbox\" name=\"ck_false\" id=\"ck_false\" "+tempFalseVal+" onclick=\"switchCheckBox('ck_false','ck_true')\"/></div><div style=\"width:30px;float:left;padding-top:3px;\">否</div>"
break;
case "int":
$("txt_attrval").innerHTML = "<input type=\"text\" id=\"txt_val\" name=\"txt_val\" class=\"txtTab\" style=\"width:100%\" value=\""+($("h_attrval").value.trim() != ""?$("h_attrval").value.trim():attributeObj.attr[0].dval)+"\" />";
break;
case "string":
$("txt_attrval").innerHTML = "<input type=\"text\" id=\"txt_val\" name=\"txt_val\" class=\"txtTab\" style=\"width:100%\" value=\""+($("h_attrval").value.trim() != ""?$("h_attrval").value.trim():attributeObj.attr[0].dval)+"\"/>";
break;
}
}
}
function createComboAttribute(){//参数信息
comboAttribute = dhtmlXComboFromSelect("sel_attribute");
comboAttribute.loadXML("../FeeCodes/AttributeAdapter.aspx?mask=0&pos=0");
comboAttribute.attachEvent("onChange", function(){
comboAttribute.setComboText($("h_attrname").value);
$("h_attrid").value = comboAttribute.getSelectedValue();
// var attributeObj = null;
// var url = "../FeeCodes/AttributeAdapter.aspx?handle=attrinfo&attrid="+$("h_attrid").value+"&uid="+newGuid();
// var loader = dhtmlxAjax.getSync(url);
//
// var attributeVal = loader.xmlDoc.responseText;//alert(opInfo);
// var attributeObj = eval('(' + attributeVal + ')');
//
// if(attributeObj.attr.length > 0){
// var selType = $("sel_type");
// selType.options.length = 0;
//
// selType.add(new Option(attributeObj.attr[0].type,attributeObj.attr[0].type));
// $("h_attrid").value = attributeObj.attr[0].id;
// $("h_type").value = attributeObj.attr[0].type;
// $("txt_description").value = attributeObj.attr[0].name;
//
//// if($("h_compattrid").value.trim() == ""){
// switch(attributeObj.attr[0].type){
// case "bool":
// $("txt_attrval").innerHTML = "<div style=\"width:30px;float:left;\"><input type=\"radio\" name=\"ck_true\" id=\"ck_true\"/></div><div style=\"width:30px;float:left;\">是</div>"
// + "<div style=\"width:30px;float:left;\"><input type=\"radio\" name=\"ck_false\" id=\"ck_false\"/></div><div style=\"width:30px;float:left;\">否</div>"
// break;
// case "int":
// $("txt_attrval").innerHTML = "<input type=\"text\" id=\"txt_val\" class=\"txtTab\" style=\"width:100%\" value=\""+attributeObj.attr[0].dval+"\"/>";
// break;
// case "string":
// $("txt_attrval").innerHTML = "<input type=\"text\" id=\"txt_val\" class=\"txtTab\" style=\"width:100%\" value=\""+attributeObj.attr[0].dval+"\"/>";
// break;
// }
//// }else{
//// var typeID = $("h_typeid").value.trim();
//// for(var i=0;i<attributeObj.attr.length;i++){
//// if(attributeObj.attr[0].typeid == typeID){
//// selType.value = attributeObj.attr[0].type;
//// }
//// }
//// }
// }
initType();
});
comboAttribute.attachEvent("onBlur", function(){
// var s1 = comboAttribute.getComboText().trim();
// var s2 = s1.indexOf("|");
// if(s2>0){
// s2=s2+2;
// }
// var s3 = s1.substring(s2);
// if(s2>0){
// comboAttribute.setComboText(s3);
// $("h_customer").value=s3;
// }
// else
// {
comboAttribute.setComboText($("h_attrname").value);
// }
});
comboAttribute.setComboText($("h_attrname").value);
comboAttribute.attachEvent("onKeyPressed", function(keyCode){
if(keyCode!="8"){
var arrayArg = new Array();
setTimeout(function(){
var filterCount = 0;
var is = -1;
var ishd = $("h_attrname").value.trim();
if("" != comboAttribute.getComboText().trim()){
while("undefined" != typeof comboAttribute.getOptionByIndex(filterCount)){
var comboValue = comboAttribute.getOptionByIndex(filterCount).text.toUpperCase();//.value;
var enterValue = comboAttribute.getComboText().trim().toUpperCase();
$("h_attrname").value = comboAttribute.getComboText().trim().toUpperCase();
if(comboValue.indexOf(enterValue) == 0){
comboAttribute.selectOption(filterCount,true,true);
is=filterCount;
break;
}
++filterCount;
}
if(is==-1){
$("h_customer").value = ishd;
alert("无此内容,请重新选择!");
}
}
},10);
}
});
comboAttribute.attachEvent("onSelectionChange", function(){
$("h_attrname").value = comboAttribute.getComboText().trim();
$("h_attrid").value = comboAttribute.getSelectedValue();
});
initType();
}
String.prototype.trim = function() { return this.replace(/(^\s*)|(\s*$)/g,""); }
//获取GUID
function newGuid()
{
var guid = "";
for (var i = 1; i <= 32; i++){
var n = Math.floor(Math.random()*16.0).toString(16);
guid += n;
if((i==8)||(i==12)||(i==16)||(i==20))
guid += "-";
}
return guid.toUpperCase();
}
function switchCheckBox(pushObjName,otherObjName){
if($(pushObjName).checked){
$(otherObjName).checked = false;
}else{
$(pushObjName).checked = true;
$(otherObjName).checked = false;
}
}