Commit 87e7ebf8 by 陈超

T

parent 60e7ecad
...@@ -171,6 +171,15 @@ ...@@ -171,6 +171,15 @@
} }
}, },
methods: { methods: {
//Helper
indexOf: function(array, call) {
for(let i = 0; i < array.length; i++) {
if(call(array[i])) {
return i
}
}
return -1
},
//当选择省变化 //当选择省变化
onProvinceChange: function(picker, p) { onProvinceChange: function(picker, p) {
console.log("当选择省变化") console.log("当选择省变化")
...@@ -178,11 +187,8 @@ ...@@ -178,11 +187,8 @@
let that = this let that = this
if(p.children.length == 0) { if(p.children.length == 0) {
that.getCity(p.id, r => { that.getCity(p.id, r => {
p.children = r.map(r => { return { text: r.title, id: r.area_id, children: [] } }) let idx = that.indexOf(that.columns, i => { return i.text == p.text })
if(!that.loading) { that.$set(that.columns[idx], 'children', r.map(r => { return { text: r.title, id: r.area_id, children: [] } }))
that.loading = true
that.columns = [].concat(that.columns)
}
let c = p.children[0] let c = p.children[0]
that.selected[1] = c.text that.selected[1] = c.text
that.onCityChange(picker, c) that.onCityChange(picker, c)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment