配置
This commit is contained in:
@@ -7,8 +7,10 @@ Page({
|
||||
isIncome: 0,
|
||||
isAdd: 0,
|
||||
showDeleteConfirm: false,
|
||||
id : -1,
|
||||
icon : null,
|
||||
accType: null
|
||||
settingType: null,
|
||||
name: null,
|
||||
},
|
||||
onLoad: function (options) {
|
||||
this.setData({
|
||||
@@ -16,6 +18,26 @@ Page({
|
||||
isIncome : options.isIncome,
|
||||
isAdd : options.isAdd
|
||||
})
|
||||
if (options.isAdd == 0){
|
||||
this.setData({
|
||||
id : options.id
|
||||
})
|
||||
app.$api.getSetting(options.id).then(res => {
|
||||
if (res.data){
|
||||
let name = res.data.name
|
||||
let icon = res.data.icon
|
||||
let settingType = res.data.settingType
|
||||
this.setData({name,icon,settingType})
|
||||
}
|
||||
})
|
||||
}
|
||||
if (options.isAdd == 1 && options.isAccount == 0){
|
||||
let settingType = 'EXPEND_SETTING';
|
||||
if (options.isIncome == 1){
|
||||
settingType = 'INCOME_SETTING'
|
||||
}
|
||||
this.setData({settingType})
|
||||
}
|
||||
},
|
||||
handleMultiAction(e) {
|
||||
if (this.data.isAccount == 1) {
|
||||
@@ -41,8 +63,29 @@ Page({
|
||||
let {icon} = e.detail.selected
|
||||
this.setData({icon})
|
||||
},
|
||||
changeItem(e) {
|
||||
this.setData({ settingType : e.detail.value})
|
||||
},
|
||||
onNameInput(e) {
|
||||
this.setData({ name : e.detail.value})
|
||||
},
|
||||
saveSetting () {
|
||||
wx.navigateBack();
|
||||
let param = {
|
||||
id : this.data.id,
|
||||
name : this.data.name,
|
||||
icon : this.data.icon,
|
||||
settingType : this.data.settingType
|
||||
}
|
||||
app.$api.editSetting(param).then(res => {
|
||||
if (res){
|
||||
wx.showToast({
|
||||
title: '保存成功!',
|
||||
icon: 'none',
|
||||
duration: 2000
|
||||
})
|
||||
wx.navigateBack();
|
||||
}
|
||||
})
|
||||
},
|
||||
deleteSetting() {
|
||||
this.setData({
|
||||
@@ -50,9 +93,12 @@ Page({
|
||||
})
|
||||
},
|
||||
onConfirm (e) {
|
||||
app.$api.deleteSetting();
|
||||
wx.navigateBack();
|
||||
this.closeDialog();
|
||||
app.$api.deleteSetting(this.data.id).then(res => {
|
||||
if (res){
|
||||
wx.navigateBack();
|
||||
this.closeDialog();
|
||||
}
|
||||
});
|
||||
},
|
||||
closeDialog() {
|
||||
this.setData({
|
||||
|
||||
@@ -2,13 +2,13 @@
|
||||
label="名称"
|
||||
placeholder="请输入名称"
|
||||
align="right"
|
||||
bindchange="onPriceInput"
|
||||
value="{{ '假的名称' }}"
|
||||
bindchange="onNameInput"
|
||||
value="{{name}}"
|
||||
/>
|
||||
<t-input wx:if="{{ isAccount == 1 }}" label="分类" disabled>
|
||||
<t-radio-group slot="suffix" default-value="{{accType}}" borderless t-class="box">
|
||||
<t-radio block="{{ false }}" label="资产账户" value="0" />
|
||||
<t-radio block="{{ false }}" label="负债账户" value="1" />
|
||||
<t-radio-group slot="suffix" default-value="CASH_SETTING" value="{{settingType}}" bind:change="changeItem" borderless t-class="box">
|
||||
<t-radio block="{{ false }}" label="资产账户" value="CASH_SETTING" />
|
||||
<t-radio block="{{ false }}" label="负债账户" value="OWE_SETTING" />
|
||||
</t-radio-group>
|
||||
</t-input>
|
||||
<t-input label="图标" disabled >
|
||||
|
||||
Reference in New Issue
Block a user