Commit 10524e1e by 胡悦

修复年份默认值

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