Commit 41c2a102 authored by 高宇's avatar 高宇

1.修改高亮行

parent db9093f1
......@@ -58,6 +58,11 @@ export default {
name: 'Dispose',
data() {
return {
// 本地储存
/**
* 元素是一个对象 对象中有三个值 location list frequency
* **/
storeList: [],
// 总计
total: 0,
rowIndexList: [],
......@@ -100,40 +105,132 @@ export default {
}
})
},
/**
* 获取本次要高亮的行的下坐标和要加的数量
* **/
getIndexAndNeedNumber(search) {
var last = {
index: null,
needNumber: null
}
/**
* 1.判断储存的list是不是为空
* **/
if (this.storeList.length > 0) {
var list = []
// 判断tableList中location和search相同的元素个数
this.tableList.forEach((item,index) => {
if (item.location === search) {
list.push(index)
}
})
if (list.length > 0) {
if (list.length === 1) {
last.index = list[0]
last.needNumber = this.tableList[list[0]].needNumber
return last
}
if (list.length > 1) {
// 是否能从储存中找到location
if (this.storeList.find(Litem => Litem.location === search)) {
var index = this.storeList.findIndex(Litem => Litem.location === search)
this.storeList[index].frequency = this.storeList[index].frequency + 1
last.index = this.storeList[index].list[this.storeList[index].frequency]
last.needNumber = this.tableList[this.storeList[index].list[this.storeList[index].frequency]].needNumber
return last
} else {
var objT= {
location: search,
list: list,
frequency: 0
}
this.storeList.push(objT)
last.index = list[0]
last.needNumber = this.tableList[list[0]].needNumber
return last
}
}
} else {
this.$message.error("请输入正确的地址")
return null;
}
} else {
// 向储存列表加数据
var obj = {
location: search,
list: [],
frequency: 0
}
// 判断tableList中location和search相同的元素个数
this.tableList.forEach((item,index) => {
if (item.location === search) {
obj.list.push(index)
}
})
if (obj.list.length > 0) {
if (obj.list.length === 1) {
last.index = obj.list[0]
last.needNumber = this.tableList[obj.list[0]].needNumber
return last
}
if (obj.list.length > 1) {
// 向本地本地储存存入obj
this.storeList.push(obj)
last.index = obj.list[0]
last.needNumber = this.tableList[obj.list[0]].needNumber
return last
}
} else {
this.$message.error("请输入正确的地址")
return null;
}
console.log('判断tableList中location和search相同的元素个数',obj.list.length)
}
},
// 查询回
// handleSearch() {
handleSearch() {
const obj = this.getIndexAndNeedNumber(this.searchForm.search)
console.log('obj',obj)
if (obj) {
const {index,needNumber} = obj
if (!this.rowIndexList.includes(index)) {
this.rowIndexList.push(index)
}
this.total = this.total + needNumber
}
// this.tableList.forEach((item, index) => {
// if (item.location === this.searchForm.search) {
// this.rowIndexList.push(index)
// this.total = this.total + item.needNumber
// }
// })
// },
handleSearch() {
const keyword = this.searchForm.search
// 如果搜索关键字与上一次相同,则从当前索引的下一个位置开始搜索
if (keyword === this.SearchKeyword) {
this.currentIndex++
} else {
// 如果搜索关键字发生变化,则重置索引为-1,并更新上一次搜索的关键字
this.currentIndex = -1
this.SearchKeyword = keyword
}
// 清空之前的高亮记录
this.rowIndexList = []
// 查找匹配项,并将其索引添加到rowIndexList中
for (let i = this.currentIndex + 1; i < this.tableList.length; i++) {
const item = this.tableList[i]
if (item.location === keyword) {
this.rowIndexList.push(i)
this.total = this.total + item.needNumber
// 找到匹配项后,跳出循环
break
}
}
},
// handleSearch() {
// const keyword = this.searchForm.search
// // 如果搜索关键字与上一次相同,则从当前索引的下一个位置开始搜索
// if (keyword === this.SearchKeyword) {
// this.currentIndex++
// } else {
// // 如果搜索关键字发生变化,则重置索引为-1,并更新上一次搜索的关键字
// this.currentIndex = -1
// this.SearchKeyword = keyword
// }
// // 清空之前的高亮记录
// this.rowIndexList = []
// // 查找匹配项,并将其索引添加到rowIndexList中
// for (let i = this.currentIndex + 1; i < this.tableList.length; i++) {
// const item = this.tableList[i]
// if (item.location === keyword) {
// this.rowIndexList.push(i)
// this.total = this.total + item.needNumber
// // 找到匹配项后,跳出循环
// break
// }
// }
// },
// 出库
handleSave() {
if (this.total === this.form.qty) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment