Correcciones menores
This commit is contained in:
parent
004836ece7
commit
a3c6d0e584
@ -20,9 +20,10 @@ const form = useForm({
|
||||
maternal: '',
|
||||
email: '',
|
||||
phone: '',
|
||||
hire_date: '',
|
||||
password: '',
|
||||
roles: [],
|
||||
departmen_id: '',
|
||||
department_id: '',
|
||||
});
|
||||
|
||||
const roles = ref([]);
|
||||
@ -33,7 +34,7 @@ function submit() {
|
||||
form.transform(data => ({
|
||||
...data,
|
||||
roles: data.roles.map(role => role.id),
|
||||
departmen_id: data.departmen_id?.id
|
||||
department_id: data.department_id?.id
|
||||
})).post(apiTo('store'), {
|
||||
onSuccess: () => {
|
||||
Notify.success(Lang('register.create.onSuccess'))
|
||||
@ -55,7 +56,6 @@ onMounted(() => {
|
||||
},
|
||||
{
|
||||
onSuccess: (r) => {
|
||||
console.log(r);
|
||||
departments.value = r['department:all'] ?? [];
|
||||
}
|
||||
}
|
||||
@ -97,8 +97,8 @@ onMounted(() => {
|
||||
multiple
|
||||
/>
|
||||
<Selectable
|
||||
v-model="form.departmen_id"
|
||||
title="Departamentos"
|
||||
v-model="form.department_id"
|
||||
title="Departamento"
|
||||
:options="departments"
|
||||
/>
|
||||
</Form>
|
||||
|
||||
@ -1,11 +1,12 @@
|
||||
<script setup>
|
||||
import { onMounted } from 'vue';
|
||||
import { onMounted, ref } from 'vue';
|
||||
import { RouterLink, useRoute, useRouter } from 'vue-router';
|
||||
import { api, useForm } from '@Services/Api';
|
||||
import { viewTo, apiTo , transl } from './Module';
|
||||
|
||||
import IconButton from '@Holos/Button/Icon.vue'
|
||||
import PageHeader from '@Holos/PageHeader.vue';
|
||||
import Selectable from '@Holos/Form/Selectable.vue';
|
||||
import Form from './Form.vue'
|
||||
|
||||
/** Definiciones */
|
||||
@ -19,12 +20,19 @@ const form = useForm({
|
||||
paternal: '',
|
||||
maternal: '',
|
||||
email: '',
|
||||
hire_date: '',
|
||||
phone: '',
|
||||
department_id: '',
|
||||
});
|
||||
|
||||
const departments = ref([]);
|
||||
|
||||
/** Métodos */
|
||||
function submit() {
|
||||
form.put(apiTo('update', { user: form.id }), {
|
||||
form.transform(data => ({
|
||||
...data,
|
||||
department_id: data.department_id?.id
|
||||
})).put(apiTo('update', { user: form.id }), {
|
||||
onSuccess: () => {
|
||||
Notify.success(Lang('register.edit.onSuccess'))
|
||||
router.push(viewTo({ name: 'index' }));
|
||||
@ -34,8 +42,24 @@ function submit() {
|
||||
|
||||
onMounted(() => {
|
||||
api.get(apiTo('show', { user: vroute.params.id }), {
|
||||
onSuccess: (r) => form.fill(r.user)
|
||||
onSuccess: (r) => {
|
||||
form.fill(r.user)
|
||||
form.department_id = r.user.department
|
||||
if (r.user.hire_date) {
|
||||
form.hire_date = new Date(r.user.hire_date).toISOString().split('T')[0]
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
api.catalog({
|
||||
'department:all': null,
|
||||
},
|
||||
{
|
||||
onSuccess: (r) => {
|
||||
departments.value = r['department:all'] ?? [];
|
||||
}
|
||||
}
|
||||
);
|
||||
})
|
||||
</script>
|
||||
|
||||
@ -54,5 +78,11 @@ onMounted(() => {
|
||||
action="update"
|
||||
:form="form"
|
||||
@submit="submit"
|
||||
/>
|
||||
>
|
||||
<Selectable
|
||||
v-model="form.department_id"
|
||||
title="Departamento"
|
||||
:options="departments"
|
||||
/>
|
||||
</Form>
|
||||
</template>
|
||||
|
||||
@ -61,6 +61,13 @@ function submit() {
|
||||
:onError="form.errors.email"
|
||||
required
|
||||
/>
|
||||
<Input
|
||||
v-model="form.hire_date"
|
||||
id="hire_date"
|
||||
:onError="form.errors.hire_date"
|
||||
type="date"
|
||||
required
|
||||
/>
|
||||
<slot />
|
||||
<div class="col-span-1 md:col-span-2 lg:col-span-3 xl:col-span-4 flex flex-col items-center justify-end space-y-4 mt-4">
|
||||
<PrimaryButton
|
||||
|
||||
@ -72,7 +72,7 @@ onMounted(() => {
|
||||
<td>{{ model.full_name }}</td>
|
||||
<td>{{ model.department?.name }}</td>
|
||||
<td>{{ model.headquarter }}</td>
|
||||
<td>{{ getDate(model.hire_date) }}</td>
|
||||
<td>{{ model.hire_date ? getDate(model.hire_date) : '-' }}</td>
|
||||
<td class="py-6">
|
||||
<span
|
||||
class="inline-block px-3 py-1 rounded-full text-xs font-semibold bg-green-100 text-green-700 dark:bg-success-d dark:text-success-dt">
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user