refs #5888 feat: add address-autocomplte in client and supplier fiscal-data
gitea/salix/pipeline/head There was a failure building this commit
Details
gitea/salix/pipeline/head There was a failure building this commit
Details
This commit is contained in:
parent
bd205418a0
commit
3073955517
|
@ -4,13 +4,17 @@
|
||||||
data="$ctrl.locations"
|
data="$ctrl.locations"
|
||||||
order="code">
|
order="code">
|
||||||
</vn-crud-model>
|
</vn-crud-model>
|
||||||
|
{{$ctrl.postCode}}
|
||||||
<vn-autocomplete
|
<vn-autocomplete
|
||||||
vn-two
|
vn-two
|
||||||
vn-id="location"
|
vn-id="location"
|
||||||
label="Location"
|
label="Location"
|
||||||
vn-name="location"
|
vn-name="location"
|
||||||
ng-model="$ctrl.postCode"
|
ng-model="$ctrl.postCode"
|
||||||
data="$ctrl.locations">
|
data="$ctrl.locations"
|
||||||
|
selection="$ctrl.selection"
|
||||||
|
show-field="name"
|
||||||
|
value-field="id">
|
||||||
<tpl-item class="address">
|
<tpl-item class="address">
|
||||||
<span>
|
<span>
|
||||||
{{::name}}
|
{{::name}}
|
||||||
|
@ -18,10 +22,16 @@
|
||||||
</tpl-item>
|
</tpl-item>
|
||||||
<append>
|
<append>
|
||||||
<vn-icon-button
|
<vn-icon-button
|
||||||
ui-sref="client.card.address.edit({id: $ctrl.clientId, addressId: $ctrl.addressId})"
|
ui-sref="postcode.open()"
|
||||||
icon="edit"
|
icon="add_circle"
|
||||||
vn-tooltip="Edit address">
|
vn-tooltip="New postcode">
|
||||||
</vn-icon-button>
|
</vn-icon-button>
|
||||||
</append>
|
</append>
|
||||||
</vn-autocomplete>
|
</vn-autocomplete>
|
||||||
|
|
||||||
|
<!-- New postcode dialog -->
|
||||||
|
<vn-geo-postcode
|
||||||
|
vn-id="postcode"
|
||||||
|
on-response="$ctrl.onResponse($response)">
|
||||||
|
</vn-geo-postcode>
|
||||||
|
|
||||||
|
|
|
@ -19,45 +19,56 @@ export default class AddressAutocomplete extends Component {
|
||||||
super(...args);
|
super(...args);
|
||||||
}
|
}
|
||||||
|
|
||||||
get addressData() {
|
|
||||||
return this._addressData;
|
|
||||||
}
|
|
||||||
|
|
||||||
set addressData(value) {
|
|
||||||
if (!value) return;
|
|
||||||
console.log(value);
|
|
||||||
this._addressData = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
get locations() {
|
get locations() {
|
||||||
return this._locations;
|
return this._locations;
|
||||||
}
|
}
|
||||||
|
|
||||||
set locations(value) {
|
set locations(value) {
|
||||||
if (!value) return;
|
if (!value) return;
|
||||||
console.log('set locations');
|
value = value.map(l => {
|
||||||
console.log(value);
|
|
||||||
for (let location of value) {
|
|
||||||
location.map(l => {
|
|
||||||
return {
|
return {
|
||||||
name: l.code + ' ' + l.town.name + ', ' + l.town.province.name + ', ' + l.town.province.country.name,
|
id: l.code,
|
||||||
|
name: l.code + ' ' + l.town.name + ', ' + l.town.province.name + ', ' + l.town.province.country.country,
|
||||||
postalCode: l.code,
|
postalCode: l.code,
|
||||||
townFk: l.town.id,
|
townFk: l.town.id,
|
||||||
|
townName: l.town.name,
|
||||||
provinceFk: l.town.province.id,
|
provinceFk: l.town.province.id,
|
||||||
|
provinceName: l.town.province.name,
|
||||||
countryFk: l.town.province.country.id,
|
countryFk: l.town.province.country.id,
|
||||||
|
countryName: l.town.province.country.country,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
}
|
|
||||||
console.log('location', location);
|
|
||||||
this._locations = value;
|
this._locations = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get postCode() {
|
||||||
|
return this._postCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
set postCode(value) {
|
||||||
|
if (!value) return;
|
||||||
|
this._postCode = value;
|
||||||
|
if (!this.locations) return;
|
||||||
|
const selection = this.locations.find(location => location.id == value);
|
||||||
|
this.town = selection.townFk;
|
||||||
|
this.townName = selection.townName;
|
||||||
|
this.province = selection.provinceFk;
|
||||||
|
this.provinceName = selection.provinceName;
|
||||||
|
this.country = selection.countryFk;
|
||||||
|
this.countryName = selection.countryName;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ngModule.vnComponent('vnAddressAutocomplete', {
|
ngModule.vnComponent('vnAddressAutocomplete', {
|
||||||
template: require('./index.html'),
|
template: require('./index.html'),
|
||||||
controller: AddressAutocomplete,
|
controller: AddressAutocomplete,
|
||||||
bindings: {
|
bindings: {
|
||||||
addressData: '<?',
|
postCode: '=?',
|
||||||
postCode: '<?'
|
town: '=?',
|
||||||
|
province: '=?',
|
||||||
|
country: '=?',
|
||||||
|
townName: '=?',
|
||||||
|
provinceName: '=?',
|
||||||
|
countryName: '=?',
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -137,6 +137,14 @@
|
||||||
rule>
|
rule>
|
||||||
</vn-autocomplete>
|
</vn-autocomplete>
|
||||||
</vn-horizontal>
|
</vn-horizontal>
|
||||||
|
<vn-horizontal>
|
||||||
|
<vn-address-autocomplete
|
||||||
|
label="Address"
|
||||||
|
post-code="$ctrl.client.postcode"
|
||||||
|
town-name="$ctrl.client.city"
|
||||||
|
province="$ctrl.client.provinceFk"
|
||||||
|
country="$ctrl.client.countryFk"/>
|
||||||
|
</vn-horizontal>
|
||||||
<vn-horizontal>
|
<vn-horizontal>
|
||||||
<vn-check
|
<vn-check
|
||||||
label="Active"
|
label="Active"
|
||||||
|
|
|
@ -193,10 +193,8 @@
|
||||||
<vn-horizontal>
|
<vn-horizontal>
|
||||||
<vn-address-autocomplete
|
<vn-address-autocomplete
|
||||||
label="Address"
|
label="Address"
|
||||||
address-data="$ctrl.supplier"
|
|
||||||
ng-model="$ctrl.supplier.postCode"
|
|
||||||
post-code="$ctrl.supplier.postCode"
|
post-code="$ctrl.supplier.postCode"
|
||||||
town="$ctrl.supplier.city"
|
town-name="$ctrl.supplier.city"
|
||||||
province="$ctrl.supplier.provinceFk"
|
province="$ctrl.supplier.provinceFk"
|
||||||
country="$ctrl.supplier.countryFk"
|
country="$ctrl.supplier.countryFk"
|
||||||
/>
|
/>
|
||||||
|
@ -241,8 +239,4 @@
|
||||||
</vn-button>
|
</vn-button>
|
||||||
</vn-button-bar>
|
</vn-button-bar>
|
||||||
</form>
|
</form>
|
||||||
<!-- New postcode dialog -->
|
|
||||||
<vn-geo-postcode
|
|
||||||
vn-id="postcode"
|
|
||||||
on-response="$ctrl.onResponse($response)">
|
|
||||||
</vn-geo-postcode>
|
|
||||||
|
|
|
@ -1,85 +1,9 @@
|
||||||
import ngModule from '../module';
|
import ngModule from '../module';
|
||||||
import Section from 'salix/components/section';
|
import Section from 'salix/components/section';
|
||||||
|
|
||||||
export default class Controller extends Section {
|
|
||||||
get province() {
|
|
||||||
return this._province;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Province auto complete
|
|
||||||
set province(selection) {
|
|
||||||
const oldValue = this._province;
|
|
||||||
this._province = selection;
|
|
||||||
|
|
||||||
if (!selection || !oldValue) return;
|
|
||||||
|
|
||||||
const country = selection.country;
|
|
||||||
|
|
||||||
if (!this.supplier.countryFk)
|
|
||||||
this.supplier.countryFk = country.id;
|
|
||||||
}
|
|
||||||
|
|
||||||
get town() {
|
|
||||||
return this._town;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Town auto complete
|
|
||||||
set town(selection) {
|
|
||||||
const oldValue = this._town;
|
|
||||||
this._town = selection;
|
|
||||||
|
|
||||||
if (!selection || !oldValue) return;
|
|
||||||
|
|
||||||
const province = selection.province;
|
|
||||||
const country = province.country;
|
|
||||||
const postcodes = selection.postcodes;
|
|
||||||
|
|
||||||
if (!this.supplier.provinceFk)
|
|
||||||
this.supplier.provinceFk = province.id;
|
|
||||||
|
|
||||||
if (!this.supplier.countryFk)
|
|
||||||
this.supplier.countryFk = country.id;
|
|
||||||
|
|
||||||
if (!this.supplier.postCode && postcodes.length === 1)
|
|
||||||
this.supplier.postCode = postcodes[0].code;
|
|
||||||
}
|
|
||||||
|
|
||||||
get postcode() {
|
|
||||||
return this._postcode;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Postcode auto complete
|
|
||||||
set postcode(selection) {
|
|
||||||
const oldValue = this._postcode;
|
|
||||||
this._postcode = selection;
|
|
||||||
|
|
||||||
if (!selection || !oldValue) return;
|
|
||||||
|
|
||||||
const town = selection.town;
|
|
||||||
const province = town.province;
|
|
||||||
const country = province.country;
|
|
||||||
|
|
||||||
if (!this.supplier.city)
|
|
||||||
this.supplier.city = town.name;
|
|
||||||
|
|
||||||
if (!this.supplier.provinceFk)
|
|
||||||
this.supplier.provinceFk = province.id;
|
|
||||||
|
|
||||||
if (!this.supplier.countryFk)
|
|
||||||
this.supplier.countryFk = country.id;
|
|
||||||
}
|
|
||||||
|
|
||||||
onResponse(response) {
|
|
||||||
this.supplier.postCode = response.code;
|
|
||||||
this.supplier.city = response.city;
|
|
||||||
this.supplier.provinceFk = response.provinceFk;
|
|
||||||
this.supplier.countryFk = response.countryFk;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ngModule.vnComponent('vnSupplierFiscalData', {
|
ngModule.vnComponent('vnSupplierFiscalData', {
|
||||||
template: require('./index.html'),
|
template: require('./index.html'),
|
||||||
controller: Controller,
|
controller: Section,
|
||||||
bindings: {
|
bindings: {
|
||||||
supplier: '<'
|
supplier: '<'
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue