添加页面, 组件, 图标
This commit is contained in:
16
miniprogram/pages/base/account/account.json
Normal file
16
miniprogram/pages/base/account/account.json
Normal file
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"usingComponents": {
|
||||
"search-popup": "/pages/components/search-popup/search-popup",
|
||||
"card-plugin": "/pages/components/card-plugin/card-plugin",
|
||||
"card-item-plugin": "/pages/components/card-item-plugin/card-item-plugin",
|
||||
"option-cell-plugin": "/pages/components/option-cell-plugin/option-cell-plugin",
|
||||
"date-picker-plugin": "/pages/components/date-picker-plugin/date-picker-plugin",
|
||||
"sort-plugin": "/pages/components/sort-plugin/sort-plugin",
|
||||
"count-plugin": "/pages/components/count-plugin/count-plugin",
|
||||
"total-bar-plugin": "/pages/components/total-bar-plugin/total-bar-plugin",
|
||||
"pagination-plugin": "/pages/components/pagination-plugin/pagination-plugin",
|
||||
"search-input": "/pages/components/search-input/search-input",
|
||||
"t-icon": "tdesign-miniprogram/icon/icon"
|
||||
},
|
||||
"navigationBarTitleText": "结算账户"
|
||||
}
|
||||
183
miniprogram/pages/base/account/account.ts
Normal file
183
miniprogram/pages/base/account/account.ts
Normal file
@@ -0,0 +1,183 @@
|
||||
import { loginStatus, post } from '@/utils/https';
|
||||
import {
|
||||
cloneLite,
|
||||
getAuthInfo,
|
||||
getDataSet,
|
||||
showModal,
|
||||
sleep,
|
||||
toArray,
|
||||
toastSuccess,
|
||||
toNumber,
|
||||
} from '@/utils/util';
|
||||
|
||||
const defaultParams = { curr_page: 1, page_count: 20 };
|
||||
|
||||
Page({
|
||||
/**
|
||||
* 页面的初始数据
|
||||
*/
|
||||
data: {
|
||||
params: cloneLite(defaultParams) as any,
|
||||
list: [] as any[],
|
||||
count: 0,
|
||||
sort: [{ label: '创建日期', value: 'create_date' }],
|
||||
},
|
||||
handleLogin(e: any) {
|
||||
this.setData({ isLogin: e.detail });
|
||||
if (e.detail) {
|
||||
this.init();
|
||||
}
|
||||
},
|
||||
init() {
|
||||
this.setData({ authInfo: getAuthInfo() });
|
||||
this.getList();
|
||||
},
|
||||
searchChange(e: any) {
|
||||
const key = getDataSet(e).key;
|
||||
this.data.params[key] = e.detail.value;
|
||||
this.setData({ params: this.data.params });
|
||||
},
|
||||
searchChange2(e: any) {
|
||||
const key = getDataSet(e).key;
|
||||
const val = `${e.detail.value || ''}`.trim();
|
||||
if (val) {
|
||||
this.data.params[key] = val;
|
||||
} else {
|
||||
delete this.data.params[key];
|
||||
}
|
||||
this.setData({ params: this.data.params });
|
||||
},
|
||||
onOptionChange(e: any) {
|
||||
const key = getDataSet(e).key;
|
||||
this.data.params[key] = e.detail.value;
|
||||
this.setData({ params: this.data.params });
|
||||
},
|
||||
datePickerConfirm(e: any) {
|
||||
const data = getDataSet(e);
|
||||
this.data.params[data.key] = e.detail.value;
|
||||
this.setData({ params: this.data.params });
|
||||
},
|
||||
searchOk() {
|
||||
this.getList(1);
|
||||
},
|
||||
searchReset() {
|
||||
this.data.params = cloneLite(defaultParams);
|
||||
this.getList(1);
|
||||
},
|
||||
onSort(e: any) {
|
||||
this.data.params.order = e.detail.value;
|
||||
this.setData({ params: this.data.params });
|
||||
this.getList(1);
|
||||
},
|
||||
paginationChange(e: any) {
|
||||
this.getList(e.detail.curr_page);
|
||||
},
|
||||
getList(curr: number = 1) {
|
||||
this.data.params.curr_page = curr;
|
||||
this.setData({ params: this.data.params });
|
||||
const temp = cloneLite(this.data.params);
|
||||
|
||||
post('ErpAccount/list', temp).then((res: any) => {
|
||||
const list = toArray(res.data?.list);
|
||||
if (list.length == 0 && this.data.params.curr_page > 1) {
|
||||
this.getList(this.data.params.curr_page - 1);
|
||||
}
|
||||
this.setData({
|
||||
count: toNumber(res.data?.count),
|
||||
list: list,
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
onDefault(e: any) {
|
||||
const data = getDataSet(e);
|
||||
const index = data.index;
|
||||
const item = this.data.list[index];
|
||||
showModal({ content: `确认将 ${item.account_name} 设为默认账户?` }).then(() => {
|
||||
post('ErpAccount/setDefault', { account_id: item.account_id }).then(() => {
|
||||
toastSuccess('设置成功');
|
||||
sleep(() => {
|
||||
this.getList();
|
||||
}, 1000);
|
||||
});
|
||||
});
|
||||
},
|
||||
onState(e: any) {
|
||||
const data = getDataSet(e);
|
||||
const index = data.index;
|
||||
const item = this.data.list[index];
|
||||
showModal({
|
||||
content: `确认 ${item.state == 1 ? '禁用' : '启用'} ${item.account_name}账户?`,
|
||||
}).then(() => {
|
||||
post('ErpAccount/setState', { account_id: item.account_id }).then(() => {
|
||||
toastSuccess(`${item.state == 1 ? '禁用' : '启用'}成功`);
|
||||
sleep(() => {
|
||||
this.getList();
|
||||
}, 1000);
|
||||
});
|
||||
});
|
||||
},
|
||||
onDelete(e: any) {
|
||||
const data = getDataSet(e);
|
||||
const index = data.index;
|
||||
const item = this.data.list[index];
|
||||
showModal({ content: `确认删除 ${item.account_name} 账户?` }).then(() => {
|
||||
post('ErpAccount/del', { account_id: item.account_id }).then(() => {
|
||||
toastSuccess('删除成功');
|
||||
sleep(() => {
|
||||
this.getList();
|
||||
}, 1000);
|
||||
});
|
||||
});
|
||||
},
|
||||
/**
|
||||
* 生命周期函数--监听页面加载
|
||||
*/
|
||||
onLoad(_options) {},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面初次渲染完成
|
||||
*/
|
||||
onReady() {},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面显示
|
||||
*/
|
||||
onShow() {
|
||||
this.setData({ loading: true });
|
||||
loginStatus()
|
||||
.then(() => {
|
||||
this.setData({ isLogin: true, loading: false });
|
||||
this.init();
|
||||
})
|
||||
.catch((err) => {
|
||||
this.setData({ isLogin: false, loading: false });
|
||||
console.log('调用登录状态请求失败', err);
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面隐藏
|
||||
*/
|
||||
onHide() {},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面卸载
|
||||
*/
|
||||
onUnload() {},
|
||||
|
||||
/**
|
||||
* 页面相关事件处理函数--监听用户下拉动作
|
||||
*/
|
||||
onPullDownRefresh() {},
|
||||
|
||||
/**
|
||||
* 页面上拉触底事件的处理函数
|
||||
*/
|
||||
onReachBottom() {},
|
||||
|
||||
/**
|
||||
* 用户点击右上角分享
|
||||
*/
|
||||
onShareAppMessage() {},
|
||||
});
|
||||
55
miniprogram/pages/base/account/account.wxml
Normal file
55
miniprogram/pages/base/account/account.wxml
Normal file
@@ -0,0 +1,55 @@
|
||||
<page-plugin isAuth="{{authInfo['SF_ERP_ACCOUNT_VIEW']}}" loading="{{loading}}"
|
||||
is-login="{{isLogin}}" bind:handleLogin="handleLogin">
|
||||
<search-popup placeholder="输入名称" bind:change="searchChange" bind:ok="searchOk"
|
||||
bind:reset="searchReset" value="{{params.account_name}}" data-key="account_name"
|
||||
hideMore="{{true}}">
|
||||
<!-- <view slot="content">
|
||||
<search-input label="手机号码" value="{{params.crm_phone}}" data-key="crm_phone"
|
||||
bind:change="searchChange2" />
|
||||
<date-picker-plugin title="创建开始日期" value="{{params.create_dateL}}" data-key="create_dateL"
|
||||
bind:confirm="datePickerConfirm" />
|
||||
<date-picker-plugin title="创建结束日期" value="{{params.create_dateU}}" data-key="create_dateU"
|
||||
bind:confirm="datePickerConfirm" />
|
||||
</view> -->
|
||||
</search-popup>
|
||||
|
||||
<count-plugin count="{{count}}">
|
||||
<!-- <sort-plugin options="{{sort}}" bind:ok="onSort" value="{{params.order}}" slot="right" /> -->
|
||||
</count-plugin>
|
||||
|
||||
<empty-plugin wx:if="{{list.length == 0}}" />
|
||||
<card-plugin wx:for="{{ list }}" wx:key="account_id">
|
||||
<view slot="header"
|
||||
style="display: flex;justify-content: space-between;width: 100%;align-items: center;column-gap: 12rpx;">
|
||||
<view style="word-break: break-all;min-width: 0;">
|
||||
{{ item.account_name }}
|
||||
</view>
|
||||
<view
|
||||
style="display: flex;align-items: center;column-gap: 8rpx;font-weight: normal;flex-shrink: 0;">
|
||||
<t-icon wx:if="{{item.if_default == 2}}" name="star" color="#2ba471" />
|
||||
<text wx:if="{{item.state == 1}}" style="color: #0052d9;">正常</text>
|
||||
<text wx:elif="{{item.state == 2}}" style="color: #d54941;">禁用</text>
|
||||
</view>
|
||||
</view>
|
||||
<view slot="content">
|
||||
<card-item-plugin label="期初金额" value="{{item.init_amount}}" />
|
||||
<card-item-plugin label="当前金额" value="{{item.current_amount}}" />
|
||||
<card-item-plugin label="备注" value="{{item.comments}}" />
|
||||
<card-item-plugin label="创建日期" value="{{item.create_date}}" />
|
||||
</view>
|
||||
<view slot="footer" class="card-plugin-footer">
|
||||
<t-button wx:if="{{authInfo['SF_ERP_ACCOUNT_EDIT'] && item.if_default == 1}}" size="small"
|
||||
theme="primary" bind:tap="onDefault" data-index="{{index}}">
|
||||
设为默认</t-button>
|
||||
<t-button wx:if="{{authInfo['SF_ERP_ACCOUNT_EDIT']}}" size="small"
|
||||
theme="{{item.state == 1 ? 'danger' : 'primary'}}" bind:tap="onState"
|
||||
data-index="{{index}}">
|
||||
{{item.state == 1 ? '禁用' : '启用'}}
|
||||
</t-button>
|
||||
<t-button wx:if="{{authInfo['SF_ERP_ACCOUNT_DEL']}}" size="small" theme="danger"
|
||||
bind:tap="onDelete" data-index="{{index}}">删除</t-button>
|
||||
</view>
|
||||
</card-plugin>
|
||||
<pagination-plugin curr_page="{{params.curr_page}}" page_count="{{params.page_count}}"
|
||||
total="{{count}}" bind:change="paginationChange" />
|
||||
</page-plugin>
|
||||
0
miniprogram/pages/base/account/account.wxss
Normal file
0
miniprogram/pages/base/account/account.wxss
Normal file
Reference in New Issue
Block a user