Created
July 24, 2015 10:49
-
-
Save isnifer/a8fa1b104bd7cc963faa to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Метод для проверки валидности формы | |
* | |
* @param {Object} formCtrl контроллер формы | |
*/ | |
function isInvalidForm (formCtrl) { | |
return formCtrl.$invalid || (!isAccountablePerson() && !innerKontragents.KontragentId) | |
} | |
/** | |
* Метод сохранения первого шага оприходования | |
* | |
* @param {Object} formCtrl контроллер формы | |
*/ | |
function saveStep1 (formCtrl) { | |
if (isInvalidForm(formCtrl) || model.sending) { | |
return; | |
} | |
model.sending = true; | |
var data = { | |
Id: model.Id, | |
KontragentId: innerKontragents.KontragentId, | |
DogovorId: innerKontragents.DogovorId, | |
AccountablePerson: isAccountablePerson() ? model.AccountablePerson : null, | |
Kontragent: innerKontragents.Kontragent, | |
Nomenklatura: model.Nomenklatura.List, | |
DocumentSubTypeId: model.DocumentSubTypeId, | |
DocumentTypeId: model.DocumentTypeId, | |
Sum: model.Sum, | |
Date: model.Date, | |
Nomer: model.Nomer, | |
DraftState: model.DraftState | |
}; | |
data.Nomenklatura = _.filter(data.Nomenklatura, function (item) { | |
item.NomenklaturaTypeId = Number(model.NomenklaturaTypeId); | |
return !(!item.Name && !item.Qty && !item.TotalSum); | |
}); | |
data.Kontragent.Inn = data.Kontragent[data.Kontragent.isFiz ? 'InnFiz' : 'InnUr']; | |
inventory.saveStep1(data).success(function (response) { | |
if (response.Id) { | |
location.href = '/my/' + companyTranslitName + '/inventory/step2?id=' + response.Id; | |
} | |
}).finally(function () { | |
model.sending = false; | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment