账单增删改调整

This commit is contained in:
2023-02-07 20:19:02 +08:00
parent 1fadf4c339
commit 1f5580c0f3
12 changed files with 109 additions and 83 deletions

View File

@@ -128,6 +128,9 @@ t-cell {
color: whitesmoke !important;
}
/*文本域*/
.t-textarea {
--td-textarea-disabled-text-color: orange;
}
.t-textarea__label {
--td-font-size-base: 32rpx;
--td-textarea-label-color:none

View File

@@ -1,14 +1,14 @@
<t-tabs defaultValue="{{0}}" t-class="custom-tabs" theme="card">
<t-tab-panel label="支出" value="0">
<expenses changeType="expend"/>
<expenses changeType="EXPEND"/>
</t-tab-panel>
<t-tab-panel label="收入" value="1">
<expenses changeType="income"/>
<expenses/>
</t-tab-panel>
<t-tab-panel label="转账" value="2">
<transfer/>
</t-tab-panel>
<t-tab-panel label="还款" value="3">
<transfer changeType="repayment"/>
<transfer changeType="REPAYMENT"/>
</t-tab-panel>
</t-tabs>

View File

@@ -1,9 +1,11 @@
Page({
data: {
sid: null
sid: null,
billType: null
},
onLoad: function (options) {
let sid = options.id
this.setData({sid})
let billType = options.billType
this.setData({sid,billType})
}
});

View File

@@ -1,4 +1,4 @@
<view class="padding_box">
<expenses/>
<!-- <transfer/>-->
<expenses wx:if="{{billType == 'INCOME' || billType == 'EXPEND'}}" billId="{{sid}}" changeType="{{billType}}"/>
<transfer wx:if="{{billType == 'REPAYMENT' || billType == 'TRANSFER'}}" billId="{{sid}}" changeType="{{billType}}"/>
</view>

View File

@@ -12,6 +12,7 @@ Page({
moneyName: null,
fromAccountName: null,
accountName: null,
remark: null,
},
onLoad: function (options) {
let sid = options.id
@@ -29,13 +30,14 @@ Page({
let moneyName = res.data.moneyName
let fromAccountName = res.data.fromAccountName
let accountName = res.data.accountName
this.setData({sid,name,money,balance,date,billType,moneyName,fromAccountName,accountName})
let remark = res.data.remark
this.setData({sid,name,money,balance,date,billType,moneyName,fromAccountName,accountName,remark})
}
})
},
editBill() {
wx.navigateTo({
url: './edit/index?id=' + this.data.sid
url: './edit/index?id=' + this.data.sid + '&billType=' + this.data.billType
})
},
deleteBill() {

View File

@@ -13,15 +13,15 @@
</t-cell>
<view wx:if="{{billType == 'TRANSFER' || billType == 'REPAYMENT'}}">
<t-cell title="账户" note="{{fromAccountName}}">
<t-icon name="fromAccount" slot="left-icon" />
<t-icon name="creditcard" slot="left-icon" />
</t-cell>
<t-cell title="目标" note="{{accountName}}">
<t-icon name="account" slot="left-icon" />
<t-icon name="creditcard" slot="left-icon" />
</t-cell>
</view>
<view wx:if="{{billType == 'INCOME' || billType == 'EXPEND'}}">
<t-cell title="账户" note="{{accountName}}">
<t-icon name="account" slot="left-icon" />
<t-icon name="creditcard" slot="left-icon" />
</t-cell>
<t-cell title="余额" note="{{balance}}">
<t-icon name="root-list" slot="left-icon" />
@@ -30,6 +30,7 @@
<t-cell title="时间" note="{{date}}">
<t-icon name="calendar" slot="left-icon" />
</t-cell>
<t-textarea value="{{remark}}" maxlength="200" bindchange="onRemarkInput" disabled />
<view class="bottom_box">
<view class="space_box">
<t-button theme="danger" variant="outline" block bind:tap="deleteBill">删除</t-button>

View File

@@ -15,3 +15,6 @@ image {
t-button {
width: 50%;
}
.t-color-input {
color: orange;
}

View File

@@ -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({
expendGrid1 = expendGrid1.concat({
id: x.id,
label: x.name,
icon: x.icon,
});
})
}else {
income.forEach(x=>{
firstGrid.fill({
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) {

View File

@@ -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>

View File

@@ -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,
});
})
if ('transfer' == this.properties.changeType){
cash.forEach(x=>{
secondGrid.fill({
transferGrid2 = transferGrid2.concat({
id: x.id,
label: x.name,
icon: x.icon,
});
repaymentGrid1 = repaymentGrid1.concat({
id: x.id,
label: x.name,
icon: x.icon,
});
})
}else {
owe.forEach(x=>{
secondGrid.fill({
repaymentGrid2 = repaymentGrid2.concat({
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) {

View File

@@ -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>

View File

@@ -31,7 +31,7 @@
title="{{item.name}}"
description="{{item.date}} • {{item.accountName}}"
align="top"
image="{{item.icon}}"
image="{{item.moneyIcon}}"
note="{{item.money}}"
class="t-cell-{{item.type}}"
url="{{'/pages/bill/index?id=' + item.id}}"