salix/client/route/src/zone/create/index.js

35 lines
933 B
JavaScript
Raw Normal View History

2018-09-19 13:05:07 +00:00
import ngModule from '../../module';
export default class Controller {
constructor($scope, $state, $http) {
this.$scope = $scope;
this.$state = $state;
this.$http = $http;
this.zone = {
travelingDays: 0,
price: 0.50,
bonus: 0.50
};
}
onSubmit() {
this.$scope.watcher.check();
let data = Object.assign({}, this.zone);
data.hour = new Date(this.zone.hour);
this.$http.post('/route/api/Zones', data).then(res => {
this.$scope.watcher.updateOriginalData();
this.$scope.watcher.setPristine();
this.$scope.watcher.notifySaved();
this.$state.go('zone.card.basicData', {id: res.data.id});
});
}
}
Controller.$inject = ['$scope', '$state', '$http'];
ngModule.component('vnZoneCreate', {
template: require('./index.html'),
controller: Controller
});