账单增删改调整
This commit is contained in:
@@ -1,21 +1,24 @@
|
||||
const app = getApp();
|
||||
import ActionSheet, { ActionSheetTheme } from '../../../miniprogram_npm/tdesign-miniprogram/action-sheet/index';
|
||||
let handler = null;
|
||||
const firstGrid = [];
|
||||
const secondGrid = [];
|
||||
Component({
|
||||
properties: {
|
||||
billId: {
|
||||
type: String,
|
||||
value: null
|
||||
value: -1
|
||||
},
|
||||
/* income & expend */
|
||||
changeType: {
|
||||
type: String,
|
||||
value: 'income'
|
||||
value: 'INCOME'
|
||||
},
|
||||
},
|
||||
data: {
|
||||
incomeGrid1: [],
|
||||
incomeGrid2: [],
|
||||
expendGrid1: [],
|
||||
expendGrid2: [],
|
||||
|
||||
priceError: false,
|
||||
grid: '',
|
||||
outText: '',
|
||||
@@ -36,48 +39,60 @@ Component({
|
||||
remark: null,
|
||||
},
|
||||
attached(){
|
||||
let incomeGrid1 = [];
|
||||
let incomeGrid2 = [];
|
||||
let expendGrid1 = [];
|
||||
let expendGrid2 = [];
|
||||
app.$api.getSettings().then(setting => {
|
||||
if (setting){
|
||||
let expend = setting.data.EXPEND_SETTING;
|
||||
let income = setting.data.INCOME_SETTING;
|
||||
let cash = setting.data.CASH_SETTING;
|
||||
let owe = setting.data.OWE_SETTING;
|
||||
if ('expend' == this.properties.changeType){
|
||||
expend.forEach(x=>{
|
||||
firstGrid.fill({
|
||||
id: x.id,
|
||||
label: x.name,
|
||||
icon: x.icon,
|
||||
});
|
||||
})
|
||||
}else {
|
||||
income.forEach(x=>{
|
||||
firstGrid.fill({
|
||||
id: x.id,
|
||||
label: x.name,
|
||||
icon: x.icon,
|
||||
});
|
||||
})
|
||||
}
|
||||
expend.forEach(x=>{
|
||||
expendGrid1 = expendGrid1.concat({
|
||||
id: x.id,
|
||||
label: x.name,
|
||||
icon: x.icon,
|
||||
});
|
||||
})
|
||||
income.forEach(x=>{
|
||||
incomeGrid1 = incomeGrid1.concat({
|
||||
id: x.id,
|
||||
label: x.name,
|
||||
icon: x.icon,
|
||||
});
|
||||
})
|
||||
cash.forEach(x=>{
|
||||
secondGrid.fill({
|
||||
incomeGrid2 = incomeGrid2.concat({
|
||||
id: x.id,
|
||||
label: x.name,
|
||||
icon: x.icon,
|
||||
});
|
||||
expendGrid2 = expendGrid2.concat({
|
||||
id: x.id,
|
||||
label: x.name,
|
||||
icon: x.icon,
|
||||
});
|
||||
})
|
||||
owe.forEach(x=>{
|
||||
secondGrid.fill({
|
||||
incomeGrid2 = incomeGrid2.concat({
|
||||
id: x.id,
|
||||
label: x.name,
|
||||
icon: x.icon,
|
||||
});
|
||||
expendGrid2 = expendGrid2.concat({
|
||||
id: x.id,
|
||||
label: x.name,
|
||||
icon: x.icon,
|
||||
});
|
||||
})
|
||||
this.setData({expendGrid1,expendGrid2,incomeGrid1,incomeGrid2})
|
||||
}
|
||||
});
|
||||
if (this.properties.billId){
|
||||
if (this.properties.billId != -1){
|
||||
app.$api.getBill(this.properties.billId).then(res => {
|
||||
if (res){
|
||||
if (res.data){
|
||||
let name = res.data.name;
|
||||
let money = res.data.money;
|
||||
let billType = res.data.billType;
|
||||
@@ -86,18 +101,14 @@ Component({
|
||||
let typeText = res.data.moneyName;
|
||||
let accountText = res.data.accountName;
|
||||
let remark = res.data.remark;
|
||||
let date = res.data.date;
|
||||
let dateText = app.$utils.formatDate(date)
|
||||
let dateText = res.data.date;
|
||||
this.setData({
|
||||
name,money,billType,account,moneyType,typeText,accountText,remark,date,dateText
|
||||
name,money,billType,account,moneyType,typeText,accountText,remark,dateText
|
||||
})
|
||||
}
|
||||
})
|
||||
}else {
|
||||
let billType = 'INCOME'
|
||||
if ('expend' == this.properties.changeType){
|
||||
billType = 'EXPEND'
|
||||
}
|
||||
let billType = this.properties.changeType
|
||||
this.setData({billType})
|
||||
}
|
||||
},
|
||||
@@ -124,14 +135,14 @@ Component({
|
||||
theme: ActionSheetTheme.Grid,
|
||||
selector: '#t-action-sheet',
|
||||
context: this,
|
||||
items: firstGrid
|
||||
items: this.properties.changeType == 'EXPEND' ? this.data.expendGrid1 : this.data.incomeGrid1
|
||||
});
|
||||
}else {
|
||||
handler = ActionSheet.show({
|
||||
theme: ActionSheetTheme.Grid,
|
||||
selector: '#t-action-sheet',
|
||||
context: this,
|
||||
items: secondGrid
|
||||
items: this.properties.changeType == 'EXPEND' ? this.data.expendGrid2 : this.data.incomeGrid2
|
||||
});
|
||||
}
|
||||
},
|
||||
@@ -181,20 +192,17 @@ Component({
|
||||
bYesterday () {
|
||||
let preDate = new Date(new Date().getTime() - 24 * 60 * 60 * 1000 * 2);
|
||||
this.setData({
|
||||
date : preDate,
|
||||
dateText: app.$utils.formatDate(preDate)
|
||||
})
|
||||
},
|
||||
yesterday() {
|
||||
let preDate = new Date(new Date().getTime() - 24 * 60 * 60 * 1000);
|
||||
this.setData({
|
||||
date : preDate,
|
||||
dateText: app.$utils.formatDate(preDate)
|
||||
})
|
||||
},
|
||||
today () {
|
||||
this.setData({
|
||||
date : new Date(),
|
||||
dateText: app.$utils.formatDate(new Date())
|
||||
})
|
||||
},
|
||||
@@ -207,7 +215,7 @@ Component({
|
||||
account:this.data.account,
|
||||
moneyType:this.data.moneyType,
|
||||
remark:this.data.remark,
|
||||
date:this.data.date
|
||||
date:this.data.dateText
|
||||
}
|
||||
app.$api.editBill(param).then(res => {
|
||||
if (res) {
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
<view class="placeholder_line"></view>
|
||||
<t-tag size="large" bind:tap="today" variant="light">今天</t-tag>
|
||||
</view>
|
||||
<t-textarea label="备注" placeholder="请输入该账单说明..." bindchange="onRemarkInput" maxlength="200" indicator />
|
||||
<t-textarea label="备注" placeholder="请输入该账单说明..." value="{{remark}}" bindchange="onRemarkInput" maxlength="200" indicator />
|
||||
<view class="view_button">
|
||||
<t-button theme="primary" block bind:tap="saveBill">保存</t-button>
|
||||
</view>
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
const app = getApp();
|
||||
import ActionSheet, { ActionSheetTheme } from '../../../miniprogram_npm/tdesign-miniprogram/action-sheet/index';
|
||||
let handler = null;
|
||||
const firstGrid = [];
|
||||
const secondGrid = [];
|
||||
Component({
|
||||
properties: {
|
||||
billId: {
|
||||
@@ -12,10 +10,14 @@ Component({
|
||||
/* transfer & repayment */
|
||||
changeType: {
|
||||
type: String,
|
||||
value: 'transfer'
|
||||
value: 'TRANSFER'
|
||||
},
|
||||
},
|
||||
data: {
|
||||
transferGrid1: [],
|
||||
transferGrid2: [],
|
||||
repaymentGrid1: [],
|
||||
repaymentGrid2: [],
|
||||
priceError: false,
|
||||
grid: '',
|
||||
typeText: '',
|
||||
@@ -41,35 +43,41 @@ Component({
|
||||
if (setting){
|
||||
let cash = setting.data.CASH_SETTING;
|
||||
let owe = setting.data.OWE_SETTING;
|
||||
let transferGrid1 = []
|
||||
let transferGrid2 = []
|
||||
let repaymentGrid1 = []
|
||||
let repaymentGrid2 = []
|
||||
cash.forEach(x=>{
|
||||
firstGrid.fill({
|
||||
transferGrid1 = transferGrid1.concat({
|
||||
id: x.id,
|
||||
label: x.name,
|
||||
icon: x.icon,
|
||||
});
|
||||
transferGrid2 = transferGrid2.concat({
|
||||
id: x.id,
|
||||
label: x.name,
|
||||
icon: x.icon,
|
||||
});
|
||||
repaymentGrid1 = repaymentGrid1.concat({
|
||||
id: x.id,
|
||||
label: x.name,
|
||||
icon: x.icon,
|
||||
});
|
||||
|
||||
})
|
||||
owe.forEach(x=>{
|
||||
repaymentGrid2 = repaymentGrid2.concat({
|
||||
id: x.id,
|
||||
label: x.name,
|
||||
icon: x.icon,
|
||||
});
|
||||
})
|
||||
if ('transfer' == this.properties.changeType){
|
||||
cash.forEach(x=>{
|
||||
secondGrid.fill({
|
||||
id: x.id,
|
||||
label: x.name,
|
||||
icon: x.icon,
|
||||
});
|
||||
})
|
||||
}else {
|
||||
owe.forEach(x=>{
|
||||
secondGrid.fill({
|
||||
id: x.id,
|
||||
label: x.name,
|
||||
icon: x.icon,
|
||||
});
|
||||
})
|
||||
}
|
||||
this.setData({transferGrid1,transferGrid2,repaymentGrid1,repaymentGrid2})
|
||||
}
|
||||
})
|
||||
if (this.properties.billId){
|
||||
if (this.properties.billId != -1){
|
||||
app.$api.getBill(this.properties.billId).then(res => {
|
||||
if (res){
|
||||
if (res.data){
|
||||
let name = res.data.name;
|
||||
let money = res.data.money;
|
||||
let billType = res.data.billType;
|
||||
@@ -79,17 +87,16 @@ Component({
|
||||
let inText = res.data.accountName;
|
||||
let moneyType = res.data.moneyType;
|
||||
let remark = res.data.remark;
|
||||
let date = res.data.date;
|
||||
let dateText = app.$utils.formatDate(date)
|
||||
let dateText = res.data.date;
|
||||
this.setData({
|
||||
name,money,billType,fromAccount,account,outText,inText,moneyType,remark,date,dateText
|
||||
name,money,billType,fromAccount,account,outText,inText,moneyType,remark,dateText
|
||||
})
|
||||
}
|
||||
})
|
||||
}else {
|
||||
let billType = 'TRANSFER'
|
||||
let moneyType = -1
|
||||
if ('repayment' == this.properties.changeType){
|
||||
if ('REPAYMENT' == this.properties.changeType){
|
||||
billType = 'REPAYMENT'
|
||||
moneyType = -2
|
||||
}
|
||||
@@ -118,14 +125,14 @@ Component({
|
||||
theme: ActionSheetTheme.Grid,
|
||||
selector: '#t-action-sheet',
|
||||
context: this,
|
||||
items: firstGrid
|
||||
items: this.properties.changeType == 'REPAYMENT' ? this.data.repaymentGrid1 : this.data.transferGrid1
|
||||
});
|
||||
}else {
|
||||
handler = ActionSheet.show({
|
||||
theme: ActionSheetTheme.Grid,
|
||||
selector: '#t-action-sheet',
|
||||
context: this,
|
||||
items: secondGrid
|
||||
items: this.properties.changeType == 'REPAYMENT' ? this.data.repaymentGrid2 : this.data.transferGrid2
|
||||
});
|
||||
}
|
||||
},
|
||||
@@ -199,7 +206,7 @@ Component({
|
||||
account:this.data.account,
|
||||
moneyType:this.data.moneyType,
|
||||
remark:this.data.remark,
|
||||
date:this.data.date
|
||||
date:this.data.dateText
|
||||
}
|
||||
app.$api.editBill(param).then(res => {
|
||||
if (res) {
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
<view class="placeholder_line"></view>
|
||||
<t-tag size="large" bind:tap="today" variant="light">今天</t-tag>
|
||||
</view>
|
||||
<t-textarea label="备注" placeholder="请输入该账单说明..." maxlength="200" bindchange="onRemarkInput" indicator />
|
||||
<t-textarea label="备注" placeholder="请输入该账单说明..." value="{{remark}}" maxlength="200" bindchange="onRemarkInput" indicator />
|
||||
<view class="view_button">
|
||||
<t-button theme="primary" block bind:tap="saveBill">保存</t-button>
|
||||
</view>
|
||||
|
||||
Reference in New Issue
Block a user