
var layer_index;
function addUser(title, id) {
    //alert('3');
    $("#jswintitle").html(title);
    layer_index = layer.open({
        type: 1,
        title: false,
        closeBtn: 0,
        shift: false,
        //offset: 'lt',//设置弹出框的位置
       // offset: 't',
        //offset: ['15%', '20%'],
       // fix: false,
        //move: true,
        offset: '-120px',
       // maxmin: true,
       // area: ['380px', '90%'],
        content: $("#jsAddUser"),
        
    });
    $("#id").val(id);
    //如果是新增     area: ['900px', '100px'],
    if (id == "0") {
      
        $("#fvhpmc").val("");
        $("#fvcode").val("");
     
    }
    else {//是修改，调用getuser()
        getuser(id);
    }
}
//AJAX读取货品信息
function getuser(id) {

    var1 = "beduajax.aspx?ACT=F433EA6C62930A105DD91040C8ADFC78&id=" + id;
    var1 = encodeURI((var1));
    $.ajax({
        type: "Post",
        url: var1,
        data: { data1: '13D17C93EDB', },
        cache: false,
        contentType: "application/x-www-form-urlencoded; charset=UTF-8",
        success: function (temptext) {
            var arr = new Array();
            arr = temptext.split("|");
            //0货品名称|1助记码|2类别|3供货商|4生产商|5单位|6库存上限|7库存下限   |8审核人id |9三证档案|10备注说明
            $("#fvhpmc").val(arr[0]);
            $("#fvcode").val(arr[1]);
            $("#fvhplb").val(arr[2]);
            $("#fvhplb1").val(arr[2]);

            $("#fvghsm").val(arr[3]);
            $("#fvghsm1").val(arr[3]);

            $("#fvscsm").val(arr[4]);
            $("#fvscsm1").val(arr[4]);

            $("#fvdwmc").val(arr[5]);
            $("#fvdwmc1").val(arr[5]);

            $("#fikcsx").val(arr[6]);
            $("#fikcxx").val(arr[7]);
            $("#fishid").val(arr[8]);
            $("#fvszda").val(arr[9]);
            $("#fvbzsm").val(arr[10]);
            //fidxsl

        }
    });


}

//AJAX读取汉字首字母
function getsjm(hz) {

    var1 = "beduajax.aspx?ACT=F8800B7C1D0A5F9FD2B267E192781F51&hz=" + $("#fvhpmc").val();
    var1 = encodeURI((var1));
    $.ajax({
        type: "Post",
        url: var1,
        data: { data1: '13D17C93EDB', },
        cache: false,
        contentType: "application/x-www-form-urlencoded; charset=UTF-8",
        success: function (temptext) {

            $("#fvcode").val(temptext);

        }
    });
}

//关闭弹出
function cansleAdd() {
    layer.close(layer_index);
    clearWin();
}
//清除窗体中内容
function clearWin() {
    $("#jsAddUser").find("input").each(function () {
        $(this).val("");
    });
}
//
//类别选择框


//发送AJAX
function Zsend(var1) {

    temptext = var1;
    layer.msg(temptext, { icon: 1, btn: ['确定'] }, function () {
        if (temptext.indexOf("成功") > -1) {
            window.location.reload();
        }
        if (temptext.indexOf("相同货品") > -1) {
           
            $("#fvhpmc").select();
            $("#fvhpmc").focus();

        }
        return true;
    });
}
function ZDELESELE(id) {
    layer.confirm('确认要删除吗？', {
        icon: 3, btn: ['确定', '取消'] //按钮
    }, function () {
        temp = ZQDdele(id);
    });
}

function ZQDdele(id) {//删除
    var1 = "beduajax.aspx?ACT=A24F8C7B04925D7295E248489C4F3DEE&id=" + id;
    var temptext = "";
    var1 = encodeURI((var1));
    $.ajax({
        type: "Post",
        url: var1,
        data: { data1: '13D17C93EDB', },
        cache: false,
        contentType: "application/x-www-form-urlencoded; charset=UTF-8",
        success: function (temptext) {
            layer.msg(temptext, { icon: 1, btn: ['确定'] }, function () {
                if (temptext.indexOf("成功删除货品") > -1) {
                    window.location.reload();
                }
                return true;
            });
        }
    });


}

function ZALLRZ() {// 全部记录
    window.location.href = "dhpsz.aspx";
}

function ZJLCX() {// 条件查询
    var fvcode = "";
    var fvhplb = "";

    var fvghsm = "";
    var fvscsm = "";
    var fishid = "";


    if ($("#fvcode2").val() != "")
    { fvcode = $("#fvcode2").val(); }

    if ($("#fvhplb2").val() != "")
    {
        fvhplb = $("#fvhplb2").val();
       // fvhplb = $("#fvhplb2").val();
    }

    if ($("#fvghsm2").val() != "")
    { fvghsm = $("#fvghsm2").val(); }

    if ($("#fvscsm2").val() != "")
    { fvscsm = $("#fvscsm2").val(); }

    if ($("#fishid2").val() != "")
    {
        fishid = $("#fishid2").val();
       // fishid = FormatDate($("#fishid2").val());
    }

    window.location.href = "dhpsz.aspx?fvcode=" + fvcode + "&fvhplb=" + fvhplb + "&fvghsm=" + fvghsm + "&fvscsm=" + fvscsm + "&fishid=" + fishid;
}


