| Server IP : 34.87.99.72 / Your IP : 216.73.217.31 Web Server : Apache/2.4.46 (Unix) OpenSSL/1.1.1n System : Linux zlock-bitnami-lamp-prod-v2-vm 4.19.0-16-cloud-amd64 #1 SMP Debian 4.19.181-1 (2021-03-19) x86_64 User : bitnami ( 1000) PHP Version : 7.4.18 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : OFF Directory : /opt/bitnami/apache/htdocs/app/resources/js/views/LockerBoxes/ |
Upload File : |
<template>
<div>
<v-card class="radius-10">
<v-card-title>
<span class="headline">{{ (action == 'edit') ? 'Edit Locker Box' : 'New Locker Box' }}</span>
</v-card-title>
<v-divider class="mb-2"></v-divider>
<v-card-text class="py-4">
<v-row dense>
<v-col cols="12" md="12">
<v-text-field
:value="form.box_no"
label="Box No" placeholder="Box No"
dense
disabled
:error-messages="errors.box_no"
></v-text-field>
</v-col>
<v-col cols="12" md="12">
<v-select
v-model="form.box_type_id"
label="Type"
:items="availableBoxTypes"
item-value="id" item-text="title"
dense
clearable
:error-messages="errors.box_type_id"
>
<template #item="data">
<v-list>
<v-list-item-content>
<v-list-item-title v-text="data.item.title"></v-list-item-title>
<v-list-item-subtitle v-text="data.item.dimension"></v-list-item-subtitle>
</v-list-item-content>
</v-list>
</template>
</v-select>
</v-col>
</v-row>
</v-card-text>
<v-card-actions>
<v-spacer></v-spacer>
<v-btn
color="blue darken-1" text title="Cancel"
@click="closeDialog()"
>
Cancel
</v-btn>
<v-btn
color="blue darken-1"
text title="Save"
:loading="submit_loading"
@click="submitForm(form)"
>
Save
</v-btn>
</v-card-actions>
</v-card>
</div>
</template>
<script>
import { errorHandlerMixin } from "@/js/mixins/ErrorHandlerMixin"
export default{
mixins: [
errorHandlerMixin
],
props:{
visible: {
type: Boolean,
required: true,
},
item: {
type: Object,
required: true,
default: ()=>{
return {}
}
},
action: {
type: String,
required: true,
},
availableBoxTypes: {
type: Array,
required: true,
default: ()=>{
return []
}
},
},
data () {
return {
form : {},
errors : {},
submit_loading : false,
}
},
watch:{
'item':{
handler(){
this.form = this.item
},
immediate: true,
},
'visible':{
handler: function (newVal){
if(!newVal){
// reset
this.form = {}
this.errors = {}
}
},
immediate : true,
},
},
created(){
},
methods: {
initialize(){
this.closeDialog()
this.$emit('initialize')
},
closeDialog(){
this.$emit('update:visible',false)
},
submitForm(item){
this.saveModel(item)
},
saveModel(){
this.submit_loading = true
this.errors = {}
let payload = {
id : this.form.id,
box_type_id : this.form.box_type_id
}
let theApi = this.$api.updateLockerBox(payload)
theApi.then((res)=>{
this.$toast.success(res.data.message)
this.initialize()
}).catch((err) => {
this.errors = this.errorHandler_(err, Object.keys(payload))
}).finally(()=>{
this.submit_loading = false
})
},
}
}
</script>