
function saveUser(call){

    if($("#accountName").val()==''){
        alert(XTJCGL.GYSYHGL_YHZHBNWK);
        return ;
    }

    if($("#username").val()==''){
        alert(XTJCGL.GYSYHGL_XMBNWK);
        return ;
    }
    var url = g.ctx + "pc/sys/user/update";
    var userForm = {
        orgId:$("#orgId").val(),
        deptCode:$("#deptCodeId").val(),
        deptName:$("#deptCode").val(),
        id: $("#id").val(),
        accountName: $("#accountName").val(),
        username: $("#username").val(),
        sex: $("#sex option:selected").val(),
        userFlag: $("#userFlag option:selected").val(),
        email: $("#email").val(),
        cardId: $("#cardId").val(),
        birthday: $("#birthday").val(),
        educationalHistory: $("#educationalHistory").val(),
        professional: $("#professional").val(),
        position: $("#position").val(),
        phone: $("#phone").val(),
        startFromDate: $("#startFromDate").val(),
        supplierId: $("#supplierId").val(),
        description: $("#description").val()
    };
    $.ajax({
        url:  url,
        method:"POST",
        data: userForm,
        success: function (data) {
            topWin.layer.alert("保存成功",{icon: 1}, function (idx) {
                topWin.layer.close(idx);
                call();
            });
        },
        error: function (data) {
            topWin.layer.alert(data.responseJSON.message, {icon: 2});
        }
    });
}
function doSearch() {
    var userOrgyDialog = openDialog('userOrgyDialog', g.ctx + 'pc/sys/org/orgTree', {
        title: "组织部门",
        width: '400px',
        height: '700px',
        cache: false,
        modal: true,
        border: false,
        draggable: false,
        shadow: false,
        onClose: function () {
            userOrgyDialog.dialog('destroy');
        },
        buttons: [
            {
                text: itablei8n.save,
                handler: function () {
                    topWin.frames['userOrgyDialog'].confirm(function (cbox) {
                        setOrgValue(cbox.id, cbox.name, cbox.code);
                        userOrgyDialog.dialog('close');
                    });
                }
            },
            {
                text: itablei8n.close,
                handler: function () {
                    userOrgyDialog.dialog('close');
                }
            }
        ]
    });
}

function searchSupplier(){
    var userOrgyDialog = openDialog('userOrgyDialog', g.ctx + 'pc/supplier/supplierSelect?single=1', {
        title: "选择供应商",
        width: '800px',
        height: '500px',
        cache: false,
        modal: true,
        border: false,
        draggable: false,
        shadow: false,
        onClose: function () {
            userOrgyDialog.dialog('destroy');
        },
        buttons: [
            {
                text: itablei8n.confirm,
                handler: function () {
                    topWin.frames['userOrgyDialog'].chooseRow(function (cbox) {
                        $('#supplierId').val(cbox.id);
                        $('#supplierName').textbox('setValue', cbox.supplierName)
                        userOrgyDialog.dialog('close');
                    });
                }
            },
            {
                text: itablei8n.close,
                handler: function () {
                    userOrgyDialog.dialog('close');
                }
            }
        ]
    });
}
function setOrgValue(id, value, value1) {

    $("#orgId").val(id);
    /*      $('#deptCode').val(value);*/
    $("#deptCodeId").val(value1);
    $('#deptCode').textbox('setValue', value)
}

function setCompanyValue(value, value1) {

    $('#institutionId').val(value);
    $('#institution').textbox('setValue', value1)
}

