//打开货物类型
columnsGoodsShow(){//console.log(this.suoyin1)
this.columnsgoods_show = true;//如果没有选中过就不走里面
if(this.suoyin1.length != 0){//通过索引拿到数据表中选中的二级类全部数据
let obj1 = this.columnsgoods[0].values[this.suoyin1[0]]//将当前选中的一级类数据和二级类数据赋值给数据表
this.columnsgoods= [{values: this.columnsgoods[0].values},{values: obj1.children}]this.$nextTick(function(){//通过索引在数据表中找到选中的那一项
this.$refs.ppkk.setIndexes(this.suoyin1)
})
}
},//改变货物类型
onChangegoods(picker, values,index) {//values会得到当前选中的一级和二级,因为一级下带有所有的二级,所以在children中找
picker.setColumnValues(1, values[0].children.filter(item =>item.text));
},//货物类型确认按钮
onConfirmgoods(value, index) {//console.log(value, index)
this.goodstypeval = value[0].text + '-' + value[1].text;this.CategoryParentID = value[0].id;//一级id
this.CategoryID = value[1].id;//二级id
this.columnsgoods_show = false;//将当前选中的索引存起来
this.suoyin1 =index;
},//选择货物类型取消按钮,这里如果没有别的操作可以把他写到行内v-on:cancel="columnsgoods_show = false"
onCancelgoods() {this.columnsgoods_show = false;
},//货物类型
async goodsCategory(){
let self= this;
await getCategoryList(1).then(msg =>{//console.log(msg.row_data.record,'1')
if (msg.status.code == 1) {this.goodstypelistsource = msg.row_data.record;//数据源
let ary = [{id:0,text:'不限',children:[{id:0,text:'不限'}]}];//初始化就有第一项不限
let source =msg.row_data.record;//console.log(source)
source.forEach(item =>{if(item.ParentID==0){
let obj={};
obj.id=item.CategoryID;
obj.text=item.CategoryName;
ary.push(obj);
}
});//第一项不限不循环
for(let i=1;i
let cur=ary[i];
ary[i].children= [{id:0,text:'不限'}];
source.forEach(item=>{if(item.ParentID ==cur.id){
let obj={};
obj.id=item.CategoryID;
obj.text=item.CategoryName;
ary[i].children.push(obj);
}
})
}this.goodstypelist =ary;
console.log(this.goodstypelist)this.columnsgoods= [{values:this.goodstypelist.filter(item => item.text)},{values:this.goodstypelist[0].children.filter(item => item.text)}];//货物类型数据和初始化
//console.log(this.columnsgoods)
}else{
self.$toast(msg.status.msg)return;
};
}).catch(msg =>{
console.log(msg)//self.$toast(msg)
})
},