forked from verdnatura/salix-front
perf: order components
This commit is contained in:
parent
0c1cd47d38
commit
754f047943
|
@ -24,24 +24,31 @@ import RightMenu from 'src/components/common/RightMenu.vue';
|
||||||
import VnTable from 'src/components/VnTable/VnTable.vue';
|
import VnTable from 'src/components/VnTable/VnTable.vue';
|
||||||
import { QCheckbox } from 'quasar';
|
import { QCheckbox } from 'quasar';
|
||||||
|
|
||||||
|
const quasar = useQuasar();
|
||||||
const stateStore = useStateStore();
|
const stateStore = useStateStore();
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
const { openConfirmationModal } = useVnConfirm();
|
const { openConfirmationModal } = useVnConfirm();
|
||||||
const state = useState();
|
const state = useState();
|
||||||
const { notify } = useNotify();
|
const { notify } = useNotify();
|
||||||
|
const tableRef = ref();
|
||||||
const editTableCellDialogRef = ref(null);
|
const editTableCellDialogRef = ref(null);
|
||||||
const user = state.getUser();
|
const user = state.getUser();
|
||||||
const fixedPrices = ref([]);
|
const fixedPrices = ref([]);
|
||||||
const warehousesOptions = ref([]);
|
const warehousesOptions = ref([]);
|
||||||
const rowsSelected = ref([]);
|
const rowsSelected = ref([]);
|
||||||
|
|
||||||
|
const itemFixedPriceFilterRef = ref();
|
||||||
|
|
||||||
const params = reactive({});
|
const params = reactive({});
|
||||||
const defaultColumnAttrs = {
|
const defaultColumnAttrs = {
|
||||||
align: 'left',
|
align: 'left',
|
||||||
sortable: true,
|
sortable: true,
|
||||||
};
|
};
|
||||||
|
onMounted(async () => {
|
||||||
|
stateStore.rightDrawer = true;
|
||||||
|
params.warehouseFk = user.value.warehouseFk;
|
||||||
|
});
|
||||||
|
onUnmounted(() => (stateStore.rightDrawer = false));
|
||||||
const columns = computed(() => [
|
const columns = computed(() => [
|
||||||
{
|
{
|
||||||
label: t('item.fixedPrice.itemId'),
|
label: t('item.fixedPrice.itemId'),
|
||||||
|
@ -255,13 +262,12 @@ const updateMinPrice = async (value, props) => {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const upsertPrice = async ({ row, col, rowIndex }, resetMinPrice = false) => {
|
const upsertPrice = async ({ row }, resetMinPrice = false) => {
|
||||||
// if (!validations(row, rowIndex, col)) return;
|
// if (!validations(row, rowIndex, col)) return;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (resetMinPrice) row.hasMinPrice = 0;
|
if (resetMinPrice) row.hasMinPrice = 0;
|
||||||
row = await upsertFixedPrice(row);
|
row = await upsertFixedPrice(row);
|
||||||
// fixedPricesOriginalData.value[rowIndex][col.field] = row[col.field];
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('Error editing price', err);
|
console.error('Error editing price', err);
|
||||||
}
|
}
|
||||||
|
@ -281,14 +287,11 @@ async function saveOnRowChange(row) {
|
||||||
await upsertFixedPrice(rowsSelected.value[0]);
|
await upsertFixedPrice(rowsSelected.value[0]);
|
||||||
rowsSelected.value = [row];
|
rowsSelected.value = [row];
|
||||||
}
|
}
|
||||||
const tableRef = ref();
|
|
||||||
function checkLastVisibleRow() {
|
function checkLastVisibleRow() {
|
||||||
const rows = document
|
|
||||||
.getElementsByClassName('q-table')[0]
|
|
||||||
.querySelectorAll('tr.cursor-pointer');
|
|
||||||
let lastVisibleRow = null;
|
let lastVisibleRow = null;
|
||||||
|
|
||||||
rows.forEach((row, index) => {
|
getTableRows().forEach((row, index) => {
|
||||||
const rect = row.getBoundingClientRect();
|
const rect = row.getBoundingClientRect();
|
||||||
if (rect.top >= 0 && rect.bottom <= window.innerHeight) {
|
if (rect.top >= 0 && rect.bottom <= window.innerHeight) {
|
||||||
lastVisibleRow = index;
|
lastVisibleRow = index;
|
||||||
|
@ -337,10 +340,10 @@ const addRow = (original = null) => {
|
||||||
};
|
};
|
||||||
return { original, copy };
|
return { original, copy };
|
||||||
};
|
};
|
||||||
|
const getTableRows = () =>
|
||||||
|
document.getElementsByClassName('q-table')[0].querySelectorAll('tr.cursor-pointer');
|
||||||
function highlightNewRow({ $index: index }) {
|
function highlightNewRow({ $index: index }) {
|
||||||
const row = document
|
const row = getTableRows()[index];
|
||||||
.getElementsByClassName('q-table')[0]
|
|
||||||
.querySelectorAll('tr.cursor-pointer')[index];
|
|
||||||
if (row) {
|
if (row) {
|
||||||
row.classList.add('highlight');
|
row.classList.add('highlight');
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
|
@ -365,8 +368,6 @@ const removeFuturePrice = async () => {
|
||||||
console.error('Error removing price', err);
|
console.error('Error removing price', err);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
const quasar = useQuasar();
|
|
||||||
|
|
||||||
function confirmRemove(item, isFuture) {
|
function confirmRemove(item, isFuture) {
|
||||||
const promise = async () =>
|
const promise = async () =>
|
||||||
isFuture ? removeFuturePrice(item.id) : removePrice(item.id);
|
isFuture ? removeFuturePrice(item.id) : removePrice(item.id);
|
||||||
|
@ -389,10 +390,6 @@ const removePrice = async (id) => {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
onMounted(async () => {
|
|
||||||
stateStore.rightDrawer = true;
|
|
||||||
params.warehouseFk = user.value.warehouseFk;
|
|
||||||
});
|
|
||||||
function handleOnDataSave({ CrudModelRef }) {
|
function handleOnDataSave({ CrudModelRef }) {
|
||||||
const { original, copy } = addRow(CrudModelRef.formData[checkLastVisibleRow()]);
|
const { original, copy } = addRow(CrudModelRef.formData[checkLastVisibleRow()]);
|
||||||
if (original) {
|
if (original) {
|
||||||
|
@ -404,8 +401,6 @@ function handleOnDataSave({ CrudModelRef }) {
|
||||||
highlightNewRow(original ?? { $index: 0 });
|
highlightNewRow(original ?? { $index: 0 });
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
onUnmounted(() => (stateStore.rightDrawer = false));
|
|
||||||
const itemFixedPriceFilterRef = ref();
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
@ -629,7 +624,7 @@ const itemFixedPriceFilterRef = ref();
|
||||||
"
|
"
|
||||||
>
|
>
|
||||||
<QTooltip class="text-no-wrap">
|
<QTooltip class="text-no-wrap">
|
||||||
{{ t('Delete') }}
|
{{ t('globals.delete') }}
|
||||||
</QTooltip>
|
</QTooltip>
|
||||||
</QIcon>
|
</QIcon>
|
||||||
</QTd>
|
</QTd>
|
||||||
|
@ -644,8 +639,6 @@ const itemFixedPriceFilterRef = ref();
|
||||||
@on-data-saved="onEditCellDataSaved()"
|
@on-data-saved="onEditCellDataSaved()"
|
||||||
/>
|
/>
|
||||||
</QDialog>
|
</QDialog>
|
||||||
{{ rowsSelected }}
|
|
||||||
**{{ editTableFieldsOptions }}
|
|
||||||
</QPage>
|
</QPage>
|
||||||
</template>
|
</template>
|
||||||
<style lang="scss">
|
<style lang="scss">
|
||||||
|
@ -694,6 +687,4 @@ tbody tr.highlight .q-td {
|
||||||
es:
|
es:
|
||||||
Add fixed price: Añadir precio fijado
|
Add fixed price: Añadir precio fijado
|
||||||
Edit fixed price(s): Editar precio(s) fijado(s)
|
Edit fixed price(s): Editar precio(s) fijado(s)
|
||||||
Are you sure you want to continue?: ¿Seguro que quieres continuar?
|
|
||||||
Delete: Eliminar
|
|
||||||
</i18n>
|
</i18n>
|
||||||
|
|
Loading…
Reference in New Issue