|
@@ -22,6 +22,7 @@ let page = 1
|
|
let rightPage = 1
|
|
let rightPage = 1
|
|
let limit = 15
|
|
let limit = 15
|
|
let hasMoreParentAsin = true
|
|
let hasMoreParentAsin = true
|
|
|
|
+let isFirstTime = true
|
|
|
|
|
|
emitter.on('PopoverFilter-noMoreParenAsin', () => {
|
|
emitter.on('PopoverFilter-noMoreParenAsin', () => {
|
|
hasMoreParentAsin = false
|
|
hasMoreParentAsin = false
|
|
@@ -32,12 +33,17 @@ emitter.on('PopoverFilter-productLineSelect', (data: any) => {
|
|
gridOptions.data.splice(0)
|
|
gridOptions.data.splice(0)
|
|
})
|
|
})
|
|
|
|
|
|
-let isFirstTime = true
|
|
|
|
emitter.on('PopoverFilter-searchResult', (data: any) => {
|
|
emitter.on('PopoverFilter-searchResult', (data: any) => {
|
|
gridOptions.data = data.value
|
|
gridOptions.data = data.value
|
|
isFirstTime = false
|
|
isFirstTime = false
|
|
})
|
|
})
|
|
|
|
|
|
|
|
+emitter.on('PopoverFilter-productLineSelect', () => {
|
|
|
|
+ vxeRef.value.clearAll()
|
|
|
|
+ // vxeRef.value.setAllCheckboxRow(false)
|
|
|
|
+ isScrollSelectAll.value = false
|
|
|
|
+})
|
|
|
|
+
|
|
emitter.on('TopFilter', (value: any) => {
|
|
emitter.on('TopFilter', (value: any) => {
|
|
if (value.isVisible?.value) {
|
|
if (value.isVisible?.value) {
|
|
fetchParentAsin()
|
|
fetchParentAsin()
|
|
@@ -102,7 +108,9 @@ async function selectChangeEvent(table: any) {
|
|
|
|
|
|
// 左侧全选事件
|
|
// 左侧全选事件
|
|
async function selectAllChangeEvent(table: any) {
|
|
async function selectAllChangeEvent(table: any) {
|
|
|
|
+ // await vxeRef.value.clearAll()
|
|
// console.log('多选:', table)
|
|
// console.log('多选:', table)
|
|
|
|
+
|
|
if (table.checked) {
|
|
if (table.checked) {
|
|
table.records.forEach((record: any) => {
|
|
table.records.forEach((record: any) => {
|
|
selectedParentAsins.value.push(record.parentAsin)
|
|
selectedParentAsins.value.push(record.parentAsin)
|
|
@@ -133,10 +141,9 @@ function handleCellClick(table: any) {
|
|
})
|
|
})
|
|
}
|
|
}
|
|
|
|
|
|
-// 这个函数用来勾选右侧表格的行
|
|
|
|
|
|
+// 勾选右侧表格的行
|
|
function checkRightTableRows() {
|
|
function checkRightTableRows() {
|
|
const rightData = vxeRefRight.value.getTableData().tableData
|
|
const rightData = vxeRefRight.value.getTableData().tableData
|
|
-
|
|
|
|
rightData.forEach((row: any) => {
|
|
rightData.forEach((row: any) => {
|
|
const concatValue = searchType === 'sku' ? row.parentAsin + row.sku : row.parentAsin + row.asin
|
|
const concatValue = searchType === 'sku' ? row.parentAsin + row.sku : row.parentAsin + row.asin
|
|
if (parentAsinsSet.value.has(concatValue)) {
|
|
if (parentAsinsSet.value.has(concatValue)) {
|
|
@@ -149,33 +156,36 @@ function checkRightTableRows() {
|
|
async function selectChangeRight(table: any) {
|
|
async function selectChangeRight(table: any) {
|
|
if (table.checked) {
|
|
if (table.checked) {
|
|
getRightSelectedItem()
|
|
getRightSelectedItem()
|
|
- // 新增代码: 查找并选中左侧表格对应的条目
|
|
|
|
- const parentAsin = table.row.parentAsin
|
|
|
|
- const leftTableData = vxeRef.value.getTableData().tableData
|
|
|
|
- const leftRow = leftTableData.find((row: any) => row.parentAsin === parentAsin)
|
|
|
|
|
|
+ // 查找并选中左侧表格对应的条目
|
|
|
|
+ const leftRow = findParentAsin(table.row.parentAsin)
|
|
if (leftRow) {
|
|
if (leftRow) {
|
|
await vxeRef.value.setCheckboxRow(leftRow, true)
|
|
await vxeRef.value.setCheckboxRow(leftRow, true)
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
emitter.emit('PopoverFilterTable-needDeleteBySearchType', searchType === 'sku' ? table.row.sku : table.row.asin)
|
|
emitter.emit('PopoverFilterTable-needDeleteBySearchType', searchType === 'sku' ? table.row.sku : table.row.asin)
|
|
- // 新增代码: 查找并取消选中左侧表格对应的条目
|
|
|
|
- const parentAsin = table.row.parentAsin
|
|
|
|
- const leftTableData = vxeRef.value.getTableData().tableData
|
|
|
|
- const leftRow = leftTableData.find((row: any) => row.parentAsin === parentAsin)
|
|
|
|
|
|
+ // 查找并取消选中左侧表格对应的条目
|
|
|
|
+ const leftRow = findParentAsin(table.row.parentAsin)
|
|
if (leftRow && table.records.length === 0) {
|
|
if (leftRow && table.records.length === 0) {
|
|
await vxeRef.value.setCheckboxRow(leftRow, false)
|
|
await vxeRef.value.setCheckboxRow(leftRow, false)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+// 查找左侧表格对应的条目
|
|
|
|
+function findParentAsin(tableParentAsin: string) {
|
|
|
|
+ const parentAsin = tableParentAsin
|
|
|
|
+ const leftTableData = vxeRef.value.getTableData().tableData
|
|
|
|
+ return leftTableData.find((row: any) => row.parentAsin === parentAsin)
|
|
|
|
+}
|
|
|
|
+
|
|
// 右侧表格全选事件
|
|
// 右侧表格全选事件
|
|
async function selectAllChangeRight(table: any) {
|
|
async function selectAllChangeRight(table: any) {
|
|
if (table.checked) {
|
|
if (table.checked) {
|
|
getRightSelectedItem()
|
|
getRightSelectedItem()
|
|
const rightTableData = vxeRefRight.value.getTableData().tableData
|
|
const rightTableData = vxeRefRight.value.getTableData().tableData
|
|
|
|
+ // 勾选左侧表格中对应的条目
|
|
for (const data of rightTableData) {
|
|
for (const data of rightTableData) {
|
|
- const leftTableData = vxeRef.value.getTableData().tableData
|
|
|
|
- const leftRow = leftTableData.find((row: any) => row.parentAsin === data.parentAsin)
|
|
|
|
|
|
+ const leftRow = findLeftCorrespondItem(data)
|
|
if (leftRow) {
|
|
if (leftRow) {
|
|
await vxeRef.value.setCheckboxRow(leftRow, true)
|
|
await vxeRef.value.setCheckboxRow(leftRow, true)
|
|
}
|
|
}
|
|
@@ -185,8 +195,7 @@ async function selectAllChangeRight(table: any) {
|
|
emitter.emit('PopoverFilterTable-needDelete', vxeRefRight.value.getTableData().tableData[0].parentAsin)
|
|
emitter.emit('PopoverFilterTable-needDelete', vxeRefRight.value.getTableData().tableData[0].parentAsin)
|
|
const rightTableData = vxeRefRight.value.getTableData().tableData
|
|
const rightTableData = vxeRefRight.value.getTableData().tableData
|
|
for (const data of rightTableData) {
|
|
for (const data of rightTableData) {
|
|
- const leftTableData = vxeRef.value.getTableData().tableData
|
|
|
|
- const leftRow = leftTableData.find((row: any) => row.parentAsin === data.parentAsin)
|
|
|
|
|
|
+ const leftRow = findLeftCorrespondItem(data)
|
|
if (leftRow) {
|
|
if (leftRow) {
|
|
await vxeRef.value.setCheckboxRow(leftRow, false)
|
|
await vxeRef.value.setCheckboxRow(leftRow, false)
|
|
}
|
|
}
|
|
@@ -194,6 +203,11 @@ async function selectAllChangeRight(table: any) {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+function findLeftCorrespondItem(data: any) {
|
|
|
|
+ const leftTableData = vxeRef.value.getTableData().tableData
|
|
|
|
+ return leftTableData.find((row: any) => row.parentAsin === data.parentAsin)
|
|
|
|
+}
|
|
|
|
+
|
|
// 获取右侧表格选中的数据
|
|
// 获取右侧表格选中的数据
|
|
function getRightSelectedItem() {
|
|
function getRightSelectedItem() {
|
|
const selectedData = vxeRefRight.value.getCheckboxRecords()
|
|
const selectedData = vxeRefRight.value.getCheckboxRecords()
|
|
@@ -260,7 +274,7 @@ async function handleScroll(event: any) {
|
|
await vxeRef.value.setAllCheckboxRow(true)
|
|
await vxeRef.value.setAllCheckboxRow(true)
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
- console.log('Reached the bottom, but no more data to load.')
|
|
|
|
|
|
+ // console.log('Reached the bottom, but no more data to load.')
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|