Skip to content

Commit

Permalink
Merge branch 'dev' into yiruiwen
Browse files Browse the repository at this point in the history
  • Loading branch information
wlxuqu committed Jun 23, 2020
2 parents f76fb96 + 0f38bd6 commit 5874cf8
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 26 deletions.
38 changes: 19 additions & 19 deletions uview-ui/components/u-select/u-select.vue
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
* @event {Function} confirm 点击确定按钮,返回当前选择的值
* @example <u-select v-model="show" :list="list"></u-select>
*/
export default {
props: {
// 列数据
Expand Down Expand Up @@ -155,7 +155,7 @@ export default {
// 每次队列发生变化时,保存选择的结果
selectValue: [],
// 上一次列变化时的index
lastSelectIndex: [],
lastSelectIndex: [],
// 列数
columnNum: 0,
// 列是否还在滑动中,微信小程序如果在滑动中就点确定,结果可能不准确
Expand Down Expand Up @@ -262,39 +262,39 @@ export default {
// 列选项
columnChange(e) {
let index = null;
let cloumnIndex = e.detail.value;
let columnIndex = e.detail.value;
// 由于后面是需要push进数组的,所以需要先清空数组
this.selectValue = [];
if(this.mode == 'mutil-column-auto') {
// 对比前后两个数组,寻找变更的是哪一列,如果某一个元素不同,即可判定该列发生了变化
this.lastSelectIndex.map((val, idx) => {
if (val != cloumnIndex[idx]) index = idx;
if (val != columnIndex[idx]) index = idx;
});
this.defaultSelector = cloumnIndex;
this.defaultSelector = columnIndex;
for (let i = index + 1; i < this.columnNum; i++) {
// 当前变化列的下一列的数据,需要获取上一列的数据,同时需要指定是上一列的第几个的children,再往后的
// 默认是队列的第一个为默认选项
this.columnData[i] = this.columnData[i - 1][i - 1 == index ? cloumnIndex[index] : 0][this.childName];
this.columnData[i] = this.columnData[i - 1][i - 1 == index ? columnIndex[index] : 0][this.childName];
// 改变的列之后的所有列,默认选中第一个
this.defaultSelector[i] = 0;
}
// 在历遍的过程中,可能由于上一步修改this.columnData,导致产生连锁反应,程序触发columnChange,会有多次调用
// 只有在最后一次数据稳定后的结果是正确的,此前的历遍中,可能会产生undefined,故需要判断
cloumnIndex.map((item, index) => {
let data = this.columnData[index][cloumnIndex[index]];
columnIndex.map((item, index) => {
let data = this.columnData[index][columnIndex[index]];
let tmp = {
value: data ? data[this.valueName] : null,
label: data ? data[this.labelName] : null,
};
// 判断是否有需要额外携带的参数
if(data && data.extra) tmp.extra = data.extra;
this.selectValue.push(tmp);
})
// 保存这一次的结果,用于下次列发生变化时作比较
this.lastSelectIndex = cloumnIndex;
this.lastSelectIndex = columnIndex;
} else if(this.mode == 'single-column') {
let data = this.columnData[0][cloumnIndex[0]];
let data = this.columnData[0][columnIndex[0]];
// 初始默认选中值
let tmp = {
value: data ? data[this.valueName] : null,
Expand All @@ -305,8 +305,8 @@ export default {
this.selectValue.push(tmp);
} else if(this.mode == 'mutil-column') {
// 初始默认选中值
cloumnIndex.map((item, index) => {
let data = this.columnData[index][cloumnIndex[index]];
columnIndex.map((item, index) => {
let data = this.columnData[index][columnIndex[index]];
// 初始默认选中值
let tmp = {
value: data ? data[this.valueName] : null,
Expand Down Expand Up @@ -340,38 +340,38 @@ export default {
@import "../../libs/css/style.components.scss";
.u-select {
&__action {
position: relative;
line-height: $u-form-item-height;
height: $u-form-item-height;
&__icon {
position: absolute;
right: 20rpx;
top: 50%;
transition: transform .4s;
transform: translateY(-50%);
z-index: 1;
&--reverse {
transform: rotate(-180deg) translateY(50%);
}
}
}
&__hader {
&__title {
color: $u-content-color;
}
}
&--border {
border-radius: 6rpx;
border-radius: 4px;
border: 1px solid $u-form-item-border-color;
}
&__header {
display: flex;
align-items: center;
Expand Down
14 changes: 7 additions & 7 deletions uview-ui/components/u-waterfall/u-waterfall.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<view class="u-waterfall">
<view id="u-left-cloumn" class="u-cloumn"><slot name="left" :leftList="leftList"></slot></view>
<view id="u-right-cloumn" class="u-cloumn"><slot name="right" :rightList="rightList"></slot></view>
<view id="u-left-column" class="u-column"><slot name="left" :leftList="leftList"></slot></view>
<view id="u-right-column" class="u-column"><slot name="right" :rightList="rightList"></slot></view>
</view>
</template>

Expand Down Expand Up @@ -73,8 +73,8 @@ export default {
methods: {
async splitData() {
if (!this.tempList.length) return;
let leftRect = await this.$uGetRect('#u-left-cloumn');
let rightRect = await this.$uGetRect('#u-right-cloumn');
let leftRect = await this.$uGetRect('#u-left-column');
let rightRect = await this.$uGetRect('#u-right-column');
// 如果左边小于或等于右边,就添加到左边,否则添加到右边
let item = this.tempList[0];
// 解决多次快速上拉后,可能数据会乱的问题,因为经过上面的两个await节点查询阻塞一定时间,加上后面的定时器干扰
Expand Down Expand Up @@ -116,7 +116,7 @@ export default {
// 清除某一条指定的数据,根据id实现
remove(id) {
// 如果findIndex找不到合适的条件,就会返回-1
let index = -1;
let index = -1;
index = this.leftList.findIndex(val => val[this.idKey] == id);
if(index != -1) {
// 如果index不等于-1,说明已经找到了要找的id,根据index索引删除这一条数据
Expand All @@ -133,7 +133,7 @@ export default {
// 修改某条数据的某个属性
modify(id, key, value) {
// 如果findIndex找不到合适的条件,就会返回-1
let index = -1;
let index = -1;
index = this.leftList.findIndex(val => val[this.idKey] == id);
if(index != -1) {
// 如果index不等于-1,说明已经找到了要找的id,修改对应key的值
Expand Down Expand Up @@ -167,7 +167,7 @@ export default {
align-items: flex-start;
}
.u-cloumn {
.u-column {
display: flex;
flex: 1;
flex-direction: column;
Expand Down

0 comments on commit 5874cf8

Please sign in to comment.