salix/modules/client/front/create/index.js

37 lines
960 B
JavaScript
Raw Normal View History

2017-06-03 11:01:47 +00:00
import ngModule from '../module';
2017-06-03 11:01:47 +00:00
export default class Controller {
constructor($scope, $state, $http) {
2017-06-03 11:01:47 +00:00
this.$ = $scope;
this.$state = $state;
this.$http = $http;
this.client = {
active: true
};
}
setLocation() {
const location = this.$.postcode.selection;
if (!location || !location.town) return;
const town = location.town;
const province = town.province;
const country = province.country;
this.client.city = location.town.name;
this.client.provinceFk = province.id;
this.client.countryFk = country.id;
}
onSubmit() {
2017-06-03 11:01:47 +00:00
this.$.watcher.submit().then(
2018-05-23 12:26:51 +00:00
json => this.$state.go('client.card.basicData', {id: json.data.id})
);
}
}
Controller.$inject = ['$scope', '$state', '$http'];
2017-06-03 11:01:47 +00:00
ngModule.component('vnClientCreate', {
2018-05-23 12:26:51 +00:00
template: require('./index.html'),
controller: Controller
2017-06-03 11:01:47 +00:00
});