更新商品列表按照字母搜索
This commit is contained in:
11
package-lock.json
generated
11
package-lock.json
generated
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "vite-electron",
|
||||
"version": "2.0.28",
|
||||
"version": "2.0.30",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "vite-electron",
|
||||
"version": "2.0.28",
|
||||
"version": "2.0.30",
|
||||
"hasInstallScript": true,
|
||||
"dependencies": {
|
||||
"@element-plus/icons-vue": "^2.3.1",
|
||||
@@ -21,6 +21,7 @@
|
||||
"lodash": "^4.17.21",
|
||||
"pinia": "^2.1.7",
|
||||
"pinia-plugin-persistedstate": "^3.2.1",
|
||||
"pinyin-match": "^1.2.10",
|
||||
"qr-image": "^3.2.0",
|
||||
"qrcode": "^1.5.3",
|
||||
"reconnecting-websocket": "^4.4.0",
|
||||
@@ -5223,6 +5224,12 @@
|
||||
"pinia": "^2.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/pinyin-match": {
|
||||
"version": "1.2.10",
|
||||
"resolved": "https://registry.npmmirror.com/pinyin-match/-/pinyin-match-1.2.10.tgz",
|
||||
"integrity": "sha512-Xo1uMd9n56/xP2EAn7yfApnTmAGCLGqxFIm1fuOnSMty0xhqRF3+ZwVjp2yWFD/alv60RUWa/cZoQSeTSp1HxA==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/plist": {
|
||||
"version": "3.1.0",
|
||||
"resolved": "https://registry.npmmirror.com/plist/-/plist-3.1.0.tgz",
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "vite-electron",
|
||||
"private": true,
|
||||
"version": "2.0.30",
|
||||
"version": "2.0.31",
|
||||
"main": "dist-electron/main.js",
|
||||
"scripts": {
|
||||
"dev": "chcp 65001 && vite",
|
||||
@@ -24,6 +24,7 @@
|
||||
"lodash": "^4.17.21",
|
||||
"pinia": "^2.1.7",
|
||||
"pinia-plugin-persistedstate": "^3.2.1",
|
||||
"pinyin-match": "^1.2.10",
|
||||
"qr-image": "^3.2.0",
|
||||
"qrcode": "^1.5.3",
|
||||
"reconnecting-websocket": "^4.4.0",
|
||||
|
||||
@@ -11,6 +11,7 @@ import useStorage from "@/utils/useStorage.js";
|
||||
import { formatDecimal } from "@/utils/index.js";
|
||||
import { shopUserDetail } from "@/api/account.js";
|
||||
import { ElMessage } from "element-plus";
|
||||
import PinyinMatch from 'pinyin-match';
|
||||
|
||||
import {
|
||||
OrderPriceCalculator, limitUtils,
|
||||
@@ -359,10 +360,16 @@ export const useGoods = defineStore("goods", {
|
||||
// 根据商品名字模糊查询商品列表
|
||||
filterNameGoods(name) {
|
||||
this.goodsList = _.chunk(
|
||||
this.originGoodsList.filter((item) => item.name.includes(name)),
|
||||
this.originGoodsList.filter((item) => {
|
||||
// 原来的汉字模糊搜索
|
||||
const hasName = item.name.includes(name);
|
||||
// 新增:拼音/首字母模糊搜索(zs / zhangsan / 张三 都能搜)
|
||||
const hasPinyin = name && PinyinMatch.match(item.name, name);
|
||||
|
||||
return hasName || hasPinyin;
|
||||
}),
|
||||
12
|
||||
);
|
||||
|
||||
this.updateGoodsNumber();
|
||||
},
|
||||
// 获取商品分类列表
|
||||
|
||||
Reference in New Issue
Block a user