Skip to content

Commit 6cf46e9

Browse files
yangxiaolu1993lkjh3214lkjh3214szg2008richard1015
authored
feat: address 新增底部插槽 (#1509)
* fix: marge主分支 (#1) * doc: calendar 文档修改 (#1410) * feat: 添加range组件、calendar组件在线文档 * fix: 文档调整 * fix: 重构calendar组件 * feat: 日历组件重构,文档修改,功能完善 * fix: 格式化 * fix: 代码格式化调整。 * fix: 去除无用代码 * fix: 文档调整 * fix: 文档调整 * fix: taro demo 样式修改 * feat: range组件功能完善,新增 竖向操作,刻度展示。 * fix: 冲突解决 * feat: taro功能新增,兼容处理,文档修改 * feat: 添加range组件,jdt主题色 * fix: 修改组件初始化逻辑 * feat: 新增h5 日期多选功能 * feat: taro版本添加 日期多选功能 * fix: 修复多选,无法选中开头结尾日期问题 * fix: 文档修改,添加en-US 文档 * fix: 文档完善 Co-authored-by: lkjh3214 <[email protected]> Co-authored-by: love_forever <[email protected]> * feat: imagepreview 部分功能补齐 (#1412) * feat: image新增单元测试 * feat: ellipsis添加单元测试 * feat: imagepreview 添加 * fix: popop单元测试修改 * docs: 添加版本号 * feat: support highlight for JetBrains web-types * test(imagepreview): edit snap * fix(image): dts edit import * docs(input): demo和md国际化文案修改 (#1414) * fix: 抽离 input ConfirmTextType * feat: input、switch国际化 * feat: category、address国际化 * feat: taro升级maxlength问题 * fix: 国际化增加默认字段 * fix: blank * fix: input组件国际化文案修改 * style: add ellipsis add sass * docs(elevator): 增加吸顶props * feat: input组件新增input slot插槽 (#1418) * fix: 抽离 input ConfirmTextType * feat: input、switch国际化 * feat: category、address国际化 * feat: taro升级maxlength问题 * fix: 国际化增加默认字段 * fix: blank * fix: input组件国际化文案修改 * feat: input组件新增input slot插槽 * release: v3.1.22 * Update README.md add alipay img * Update README.md * docs: changelog 3.1.22 Co-authored-by: lkjh3214 <[email protected]> Co-authored-by: lkjh3214 <[email protected]> Co-authored-by: love_forever <[email protected]> Co-authored-by: richard1015 <[email protected]> Co-authored-by: ailululu <[email protected]> Co-authored-by: snandy <[email protected]> * feat: imagepreview重复问题修改 * fix: picker 组件重影问题修改 * fix: 科技样式同步 * feat: picker组件惯性滚动优化 * feat: picker组件惯性滚动优化 * fix: issue问题修噶 * fix: datepicker国际化修噶 * fix: datePicker在year-month下,maxDate不生效问题解决 * fix: picker异步处理 * fix: picker taro * fix: picker问题修改 * feat: address 新增插槽 * feat: address 新增插槽 Co-authored-by: lkjh3214 <[email protected]> Co-authored-by: lkjh3214 <[email protected]> Co-authored-by: love_forever <[email protected]> Co-authored-by: richard1015 <[email protected]> Co-authored-by: ailululu <[email protected]> Co-authored-by: snandy <[email protected]>
1 parent 11bbbc0 commit 6cf46e9

File tree

8 files changed

+168
-25
lines changed

8 files changed

+168
-25
lines changed

src/packages/__VUE/address/demo.vue

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,13 @@
7272
:default-icon="defaultIcon"
7373
:selected-icon="selectedIcon"
7474
:close-btn-icon="closeBtnIcon"
75-
></nut-address>
75+
>
76+
<template #bottom>
77+
<div class="nut-address-custom-buttom">
78+
<div class="btn">自定义按钮</div>
79+
</div>
80+
</template>
81+
</nut-address>
7682

7783
<h2>{{ translate('change') }}</h2>
7884
<nut-cell :title="translate('title')" :desc="four" is-link @click="showAddressOther"></nut-cell>

src/packages/__VUE/address/doc.en-US.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -578,4 +578,10 @@ If you want to select a province, you need to set the region ID in the order of
578578
|----- | ----- | -----
579579
| type | Selected Type | exist/custom/custom2
580580
| data | Selected Data | {}
581+
582+
583+
## Slot
584+
| Attribute | Description |
585+
|----- | ----- |
586+
| bottom `3.1.23` | Bottom slot |
581587

src/packages/__VUE/address/doc.md

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,13 @@ app.use(Elevator);
332332
:default-icon="defaultIcon"
333333
:selected-icon="selectedIcon"
334334
:close-btn-icon="closeBtnIcon"
335-
></nut-address>
335+
>
336+
<template #bottom>
337+
<div class="nut-address-custom-buttom">
338+
<div class="btn">自定义按钮</div>
339+
</div>
340+
</template>
341+
</nut-address>
336342
</template>
337343
<script>
338344
import { ref,reactive,toRefs } from 'vue';
@@ -587,4 +593,8 @@ app.use(Elevator);
587593
|----- | ----- | -----
588594
| type | 地址选择类型 exist/custom/custom2 | exist/custom/custom2
589595
| data | 选择地址的值,custom 时,addressStr 为选择的地址组合 | {}
590-
596+
597+
## Slot
598+
| 字段 | 说明 |
599+
|----- | ----- |
600+
| bottom `3.1.23` | 可自定义底部 |

src/packages/__VUE/address/index.scss

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,4 +152,22 @@
152152
}
153153
}
154154
}
155+
156+
&-custom-buttom {
157+
width: 100%;
158+
height: 54px;
159+
padding: 6px 0px 0;
160+
border-top: 1px solid #f2f2f2;
161+
.btn {
162+
width: 90%;
163+
height: 42px;
164+
line-height: 42px;
165+
margin: auto;
166+
text-align: center;
167+
background: $button-primary-background-color;
168+
border-radius: 21px;
169+
font-size: 15px;
170+
color: $white;
171+
}
172+
}
155173
}

src/packages/__VUE/address/index.taro.vue

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,9 @@
122122
<div class="choose-other" @click="switchModule" v-if="isShowCustomAddress">
123123
<div class="btn">{{ customAndExistTitle || translate('chooseAnotherAddress') }}</div>
124124
</div>
125+
<template v-if="!isShowCustomAddress">
126+
<slot name="bottom"></slot>
127+
</template>
125128
</view>
126129
</view>
127130
</nut-popup>

src/packages/__VUE/address/index.vue

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,10 +124,13 @@
124124
</li>
125125
</ul>
126126
</div>
127+
127128
<div class="choose-other" @click="switchModule" v-if="isShowCustomAddress">
128129
<div class="btn">{{ customAndExistTitle || translate('chooseAnotherAddress') }}</div>
129130
</div>
130131
</view>
132+
133+
<slot name="bottom"></slot>
131134
</view>
132135
</nut-popup>
133136
</template>

src/packages/__VUE/picker/demo.vue

Lines changed: 90 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,25 @@
129129
>
130130
<nut-button block type="primary" @click="alwaysFun">{{ translate('always') }}</nut-button></nut-picker
131131
>
132+
133+
<!-- <h2>异步获取</h2>
134+
<nut-cell
135+
:title="translate('validTime')"
136+
:desc="effect"
137+
@click="
138+
() => {
139+
showJK = true;
140+
}
141+
"
142+
></nut-cell>
143+
<nut-picker
144+
v-model:visible="showJK"
145+
:columns="jkColumns"
146+
:title="translate('chooseDate')"
147+
@confirm="(options) => confirm('effect', options)"
148+
@change="changeJK"
149+
></nut-picker
150+
> -->
132151
</div>
133152
</template>
134153
<script lang="ts">
@@ -138,7 +157,7 @@ import { PickerOption } from './types';
138157
const { createDemo, translate } = createComponent('picker');
139158
import { useTranslate } from '@/sites/assets/util/useTranslate';
140159
import { Internation } from './doc.en';
141-
import { convertListToOptions } from '../cascader/helper';
160+
142161
useTranslate(Internation);
143162
export default createDemo({
144163
props: {},
@@ -219,6 +238,58 @@ export default createDemo({
219238
}
220239
]);
221240
241+
const bf = {
242+
ZheJiang: [
243+
{
244+
text: translate('hangZhou'),
245+
value: 'HangZhou',
246+
children: [
247+
{ text: translate('xiHu'), value: 'XiHu' },
248+
{ text: translate('yuHang'), value: 'YuHang' }
249+
]
250+
},
251+
{
252+
text: translate('wenZhou'),
253+
value: 'WenZhou',
254+
children: [
255+
{ text: translate('luCheng'), value: 'LuCheng' },
256+
{ text: translate('ouHai'), value: 'OuHai' }
257+
]
258+
}
259+
],
260+
FuJian: [
261+
{
262+
text: translate('fuZhou'),
263+
value: 'FuZhou',
264+
children: [
265+
{ text: translate('guLou'), value: 'GuLou' },
266+
{ text: translate('taiJiang'), value: 'TaiJiang' }
267+
]
268+
},
269+
{
270+
text: translate('xiaMen'),
271+
value: 'XiaMen',
272+
children: [
273+
{ text: translate('siMing'), value: 'SiMing' },
274+
{ text: translate('haiCang'), value: 'HaiCang' }
275+
]
276+
}
277+
]
278+
};
279+
280+
const jkColumns = ref([
281+
{
282+
text: translate('zheJiang'),
283+
value: 'ZheJiang',
284+
children: []
285+
},
286+
{
287+
text: translate('fuJian'),
288+
value: 'FuJian',
289+
children: []
290+
}
291+
]);
292+
222293
const effectColumns = ref([
223294
{ text: '2022-01', value: 'January' },
224295
{ text: '2022-02', value: 'February' },
@@ -243,6 +314,8 @@ export default createDemo({
243314
const showEffect = ref(false);
244315
const showTile = ref(false);
245316
317+
const showJK = ref(false);
318+
246319
const desc = reactive({
247320
index: '',
248321
defult: '',
@@ -301,6 +374,18 @@ export default createDemo({
301374
console.log(selectedValue);
302375
};
303376
377+
// change
378+
const changeJK = (data) => {
379+
const { columnIndex, selectedOptions, selectedValue } = data;
380+
if (columnIndex == 0) {
381+
jkColumns.value.forEach((colum) => {
382+
if (colum.value == selectedValue[columnIndex] && colum.children.length == 0) {
383+
colum.children = bf[selectedValue[columnIndex]];
384+
}
385+
});
386+
}
387+
};
388+
304389
const alwaysFun = () => {
305390
showEffect.value = false;
306391
desc.effect = translate('always');
@@ -327,7 +412,10 @@ export default createDemo({
327412
translate,
328413
selectedTime,
329414
columsNum,
330-
showTile
415+
showTile,
416+
showJK,
417+
jkColumns,
418+
changeJK
331419
};
332420
}
333421
});

src/packages/__VUE/picker/index.vue

Lines changed: 29 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,16 @@ import { createComponent } from '@/packages/utils/create';
5151
import popup, { popupProps } from '../popup/index.vue';
5252
import column from './Column.vue';
5353
const { componentName, create, translate } = createComponent('picker');
54+
// import { PickerColumnOption, PickerOption, TouchParams } from './types';
55+
56+
export interface PickerOption {
57+
text: string | number;
58+
value: string | number;
59+
disabled?: string;
60+
children?: PickerOption[];
61+
className?: string | number;
62+
}
63+
5464
export default create({
5565
components: {
5666
[column.name]: column,
@@ -75,7 +85,7 @@ export default create({
7585
default: ''
7686
},
7787
columns: {
78-
type: Array,
88+
type: Array as PropType<(PickerOption | PickerOption[])[]>,
7989
default: () => {
8090
return [];
8191
}
@@ -94,7 +104,7 @@ export default create({
94104
setup(props, { emit }) {
95105
const state = reactive({
96106
show: false,
97-
formattedColumns: props.columns as import('./types').PickerOption[]
107+
formattedColumns: props.columns
98108
});
99109
100110
// 选中项
@@ -110,20 +120,18 @@ export default create({
110120
});
111121
112122
const selectedOptions = computed(() => {
113-
let optins: import('./types').PickerOption[] = [];
114-
(columnsList.value as import('./types').PickerOption[][]).map(
115-
(column: import('./types').PickerOption[], index: number) => {
116-
let currOptions = [];
117-
currOptions = column.filter((item) => item.value == defaultValues.value[index]);
118-
optins.push(currOptions[0]);
119-
}
120-
);
123+
let optins: PickerOption[] = [];
124+
(columnsList.value as PickerOption[][]).map((column: PickerOption[], index: number) => {
125+
let currOptions = [];
126+
currOptions = column.filter((item) => item.value == defaultValues.value[index]);
127+
optins.push(currOptions[0]);
128+
});
121129
122130
return optins;
123131
});
124132
// 当前类型
125133
const columnsType = computed(() => {
126-
const firstColumn: import('./types').PickerOption = state.formattedColumns[0];
134+
const firstColumn: PickerOption | PickerOption[] = state.formattedColumns[0];
127135
if (firstColumn) {
128136
if (Array.isArray(firstColumn)) {
129137
return 'multiple';
@@ -138,19 +146,19 @@ export default create({
138146
const columnsList = computed(() => {
139147
switch (columnsType.value) {
140148
case 'multiple':
141-
return state.formattedColumns;
149+
return state.formattedColumns as PickerOption[][];
142150
case 'cascade':
143151
// 级联数据处理
144-
return formatCascade(state.formattedColumns, defaultValues.value);
152+
return formatCascade(state.formattedColumns as PickerOption[], defaultValues.value);
145153
default:
146-
return [state.formattedColumns];
154+
return [state.formattedColumns] as PickerOption[][];
147155
}
148156
});
149157
150158
// 级联数据格式化
151-
const formatCascade = (columns: import('./types').PickerOption[], defaultValues: (number | string)[]) => {
152-
const formatted: import('./types').PickerOption[][] = [];
153-
let cursor: import('./types').PickerOption = {
159+
const formatCascade = (columns: PickerOption[], defaultValues: (number | string)[]) => {
160+
const formatted: PickerOption[][] = [];
161+
let cursor: PickerOption = {
154162
text: '',
155163
value: '',
156164
children: columns
@@ -159,7 +167,7 @@ export default create({
159167
let columnIndex = 0;
160168
161169
while (cursor && cursor.children) {
162-
const options: import('./types').PickerOption[] = cursor.children;
170+
const options: PickerOption[] = cursor.children;
163171
const value = defaultValues[columnIndex];
164172
let index = options.findIndex((columnItem) => columnItem.value == value);
165173
if (index == -1) index = 0;
@@ -180,7 +188,7 @@ export default create({
180188
emit('update:visible', false);
181189
};
182190
183-
const changeHandler = (columnIndex: number, option: import('./types').PickerOption) => {
191+
const changeHandler = (columnIndex: number, option: PickerOption) => {
184192
if (option && Object.keys(option).length) {
185193
if (columnsType.value === 'cascade') {
186194
defaultValues.value[columnIndex] = option.value ? option.value : '';
@@ -256,7 +264,8 @@ export default create({
256264
watch(
257265
() => props.columns,
258266
(val) => {
259-
if (val.length) state.formattedColumns = val as import('./types').PickerOption[];
267+
console.log('更新 columes');
268+
if (val.length) state.formattedColumns = val as PickerOption[];
260269
}
261270
);
262271

0 commit comments

Comments
 (0)