mirror of
https://github.com/PanJiaChen/vue-element-admin.git
synced 2025-08-13 23:20:12 +08:00
fix: Unnecessary requests for the sort type tab. (#664)
Co-authored-by: EdwinBetanc0urt <EdwinBetanco0urt@outlook.com>
This commit is contained in:
parent
66d877e627
commit
7bf5bcc461
@ -797,6 +797,7 @@ export default {
|
|||||||
eventType
|
eventType
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get data to table in tab
|
* Get data to table in tab
|
||||||
* @param {string} parentUuid, window to search record data
|
* @param {string} parentUuid, window to search record data
|
||||||
@ -1005,7 +1006,7 @@ export default {
|
|||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update records in tab sort
|
* Update records in tab sort (sequence)
|
||||||
* @param {string} containerUuid
|
* @param {string} containerUuid
|
||||||
* @param {string} parentUuid
|
* @param {string} parentUuid
|
||||||
*/
|
*/
|
||||||
@ -1020,26 +1021,43 @@ export default {
|
|||||||
// scrolls through the logs and checks if there is a change to be sent to server
|
// scrolls through the logs and checks if there is a change to be sent to server
|
||||||
recordData.forEach(itemData => {
|
recordData.forEach(itemData => {
|
||||||
const dataSequence = listSequenceToSet.find(item => item.UUID === itemData.UUID)
|
const dataSequence = listSequenceToSet.find(item => item.UUID === itemData.UUID)
|
||||||
if (itemData[sortOrderColumnName] === dataSequence[sortOrderColumnName]) {
|
const currentSequence = itemData[sortOrderColumnName]
|
||||||
|
const newSequence = dataSequence[sortOrderColumnName]
|
||||||
|
|
||||||
|
// same sequence, or empty sequence and less than 0
|
||||||
|
if (currentSequence === newSequence ||
|
||||||
|
(isEmptyValue(currentSequence) && newSequence <= 0) ||
|
||||||
|
(isEmptyValue(newSequence) && currentSequence <= 0)) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
const valuesToSend = [{
|
const valuesToSend = [{
|
||||||
columnName: sortOrderColumnName,
|
columnName: sortOrderColumnName,
|
||||||
value: dataSequence[sortOrderColumnName]
|
value: newSequence
|
||||||
}]
|
}]
|
||||||
|
|
||||||
if (itemData[sortYesNoColumnName] !== dataSequence[sortYesNoColumnName]) {
|
const currentYesNo = itemData[sortYesNoColumnName]
|
||||||
|
const newYesNo = dataSequence[sortYesNoColumnName]
|
||||||
|
|
||||||
|
// not current visivility and not sequence valid to set (greater than 0)
|
||||||
|
if ((isEmptyValue(currentYesNo) || currentYesNo === false) &&
|
||||||
|
(isEmptyValue(newSequence) || newSequence <= 0)) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if (currentYesNo !== newYesNo) {
|
||||||
valuesToSend.push({
|
valuesToSend.push({
|
||||||
columnName: sortYesNoColumnName,
|
columnName: sortYesNoColumnName,
|
||||||
value: dataSequence[sortYesNoColumnName]
|
value: newYesNo
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
const countRequest = state.totalRequest + 1
|
const countRequest = state.totalRequest + 1
|
||||||
commit('setTotalRequest', countRequest)
|
commit('setTotalRequest', countRequest)
|
||||||
|
|
||||||
|
const recordId = itemData[tableName + '_ID']
|
||||||
requestUpdateEntity({
|
requestUpdateEntity({
|
||||||
tableName,
|
tableName,
|
||||||
|
recordId,
|
||||||
recordUuid: itemData.UUID,
|
recordUuid: itemData.UUID,
|
||||||
attributesList: valuesToSend
|
attributesList: valuesToSend
|
||||||
})
|
})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user