Commit 22041094 by liangjianmin

feat(home): 添加费用申请统计功能并优化跳转逻辑

- 在首页统计数据中添加费用申请待处理统计项
- 实现点击统计项跳转到审批列表对应主 tab
- 更新 API 接口以支持费用申请待处理统计
parent c6014eb6
...@@ -152,6 +152,7 @@ ...@@ -152,6 +152,7 @@
} }
}, },
onShow() { onShow() {
this.setCurrentTabFromHome();
this.resetAndLoad(); this.resetAndLoad();
}, },
onReachBottom() { onReachBottom() {
...@@ -169,6 +170,19 @@ ...@@ -169,6 +170,19 @@
this.getData(); this.getData();
}, },
/** /**
* 根据首页传入索引选中主 tab
* @return {void}
*/
setCurrentTabFromHome() {
var approveTab = uni.getStorageSync('approve_tab');
if (approveTab === '') return;
uni.removeStorageSync('approve_tab');
var tabIndex = Number(approveTab);
this.currentTab = tabIndex >= 0 && tabIndex < this.tabList.length ? tabIndex : 0;
this.currentType = 0;
this.resetAllList();
},
/**
* 重置全部 tab 的列表与分页 * 重置全部 tab 的列表与分页
* @return {void} * @return {void}
*/ */
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
<view class="hero-bg"></view> <view class="hero-bg"></view>
<view class="hero-inner"> <view class="hero-inner">
<view class="stat-card"> <view class="stat-card">
<view class="stat-item" v-for="(item, index) in statList" :key="item.key" :style="{ animationDelay: (index * 0.08) + 's' }"> <view class="stat-item" v-for="(item, index) in statList" :key="item.key" :style="{ animationDelay: (index * 0.08) + 's' }" @click="goApproveTab(item)">
<text class="stat-num">{{ item.value }}</text> <text class="stat-num">{{ item.value }}</text>
<text class="stat-label">{{ item.label }}</text> <text class="stat-label">{{ item.label }}</text>
</view> </view>
...@@ -39,14 +39,15 @@ ...@@ -39,14 +39,15 @@
</template> </template>
<script> <script>
import { API } from '@/util/api';
export default { export default {
data() { data() {
return { return {
// 统计数据:暂写死,后续接入接口
statList: [ statList: [
{ key: 'pending', label: '待处理', value: 5 }, { key: 'pending', label: '待处理', value: 0, tabIndex: 0 },
{ key: 'done', label: '已处理', value: 1 }, { key: 'done', label: '已处理', value: 0, tabIndex: 1 },
{ key: 'mine', label: '我发起', value: 0 } { key: 'mine', label: '我发起', value: 0, tabIndex: 2 }
], ],
groupList: [ groupList: [
{ {
...@@ -72,8 +73,43 @@ ...@@ -72,8 +73,43 @@
] ]
}; };
}, },
onShow() {
this.getFeeApplyStats();
},
methods: { methods: {
/** /**
* 获取费用申请待处理统计
* @return {void}
*/
getFeeApplyStats() {
this.request(API.feeApplyStats, 'GET').then(res => {
if (res.code !== 0) return;
var list = res.data || [];
this.setFeeApplyStats(list);
});
},
/**
* 写入费用申请统计数据
* @param {Array} list - 统计列表
* @return {void}
*/
setFeeApplyStats(list) {
var statMap = list || {};
this.statList = this.statList.map(item => ({
...item,
value: statMap[item.key] || 0
}));
},
/**
* 跳转到审批列表对应主 tab
* @param {Object} item - 统计项
* @return {void}
*/
goApproveTab(item) {
uni.setStorageSync('approve_tab', item.tabIndex || 0);
uni.switchTab({ url: '/pages/approve/index' });
},
/**
* 跳转到对应业务页面 * 跳转到对应业务页面
* @param {Object} item - 入口项 * @param {Object} item - 入口项
* @return {void} * @return {void}
......
...@@ -67,6 +67,10 @@ const API = { ...@@ -67,6 +67,10 @@ const API = {
*/ */
addFeeApply: API_BASE + '/api/order/addFeeApply', addFeeApply: API_BASE + '/api/order/addFeeApply',
/** /**
* 费用申请待处理统计
*/
feeApplyStats: API_BASE + '/api/order/feeApplyStats',
/**
* 根据订单号获取客户名称 * 根据订单号获取客户名称
*/ */
getCustomerName: API_BASE + '/ajax/customerNameOption', getCustomerName: API_BASE + '/ajax/customerNameOption',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment