Skip to content

Commit e59a208

Browse files
yangxiaolu1993lkjh3214lkjh3214szg2008richard1015
authored
fix: Picker 与 DatePicker Issue 问题修改 (#1502)
* 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问题修改 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 68874f7 commit e59a208

File tree

14 files changed

+231
-23
lines changed

14 files changed

+231
-23
lines changed

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,20 +219,24 @@ export default create({
219219
selectedValue: (string | number)[];
220220
selectedOptions: import('../picker/types').PickerOption[];
221221
}) => {
222-
if (['date', 'datetime', 'datehour', 'month-day'].includes(props.type)) {
222+
if (['date', 'datetime', 'datehour', 'month-day', 'year-month'].includes(props.type)) {
223223
let formatDate: (number | string)[] = [];
224224
selectedValue.forEach((item) => {
225225
formatDate.push(item);
226226
});
227227
if (props.type == 'month-day') {
228228
formatDate.unshift(new Date(props.modelValue || props.minDate || props.maxDate).getFullYear());
229229
}
230+
if (props.type == 'year-month' && formatDate.length < 3) {
231+
formatDate.push(new Date(props.modelValue || props.minDate || props.maxDate).getDate());
232+
}
233+
230234
const year = Number(formatDate[0]);
231235
const month = Number(formatDate[1]) - 1;
232236
const day = Math.min(Number(formatDate[2]), getMonthEndDay(Number(formatDate[0]), Number(formatDate[1])));
233237
let date: Date | null = null;
234238
235-
if (props.type === 'date' || props.type === 'month-day') {
239+
if (props.type === 'date' || props.type === 'month-day' || props.type === 'year-month') {
236240
date = new Date(year, month, day);
237241
} else if (props.type === 'datetime') {
238242
date = new Date(year, month, day, Number(formatDate[3]), Number(formatDate[4]));

src/packages/__VUE/datepicker/index.vue

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ export default create({
237237
selectedValue: (string | number)[];
238238
selectedOptions: PickerOption[];
239239
}) => {
240-
if (['date', 'datetime', 'datehour', 'month-day'].includes(props.type)) {
240+
if (['date', 'datetime', 'datehour', 'month-day', 'year-month'].includes(props.type)) {
241241
let formatDate: (number | string)[] = [];
242242
selectedValue.forEach((item) => {
243243
formatDate.push(item);
@@ -246,11 +246,15 @@ export default create({
246246
formatDate.unshift(new Date(props.modelValue || props.minDate || props.maxDate).getFullYear());
247247
}
248248
249+
if (props.type == 'year-month' && formatDate.length < 3) {
250+
formatDate.push(new Date(props.modelValue || props.minDate || props.maxDate).getDate());
251+
}
252+
249253
const year = Number(formatDate[0]);
250254
const month = Number(formatDate[1]) - 1;
251255
const day = Math.min(Number(formatDate[2]), getMonthEndDay(Number(formatDate[0]), Number(formatDate[1])));
252256
let date: Date | null = null;
253-
if (props.type === 'date' || props.type === 'month-day') {
257+
if (props.type === 'date' || props.type === 'month-day' || props.type === 'year-month') {
254258
date = new Date(year, month, day);
255259
} else if (props.type === 'datetime') {
256260
date = new Date(year, month, day, Number(formatDate[3]), Number(formatDate[4]));

src/packages/__VUE/picker/Column.vue

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,19 @@ export default create({
276276
watch(
277277
() => props.column,
278278
(val) => {
279-
console.log('props.column变化', props.column);
279+
if (props.column && props.column.length > 0) {
280+
state.transformY = 0;
281+
modifyStatus(false);
282+
}
283+
},
284+
{
285+
deep: true
286+
}
287+
);
288+
289+
watch(
290+
() => props.value,
291+
(val) => {
280292
state.transformY = 0;
281293
modifyStatus(false);
282294
},
@@ -285,17 +297,6 @@ export default create({
285297
}
286298
);
287299
288-
// watch(
289-
// () => props.value,
290-
// (val) => {
291-
// console.log('props.value变化')
292-
// modifyStatus(true);
293-
// },
294-
// {
295-
// deep: true
296-
// }
297-
// );
298-
299300
onMounted(() => {
300301
modifyStatus(true);
301302
});

src/packages/__VUE/picker/ColumnTaro.vue

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,17 @@ export default create({
274274
}
275275
);
276276
277+
watch(
278+
() => props.value,
279+
(val) => {
280+
state.transformY = 0;
281+
modifyStatus(false);
282+
},
283+
{
284+
deep: true
285+
}
286+
);
287+
277288
watch(
278289
() => props.itemShow,
279290
(val) => {

src/packages/__VUE/picker/demo.vue

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,26 @@
3737
>
3838
</nut-picker>
3939

40+
<h2>{{ translate('tileDesc') }}</h2>
41+
<nut-cell
42+
:title="translate('chooseCity')"
43+
:desc="defult"
44+
@click="
45+
() => {
46+
showTile = true;
47+
}
48+
"
49+
></nut-cell>
50+
<nut-picker
51+
v-model="selectedValue"
52+
v-model:visible="showTile"
53+
:columns="columns"
54+
:title="translate('chooseCity')"
55+
:threeDimensional="false"
56+
@confirm="(options) => confirm('defult', options)"
57+
>
58+
</nut-picker>
59+
4060
<h2>{{ translate('multipleColumns') }}</h2>
4161
<nut-cell
4262
:title="translate('chooseTime')"
@@ -221,6 +241,7 @@ export default createDemo({
221241
const showCascader = ref(false);
222242
const showAsync = ref(false);
223243
const showEffect = ref(false);
244+
const showTile = ref(false);
224245
225246
const desc = reactive({
226247
index: '',
@@ -305,7 +326,8 @@ export default createDemo({
305326
alwaysFun,
306327
translate,
307328
selectedTime,
308-
columsNum
329+
columsNum,
330+
showTile
309331
};
310332
}
311333
});

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

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,52 @@ The default selection is implemented by setting `modelValue`, which is an array
113113

114114
:::
115115

116+
### Tile
117+
118+
:::demo
119+
120+
```html
121+
<template>
122+
<nut-cell title="Choose City" :desc="desc" @click="() => { show = true;}"></nut-cell>
123+
<nut-picker
124+
v-model="selectedValue"
125+
v-model:visible="show"
126+
:columns="columns"
127+
title="Choose City"
128+
:threeDimensional="false"
129+
@confirm="confirm"
130+
>
131+
</nut-picker>
132+
</template>
133+
<script>
134+
import { ref } from 'vue';
135+
export default {
136+
setup(props) {
137+
const show = ref(false);
138+
const desc = ref('');
139+
const selectedValue = ref(['ZheJiang']);
140+
const columns = ref([
141+
{ text: 'NanJing', value: 'NanJing' },
142+
{ text: 'WuXi', value: 'WuXi' },
143+
{ text: 'ZangZu', value: 'ZangZu' },
144+
{ text: 'BeiJing', value: 'BeiJing' },
145+
{ text: 'LianYunGang', value: 'LianYunGang' },
146+
{ text: 'ZheJiang', value: 'ZheJiang' },
147+
{ text: 'JiangSu', value: 'JiangSu' }
148+
]);
149+
150+
const confirm = ( { selectedValue,selectedOptions })=>{
151+
desc.value = selectedValue.join(',');
152+
}
153+
154+
return {show,desc,columns,selectedValue, confirm};
155+
}
156+
};
157+
</script>
158+
```
159+
160+
:::
161+
116162
### Multiple Columns
117163

118164
:::demo

src/packages/__VUE/picker/doc.en.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ export const Internation = {
33
basic: '基本用法',
44
chooseCity: '请选择城市',
55
defaultSelected: '默认选中项',
6+
tileDesc: '平铺展示',
67
multipleColumns: '多列样式',
78
chooseTime: '请选择时间',
89
cascade: '多级联动',
@@ -44,6 +45,7 @@ export const Internation = {
4445
basic: 'Basic Usage',
4546
chooseCity: 'Choose City',
4647
defaultSelected: 'Default Index',
48+
tileDesc: 'Tile',
4749
multipleColumns: 'Multiple Columns',
4850
chooseTime: 'Choose Time',
4951
cascade: 'Cascade',

src/packages/__VUE/picker/doc.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,50 @@ app.use(OverLay);
119119
```
120120
:::
121121

122+
### 平铺展示
123+
124+
:::demo
125+
```html
126+
<template>
127+
<nut-cell title="请选择城市" :desc="desc" @click="() => { show = true;}"></nut-cell>
128+
<nut-picker
129+
v-model="selectedValue"
130+
v-model:visible="show"
131+
:columns="columns"
132+
title="城市选择"
133+
:threeDimensional="false"
134+
@confirm="confirm"
135+
>
136+
</nut-picker>
137+
</template>
138+
<script>
139+
import { ref } from 'vue';
140+
export default {
141+
setup(props) {
142+
const show = ref(false);
143+
const desc = ref('');
144+
const selectedValue = ref(['ZheJiang']);
145+
const columns = ref([
146+
{ text: '南京市', value: 'NanJing' },
147+
{ text: '无锡市', value: 'WuXi' },
148+
{ text: '海北藏族自治区', value: 'ZangZu' },
149+
{ text: '北京市', value: 'BeiJing' },
150+
{ text: '连云港市', value: 'LianYunGang' },
151+
{ text: '浙江市', value: 'ZheJiang' },
152+
{ text: '江苏市', value: 'JiangSu' }
153+
]);
154+
155+
const confirm = ( { selectedValue,selectedOptions })=>{
156+
desc.value = selectedValue.join(',');
157+
}
158+
159+
return {show,desc,columns,selectedValue, confirm};
160+
}
161+
};
162+
</script>
163+
```
164+
:::
165+
122166
### 多列展示
123167

124168
columns 属性可以通过二维数组的形式配置多列选择。

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,11 +178,16 @@ export default create({
178178
defaultValues.value[columnIndex] = option.value ? option.value : '';
179179
let index = columnIndex;
180180
let cursor = option;
181-
while (cursor && cursor.children) {
181+
while (cursor && cursor.children && cursor.children[0]) {
182182
defaultValues.value[index + 1] = cursor.children[0].value;
183183
index++;
184184
cursor = cursor.children[0];
185185
}
186+
187+
// 当前改变列 的 下一列 children 值为空
188+
if (cursor && cursor.children && cursor.children.length == 0) {
189+
defaultValues.value = defaultValues.value.slice(0, index + 1);
190+
}
186191
} else {
187192
defaultValues.value[columnIndex] = option.hasOwnProperty('value') ? option.value : '';
188193
}

src/packages/__VUE/picker/index.vue

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,11 +186,16 @@ export default create({
186186
defaultValues.value[columnIndex] = option.value ? option.value : '';
187187
let index = columnIndex;
188188
let cursor = option;
189-
while (cursor && cursor.children) {
189+
while (cursor && cursor.children && cursor.children[0]) {
190190
defaultValues.value[index + 1] = cursor.children[0].value;
191191
index++;
192192
cursor = cursor.children[0];
193193
}
194+
195+
// 当前改变列 的 下一列 children 值为空
196+
if (cursor && cursor.children && cursor.children.length == 0) {
197+
defaultValues.value = defaultValues.value.slice(0, index + 1);
198+
}
194199
} else {
195200
defaultValues.value[columnIndex] = option.hasOwnProperty('value') ? option.value : '';
196201
}

src/packages/styles/variables-jdb.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ $picker-bar-title-font-weight: normal !default;
234234
$picker-item-height: 36px !default;
235235
$picker-item-text-color: $title-color !default;
236236
$picker-item-active-text-color: inherit !default;
237-
$picker-item-text-font-size: 16px !default;
237+
$picker-item-text-font-size: 14px !default;
238238
$picker-item-active-line-border: 1px solid #d8d8d8 !default;
239239
$picker-columns-item-color: $title-color !default;
240240

src/packages/styles/variables-jdt.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ $picker-bar-title-font-weight: 600 !default;
152152
$picker-item-height: 36px !default;
153153
$picker-item-text-color: $title-color !default;
154154
$picker-item-active-text-color: $primary-color !default;
155-
$picker-item-text-font-size: 16px !default;
155+
$picker-item-text-font-size: 14px !default;
156156
$picker-item-active-line-border: 1px solid rgba(0, 0, 0, 0.06) !default;
157157
$picker-columns-item-color: $title-color !default;
158158

src/packages/styles/variables.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ $picker-bar-title-font-weight: normal !default;
165165
$picker-item-height: 36px !default;
166166
$picker-item-text-color: $title-color !default;
167167
$picker-item-active-text-color: inherit !default;
168-
$picker-item-text-font-size: 16px !default;
168+
$picker-item-text-font-size: 14px !default;
169169
$picker-item-active-line-border: 1px solid #d8d8d8 !default;
170170
$picker-columns-item-color: $title-color !default;
171171

0 commit comments

Comments
 (0)