better saving/loading in contracts and med feeds, handlers for adding med feed
This commit is contained in:
parent
43ab44794c
commit
64fcfff373
2 changed files with 20 additions and 12 deletions
|
@ -69,9 +69,11 @@
|
|||
<v-card-actions>
|
||||
<v-btn v-if="!contract.isNew" color="red-darken-1"
|
||||
variant="text"
|
||||
:loading="saving"
|
||||
@click="saveContract(selected_contract)">Save</v-btn>
|
||||
<v-btn v-if="contract.isNew" color="red-darken-1"
|
||||
variant="text"
|
||||
:loading="saving"
|
||||
@click="saveContract(selected_contract)">Add</v-btn>
|
||||
<v-spacer></v-spacer>
|
||||
<v-btn color="blue-darken-1"
|
||||
|
@ -167,18 +169,14 @@ export default {
|
|||
}).then(resp => {
|
||||
console.log("Saved Contract : " + JSON.stringify(resp.data))
|
||||
this.saving = false
|
||||
if (resp.data == true) {
|
||||
let stat = resp.data
|
||||
if (stat.status == true ) {
|
||||
if (this.contract.isNew) {
|
||||
this.$emit('contractupdate', resp.data)
|
||||
} else {
|
||||
this.$emit('contractupdate', resp.data)
|
||||
}
|
||||
let stat = resp.data
|
||||
if (stat.status == true ) {
|
||||
if (this.contract.isNew) {
|
||||
this.$emit('contractupdate', resp.data)
|
||||
} else {
|
||||
this.errors.push("Error Saving... ")
|
||||
this.$emit('contractupdate', resp.data)
|
||||
}
|
||||
} else {
|
||||
} else {
|
||||
this.errors.push("Contract not saved.")
|
||||
console.log("Not Saved")
|
||||
}
|
||||
|
|
|
@ -51,13 +51,15 @@
|
|||
</v-row>
|
||||
</v-container>
|
||||
</v-card-text>
|
||||
<ErrorBanner :errors="errors" />
|
||||
<ErrorBanner :errors="errors" />
|
||||
<v-card-actions>
|
||||
<v-btn v-if="!mf.isNew" color="red-darken-1"
|
||||
variant="text"
|
||||
:loading="saving"
|
||||
@click="saveMedFeed(mf)">Save</v-btn>
|
||||
<v-btn v-if="mf.isNew" color="red-darken-1"
|
||||
variant="text"
|
||||
:loading="saving"
|
||||
@click="saveMedFeed(mf)">Add</v-btn>
|
||||
<v-spacer></v-spacer>
|
||||
<v-btn color="blue-darken-1"
|
||||
|
@ -109,7 +111,8 @@ export default {
|
|||
products: [],
|
||||
search: [],
|
||||
searching: {},
|
||||
errors: []
|
||||
errors: [],
|
||||
saving: false
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
|
@ -128,7 +131,11 @@ export default {
|
|||
},
|
||||
saveMedFeed(medfeed) {
|
||||
this.errors = []
|
||||
this.saving = true
|
||||
let url = this.$api_url + "/customers/medicated-feeds/" + this.mf.id + "/save"
|
||||
if (this.contract.isNew) {
|
||||
url = this.$api_url + "/customers/medicated-feeds/add"
|
||||
}
|
||||
console.log("Saving Med Feed...")
|
||||
axios.put(url,{
|
||||
medfeed: medfeed
|
||||
|
@ -144,6 +151,9 @@ export default {
|
|||
.catch(err => {
|
||||
console.log(err)
|
||||
})
|
||||
.finally(()=>{
|
||||
this.saving = false
|
||||
})
|
||||
},
|
||||
showCustomerSearch(){
|
||||
this.search[0] = true
|
||||
|
|
Loading…
Reference in a new issue