update company & crud budgets
This commit is contained in:
@@ -25,10 +25,12 @@
|
||||
|
||||
onMounted(() => {
|
||||
console.log('EditCompanyModal');
|
||||
console.log(companyStore.company)
|
||||
if(companyStore.company){
|
||||
companyCategories.value = companyStore.company.categories.map(m =>{
|
||||
return { name: m.name };
|
||||
});
|
||||
// companyCategories.value = companyStore.company.categories.map(m =>{
|
||||
// return { name: m.name };
|
||||
// });
|
||||
companyCategories.value = companyStore.company.categories;
|
||||
}
|
||||
if(companyStore.company){
|
||||
companyStates.value = companyStore.company.company_state.map(m =>{
|
||||
@@ -54,17 +56,34 @@
|
||||
description: companyStore.company?.company_description ?? '',
|
||||
});
|
||||
|
||||
const handleSave = () => {
|
||||
const handleSave = async() => {
|
||||
// const resp = editCompany()
|
||||
const resp = validations();
|
||||
if(resp !== '') {
|
||||
msgError.value = resp;
|
||||
clearMessages();
|
||||
} else {
|
||||
// $('#editcompanymodal').modal('toggle');
|
||||
document.getElementById('btnCloseEditCompany').click();
|
||||
notifications.show = true;
|
||||
notifications.text = 'Empresa actualizada';
|
||||
loading.value = true;
|
||||
let companyData = {
|
||||
is_company: companyStore.company._id,
|
||||
company_type: companyStore.company.company_type,
|
||||
meta_data: companyStore.company.meta_data,
|
||||
categories: company.segments,
|
||||
company_city: company.cities.map((e) => e.city_name),
|
||||
company_state: company.states.map((e) => e.state_name),
|
||||
truck_type: company.truckTypes.map((e) => e.meta_value),
|
||||
company_description: company.description
|
||||
};
|
||||
const result = await companyStore.editCompany(companyData);
|
||||
loading.value = false;
|
||||
if(result === 'success') {
|
||||
document.getElementById('btnCloseEditCompany').click();
|
||||
notifications.show = true;
|
||||
notifications.text = 'Empresa actualizada';
|
||||
} else {
|
||||
msgError.value === result;
|
||||
clearMessages();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,6 +108,7 @@
|
||||
|
||||
}
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -139,8 +159,11 @@
|
||||
:filled="false"
|
||||
v-model:field="company.description"
|
||||
/>
|
||||
|
||||
<input type="submit" value="Cuardar cambios" class="btn-primary-lg btn-lg-block my-4">
|
||||
<Spiner v-if="loading"/>
|
||||
<input
|
||||
v-else
|
||||
type="submit"
|
||||
value="Cuardar cambios" class="btn-primary-lg btn-lg-block my-4">
|
||||
</form>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
|
||||
Reference in New Issue
Block a user