Overhaul new custorder so contact may be either Person or Customer
also make the handler responsible for (un)assigning contact
This commit is contained in:
parent
12310da09e
commit
a52b5ec380
2 changed files with 202 additions and 91 deletions
|
@ -101,50 +101,63 @@
|
|||
|
||||
<br />
|
||||
<div class="field">
|
||||
<b-radio v-model="customerIsKnown"
|
||||
<b-radio v-model="contactIsKnown"
|
||||
:native-value="true">
|
||||
Customer is already in the system.
|
||||
</b-radio>
|
||||
</div>
|
||||
|
||||
<div v-show="customerIsKnown">
|
||||
<div v-show="contactIsKnown">
|
||||
<b-field label="Customer" horizontal>
|
||||
<tailbone-autocomplete ref="customerAutocomplete"
|
||||
v-model="customerUUID"
|
||||
<tailbone-autocomplete ref="contactAutocomplete"
|
||||
v-model="contactUUID"
|
||||
placeholder="Enter name or phone number"
|
||||
:initial-label="customerDisplay"
|
||||
:initial-label="contactDisplay"
|
||||
% if new_order_requires_customer:
|
||||
serviceUrl="${url('{}.customer_autocomplete'.format(route_prefix))}"
|
||||
@input="customerChanged">
|
||||
% else:
|
||||
serviceUrl="${url('{}.person_autocomplete'.format(route_prefix))}"
|
||||
% endif
|
||||
@input="contactChanged">
|
||||
</tailbone-autocomplete>
|
||||
<b-button v-if="contactUUID && contactProfileURL"
|
||||
type="is-primary"
|
||||
tag="a" target="_blank"
|
||||
:href="contactProfileURL"
|
||||
icon-pack="fas"
|
||||
icon-left="external-link-alt">
|
||||
View Profile
|
||||
</b-button>
|
||||
</b-field>
|
||||
<b-field label="Phone Number" horizontal
|
||||
v-show="customerUUID">
|
||||
<b-input v-model="phoneNumberEntry"
|
||||
@input="phoneNumberChanged"
|
||||
@keydown.native="phoneNumberKeyDown">
|
||||
</b-input>
|
||||
<b-button v-if="!phoneNumberSaved"
|
||||
type="is-primary"
|
||||
icon-pack="fas"
|
||||
icon-left="fas fa-save"
|
||||
@click="setCustomerData()">
|
||||
Please save when finished editing
|
||||
</b-button>
|
||||
<!-- <tailbone-autocomplete -->
|
||||
<!-- serviceUrl="${url('customers.autocomplete.phone')}"> -->
|
||||
<!-- </tailbone-autocomplete> -->
|
||||
v-show="contactUUID">
|
||||
{{ phoneNumberEntry }}
|
||||
## <b-input v-model="phoneNumberEntry"
|
||||
## @input="phoneNumberChanged"
|
||||
## @keydown.native="phoneNumberKeyDown">
|
||||
## </b-input>
|
||||
## <b-button v-if="!phoneNumberSaved"
|
||||
## type="is-primary"
|
||||
## icon-pack="fas"
|
||||
## icon-left="fas fa-save"
|
||||
## @click="setContactData()">
|
||||
## Please save when finished editing
|
||||
## </b-button>
|
||||
## <!-- <tailbone-autocomplete -->
|
||||
## <!-- serviceUrl="${url('customers.autocomplete.phone')}"> -->
|
||||
## <!-- </tailbone-autocomplete> -->
|
||||
</b-field>
|
||||
</div>
|
||||
|
||||
<br />
|
||||
<div class="field">
|
||||
<b-radio v-model="customerIsKnown" disabled
|
||||
<b-radio v-model="contactIsKnown" disabled
|
||||
:native-value="false">
|
||||
Customer is not yet in the system.
|
||||
</b-radio>
|
||||
</div>
|
||||
|
||||
<div v-if="!customerIsKnown">
|
||||
<div v-if="!contactIsKnown">
|
||||
<b-field label="Customer Name" horizontal>
|
||||
<b-input v-model="customerName"></b-input>
|
||||
</b-field>
|
||||
|
@ -382,10 +395,11 @@
|
|||
batchTotalPriceDisplay: ${json.dumps(normalized_batch['total_price_display'])|n},
|
||||
|
||||
customerPanelOpen: false,
|
||||
customerIsKnown: true,
|
||||
customerUUID: ${json.dumps(batch.customer_uuid)|n},
|
||||
customerDisplay: ${json.dumps(six.text_type(batch.customer or ''))|n},
|
||||
contactIsKnown: true,
|
||||
contactUUID: ${json.dumps(batch.customer_uuid)|n},
|
||||
contactDisplay: ${json.dumps(six.text_type(batch.customer or ''))|n},
|
||||
customerEntry: null,
|
||||
contactProfileURL: ${json.dumps(contact_profile_url)|n},
|
||||
phoneNumberEntry: ${json.dumps(batch.phone_number)|n},
|
||||
phoneNumberSaved: true,
|
||||
customerName: null,
|
||||
|
@ -415,12 +429,12 @@
|
|||
customerPanelHeader() {
|
||||
let text = "Customer"
|
||||
|
||||
if (this.customerIsKnown) {
|
||||
if (this.customerUUID) {
|
||||
if (this.$refs.customerAutocomplete) {
|
||||
text = "Customer: " + this.$refs.customerAutocomplete.getDisplayText()
|
||||
if (this.contactIsKnown) {
|
||||
if (this.contactUUID) {
|
||||
if (this.$refs.contactAutocomplete) {
|
||||
text = "Customer: " + this.$refs.contactAutocomplete.getDisplayText()
|
||||
} else {
|
||||
text = "Customer: " + this.customerDisplay
|
||||
text = "Customer: " + this.contactDisplay
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -457,8 +471,8 @@
|
|||
},
|
||||
customerStatusTypeAndText() {
|
||||
let phoneNumber = null
|
||||
if (this.customerIsKnown) {
|
||||
if (!this.customerUUID) {
|
||||
if (this.contactIsKnown) {
|
||||
if (!this.contactUUID) {
|
||||
return {
|
||||
type: 'is-danger',
|
||||
text: "Please identify the customer.",
|
||||
|
@ -495,7 +509,7 @@
|
|||
}
|
||||
}
|
||||
|
||||
if (!this.customerIsKnown) {
|
||||
if (!this.contactIsKnown) {
|
||||
return {
|
||||
type: 'is-warning',
|
||||
text: "Will create a new customer record.",
|
||||
|
@ -555,8 +569,8 @@
|
|||
// return
|
||||
// }
|
||||
// }
|
||||
// this.customerIsKnown = true
|
||||
// this.customerUUID = null
|
||||
// this.contactIsKnown = true
|
||||
// this.contactUUID = null
|
||||
// // this.customerEntry = null
|
||||
// this.phoneNumberEntry = null
|
||||
// this.customerName = null
|
||||
|
@ -607,17 +621,17 @@
|
|||
})
|
||||
},
|
||||
|
||||
setCustomerData() {
|
||||
let params = {
|
||||
action: 'set_customer_data',
|
||||
customer_uuid: this.customerUUID,
|
||||
phone_number: this.phoneNumberEntry,
|
||||
}
|
||||
let that = this
|
||||
this.submitBatchData(params, function(response) {
|
||||
that.phoneNumberSaved = true
|
||||
})
|
||||
},
|
||||
// setContactData() {
|
||||
// let params = {
|
||||
// action: 'set_customer_data',
|
||||
// customer_uuid: this.contactUUID,
|
||||
// phone_number: this.phoneNumberEntry,
|
||||
// }
|
||||
// let that = this
|
||||
// this.submitBatchData(params, function(response) {
|
||||
// that.phoneNumberSaved = true
|
||||
// })
|
||||
// },
|
||||
|
||||
submitOrder() {
|
||||
this.submittingOrder = true
|
||||
|
@ -644,32 +658,40 @@
|
|||
})
|
||||
},
|
||||
|
||||
customerChanged(uuid) {
|
||||
contactChanged(uuid) {
|
||||
let params
|
||||
if (!uuid) {
|
||||
this.phoneNumberEntry = null
|
||||
this.setCustomerData()
|
||||
} else {
|
||||
let params = {
|
||||
action: 'get_customer_info',
|
||||
uuid: this.customerUUID,
|
||||
params = {
|
||||
action: 'unassign_contact',
|
||||
}
|
||||
} else {
|
||||
params = {
|
||||
action: 'assign_contact',
|
||||
uuid: this.contactUUID,
|
||||
}
|
||||
let that = this
|
||||
this.submitBatchData(params, function(response) {
|
||||
that.phoneNumberEntry = response.data.phone_number
|
||||
that.setCustomerData()
|
||||
})
|
||||
}
|
||||
let that = this
|
||||
this.submitBatchData(params, function(response) {
|
||||
console.log(response.data)
|
||||
% if new_order_requires_customer:
|
||||
that.contactUUID = response.data.customer_uuid
|
||||
% else:
|
||||
that.contactUUID = response.data.person_uuid
|
||||
% endif
|
||||
that.phoneNumberEntry = response.data.phone_number
|
||||
that.contactProfileURL = response.data.contact_profile_url
|
||||
})
|
||||
},
|
||||
|
||||
phoneNumberChanged(value) {
|
||||
this.phoneNumberSaved = false
|
||||
},
|
||||
// phoneNumberChanged(value) {
|
||||
// this.phoneNumberSaved = false
|
||||
// },
|
||||
|
||||
phoneNumberKeyDown(event) {
|
||||
if (event.which == 13) { // Enter
|
||||
this.setCustomerData()
|
||||
}
|
||||
},
|
||||
// phoneNumberKeyDown(event) {
|
||||
// if (event.which == 13) { // Enter
|
||||
// this.setContactData()
|
||||
// }
|
||||
// },
|
||||
|
||||
showAddItemDialog() {
|
||||
this.editingItem = null
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue