[update 日期多选] 处理多选日期不显示删除按钮
This commit is contained in:
@@ -8,6 +8,7 @@
|
|||||||
@openChange="handleOpenChange"
|
@openChange="handleOpenChange"
|
||||||
@change="handleChange"
|
@change="handleChange"
|
||||||
style="width: 100%"
|
style="width: 100%"
|
||||||
|
:value="firstValue"
|
||||||
v-bind="$attrs"
|
v-bind="$attrs"
|
||||||
>
|
>
|
||||||
<template slot="dateRender" slot-scope="current">
|
<template slot="dateRender" slot-scope="current">
|
||||||
@@ -50,7 +51,8 @@ export default {
|
|||||||
data () {
|
data () {
|
||||||
return {
|
return {
|
||||||
open: false,
|
open: false,
|
||||||
checkedValue: []
|
checkedValue: [],
|
||||||
|
firstValue: null // 多选中第一个日期,用于触发显示删除按钮
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
@@ -103,6 +105,7 @@ export default {
|
|||||||
handleChange (val) {
|
handleChange (val) {
|
||||||
console.log('-handleChange-----', val)
|
console.log('-handleChange-----', val)
|
||||||
if (!val) {
|
if (!val) {
|
||||||
|
this.firstValue = null
|
||||||
this.checkedValue = []
|
this.checkedValue = []
|
||||||
this.$emit('change', this.checkedValue.join(','))
|
this.$emit('change', this.checkedValue.join(','))
|
||||||
}
|
}
|
||||||
@@ -113,6 +116,10 @@ export default {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
// 日期面板中input绑定事件
|
||||||
|
focusInput (e) {
|
||||||
|
e.target.value = this.checkedValue.join(',')
|
||||||
|
},
|
||||||
// 点击日期,加日期或者减日期
|
// 点击日期,加日期或者减日期
|
||||||
clickCalendarDate (current) {
|
clickCalendarDate (current) {
|
||||||
const currentStr = current.format('YYYY-MM-DD')
|
const currentStr = current.format('YYYY-MM-DD')
|
||||||
@@ -128,8 +135,13 @@ export default {
|
|||||||
console.log('减日期')
|
console.log('减日期')
|
||||||
this.checkedValue = this.checkedValue.filter(item => item !== currentStr)
|
this.checkedValue = this.checkedValue.filter(item => item !== currentStr)
|
||||||
}
|
}
|
||||||
|
this.firstValue = this.checkedValue[0]
|
||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
document.getElementsByClassName(this.fieldName + '-drop')[0].children[0].children[0].children[0].children[0].children[0].value = this.checkedValue.join(',')
|
setTimeout(() => {
|
||||||
|
const inputDom = document.getElementsByClassName(this.fieldName + '-drop')[0].children[0].children[0].children[0].children[0].children[0]
|
||||||
|
inputDom.value = this.checkedValue.join(',')
|
||||||
|
inputDom.addEventListener('focus', this.focusInput)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
this.$emit('change', this.checkedValue.join(','))
|
this.$emit('change', this.checkedValue.join(','))
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user