Skip to content

feat: address 新增底部插槽 #1509

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 31 commits into from
Jul 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
a7878df
fix: marge主分支 (#1)
yangxiaolu1993 Jun 27, 2022
4ab2003
Merge branch 'jdf2e:next' into next
yangxiaolu1993 Jun 27, 2022
f98d540
feat: imagepreview重复问题修改
yangxiaolu1993 Jun 27, 2022
67b6cad
fix: picker 组件重影问题修改
yangxiaolu1993 Jun 27, 2022
236f2fa
Merge branch 'jdf2e:next' into next
yangxiaolu1993 Jun 27, 2022
3a01721
fix: 科技样式同步
yangxiaolu1993 Jun 27, 2022
6baa48c
Merge branch 'next' of https://github.com/yangxiaolu1993/nutui into next
yangxiaolu1993 Jun 27, 2022
dbf8062
Merge branch 'jdf2e:next' into next
yangxiaolu1993 Jun 30, 2022
257bbde
Merge branch 'jdf2e:next' into next
yangxiaolu1993 Jul 1, 2022
6540137
Merge branch 'jdf2e:next' into next
yangxiaolu1993 Jul 1, 2022
535da7c
Merge branch 'jdf2e:next' into next
yangxiaolu1993 Jul 4, 2022
3def99e
feat: picker组件惯性滚动优化
yangxiaolu1993 Jul 6, 2022
20cde08
feat: picker组件惯性滚动优化
yangxiaolu1993 Jul 6, 2022
8f6801f
Merge branch 'jdf2e:next' into next
yangxiaolu1993 Jul 6, 2022
3875a2a
Merge branch 'jdf2e:next' into next
yangxiaolu1993 Jul 7, 2022
d00b6d6
fix: issue问题修噶
yangxiaolu1993 Jul 8, 2022
0bc2db1
fix: datepicker国际化修噶
yangxiaolu1993 Jul 8, 2022
99c8f79
Merge branch 'jdf2e:next' into next
yangxiaolu1993 Jul 8, 2022
eb482f4
Merge branch 'jdf2e:next' into next
yangxiaolu1993 Jul 11, 2022
afb0ea6
Merge branch 'jdf2e:next' into next
yangxiaolu1993 Jul 15, 2022
2fa73b1
Merge branch 'jdf2e:next' into next
yangxiaolu1993 Jul 21, 2022
8d4f961
Merge branch 'jdf2e:next' into next
yangxiaolu1993 Jul 27, 2022
0eacdbb
fix: datePicker在year-month下,maxDate不生效问题解决
yangxiaolu1993 Jul 27, 2022
64f2c62
Merge branch 'jdf2e:next' into next
yangxiaolu1993 Jul 27, 2022
e420d76
fix: picker异步处理
yangxiaolu1993 Jul 27, 2022
c466171
fix: picker taro
yangxiaolu1993 Jul 27, 2022
780e3b6
fix: picker问题修改
yangxiaolu1993 Jul 27, 2022
6422c66
Merge branch 'jdf2e:next' into next
yangxiaolu1993 Jul 28, 2022
a58e1c4
feat: address 新增插槽
yangxiaolu1993 Jul 29, 2022
7e5f199
feat: address 新增插槽
yangxiaolu1993 Jul 29, 2022
f601b7b
Merge branch 'jdf2e:next' into next
yangxiaolu1993 Jul 29, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/packages/__VUE/address/demo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,13 @@
:default-icon="defaultIcon"
:selected-icon="selectedIcon"
:close-btn-icon="closeBtnIcon"
></nut-address>
>
<template #bottom>
<div class="nut-address-custom-buttom">
<div class="btn">自定义按钮</div>
</div>
</template>
</nut-address>

<h2>{{ translate('change') }}</h2>
<nut-cell :title="translate('title')" :desc="four" is-link @click="showAddressOther"></nut-cell>
Expand Down
6 changes: 6 additions & 0 deletions src/packages/__VUE/address/doc.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -578,4 +578,10 @@ If you want to select a province, you need to set the region ID in the order of
|----- | ----- | -----
| type | Selected Type | exist/custom/custom2
| data | Selected Data | {}


## Slot
| Attribute | Description |
|----- | ----- |
| bottom `3.1.23` | Bottom slot |

14 changes: 12 additions & 2 deletions src/packages/__VUE/address/doc.md
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,13 @@ app.use(Elevator);
:default-icon="defaultIcon"
:selected-icon="selectedIcon"
:close-btn-icon="closeBtnIcon"
></nut-address>
>
<template #bottom>
<div class="nut-address-custom-buttom">
<div class="btn">自定义按钮</div>
</div>
</template>
</nut-address>
</template>
<script>
import { ref,reactive,toRefs } from 'vue';
Expand Down Expand Up @@ -587,4 +593,8 @@ app.use(Elevator);
|----- | ----- | -----
| type | 地址选择类型 exist/custom/custom2 | exist/custom/custom2
| data | 选择地址的值,custom 时,addressStr 为选择的地址组合 | {}


## Slot
| 字段 | 说明 |
|----- | ----- |
| bottom `3.1.23` | 可自定义底部 |
18 changes: 18 additions & 0 deletions src/packages/__VUE/address/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -152,4 +152,22 @@
}
}
}

&-custom-buttom {
width: 100%;
height: 54px;
padding: 6px 0px 0;
border-top: 1px solid #f2f2f2;
.btn {
width: 90%;
height: 42px;
line-height: 42px;
margin: auto;
text-align: center;
background: $button-primary-background-color;
border-radius: 21px;
font-size: 15px;
color: $white;
}
}
}
3 changes: 3 additions & 0 deletions src/packages/__VUE/address/index.taro.vue
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,9 @@
<div class="choose-other" @click="switchModule" v-if="isShowCustomAddress">
<div class="btn">{{ customAndExistTitle || translate('chooseAnotherAddress') }}</div>
</div>
<template v-if="!isShowCustomAddress">
<slot name="bottom"></slot>
</template>
</view>
</view>
</nut-popup>
Expand Down
3 changes: 3 additions & 0 deletions src/packages/__VUE/address/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,13 @@
</li>
</ul>
</div>

<div class="choose-other" @click="switchModule" v-if="isShowCustomAddress">
<div class="btn">{{ customAndExistTitle || translate('chooseAnotherAddress') }}</div>
</div>
</view>

<slot name="bottom"></slot>
</view>
</nut-popup>
</template>
Expand Down
92 changes: 90 additions & 2 deletions src/packages/__VUE/picker/demo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,25 @@
>
<nut-button block type="primary" @click="alwaysFun">{{ translate('always') }}</nut-button></nut-picker
>

<!-- <h2>异步获取</h2>
<nut-cell
:title="translate('validTime')"
:desc="effect"
@click="
() => {
showJK = true;
}
"
></nut-cell>
<nut-picker
v-model:visible="showJK"
:columns="jkColumns"
:title="translate('chooseDate')"
@confirm="(options) => confirm('effect', options)"
@change="changeJK"
></nut-picker
> -->
</div>
</template>
<script lang="ts">
Expand All @@ -138,7 +157,7 @@ import { PickerOption } from './types';
const { createDemo, translate } = createComponent('picker');
import { useTranslate } from '@/sites/assets/util/useTranslate';
import { Internation } from './doc.en';
import { convertListToOptions } from '../cascader/helper';

useTranslate(Internation);
export default createDemo({
props: {},
Expand Down Expand Up @@ -219,6 +238,58 @@ export default createDemo({
}
]);

const bf = {
ZheJiang: [
{
text: translate('hangZhou'),
value: 'HangZhou',
children: [
{ text: translate('xiHu'), value: 'XiHu' },
{ text: translate('yuHang'), value: 'YuHang' }
]
},
{
text: translate('wenZhou'),
value: 'WenZhou',
children: [
{ text: translate('luCheng'), value: 'LuCheng' },
{ text: translate('ouHai'), value: 'OuHai' }
]
}
],
FuJian: [
{
text: translate('fuZhou'),
value: 'FuZhou',
children: [
{ text: translate('guLou'), value: 'GuLou' },
{ text: translate('taiJiang'), value: 'TaiJiang' }
]
},
{
text: translate('xiaMen'),
value: 'XiaMen',
children: [
{ text: translate('siMing'), value: 'SiMing' },
{ text: translate('haiCang'), value: 'HaiCang' }
]
}
]
};

const jkColumns = ref([
{
text: translate('zheJiang'),
value: 'ZheJiang',
children: []
},
{
text: translate('fuJian'),
value: 'FuJian',
children: []
}
]);

const effectColumns = ref([
{ text: '2022-01', value: 'January' },
{ text: '2022-02', value: 'February' },
Expand All @@ -243,6 +314,8 @@ export default createDemo({
const showEffect = ref(false);
const showTile = ref(false);

const showJK = ref(false);

const desc = reactive({
index: '',
defult: '',
Expand Down Expand Up @@ -301,6 +374,18 @@ export default createDemo({
console.log(selectedValue);
};

// change
const changeJK = (data) => {
const { columnIndex, selectedOptions, selectedValue } = data;
if (columnIndex == 0) {
jkColumns.value.forEach((colum) => {
if (colum.value == selectedValue[columnIndex] && colum.children.length == 0) {
colum.children = bf[selectedValue[columnIndex]];
}
});
}
};

const alwaysFun = () => {
showEffect.value = false;
desc.effect = translate('always');
Expand All @@ -327,7 +412,10 @@ export default createDemo({
translate,
selectedTime,
columsNum,
showTile
showTile,
showJK,
jkColumns,
changeJK
};
}
});
Expand Down
49 changes: 29 additions & 20 deletions src/packages/__VUE/picker/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,16 @@ import { createComponent } from '@/packages/utils/create';
import popup, { popupProps } from '../popup/index.vue';
import column from './Column.vue';
const { componentName, create, translate } = createComponent('picker');
// import { PickerColumnOption, PickerOption, TouchParams } from './types';

export interface PickerOption {
text: string | number;
value: string | number;
disabled?: string;
children?: PickerOption[];
className?: string | number;
}

export default create({
components: {
[column.name]: column,
Expand All @@ -75,7 +85,7 @@ export default create({
default: ''
},
columns: {
type: Array,
type: Array as PropType<(PickerOption | PickerOption[])[]>,
default: () => {
return [];
}
Expand All @@ -94,7 +104,7 @@ export default create({
setup(props, { emit }) {
const state = reactive({
show: false,
formattedColumns: props.columns as import('./types').PickerOption[]
formattedColumns: props.columns
});

// 选中项
Expand All @@ -110,20 +120,18 @@ export default create({
});

const selectedOptions = computed(() => {
let optins: import('./types').PickerOption[] = [];
(columnsList.value as import('./types').PickerOption[][]).map(
(column: import('./types').PickerOption[], index: number) => {
let currOptions = [];
currOptions = column.filter((item) => item.value == defaultValues.value[index]);
optins.push(currOptions[0]);
}
);
let optins: PickerOption[] = [];
(columnsList.value as PickerOption[][]).map((column: PickerOption[], index: number) => {
let currOptions = [];
currOptions = column.filter((item) => item.value == defaultValues.value[index]);
optins.push(currOptions[0]);
});

return optins;
});
// 当前类型
const columnsType = computed(() => {
const firstColumn: import('./types').PickerOption = state.formattedColumns[0];
const firstColumn: PickerOption | PickerOption[] = state.formattedColumns[0];
if (firstColumn) {
if (Array.isArray(firstColumn)) {
return 'multiple';
Expand All @@ -138,19 +146,19 @@ export default create({
const columnsList = computed(() => {
switch (columnsType.value) {
case 'multiple':
return state.formattedColumns;
return state.formattedColumns as PickerOption[][];
case 'cascade':
// 级联数据处理
return formatCascade(state.formattedColumns, defaultValues.value);
return formatCascade(state.formattedColumns as PickerOption[], defaultValues.value);
default:
return [state.formattedColumns];
return [state.formattedColumns] as PickerOption[][];
}
});

// 级联数据格式化
const formatCascade = (columns: import('./types').PickerOption[], defaultValues: (number | string)[]) => {
const formatted: import('./types').PickerOption[][] = [];
let cursor: import('./types').PickerOption = {
const formatCascade = (columns: PickerOption[], defaultValues: (number | string)[]) => {
const formatted: PickerOption[][] = [];
let cursor: PickerOption = {
text: '',
value: '',
children: columns
Expand All @@ -159,7 +167,7 @@ export default create({
let columnIndex = 0;

while (cursor && cursor.children) {
const options: import('./types').PickerOption[] = cursor.children;
const options: PickerOption[] = cursor.children;
const value = defaultValues[columnIndex];
let index = options.findIndex((columnItem) => columnItem.value == value);
if (index == -1) index = 0;
Expand All @@ -180,7 +188,7 @@ export default create({
emit('update:visible', false);
};

const changeHandler = (columnIndex: number, option: import('./types').PickerOption) => {
const changeHandler = (columnIndex: number, option: PickerOption) => {
if (option && Object.keys(option).length) {
if (columnsType.value === 'cascade') {
defaultValues.value[columnIndex] = option.value ? option.value : '';
Expand Down Expand Up @@ -256,7 +264,8 @@ export default create({
watch(
() => props.columns,
(val) => {
if (val.length) state.formattedColumns = val as import('./types').PickerOption[];
console.log('更新 columes');
if (val.length) state.formattedColumns = val as PickerOption[];
}
);

Expand Down