forked from verdnatura/salix-front
WIP
This commit is contained in:
parent
6c4901076f
commit
b22d54f490
|
@ -1,7 +1,7 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import { computed, ref } from 'vue';
|
import { computed, ref } from 'vue';
|
||||||
import VnInput from 'components/common/VnInput.vue';
|
import VnInput from 'components/common/VnInput.vue';
|
||||||
import isValidDate from "filters/isValidDate";
|
import isValidDate from 'filters/isValidDate';
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
modelValue: {
|
modelValue: {
|
||||||
|
|
|
@ -9,6 +9,8 @@ import VnSelectFilter from 'src/components/common/VnSelectFilter.vue';
|
||||||
import VnInputDate from 'src/components/common/VnInputDate.vue';
|
import VnInputDate from 'src/components/common/VnInputDate.vue';
|
||||||
import EditTableCellValueForm from 'src/components/EditTableCellValueForm.vue';
|
import EditTableCellValueForm from 'src/components/EditTableCellValueForm.vue';
|
||||||
import ItemFixedPriceFilter from './ItemFixedPriceFilter.vue';
|
import ItemFixedPriceFilter from './ItemFixedPriceFilter.vue';
|
||||||
|
// TODO: mostrar item descriptor en fetchedtags
|
||||||
|
import ItemDescriptorProxy from './Card/ItemDescriptorProxy.vue';
|
||||||
|
|
||||||
import { useStateStore } from 'stores/useStateStore';
|
import { useStateStore } from 'stores/useStateStore';
|
||||||
import { dashIfEmpty } from 'src/filters';
|
import { dashIfEmpty } from 'src/filters';
|
||||||
|
@ -25,7 +27,7 @@ const { openConfirmationModal } = useVnConfirm();
|
||||||
const state = useState();
|
const state = useState();
|
||||||
const { notify } = useNotify();
|
const { notify } = useNotify();
|
||||||
|
|
||||||
const fixedPricesFetchRef = ref(null);
|
// const fixedPricesFetchRef = ref(null);
|
||||||
const editTableCellDialogRef = ref(null);
|
const editTableCellDialogRef = ref(null);
|
||||||
const user = state.getUser();
|
const user = state.getUser();
|
||||||
const fixedPrices = ref([]);
|
const fixedPrices = ref([]);
|
||||||
|
@ -59,9 +61,19 @@ const arrayData = useArrayData('ItemFixedPrices', {
|
||||||
});
|
});
|
||||||
const store = arrayData.store;
|
const store = arrayData.store;
|
||||||
|
|
||||||
|
const fetchFixedPrices = async () => {
|
||||||
|
await arrayData.fetch({ append: false });
|
||||||
|
};
|
||||||
|
|
||||||
|
const onFixedPricesFetched = (data) => {
|
||||||
|
fixedPrices.value = data;
|
||||||
|
// el objetivo de guardar una copia de las rows es evitar guardar cambios si la data no cambió al disparar los eventos
|
||||||
|
fixedPricesOriginalData.value = JSON.parse(JSON.stringify(data));
|
||||||
|
};
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
() => store.data,
|
() => store.data,
|
||||||
(value) => (fixedPrices.value = value)
|
(data) => onFixedPricesFetched(data)
|
||||||
);
|
);
|
||||||
|
|
||||||
const applyColumnFilter = async (col) => {
|
const applyColumnFilter = async (col) => {
|
||||||
|
@ -261,12 +273,6 @@ const editTableFieldsOptions = [
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
const onFixedPricesFetched = (data) => {
|
|
||||||
fixedPrices.value = data;
|
|
||||||
// el objetivo de esto es guardar los valores iniciales de todas las rows para evitar guardar cambios si la data no cambió al disparar los eventos
|
|
||||||
fixedPricesOriginalData.value = JSON.parse(JSON.stringify(data));
|
|
||||||
};
|
|
||||||
|
|
||||||
const getRowUpdateInputEvents = (props, resetMinPrice, inputType = 'text') => {
|
const getRowUpdateInputEvents = (props, resetMinPrice, inputType = 'text') => {
|
||||||
return inputType === 'text'
|
return inputType === 'text'
|
||||||
? {
|
? {
|
||||||
|
@ -309,7 +315,6 @@ const addRow = () => {
|
||||||
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);
|
||||||
|
@ -317,10 +322,12 @@ const addRow = () => {
|
||||||
fixedPricesOriginalData.value.push({
|
fixedPricesOriginalData.value.push({
|
||||||
started: today,
|
started: today,
|
||||||
ended: nextWeek,
|
ended: nextWeek,
|
||||||
|
hasMinPrice: 0,
|
||||||
});
|
});
|
||||||
fixedPrices.value.push({
|
fixedPrices.value.push({
|
||||||
started: today,
|
started: today,
|
||||||
ended: nextWeek,
|
ended: nextWeek,
|
||||||
|
hasMinPrice: 0,
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -339,7 +346,7 @@ const openEditTableCellDialog = () => {
|
||||||
|
|
||||||
const onEditCellDataSaved = async () => {
|
const onEditCellDataSaved = async () => {
|
||||||
rowsSelected.value = [];
|
rowsSelected.value = [];
|
||||||
await fixedPricesFetchRef.value.fetch();
|
await fetchFixedPrices();
|
||||||
};
|
};
|
||||||
|
|
||||||
const onWarehousesFetched = (data) => {
|
const onWarehousesFetched = (data) => {
|
||||||
|
@ -373,11 +380,34 @@ const updateMinPrice = async (value, props) => {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const isLower = (date) => {
|
||||||
|
// TODO: APLICAR ESTO A CHIPS A LAS FECHAS DE ENDED DATE
|
||||||
|
let today = Date.vnNew();
|
||||||
|
today.setHours(0, 0, 0, 0);
|
||||||
|
|
||||||
|
date = new Date(date);
|
||||||
|
date.setHours(0, 0, 0, 0);
|
||||||
|
|
||||||
|
const timeDifference = today - date;
|
||||||
|
if (timeDifference > 0) return 'warning';
|
||||||
|
};
|
||||||
|
|
||||||
|
const isBigger = (date) => {
|
||||||
|
// TODO: APLICAR ESTO A CHIPS A LAS FECHAS DE STARTED DATE
|
||||||
|
let today = Date.vnNew();
|
||||||
|
today.setHours(0, 0, 0, 0);
|
||||||
|
|
||||||
|
date = new Date(date);
|
||||||
|
date.setHours(0, 0, 0, 0);
|
||||||
|
|
||||||
|
const timeDifference = today - date;
|
||||||
|
if (timeDifference < 0) return 'warning';
|
||||||
|
};
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
stateStore.rightDrawer = true;
|
stateStore.rightDrawer = true;
|
||||||
params.warehouseFk = user.value.warehouseFk;
|
params.warehouseFk = user.value.warehouseFk;
|
||||||
const { data } = await arrayData.fetch({ append: false });
|
await fetchFixedPrices();
|
||||||
onFixedPricesFetched(data);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
onUnmounted(() => (stateStore.rightDrawer = false));
|
onUnmounted(() => (stateStore.rightDrawer = false));
|
||||||
|
@ -524,7 +554,7 @@ onUnmounted(() => (stateStore.rightDrawer = false));
|
||||||
<QTd class="col" style="min-width: 150px">
|
<QTd class="col" style="min-width: 150px">
|
||||||
<VnInputDate
|
<VnInputDate
|
||||||
v-model="props.row.started"
|
v-model="props.row.started"
|
||||||
v-on="getRowUpdateInputEvents(props)"
|
v-on="getRowUpdateInputEvents(props, false, 'date')"
|
||||||
/>
|
/>
|
||||||
</QTd>
|
</QTd>
|
||||||
</template>
|
</template>
|
||||||
|
@ -532,7 +562,7 @@ onUnmounted(() => (stateStore.rightDrawer = false));
|
||||||
<QTd class="col" style="min-width: 150px">
|
<QTd class="col" style="min-width: 150px">
|
||||||
<VnInputDate
|
<VnInputDate
|
||||||
v-model="props.row.ended"
|
v-model="props.row.ended"
|
||||||
v-on="getRowUpdateInputEvents(props)"
|
v-on="getRowUpdateInputEvents(props, false, 'date')"
|
||||||
/>
|
/>
|
||||||
</QTd>
|
</QTd>
|
||||||
</template>
|
</template>
|
||||||
|
@ -544,7 +574,7 @@ onUnmounted(() => (stateStore.rightDrawer = false));
|
||||||
option-label="name"
|
option-label="name"
|
||||||
option-value="id"
|
option-value="id"
|
||||||
v-model="props.row.warehouseFk"
|
v-model="props.row.warehouseFk"
|
||||||
v-on="getRowUpdateInputEvents(props)"
|
v-on="getRowUpdateInputEvents(props, false, 'select')"
|
||||||
/>
|
/>
|
||||||
</QTd>
|
</QTd>
|
||||||
</template>
|
</template>
|
||||||
|
|
Loading…
Reference in New Issue