Commit 3e1a9d8f by 王志慧

van-picker显示修改

1 parent 52cec0e5
...@@ -2,7 +2,9 @@ ...@@ -2,7 +2,9 @@
<div> <div>
<div class="top flex"> <div class="top flex">
<div class="report-name text-hide"> <div class="report-name text-hide">
{{ userInfo.merchantName || 'XXXX商户名称-10月小结' }}-<span>{{text}}</span>小结 {{ userInfo.merchantName || 'XXXX商户名称-10月小结' }}-
<span>{{ text }}</span>
小结
</div> </div>
<template v-if="outputData.reportTimeStart && reportType == 0"> <template v-if="outputData.reportTimeStart && reportType == 0">
<div class="time small-text" @click="showDateSelect = true"> <div class="time small-text" @click="showDateSelect = true">
...@@ -17,8 +19,8 @@ ...@@ -17,8 +19,8 @@
</div> </div>
</template> </template>
</div> </div>
<van-popup v-model="showDateSelect" position="bottom"> <van-popup v-model="showDateSelect" v-if="showDateSelect" position="bottom">
<van-picker show-toolbar :title="reportType == 0 ? '选择日期' : '选择月份'" :columns="dateColumns" :default-index="dateColumns.length" @confirm="confirmDate" @cancel="showDateSelect = false" /> <van-picker show-toolbar :title="reportType == 0 ? '选择日期' : '选择月份'" :columns="dateColumns" :default-index="defaultIndex" @confirm="confirmDate" @cancel="showDateSelect = false" />
</van-popup> </van-popup>
</div> </div>
</template> </template>
...@@ -30,7 +32,8 @@ export default { ...@@ -30,7 +32,8 @@ export default {
return { return {
showDateSelect: false, showDateSelect: false,
dateColumns: [], dateColumns: [],
text:'' text: '',
defaultIndex: 0
} }
}, },
computed: { computed: {
...@@ -71,6 +74,7 @@ export default { ...@@ -71,6 +74,7 @@ export default {
} }
this.dateColumns = dateColumns this.dateColumns = dateColumns
let time = this.dateColumns[this.dateColumns.length - 1].split('~') let time = this.dateColumns[this.dateColumns.length - 1].split('~')
this.SET_START_TIME({ this.SET_START_TIME({
reportTimeStart: time[0], reportTimeStart: time[0],
...@@ -85,11 +89,11 @@ export default { ...@@ -85,11 +89,11 @@ export default {
this.SET_START_TIME({ this.SET_START_TIME({
reportTimeStart: this.dateColumns[this.dateColumns.length - 1] + '-01' reportTimeStart: this.dateColumns[this.dateColumns.length - 1] + '-01'
}) })
} }
this.initTextData() this.defaultIndex = this.dateColumns.length //初始选中项的索引
this.initTextData()
}, },
initTextData() { initTextData() {
let { reportType, outputData } = this let { reportType, outputData } = this
if (reportType == 0) { if (reportType == 0) {
this.text = '周' this.text = '周'
...@@ -98,10 +102,9 @@ export default { ...@@ -98,10 +102,9 @@ export default {
if (parseInt(time[1]) > 9) { if (parseInt(time[1]) > 9) {
this.text = time[1] + '月' this.text = time[1] + '月'
} else { } else {
this.text = time[1]&&time[1].split('')[1] + '月' this.text = time[1] && time[1].split('')[1] + '月'
} }
} }
}, },
confirmDate(e) { confirmDate(e) {
let { let {
...@@ -158,6 +161,7 @@ export default { ...@@ -158,6 +161,7 @@ export default {
} }
}) })
} }
this.defaultIndex = this.dateColumns.indexOf(e)
this.initTextData() this.initTextData()
this.SET_TABTYPE_INDEX({ index: 0 }) this.SET_TABTYPE_INDEX({ index: 0 })
this.showDateSelect = false this.showDateSelect = false
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!