//select视图页面专用

if (objName == "") {
    $("body").html("objname参数不能为空!")
}
var $parentObj = parent.$(objName);
if ($parentObj.length == 0) {
    $("body").html("对象" + objName + "不存在!")
}
var fieldType = $parentObj.get(0).tagName.toLowerCase();
if (fieldType == "select") {
    if (typeof ($parentObj.attr("multiple")) != "undefined") {
        fieldType = "multipleSelect";
    }
}

//已经选中的设置为disabled
function SetSelectedDisabled() {
    var hasSelectIds = "";
    if (fieldType == "input") {
        hasSelectIds = $parentObj.val();
        var $checkObj = $(".checked-item");
        $checkObj.attr("type", "radio").attr("name", "_checked_item_");
        $(".item").find("[data-input-value='" + hasSelectIds + "']").prop("checked", true).attr("disabled", "disabled");
        return;
    }
    else {
        var $options = $parentObj.children("option");
        $options.each(function (i) {
            hasSelectIds += $(this).val() + ",";
        });
    }

    var arrHasSelectIds = hasSelectIds.split(",");
    for (var k = 0; k < arrHasSelectIds.length; k++) {
        $("#item_" + arrHasSelectIds[k]).find(".checked-item").prop("checked", true).attr("disabled", "disabled");
    }
}

function SelectData() {

    var selectInputStr = "";
    var selectedStr = "";
    var $checkObj = $(".checked-item");
    selectedStr = $checkObj.GetValue();
    $checkObj.each(function () {
        if ($(this).prop("checked") && $(this).attr("data-input-value") != undefined) {
            selectInputStr += "," + $(this).attr("data-input-value");
        }
    });

    if (fieldType == "input") {
        if (selectInputStr != "") {
            selectedStr = selectInputStr;
        }
        var str = selectedStr;
        str = Unique(str);
        $parentObj.val(str);
        CloseDialog();
        return;
    }

    if (selectedStr == "") {
        CloseDialog();
        return;
    }
    var $options = $parentObj.children("option");
    if (fieldType == "select") //单选先删除之前的旧数据
    {
        $options.each(function () {
            var $this = $(this);
            if ($this.val() != "" && $this.val() != "0") {
                $this.remove();
            }
        });
    }

    $parentObj.ConvertSelect({ids:selectedStr,isFormBind:false,dataSourceForm:"ajax"});

    if (fieldType == "select")//单选则默认选中最后一个
    {
        var length = $parentObj.children("option").length;
        $parentObj.children("option").eq(length - 1).attr("selected", "selected").siblings().removeAttr("selected");
    }

    CloseDialog();
}