|
@ -2,25 +2,15 @@
|
||||||
import { onMounted, ref, reactive, computed, onUnmounted, watch } from 'vue';
|
import { onMounted, ref, reactive, computed, onUnmounted, watch } from 'vue';
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
import { toDate } from 'src/filters';
|
import { toDate } from 'src/filters';
|
||||||
import FetchData from 'components/FetchData.vue';
|
|
||||||
import FetchedTags from 'components/ui/FetchedTags.vue';
|
import FetchedTags from 'components/ui/FetchedTags.vue';
|
||||||
import VnInput from 'src/components/common/VnInput.vue';
|
import VnInput from 'src/components/common/VnInput.vue';
|
||||||
import VnSelect from 'src/components/common/VnSelect.vue';
|
|
||||||
import VnInputDate from 'src/components/common/VnInputDate.vue';
|
|
||||||
import EditTableCellValueForm from 'src/components/EditTableCellValueForm.vue';
|
|
||||||
import ItemFixedPriceFilter from './ItemFixedPriceFilter.vue';
|
|
||||||
import ItemDescriptorProxy from './Card/ItemDescriptorProxy.vue';
|
|
||||||
import VnTable from 'components/VnTable/VnTable.vue';
|
import VnTable from 'components/VnTable/VnTable.vue';
|
||||||
import { useStateStore } from 'stores/useStateStore';
|
import { useStateStore } from 'stores/useStateStore';
|
||||||
import { dashIfEmpty } from 'src/filters';
|
|
||||||
import { useVnConfirm } from 'composables/useVnConfirm';
|
import { useVnConfirm } from 'composables/useVnConfirm';
|
||||||
import { useState } from 'src/composables/useState';
|
import { useState } from 'src/composables/useState';
|
||||||
import { toCurrency } from 'filters/index';
|
|
||||||
import useNotify from 'src/composables/useNotify.js';
|
import useNotify from 'src/composables/useNotify.js';
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import { useArrayData } from 'composables/useArrayData';
|
import { useArrayData } from 'composables/useArrayData';
|
||||||
import { isLower, isBigger } from 'src/filters/date.js';
|
|
||||||
import RightMenu from 'src/components/common/RightMenu.vue';
|
|
||||||
|
|
||||||
const stateStore = useStateStore();
|
const stateStore = useStateStore();
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
|
@ -75,39 +65,6 @@ watch(
|
||||||
(data) => onFixedPricesFetched(data)
|
(data) => onFixedPricesFetched(data)
|
||||||
);
|
);
|
||||||
|
|
||||||
const applyColumnFilter = async (col) => {
|
|
||||||
try {
|
|
||||||
const paramKey = col.columnFilter?.filterParamKey || col.field;
|
|
||||||
params[paramKey] = col.columnFilter.filterValue;
|
|
||||||
await arrayData.addFilter({ params });
|
|
||||||
} catch (err) {
|
|
||||||
console.error('Error applying column filter', err);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const getColumnInputEvents = (col) => {
|
|
||||||
return col.columnFilter.type === 'select'
|
|
||||||
? { 'update:modelValue': () => applyColumnFilter(col) }
|
|
||||||
: {
|
|
||||||
'keyup.enter': () => applyColumnFilter(col),
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
const defaultColumnFilter = {
|
|
||||||
component: VnInput,
|
|
||||||
type: 'text',
|
|
||||||
filterValue: null,
|
|
||||||
event: getColumnInputEvents,
|
|
||||||
attrs: {
|
|
||||||
dense: true,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
const defaultColumnAttrs = {
|
|
||||||
align: 'left',
|
|
||||||
sortable: true,
|
|
||||||
};
|
|
||||||
|
|
||||||
const columns = computed(() => [
|
const columns = computed(() => [
|
||||||
{
|
{
|
||||||
label: t('item.fixedPrice.itemId'),
|
label: t('item.fixedPrice.itemId'),
|
||||||
|
@ -127,12 +84,14 @@ const columns = computed(() => [
|
||||||
{
|
{
|
||||||
label: t('item.fixedPrice.groupingPrice'),
|
label: t('item.fixedPrice.groupingPrice'),
|
||||||
name: 'rate2',
|
name: 'rate2',
|
||||||
|
component: 'input',
|
||||||
align: 'left',
|
align: 'left',
|
||||||
create: true,
|
create: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: t('item.fixedPrice.packingPrice'),
|
label: t('item.fixedPrice.packingPrice'),
|
||||||
name: 'rate3',
|
name: 'rate3',
|
||||||
|
component: 'input',
|
||||||
align: 'left',
|
align: 'left',
|
||||||
create: true,
|
create: true,
|
||||||
},
|
},
|
||||||
|
@ -140,6 +99,7 @@ const columns = computed(() => [
|
||||||
{
|
{
|
||||||
label: t('item.fixedPrice.minPrice'),
|
label: t('item.fixedPrice.minPrice'),
|
||||||
name: 'minPrice',
|
name: 'minPrice',
|
||||||
|
component: 'input',
|
||||||
align: 'left',
|
align: 'left',
|
||||||
create: true,
|
create: true,
|
||||||
},
|
},
|
||||||
|
@ -188,70 +148,14 @@ const columns = computed(() => [
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
|
|
||||||
const editTableFieldsOptions = [
|
// const getRowUpdateInputEvents = (props, resetMinPrice, inputType = 'text') => {
|
||||||
{
|
// return inputType === 'text'
|
||||||
field: 'rate2',
|
// ? {
|
||||||
label: t('item.fixedPrice.groupingPrice'),
|
// 'keyup.enter': () => upsertPrice(props, resetMinPrice),
|
||||||
component: 'input',
|
// blur: () => upsertPrice(props, resetMinPrice),
|
||||||
attrs: {
|
// }
|
||||||
type: 'number',
|
// : { 'update:modelValue': () => upsertPrice(props, resetMinPrice) };
|
||||||
},
|
// };
|
||||||
},
|
|
||||||
{
|
|
||||||
field: 'rate3',
|
|
||||||
label: t('item.fixedPrice.packingPrice'),
|
|
||||||
component: 'input',
|
|
||||||
attrs: {
|
|
||||||
type: 'number',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
field: 'minPrice',
|
|
||||||
label: t('item.fixedPrice.minPrice'),
|
|
||||||
component: 'input',
|
|
||||||
attrs: {
|
|
||||||
type: 'number',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
field: 'hasMinPrice',
|
|
||||||
label: t('item.fixedPrice.hasMinPrice'),
|
|
||||||
component: 'checkbox',
|
|
||||||
attrs: {
|
|
||||||
'false-value': 0,
|
|
||||||
'true-value': 1,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
field: 'started',
|
|
||||||
label: t('item.fixedPrice.started'),
|
|
||||||
component: 'date',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
field: 'ended',
|
|
||||||
label: t('item.fixedPrice.ended'),
|
|
||||||
component: 'date',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
field: 'warehouseFk',
|
|
||||||
label: t('item.fixedPrice.warehouse'),
|
|
||||||
component: 'select',
|
|
||||||
attrs: {
|
|
||||||
options: [],
|
|
||||||
'option-label': 'name',
|
|
||||||
'option-value': 'id',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
const getRowUpdateInputEvents = (props, resetMinPrice, inputType = 'text') => {
|
|
||||||
return inputType === 'text'
|
|
||||||
? {
|
|
||||||
'keyup.enter': () => upsertPrice(props, resetMinPrice),
|
|
||||||
blur: () => upsertPrice(props, resetMinPrice),
|
|
||||||
}
|
|
||||||
: { 'update:modelValue': () => upsertPrice(props, resetMinPrice) };
|
|
||||||
};
|
|
||||||
|
|
||||||
const validations = (row, rowIndex, col) => {
|
const validations = (row, rowIndex, col) => {
|
||||||
const isNew = !row.id;
|
const isNew = !row.id;
|
||||||
|
@ -281,81 +185,73 @@ const upsertPrice = async ({ row, col, rowIndex }, resetMinPrice = false) => {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const addRow = () => {
|
// const addRow = () => {
|
||||||
if (!fixedPrices.value || fixedPrices.value.length === 0) {
|
// if (!fixedPrices.value || fixedPrices.value.length === 0) {
|
||||||
fixedPrices.value = [];
|
// fixedPrices.value = [];
|
||||||
|
|
||||||
const today = Date.vnNew();
|
// const today = Date.vnNew();
|
||||||
const millisecsInDay = 86400000;
|
// const millisecsInDay = 86400000;
|
||||||
const daysInWeek = 7;
|
// const daysInWeek = 7;
|
||||||
const nextWeek = new Date(today.getTime() + daysInWeek * millisecsInDay);
|
// const nextWeek = new Date(today.getTime() + daysInWeek * millisecsInDay);
|
||||||
|
|
||||||
const newPrice = {
|
// const newPrice = {
|
||||||
started: today,
|
// started: today,
|
||||||
ended: nextWeek,
|
// ended: nextWeek,
|
||||||
hasMinPrice: 0,
|
// hasMinPrice: 0,
|
||||||
};
|
// };
|
||||||
|
|
||||||
fixedPricesOriginalData.value.push({ ...newPrice });
|
// fixedPricesOriginalData.value.push({ ...newPrice });
|
||||||
fixedPrices.value.push({ ...newPrice });
|
// fixedPrices.value.push({ ...newPrice });
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
|
|
||||||
const lastItemCopy = JSON.parse(
|
// const lastItemCopy = JSON.parse(
|
||||||
JSON.stringify(fixedPrices.value[fixedPrices.value.length - 1])
|
// JSON.stringify(fixedPrices.value[fixedPrices.value.length - 1])
|
||||||
);
|
// );
|
||||||
delete lastItemCopy.id;
|
// delete lastItemCopy.id;
|
||||||
fixedPricesOriginalData.value.push(lastItemCopy);
|
// fixedPricesOriginalData.value.push(lastItemCopy);
|
||||||
fixedPrices.value.push(lastItemCopy);
|
// fixedPrices.value.push(lastItemCopy);
|
||||||
};
|
// };
|
||||||
|
|
||||||
const openEditTableCellDialog = () => {
|
// const openEditTableCellDialog = () => {
|
||||||
editTableCellDialogRef.value.show();
|
// editTableCellDialogRef.value.show();
|
||||||
};
|
// };
|
||||||
|
|
||||||
const onEditCellDataSaved = async () => {
|
// const onEditCellDataSaved = async () => {
|
||||||
rowsSelected.value = [];
|
// rowsSelected.value = [];
|
||||||
await fetchFixedPrices();
|
// await fetchFixedPrices();
|
||||||
};
|
// };
|
||||||
|
|
||||||
const onWarehousesFetched = (data) => {
|
// const onWarehousesFetched = (data) => {
|
||||||
warehousesOptions.value = data;
|
// warehousesOptions.value = data;
|
||||||
// Actualiza las 'options' del elemento con field 'warehouseFk' en 'editTableFieldsOptions'.
|
// // Actualiza las 'options' del elemento con field 'warehouseFk' en 'editTableFieldsOptions'.
|
||||||
const warehouseField = editTableFieldsOptions.find(
|
// const warehouseField = editTableFieldsOptions.find(
|
||||||
(field) => field.field === 'warehouseFk'
|
// (field) => field.field === 'warehouseFk'
|
||||||
);
|
// );
|
||||||
warehouseField.attrs.options = data;
|
// warehouseField.attrs.options = data;
|
||||||
};
|
// };
|
||||||
|
|
||||||
const removePrice = async (id, rowIndex) => {
|
// const removePrice = async (id, rowIndex) => {
|
||||||
try {
|
// try {
|
||||||
await axios.delete(`FixedPrices/${id}`);
|
// await axios.delete(`FixedPrices/${id}`);
|
||||||
fixedPrices.value.splice(rowIndex, 1);
|
// fixedPrices.value.splice(rowIndex, 1);
|
||||||
fixedPricesOriginalData.value.splice(rowIndex, 1);
|
// fixedPricesOriginalData.value.splice(rowIndex, 1);
|
||||||
notify(t('globals.dataSaved'), 'positive');
|
// notify(t('globals.dataSaved'), 'positive');
|
||||||
} catch (err) {
|
// } catch (err) {
|
||||||
console.error('Error removing price', err);
|
// console.error('Error removing price', err);
|
||||||
}
|
// }
|
||||||
};
|
// };
|
||||||
|
|
||||||
const updateMinPrice = async (value, props) => {
|
// const updateMinPrice = async (value, props) => {
|
||||||
// El checkbox hasMinPrice se encuentra en la misma columna que el input hasMinPrice
|
// // El checkbox hasMinPrice se encuentra en la misma columna que el input hasMinPrice
|
||||||
// Por lo tanto le mandamos otro objeto con las mismas propiedades pero con el campo 'field' cambiado
|
// // Por lo tanto le mandamos otro objeto con las mismas propiedades pero con el campo 'field' cambiado
|
||||||
props.row.hasMinPrice = value;
|
// props.row.hasMinPrice = value;
|
||||||
await upsertPrice({
|
// await upsertPrice({
|
||||||
row: props.row,
|
// row: props.row,
|
||||||
col: { field: 'hasMinPrice' },
|
// col: { field: 'hasMinPrice' },
|
||||||
rowIndex: props.rowIndex,
|
// rowIndex: props.rowIndex,
|
||||||
});
|
// });
|
||||||
};
|
// };
|
||||||
|
|
||||||
onMounted(async () => {
|
|
||||||
stateStore.rightDrawer = true;
|
|
||||||
params.warehouseFk = user.value.warehouseFk;
|
|
||||||
await fetchFixedPrices();
|
|
||||||
});
|
|
||||||
|
|
||||||
onUnmounted(() => (stateStore.rightDrawer = false));
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
@ -372,13 +268,13 @@ onUnmounted(() => (stateStore.rightDrawer = false));
|
||||||
order="id ASC"
|
order="id ASC"
|
||||||
:columns="columns"
|
:columns="columns"
|
||||||
auto-load
|
auto-load
|
||||||
:is-editable="false"
|
:is-editable="true"
|
||||||
:use-model="true"
|
:use-model="true"
|
||||||
>
|
>
|
||||||
<template #column-description="{ row }">
|
<template #column-description="{ row }">
|
||||||
<div class="row column full-width justify-between items-start">
|
<div class="row column full-width justify-between items-start">
|
||||||
{{ row?.description }}
|
{{ row?.name }}
|
||||||
<div v-if="row?.description" class="subName">
|
<div v-if="row?.subName" class="subName">
|
||||||
{{ row?.subName.toUpperCase() }}
|
{{ row?.subName.toUpperCase() }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -386,7 +282,12 @@ onUnmounted(() => (stateStore.rightDrawer = false));
|
||||||
</template>
|
</template>
|
||||||
</VnTable>
|
</VnTable>
|
||||||
</template>
|
</template>
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
.subName {
|
||||||
|
text-transform: uppercase;
|
||||||
|
color: var(--vn-label-color);
|
||||||
|
}
|
||||||
|
</style>
|
||||||
<i18n>
|
<i18n>
|
||||||
es:
|
es:
|
||||||
Add fixed price: Añadir precio fijado
|
Add fixed price: Añadir precio fijado
|
||||||
|
|
|
@ -100,6 +100,7 @@ const columns = computed(() => [
|
||||||
{
|
{
|
||||||
label: t('item.buyRequest.state'),
|
label: t('item.buyRequest.state'),
|
||||||
name: 'state',
|
name: 'state',
|
||||||
|
action: (row) => getState(row.isOk),
|
||||||
align: 'left',
|
align: 'left',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -146,7 +147,6 @@ const confirmRequest = async (request) => {
|
||||||
`TicketRequests/${request.id}/confirm`,
|
`TicketRequests/${request.id}/confirm`,
|
||||||
params
|
params
|
||||||
);
|
);
|
||||||
|
|
||||||
request.itemDescription = data.concept;
|
request.itemDescription = data.concept;
|
||||||
request.isOk = true;
|
request.isOk = true;
|
||||||
notify(t('globals.dataSaved'), 'positive');
|
notify(t('globals.dataSaved'), 'positive');
|
||||||
|
@ -338,15 +338,22 @@ onBeforeMount(() => {
|
||||||
url="ticketRequests/filter"
|
url="ticketRequests/filter"
|
||||||
order="id DESC"
|
order="id DESC"
|
||||||
:columns="columns"
|
:columns="columns"
|
||||||
:is-editable="false"
|
:is-editable="true"
|
||||||
auto-load
|
auto-load
|
||||||
>
|
>
|
||||||
<template #column-attender="{ row }">
|
<template #column-attenderName="{ row }">
|
||||||
<span class="link" @click.stop>
|
<span class="link" @click.stop>
|
||||||
{{ row }}
|
{{ row.attenderName }}
|
||||||
<WorkerDescriptorProxy :id="row.attenderFk" />
|
<WorkerDescriptorProxy :id="row.attenderFk" />
|
||||||
</span>
|
</span>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
<template #column-requesterName="{ row }">
|
||||||
|
<span class="link" @click.stop>
|
||||||
|
{{ row.requesterName }}
|
||||||
|
<WorkerDescriptorProxy :id="row.requesterFk" />
|
||||||
|
</span>
|
||||||
|
</template>
|
||||||
</VnTable>
|
</VnTable>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue