Skip to content

Commit

Permalink
Merge pull request #425 from ielgnaw/patch
Browse files Browse the repository at this point in the history
feat: bump to 2.5.8-beta.3
  • Loading branch information
ielgnaw committed Jul 31, 2023
2 parents eff3ef3 + a89080b commit 7a34203
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 12 deletions.
7 changes: 7 additions & 0 deletions example/components/changelog/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@

<div class="changelog-wrapper">

### 2.5.8-beta.3 {page=#/changelog}

* **[update]**:
- [DatePicker 日期选择器](#/date-picker) 年/月/日选择器 `cell-class` 配置回调函数参数增加 `pickerType` 属性,标识当前是什么类型的 picker

---

### 2.5.8-beta.2 {page=#/changelog}

* **[add]**:
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bk-magic-vue",
"version": "2.5.8-beta.2",
"version": "2.5.8-beta.3",
"description": "基于蓝鲸 Magicbox 和 Vue 的前端组件库",
"main": "dist/bk-magic-vue.min.js",
"files": [
Expand Down
11 changes: 11 additions & 0 deletions src/components/date-picker/panel/date-range.vue
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
</span>
</div>
<!-- eslint-disable-next-line vue/require-component-is -->
<!-- {{ leftPickerTable }}--{{ leftRealPickerType }} -->
<component
:is="leftPickerTable"
v-if="currentView !== 'time'"
Expand All @@ -55,6 +56,7 @@
:value="preSelecting.left ? [dates[0]] : dates"
:focused-date="focusedDate"
:cell-class="cellClass"
:real-picker-type="leftRealPickerType"
@change-range="handleChangeRange"
@pick="panelPickerHandlers.left"
@pick-click="handlePickClick"
Expand Down Expand Up @@ -98,6 +100,7 @@
:value="preSelecting.right ? [dates[dates.length - 1]] : dates"
:focused-date="focusedDate"
:cell-class="cellClass"
:real-picker-type="rightRealPickerType"
@change-range="handleChangeRange"
@pick="panelPickerHandlers.right"
@pick-click="handlePickClick">
Expand Down Expand Up @@ -196,7 +199,9 @@ export default {
rangeState: { from: this.value[0], to: this.value[1], selecting: minDate && !maxDate },
currentView: this.selectionMode || 'range',
leftPickerTable: `${this.selectionMode}-table`,
leftRealPickerType: this.selectionMode,
rightPickerTable: `${this.selectionMode}-table`,
rightRealPickerType: this.selectionMode,
leftPanelDate: leftPanelDate,
rightPanelDate: new Date(leftPanelDate.getFullYear(), leftPanelDate.getMonth() + 1, 1),
// 判断 range 中,第一次选的时间是否晚于当前时间
Expand Down Expand Up @@ -274,6 +279,12 @@ export default {
},
focusedDate (date) {
this.setPanelDates(date || new Date())
},
leftPickerTable (val) {
this.leftRealPickerType = val.replace('-table', '')
},
rightPickerTable (val) {
this.rightRealPickerType = val.replace('-table', '')
}
},
methods: {
Expand Down
18 changes: 7 additions & 11 deletions src/components/date-picker/panel/date.vue
Original file line number Diff line number Diff line change
Expand Up @@ -164,13 +164,14 @@ export default {
data () {
const { selectionMode, value } = this
const dates = value.slice().sort()
const pickerTable = this.getTableType(selectionMode)
return {
currentView: selectionMode || 'date',
pickerTable: this.getTableType(selectionMode),
pickerTable,
realPickerType: pickerTable.replace('-table', ''),
dates: dates,
panelDate: this.startDate || dates[0] || new Date(),
realPickerType: this.getRealPickerType(selectionMode)
panelDate: this.startDate || dates[0] || new Date()
}
},
computed: {
Expand All @@ -186,7 +187,6 @@ export default {
const handler = (type) => {
return () => {
this.pickerTable = this.getTableType(type)
this.realPickerType = this.getRealPickerType(type)
}
}
Expand Down Expand Up @@ -221,7 +221,6 @@ export default {
selectionMode (type) {
this.currentView = type
this.pickerTable = this.getTableType(type)
this.realPickerType = this.getRealPickerType(type)
},
focusedDate (date) {
const isDifferentYear = date.getFullYear() !== this.panelDate.getFullYear()
Expand All @@ -231,13 +230,15 @@ export default {
this.panelDate = date
}
}
},
pickerTable (val) {
this.realPickerType = val.replace('-table', '')
}
},
methods: {
reset () {
this.currentView = this.selectionMode
this.pickerTable = this.getTableType(this.currentView)
this.realPickerType = this.getRealPickerType(this.currentView)
},
changeYear (dir) {
if (this.selectionMode === 'year' || this.pickerTable === 'year-table') {
Expand All @@ -249,20 +250,15 @@ export default {
getTableType (currentView) {
return currentView.match(/^time/) ? 'time-picker' : `${currentView}-table`
},
getRealPickerType (currentView) {
return currentView.match(/^time/) ? 'time-picker' : `${currentView}`
},
changeMonth (dir) {
this.panelDate = siblingMonth(this.panelDate, dir)
},
handlePreSelection (value) {
this.panelDate = value
if (this.pickerTable === 'year-table') {
this.pickerTable = 'month-table'
this.realPickerType = 'month'
} else {
this.pickerTable = this.getTableType(this.currentView)
this.realPickerType = this.getRealPickerType(this.currentView)
}
},
handlePick (value, type) {
Expand Down

0 comments on commit 7a34203

Please sign in to comment.