Commit 10524e1e by 胡悦

修复年份默认值

1 parent 03c41311
......@@ -3,7 +3,7 @@
* @Author: huyue
* @Date: 2023-07-05 15:11:53
* @LastEditors: huyue
* @LastEditTime: 2023-07-17 18:18:37
* @LastEditTime: 2023-08-14 11:10:30
-->
<template>
<div v-click-outside="handleClickOutside" @mouseleave="handleMouseLeave" v-show="isShow" class="select-box" :style="{'width': boxWidth}">
......@@ -46,7 +46,7 @@ export default {
type: String
},
defaultValue: {
type: [String, Number]
type: [String, Number, Object]
}
},
directives: {
......@@ -73,9 +73,9 @@ export default {
}
},
mounted() {
console.log(this.defaultValue,this.dataList, '00000000');
const { valueName, isObject, dataList, defaultValue } = this
this.value = defaultValue || (isObject ? dataList[0][valueName] : dataList[0])
console.log(this.defaultValue, this.dataList, '00000000')
const { labelName, isObject, dataList, defaultValue } = this
this.value = defaultValue || (isObject ? dataList[0][labelName] : dataList[0])
},
methods: {
select(item) {
......
......@@ -18,7 +18,6 @@
:dataList.sync="dataList"
:boxWidth="'8.61vw'"
@selectVal="selectVal"
:labelName="'statMonth'"
:valueName="'statMonth'"
></SelectBox>
</div>
......@@ -39,7 +38,9 @@ export default {
return {
tabActive: 0,
isShow: false,
defaultMonth: '',
defaultMonth: {
label: new Date().format('yyyy年MM月')
},
dataList: [],
month: ''
}
......@@ -53,9 +54,15 @@ export default {
methods: {
async getMonth() {
const _result = await this.api.crowdFunding.getMonth()
this.dataList = _result.data.dataList
this.defaultMonth = this.month = this.dataList[0].statMonth
this.$bus.$emit('crowdFundingMonth', this.defaultMonth)
const _dataList = _result.data.dataList
_dataList.forEach(item => {
this.dataList.push({
label: new Date(item.statMonth).format('yyyy年MM月'),
statMonth: item.statMonth
})
})
this.defaultMonth = this.month = this.dataList[0].label
// this.$bus.$emit('crowdFundingMonth', this.defaultMonth)
},
// tab切换
changeTab(index) {
......@@ -66,8 +73,8 @@ export default {
this.isShow = !this.isShow
},
selectVal(val) {
this.defaultMonth = this.month = val.statMonth
this.$bus.$emit('crowdFundingMonth', this.defaultMonth)
this.defaultMonth = this.month = val.label
this.$bus.$emit('crowdFundingMonth', val.statMonth)
this.switchMonth()
},
clickOutside() {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!