30 lines
505 B
JavaScript
30 lines
505 B
JavaScript
const StickyCalculate = class {
|
|
typeIdMap = []
|
|
fixArr = []
|
|
|
|
constructor(type) {
|
|
this.typeIdMap = type;
|
|
}
|
|
|
|
opFixArr(typeId, isFix) {
|
|
let index = this.fixArr.indexOf(typeId)
|
|
if (isFix && (index == -1)) {
|
|
this.fixArr.push(typeId)
|
|
} else if ((!isFix) && (index > -1)) {
|
|
this.fixArr.splice(index, 1)
|
|
}
|
|
return this
|
|
}
|
|
|
|
getActionId() {
|
|
let index = this.fixArr.length - 1
|
|
if (index < 0) {
|
|
return 0
|
|
} else {
|
|
return this.typeIdMap[index]
|
|
}
|
|
}
|
|
}
|
|
|
|
export default StickyCalculate
|