Newer
Older
<template>
<div class="container-fluid">
<form v-on:submit.prevent="addClient">
<span class="row">
<label for="numSSInput">{{$t('clients.numss-input')}}</label>
<div class="col">
<input v-model="client.numSS" v-bind:placeholder="$t('clients.numss-input')" type="text" id="numSSInput" class="form-control form-control-sm input_ss" size="13"/>
<input v-model="client.cleSS" v-bind:placeholder="$t('clients.keyss-input')" type="number" id="cleSSInput" class="form-control form-control-sm input_key" min="0" max="99" value="00" size="2"/>
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
</div>
</span>
<span class="row">
<label for="lastNameInput">{{$t('clients.name-input')}}</label>
<input v-model="client.lastName" type="text" id="lastNameInput" class="form-control form-control-sm" v-bind:placeholder="$t('clients.name-input')"/>
</span>
<span class="row">
<label for="firstNameInput">{{$t('clients.firstname-input')}}</label>
<input v-model="client.firstName" type="text" id="firstNameInput" class="form-control form-control-sm" v-bind:placeholder="$t('clients.firstname-input')"/>
</span>
<span class="row">
<label for="birthDateInput">{{$t('clients.birthdate-input')}}</label>
<input v-model="client.birthDate" type="date" id="birthDateInput" class="form-control form-control-sm" v-bind:placeholder="$t('clients.birthdate-input')"/>
</span>
<span class="row">
<label for="birthDateInput">{{$t('clients.address-input')}}</label>
<input v-model="client.address" type="text" id="addressInput" class="form-control form-control-sm" v-bind:placeholder="$t('clients.address-input')"/>
</span>
<span class="row">
<label for="birthDateInput">{{$t('clients.address2-input')}}</label>
<input v-model="client.address2" type="text" id="address2Input" class="form-control form-control-sm" v-bind:placeholder="$t('clients.address2-input')"/>
</span>
<span class="row">
<label for="birthDateInput">{{$t('clients.zipcode-input')}}</label>
<input v-model="client.zipcode" type="text" id="zipcodeInput" class="form-control form-control-sm" v-bind:placeholder="$t('clients.zipcode-input')"/>
</span>
<span class="row">
<label for="birthDateInput">{{$t('clients.city-input')}}</label>
<input v-model="client.city" type="text" id="cityInput" class="form-control form-control-sm" v-bind:placeholder="$t('clients.city-input')"/>
</span>
<span class="row">
<label for="birthDateInput">{{$t('clients.cellphone-input')}}</label>
<input v-model="client.cellphone" type="tel" pattern="[0-9]{2} [0-9]{2} [0-9]{2} [0-9]{2} [0-9]{2}" id="cellphoneInput" class="form-control form-control-sm" v-bind:placeholder="$t('clients.cellphone-input')"/>
</span>
<span class="row">
<label for="birthDateInput">{{$t('clients.center-input')}}</label>
<input v-model="client.center" type="text" id="centerInput" class="form-control form-control-sm" v-bind:placeholder="$t('clients.center-input')"/>
</span>
<span class="row">
<label for="birthDateInput">{{$t('clients.viewAt-input')}}</label>
<input readonly v-model="client.viewAt" type="text" id="viewAtInput" class="form-control form-control-sm form-control-plaintext" v-bind:placeholder="$t('clients.viewAt-input')"/>
</span>
<!-- -->
<!-- <span class="row">
<label for="birthDateInput">{{$t('clients.')}}</label>
<input v-model="client.birthDate" type="date" id="birthDateInput" class="form-control form-control-sm" v-bind:placeholder="$t('clients.birthdate-input')"/>
</span> -->
<span class="row">
<button v-if="this.client.isEdit == false" type="submit" class="btn btn-success btn-block btn-sm mt-3" >{{$t('buttons.save-button')}}</button>
<button v-else v-on:click="updateClient()" type="button" class="btn btn-primary btn-block btn-sm mt-3" >{{$t('buttons.update-button')}}</button>
</span>
</form>
</div>
</template>
<script>
import axios from 'axios'
export default {
name: 'Client',
data () {
return {
uuid: '',
client: {
// uuid: undefined,
// numSS: '',
// cleSS: '',
// lastName: '',
// firstName: '',
// birthDate: '',
// address: '',
// address2: '',
// city: '',
// zipcode: '',
// cellphone: '',
// phone: '',
// center: '',
// viewAt: '',
// active: false,
// isEdit: false
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
}
}
},
mounted () {
if (this.$route.params.uuid !== undefined) {
this.uuid = this.$route.params.uuid
this.getClient(this.uuid)
} else {
}
},
methods: {
getClient (uuid) {
var url = '/api/clients/' + uuid
axios.get(url)
.then(result => {
this.mapClient(result.data)
},
error => { console.error(error) }
)
},
mapClient (pClient) {
debugger
console.log(pClient.birthDate)
this.client = pClient
var viewAt = new Date()
this.client.viewAt = viewAt
},
addClient () {
this.client.active = true
axios
.post('api/clients', this.client).then(res => {
this.client = {}
this.client.isEdit = false
this.getClients()
}).catch(err => { console.log(err) })
},
updateClient () {
axios
.put(`/api/clients/${this.client.uuid}`, this.client).then(res => {
this.client = {}
this.client.isEdit = false
this.getTasks()
console.log(res)
})
.catch(err => { console.log(err) })
},
deleteClient (uuid) {
axios
.delete(`/api/clients/${uuid}`).then(res => {
this.client = {}
this.getTasks()
console.log(res)
}).catch(err => { console.log(err) })
}
}
}
</script>
<style>
.input_ss { width: 9em; }
.input_key { width: 3em; }
.input_key input[type=number], input[type=number]::-webkit-inner-spin-button, input[type=number]::-webkit-outer-spin-button {
-moz-appearance: textfield;
-webkit-appearance: none;
margin: 0;
}