添加基础资料下的页面功能

This commit is contained in:
zhengw
2026-03-06 17:18:27 +08:00
parent 816188c2bb
commit aa1294f997
47 changed files with 1697 additions and 5 deletions

View File

@@ -0,0 +1,9 @@
{
"usingComponents": {
"t-cell": "tdesign-miniprogram/cell/cell",
"t-checkbox": "tdesign-miniprogram/checkbox/checkbox",
"t-textarea": "tdesign-miniprogram/textarea/textarea",
"t-input": "tdesign-miniprogram/input/input"
},
"navigationBarTitleText": "结算账户"
}

View File

@@ -0,0 +1,121 @@
import { loginStatusPage, post } from '@/utils/https';
import {
cloneLite,
getAuthInfo,
getDataSet,
sleep,
toastError,
toastSuccess,
toNumber,
toObject,
} from '@/utils/util';
const defaultParams = { comments: '', account_name: '' };
Page({
/**
* 页面的初始数据
*/
data: {
params: cloneLite(defaultParams) as any,
mode: 'new' as 'new' | 'edit',
},
handleLogin(e: any) {
this.setData({ isLogin: e.detail });
if (e.detail) {
this.init();
}
},
init() {
this.setData({ authInfo: getAuthInfo() });
},
onChange(e: any) {
const key = getDataSet(e).key;
const val = e.detail.value;
this.data.params[key] = val;
this.setData({ params: this.data.params });
},
onBlur(e: any) {
const key = getDataSet(e).key;
if (key == 'init_amount') {
const val = e.detail.value;
this.data.params[key] = val ? toNumber(val).toFixed(2) : val;
this.setData({ params: this.data.params });
}
},
onCheckboxChange(e: any) {
const key = getDataSet(e).key;
this.data.params[key] = e.detail.checked ? 1 : 2;
this.setData({ params: this.data.params });
},
onSave() {
// console.log(this.data.params);
if (this.data.mode == 'new') {
this.data.params.current_amount = this.data.params.init_amount;
}
if (this.data.params.account_name) {
post(this.data.mode == 'new' ? 'ErpAccount/add' : 'ErpAccount/edit', this.data.params).then(
() => {
toastSuccess('保存成功');
sleep(() => {
wx.navigateBack();
}, 1000);
},
);
} else {
toastError('类型名称必填');
}
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(_options) {
const eventChannel: any = this.getOpenerEventChannel();
eventChannel?.on('accountEdit', (e: any) => {
const data = toObject(e.data);
wx.setNavigationBarTitle({
title: data.account_id ? `${data.account_name} 修改` : '新增结算账户',
});
this.setData({ params: data, mode: data.account_id ? 'edit' : 'new' });
});
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
loginStatusPage(this);
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {},
});

View File

@@ -0,0 +1,25 @@
<page-plugin isAuth="{{authInfo['SF_ORDER_CATEGORY_VIEW']}}" loading="{{loading}}"
is-login="{{isLogin}}" bind:handleLogin="handleLogin">
<t-input placeholder="账户名称" focus value="{{params.account_name}}" data-key="account_name"
bind:change="onChange" align="right" style="padding-left: 0;padding-right: 0;">
<view slot="label" class="required">账户名称</view>
</t-input>
<t-input placeholder="期初金额" focus value="{{params.init_amount}}" data-key="init_amount"
bind:change="onChange" bind:blur="onBlur" align="right"
style="padding-left: 0;padding-right: 0;" type="digit">
<view slot="label">期初金额</view>
</t-input>
<!-- <t-cell title="是否默认" align="right" style="padding-left: 0;padding-right: 0;">
<view slot="note">
<t-checkbox icon="rectangle" checked="{{params.if_default==1}}" style="padding: 0;"
bind:change="onCheckboxChange" data-key="if_default" />
</view>
</t-cell> -->
<t-textarea placeholder="备注" bordered style="margin-top: 16rpx;" value="{{params.comments}}"
data-key="comments" bind:change="onChange">
<view slot="label" class="textarea-label">备注</view>
</t-textarea>
<view style="margin-top: 32rpx;display: flex;justify-content: center;">
<t-button theme="primary" bind:tap="onSave">保存</t-button>
</view>
</page-plugin>