better saving/loading in contracts and med feeds, handlers for adding med feed

This commit is contained in:
Paul Wilde 2023-03-23 20:46:24 +00:00
parent 43ab44794c
commit 64fcfff373
2 changed files with 20 additions and 12 deletions

View file

@ -69,9 +69,11 @@
<v-card-actions> <v-card-actions>
<v-btn v-if="!contract.isNew" color="red-darken-1" <v-btn v-if="!contract.isNew" color="red-darken-1"
variant="text" variant="text"
:loading="saving"
@click="saveContract(selected_contract)">Save</v-btn> @click="saveContract(selected_contract)">Save</v-btn>
<v-btn v-if="contract.isNew" color="red-darken-1" <v-btn v-if="contract.isNew" color="red-darken-1"
variant="text" variant="text"
:loading="saving"
@click="saveContract(selected_contract)">Add</v-btn> @click="saveContract(selected_contract)">Add</v-btn>
<v-spacer></v-spacer> <v-spacer></v-spacer>
<v-btn color="blue-darken-1" <v-btn color="blue-darken-1"
@ -167,7 +169,6 @@ export default {
}).then(resp => { }).then(resp => {
console.log("Saved Contract : " + JSON.stringify(resp.data)) console.log("Saved Contract : " + JSON.stringify(resp.data))
this.saving = false this.saving = false
if (resp.data == true) {
let stat = resp.data let stat = resp.data
if (stat.status == true ) { if (stat.status == true ) {
if (this.contract.isNew) { if (this.contract.isNew) {
@ -175,9 +176,6 @@ export default {
} else { } else {
this.$emit('contractupdate', resp.data) this.$emit('contractupdate', resp.data)
} }
} else {
this.errors.push("Error Saving... ")
}
} else { } else {
this.errors.push("Contract not saved.") this.errors.push("Contract not saved.")
console.log("Not Saved") console.log("Not Saved")

View file

@ -55,9 +55,11 @@
<v-card-actions> <v-card-actions>
<v-btn v-if="!mf.isNew" color="red-darken-1" <v-btn v-if="!mf.isNew" color="red-darken-1"
variant="text" variant="text"
:loading="saving"
@click="saveMedFeed(mf)">Save</v-btn> @click="saveMedFeed(mf)">Save</v-btn>
<v-btn v-if="mf.isNew" color="red-darken-1" <v-btn v-if="mf.isNew" color="red-darken-1"
variant="text" variant="text"
:loading="saving"
@click="saveMedFeed(mf)">Add</v-btn> @click="saveMedFeed(mf)">Add</v-btn>
<v-spacer></v-spacer> <v-spacer></v-spacer>
<v-btn color="blue-darken-1" <v-btn color="blue-darken-1"
@ -109,7 +111,8 @@ export default {
products: [], products: [],
search: [], search: [],
searching: {}, searching: {},
errors: [] errors: [],
saving: false
} }
}, },
computed: { computed: {
@ -128,7 +131,11 @@ export default {
}, },
saveMedFeed(medfeed) { saveMedFeed(medfeed) {
this.errors = [] this.errors = []
this.saving = true
let url = this.$api_url + "/customers/medicated-feeds/" + this.mf.id + "/save" 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...") console.log("Saving Med Feed...")
axios.put(url,{ axios.put(url,{
medfeed: medfeed medfeed: medfeed
@ -144,6 +151,9 @@ export default {
.catch(err => { .catch(err => {
console.log(err) console.log(err)
}) })
.finally(()=>{
this.saving = false
})
}, },
showCustomerSearch(){ showCustomerSearch(){
this.search[0] = true this.search[0] = true