预算配置
This commit is contained in:
@@ -1,33 +1,50 @@
|
||||
const app = getApp()
|
||||
Page({
|
||||
data: {
|
||||
sumBudget: "0.00",
|
||||
sumUsed: "0.00",
|
||||
sumBalance: "0.00",
|
||||
|
||||
showSetBudget : false,
|
||||
mainMoney: "200.00",
|
||||
changeType: "main",
|
||||
changeItem: 0,
|
||||
currentId: -1,
|
||||
currentMoney: "0.00",
|
||||
priceError: false,
|
||||
payTypeList : [
|
||||
{"id":1,"name":"娱乐","money":"2000.00"},
|
||||
{"id":2,"name":"干饭","money":""},
|
||||
{"id":3,"name":"游戏","money":"2000.00"},
|
||||
{"id":4,"name":"其它","money":"400"}
|
||||
],
|
||||
payTypeList : [],
|
||||
},
|
||||
onLoad: function (options) {
|
||||
|
||||
},
|
||||
onShow() {
|
||||
this.updateBudget();
|
||||
},
|
||||
updateBudget(){
|
||||
app.$api.getBudget().then(res => {
|
||||
if (res.data){
|
||||
let sumBudget = res.data.sumBudget
|
||||
let sumUsed = res.data.sumUsed
|
||||
let sumBalance = res.data.sumBalance
|
||||
let payTypeList = res.data.payTypeList
|
||||
this.setData({sumBudget,sumUsed,sumBalance,payTypeList})
|
||||
}
|
||||
})
|
||||
},
|
||||
changeBudget(e) {
|
||||
let {type,id} = e.currentTarget.dataset
|
||||
let tCurrentMoney = 0.00;
|
||||
if (type == 'count'){
|
||||
tCurrentMoney = this.data.mainMoney
|
||||
tCurrentMoney = this.data.sumBudget
|
||||
}else {
|
||||
tCurrentMoney = this.data.payTypeList[id - 1].money;
|
||||
this.data.payTypeList.forEach(item => {
|
||||
if (item.id == id){
|
||||
tCurrentMoney = item.budget
|
||||
}
|
||||
})
|
||||
}
|
||||
this.setData({
|
||||
showSetBudget: true,
|
||||
changeType: type,
|
||||
changeItem: id,
|
||||
currentId: id,
|
||||
currentMoney: tCurrentMoney
|
||||
})
|
||||
},
|
||||
@@ -51,19 +68,14 @@ Page({
|
||||
})
|
||||
return;
|
||||
}
|
||||
if (this.data.changeType == 'count') {
|
||||
this.setData({
|
||||
mainMoney: this.data.currentMoney
|
||||
})
|
||||
}else {
|
||||
let cPayTypeList = this.data.payTypeList
|
||||
let cPayType = cPayTypeList[this.data.changeItem - 1]
|
||||
cPayType.money = this.data.currentMoney;
|
||||
this.setData({
|
||||
payTypeList : cPayTypeList
|
||||
})
|
||||
}
|
||||
this.closeDialog()
|
||||
app.$api.editBudget({
|
||||
expendId:this.data.currentId,
|
||||
budget:this.data.currentMoney
|
||||
}).then(res=>{
|
||||
if(res){
|
||||
this.closeDialog();
|
||||
}
|
||||
})
|
||||
},
|
||||
closeDialog() {
|
||||
this.setData({
|
||||
|
||||
Reference in New Issue
Block a user