fix(store): 修复店员列表拉取逻辑,保证数据正确性

- 获取当前登录店员的 storeId,避免使用无效 storeId 查询
- 根据 storeId 拉取本门店店员列表,修复空列表问题
- 加载失败时提示“加载店员失败”
- 提示门店信息未就绪时的用户反馈
- 默认选中当前登录用户对应的店员项
This commit is contained in:
2026-07-17 11:36:15 +08:00
parent 01f0638a37
commit ceba1cabec

View File

@@ -462,8 +462,21 @@ export default function StoreOrdersPage() {
setShowShipModal(true)
setLoadingClerks(true)
try {
const res = await listShopStoreUser()
// 获取当前登录店员(含 storeId / userId
// 用 storeId 拉取本门店店员列表,避免 ?storeId=0 拉不到数据
const myClerk = await getMyClerk()
const storeId = myClerk?.storeId
if (!storeId) {
Taro.showToast({title: '门店信息未就绪,请稍后再试', icon: 'none'})
return
}
const res = await listShopStoreUser({storeId})
setClerkList(res || [])
// 默认选中与当前登录用户 userId 一致的店员
if (res && myClerk?.userId) {
const match = res.find(c => c.userId === myClerk!.userId)
if (match) setSelectedClerkId(match.id ?? null)
}
} catch (e) {
Taro.showToast({title: '加载店员失败', icon: 'none'})
} finally {