var el = {
    form : '#form'
}
$(function () {
    //加载公司数据
    $('#companyCode').combobox({
        // valueField: 'companyCode',
        // textField: 'dataPrimary',
        // valueField: 'companyName',
        // textField: 'companyCode',
        // valueField: 'companyCode',
        // textField: 'companyCode',
        valueField: 'code',
        textField: 'codeWithDesc',
        url: g.ctx + 'pc/sys/company/rest/listAll',
        editable: false,
        prompt: '--- 请选择 ---',
        panelHeight: 'auto',
        panelWidth: 300,
        onSelect:function (data) {
            $('#companyName').textbox('setValue',data.companyName);
        }
    });
});
function saveOrUpdate(call) {
    if($(el.form).form('validate')){
        var formData = $(el.form).serializeJson();
        var loading = top.layer.msg('处理中', {icon: 16, shade: [0.1, '#000'], time: false});
        $.ajax({
            url: g.ctx + 'pc/sys/factory/rest/saveOrUpdate',
            method: 'post',
            data: formData,
            success: function (data) {
                call();
            },
            complete: function(data) {
                top.layer.close(loading);
            },
            error: function (data) {
                layer.alert(JSON.parse(data.responseText).message);
            }
        });
    }else{
        layer.msg("红色框为必输项，请填写！");
    }
}