Merge branch 'dev' into 6321_negative_tickets
This commit is contained in:
commit
d7b9a01c57
|
@ -1,6 +1,6 @@
|
|||
export default {
|
||||
mounted: function (el, binding) {
|
||||
const shortcut = binding.value ?? '+';
|
||||
mounted(el, binding) {
|
||||
const shortcut = binding.value || '+';
|
||||
|
||||
const { key, ctrl, alt, callback } =
|
||||
typeof shortcut === 'string'
|
||||
|
@ -8,25 +8,24 @@ export default {
|
|||
key: shortcut,
|
||||
ctrl: true,
|
||||
alt: true,
|
||||
callback: () =>
|
||||
document
|
||||
.querySelector(`button[shortcut="${shortcut}"]`)
|
||||
?.click(),
|
||||
callback: () => el?.click(),
|
||||
}
|
||||
: binding.value;
|
||||
|
||||
if (!el.hasAttribute('shortcut')) {
|
||||
el.setAttribute('shortcut', key);
|
||||
}
|
||||
|
||||
const handleKeydown = (event) => {
|
||||
if (event.key === key && (!ctrl || event.ctrlKey) && (!alt || event.altKey)) {
|
||||
callback();
|
||||
}
|
||||
};
|
||||
|
||||
// Attach the event listener to the window
|
||||
window.addEventListener('keydown', handleKeydown);
|
||||
|
||||
el._handleKeydown = handleKeydown;
|
||||
},
|
||||
unmounted: function (el) {
|
||||
unmounted(el) {
|
||||
if (el._handleKeydown) {
|
||||
window.removeEventListener('keydown', el._handleKeydown);
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ const { t } = useI18n();
|
|||
const bicInputRef = ref(null);
|
||||
const state = useState();
|
||||
|
||||
const customer = computed(() => state.get('customer'));
|
||||
const customer = computed(() => state.get('Customer'));
|
||||
|
||||
const countriesFilter = {
|
||||
fields: ['id', 'name', 'code'],
|
||||
|
|
|
@ -84,7 +84,7 @@ const $props = defineProps({
|
|||
},
|
||||
reload: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
default: true,
|
||||
},
|
||||
defaultTrim: {
|
||||
type: Boolean,
|
||||
|
@ -97,7 +97,7 @@ const $props = defineProps({
|
|||
});
|
||||
const emit = defineEmits(['onFetch', 'onDataSaved']);
|
||||
const modelValue = computed(
|
||||
() => $props.model ?? `formModel_${route?.meta?.title ?? route.name}`
|
||||
() => $props.model ?? `formModel_${route?.meta?.title ?? route.name}`,
|
||||
).value;
|
||||
const componentIsRendered = ref(false);
|
||||
const arrayData = useArrayData(modelValue);
|
||||
|
@ -105,8 +105,8 @@ const isLoading = ref(false);
|
|||
// Si elegimos observar los cambios del form significa que inicialmente las actions estaran deshabilitadas
|
||||
const isResetting = ref(false);
|
||||
const hasChanges = ref(!$props.observeFormChanges);
|
||||
const originalData = ref({});
|
||||
const formData = computed(() => state.get(modelValue));
|
||||
const originalData = computed(() => state.get(modelValue));
|
||||
const formData = ref({});
|
||||
const defaultButtons = computed(() => ({
|
||||
save: {
|
||||
dataCy: 'saveDefaultBtn',
|
||||
|
@ -127,8 +127,6 @@ const defaultButtons = computed(() => ({
|
|||
}));
|
||||
|
||||
onMounted(async () => {
|
||||
originalData.value = JSON.parse(JSON.stringify($props.formInitialData ?? {}));
|
||||
|
||||
nextTick(() => (componentIsRendered.value = true));
|
||||
|
||||
// Podemos enviarle al form la estructura de data inicial sin necesidad de fetchearla
|
||||
|
@ -148,7 +146,7 @@ onMounted(async () => {
|
|||
JSON.stringify(newVal) !== JSON.stringify(originalData.value);
|
||||
isResetting.value = false;
|
||||
},
|
||||
{ deep: true }
|
||||
{ deep: true },
|
||||
);
|
||||
}
|
||||
});
|
||||
|
@ -156,16 +154,24 @@ onMounted(async () => {
|
|||
if (!$props.url)
|
||||
watch(
|
||||
() => arrayData.store.data,
|
||||
(val) => updateAndEmit('onFetch', val)
|
||||
(val) => updateAndEmit('onFetch', val),
|
||||
);
|
||||
|
||||
watch(
|
||||
originalData,
|
||||
(val) => {
|
||||
if (val) formData.value = JSON.parse(JSON.stringify(val));
|
||||
},
|
||||
{ immediate: true },
|
||||
);
|
||||
|
||||
watch(
|
||||
() => [$props.url, $props.filter],
|
||||
async () => {
|
||||
originalData.value = null;
|
||||
state.set(modelValue, null);
|
||||
reset();
|
||||
await fetch();
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
onBeforeRouteLeave((to, from, next) => {
|
||||
|
@ -197,7 +203,6 @@ async function fetch() {
|
|||
updateAndEmit('onFetch', data);
|
||||
} catch (e) {
|
||||
state.set(modelValue, {});
|
||||
originalData.value = {};
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
@ -236,6 +241,7 @@ async function saveAndGo() {
|
|||
}
|
||||
|
||||
function reset() {
|
||||
formData.value = JSON.parse(JSON.stringify(originalData.value));
|
||||
updateAndEmit('onFetch', originalData.value);
|
||||
if ($props.observeFormChanges) {
|
||||
hasChanges.value = false;
|
||||
|
@ -254,13 +260,12 @@ function filter(value, update, filterOptions) {
|
|||
(ref) => {
|
||||
ref.setOptionIndex(-1);
|
||||
ref.moveOptionSelection(1, true);
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
function updateAndEmit(evt, val, res) {
|
||||
state.set(modelValue, val);
|
||||
originalData.value = val && JSON.parse(JSON.stringify(val));
|
||||
if (!$props.url) arrayData.store.data = val;
|
||||
|
||||
emit(evt, state.get(modelValue), res);
|
||||
|
|
|
@ -282,7 +282,7 @@ const setCategoryList = (data) => {
|
|||
<QItem class="q-mt-lg">
|
||||
<QBtn
|
||||
icon="add_circle"
|
||||
shortcut="+"
|
||||
v-shortcut="'+'"
|
||||
flat
|
||||
class="fill-icon-on-hover q-px-xs"
|
||||
color="primary"
|
||||
|
|
|
@ -630,7 +630,7 @@ function handleSelection({ evt, added, rows: selectedRows }, rows) {
|
|||
size="md"
|
||||
round
|
||||
flat
|
||||
shortcut="+"
|
||||
v-shortcut="'+'"
|
||||
:disabled="!disabledAttr"
|
||||
/>
|
||||
<QTooltip>
|
||||
|
@ -648,7 +648,7 @@ function handleSelection({ evt, added, rows: selectedRows }, rows) {
|
|||
color="primary"
|
||||
fab
|
||||
icon="add"
|
||||
shortcut="+"
|
||||
v-shortcut="'+'"
|
||||
data-cy="vnTableCreateBtn"
|
||||
/>
|
||||
<QTooltip self="top right">
|
||||
|
|
|
@ -93,7 +93,7 @@ describe('FormModel', () => {
|
|||
|
||||
it('should call axios.patch with the right data', async () => {
|
||||
const spy = vi.spyOn(axios, 'patch').mockResolvedValue({ data: {} });
|
||||
const { vm } = mount({ propsData: { url, model, formInitialData } });
|
||||
const { vm } = mount({ propsData: { url, model } });
|
||||
vm.formData.mockKey = 'newVal';
|
||||
await vm.$nextTick();
|
||||
await vm.save();
|
||||
|
@ -106,6 +106,7 @@ describe('FormModel', () => {
|
|||
const { vm } = mount({
|
||||
propsData: { url, model, formInitialData, urlCreate: 'mockUrlCreate' },
|
||||
});
|
||||
await vm.$nextTick();
|
||||
vm.formData.mockKey = 'newVal';
|
||||
await vm.$nextTick();
|
||||
await vm.save();
|
||||
|
@ -119,7 +120,7 @@ describe('FormModel', () => {
|
|||
});
|
||||
const spyPatch = vi.spyOn(axios, 'patch').mockResolvedValue({ data: {} });
|
||||
const spySaveFn = vi.spyOn(vm.$props, 'saveFn');
|
||||
|
||||
await vm.$nextTick();
|
||||
vm.formData.mockKey = 'newVal';
|
||||
await vm.$nextTick();
|
||||
await vm.save();
|
||||
|
|
|
@ -10,11 +10,11 @@ import LeftMenu from 'components/LeftMenu.vue';
|
|||
import RightMenu from 'components/common/RightMenu.vue';
|
||||
const props = defineProps({
|
||||
dataKey: { type: String, required: true },
|
||||
baseUrl: { type: String, default: undefined },
|
||||
customUrl: { type: String, default: undefined },
|
||||
url: { type: String, default: undefined },
|
||||
filter: { type: Object, default: () => {} },
|
||||
descriptor: { type: Object, required: true },
|
||||
filterPanel: { type: Object, default: undefined },
|
||||
idInWhere: { type: Boolean, default: false },
|
||||
searchDataKey: { type: String, default: undefined },
|
||||
searchbarProps: { type: Object, default: undefined },
|
||||
redirectOnError: { type: Boolean, default: false },
|
||||
|
@ -23,25 +23,20 @@ const props = defineProps({
|
|||
const stateStore = useStateStore();
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
const url = computed(() => {
|
||||
if (props.baseUrl) {
|
||||
return `${props.baseUrl}/${route.params.id}`;
|
||||
}
|
||||
return props.customUrl;
|
||||
});
|
||||
const searchRightDataKey = computed(() => {
|
||||
if (!props.searchDataKey) return route.name;
|
||||
return props.searchDataKey;
|
||||
});
|
||||
|
||||
const arrayData = useArrayData(props.dataKey, {
|
||||
url: url.value,
|
||||
filter: props.filter,
|
||||
url: props.url,
|
||||
userFilter: props.filter,
|
||||
oneRecord: true,
|
||||
});
|
||||
|
||||
onBeforeMount(async () => {
|
||||
try {
|
||||
if (!props.baseUrl) arrayData.store.filter.where = { id: route.params.id };
|
||||
await arrayData.fetch({ append: false, updateRouter: false });
|
||||
await fetch(route.params.id);
|
||||
} catch {
|
||||
const { matched: matches } = router.currentRoute.value;
|
||||
const { path } = matches.at(-1);
|
||||
|
@ -49,13 +44,17 @@ onBeforeMount(async () => {
|
|||
}
|
||||
});
|
||||
|
||||
if (props.baseUrl) {
|
||||
onBeforeRouteUpdate(async (to, from) => {
|
||||
if (to.params.id !== from.params.id) {
|
||||
arrayData.store.url = `${props.baseUrl}/${to.params.id}`;
|
||||
await arrayData.fetch({ append: false, updateRouter: false });
|
||||
}
|
||||
});
|
||||
onBeforeRouteUpdate(async (to, from) => {
|
||||
const id = to.params.id;
|
||||
if (id !== from.params.id) await fetch(id, true);
|
||||
});
|
||||
|
||||
async function fetch(id, append = false) {
|
||||
const regex = /\/(\d+)/;
|
||||
if (props.idInWhere) arrayData.store.filter.where = { id };
|
||||
else if (!regex.test(props.url)) arrayData.store.url = `${props.url}/${id}`;
|
||||
else arrayData.store.url = props.url.replace(regex, `/${id}`);
|
||||
await arrayData.fetch({ append, updateRouter: false });
|
||||
}
|
||||
</script>
|
||||
<template>
|
||||
|
@ -83,7 +82,7 @@ if (props.baseUrl) {
|
|||
<QPage>
|
||||
<VnSubToolbar />
|
||||
<div :class="[useCardSize(), $attrs.class]">
|
||||
<RouterView :key="route.path" />
|
||||
<RouterView :key="$route.path" />
|
||||
</div>
|
||||
</QPage>
|
||||
</QPageContainer>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<script setup>
|
||||
import { onBeforeMount, computed } from 'vue';
|
||||
import { useRoute, useRouter, onBeforeRouteUpdate } from 'vue-router';
|
||||
import { onBeforeMount } from 'vue';
|
||||
import { useRouter, onBeforeRouteUpdate } from 'vue-router';
|
||||
import { useArrayData } from 'src/composables/useArrayData';
|
||||
import { useStateStore } from 'stores/useStateStore';
|
||||
import useCardSize from 'src/composables/useCardSize';
|
||||
|
@ -9,10 +9,9 @@ import VnSubToolbar from '../ui/VnSubToolbar.vue';
|
|||
|
||||
const props = defineProps({
|
||||
dataKey: { type: String, required: true },
|
||||
baseUrl: { type: String, default: undefined },
|
||||
customUrl: { type: String, default: undefined },
|
||||
url: { type: String, default: undefined },
|
||||
idInWhere: { type: Boolean, default: false },
|
||||
filter: { type: Object, default: () => {} },
|
||||
userFilter: { type: Object, default: () => {} },
|
||||
descriptor: { type: Object, required: true },
|
||||
filterPanel: { type: Object, default: undefined },
|
||||
searchDataKey: { type: String, default: undefined },
|
||||
|
@ -21,39 +20,35 @@ const props = defineProps({
|
|||
});
|
||||
|
||||
const stateStore = useStateStore();
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
const url = computed(() => {
|
||||
if (props.baseUrl) {
|
||||
return `${props.baseUrl}/${route.params.id}`;
|
||||
}
|
||||
return props.customUrl;
|
||||
});
|
||||
|
||||
const arrayData = useArrayData(props.dataKey, {
|
||||
url: url.value,
|
||||
filter: props.filter,
|
||||
userFilter: props.userFilter,
|
||||
url: props.url,
|
||||
userFilter: props.filter,
|
||||
oneRecord: true,
|
||||
});
|
||||
|
||||
onBeforeMount(async () => {
|
||||
const route = router.currentRoute.value;
|
||||
try {
|
||||
if (!props.baseUrl) arrayData.store.filter.where = { id: route.params.id };
|
||||
await arrayData.fetch({ append: false, updateRouter: false });
|
||||
await fetch(route.params.id);
|
||||
} catch {
|
||||
const { matched: matches } = router.currentRoute.value;
|
||||
const { matched: matches } = route;
|
||||
const { path } = matches.at(-1);
|
||||
router.push({ path: path.replace(/:id.*/, '') });
|
||||
}
|
||||
});
|
||||
|
||||
if (props.baseUrl) {
|
||||
onBeforeRouteUpdate(async (to, from) => {
|
||||
if (to.params.id !== from.params.id) {
|
||||
arrayData.store.url = `${props.baseUrl}/${to.params.id}`;
|
||||
await arrayData.fetch({ append: false, updateRouter: false });
|
||||
}
|
||||
});
|
||||
onBeforeRouteUpdate(async (to, from) => {
|
||||
const id = to.params.id;
|
||||
if (id !== from.params.id) await fetch(id, true);
|
||||
});
|
||||
|
||||
async function fetch(id, append = false) {
|
||||
const regex = /\/(\d+)/;
|
||||
if (props.idInWhere) arrayData.store.filter.where = { id };
|
||||
else if (!regex.test(props.url)) arrayData.store.url = `${props.url}/${id}`;
|
||||
else arrayData.store.url = props.url.replace(regex, `/${id}`);
|
||||
await arrayData.fetch({ append, updateRouter: false });
|
||||
}
|
||||
</script>
|
||||
<template>
|
||||
|
@ -64,6 +59,6 @@ if (props.baseUrl) {
|
|||
</Teleport>
|
||||
<VnSubToolbar />
|
||||
<div :class="[useCardSize(), $attrs.class]">
|
||||
<RouterView :key="route.path" />
|
||||
<RouterView :key="$route.path" />
|
||||
</div>
|
||||
</template>
|
||||
|
|
|
@ -413,7 +413,7 @@ defineExpose({
|
|||
fab
|
||||
color="primary"
|
||||
icon="add"
|
||||
shortcut="+"
|
||||
v-shortcut
|
||||
@click="showFormDialog()"
|
||||
class="fill-icon"
|
||||
>
|
||||
|
|
|
@ -268,7 +268,7 @@ async function applyFilter() {
|
|||
filter.where.and.push(selectedFilters.value);
|
||||
}
|
||||
|
||||
paginate.value.fetch(filter);
|
||||
paginate.value.fetch({ filter });
|
||||
}
|
||||
|
||||
function setDate(type) {
|
||||
|
@ -404,7 +404,7 @@ watch(
|
|||
ref="paginate"
|
||||
:data-key="`${model}Log`"
|
||||
:url="`${model}Logs`"
|
||||
:filter="filter"
|
||||
:user-filter="filter"
|
||||
:skeleton="false"
|
||||
auto-load
|
||||
@on-fetch="setLogTree"
|
||||
|
|
|
@ -59,10 +59,11 @@ onBeforeMount(async () => {
|
|||
url: $props.url,
|
||||
filter: $props.filter,
|
||||
skip: 0,
|
||||
oneRecord: true,
|
||||
});
|
||||
store = arrayData.store;
|
||||
entity = computed(() => {
|
||||
const data = (Array.isArray(store.data) ? store.data[0] : store.data) ?? {};
|
||||
const data = store.data ?? {};
|
||||
if (data) emit('onFetch', data);
|
||||
return data;
|
||||
});
|
||||
|
@ -73,7 +74,7 @@ onBeforeMount(async () => {
|
|||
() => [$props.url, $props.filter],
|
||||
async () => {
|
||||
if (!isSameDataKey.value) await getData();
|
||||
}
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
|
@ -84,7 +85,7 @@ async function getData() {
|
|||
try {
|
||||
const { data } = await arrayData.fetch({ append: false, updateRouter: false });
|
||||
state.set($props.dataKey, data);
|
||||
emit('onFetch', Array.isArray(data) ? data[0] : data);
|
||||
emit('onFetch', data);
|
||||
} finally {
|
||||
isLoading.value = false;
|
||||
}
|
||||
|
@ -108,7 +109,7 @@ const iconModule = computed(() => route.matched[1].meta.icon);
|
|||
const toModule = computed(() =>
|
||||
route.matched[1].path.split('/').length > 2
|
||||
? route.matched[1].redirect
|
||||
: route.matched[1].children[0].redirect
|
||||
: route.matched[1].children[0].redirect,
|
||||
);
|
||||
</script>
|
||||
|
||||
|
|
|
@ -40,9 +40,10 @@ const arrayData = useArrayData(props.dataKey, {
|
|||
filter: props.filter,
|
||||
userFilter: props.userFilter,
|
||||
skip: 0,
|
||||
oneRecord: true,
|
||||
});
|
||||
const { store } = arrayData;
|
||||
const entity = computed(() => (Array.isArray(store.data) ? store.data[0] : store.data));
|
||||
const entity = computed(() => store.data);
|
||||
const isLoading = ref(false);
|
||||
|
||||
defineExpose({
|
||||
|
@ -61,7 +62,7 @@ async function fetch() {
|
|||
store.filter = props.filter ?? {};
|
||||
isLoading.value = true;
|
||||
const { data } = await arrayData.fetch({ append: false, updateRouter: false });
|
||||
emit('onFetch', Array.isArray(data) ? data[0] : data);
|
||||
emit('onFetch', data);
|
||||
isLoading.value = false;
|
||||
}
|
||||
</script>
|
||||
|
@ -208,4 +209,13 @@ async function fetch() {
|
|||
.summaryHeader {
|
||||
color: $white;
|
||||
}
|
||||
|
||||
.cardSummary :deep(.q-card__section[content]) {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
padding: 0;
|
||||
> * {
|
||||
flex: 1;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
|
|
@ -114,7 +114,7 @@ async function clearFilters() {
|
|||
arrayData.resetPagination();
|
||||
// Filtrar los params no removibles
|
||||
const removableFilters = Object.keys(userParams.value).filter((param) =>
|
||||
$props.unremovableParams.includes(param)
|
||||
$props.unremovableParams.includes(param),
|
||||
);
|
||||
const newParams = {};
|
||||
// Conservar solo los params que no son removibles
|
||||
|
@ -162,13 +162,13 @@ const formatTags = (tags) => {
|
|||
|
||||
const tags = computed(() => {
|
||||
const filteredTags = tagsList.value.filter(
|
||||
(tag) => !($props.customTags || []).includes(tag.label)
|
||||
(tag) => !($props.customTags || []).includes(tag.label),
|
||||
);
|
||||
return formatTags(filteredTags);
|
||||
});
|
||||
|
||||
const customTags = computed(() =>
|
||||
tagsList.value.filter((tag) => ($props.customTags || []).includes(tag.label))
|
||||
tagsList.value.filter((tag) => ($props.customTags || []).includes(tag.label)),
|
||||
);
|
||||
|
||||
async function remove(key) {
|
||||
|
@ -188,10 +188,13 @@ function formatValue(value) {
|
|||
const getLocale = (label) => {
|
||||
const param = label.split('.').at(-1);
|
||||
const globalLocale = `globals.params.${param}`;
|
||||
const moduleName = route.meta.moduleName;
|
||||
const moduleLocale = `${moduleName.toLowerCase()}.${param}`;
|
||||
if (te(globalLocale)) return t(globalLocale);
|
||||
else if (te(t(`params.${param}`)));
|
||||
else if (te(moduleLocale)) return t(moduleLocale);
|
||||
else {
|
||||
const camelCaseModuleName = route.meta.moduleName.charAt(0).toLowerCase() + route.meta.moduleName.slice(1);
|
||||
const camelCaseModuleName =
|
||||
moduleName.charAt(0).toLowerCase() + moduleName.slice(1);
|
||||
return t(`${camelCaseModuleName}.params.${param}`);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -49,7 +49,7 @@ function formatNumber(number) {
|
|||
<VnPaginate
|
||||
:data-key="$props.url"
|
||||
:url="$props.url"
|
||||
:filter="filter"
|
||||
:user-filter="filter"
|
||||
order="smsFk DESC"
|
||||
:offset="100"
|
||||
:limit="5"
|
||||
|
|
|
@ -51,16 +51,6 @@ describe('CardSummary', () => {
|
|||
expect(vm.store.filter).toEqual('cardFilter');
|
||||
});
|
||||
|
||||
it('should compute entity correctly from store data', () => {
|
||||
vm.store.data = [{ id: 1, name: 'Entity 1' }];
|
||||
expect(vm.entity).toEqual({ id: 1, name: 'Entity 1' });
|
||||
});
|
||||
|
||||
it('should handle empty data gracefully', () => {
|
||||
vm.store.data = [];
|
||||
expect(vm.entity).toBeUndefined();
|
||||
});
|
||||
|
||||
it('should respond to prop changes and refetch data', async () => {
|
||||
const newUrl = 'CardSummary/35';
|
||||
const newKey = 'cardSummaryKey/35';
|
||||
|
@ -72,7 +62,7 @@ describe('CardSummary', () => {
|
|||
expect(vm.store.filter).toEqual({ key: newKey });
|
||||
});
|
||||
|
||||
it('should return true if route path ends with /summary' , () => {
|
||||
it('should return true if route path ends with /summary', () => {
|
||||
expect(vm.isSummary).toBe(true);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -16,7 +16,7 @@ describe('useArrayData', () => {
|
|||
vi.clearAllMocks();
|
||||
});
|
||||
|
||||
it('should fetch and repalce url with new params', async () => {
|
||||
it('should fetch and replace url with new params', async () => {
|
||||
vi.spyOn(axios, 'get').mockReturnValueOnce({ data: [] });
|
||||
|
||||
const arrayData = useArrayData('ArrayData', { url: 'mockUrl' });
|
||||
|
@ -33,11 +33,11 @@ describe('useArrayData', () => {
|
|||
});
|
||||
expect(routerReplace.path).toEqual('mockSection/list');
|
||||
expect(JSON.parse(routerReplace.query.params)).toEqual(
|
||||
expect.objectContaining(params)
|
||||
expect.objectContaining(params),
|
||||
);
|
||||
});
|
||||
|
||||
it('Should get data and send new URL without keeping parameters, if there is only one record', async () => {
|
||||
it('should get data and send new URL without keeping parameters, if there is only one record', async () => {
|
||||
vi.spyOn(axios, 'get').mockReturnValueOnce({ data: [{ id: 1 }] });
|
||||
|
||||
const arrayData = useArrayData('ArrayData', { url: 'mockUrl', navigate: {} });
|
||||
|
@ -56,7 +56,7 @@ describe('useArrayData', () => {
|
|||
expect(routerPush.query).toBeUndefined();
|
||||
});
|
||||
|
||||
it('Should get data and send new URL keeping parameters, if you have more than one record', async () => {
|
||||
it('should get data and send new URL keeping parameters, if you have more than one record', async () => {
|
||||
vi.spyOn(axios, 'get').mockReturnValueOnce({ data: [{ id: 1 }, { id: 2 }] });
|
||||
|
||||
vi.spyOn(vueRouter, 'useRoute').mockReturnValue({
|
||||
|
@ -95,4 +95,25 @@ describe('useArrayData', () => {
|
|||
expect(routerPush.path).toEqual('mockName/');
|
||||
expect(routerPush.query.params).toBeDefined();
|
||||
});
|
||||
|
||||
it('should return one record', async () => {
|
||||
vi.spyOn(axios, 'get').mockReturnValueOnce({
|
||||
data: [
|
||||
{ id: 1, name: 'Entity 1' },
|
||||
{ id: 2, name: 'Entity 2' },
|
||||
],
|
||||
});
|
||||
const arrayData = useArrayData('ArrayData', { url: 'mockUrl', oneRecord: true });
|
||||
await arrayData.fetch({});
|
||||
|
||||
expect(arrayData.store.data).toEqual({ id: 1, name: 'Entity 1' });
|
||||
});
|
||||
|
||||
it('should handle empty data gracefully if has to return one record', async () => {
|
||||
vi.spyOn(axios, 'get').mockReturnValueOnce({ data: [] });
|
||||
const arrayData = useArrayData('ArrayData', { url: 'mockUrl', oneRecord: true });
|
||||
await arrayData.fetch({});
|
||||
|
||||
expect(arrayData.store.data).toBeUndefined();
|
||||
});
|
||||
});
|
||||
|
|
|
@ -57,6 +57,7 @@ export function useArrayData(key, userOptions) {
|
|||
'navigate',
|
||||
'mapKey',
|
||||
'keepData',
|
||||
'oneRecord',
|
||||
];
|
||||
if (typeof userOptions === 'object') {
|
||||
for (const option in userOptions) {
|
||||
|
@ -112,7 +113,11 @@ export function useArrayData(key, userOptions) {
|
|||
store.isLoading = false;
|
||||
canceller = null;
|
||||
|
||||
processData(response.data, { map: !!store.mapKey, append });
|
||||
processData(response.data, {
|
||||
map: !!store.mapKey,
|
||||
append,
|
||||
oneRecord: store.oneRecord,
|
||||
});
|
||||
|
||||
return response;
|
||||
}
|
||||
|
@ -314,7 +319,11 @@ export function useArrayData(key, userOptions) {
|
|||
return { params, limit };
|
||||
}
|
||||
|
||||
function processData(data, { map = true, append = true }) {
|
||||
function processData(data, { map = true, append = true, oneRecord = false }) {
|
||||
if (oneRecord) {
|
||||
store.data = Array.isArray(data) ? data[0] : data;
|
||||
return;
|
||||
}
|
||||
if (!append) {
|
||||
store.data = [];
|
||||
store.map = new Map();
|
||||
|
|
|
@ -212,6 +212,10 @@ select:-webkit-autofill {
|
|||
justify-content: center;
|
||||
}
|
||||
|
||||
.q-card__section[dense] {
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
input[type='number'] {
|
||||
-moz-appearance: textfield;
|
||||
}
|
||||
|
|
|
@ -334,10 +334,13 @@ globals:
|
|||
wasteRecalc: Waste recaclulate
|
||||
operator: Operator
|
||||
parking: Parking
|
||||
vehicleList: Vehicles
|
||||
vehicle: Vehicle
|
||||
unsavedPopup:
|
||||
title: Unsaved changes will be lost
|
||||
subtitle: Are you sure exit without saving?
|
||||
params:
|
||||
description: Description
|
||||
clientFk: Client id
|
||||
salesPersonFk: Sales person
|
||||
warehouseFk: Warehouse
|
||||
|
@ -360,7 +363,13 @@ globals:
|
|||
correctingFk: Rectificative
|
||||
daysOnward: Days onward
|
||||
countryFk: Country
|
||||
countryCodeFk: Country
|
||||
companyFk: Company
|
||||
model: Model
|
||||
fuel: Fuel
|
||||
active: Active
|
||||
inactive: Inactive
|
||||
deliveryPoint: Delivery point
|
||||
errors:
|
||||
statusUnauthorized: Access denied
|
||||
statusInternalServerError: An internal server error has ocurred
|
||||
|
|
|
@ -337,10 +337,13 @@ globals:
|
|||
wasteRecalc: Recalcular mermas
|
||||
operator: Operario
|
||||
parking: Parking
|
||||
vehicleList: Vehículos
|
||||
vehicle: Vehículo
|
||||
unsavedPopup:
|
||||
title: Los cambios que no haya guardado se perderán
|
||||
subtitle: ¿Seguro que quiere salir sin guardar?
|
||||
params:
|
||||
description: Descripción
|
||||
clientFk: Id cliente
|
||||
salesPersonFk: Comercial
|
||||
warehouseFk: Almacén
|
||||
|
@ -361,6 +364,7 @@ globals:
|
|||
daysOnward: Días adelante
|
||||
packing: ITP
|
||||
countryFk: País
|
||||
countryCodeFk: País
|
||||
companyFk: Empresa
|
||||
errors:
|
||||
statusUnauthorized: Acceso denegado
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
import Navbar from 'src/components/NavBar.vue';
|
||||
</script>
|
||||
<template>
|
||||
<QLayout view="hHh LpR fFf" v-shortcut>
|
||||
<QLayout view="hHh LpR fFf">
|
||||
<Navbar />
|
||||
<RouterView></RouterView>
|
||||
<QFooter v-if="$q.platform.is.mobile"></QFooter>
|
||||
|
|
|
@ -3,6 +3,7 @@ import { useI18n } from 'vue-i18n';
|
|||
import { ref, computed } from 'vue';
|
||||
import VnTable from 'components/VnTable/VnTable.vue';
|
||||
import VnSection from 'src/components/common/VnSection.vue';
|
||||
import exprBuilder from './Alias/AliasExprBuilder';
|
||||
|
||||
const tableRef = ref();
|
||||
const { t } = useI18n();
|
||||
|
@ -31,15 +32,6 @@ const columns = computed(() => [
|
|||
create: true,
|
||||
},
|
||||
]);
|
||||
|
||||
const exprBuilder = (param, value) => {
|
||||
switch (param) {
|
||||
case 'search':
|
||||
return /^\d+$/.test(value)
|
||||
? { id: value }
|
||||
: { alias: { like: `%${value}%` } };
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
|
|
@ -46,7 +46,7 @@ const killSession = async ({ userId, created }) => {
|
|||
<VnPaginate
|
||||
:data-key="urlPath"
|
||||
ref="paginateRef"
|
||||
:filter="filter"
|
||||
:user-filter="filter"
|
||||
:url="urlPath"
|
||||
order="created DESC"
|
||||
auto-load
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
export default (param, value) => {
|
||||
switch (param) {
|
||||
case 'search':
|
||||
return /^\d+$/.test(value)
|
||||
? { id: value }
|
||||
: {
|
||||
or: [
|
||||
{ name: { like: `%${value}%` } },
|
||||
{ nickname: { like: `%${value}%` } },
|
||||
],
|
||||
};
|
||||
case 'name':
|
||||
case 'nickname':
|
||||
return { [param]: { like: `%${value}%` } };
|
||||
case 'roleFk':
|
||||
return { [param]: value };
|
||||
}
|
||||
};
|
|
@ -4,15 +4,16 @@ import { computed, ref } from 'vue';
|
|||
import VnTable from 'components/VnTable/VnTable.vue';
|
||||
import AccountSummary from './Card/AccountSummary.vue';
|
||||
import { useSummaryDialog } from 'src/composables/useSummaryDialog';
|
||||
import exprBuilder from './AccountExprBuilder.js';
|
||||
import filter from './Card/AccountFilter.js';
|
||||
import VnSection from 'src/components/common/VnSection.vue';
|
||||
import FetchData from 'src/components/FetchData.vue';
|
||||
import VnInputPassword from 'src/components/common/VnInputPassword.vue';
|
||||
|
||||
const { t } = useI18n();
|
||||
const { viewSummary } = useSummaryDialog();
|
||||
const filter = {
|
||||
include: { relation: 'role', scope: { fields: ['id', 'name'] } },
|
||||
};
|
||||
const tableRef = ref();
|
||||
|
||||
const dataKey = 'AccountList';
|
||||
const roles = ref([]);
|
||||
const columns = computed(() => [
|
||||
|
@ -117,25 +118,6 @@ const columns = computed(() => [
|
|||
],
|
||||
},
|
||||
]);
|
||||
|
||||
function exprBuilder(param, value) {
|
||||
switch (param) {
|
||||
case 'search':
|
||||
return /^\d+$/.test(value)
|
||||
? { id: value }
|
||||
: {
|
||||
or: [
|
||||
{ name: { like: `%${value}%` } },
|
||||
{ nickname: { like: `%${value}%` } },
|
||||
],
|
||||
};
|
||||
case 'name':
|
||||
case 'nickname':
|
||||
return { [param]: { like: `%${value}%` } };
|
||||
case 'roleFk':
|
||||
return { [param]: value };
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<template>
|
||||
<FetchData url="VnRoles" @on-fetch="(data) => (roles = data)" auto-load />
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
export default (param, value) => {
|
||||
switch (param) {
|
||||
case 'search':
|
||||
return /^\d+$/.test(value)
|
||||
? { id: value }
|
||||
: { alias: { like: `%${value}%` } };
|
||||
}
|
||||
};
|
|
@ -1,21 +1,13 @@
|
|||
<script setup>
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import VnCardBeta from 'components/common/VnCardBeta.vue';
|
||||
import AliasDescriptor from './AliasDescriptor.vue';
|
||||
const { t } = useI18n();
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<VnCardBeta
|
||||
data-key="Alias"
|
||||
base-url="MailAliases"
|
||||
url="MailAliases"
|
||||
:descriptor="AliasDescriptor"
|
||||
search-data-key="AccountAliasList"
|
||||
:searchbar-props="{
|
||||
url: 'MailAliases',
|
||||
info: t('mailAlias.searchInfo'),
|
||||
label: t('mailAlias.search'),
|
||||
searchUrl: 'table',
|
||||
}"
|
||||
/>
|
||||
</template>
|
||||
|
|
|
@ -7,7 +7,6 @@ import { useQuasar } from 'quasar';
|
|||
import CardDescriptor from 'components/ui/CardDescriptor.vue';
|
||||
import VnLv from 'src/components/ui/VnLv.vue';
|
||||
|
||||
import useCardDescription from 'src/composables/useCardDescription';
|
||||
import axios from 'axios';
|
||||
import useNotify from 'src/composables/useNotify.js';
|
||||
|
||||
|
@ -29,9 +28,6 @@ const entityId = computed(() => {
|
|||
return $props.id || route.params.id;
|
||||
});
|
||||
|
||||
const data = ref(useCardDescription());
|
||||
const setData = (entity) => (data.value = useCardDescription(entity.alias, entity.id));
|
||||
|
||||
const removeAlias = () => {
|
||||
quasar
|
||||
.dialog({
|
||||
|
@ -56,10 +52,8 @@ const removeAlias = () => {
|
|||
ref="descriptor"
|
||||
:url="`MailAliases/${entityId}`"
|
||||
module="Alias"
|
||||
@on-fetch="setData"
|
||||
data-key="aliasData"
|
||||
:title="data.title"
|
||||
:subtitle="data.subtitle"
|
||||
data-key="Alias"
|
||||
title="alias"
|
||||
>
|
||||
<template #menu>
|
||||
<QItem v-ripple clickable @click="removeAlias()">
|
||||
|
|
|
@ -1,13 +1,11 @@
|
|||
<script setup>
|
||||
import { ref, computed } from 'vue';
|
||||
import { computed } from 'vue';
|
||||
import { useRoute } from 'vue-router';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
|
||||
import CardSummary from 'components/ui/CardSummary.vue';
|
||||
import VnLv from 'src/components/ui/VnLv.vue';
|
||||
|
||||
import { useArrayData } from 'src/composables/useArrayData';
|
||||
|
||||
const route = useRoute();
|
||||
const { t } = useI18n();
|
||||
|
||||
|
@ -18,20 +16,15 @@ const $props = defineProps({
|
|||
},
|
||||
});
|
||||
|
||||
const { store } = useArrayData('Alias');
|
||||
const alias = ref(store.data);
|
||||
const entityId = computed(() => $props.id || route.params.id);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<CardSummary
|
||||
ref="summary"
|
||||
:url="`MailAliases/${entityId}`"
|
||||
@on-fetch="(data) => (alias = data)"
|
||||
data-key="MailAliasesSummary"
|
||||
>
|
||||
<template #header> {{ alias.id }} - {{ alias.alias }} </template>
|
||||
<template #body>
|
||||
<CardSummary ref="summary" :url="`MailAliases/${entityId}`" data-key="Alias">
|
||||
<template #header="{ entity: alias }">
|
||||
{{ alias.id }} - {{ alias.alias }}
|
||||
</template>
|
||||
<template #body="{ entity: alias }">
|
||||
<QCard class="vn-one">
|
||||
<QCardSection class="q-pa-none">
|
||||
<router-link
|
||||
|
|
|
@ -69,7 +69,7 @@ const fetchAliases = () => paginateRef.value.fetch();
|
|||
<VnPaginate
|
||||
ref="paginateRef"
|
||||
data-key="AliasUsers"
|
||||
:filter="filter"
|
||||
:user-filter="filter"
|
||||
:url="urlPath"
|
||||
:limit="0"
|
||||
auto-load
|
||||
|
|
|
@ -1,46 +1,20 @@
|
|||
<script setup>
|
||||
import { useRoute } from 'vue-router';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import VnSelect from 'src/components/common/VnSelect.vue';
|
||||
import VnSelectEnum from 'src/components/common/VnSelectEnum.vue';
|
||||
import FormModel from 'components/FormModel.vue';
|
||||
import VnInput from 'src/components/common/VnInput.vue';
|
||||
import { ref, watch } from 'vue';
|
||||
|
||||
const route = useRoute();
|
||||
const { t } = useI18n();
|
||||
const formModelRef = ref(null);
|
||||
|
||||
const accountFilter = {
|
||||
where: { id: route.params.id },
|
||||
fields: ['id', 'email', 'nickname', 'name', 'accountStateFk', 'packages', 'pickup'],
|
||||
include: [],
|
||||
};
|
||||
|
||||
watch(
|
||||
() => route.params.id,
|
||||
() => formModelRef.value.reset()
|
||||
);
|
||||
</script>
|
||||
<template>
|
||||
<FormModel
|
||||
ref="formModelRef"
|
||||
url="VnUsers/preview"
|
||||
:url-update="`VnUsers/${route.params.id}/update-user`"
|
||||
:filter="accountFilter"
|
||||
model="Accounts"
|
||||
auto-load
|
||||
@on-data-saved="formModelRef.fetch()"
|
||||
>
|
||||
<FormModel :url-update="`VnUsers/${$route.params.id}/update-user`" model="Account">
|
||||
<template #form="{ data }">
|
||||
<div class="q-gutter-y-sm">
|
||||
<VnInput v-model="data.name" :label="t('account.card.nickname')" />
|
||||
<VnInput v-model="data.nickname" :label="t('account.card.alias')" />
|
||||
<VnInput v-model="data.email" :label="t('globals.params.email')" />
|
||||
<VnInput v-model="data.name" :label="$t('account.card.nickname')" />
|
||||
<VnInput v-model="data.nickname" :label="$t('account.card.alias')" />
|
||||
<VnInput v-model="data.email" :label="$t('globals.params.email')" />
|
||||
<VnSelect
|
||||
url="Languages"
|
||||
v-model="data.lang"
|
||||
:label="t('account.card.lang')"
|
||||
:label="$t('account.card.lang')"
|
||||
option-value="code"
|
||||
option-label="code"
|
||||
/>
|
||||
|
@ -49,7 +23,7 @@ watch(
|
|||
table="user"
|
||||
column="twoFactor"
|
||||
v-model="data.twoFactor"
|
||||
:label="t('account.card.twoFactor')"
|
||||
:label="$t('account.card.twoFactor')"
|
||||
option-value="code"
|
||||
option-label="code"
|
||||
/>
|
||||
|
|
|
@ -1,8 +1,14 @@
|
|||
<script setup>
|
||||
import VnCardBeta from 'components/common/VnCardBeta.vue';
|
||||
import AccountDescriptor from './AccountDescriptor.vue';
|
||||
import filter from './AccountFilter.js';
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<VnCardBeta data-key="AccountId" :descriptor="AccountDescriptor" />
|
||||
<VnCardBeta
|
||||
url="VnUsers/preview"
|
||||
:id-in-where="true"
|
||||
data-key="Account"
|
||||
:descriptor="AccountDescriptor"
|
||||
:filter="filter"
|
||||
/>
|
||||
</template>
|
||||
|
|
|
@ -1,36 +1,18 @@
|
|||
<script setup>
|
||||
import { ref, computed, onMounted } from 'vue';
|
||||
import { useRoute } from 'vue-router';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import CardDescriptor from 'components/ui/CardDescriptor.vue';
|
||||
import VnLv from 'src/components/ui/VnLv.vue';
|
||||
import useCardDescription from 'src/composables/useCardDescription';
|
||||
import AccountDescriptorMenu from './AccountDescriptorMenu.vue';
|
||||
import VnImg from 'src/components/ui/VnImg.vue';
|
||||
import filter from './AccountFilter.js';
|
||||
import useHasAccount from 'src/composables/useHasAccount.js';
|
||||
|
||||
const $props = defineProps({
|
||||
id: {
|
||||
type: Number,
|
||||
required: false,
|
||||
default: null,
|
||||
},
|
||||
});
|
||||
const $props = defineProps({ id: { type: Number, default: null } });
|
||||
|
||||
const route = useRoute();
|
||||
const { t } = useI18n();
|
||||
const entityId = computed(() => {
|
||||
return $props.id || route.params.id;
|
||||
});
|
||||
const data = ref(useCardDescription());
|
||||
const entityId = computed(() => $props.id || route.params.id);
|
||||
const hasAccount = ref();
|
||||
const setData = (entity) => (data.value = useCardDescription(entity.nickname, entity.id));
|
||||
|
||||
const filter = {
|
||||
where: { id: entityId },
|
||||
fields: ['id', 'nickname', 'name', 'role'],
|
||||
include: { relation: 'role', scope: { fields: ['id', 'name'] } },
|
||||
};
|
||||
|
||||
onMounted(async () => {
|
||||
hasAccount.value = await useHasAccount(entityId.value);
|
||||
|
@ -43,10 +25,8 @@ onMounted(async () => {
|
|||
:url="`VnUsers/preview`"
|
||||
:filter="filter"
|
||||
module="Account"
|
||||
@on-fetch="setData"
|
||||
data-key="AccountId"
|
||||
:title="data.title"
|
||||
:subtitle="data.subtitle"
|
||||
data-key="Account"
|
||||
title="nickname"
|
||||
>
|
||||
<template #menu>
|
||||
<AccountDescriptorMenu :entity-id="entityId" />
|
||||
|
@ -62,7 +42,7 @@ onMounted(async () => {
|
|||
<QIcon name="vn:claims" />
|
||||
</div>
|
||||
<div class="text-grey-5" style="opacity: 0.4">
|
||||
{{ t('account.imageNotFound') }}
|
||||
{{ $t('account.imageNotFound') }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -70,8 +50,8 @@ onMounted(async () => {
|
|||
</VnImg>
|
||||
</template>
|
||||
<template #body="{ entity }">
|
||||
<VnLv :label="t('account.card.nickname')" :value="entity.name" />
|
||||
<VnLv :label="t('account.card.role')" :value="entity.role.name" />
|
||||
<VnLv :label="$t('account.card.nickname')" :value="entity.name" />
|
||||
<VnLv :label="$t('account.card.role')" :value="entity.role?.name" />
|
||||
</template>
|
||||
<template #actions="{ entity }">
|
||||
<QCardActions class="q-gutter-x-md">
|
||||
|
@ -84,7 +64,7 @@ onMounted(async () => {
|
|||
size="sm"
|
||||
class="fill-icon"
|
||||
>
|
||||
<QTooltip>{{ t('account.card.deactivated') }}</QTooltip>
|
||||
<QTooltip>{{ $t('account.card.deactivated') }}</QTooltip>
|
||||
</QIcon>
|
||||
<QIcon
|
||||
color="primary"
|
||||
|
@ -95,7 +75,7 @@ onMounted(async () => {
|
|||
size="sm"
|
||||
class="fill-icon"
|
||||
>
|
||||
<QTooltip>{{ t('account.card.enabled') }}</QTooltip>
|
||||
<QTooltip>{{ $t('account.card.enabled') }}</QTooltip>
|
||||
</QIcon>
|
||||
</QCardActions>
|
||||
</template>
|
||||
|
|
|
@ -29,7 +29,7 @@ const router = useRouter();
|
|||
const state = useState();
|
||||
const user = state.getUser();
|
||||
const { notify } = useQuasar();
|
||||
const account = computed(() => useArrayData('AccountId').store.data[0]);
|
||||
const account = computed(() => useArrayData('Account').store.data[0]);
|
||||
account.value.hasAccount = hasAccount.value;
|
||||
const entityId = computed(() => +route.params.id);
|
||||
const hasitManagementAccess = ref();
|
||||
|
@ -152,7 +152,7 @@ onMounted(() => {
|
|||
openConfirmationModal(
|
||||
t('account.card.actions.disableAccount.title'),
|
||||
t('account.card.actions.disableAccount.subtitle'),
|
||||
() => deleteAccount()
|
||||
() => deleteAccount(),
|
||||
)
|
||||
"
|
||||
>
|
||||
|
@ -177,7 +177,7 @@ onMounted(() => {
|
|||
openConfirmationModal(
|
||||
t('account.card.actions.enableAccount.title'),
|
||||
t('account.card.actions.enableAccount.subtitle'),
|
||||
() => updateStatusAccount(true)
|
||||
() => updateStatusAccount(true),
|
||||
)
|
||||
"
|
||||
>
|
||||
|
@ -191,7 +191,7 @@ onMounted(() => {
|
|||
openConfirmationModal(
|
||||
t('account.card.actions.disableAccount.title'),
|
||||
t('account.card.actions.disableAccount.subtitle'),
|
||||
() => updateStatusAccount(false)
|
||||
() => updateStatusAccount(false),
|
||||
)
|
||||
"
|
||||
>
|
||||
|
@ -206,7 +206,7 @@ onMounted(() => {
|
|||
openConfirmationModal(
|
||||
t('account.card.actions.activateUser.title'),
|
||||
t('account.card.actions.activateUser.title'),
|
||||
() => updateStatusUser(true)
|
||||
() => updateStatusUser(true),
|
||||
)
|
||||
"
|
||||
>
|
||||
|
@ -220,7 +220,7 @@ onMounted(() => {
|
|||
openConfirmationModal(
|
||||
t('account.card.actions.deactivateUser.title'),
|
||||
t('account.card.actions.deactivateUser.title'),
|
||||
() => updateStatusUser(false)
|
||||
() => updateStatusUser(false),
|
||||
)
|
||||
"
|
||||
>
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
export default {
|
||||
include: { relation: 'role', scope: { fields: ['id', 'name'] } },
|
||||
};
|
|
@ -86,7 +86,7 @@ watch(
|
|||
() => route.params.id,
|
||||
() => {
|
||||
getAccountData();
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
onMounted(async () => await getAccountData(false));
|
||||
|
@ -99,7 +99,7 @@ onMounted(async () => await getAccountData(false));
|
|||
<VnPaginate
|
||||
ref="paginateRef"
|
||||
data-key="AccountMailAliases"
|
||||
:filter="filter"
|
||||
:user-filter="filter"
|
||||
:url="urlPath"
|
||||
auto-load
|
||||
>
|
||||
|
@ -130,7 +130,8 @@ onMounted(async () => await getAccountData(false));
|
|||
openConfirmationModal(
|
||||
t('User will be removed from alias'),
|
||||
t('¿Seguro que quieres continuar?'),
|
||||
() => deleteMailAlias(row, rows, rowIndex)
|
||||
() =>
|
||||
deleteMailAlias(row, rows, rowIndex),
|
||||
)
|
||||
"
|
||||
>
|
||||
|
@ -157,7 +158,7 @@ onMounted(async () => await getAccountData(false));
|
|||
icon="add"
|
||||
color="primary"
|
||||
@click="openCreateMailAliasForm()"
|
||||
shortcut="+"
|
||||
v-shortcut="'+'"
|
||||
>
|
||||
<QTooltip>{{ t('warehouses.add') }}</QTooltip>
|
||||
</QBtn>
|
||||
|
|
|
@ -1,58 +1,41 @@
|
|||
<script setup>
|
||||
import { ref, computed } from 'vue';
|
||||
import { computed } from 'vue';
|
||||
import { useRoute } from 'vue-router';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
|
||||
import CardSummary from 'components/ui/CardSummary.vue';
|
||||
import VnLv from 'src/components/ui/VnLv.vue';
|
||||
|
||||
import { useArrayData } from 'src/composables/useArrayData';
|
||||
import filter from './AccountFilter.js';
|
||||
import AccountDescriptorMenu from './AccountDescriptorMenu.vue';
|
||||
|
||||
const $props = defineProps({ id: { type: Number, default: 0 } });
|
||||
|
||||
const route = useRoute();
|
||||
const { t } = useI18n();
|
||||
|
||||
const $props = defineProps({
|
||||
id: {
|
||||
type: Number,
|
||||
default: 0,
|
||||
},
|
||||
});
|
||||
const { store } = useArrayData('Account');
|
||||
const account = ref(store.data);
|
||||
|
||||
const entityId = computed(() => $props.id || route.params.id);
|
||||
const filter = {
|
||||
where: { id: entityId },
|
||||
fields: ['id', 'nickname', 'name', 'role'],
|
||||
include: { relation: 'role', scope: { fields: ['id', 'name'] } },
|
||||
};
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<CardSummary
|
||||
data-key="AccountId"
|
||||
data-key="Account"
|
||||
ref="AccountSummary"
|
||||
url="VnUsers/preview"
|
||||
:filter="filter"
|
||||
@on-fetch="(data) => (account = data)"
|
||||
>
|
||||
<template #header>{{ account.id }} - {{ account.nickname }}</template>
|
||||
<template #menu="">
|
||||
<template #header="{ entity }">{{ entity.id }} - {{ entity.nickname }}</template>
|
||||
<template #menu>
|
||||
<AccountDescriptorMenu :entity-id="entityId" />
|
||||
</template>
|
||||
<template #body>
|
||||
<template #body="{ entity }">
|
||||
<QCard class="vn-one">
|
||||
<QCardSection class="q-pa-none">
|
||||
<router-link
|
||||
:to="{ name: 'AccountBasicData', params: { id: entityId } }"
|
||||
class="header header-link"
|
||||
>
|
||||
{{ t('globals.pageTitles.basicData') }}
|
||||
{{ $t('globals.pageTitles.basicData') }}
|
||||
<QIcon name="open_in_new" />
|
||||
</router-link>
|
||||
</QCardSection>
|
||||
<VnLv :label="t('account.card.nickname')" :value="account.name" />
|
||||
<VnLv :label="t('account.card.role')" :value="account.role.name" />
|
||||
<VnLv :label="$t('account.card.nickname')" :value="entity.name" />
|
||||
<VnLv :label="$t('account.card.role')" :value="entity.role?.name" />
|
||||
</QCard>
|
||||
</template>
|
||||
</CardSummary>
|
||||
|
|
|
@ -59,7 +59,7 @@ const redirectToRoleSummary = (id) =>
|
|||
<VnPaginate
|
||||
ref="paginateRef"
|
||||
:data-key="dataKey"
|
||||
:filter="filter"
|
||||
:user-filter="filter"
|
||||
:url="urlPath"
|
||||
:limit="0"
|
||||
auto-load
|
||||
|
|
|
@ -5,6 +5,7 @@ import VnTable from 'components/VnTable/VnTable.vue';
|
|||
import { useRoute } from 'vue-router';
|
||||
import { useSummaryDialog } from 'src/composables/useSummaryDialog';
|
||||
import RoleSummary from './Card/RoleSummary.vue';
|
||||
import exprBuilder from './RoleExprBuilder.js';
|
||||
import VnSection from 'src/components/common/VnSection.vue';
|
||||
|
||||
const route = useRoute();
|
||||
|
@ -66,24 +67,7 @@ const columns = computed(() => [
|
|||
],
|
||||
},
|
||||
]);
|
||||
const exprBuilder = (param, value) => {
|
||||
switch (param) {
|
||||
case 'search':
|
||||
return /^\d+$/.test(value)
|
||||
? { id: value }
|
||||
: {
|
||||
or: [
|
||||
{ name: { like: `%${value}%` } },
|
||||
{ nickname: { like: `%${value}%` } },
|
||||
],
|
||||
};
|
||||
case 'name':
|
||||
case 'description':
|
||||
return { [param]: { like: `%${value}%` } };
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<VnSection
|
||||
:data-key="dataKey"
|
||||
|
|
|
@ -58,7 +58,7 @@ const redirectToRoleSummary = (id) =>
|
|||
<VnPaginate
|
||||
ref="paginateRef"
|
||||
data-key="InheritedRoles"
|
||||
:filter="filter"
|
||||
:user-filter="filter"
|
||||
:url="urlPath"
|
||||
:limit="0"
|
||||
auto-load
|
||||
|
|
|
@ -1,24 +1,16 @@
|
|||
<script setup>
|
||||
import { useRoute } from 'vue-router';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import FormModel from 'components/FormModel.vue';
|
||||
import VnRow from 'components/ui/VnRow.vue';
|
||||
import VnInput from 'src/components/common/VnInput.vue';
|
||||
const route = useRoute();
|
||||
const { t } = useI18n();
|
||||
</script>
|
||||
<template>
|
||||
<FormModel :url="`VnRoles/${route.params.id}`" model="VnRole" auto-load>
|
||||
<FormModel model="Role" auto-load>
|
||||
<template #form="{ data }">
|
||||
<VnRow>
|
||||
<div class="col">
|
||||
<VnInput v-model="data.name" :label="t('globals.name')" />
|
||||
</div>
|
||||
<VnInput v-model="data.name" :label="$t('globals.name')" />
|
||||
</VnRow>
|
||||
<VnRow>
|
||||
<div class="col">
|
||||
<VnInput v-model="data.description" :label="t('role.description')" />
|
||||
</div>
|
||||
<VnInput v-model="data.description" :label="$t('role.description')" />
|
||||
</VnRow>
|
||||
</template>
|
||||
</FormModel>
|
||||
|
|
|
@ -3,5 +3,10 @@ import VnCardBeta from 'components/common/VnCardBeta.vue';
|
|||
import RoleDescriptor from './RoleDescriptor.vue';
|
||||
</script>
|
||||
<template>
|
||||
<VnCardBeta data-key="Role" :descriptor="RoleDescriptor" />
|
||||
<VnCardBeta
|
||||
url="VnRoles"
|
||||
data-key="Role"
|
||||
:id-in-where="true"
|
||||
:descriptor="RoleDescriptor"
|
||||
/>
|
||||
</template>
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
<script setup>
|
||||
import { ref, computed } from 'vue';
|
||||
import { computed } from 'vue';
|
||||
import { useRoute } from 'vue-router';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import CardDescriptor from 'components/ui/CardDescriptor.vue';
|
||||
import VnLv from 'src/components/ui/VnLv.vue';
|
||||
import useCardDescription from 'src/composables/useCardDescription';
|
||||
import axios from 'axios';
|
||||
import useNotify from 'src/composables/useNotify.js';
|
||||
const $props = defineProps({
|
||||
|
@ -26,11 +25,6 @@ const { t } = useI18n();
|
|||
const entityId = computed(() => {
|
||||
return $props.id || route.params.id;
|
||||
});
|
||||
const data = ref(useCardDescription());
|
||||
const setData = (entity) => (data.value = useCardDescription(entity.name, entity.id));
|
||||
const filter = {
|
||||
where: { id: entityId },
|
||||
};
|
||||
const removeRole = async () => {
|
||||
await axios.delete(`VnRoles/${entityId.value}`);
|
||||
notify(t('Role removed'), 'positive');
|
||||
|
@ -39,13 +33,10 @@ const removeRole = async () => {
|
|||
|
||||
<template>
|
||||
<CardDescriptor
|
||||
:url="`VnRoles/${entityId}`"
|
||||
:filter="filter"
|
||||
url="VnRoles"
|
||||
:filter="{ where: { id: entityId } }"
|
||||
module="Role"
|
||||
@on-fetch="setData"
|
||||
data-key="Role"
|
||||
:title="data.title"
|
||||
:subtitle="data.subtitle"
|
||||
:summary="$props.summary"
|
||||
>
|
||||
<template #menu>
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
<script setup>
|
||||
import { ref, computed } from 'vue';
|
||||
import { computed } from 'vue';
|
||||
import { useRoute } from 'vue-router';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import CardSummary from 'components/ui/CardSummary.vue';
|
||||
import VnLv from 'src/components/ui/VnLv.vue';
|
||||
import { useArrayData } from 'src/composables/useArrayData';
|
||||
|
||||
const route = useRoute();
|
||||
const { t } = useI18n();
|
||||
|
@ -16,24 +15,18 @@ const $props = defineProps({
|
|||
},
|
||||
});
|
||||
|
||||
const { store } = useArrayData('Role');
|
||||
const role = ref(store.data);
|
||||
const entityId = computed(() => $props.id || route.params.id);
|
||||
const filter = {
|
||||
where: { id: entityId },
|
||||
};
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<CardSummary
|
||||
ref="summary"
|
||||
:url="`VnRoles/${entityId}`"
|
||||
:filter="filter"
|
||||
@on-fetch="(data) => (role = data)"
|
||||
url="VnRoles"
|
||||
:filter="{ where: { id: entityId } }"
|
||||
data-key="Role"
|
||||
>
|
||||
<template #header> {{ role.id }} - {{ role.name }} </template>
|
||||
<template #body>
|
||||
<template #header="{ entity }"> {{ entity.id }} - {{ entity.name }} </template>
|
||||
<template #body="{ entity }">
|
||||
<QCard class="vn-one">
|
||||
<QCardSection class="q-pa-none">
|
||||
<a
|
||||
|
@ -44,9 +37,9 @@ const filter = {
|
|||
<QIcon name="open_in_new" />
|
||||
</a>
|
||||
</QCardSection>
|
||||
<VnLv :label="t('role.id')" :value="role.id" />
|
||||
<VnLv :label="t('globals.name')" :value="role.name" />
|
||||
<VnLv :label="t('role.description')" :value="role.description" />
|
||||
<VnLv :label="t('role.id')" :value="entity.id" />
|
||||
<VnLv :label="t('globals.name')" :value="entity.name" />
|
||||
<VnLv :label="t('role.description')" :value="entity.description" />
|
||||
</QCard>
|
||||
</template>
|
||||
</CardSummary>
|
||||
|
|
|
@ -63,7 +63,7 @@ watch(
|
|||
store.url = urlPath.value;
|
||||
store.filter = filter.value;
|
||||
fetchSubRoles();
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
const fetchSubRoles = () => paginateRef.value.fetch();
|
||||
|
@ -80,7 +80,7 @@ const redirectToRoleSummary = (id) =>
|
|||
<VnPaginate
|
||||
ref="paginateRef"
|
||||
data-key="SubRoles"
|
||||
:filter="filter"
|
||||
:user-filter="filter"
|
||||
:url="urlPath"
|
||||
auto-load
|
||||
>
|
||||
|
@ -109,7 +109,7 @@ const redirectToRoleSummary = (id) =>
|
|||
openConfirmationModal(
|
||||
t('El rol va a ser eliminado'),
|
||||
t('¿Seguro que quieres continuar?'),
|
||||
() => deleteSubRole(row, rows, rowIndex)
|
||||
() => deleteSubRole(row, rows, rowIndex),
|
||||
)
|
||||
"
|
||||
>
|
||||
|
@ -131,7 +131,7 @@ const redirectToRoleSummary = (id) =>
|
|||
<QBtn
|
||||
fab
|
||||
icon="add"
|
||||
shortcut="+"
|
||||
v-shortcut="'+'"
|
||||
color="primary"
|
||||
@click="openCreateSubRoleForm()"
|
||||
>
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
export default (param, value) => {
|
||||
switch (param) {
|
||||
case 'search':
|
||||
return /^\d+$/.test(value)
|
||||
? { id: value }
|
||||
: {
|
||||
or: [
|
||||
{ name: { like: `%${value}%` } },
|
||||
{ nickname: { like: `%${value}%` } },
|
||||
],
|
||||
};
|
||||
case 'name':
|
||||
case 'description':
|
||||
return { [param]: { like: `%${value}%` } };
|
||||
}
|
||||
};
|
|
@ -28,7 +28,6 @@ const workersOptions = ref([]);
|
|||
model="Claim"
|
||||
:url-update="`Claims/updateClaim/${route.params.id}`"
|
||||
auto-load
|
||||
:reload="true"
|
||||
>
|
||||
<template #form="{ data, validate }">
|
||||
<VnRow>
|
||||
|
|
|
@ -4,10 +4,11 @@ import ClaimDescriptor from './ClaimDescriptor.vue';
|
|||
import filter from './ClaimFilter.js';
|
||||
</script>
|
||||
<template>
|
||||
<VnCardBeta
|
||||
data-key="Claim"
|
||||
base-url="Claims"
|
||||
:descriptor="ClaimDescriptor"
|
||||
<VnCardBeta
|
||||
data-key="Claim"
|
||||
url="Claims"
|
||||
:descriptor="ClaimDescriptor"
|
||||
search-data-key="ClaimList"
|
||||
:filter="filter"
|
||||
/>
|
||||
</template>
|
||||
|
|
|
@ -3,12 +3,10 @@ import { ref, computed, onMounted } from 'vue';
|
|||
import { useRoute } from 'vue-router';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { toDateHourMinSec, toPercentage } from 'src/filters';
|
||||
import { useState } from 'src/composables/useState';
|
||||
import TicketDescriptorProxy from 'pages/Ticket/Card/TicketDescriptorProxy.vue';
|
||||
import ClaimDescriptorMenu from 'pages/Claim/Card/ClaimDescriptorMenu.vue';
|
||||
import CardDescriptor from 'components/ui/CardDescriptor.vue';
|
||||
import VnLv from 'src/components/ui/VnLv.vue';
|
||||
import useCardDescription from 'src/composables/useCardDescription';
|
||||
import VnUserLink from 'src/components/ui/VnUserLink.vue';
|
||||
import { getUrl } from 'src/composables/getUrl';
|
||||
import ZoneDescriptorProxy from 'src/pages/Zone/Card/ZoneDescriptorProxy.vue';
|
||||
|
@ -23,7 +21,6 @@ const $props = defineProps({
|
|||
});
|
||||
|
||||
const route = useRoute();
|
||||
const state = useState();
|
||||
const { t } = useI18n();
|
||||
const salixUrl = ref();
|
||||
const entityId = computed(() => {
|
||||
|
@ -39,12 +36,7 @@ const STATE_COLOR = {
|
|||
function stateColor(code) {
|
||||
return STATE_COLOR[code];
|
||||
}
|
||||
const data = ref(useCardDescription());
|
||||
const setData = (entity) => {
|
||||
if (!entity) return;
|
||||
data.value = useCardDescription(entity?.client?.name, entity.id);
|
||||
state.set('ClaimDescriptor', entity);
|
||||
};
|
||||
|
||||
onMounted(async () => {
|
||||
salixUrl.value = await getUrl('');
|
||||
});
|
||||
|
@ -56,7 +48,6 @@ onMounted(async () => {
|
|||
:filter="filter"
|
||||
module="Claim"
|
||||
title="client.name"
|
||||
@on-fetch="setData"
|
||||
data-key="Claim"
|
||||
>
|
||||
<template #menu="{ entity }">
|
||||
|
|
|
@ -57,7 +57,6 @@ function onFetch(rows, newRows) {
|
|||
const price = row.quantity * sale.price;
|
||||
const discount = (sale.discount * price) / 100;
|
||||
amountClaimed.value = amountClaimed.value + (price - discount);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -208,7 +207,6 @@ async function saveWhenHasChanges() {
|
|||
selection="multiple"
|
||||
v-model:selected="selected"
|
||||
:grid="$q.screen.lt.md"
|
||||
|
||||
>
|
||||
<template #body-cell-claimed="{ row }">
|
||||
<QTd auto-width align="right" class="text-primary shrink">
|
||||
|
@ -319,7 +317,13 @@ async function saveWhenHasChanges() {
|
|||
</div>
|
||||
|
||||
<QPageSticky position="bottom-right" :offset="[25, 25]">
|
||||
<QBtn fab color="primary" shortcut="+" icon="add" @click="showImportDialog()" />
|
||||
<QBtn
|
||||
fab
|
||||
color="primary"
|
||||
v-shortcut="'+'"
|
||||
icon="add"
|
||||
@click="showImportDialog()"
|
||||
/>
|
||||
</QPageSticky>
|
||||
</template>
|
||||
|
||||
|
@ -330,9 +334,10 @@ async function saveWhenHasChanges() {
|
|||
width: 100%;
|
||||
}
|
||||
.grid-style-transition {
|
||||
transition: transform 0.28s, background-color 0.28s;
|
||||
transition:
|
||||
transform 0.28s,
|
||||
background-color 0.28s;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
<i18n>
|
||||
|
|
|
@ -61,7 +61,7 @@ watch(
|
|||
() => {
|
||||
claimDmsFilter.value.where.id = router.currentRoute.value.params.id;
|
||||
claimDmsRef.value.fetch();
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
function openDialog(dmsId) {
|
||||
|
@ -249,7 +249,7 @@ function onDrag() {
|
|||
<QBtn
|
||||
fab
|
||||
@click="inputFile.nativeEl.click()"
|
||||
shortcut="+"
|
||||
v-shortcut="'+'"
|
||||
icon="add"
|
||||
color="primary"
|
||||
>
|
||||
|
|
|
@ -61,7 +61,7 @@ watch(
|
|||
(newValue) => {
|
||||
if (!newValue) return;
|
||||
getClientData(newValue);
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
const getClientData = async (id) => {
|
||||
|
@ -117,7 +117,7 @@ const toCustomerAddressEdit = (addressId) => {
|
|||
data-key="CustomerAddresses"
|
||||
order="id DESC"
|
||||
ref="vnPaginateRef"
|
||||
:filter="addressFilter"
|
||||
:user-filter="addressFilter"
|
||||
:url="`Clients/${route.params.id}/addresses`"
|
||||
/>
|
||||
<div class="full-width flex justify-center">
|
||||
|
@ -137,7 +137,7 @@ const toCustomerAddressEdit = (addressId) => {
|
|||
<QIcon
|
||||
:style="{
|
||||
'font-variation-settings': `'FILL' ${isDefaultAddress(
|
||||
item
|
||||
item,
|
||||
)}`,
|
||||
}"
|
||||
color="primary"
|
||||
|
@ -150,7 +150,7 @@ const toCustomerAddressEdit = (addressId) => {
|
|||
t(
|
||||
isDefaultAddress(item)
|
||||
? 'Default address'
|
||||
: 'Set as default'
|
||||
: 'Set as default',
|
||||
)
|
||||
}}
|
||||
</QTooltip>
|
||||
|
@ -216,7 +216,7 @@ const toCustomerAddressEdit = (addressId) => {
|
|||
color="primary"
|
||||
fab
|
||||
icon="add"
|
||||
shortcut="+"
|
||||
v-shortcut="'+'"
|
||||
/>
|
||||
<QTooltip>
|
||||
{{ t('New consignee') }}
|
||||
|
|
|
@ -158,7 +158,7 @@ const columns = computed(() => [
|
|||
openConfirmationModal(
|
||||
t('Send compensation'),
|
||||
t('Do you want to report compensation to the client by mail?'),
|
||||
() => sendEmail(`Receipts/${id}/balance-compensation-email`)
|
||||
() => sendEmail(`Receipts/${id}/balance-compensation-email`),
|
||||
),
|
||||
},
|
||||
],
|
||||
|
@ -291,7 +291,7 @@ const showBalancePdf = ({ id }) => {
|
|||
color="primary"
|
||||
fab
|
||||
icon="add"
|
||||
shortcut="+"
|
||||
v-shortcut="'+'"
|
||||
/>
|
||||
<QTooltip>
|
||||
{{ t('New payment') }}
|
||||
|
|
|
@ -54,10 +54,10 @@ function onBeforeSave(formData, originalData) {
|
|||
auto-load
|
||||
/>
|
||||
<FormModel
|
||||
:url="`Clients/${route.params.id}`"
|
||||
:url-update="`Clients/${route.params.id}`"
|
||||
auto-load
|
||||
model="customer"
|
||||
:mapper="onBeforeSave"
|
||||
model="Customer"
|
||||
>
|
||||
<template #form="{ data, validate }">
|
||||
<VnRow>
|
||||
|
|
|
@ -28,7 +28,7 @@ const getBankEntities = (data, formData) => {
|
|||
</script>
|
||||
|
||||
<template>
|
||||
<FormModel :url-update="`Clients/${route.params.id}`" auto-load model="customer">
|
||||
<FormModel :url-update="`Clients/${route.params.id}`" auto-load model="Customer">
|
||||
<template #form="{ data, validate }">
|
||||
<VnRow>
|
||||
<VnSelect
|
||||
|
|
|
@ -5,8 +5,8 @@ import CustomerDescriptor from './CustomerDescriptor.vue';
|
|||
|
||||
<template>
|
||||
<VnCardBeta
|
||||
data-key="Client"
|
||||
base-url="Clients"
|
||||
data-key="Customer"
|
||||
:url="`Clients/${$route.params.id}/getCard`"
|
||||
:descriptor="CustomerDescriptor"
|
||||
/>
|
||||
</template>
|
||||
|
|
|
@ -62,7 +62,7 @@ const customerContactsRef = ref(null);
|
|||
color="primary"
|
||||
flat
|
||||
icon="add"
|
||||
shortcut="+"
|
||||
v-shortcut="'+'"
|
||||
>
|
||||
<QTooltip>
|
||||
{{ t('Add contact') }}
|
||||
|
|
|
@ -75,7 +75,7 @@ const updateData = () => {
|
|||
<div class="full-width flex justify-center">
|
||||
<QCard class="card-width q-pa-lg">
|
||||
<VnPaginate
|
||||
:filter="filter"
|
||||
:user-filter="filter"
|
||||
@on-fetch="fetch"
|
||||
auto-load
|
||||
data-key="CustomerCreditContracts"
|
||||
|
@ -195,7 +195,7 @@ const updateData = () => {
|
|||
color="primary"
|
||||
fab
|
||||
icon="add"
|
||||
shortcut="+"
|
||||
v-shortcut="'+'"
|
||||
/>
|
||||
<QTooltip>
|
||||
{{ t('New contract') }}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<script setup>
|
||||
import { ref, computed } from 'vue';
|
||||
import { onMounted, ref, computed } from 'vue';
|
||||
import { useRoute } from 'vue-router';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
|
||||
|
@ -11,6 +11,15 @@ import CardDescriptor from 'components/ui/CardDescriptor.vue';
|
|||
import VnLv from 'src/components/ui/VnLv.vue';
|
||||
import VnUserLink from 'src/components/ui/VnUserLink.vue';
|
||||
import CustomerDescriptorMenu from './CustomerDescriptorMenu.vue';
|
||||
import { useState } from 'src/composables/useState';
|
||||
const state = useState();
|
||||
|
||||
const customer = ref();
|
||||
|
||||
onMounted(async () => {
|
||||
customer.value = state.get('Customer');
|
||||
if (customer.value) customer.value.webAccess = data.value?.account?.isActive;
|
||||
});
|
||||
|
||||
const customerDebt = ref();
|
||||
const customerCredit = ref();
|
||||
|
@ -48,11 +57,9 @@ const debtWarning = computed(() => {
|
|||
<CardDescriptor
|
||||
module="Customer"
|
||||
:url="`Clients/${entityId}/getCard`"
|
||||
:title="data.title"
|
||||
:subtitle="data.subtitle"
|
||||
@on-fetch="setData"
|
||||
:summary="$props.summary"
|
||||
data-key="customer"
|
||||
data-key="Customer"
|
||||
@on-fetch="setData"
|
||||
width="lg-width"
|
||||
>
|
||||
<template #menu="{ entity }">
|
||||
|
@ -61,7 +68,7 @@ const debtWarning = computed(() => {
|
|||
<template #body="{ entity }">
|
||||
<VnLv
|
||||
:label="t('customer.summary.payMethod')"
|
||||
:value="entity.payMethod.name"
|
||||
:value="entity.payMethod?.name"
|
||||
/>
|
||||
|
||||
<VnLv
|
||||
|
@ -90,7 +97,7 @@ const debtWarning = computed(() => {
|
|||
</VnLv>
|
||||
<VnLv
|
||||
:label="t('customer.extendedList.tableVisibleColumns.businessTypeFk')"
|
||||
:value="entity.businessType.description"
|
||||
:value="entity.businessType?.description"
|
||||
/>
|
||||
</template>
|
||||
<template #icons="{ entity }">
|
||||
|
@ -157,13 +164,13 @@ const debtWarning = computed(() => {
|
|||
<br />
|
||||
{{
|
||||
t('unpaidDated', {
|
||||
dated: toDate(customer.unpaid.dated),
|
||||
dated: toDate(customer.unpaid?.dated),
|
||||
})
|
||||
}}
|
||||
<br />
|
||||
{{
|
||||
t('unpaidAmount', {
|
||||
amount: toCurrency(customer.unpaid.amount),
|
||||
amount: toCurrency(customer.unpaid?.amount),
|
||||
})
|
||||
}}
|
||||
</QTooltip>
|
||||
|
|
|
@ -236,7 +236,7 @@ const toCustomerFileManagementCreate = () => {
|
|||
@click.stop="toCustomerFileManagementCreate()"
|
||||
color="primary"
|
||||
fab
|
||||
shortcut="+"
|
||||
v-shortcut="'+'"
|
||||
icon="add"
|
||||
/>
|
||||
<QTooltip>
|
||||
|
|
|
@ -35,7 +35,7 @@ function handleLocation(data, location) {
|
|||
<FormModel
|
||||
:url-update="`Clients/${route.params.id}/updateFiscalData`"
|
||||
auto-load
|
||||
model="customer"
|
||||
model="Customer"
|
||||
>
|
||||
<template #form="{ data, validate }">
|
||||
<VnRow>
|
||||
|
|
|
@ -104,7 +104,7 @@ const tableRef = ref();
|
|||
color="primary"
|
||||
fab
|
||||
icon="add"
|
||||
shortcut="+"
|
||||
v-shortcut="'+'"
|
||||
/>
|
||||
<QTooltip>
|
||||
{{ t('Send sample') }}
|
||||
|
|
|
@ -27,7 +27,7 @@ async function hasCustomerRole() {
|
|||
<FormModel
|
||||
:url-update="`Clients/${route.params.id}/updateUser`"
|
||||
:filter="filter"
|
||||
model="customer"
|
||||
model="Customer"
|
||||
:mapper="
|
||||
({ account }) => {
|
||||
const { name, email, active } = account;
|
||||
|
|
|
@ -49,7 +49,7 @@ const getData = async (observations) => {
|
|||
notes.value = originalNotes
|
||||
.map((observation) => {
|
||||
const type = observationTypes.value.find(
|
||||
(type) => type.id === observation.observationTypeFk
|
||||
(type) => type.id === observation.observationTypeFk,
|
||||
);
|
||||
return type
|
||||
? {
|
||||
|
@ -112,8 +112,8 @@ function getPayload() {
|
|||
(oNote) =>
|
||||
oNote.id === note.id &&
|
||||
(note.description !== oNote.description ||
|
||||
note.observationTypeFk !== oNote.observationTypeFk)
|
||||
)
|
||||
note.observationTypeFk !== oNote.observationTypeFk),
|
||||
),
|
||||
)
|
||||
.map((note) => ({
|
||||
data: note,
|
||||
|
@ -130,9 +130,7 @@ async function handleDialog(data) {
|
|||
.dialog({
|
||||
component: VnConfirm,
|
||||
componentProps: {
|
||||
title: t(
|
||||
'confirmTicket'
|
||||
),
|
||||
title: t('confirmTicket'),
|
||||
message: t('confirmDeletionMessage'),
|
||||
},
|
||||
})
|
||||
|
@ -341,7 +339,7 @@ function handleLocation(data, location) {
|
|||
class="cursor-pointer add-icon q-mt-md"
|
||||
flat
|
||||
icon="add"
|
||||
shortcut="+"
|
||||
v-shortcut="'+'"
|
||||
>
|
||||
<QTooltip>
|
||||
{{ t('Add note') }}
|
||||
|
|
|
@ -39,7 +39,7 @@ const optionsSamplesVisible = ref([]);
|
|||
const sampleType = ref({ hasPreview: false });
|
||||
const initialData = reactive({});
|
||||
const entityId = computed(() => route.params.id);
|
||||
const customer = computed(() => state.get('customer'));
|
||||
const customer = computed(() => state.get('Customer'));
|
||||
const filterEmailUsers = { where: { userFk: user.value.id } };
|
||||
const filterClientsAddresses = {
|
||||
include: [
|
||||
|
|
|
@ -1,27 +1,16 @@
|
|||
<script setup>
|
||||
import { useRoute } from 'vue-router';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
|
||||
import FormModel from 'components/FormModel.vue';
|
||||
import VnRow from 'components/ui/VnRow.vue';
|
||||
import VnInput from 'src/components/common/VnInput.vue';
|
||||
import VnSelect from 'src/components/common/VnSelect.vue';
|
||||
import VnSelectWorker from 'src/components/common/VnSelectWorker.vue';
|
||||
|
||||
const route = useRoute();
|
||||
const { t } = useI18n();
|
||||
</script>
|
||||
<template>
|
||||
<FormModel
|
||||
:url="`Departments/${route.params.id}`"
|
||||
model="department"
|
||||
auto-load
|
||||
class="full-width"
|
||||
>
|
||||
<FormModel model="Department" auto-load class="full-width">
|
||||
<template #form="{ data, validate }">
|
||||
<VnRow>
|
||||
<VnInput
|
||||
:label="t('globals.name')"
|
||||
:label="$t('globals.name')"
|
||||
v-model="data.name"
|
||||
:rules="validate('globals.name')"
|
||||
clearable
|
||||
|
@ -29,33 +18,33 @@ const { t } = useI18n();
|
|||
/>
|
||||
<VnInput
|
||||
v-model="data.code"
|
||||
:label="t('globals.code')"
|
||||
:label="$t('globals.code')"
|
||||
:rules="validate('globals.code')"
|
||||
clearable
|
||||
/>
|
||||
</VnRow>
|
||||
<VnRow>
|
||||
<VnInput
|
||||
:label="t('department.chat')"
|
||||
:label="$t('department.chat')"
|
||||
v-model="data.chatName"
|
||||
:rules="validate('department.chat')"
|
||||
clearable
|
||||
/>
|
||||
<VnInput
|
||||
v-model="data.notificationEmail"
|
||||
:label="t('globals.params.email')"
|
||||
:label="$t('globals.params.email')"
|
||||
:rules="validate('globals.params.email')"
|
||||
clearable
|
||||
/>
|
||||
</VnRow>
|
||||
<VnRow>
|
||||
<VnSelectWorker
|
||||
:label="t('department.bossDepartment')"
|
||||
:label="$t('department.bossDepartment')"
|
||||
v-model="data.workerFk"
|
||||
:rules="validate('department.bossDepartment')"
|
||||
/>
|
||||
<VnSelect
|
||||
:label="t('department.selfConsumptionCustomer')"
|
||||
:label="$t('department.selfConsumptionCustomer')"
|
||||
v-model="data.clientFk"
|
||||
url="Clients"
|
||||
option-value="id"
|
||||
|
@ -67,11 +56,11 @@ const { t } = useI18n();
|
|||
</VnRow>
|
||||
<VnRow>
|
||||
<QCheckbox
|
||||
:label="t('department.telework')"
|
||||
:label="$t('department.telework')"
|
||||
v-model="data.isTeleworking"
|
||||
/>
|
||||
<QCheckbox
|
||||
:label="t('department.notifyOnErrors')"
|
||||
:label="$t('department.notifyOnErrors')"
|
||||
v-model="data.hasToMistake"
|
||||
:false-value="0"
|
||||
:true-value="1"
|
||||
|
@ -79,17 +68,17 @@ const { t } = useI18n();
|
|||
</VnRow>
|
||||
<VnRow>
|
||||
<QCheckbox
|
||||
:label="t('department.worksInProduction')"
|
||||
:label="$t('department.worksInProduction')"
|
||||
v-model="data.isProduction"
|
||||
/>
|
||||
<QCheckbox
|
||||
:label="t('department.hasToRefill')"
|
||||
:label="$t('department.hasToRefill')"
|
||||
v-model="data.hasToRefill"
|
||||
/>
|
||||
</VnRow>
|
||||
<VnRow>
|
||||
<QCheckbox
|
||||
:label="t('department.hasToSendMail')"
|
||||
:label="$t('department.hasToSendMail')"
|
||||
v-model="data.hasToSendMail"
|
||||
/>
|
||||
</VnRow>
|
||||
|
|
|
@ -7,7 +7,7 @@ import DepartmentDescriptor from 'pages/Department/Card/DepartmentDescriptor.vue
|
|||
class="q-pa-md column items-center"
|
||||
v-bind="{ ...$attrs }"
|
||||
data-key="Department"
|
||||
base-url="Departments"
|
||||
url="Departments"
|
||||
:descriptor="DepartmentDescriptor"
|
||||
/>
|
||||
</template>
|
||||
|
|
|
@ -5,7 +5,6 @@ import { useI18n } from 'vue-i18n';
|
|||
import { useVnConfirm } from 'composables/useVnConfirm';
|
||||
import VnLv from 'src/components/ui/VnLv.vue';
|
||||
import CardDescriptor from 'src/components/ui/CardDescriptor.vue';
|
||||
import useCardDescription from 'src/composables/useCardDescription';
|
||||
|
||||
import axios from 'axios';
|
||||
import useNotify from 'src/composables/useNotify.js';
|
||||
|
@ -32,15 +31,6 @@ const entityId = computed(() => {
|
|||
return $props.id || route.params.id;
|
||||
});
|
||||
|
||||
const department = ref();
|
||||
|
||||
const data = ref(useCardDescription());
|
||||
|
||||
const setData = (entity) => {
|
||||
if (!entity) return;
|
||||
data.value = useCardDescription(entity.name, entity.id);
|
||||
};
|
||||
|
||||
const removeDepartment = async () => {
|
||||
await axios.post(`/Departments/${entityId.value}/removeChild`, entityId.value);
|
||||
router.push({ name: 'WorkerDepartment' });
|
||||
|
@ -54,17 +44,9 @@ const { openConfirmationModal } = useVnConfirm();
|
|||
ref="DepartmentDescriptorRef"
|
||||
module="Department"
|
||||
:url="`Departments/${entityId}`"
|
||||
:title="data.title"
|
||||
:subtitle="data.subtitle"
|
||||
:summary="$props.summary"
|
||||
:to-module="{ name: 'WorkerDepartment' }"
|
||||
@on-fetch="
|
||||
(data) => {
|
||||
department = data;
|
||||
setData(data);
|
||||
}
|
||||
"
|
||||
data-key="department"
|
||||
data-key="Department"
|
||||
>
|
||||
<template #menu="{}">
|
||||
<QItem
|
||||
|
@ -74,7 +56,7 @@ const { openConfirmationModal } = useVnConfirm();
|
|||
openConfirmationModal(
|
||||
t('Are you sure you want to delete it?'),
|
||||
t('Delete department'),
|
||||
removeDepartment
|
||||
removeDepartment,
|
||||
)
|
||||
"
|
||||
>
|
||||
|
|
|
@ -27,7 +27,7 @@ onMounted(async () => {
|
|||
|
||||
<template>
|
||||
<CardSummary
|
||||
data-key="DepartmentSummary"
|
||||
data-key="Department"
|
||||
ref="summary"
|
||||
:url="`Departments/${entityId}`"
|
||||
class="full-width"
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
<script setup>
|
||||
import VnCardBeta from 'components/common/VnCardBeta.vue';
|
||||
import EntryDescriptor from './EntryDescriptor.vue';
|
||||
import filter from './EntryFilter.js'
|
||||
import filter from './EntryFilter.js';
|
||||
</script>
|
||||
<template>
|
||||
<VnCardBeta
|
||||
data-key="Entry"
|
||||
base-url="Entries"
|
||||
url="Entries"
|
||||
:descriptor="EntryDescriptor"
|
||||
:user-filter="filter"
|
||||
:filter="filter"
|
||||
/>
|
||||
</template>
|
||||
|
|
|
@ -17,7 +17,7 @@ const selected = ref([]);
|
|||
|
||||
const sortEntryObservationOptions = (data) => {
|
||||
entryObservationsOptions.value = [...data].sort((a, b) =>
|
||||
a.description.localeCompare(b.description)
|
||||
a.description.localeCompare(b.description),
|
||||
);
|
||||
};
|
||||
|
||||
|
@ -142,7 +142,7 @@ const columns = computed(() => [
|
|||
fab
|
||||
color="primary"
|
||||
icon="add"
|
||||
shortcut="+"
|
||||
v-shortcut="'+'"
|
||||
@click="entryObservationsRef.insert()"
|
||||
/>
|
||||
</QPageSticky>
|
||||
|
|
|
@ -215,7 +215,7 @@ function deleteFile(dmsFk) {
|
|||
v-else
|
||||
icon="add_circle"
|
||||
round
|
||||
shortcut="+"
|
||||
v-shortcut="'+'"
|
||||
padding="xs"
|
||||
@click="
|
||||
() => {
|
||||
|
|
|
@ -1,47 +1,18 @@
|
|||
<script setup>
|
||||
import VnCardBeta from 'components/common/VnCardBeta.vue';
|
||||
import InvoiceInDescriptor from './InvoiceInDescriptor.vue';
|
||||
import { onBeforeRouteUpdate } from 'vue-router';
|
||||
import { setRectificative } from '../composables/setRectificative';
|
||||
import filter from './InvoiceInFilter.js';
|
||||
|
||||
const filter = {
|
||||
include: [
|
||||
{
|
||||
relation: 'supplier',
|
||||
scope: {
|
||||
include: {
|
||||
relation: 'contacts',
|
||||
scope: { where: { email: { neq: null } } },
|
||||
},
|
||||
},
|
||||
},
|
||||
{ relation: 'invoiceInDueDay' },
|
||||
{ relation: 'company' },
|
||||
{ relation: 'currency' },
|
||||
{
|
||||
relation: 'dms',
|
||||
scope: {
|
||||
fields: [
|
||||
'dmsTypeFk',
|
||||
'reference',
|
||||
'hardCopyNumber',
|
||||
'workerFk',
|
||||
'description',
|
||||
'hasFile',
|
||||
'file',
|
||||
'created',
|
||||
'companyFk',
|
||||
'warehouseFk',
|
||||
],
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
onBeforeRouteUpdate(async (to) => await setRectificative(to));
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<VnCardBeta
|
||||
data-key="InvoiceIn"
|
||||
base-url="InvoiceIns"
|
||||
url="InvoiceIns"
|
||||
:descriptor="InvoiceInDescriptor"
|
||||
:user-filter="filter"
|
||||
:filter="filter"
|
||||
/>
|
||||
</template>
|
||||
|
|
|
@ -7,6 +7,7 @@ import { toCurrency, toDate } from 'src/filters';
|
|||
import VnLv from 'src/components/ui/VnLv.vue';
|
||||
import CardDescriptor from 'components/ui/CardDescriptor.vue';
|
||||
import SupplierDescriptorProxy from 'src/pages/Supplier/Card/SupplierDescriptorProxy.vue';
|
||||
import filter from './InvoiceInFilter.js';
|
||||
import InvoiceInDescriptorMenu from './InvoiceInDescriptorMenu.vue';
|
||||
|
||||
const $props = defineProps({ id: { type: Number, default: null } });
|
||||
|
@ -16,33 +17,10 @@ const { t } = useI18n();
|
|||
const cardDescriptorRef = ref();
|
||||
const entityId = computed(() => $props.id || +currentRoute.value.params.id);
|
||||
const totalAmount = ref();
|
||||
|
||||
const filter = {
|
||||
include: [
|
||||
{
|
||||
relation: 'supplier',
|
||||
scope: {
|
||||
include: {
|
||||
relation: 'contacts',
|
||||
scope: {
|
||||
where: {
|
||||
email: { neq: null },
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
relation: 'invoiceInDueDay',
|
||||
},
|
||||
{
|
||||
relation: 'company',
|
||||
},
|
||||
{
|
||||
relation: 'currency',
|
||||
},
|
||||
],
|
||||
};
|
||||
const config = ref();
|
||||
const cplusRectificationTypes = ref([]);
|
||||
const siiTypeInvoiceIns = ref([]);
|
||||
const invoiceCorrectionTypes = ref([]);
|
||||
const invoiceInCorrection = reactive({ correcting: [], corrected: null });
|
||||
const routes = reactive({
|
||||
getSupplier: (id) => {
|
||||
|
|
|
@ -232,7 +232,7 @@ async function insert() {
|
|||
<QBtn
|
||||
color="primary"
|
||||
icon="add"
|
||||
shortcut="+"
|
||||
v-shortcut="'+'"
|
||||
size="lg"
|
||||
round
|
||||
@click="!areRows ? insert() : invoiceInFormRef.insert()"
|
||||
|
|
|
@ -0,0 +1,33 @@
|
|||
export default {
|
||||
include: [
|
||||
{
|
||||
relation: 'supplier',
|
||||
scope: {
|
||||
include: {
|
||||
relation: 'contacts',
|
||||
scope: { where: { email: { neq: null } } },
|
||||
},
|
||||
},
|
||||
},
|
||||
{ relation: 'invoiceInDueDay' },
|
||||
{ relation: 'company' },
|
||||
{ relation: 'currency' },
|
||||
{
|
||||
relation: 'dms',
|
||||
scope: {
|
||||
fields: [
|
||||
'dmsTypeFk',
|
||||
'reference',
|
||||
'hardCopyNumber',
|
||||
'workerFk',
|
||||
'description',
|
||||
'hasFile',
|
||||
'file',
|
||||
'created',
|
||||
'companyFk',
|
||||
'warehouseFk',
|
||||
],
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
|
@ -218,7 +218,7 @@ const columns = computed(() => [
|
|||
<QBtn
|
||||
color="primary"
|
||||
icon="add"
|
||||
shortcut="+"
|
||||
v-shortcut="'+'"
|
||||
size="lg"
|
||||
round
|
||||
@click="invoiceInFormRef.insert()"
|
||||
|
|
|
@ -117,7 +117,7 @@ const isNotEuro = (code) => code != 'EUR';
|
|||
function taxRate(invoiceInTax) {
|
||||
const sageTaxTypeId = invoiceInTax.taxTypeSageFk;
|
||||
const taxRateSelection = sageTaxTypes.value.find(
|
||||
(transaction) => transaction.id == sageTaxTypeId
|
||||
(transaction) => transaction.id == sageTaxTypeId,
|
||||
);
|
||||
const taxTypeSage = taxRateSelection?.rate ?? 0;
|
||||
const taxableBase = invoiceInTax?.taxableBase ?? 0;
|
||||
|
@ -131,14 +131,14 @@ function autocompleteExpense(evt, row, col) {
|
|||
|
||||
const param = isNaN(val) ? row[col.model] : val;
|
||||
const lookup = expenses.value.find(
|
||||
({ id }) => id == useAccountShortToStandard(param)
|
||||
({ id }) => id == useAccountShortToStandard(param),
|
||||
);
|
||||
|
||||
expenseRef.value.vnSelectDialogRef.vnSelectRef.toggleOption(lookup);
|
||||
}
|
||||
|
||||
const taxableBaseTotal = computed(() => {
|
||||
return getTotal(invoiceInFormRef.value.formData, 'taxableBase', );
|
||||
const taxableBaseTotal = computed(() => {
|
||||
return getTotal(invoiceInFormRef.value.formData, 'taxableBase');
|
||||
});
|
||||
|
||||
const taxRateTotal = computed(() => {
|
||||
|
@ -147,13 +147,9 @@ const taxRateTotal = computed(() => {
|
|||
});
|
||||
});
|
||||
|
||||
|
||||
const combinedTotal = computed(() => {
|
||||
return +taxableBaseTotal.value + +taxRateTotal.value;
|
||||
});
|
||||
|
||||
|
||||
|
||||
</script>
|
||||
<template>
|
||||
<FetchData
|
||||
|
@ -283,7 +279,7 @@ const combinedTotal = computed(() => {
|
|||
row.taxableBase = await getExchange(
|
||||
val,
|
||||
row.currencyFk,
|
||||
invoiceIn.issued
|
||||
invoiceIn.issued,
|
||||
);
|
||||
}
|
||||
"
|
||||
|
@ -426,7 +422,7 @@ const combinedTotal = computed(() => {
|
|||
color="primary"
|
||||
icon="add"
|
||||
size="lg"
|
||||
shortcut="+"
|
||||
v-shortcut="'+'"
|
||||
round
|
||||
@click="invoiceInFormRef.insert()"
|
||||
>
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
<script setup>
|
||||
import InvoiceOutDescriptor from './InvoiceOutDescriptor.vue';
|
||||
import VnCardBeta from 'components/common/VnCardBeta.vue';
|
||||
import filter from './InvoiceOutFilter.js';
|
||||
</script>
|
||||
<template>
|
||||
<VnCardBeta
|
||||
data-key="InvoiceOut"
|
||||
base-url="InvoiceOuts"
|
||||
url="InvoiceOuts"
|
||||
:filter="filter"
|
||||
:descriptor="InvoiceOutDescriptor"
|
||||
/>
|
||||
</template>
|
||||
|
|
|
@ -8,8 +8,8 @@ import CustomerDescriptorProxy from 'pages/Customer/Card/CustomerDescriptorProxy
|
|||
import VnLv from 'src/components/ui/VnLv.vue';
|
||||
import InvoiceOutDescriptorMenu from './InvoiceOutDescriptorMenu.vue';
|
||||
|
||||
import useCardDescription from 'src/composables/useCardDescription';
|
||||
import { toCurrency, toDate } from 'src/filters';
|
||||
import filter from './InvoiceOutFilter.js';
|
||||
|
||||
const $props = defineProps({
|
||||
id: {
|
||||
|
@ -26,30 +26,11 @@ const entityId = computed(() => {
|
|||
return $props.id || route.params.id;
|
||||
});
|
||||
|
||||
const filter = {
|
||||
include: [
|
||||
{
|
||||
relation: 'company',
|
||||
scope: {
|
||||
fields: ['id', 'code'],
|
||||
},
|
||||
},
|
||||
{
|
||||
relation: 'client',
|
||||
scope: {
|
||||
fields: ['id', 'name', 'email'],
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
const descriptor = ref();
|
||||
|
||||
function ticketFilter(invoice) {
|
||||
return JSON.stringify({ refFk: invoice.ref });
|
||||
}
|
||||
const data = ref(useCardDescription());
|
||||
const setData = (entity) => (data.value = useCardDescription(entity.ref, entity.id));
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
@ -58,10 +39,8 @@ const setData = (entity) => (data.value = useCardDescription(entity.ref, entity.
|
|||
module="InvoiceOut"
|
||||
:url="`InvoiceOuts/${entityId}`"
|
||||
:filter="filter"
|
||||
:title="data.title"
|
||||
:subtitle="data.subtitle"
|
||||
@on-fetch="setData"
|
||||
data-key="invoiceOutData"
|
||||
title="ref"
|
||||
data-key="InvoiceOut"
|
||||
width="lg-width"
|
||||
>
|
||||
<template #menu="{ entity, menuRef }">
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
export default {
|
||||
include: [
|
||||
{
|
||||
relation: 'company',
|
||||
scope: {
|
||||
fields: ['id', 'code'],
|
||||
},
|
||||
},
|
||||
{
|
||||
relation: 'client',
|
||||
scope: {
|
||||
fields: ['id', 'name', 'email'],
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
|
@ -92,7 +92,7 @@ const submit = async (rows) => {
|
|||
class="cursor-pointer fill-icon-on-hover"
|
||||
color="primary"
|
||||
icon="add_circle"
|
||||
shortcut="+"
|
||||
v-shortcut="'+'"
|
||||
flat
|
||||
>
|
||||
<QTooltip>
|
||||
|
|
|
@ -54,9 +54,8 @@ const onIntrastatCreated = (response, formData) => {
|
|||
auto-load
|
||||
/>
|
||||
<FormModel
|
||||
:url="`Items/${route.params.id}`"
|
||||
:url-update="`Items/${route.params.id}`"
|
||||
model="item"
|
||||
model="Item"
|
||||
auto-load
|
||||
:clear-store-on-unmount="false"
|
||||
>
|
||||
|
|
|
@ -5,7 +5,7 @@ import ItemDescriptor from './ItemDescriptor.vue';
|
|||
<template>
|
||||
<VnCardBeta
|
||||
data-key="Item"
|
||||
base-url="Items"
|
||||
:url="`Items/${$route.params.id}/getCard`"
|
||||
:descriptor="ItemDescriptor"
|
||||
/>
|
||||
</template>
|
||||
|
|
|
@ -7,7 +7,6 @@ import CardDescriptor from 'src/components/ui/CardDescriptor.vue';
|
|||
import VnLv from 'src/components/ui/VnLv.vue';
|
||||
import WorkerDescriptorProxy from 'src/pages/Worker/Card/WorkerDescriptorProxy.vue';
|
||||
import ItemDescriptorImage from 'src/pages/Item/Card/ItemDescriptorImage.vue';
|
||||
import useCardDescription from 'src/composables/useCardDescription';
|
||||
import axios from 'axios';
|
||||
import { dashIfEmpty } from 'src/filters';
|
||||
import { useArrayData } from 'src/composables/useArrayData';
|
||||
|
@ -55,10 +54,8 @@ onMounted(async () => {
|
|||
mounted.value = true;
|
||||
});
|
||||
|
||||
const data = ref(useCardDescription());
|
||||
const setData = async (entity) => {
|
||||
if (!entity) return;
|
||||
data.value = useCardDescription(entity.name, entity.id);
|
||||
await updateStock();
|
||||
};
|
||||
|
||||
|
@ -90,10 +87,8 @@ const updateStock = async () => {
|
|||
|
||||
<template>
|
||||
<CardDescriptor
|
||||
data-key="ItemData"
|
||||
data-key="Item"
|
||||
module="Item"
|
||||
:title="data.title"
|
||||
:subtitle="data.subtitle"
|
||||
:summary="$props.summary"
|
||||
:url="`Items/${entityId}/getCard`"
|
||||
@on-fetch="setData"
|
||||
|
|
|
@ -175,7 +175,7 @@ const insertTag = (rows) => {
|
|||
@click="insertTag(rows)"
|
||||
color="primary"
|
||||
icon="add"
|
||||
shortcut="+"
|
||||
v-shortcut="'+'"
|
||||
fab
|
||||
>
|
||||
<QTooltip>
|
||||
|
|
|
@ -40,12 +40,7 @@ const itemPackingTypesOptions = ref([]);
|
|||
}"
|
||||
auto-load
|
||||
/>
|
||||
<FormModel
|
||||
:url="`ItemTypes/${route.params.id}`"
|
||||
:url-update="`ItemTypes/${route.params.id}`"
|
||||
model="itemTypeBasicData"
|
||||
auto-load
|
||||
>
|
||||
<FormModel :url-update="`ItemTypes/${route.params.id}`" model="ItemType" auto-load>
|
||||
<template #form="{ data }">
|
||||
<VnRow>
|
||||
<VnInput v-model="data.code" :label="t('itemType.shared.code')" />
|
||||
|
|
|
@ -1,12 +1,14 @@
|
|||
<script setup>
|
||||
import VnCardBeta from 'components/common/VnCardBeta.vue';
|
||||
import ItemTypeDescriptor from 'src/pages/Item/ItemType/Card/ItemTypeDescriptor.vue';
|
||||
import filter from './ItemTypeFilter.js';
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<VnCardBeta
|
||||
data-key="ItemTypeSummary"
|
||||
base-url="ItemTypes"
|
||||
data-key="ItemType"
|
||||
url="ItemTypes"
|
||||
:filter="filter"
|
||||
:descriptor="ItemTypeDescriptor"
|
||||
/>
|
||||
</template>
|
||||
|
|
|
@ -1,12 +1,11 @@
|
|||
<script setup>
|
||||
import { ref, computed } from 'vue';
|
||||
import { computed } from 'vue';
|
||||
import { useRoute } from 'vue-router';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
|
||||
import CardDescriptor from 'components/ui/CardDescriptor.vue';
|
||||
import VnLv from 'src/components/ui/VnLv.vue';
|
||||
import WorkerDescriptorProxy from 'src/pages/Worker/Card/WorkerDescriptorProxy.vue';
|
||||
import useCardDescription from 'src/composables/useCardDescription';
|
||||
import filter from './ItemTypeFilter.js';
|
||||
|
||||
const $props = defineProps({
|
||||
id: {
|
||||
|
@ -20,46 +19,32 @@ const $props = defineProps({
|
|||
});
|
||||
|
||||
const route = useRoute();
|
||||
const { t } = useI18n();
|
||||
|
||||
const entityId = computed(() => {
|
||||
return $props.id || route.params.id;
|
||||
});
|
||||
|
||||
const itemTypeFilter = {
|
||||
include: [
|
||||
{ relation: 'worker' },
|
||||
{ relation: 'category' },
|
||||
{ relation: 'itemPackingType' },
|
||||
{ relation: 'temperature' },
|
||||
],
|
||||
};
|
||||
|
||||
const data = ref(useCardDescription());
|
||||
const setData = (entity) => (data.value = useCardDescription(entity.code, entity.id));
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<CardDescriptor
|
||||
module="ItemType"
|
||||
:url="`ItemTypes/${entityId}`"
|
||||
:filter="itemTypeFilter"
|
||||
:title="data.title"
|
||||
:subtitle="data.subtitle"
|
||||
data-key="itemTypeDescriptor"
|
||||
@on-fetch="setData"
|
||||
:filter="filter"
|
||||
title="code"
|
||||
data-key="ItemType"
|
||||
>
|
||||
<template #body="{ entity }">
|
||||
<VnLv :label="t('itemType.shared.code')" :value="entity.code" />
|
||||
<VnLv :label="t('itemType.shared.name')" :value="entity.name" />
|
||||
<VnLv :label="t('itemType.shared.worker')">
|
||||
<VnLv :label="$t('itemType.shared.code')" :value="entity.code" />
|
||||
<VnLv :label="$t('itemType.shared.name')" :value="entity.name" />
|
||||
<VnLv :label="$t('itemType.shared.worker')">
|
||||
<template #value>
|
||||
<span class="link">{{ entity.worker?.firstName }}</span>
|
||||
<WorkerDescriptorProxy :id="entity.worker?.id" />
|
||||
</template>
|
||||
</VnLv>
|
||||
<VnLv :label="t('itemType.shared.category')" :value="entity.category?.name" />
|
||||
<VnLv
|
||||
:label="$t('itemType.shared.category')"
|
||||
:value="entity.category?.name"
|
||||
/>
|
||||
</template>
|
||||
</CardDescriptor>
|
||||
</template>
|
||||
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
export default {
|
||||
include: [
|
||||
{ relation: 'worker' },
|
||||
{ relation: 'category' },
|
||||
{ relation: 'itemPackingType' },
|
||||
{ relation: 'temperature' },
|
||||
],
|
||||
};
|
|
@ -3,7 +3,7 @@ import { ref, computed, onUpdated } from 'vue';
|
|||
import { useRoute } from 'vue-router';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import WorkerDescriptorProxy from 'src/pages/Worker/Card/WorkerDescriptorProxy.vue';
|
||||
|
||||
import filter from './ItemTypeFilter.js';
|
||||
import CardSummary from 'components/ui/CardSummary.vue';
|
||||
import VnLv from 'src/components/ui/VnLv.vue';
|
||||
import VnToSummary from 'src/components/ui/VnToSummary.vue';
|
||||
|
@ -21,15 +21,6 @@ const $props = defineProps({
|
|||
},
|
||||
});
|
||||
|
||||
const itemTypeFilter = {
|
||||
include: [
|
||||
{ relation: 'worker' },
|
||||
{ relation: 'category' },
|
||||
{ relation: 'itemPackingType' },
|
||||
{ relation: 'temperature' },
|
||||
],
|
||||
};
|
||||
|
||||
const entityId = computed(() => $props.id || route.params.id);
|
||||
const summaryRef = ref();
|
||||
const itemType = ref();
|
||||
|
@ -43,8 +34,8 @@ async function setItemTypeData(data) {
|
|||
<CardSummary
|
||||
ref="summaryRef"
|
||||
:url="`ItemTypes/${entityId}`"
|
||||
data-key="ItemTypeSummary"
|
||||
:filter="itemTypeFilter"
|
||||
data-key="ItemType"
|
||||
:filter="filter"
|
||||
@on-fetch="(data) => setItemTypeData(data)"
|
||||
class="full-width"
|
||||
>
|
||||
|
|
|
@ -110,7 +110,7 @@ const getSelectedTagValues = async (tag) => {
|
|||
</div>
|
||||
<QBtn
|
||||
icon="add_circle"
|
||||
shortcut="+"
|
||||
v-shortcut="'+'"
|
||||
flat
|
||||
class="filter-icon q-mb-md"
|
||||
size="md"
|
||||
|
|
|
@ -14,7 +14,6 @@ import VnSubToolbar from 'src/components/ui/VnSubToolbar.vue';
|
|||
const { t } = useI18n();
|
||||
const route = useRoute();
|
||||
const state = useState();
|
||||
const ORDER_MODEL = 'order';
|
||||
|
||||
const isNew = Boolean(!route.params.id);
|
||||
const clientList = ref([]);
|
||||
|
@ -32,7 +31,7 @@ const fetchAddressList = async (addressId) => {
|
|||
});
|
||||
addressList.value = data;
|
||||
if (addressList.value?.length === 1) {
|
||||
state.get(ORDER_MODEL).addressFk = addressList.value[0].id;
|
||||
state.get('Order').addressFk = addressList.value[0].id;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -91,9 +90,8 @@ const onClientChange = async (clientId) => {
|
|||
<VnSubToolbar v-if="isNew" />
|
||||
<div class="q-pa-md">
|
||||
<FormModel
|
||||
:url="`Orders/${route.params.id}`"
|
||||
:url-update="`Orders/${route.params.id}/updateBasicData`"
|
||||
:model="ORDER_MODEL"
|
||||
model="Order"
|
||||
:filter="orderFilter"
|
||||
@on-fetch="fetchOrderDetails"
|
||||
auto-load
|
||||
|
|
|
@ -1,12 +1,14 @@
|
|||
<script setup>
|
||||
import VnCardBeta from 'components/common/VnCardBeta.vue';
|
||||
import OrderDescriptor from 'pages/Order/Card/OrderDescriptor.vue';
|
||||
import filter from './OrderFilter.js';
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<VnCardBeta
|
||||
data-key="Order"
|
||||
base-url="Orders"
|
||||
url="Orders"
|
||||
:filter="filter"
|
||||
:descriptor="OrderDescriptor"
|
||||
/>
|
||||
</template>
|
||||
|
|
|
@ -184,7 +184,7 @@ function addOrder(value, field, params) {
|
|||
{{
|
||||
t(
|
||||
categoryList.find((c) => c.id == customTag.value)?.name ||
|
||||
''
|
||||
'',
|
||||
)
|
||||
}}
|
||||
</strong>
|
||||
|
@ -296,7 +296,7 @@ function addOrder(value, field, params) {
|
|||
<template #append>
|
||||
<QBtn
|
||||
icon="add_circle"
|
||||
shortcut="+"
|
||||
v-shortcut="'+'"
|
||||
flat
|
||||
color="primary"
|
||||
size="md"
|
||||
|
|
|
@ -20,7 +20,7 @@ const props = defineProps({
|
|||
});
|
||||
const state = useState();
|
||||
|
||||
const orderData = computed(() => state.get('orderData'));
|
||||
const orderData = computed(() => state.get('Order'));
|
||||
|
||||
const prices = ref((props.item.prices || []).map((item) => ({ ...item, quantity: 0 })));
|
||||
const isLoading = ref(false);
|
||||
|
@ -44,7 +44,7 @@ const addToOrder = async () => {
|
|||
|
||||
state.set('orderTotal', orderTotal);
|
||||
const rows = orderData.value.rows.push(...items) || [];
|
||||
state.set('orderData', {
|
||||
state.set('Order', {
|
||||
...orderData.value,
|
||||
rows,
|
||||
});
|
||||
|
|
|
@ -4,8 +4,7 @@ import { useRoute } from 'vue-router';
|
|||
import { useI18n } from 'vue-i18n';
|
||||
import { toCurrency, toDate } from 'src/filters';
|
||||
import { useState } from 'src/composables/useState';
|
||||
import useCardDescription from 'src/composables/useCardDescription';
|
||||
|
||||
import filter from './OrderFilter.js';
|
||||
import CardDescriptor from 'components/ui/CardDescriptor.vue';
|
||||
import VnLv from 'src/components/ui/VnLv.vue';
|
||||
import FetchData from 'components/FetchData.vue';
|
||||
|
@ -24,44 +23,15 @@ const $props = defineProps({
|
|||
const route = useRoute();
|
||||
const state = useState();
|
||||
const { t } = useI18n();
|
||||
const data = ref(useCardDescription());
|
||||
const getTotalRef = ref();
|
||||
|
||||
const entityId = computed(() => {
|
||||
return $props.id || route.params.id;
|
||||
});
|
||||
|
||||
const filter = {
|
||||
include: [
|
||||
{ relation: 'agencyMode', scope: { fields: ['name'] } },
|
||||
{
|
||||
relation: 'address',
|
||||
scope: { fields: ['nickname'] },
|
||||
},
|
||||
{ relation: 'rows', scope: { fields: ['id'] } },
|
||||
{
|
||||
relation: 'client',
|
||||
scope: {
|
||||
fields: [
|
||||
'salesPersonFk',
|
||||
'name',
|
||||
'isActive',
|
||||
'isFreezed',
|
||||
'isTaxDataChecked',
|
||||
],
|
||||
include: {
|
||||
relation: 'salesPersonUser',
|
||||
scope: { fields: ['id', 'name'] },
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
const setData = (entity) => {
|
||||
if (!entity) return;
|
||||
getTotalRef.value && getTotalRef.value.fetch();
|
||||
data.value = useCardDescription(entity?.client?.name, entity?.id);
|
||||
state.set('orderTotal', total);
|
||||
};
|
||||
|
||||
|
@ -88,10 +58,9 @@ const total = ref(0);
|
|||
:url="`Orders/${entityId}`"
|
||||
:filter="filter"
|
||||
module="Order"
|
||||
:title="data.title"
|
||||
:subtitle="data.subtitle"
|
||||
title="client.name"
|
||||
@on-fetch="setData"
|
||||
data-key="orderData"
|
||||
data-key="Order"
|
||||
>
|
||||
<template #body="{ entity }">
|
||||
<VnLv
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
export default {
|
||||
include: [
|
||||
{ relation: 'agencyMode', scope: { fields: ['name'] } },
|
||||
{
|
||||
relation: 'address',
|
||||
scope: { fields: ['nickname'] },
|
||||
},
|
||||
{ relation: 'rows', scope: { fields: ['id'] } },
|
||||
{
|
||||
relation: 'client',
|
||||
scope: {
|
||||
fields: [
|
||||
'salesPersonFk',
|
||||
'name',
|
||||
'isActive',
|
||||
'isFreezed',
|
||||
'isTaxDataChecked',
|
||||
],
|
||||
include: {
|
||||
relation: 'salesPersonUser',
|
||||
scope: { fields: ['id', 'name'] },
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
|
@ -21,7 +21,7 @@ const router = useRouter();
|
|||
const route = useRoute();
|
||||
const { t } = useI18n();
|
||||
const quasar = useQuasar();
|
||||
const descriptorData = useArrayData('orderData');
|
||||
const descriptorData = useArrayData('Order');
|
||||
const componentKey = ref(0);
|
||||
const tableLinesRef = ref();
|
||||
const order = ref();
|
||||
|
|
|
@ -27,7 +27,7 @@ const $props = defineProps({
|
|||
const entityId = computed(() => $props.id || route.params.id);
|
||||
const summary = ref();
|
||||
const quasar = useQuasar();
|
||||
const descriptorData = useArrayData('orderData');
|
||||
const descriptorData = useArrayData('Order');
|
||||
const detailsColumns = ref([
|
||||
{
|
||||
name: 'item',
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue