Page({
|
data: {
|
arrayList:[],
|
checkResults: [] as any,
|
doccode:'',
|
hadRelationList:[]
|
},
|
onLoad(options) {
|
let doccode = options.doccode || '';
|
this.setData({
|
doccode
|
})
|
this.getPromotionsRelationList();
|
this.getHadRelationList();
|
},
|
onChange(event:any) {
|
console.log(event.detail);
|
this.setData({
|
checkResults: event.detail
|
});
|
},
|
toggleCheckbox2(){},
|
toggleCheckbox(event:any){
|
// console.log('event....',event);
|
const { index } = event.currentTarget.dataset;
|
const checkbox = this.selectComponent(`.checkboxes-${index}`);
|
checkbox.toggle();
|
},
|
async getPromotionsRelationList(){
|
let doccode = this.data.doccode;
|
let [error, result] = await wx.$utils.to(
|
wx.$http.request({
|
url:`/shopping/panicBuying.do?m=getMayableRelationList`,
|
data:{
|
doccode
|
}
|
})
|
)
|
if (error){
|
console.log(error);
|
return;
|
}
|
console.log(result);
|
this.setData({
|
relationList: result.mayableRelationList
|
})
|
},
|
async getHadRelationList(){
|
let doccode = this.data.doccode;
|
let [error, result] = await wx.$utils.to(
|
wx.$http.request({
|
url:`/shopping/panicBuying.do?m=getHadRelationList`,
|
data:{
|
doccode
|
}
|
})
|
)
|
if (error){
|
console.log(error);
|
return;
|
}
|
console.log(result);
|
this.handleRelationList(result.hadRelationList);
|
},
|
handleRelationList(list:any[]){
|
let checkResults: any[] = [];
|
list.forEach((item:any)=>{
|
if (item.doccode){
|
checkResults.push(item.doccode)
|
}
|
})
|
this.setData({
|
checkResults
|
})
|
},
|
async saveRelationList(){
|
let docCode = this.data.doccode;
|
let panicBuyingDocCodes = this.data.checkResults;
|
let [error, result] = await wx.$utils.to(
|
wx.$http.request({
|
url:`/shopping/panicBuying.do?m=saveRelationList`,
|
data:{
|
docCode,
|
panicBuyingDocCodes
|
},
|
method:'POST'
|
})
|
)
|
if (error){
|
console.log(error);
|
return;
|
}
|
console.log(result);
|
wx.showToast({title: '保存成功'})
|
setTimeout(()=>{
|
wx.navigateBack()
|
},1000)
|
},
|
onSubmitSave(){
|
console.log(this.data.checkResults);
|
// this.saveRelationList();
|
}
|
})
|
export {}
|