Commit bfaadc58 by 夏新然

日期插件bug

1 parent 8a39b869
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
...@@ -8,8 +8,7 @@ ...@@ -8,8 +8,7 @@
<div class="picker-title"> <div class="picker-title">
<span class="pt-cancel" @click="cancel" :style="{ color: colorCancel }">{{textCancel}}</span> <span class="pt-cancel" @click="cancel" :style="{ color: colorCancel }">{{textCancel}}</span>
<span class="pt-submit" @click="confirm" :style="{ color: colorConfirm }">{{textConfirm}}</span> <span class="pt-submit" @click="confirm" :style="{ color: colorConfirm }">{{textConfirm}}</span>
<!-- <h4 :style="{ color: colorTitle }">{{textTitle}}</h4> --> <h4 :style="{ color: colorTitle }">{{textTitle}}</h4>
<slot></slot>
</div> </div>
<div class="picker-panel"> <div class="picker-panel">
<div class="picker-mask-top"></div> <div class="picker-mask-top"></div>
...@@ -114,6 +113,7 @@ export default { ...@@ -114,6 +113,7 @@ export default {
}, },
computed: { computed: {
proxyData () { proxyData () {
return this._dataGetter() return this._dataGetter()
}, },
proxyAnchor () { proxyAnchor () {
...@@ -139,6 +139,9 @@ export default { ...@@ -139,6 +139,9 @@ export default {
}, },
_anchorGetter () { _anchorGetter () {
// if(!this.pickerData){
// this.pickerData=this._dataGetter()
// }
let anchor = [] let anchor = []
if (this.anchor.length) { if (this.anchor.length) {
anchor = this.anchor anchor = this.anchor
...@@ -150,7 +153,6 @@ export default { ...@@ -150,7 +153,6 @@ export default {
anchor = this.anchor; break anchor = this.anchor; break
} }
} }
anchor = anchor.map((item, i) => { anchor = anchor.map((item, i) => {
let index = 0 let index = 0
if (item.index) { if (item.index) {
...@@ -170,6 +172,8 @@ export default { ...@@ -170,6 +172,8 @@ export default {
this.display = true this.display = true
if (!this.wheels.length || this.dataChange) { if (!this.wheels.length || this.dataChange) {
this.dataType === DATA_CASCADE && this._updatePickerData() this.dataType === DATA_CASCADE && this._updatePickerData()
this.$nextTick(() => { this.$nextTick(() => {
const wheelWrapper = this.$refs.wheelWrapper const wheelWrapper = this.$refs.wheelWrapper
this.pickerData.forEach((item, index) => { this.pickerData.forEach((item, index) => {
...@@ -177,6 +181,8 @@ export default { ...@@ -177,6 +181,8 @@ export default {
}) })
this._wheelToAnchor(this.proxyAnchor) this._wheelToAnchor(this.proxyAnchor)
// this.$forceUpdate()
this.dataChange && this._destroyExtraWheels() this.dataChange && this._destroyExtraWheels()
this.dataChange = false this.dataChange = false
}) })
...@@ -216,11 +222,10 @@ export default { ...@@ -216,11 +222,10 @@ export default {
if (this.dataType !== DATA_CASCADE) { if (this.dataType !== DATA_CASCADE) {
return return
} }
this._updatePickerData(0)
const newIndex = this._getCurrentValue()[i].index const newIndex = this._getCurrentValue()[i].index
if (newIndex !== this.pickerAnchor[i]) { if (newIndex !== this.pickerAnchor[i]) {
this.pickerAnchor.splice(i, 1, newIndex) this.pickerAnchor.splice(i, 1, newIndex)
this._updatePickerData(i + 1) this._updatePickerData(i + 1,true)
} }
}, },
...@@ -234,14 +239,11 @@ export default { ...@@ -234,14 +239,11 @@ export default {
const value = [] const value = []
this.wheels.forEach((wheel, i) => { this.wheels.forEach((wheel, i) => {
const j = wheel.getSelectedIndex() const j = wheel.getSelectedIndex()
console.log(j)
console.log( this.pickerData)
value.push({ value.push({
index: j, index: j,
value: this.pickerData[i][j] value: this.pickerData[i][j]
}) })
}) })
console.log(value)
return value return value
}, },
...@@ -254,6 +256,7 @@ export default { ...@@ -254,6 +256,7 @@ export default {
this.pickerData.forEach((item, i) => { this.pickerData.forEach((item, i) => {
this._createWheel(wheelWrapper, i) this._createWheel(wheelWrapper, i)
}) })
this._wheelToAnchor(this.proxyAnchor) this._wheelToAnchor(this.proxyAnchor)
this._destroyExtraWheels() this._destroyExtraWheels()
}) })
...@@ -272,7 +275,11 @@ export default { ...@@ -272,7 +275,11 @@ export default {
} }
}, },
_updatePickerData (wheelIndex = 0) { _updatePickerData (wheelIndex = 0,flag) {
if(!flag){
this.pickerAnchor = this._anchorGetter()
}
let data = [...this.proxyData] let data = [...this.proxyData]
let i = 0 let i = 0
while (data) { while (data) {
...@@ -281,11 +288,12 @@ export default { ...@@ -281,11 +288,12 @@ export default {
data.forEach((item) => { data.forEach((item) => {
wheelData.push(item.value) wheelData.push(item.value)
}) })
this.pickerData[i] = wheelData this.pickerData.splice(i, 1, wheelData)
this.pickerAnchor[i] = wheelIndex === 0 this.pickerAnchor[i] = wheelIndex === 0
? (this.pickerAnchor[i] < data.length ? this.pickerAnchor[i] || 0 : 0) ? (this.pickerAnchor[i] < data.length ? this.pickerAnchor[i] || 0 : 0)
: this._reloadWheel(i, wheelData) : this._reloadWheel(i, wheelData)
} }
data = data.length ? data[this.pickerAnchor[i]].children : null data = data.length ? data[this.pickerAnchor[i]].children : null
i++ i++
} }
......
...@@ -144,7 +144,7 @@ ...@@ -144,7 +144,7 @@
<span v-show="showList['date']['year']" :class="{'activeDateType':currentDateType=='year'}" @tap="dateClick('year')">年</span> <span v-show="showList['date']['year']" :class="{'activeDateType':currentDateType=='year'}" @tap="dateClick('year')">年</span>
</div> </div>
</awesome-picker> </awesome-picker>
<awesome-picker <!-- <awesome-picker
ref="picker2" ref="picker2"
:data="dateData" :data="dateData"
:textConfirm="picker.textConfirm" :textConfirm="picker.textConfirm"
...@@ -156,7 +156,7 @@ ...@@ -156,7 +156,7 @@
<div class="typeBox"> <div class="typeBox">
<span v-show="showList['date']['week2']" class="activeDateType" @tap="dateClick('week')"></span> <span v-show="showList['date']['week2']" class="activeDateType" @tap="dateClick('week')"></span>
</div> </div>
</awesome-picker> </awesome-picker> -->
</div> </div>
</template> </template>
...@@ -627,6 +627,11 @@ ...@@ -627,6 +627,11 @@
}) })
} }
}, },
watch:{
currentDate(val){
console.log(val)
}
},
computed: { computed: {
i18n() { i18n() {
return this.$t("index") return this.$t("index")
...@@ -891,7 +896,7 @@ ...@@ -891,7 +896,7 @@
}) })
this.dateData=JSON.parse(JSON.stringify(this.dayData)) this.dateData=JSON.parse(JSON.stringify(this.dayData))
this.currentDate=this.currentDay; this.currentDate=this.currentDay;
console.log(this.currentDate)
const date = new Date(); const date = new Date();
var year = date.getFullYear(); var year = date.getFullYear();
var monthIndex = date.getMonth(); var monthIndex = date.getMonth();
......
...@@ -251,51 +251,51 @@ ...@@ -251,51 +251,51 @@
} }
} }
}, },
// { {
// text:"周中周末对比分析", text:"周中周末对比分析",
// iconSrc:week, iconSrc:week,
// rArrow:arrow, rArrow:arrow,
// src:'weekReport/weekReport', src:'weekReport/weekReport',
// showList:{ showList:{
// gateTab:true, gateTab:true,
// mall:{ mall:{
// obj:false, obj:false,
// oneMall:true, oneMall:true,
// moreMall:false, moreMall:false,
// event:false event:false
// }, },
// gate:{ gate:{
// obj:false, obj:false,
// oneMall:true, oneMall:true,
// moreMall:false, moreMall:false,
// oneGate:true, oneGate:true,
// moreGate:false moreGate:false
// }, },
// floor:{ floor:{
// obj:false, obj:false,
// oneMall:true, oneMall:true,
// moreMall:false, moreMall:false,
// oneFloor:true, oneFloor:true,
// moreFloor:false moreFloor:false
// }, },
// area:{ area:{
// obj:false, obj:false,
// oneMall:true, oneMall:true,
// moreMall:false, moreMall:false,
// oneFloor:true, oneFloor:true,
// moreFloor:false, moreFloor:false,
// oneStore:true, oneStore:true,
// moreStore:false moreStore:false
// }, },
// date:{ date:{
// day:false, day:false,
// week:true, week:true,
// month:false, month:false,
// year:false, year:false,
// week2:true week2:true
// } }
// } }
// }, },
{ {
text:"节假日活动对比", text:"节假日活动对比",
iconSrc:active, iconSrc:active,
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!