7983-testToMaster_2438 #718

Merged
alexm merged 353 commits from 7983-testToMaster_2438 into master 2024-09-17 05:39:39 +00:00
1 changed files with 37 additions and 31 deletions
Showing only changes of commit 7892e68e1b - Show all commits

View File

@ -233,8 +233,9 @@ function checkLastVisibleRow() {
return lastVisibleRow; return lastVisibleRow;
} }
} }
const addRow = (fixedPrice = null) => { const addRow = (original = null) => {
const lastvisible = checkLastVisibleRow(); // const original = checkLastVisibleRow();
let copy = null;
// if (!fixedPrices.value || fixedPrices.value.length === 0) { // if (!fixedPrices.value || fixedPrices.value.length === 0) {
// fixedPrices.value = []; // fixedPrices.value = [];
@ -253,52 +254,53 @@ const addRow = (fixedPrice = null) => {
// fixedPrices.value.push({ ...newPrice }); // fixedPrices.value.push({ ...newPrice });
// return; // return;
// } // }
if (!fixedPrice) { if (!original) {
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);
// lastItem.value = { // lastItem.value = {
lastItem.value = { copy = {
started: today, started: today,
ended: nextWeek, ended: nextWeek,
hasMinPrice: 0, hasMinPrice: 0,
}; };
return; // return;
} }
const lastItemCopy = { copy = {
itemFk: fixedPrice.itemFk, $index: original.$index - 1,
name: fixedPrice.name, itemFk: original.itemFk,
subName: fixedPrice.subName, name: original.name,
value5: fixedPrice.value5, subName: original.subName,
value6: fixedPrice.value6, value5: original.value5,
value7: fixedPrice.value7, value6: original.value6,
value8: fixedPrice.value8, value7: original.value7,
value9: fixedPrice.value9, value8: original.value8,
value10: fixedPrice.value10, value9: original.value9,
warehouseFk: fixedPrice.warehouseFk, value10: original.value10,
rate2: fixedPrice.rate2, warehouseFk: original.warehouseFk,
rate3: fixedPrice.rate3, rate2: original.rate2,
hasMinPrice: fixedPrice.hasMinPrice, rate3: original.rate3,
minPrice: fixedPrice.minPrice, hasMinPrice: original.hasMinPrice,
started: fixedPrice.started, minPrice: original.minPrice,
ended: fixedPrice.ended, started: Date.vnNew(),
ended: Date.vnNew(),
}; };
// lastItem.value = lastItemCopy; // lastItem.value = lastItemCopy;
// tableRef.value.create.onDataSaved(lastItem); // tableRef.value.create.onDataSaved(lastItem);
return lastItemCopy; // nextTick(() => {
// highlightNewRow(fixedPrice);
// });
// delete lastItemCopy.id; // delete lastItemCopy.id;
// fixedPricesOriginalData.value.splice(lastvisible, 0, lastItemCopy); // fixedPricesOriginalData.value.splice(lastvisible, 0, lastItemCopy);
// fixedPrices.value.unshift(lastItemCopy); // fixedPrices.value.unshift(lastItemCopy);
// nextTick(() => { return { original, copy };
// highlightNewRow(lastvisible);
// });
}; };
const lastItem = ref(null); const lastItem = ref(null);
function highlightNewRow(index) { function highlightNewRow({ $index: index }) {
const row = document const row = document
.getElementsByClassName('q-table')[0] .getElementsByClassName('q-table')[0]
.querySelectorAll('tr.cursor-pointer')[index]; .querySelectorAll('tr.cursor-pointer')[index];
@ -365,10 +367,11 @@ onMounted(async () => {
params.warehouseFk = user.value.warehouseFk; params.warehouseFk = user.value.warehouseFk;
}); });
function handleOnDataSave({ CrudModelRef }) { function handleOnDataSave({ CrudModelRef }) {
const roww = addRow(CrudModelRef.formData[CrudModelRef.formData.length - 1]); const { original, copy } = addRow(CrudModelRef.formData[checkLastVisibleRow()]);
CrudModelRef.formData.unshift(lastItem); // CrudModelRef.formData.unshift(roww);
CrudModelRef.formData.splice(original.$index, 0, copy);
nextTick(() => { nextTick(() => {
highlightNewRow(checkLastVisibleRow()); highlightNewRow(original);
}); });
} }
onUnmounted(() => (stateStore.rightDrawer = false)); onUnmounted(() => (stateStore.rightDrawer = false));
@ -415,10 +418,13 @@ onUnmounted(() => (stateStore.rightDrawer = false));
<QPage> <QPage>
<VnTable <VnTable
:default-remove="false" :default-remove="false"
:default-reset="false"
:default-save="false"
data-key="ItemFixedPrices" data-key="ItemFixedPrices"
url="FixedPrices/filter" url="FixedPrices/filter"
:filter="{ where: exprBuilder }"
:order="['name ASC', 'itemFk DESC']" :order="['name ASC', 'itemFk DESC']"
save-url="FixedPrices/crud"
:filter="{ where: { warehouseFk: user.warehouseFk } }"
ref="tableRef" ref="tableRef"
dense dense
:columns="columns" :columns="columns"