remove state & city stuff, Add listener version200

This commit is contained in:
raishvaria
2019-11-25 13:46:57 +05:30
parent 3158955d00
commit ac431ca815
21 changed files with 450 additions and 764 deletions

View File

@ -163,15 +163,10 @@
<div class="form-group row">
<label class="col-sm-4 col-form-label input-label">{{ $t('customers.state') }}</label>
<div class="col-sm-7">
<base-select
v-model="billingState"
:options="billingStates"
:searchable="true"
:show-labels="false"
:placeholder="$t('general.select_state')"
:disabled="isDisabledBillingState"
track-by="id"
label="name"
<base-input
v-model="billing.state"
type="text"
name="billingState"
/>
</div>
</div>
@ -179,29 +174,14 @@
<div class="form-group row">
<label class="col-sm-4 col-form-label input-label">{{ $t('customers.city') }}</label>
<div class="col-sm-7">
<base-select
v-model="billingCity"
:options="billingCities"
:searchable="true"
:show-labels="false"
:placeholder="$t('general.select_city')"
:disabled="isDisabledBillingCity"
track-by="id"
label="name"
<base-input
v-model="billing.city"
type="text"
name="billingCity"
/>
</div>
</div>
<!-- <div class="form-group row">
<label class="col-sm-4 col-form-label">Zip Code</label>
<div class="col-sm-7">
<base-input
v-model="billing.zip"
type="text"
/>
</div>
</div> -->
<div class="form-group row">
<label class="col-sm-4 col-form-label input-label">{{ $t('customers.zip_code') }}</label>
<div class="col-sm-7">
@ -294,15 +274,10 @@
<div class="form-group row">
<label class="col-sm-4 col-form-label input-label">{{ $t('customers.state') }}</label>
<div class="col-sm-7">
<base-select
v-model="shippingState"
:options="shippingStates"
:searchable="true"
:show-labels="false"
:placeholder="$t('general.select_state')"
:disabled="isDisabledShippingState"
track-by="id"
label="name"
<base-input
v-model="shipping.state"
type="text"
name="shippingState"
/>
</div>
</div>
@ -310,15 +285,10 @@
<div class="form-group row">
<label class="col-sm-4 col-form-label input-label">{{ $t('customers.city') }}</label>
<div class="col-sm-7">
<base-select
v-model="shippingCity"
:options="shippingCities"
:searchable="true"
:show-labels="false"
:placeholder="$t('general.select_city')"
:disabled="isDisabledShippingCity"
track-by="id"
label="name"
<base-input
v-model="shipping.city"
type="text"
name="shippingCity"
/>
</div>
</div>
@ -372,16 +342,8 @@ export default {
return {
isLoading: false,
countryList: [],
billingStates: [],
billingCities: [],
billingCountry: null,
billingState: null,
billingCity: null,
shippingStates: [],
shippingCities: [],
shippingCountry: null,
shippingState: null,
shippingCity: null,
isCopyFromBilling: false,
currencyList: [],
currency: '',
@ -442,61 +404,14 @@ export default {
billingCountry () {
if (this.billingCountry) {
this.billing.country_id = this.billingCountry.id
this.isDisabledBillingState = false
this.fetchBillingStates(this.billingCountry.id)
this.billingState = null
this.billingCity = null
return true
}
},
billingState () {
if (this.billingState) {
this.billing.state_id = this.billingState.id
this.isDisabledBillingCity = false
this.fetchBillingCities(this.billingState.id)
this.billingCity = null
return true
}
this.billingCity = null
this.isDisabledBillingCity = true
},
billingCity () {
if (this.billingCity) {
this.billing.city_id = this.billingCity.id
}
},
shippingCountry () {
if (this.shippingCountry) {
this.shipping.country_id = this.shippingCountry.id
this.isDisabledShippingState = false
this.fetchShippingStates(this.shippingCountry.id)
if (this.isCopyFromBilling) {
return true
}
this.shippingState = null
this.shippingCity = null
return true
}
},
shippingState () {
if (this.shippingState) {
this.shipping.state_id = this.shippingState.id
this.isDisabledShippingCity = false
this.fetchShippingCities(this.shippingState.id)
if (this.isCopyFromBilling) {
this.isCopyFromBilling = false
return true
}
this.shippingCity = null
return true
}
this.shippingCity = null
this.isDisabledShippingCity = true
},
shippingCity () {
if (this.shippingCity) {
this.shipping.city_id = this.shippingCity.id
}
}
},
mounted () {
@ -529,16 +444,8 @@ export default {
addresses: []
}
this.billingStates = []
this.billingCities = []
this.billingCountry = null
this.billingState = null
this.billingCity = null
this.shippingStates = []
this.shippingCities = []
this.shippingCountry = null
this.shippingState = null
this.shippingCity = null
this.billing = {...AddressStub}
this.shipping = {...AddressStub}
@ -553,13 +460,9 @@ export default {
this.isCopyFromBilling = true
this.shipping = {...this.billing, type: 'shipping'}
this.shippingCountry = this.billingCountry
this.shippingState = this.billingState
this.shippingCity = this.billingCity
} else {
this.shipping = {...AddressStub, type: 'shipping'}
this.shippingCountry = null
this.shippingState = null
this.shippingCity = null
}
},
async loadData () {
@ -633,30 +536,6 @@ export default {
if (res) {
this.countryList = res.data.countries
}
},
async fetchBillingStates (id) {
let res = await window.axios.get(`/api/states/${id}`)
if (res) {
this.billingStates = res.data.states
}
},
async fetchBillingCities (id) {
let res = await window.axios.get(`/api/cities/${id}`)
if (res) {
this.billingCities = res.data.cities
}
},
async fetchShippingStates (id) {
let res = await window.axios.get(`/api/states/${id}`)
if (res) {
this.shippingStates = res.data.states
}
},
async fetchShippingCities (id) {
let res = await window.axios.get(`/api/cities/${id}`)
if (res) {
this.shippingCities = res.data.cities
}
}
}
}