(function() {
    BemsWebApplication.FmsMaterialPurchaseRequestViewModel = function(data) {
            this.SiteId = ko.observable();
            this.BusinessFieldId = ko.observable();
            this.PurchaseRequestId = ko.observable();
            this.PurchaseTypeId = ko.observable();
            this.RequestDate = ko.observable();
            this.RequestUserId = ko.observable();
            this.PurchaseHopeDate = ko.observable();
            this.Title = ko.observable();
            this.Reason = ko.observable();
            this.ProgressId = ko.observable();
            this.ApprovalDate = ko.observable();
            this.ApprovalUserId = ko.observable();
            this.bSameOrder = ko.observable();
            if(data)
                this.fromJS(data);
    };

    $.extend(BemsWebApplication.FmsMaterialPurchaseRequestViewModel.prototype, {
        toJS: function() {
            return {
                SiteId: this.SiteId(),
                BusinessFieldId: this.BusinessFieldId(),
                PurchaseRequestId: this.PurchaseRequestId(),
                PurchaseTypeId: this.PurchaseTypeId(),
                RequestDate: this.RequestDate(),
                RequestUserId: this.RequestUserId(),
                PurchaseHopeDate: this.PurchaseHopeDate(),
                Title: this.Title(),
                Reason: this.Reason(),
                ProgressId: this.ProgressId(),
                ApprovalDate: this.ApprovalDate(),
                ApprovalUserId: this.ApprovalUserId(),
                bSameOrder: this.bSameOrder(),
            };
        },

        fromJS: function(data) {
            if(data) {
                this.SiteId(data.SiteId);
                this.BusinessFieldId(data.BusinessFieldId);
                this.PurchaseRequestId(data.PurchaseRequestId);
                this.PurchaseTypeId(data.PurchaseTypeId);
                this.RequestDate(data.RequestDate);
                this.RequestUserId(data.RequestUserId);
                this.PurchaseHopeDate(data.PurchaseHopeDate);
                this.Title(data.Title);
                this.Reason(data.Reason);
                this.ProgressId(data.ProgressId);
                this.ApprovalDate(data.ApprovalDate);
                this.ApprovalUserId(data.ApprovalUserId);
                this.bSameOrder(data.bSameOrder);
            }
        }
    });
})();