storePicker.helpers.js
1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/**
* @file storePicker 纯逻辑 — confirm/toast 与 show 重置
* 供全局 storePicker 合并 staffDaily 副本后单测。
*/
/**
* 未选时的 toast 文案
* @param {string|undefined} pickerType - 'merchant' | 'staff'
* @returns {string}
*/
export function getConfirmToast(pickerType) {
if (pickerType === 'staff') return '请选择员工'
return '请选择门店'
}
/**
* confirm 时是否额外 trigger search(operatingShow 默认 true)
* @param {string|undefined} pickerType
* @returns {boolean}
*/
export function shouldEmitSearchOnConfirm(pickerType) {
return !pickerType
}
/**
* show=true 时是否清空搜索并 emit search
* @param {boolean} show
* @returns {{ searchValue: string, shouldEmitSearch: boolean }|null}
*/
export function getShowResetSearchState(show) {
if (!show) return null
return { searchValue: '', shouldEmitSearch: true }
}
/**
* 搜索 confirm 时是否重置 picker 选中索引为 0(staffDaily 行为)
* @param {string} type - input 事件 type
* @returns {boolean}
*/
export function shouldResetSelectOnSearchConfirm(type) {
return type === 'confirm'
}