You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

155 lines
3.4 KiB

This file contains invisible Unicode characters!

This file contains invisible Unicode characters that may be processed differently from what appears below. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to reveal hidden characters.

const { saveOneOwner,choseBoxGroupData } = require("../../../api/api");
Page({
data: {
mshow: false,
radio:'',
dataLists:[],//列表
},
onLoad(options) {
this.setData({
entryId:options.projectId
});
this.getList();
},
onShow() {
},
//只能输入整数
onInput(e) {
let value = e.detail.value;
value = value.replace(/[^\d]/g,'');
this.setData({
countNum: value
});
},
/** 搜索输入事件 **/
keyWordsChange(e) {
this.setData({
name: e.detail,
});
},
/** 搜索 **/
keyWordsSearch(e){
this.getList();
},
/** 列表 **/
getList(){
choseBoxGroupData({
entryId: this.data.entryId,
// name:this.data.name
}).then(res=>{
if(res.data){
this.setData({
dataLists:res.data.map(itm=>itm.columns)
});
}else{
wx.showToast({
title: res.msg,
icon:'none'
})
}
});
},
/** 单选 **/
onChange(event) {
this.setData({
radio: event.detail,
});
},
/** 单选点击 **/
onClick(e) {
this.setData({
radio: e.currentTarget.dataset.id,
totalCount: e.currentTarget.dataset.count,
number:e.currentTarget.dataset.number,
name:e.currentTarget.dataset.name,
});
},
/** 返回 **/
back(e) {
wx.navigateBack();
},
/** 提交 **/
submit(){
if(!this.data.radio){
wx.showToast({
title: '请先选择一条数据',
icon:'none'
})
return;
}
saveOneOwner({
userId:wx.getStorageSync('userId'),
entryId:this.data.entryId,
boxGroupId:this.data.radio,
totalCount: this.data.totalCount
}).then(res=>{
if(res.code==200){
wx.showToast({
title: '操作成功',
icon:'none'
})
var pages = getCurrentPages(); // 获取页面栈
var prevPage = pages[pages.length - 2]; // 上一个页面
prevPage.setData({   
boxTotalCount: this.data.totalCount, // 要设置的值
boxGroupNum: this.data.number, // 要设置的值
boxGroupName: this.data.name, // 要设置的值
boxGroupId: this.data.radio, // 要设置的值
})
setTimeout(()=>{
wx.navigateBack();
},1000);
}else{
wx.showToast({
title: res.errMsg,
icon:'none'
})
}
});
},
creatFun(){
this.setData({
mshow: true,
})
},
//取消
onClose() {
this.setData({
mshow: false,
countNum: ''
})
},
//新建提交
onConfirm(){
saveOneOwner({
userId:wx.getStorageSync('userId'),
entryId:this.data.entryId,
totalCount: this.data.countNum
}).then(res=>{
if(res.code==200){
wx.showToast({
title: '操作成功',
icon:'none'
})
var pages = getCurrentPages(); // 获取页面栈
var prevPage = pages[pages.length - 2]; // 上一个页面
prevPage.setData({   
boxTotalCount: this.data.countNum, // 要设置的值
boxGroupNum: '', // 要设置的值
boxGroupName: '', // 要设置的值
boxGroupId: '', // 要设置的值
})
setTimeout(()=>{
wx.navigateBack();
},1000);
}else{
wx.showToast({
title: res.errMsg,
icon:'none'
})
}
});
}
})