Skip to content

Commit a91e3ab

Browse files
authored
fix: 修复tabs组件展开内容被遮盖,multi-slect返回值增加value (#36)
1 parent 1a10521 commit a91e3ab

File tree

4 files changed

+42
-30
lines changed

4 files changed

+42
-30
lines changed

src/multi-select/index.js

+13-12
Original file line numberDiff line numberDiff line change
@@ -52,26 +52,26 @@ export const handleClick = ({ api, props, state }) => (value) => {
5252

5353
export const confirm = ({ state, emit }) => () => {
5454
const wheelLevelItems = getWheelLevelItems(state.wheelData, state.defaultSelectedIndexs)
55-
const wheelLevelText = getWheelLevelText(wheelLevelItems, state.defaultSelectedIndexs)
56-
state.headerInfo[state.headerIndex] = { isSelected: true, title: wheelLevelText, isUP: false }
55+
const { selectedLabels, selectedItems } = getSelected(wheelLevelItems, state.defaultSelectedIndexs)
56+
state.headerInfo[state.headerIndex] = { isSelected: true, title: selectedLabels, isUP: false }
5757
state.defaultSelectedArray[state.headerIndex] = state.defaultSelectedIndexs
58-
emit('confirm', state.defaultSelectedIndexs, wheelLevelText)
58+
emit('confirm', selectedItems, state.headerIndex, state.defaultSelectedIndexs)
5959
state.showWheel = false
6060
}
6161

6262
export const reset = ({ api, props, state, emit }) => () => {
6363
state.headerInfo[state.headerIndex] = { isSelected: false, title: '', isUP: false }
6464
state.defaultSelectedIndexs = props.defaultSelectedArray[state.headerIndex] ?? api.loadDefault(state.headerIndex)
6565
state.defaultSelectedArray[state.headerIndex] = state.defaultSelectedIndexs
66-
emit('reset', state.headerIndex)
66+
emit('reset', [], state.headerIndex, state.defaultSelectedIndexs)
6767
state.showWheel = false
6868
}
6969

7070
export const wheelChange = (state) => (indexs) => {
7171
state.defaultSelectedIndexs = indexs
7272
}
7373

74-
export const clickWheelItem = ({ state, emit }) => (indexs, text) => {
74+
export const clickWheelItem = ({ state, emit }) => (indexs, text, item) => {
7575
if (indexs.length === 0) {
7676

7777
// 反选
@@ -82,12 +82,12 @@ export const clickWheelItem = ({ state, emit }) => (indexs, text) => {
8282
state.headerInfo[state.headerIndex] = { isSelected: true, title: text, isUP: false }
8383
}
8484
state.defaultSelectedArray[state.headerIndex] = state.defaultSelectedIndexs
85-
emit('confirm', indexs, text)
85+
emit('confirm', item, state.headerIndex, indexs)
8686
state.showWheel = false
8787
}
8888

8989
export const getWheelLevelItems = (wheelData, newIndexs) => {
90-
const level_1 = wheelData.map(({ label }) => ({ label }))
90+
const level_1 = wheelData
9191
const level_n = getNextLevel([], wheelData, newIndexs, 0)
9292
let wheelLevelItems = []
9393
if (level_n.length === 0) {
@@ -112,15 +112,16 @@ export const getNextLevel = (levelItems, children, nextIndexs, start) => {
112112
}
113113
}
114114

115-
export const getWheelLevelText = (wheelLevelItems, selectedIndexs) => {
116-
const selectedLabels = []
115+
export const getSelected = (wheelLevelItems, selectedIndexs) => {
116+
const selectedItems = []
117117
wheelLevelItems.forEach((levelItem, i) => {
118118
const index = selectedIndexs[i]
119-
if (levelItem[index]?.label) {
120-
selectedLabels.push(levelItem[index]?.label)
119+
if (levelItem[index]) {
120+
selectedItems.push(levelItem[index])
121121
}
122122
});
123-
return selectedLabels.join(' ')
123+
const selectedLabels = selectedItems.map(item => item?.label).join(' ')
124+
return { selectedLabels, selectedItems }
124125
}
125126

126127
export const loadDefault = ({ props, state }) => (value) => {

src/pull-refresh/index.js

+9-4
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,20 @@ export const onTouchstart = (state) => (event) => {
3737
state.draggposition = event.touches[0].clientY
3838
}
3939

40-
export const onTouchmove = (state) => (event) => {
40+
export const onTouchmove = ({ props, state }) => (event) => {
4141

4242
if (event.touches[0].clientY < state.draggposition) {
4343

4444
// 上拉刷新
4545
if (!state.pullUp.pullUpDisabled) {
46-
state.translate3d = (event.touches[0].clientY - state.draggposition) / 2
47-
state.pullUpReplaces = Math.abs(state.translate3d) > state.pullUp.footHeight ? state.loosingText : state.pullUp.pullingUpText
48-
state.pullDownReplaces =''
46+
47+
// 没有更多了
48+
if (props.hasMore) {
49+
50+
state.translate3d = (event.touches[0].clientY - state.draggposition) / 2
51+
state.pullUpReplaces = Math.abs(state.translate3d) > state.pullUp.footHeight ? state.loosingText : state.pullUp.pullingUpText
52+
state.pullDownReplaces = ''
53+
}
4954
}
5055

5156
} else {

src/pull-refresh/vue.js

+15-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { mountedHandler, beforeUnmountHandler, handlerModelValue, onTouchstart,
1414

1515
export const api = ['state']
1616

17-
export const renderless = (props, { computed, onMounted, reactive, onBeforeUnmount }, { t, refs }) => {
17+
export const renderless = (props, { watch, onMounted, reactive, onBeforeUnmount }, { t, refs }) => {
1818
const api = {}
1919
const state = reactive({
2020
pullUpReplaces: '',
@@ -27,6 +27,7 @@ export const renderless = (props, { computed, onMounted, reactive, onBeforeUnmou
2727
loosingText: '',
2828
successText: '',
2929
failedText: '',
30+
noMoreText: '',
3031
pullUp: null,
3132
pullDown: null,
3233
successDuration: props.successDuration,
@@ -36,7 +37,7 @@ export const renderless = (props, { computed, onMounted, reactive, onBeforeUnmou
3637
Object.assign(api, {
3738
state,
3839
onTouchstart: onTouchstart(state),
39-
onTouchmove: onTouchmove(state),
40+
onTouchmove: onTouchmove({ props, state }),
4041
onTouchend: onTouchend({ api, props, state }),
4142
mountedHandler: mountedHandler({ api, refs }),
4243
beforeUnmountHandler: beforeUnmountHandler({ api, refs }),
@@ -45,6 +46,18 @@ export const renderless = (props, { computed, onMounted, reactive, onBeforeUnmou
4546
clearPullRefresh: clearPullRefresh(state),
4647
})
4748

49+
watch(
50+
() => props.hasMore,
51+
(value) => {
52+
if (!value) {
53+
54+
// 没有更多了
55+
state.noMoreText = t('ui.pullRefresh.noMore')
56+
api.clearPullRefresh()
57+
}
58+
},
59+
)
60+
4861
onMounted(()=> {
4962
api.mountedHandler({ api, refs, state })
5063
api.initPullRefresh({ t, props, state })

src/wheel/index.js

+5-12
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export const created = (api) => () => {
2424
export const loadPickerData = ({ props, state }) => () => {
2525
state.dataSource = cloneDeep(props.dataSource)
2626
state.defaultSelectedIndexs = cloneDeep(props.defaultSelectedIndexs)
27-
const level_1 = state.dataSource.map(({ label }) => ({ label }))
27+
const level_1 = state.dataSource
2828
const level_n = getNextLevel([], state.dataSource, state.defaultSelectedIndexs, 0)
2929
if (level_n.length === 0) {
3030

@@ -110,7 +110,7 @@ export const refreshWheel = (nextTick) => (wheel) => {
110110
})
111111
}
112112

113-
export const loadWheels = ({ api, props, state, nextTick, refs }) => (wheel) => {
113+
export const loadWheels = ({ api, props, state, nextTick, refs }) => () => {
114114
if (state.wheels.length === 0) {
115115
nextTick(() => {
116116
state.wheels = []
@@ -149,14 +149,7 @@ export const createWheelHasFooter = ({ api, state, emit, BScroll }) => (wheelWra
149149
]
150150
api.wheelChanged(currentSelectedIndexs, state.prevSelectedIndexs)
151151
state.prevSelectedIndexs = currentSelectedIndexs
152-
const selectedLabels = []
153-
state.pickerData.forEach((data, i) => {
154-
const index = currentSelectedIndexs[i]
155-
if (data[index]?.label) {
156-
selectedLabels.push(data[index]?.label)
157-
}
158-
})
159-
emit('change', currentSelectedIndexs, selectedLabels.join(' '))
152+
emit('change', currentSelectedIndexs)
160153
})
161154
api.wheelsTo(state.defaultSelectedIndexs)
162155
api.changeWheelItemStyle(state.pickerData, state.defaultSelectedIndexs)
@@ -205,11 +198,11 @@ export const clickWheelItem = ({ api, state, emit }) => (index) => {
205198
const rItem = state.pickerData[0][index]
206199
if (state.defaultSelectedIndexs[0] !== index) {
207200
const selectedLabel = rItem?.label
208-
emit('clickWheelItem', [index], selectedLabel)
201+
emit('clickWheelItem', [index], selectedLabel, rItem)
209202
} else {
210203

211204
// 反选
212-
emit('clickWheelItem', [], '')
205+
emit('clickWheelItem', [], '', [])
213206
}
214207
}
215208

0 commit comments

Comments
 (0)