/**
 * Created by gqs on 2020/8/5.
 */
//动态创建Select Options
function Select_DyCreate(selectID,JsonArrayData,valueField,textField,addTotal){
    var $result = $("#"+selectID+"");
    $result.empty();
    var selectedIndex = 0;
    if(addTotal == true){
        var value = "-1",text="全部";
        var $option = $("<option>")
            .attr("value", value)
            .text(text)
            .appendTo($result);
        $option.prop("selected",true);
    }
    $.each(JsonArrayData, function(index, jsonData) {
        var value = valueField ? jsonData[valueField] : index,
            text = textField ? jsonData[textField] : jsonData;
        var $option = $("<option>")
            .attr("value", value)
            .text(text)
            .appendTo($result);
        // $option.prop("selected", (selectedIndex === index));
    });
}
//获取下拉框选中项Text
function Select_GetSelectText(selectID) {
    // alert($("#"+selectID+"").find("option:selected").text());
    return $("#"+selectID+"").find("option:selected").text();
}
//获取下拉框选中项value
function Select_GetSelectValue(selectID) {
    // alert( $("#"+selectID+"").val());
    return $("#"+selectID+"").val();
}
//根据文本 设置下拉框选中项
function Select_SetSelectedByText(selectID,text){
    var select = $("#"+selectID);
    select.find("option:contains('"+text+"')").prop("selected",true);

    // $("#"+selectID).find("option[text='"+text+"']").attr("selected",true);
}
//获取Select选择的索引值
function Select_getSelectIndex(selectID){
    var checkIndex=$("#"+selectID+"").get(0).selectedIndex; //获取Select选择的索引值
}
//获取Select最大的索引值
function Select_getMaxIndexID(selectID){
    var maxIndex=$("#"+selectID+" option:last").attr("index"); //获取Select最大的索引值
    return maxIndex;
}
//获 取select被选中项的文本
function SelectGroup_GetSelectText(items) {
    var item = $("select[name=items] option[selected]").text();
    return item;
}
