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