diff --git a/src/renderer/src/views/chufang.vue b/src/renderer/src/views/chufang.vue index 6f1a06f..6b97188 100644 --- a/src/renderer/src/views/chufang.vue +++ b/src/renderer/src/views/chufang.vue @@ -95,24 +95,13 @@ export default { //更新数据 async updateSeach() { this.loading = true - let allChufangList = _.cloneDeep(await myDatabase.chufang.toArray()) - let dataTemp = [] - if (_.trim(this.searchParams.xingming)) { - for (let i = 0; i < allChufangList.length; i++) { - let element = allChufangList[i]; - if (element.xingming.includes(_.trim(this.searchParams.xingming))) { - dataTemp.push({ ...element }) - } - } - } else { - dataTemp = _.cloneDeep(allChufangList) - } - let dataTempSort = dataTemp - if (_.get(this.sortObj, ["sort"], "")) { - // 带条件排序 - dataTempSort = _.orderBy(dataTemp, [this.sortObj.prop], [_.get(this.sortObj, ["sort"], "") === 1 ? 'desc' : 'asc']) + let that = this + let collection = myDatabase.chufang + if (that.searchParams.xingming) { + let reg = new RegExp(that.searchParams.xingming, "i") + collection = collection.filter((equip) => reg.test(equip.xingming)) } - this.tableData = _.uniqBy(dataTempSort, "id") + this.tableData = await collection.toArray(); this.loading = false }, // 排序