feat: 增加智慧库房,完善项目盈亏

This commit is contained in:
砂糖
2025-08-20 16:07:18 +08:00
parent f5ab69a431
commit 26ee6430c0
40 changed files with 14771 additions and 485 deletions

View File

@@ -0,0 +1,367 @@
<template>
<view class="container">
<!-- 标题和日期选择区 -->
<view class="header">
<view class="title-bar">
<text class="title">人员签到表</text>
</view>
<view class="date-picker-container">
<picker
mode="date"
fields="month"
:value="currentDate"
@change="onDateChange"
class="date-picker"
>
<view class="picker-view">
<text>{{ formattedDate }}</text>
</view>
</picker>
</view>
</view>
<!-- 加载状态 -->
<view v-if="loading" class="loading-view">
<loading class="loading" color="#007aff" size="16"></loading>
<text class="loading-text">加载中...</text>
</view>
<!-- 签到表区域支持横向滚动 -->
<scroll-view
v-else
scroll-x="true"
class="table-scroll"
@scroll="onScroll"
>
<view class="table-container">
<!-- 表头 -->
<view class="table-header">
<view class="table-cell name-cell">姓名</view>
<view
class="table-cell day-cell"
v-for="(day, index) in dateLength"
:key="index"
>
{{ index + 1 }}
</view>
</view>
<!-- 表格内容 -->
<view class="table-body">
<view
class="table-row"
v-for="(user, userIndex) in userList"
:key="userIndex"
:class="{ 'odd-row': userIndex % 2 === 1 }"
>
<view class="table-cell name-cell">{{ user.nickName }}</view>
<view
class="table-cell day-cell"
v-for="(day, dayIndex) in dateLength"
:key="dayIndex"
:style="getCellStyle(user, dayIndex + 1)"
>
{{ getAttendanceStatusText(user, dayIndex + 1) }}
</view>
</view>
</view>
</view>
</scroll-view>
<!-- 图例说明 -->
<view class="legend-container">
<view class="legend-item">
<view class="legend-color" style="background-color: #fdf6e4;"></view>
<text class="legend-text">出差</text>
</view>
<view class="legend-item">
<view class="legend-color" style="background-color: #e3f2fd;"></view>
<text class="legend-text">请假</text>
</view>
</view>
</view>
</template>
<script>
import { getDateLength, listOaAttendance } from "@/api/oa/oaAttendance";
export default {
data() {
return {
// 用户列表数据
userList: [],
// 当前月份天数
dateLength: 31,
// 当前选中日期
currentDate: '',
// 格式化显示的日期
formattedDate: '',
// 加载状态
loading: true,
// 查询参数
queryParams: {
selectTime: ''
},
// 滚动位置记录
scrollLeft: 0
};
},
onLoad() {
// 初始化日期为当前月份
const now = new Date();
const year = now.getFullYear();
const month = now.getMonth() + 1;
this.currentDate = `${year}-${month.toString().padStart(2, '0')}-01`;
this.formattedDate = `${year}${month}`;
this.queryParams.selectTime = this.currentDate;
// 获取数据
this.getDateCount();
this.getAttendanceList();
},
methods: {
// 获取当月天数
getDateCount() {
getDateLength().then(res => {
this.dateLength = res.data;
}).catch(err => {
console.error('获取日期长度失败', err);
});
},
// 获取签到列表数据
getAttendanceList() {
this.loading = true;
listOaAttendance(this.queryParams).then(res => {
this.userList = res.rows || [];
this.loading = false;
}).catch(err => {
console.error('获取签到数据失败', err);
this.loading = false;
});
},
// 日期选择变化
onDateChange(e) {
const value = e.detail.value;
this.currentDate = value;
// 格式化显示
const [year, month] = value.split('-');
this.formattedDate = `${year}${month}`;
// 更新查询参数并重新加载数据
this.queryParams.selectTime = value + '-01';
this.getAttendanceList();
},
// 处理滚动事件
onScroll(e) {
this.scrollLeft = e.detail.scrollLeft;
},
// 获取单元格样式
getCellStyle(user, dayIndex) {
// 查找对应日期的考勤记录
const attendance = user.attendances
? user.attendances.find(item => item.attendanceDay === dayIndex)
: null;
if (attendance) {
// 根据不同状态返回不同样式
if (attendance.projectId === 0) {
return { backgroundColor: '#fdf6e4' }; // 出差
} else if (attendance.projectId === 1) {
return { backgroundColor: '#e3f2fd' }; // 请假
} else if (attendance.color) {
return { backgroundColor: attendance.color }; // 其他项目颜色
}
}
// 默认样式
return { backgroundColor: '#ffffff' };
},
// 获取考勤状态文本
getAttendanceStatusText(user, dayIndex) {
if (!user.attendances || user.attendances.length === 0) {
return '';
}
const attendance = user.attendances.find(item => item.attendanceDay === dayIndex);
if (!attendance) {
return '';
}
// 根据项目ID返回对应文本
if (attendance.projectId === 0) {
return '出差';
} else if (attendance.projectId === 1) {
return '请假';
}
return '';
}
}
};
</script>
<style scoped>
.container {
flex: 1;
padding: 16rpx;
background-color: #f5f5f5;
min-height: 100vh;
box-sizing: border-box;
}
/* 头部样式 */
.header {
display: flex;
flex-direction: column;
gap: 16rpx;
margin-bottom: 20rpx;
}
.title-bar {
padding: 10rpx 0;
}
.title {
font-size: 34rpx;
font-weight: bold;
color: #333;
}
.date-picker-container {
background-color: #fff;
border-radius: 8rpx;
padding: 16rpx;
box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.05);
}
.date-picker {
width: 100%;
}
.picker-view {
text-align: center;
font-size: 28rpx;
color: #007aff;
padding: 8rpx 0;
}
/* 加载状态样式 */
.loading-view {
display: flex;
flex-direction: column;
align-items: center;
padding: 60rpx 0;
}
.loading {
margin-bottom: 16rpx;
}
.loading-text {
font-size: 26rpx;
color: #666;
}
/* 表格样式 */
.table-scroll {
width: 100%;
margin-bottom: 20rpx;
background-color: #fff;
border-radius: 10rpx;
box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.05);
}
.table-container {
min-width: 100%;
display: inline-block;
}
.table-header {
display: flex;
background-color: #f8f9fa;
border-bottom: 1px solid #eee;
}
.table-body {
display: flex;
flex-direction: column;
}
.table-row {
display: flex;
border-bottom: 1px solid #eee;
}
.table-row:last-child {
border-bottom: none;
}
.odd-row {
background-color: #fafafa;
}
.table-cell {
display: flex;
align-items: center;
justify-content: center;
padding: 20rpx 0;
font-size: 24rpx;
border-right: 1px solid #eee;
box-sizing: border-box;
}
.table-cell:last-child {
border-right: none;
}
.name-cell {
min-width: 140rpx;
flex: 0 0 140rpx;
background-color: #f0f0f0;
font-weight: bold;
color: #333;
}
.day-cell {
min-width: 80rpx;
flex: 0 0 80rpx;
color: #666;
}
/* 图例样式 */
.legend-container {
display: flex;
padding: 16rpx;
background-color: #fff;
border-radius: 10rpx;
box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.05);
margin-bottom: 20rpx;
}
.legend-item {
display: flex;
align-items: center;
margin-right: 40rpx;
}
.legend-color {
width: 24rpx;
height: 24rpx;
margin-right: 10rpx;
border-radius: 4rpx;
}
.legend-text {
font-size: 24rpx;
color: #666;
}
</style>

View File

@@ -78,6 +78,12 @@ export default {
url: '/pages/workbench/express/express',
category: '车间管理'
},
{
text: '人员考勤',
icon: '/static/images/kaoqin.png',
url: '/pages/workbench/attendance/attendance',
category: '车间管理'
},
{
text: '项目中心',
icon: '/static/images/project.png',
@@ -101,8 +107,14 @@ export default {
icon: '/static/images/yingkui.png',
url: '/pages/workbench/profit/profit',
category: '财务中心',
access: ['vice', 'baomi', 'ceo'] // 需要特定权限才能访问
// access: ['vice', 'baomi', 'ceo'] // 需要特定权限才能访问
},
{
text: '智慧库房',
icon: '/static/images/smartStock.png',
url: '/pages/workbench/smartWM/smartWM',
category: '库房管理',
},
{
text: '线上营销',
icon: '/static/images/yingxiao.png',

View File

@@ -0,0 +1,465 @@
<template>
<view>
<!-- 排序栏 -->
<view class="sort-filter-bar">
<view
class="sort-item"
v-for="(sort, index) in sortOptions"
:key="index"
@click="handleSort(sort.field)"
>
<text
:class="{
'sort-text': true,
'active-sort': sort.field === queryParams.sortField,
}"
>
{{ sort.name }}
</text>
<template v-if="sort.hasArrow && sort.field === queryParams.sortField">
<uni-icons
:type="queryParams.sortOrder === 'asc' ? 'arrowup' : 'arrowdown'"
size="16"
color="#007aff"
></uni-icons>
<text class="sort-direction-text">
{{ queryParams.sortOrder === 'asc' ? '正序' : '倒序' }}
</text>
</template>
</view>
<view class="filter-btn" @click="showPopup">
<text class="filter-text">筛选</text>
<uni-icons type="bottom" size="16"></uni-icons>
</view>
</view>
<!-- 筛选弹窗 -->
<uni-popup
type="bottom"
ref="popup"
>
<view class="popup-content">
<view class="popup-title">筛选条件</view>
<uni-section title="项目信息" type="line" class="filter-section">
<view class="filter-item">
<text class="filter-label">项目名称</text>
<input
type="text"
v-model="queryParams.projectName"
placeholder="输入项目名称"
class="filter-input"
/>
</view>
<view class="filter-item">
<text class="filter-label">项目编号</text>
<input
type="text"
v-model="queryParams.projectNum"
placeholder="输入项目编号"
class="filter-input"
/>
</view>
</uni-section>
<uni-section title="项目状态" type="line" class="filter-section">
<view class="uni-px-5 uni-pb-5">
<uni-data-checkbox
v-model="radioProjectStatus"
:localdata="projectStatusOptions"
@change="handleStatusChange"
></uni-data-checkbox>
</view>
</uni-section>
<uni-section title="贸易属性" type="line" class="filter-section">
<view class="uni-px-5 uni-pb-5">
<uni-data-checkbox
v-model="radioDomestic"
:localdata="domesticOptions"
@change="handleDomesticChange"
></uni-data-checkbox>
</view>
</uni-section>
<uni-section title="金额筛选" type="line" class="filter-section">
<view class="filter-item">
<text class="filter-label">合同金额区间</text>
<input
type="number"
v-model="queryParams.minContractAmount"
placeholder="最小"
class="filter-input"
/>
<text class="range-text">-</text>
<input
type="number"
v-model="queryParams.maxContractAmount"
placeholder="最大"
class="filter-input"
/>
</view>
<view class="filter-item">
<text class="filter-label">盈亏金额区间</text>
<input
type="number"
v-model="queryParams.minProfitLoss"
placeholder="最小"
class="filter-input"
/>
<text class="range-text">-</text>
<input
type="number"
v-model="queryParams.maxProfitLoss"
placeholder="最大"
class="filter-input"
/>
</view>
</uni-section>
<uni-section title="时间筛选" type="line" class="filter-section">
<view class="filter-item">
<text class="filter-label">启动时间</text>
<uni-datetime-picker
type="daterange"
v-model="dateRange"
start-placeholder="开始日期"
end-placeholder="结束日期"
@change="handleDateChange"
></uni-datetime-picker>
</view>
</uni-section>
<uni-section title="盈亏类型" type="line" class="filter-section">
<view class="uni-px-5 uni-pb-5">
<uni-data-checkbox
v-model="radioProfitType"
:localdata="profitTypeOptions"
@change="handleProfitTypeChange"
></uni-data-checkbox>
</view>
</uni-section>
<view class="popup-btns">
<button class="btn-reset" @click="resetFilter">重置</button>
<button class="btn-confirm" @click="confirmFilter">确定</button>
</view>
</view>
</uni-popup>
</view>
</template>
<script>
export default {
data() {
return {
showFilter: false,
dateRange: [],
dateRangeText: '',
// 单选框绑定值(非数组类型,用于单选)
radioProjectStatus: '', // 项目状态单选值
radioDomestic: '', // 贸易属性单选值
radioProfitType: '', // 盈亏类型单选值
queryParams: {
projectName: '',
projectNum: '',
projectStatus: '', // 保持字符串类型(单选)
isDomestic: '', // 保持字符串类型(单选)
minContractAmount: '',
maxContractAmount: '',
minProfitLoss: '',
maxProfitLoss: '',
beginTimeStart: '',
beginTimeEnd: '',
profitType: '', // 保持字符串类型(单选)
sortField: 'profitLoss',
sortOrder: 'desc', // 默认倒序
pageSize: 9999,
pageNum: 1
},
// 排序选项
sortOptions: [
{ name: '盈亏额', field: 'profitLoss', hasArrow: true },
{ name: '启动时间', field: 'beginTime', hasArrow: true },
],
// 项目状态选项(包含"全部"
projectStatusOptions: [
{ text: '全部状态', value: '' },
{ text: '进行中', value: '0' },
{ text: '完结', value: '1' },
],
// 国内/国外选项(包含"全部"
domesticOptions: [
{ text: '全部', value: '' },
{ text: '国内', value: '0' },
{ text: '国外', value: '1' },
],
// 盈亏类型选项(包含"全部"
profitTypeOptions: [
{ text: '全部类型', value: '' },
{ text: '盈利', value: 'profit' },
{ text: '亏损', value: 'loss' },
],
};
},
methods: {
// 处理日期范围变化
handleDateChange(e) {
this.dateRange = e;
if (e.length === 2) {
this.queryParams.beginTimeStart = e[0];
this.queryParams.beginTimeEnd = e[1];
this.dateRangeText = `${e[0]} - ${e[1]}`;
} else {
this.queryParams.beginTimeStart = '';
this.queryParams.beginTimeEnd = '';
this.dateRangeText = '';
}
},
// 重置筛选条件
resetFilter() {
this.queryParams = {
...this.queryParams,
projectName: '',
projectNum: '',
projectStatus: '',
profitType: '',
beginTimeStart: '',
beginTimeEnd: '',
minContractAmount: '',
maxContractAmount: '',
minProfitLoss: '',
maxProfitLoss: '',
isDomestic: '',
};
// 重置单选框绑定值
this.radioProjectStatus = '';
this.radioDomestic = '';
this.radioProfitType = '';
this.dateRange = [];
this.dateRangeText = '';
},
// 确认筛选条件
confirmFilter() {
this.$refs.popup.close();
this.$emit('filter-change', { ...this.queryParams });
},
// 处理排序
handleSort(field) {
if (this.queryParams.sortField === field) {
this.queryParams.sortOrder = this.queryParams.sortOrder === 'asc' ? 'desc' : 'asc';
} else {
this.queryParams.sortField = field;
this.queryParams.sortOrder = 'desc';
}
this.$emit('filter-change', { ...this.queryParams });
},
// 处理项目状态变化(单选)
handleStatusChange(value) {
console.log(value)
this.queryParams.projectStatus = value.detail.value;
},
// 处理国内/国外状态变化(单选)
handleDomesticChange(value) {
console.log(value)
this.queryParams.tradeType = value.detail.value;
},
// 处理盈亏类型变化(单选)
handleProfitTypeChange(value) {
console.log(value)
this.queryParams.profitType = value.detail.value;
},
// 显示筛选弹窗
showPopup() {
this.$refs.popup.open();
},
},
};
</script>
<style scoped>
/* 排序和筛选栏样式 */
.sort-filter-bar {
display: flex;
align-items: center;
height: 40px;
background-color: #fff;
border-bottom: 1px solid #eee;
overflow-x: auto;
white-space: nowrap;
padding: 0 10px;
}
.sort-filter-bar::-webkit-scrollbar {
display: none; /* 隐藏滚动条 */
}
.sort-item {
display: flex;
align-items: center;
padding: 0 12px;
height: 100%;
font-size: 14px;
color: #333;
cursor: pointer;
}
.sort-item:active {
background-color: #f5f5f5;
}
.active-sort {
color: #007aff;
font-weight: bold;
}
.sort-direction-text {
margin-left: 4px;
font-size: 12px;
color: #007aff;
}
.filter-btn {
display: flex;
align-items: center;
padding: 0 12px;
height: 100%;
font-size: 14px;
color: #333;
cursor: pointer;
margin-left: auto; /* 推到最右侧 */
}
.filter-btn:active {
background-color: #f5f5f5;
}
/* 筛选弹窗样式 */
.popup-content {
background-color: #fff;
border-top-left-radius: 16px;
border-top-right-radius: 16px;
padding-bottom: 20px;
overflow-y: auto;
height: 100%;
}
.popup-title {
padding: 15px;
font-size: 16px;
font-weight: bold;
border-bottom: 1px solid #eee;
position: relative;
text-align: center;
}
.popup-title::after {
content: '';
position: absolute;
bottom: -1px;
left: 50%;
transform: translateX(-50%);
width: 40px;
height: 3px;
background-color: #007aff;
}
.filter-section {
margin-bottom: 10px;
}
.filter-item {
margin-bottom: 15px;
display: flex;
align-items: center;
padding: 0 15px;
}
.filter-label {
font-size: 14px;
color: #666;
width: 100px;
flex-shrink: 0;
}
.filter-input {
flex: 1;
border: 1px solid #eee;
border-radius: 4px;
padding: 8px 10px;
font-size: 14px;
height: 36px;
box-sizing: border-box;
}
.filter-input:focus {
border-color: #007aff;
outline: none;
}
.range-text {
margin: 0 8px;
color: #999;
}
/* 弹窗按钮样式 */
.popup-btns {
display: flex;
padding: 10px 15px;
border-top: 1px solid #eee;
margin-top: 10px;
}
.btn-reset,
.btn-confirm {
flex: 1;
height: 40px;
line-height: 40px;
border-radius: 6px;
font-size: 16px;
border: none;
cursor: pointer;
}
.btn-reset {
background-color: #f5f5f5;
color: #333;
margin-right: 10px;
}
.btn-confirm {
background-color: #007aff;
color: #fff;
}
/* 解决uni组件样式冲突 */
::v-deep .uni-data-checkbox {
display: flex;
flex-wrap: wrap;
gap: 10px;
padding: 5px 0;
}
::v-deep .uni-data-checkbox .uni-checkbox-item {
margin-right: 15px;
}
::v-deep .uni-datetime-picker {
flex: 1;
}
::v-deep .uni-popup {
z-index: 999;
}
::v-deep .uni-section__content {
padding: 5px 0;
}
</style>

View File

@@ -0,0 +1,341 @@
<template>
<view class="container">
<!-- 列表内容区域 -->
<view class="list-container">
<uni-skeleton
v-if="loading"
:row="5"
:loading="loading"
title
avatar
></uni-skeleton>
<view v-else-if="profitList.length === 0" class="empty-view">
<uni-icons type="empty" size="60" color="#ccc"></uni-icons>
<text class="empty-text">暂无数据</text>
</view>
<view class="project-card" v-for="(item, index) in profitList" :key="index">
<view class="card-header">
<view class="header-left">
<text class="project-name">{{ item.projectName }}</text>
<text class="project-num">{{ item.projectNum }}</text>
</view>
<uni-tag
:text="item.projectStatus === '0' ? '进行中' : '完结'"
:type="item.projectStatus === '0' ? 'success' : 'primary'"
size="small"
></uni-tag>
</view>
<view class="card-body">
<view class="info-row">
<text class="info-label">贸易类型</text>
<text class="info-value">{{ getTradeTypeName(item.tradeType) }}</text>
</view>
<view class="info-row">
<text class="info-label">合同金额</text>
<text class="info-value">{{ item.originalFunds || item.detailIncome }}</text>
</view>
<view class="info-row">
<text class="info-label">人民币金额</text>
<text class="info-value">¥{{ item.totalIncomeCny }}</text>
</view>
<view class="info-row">
<text class="info-label">启动时间</text>
<text class="info-value">{{ item.beginTime }}</text>
</view>
</view>
<view class="card-footer">
<view class="profit-info" :style="getProfitLossStyle(item)">
<text class="profit-label">盈亏金额</text>
<text class="profit-value">{{ parseFloat(item.profitLoss || 0).toFixed(2) }}</text>
</view>
<uni-tag
v-if="getProfitRate(item) !== null"
:text="getProfitRateTag(item)"
:type="getProfitRateType(item)"
size="small"
></uni-tag>
</view>
</view>
</view>
<!-- 分页组件 -->
<uni-pagination
v-if="total > 0"
:total="total"
:pageSize="pagination.pageSize"
:current="pagination.pageNum"
@change="onPageChange"
mode="number"
show-icon
style="margin: 20px auto;"
></uni-pagination>
</view>
</template>
<script>
import { listProfit } from '@/api/oa/finance/profit';
export default {
props: {
// 接收从父组件传递的筛选参数
filterParams: {
type: Object,
default: () => ({})
}
},
data() {
return {
loading: false,
profitList: [],
total: 0,
// 分页参数
pagination: {
pageNum: 1,
pageSize: 10
},
// 盈亏阈值配置
profitThresholds: {
highProfit: 100000, // 高盈利阈值
highLoss: -50000, // 高亏损阈值
warningProfit: 50000, // 警告盈利阈值
warningLoss: -20000 // 警告亏损阈值
},
// 贸易类型字典
tradeTypeDict: [
{ value: 1, label: '外贸' },
{ value: 0, label: '内贸' },
]
};
},
watch: {
// 监听筛选参数变化,重新加载数据
filterParams: {
deep: true,
handler() {
// 筛选条件变化时重置页码
this.pagination.pageNum = 1;
this.getList();
}
}
},
methods: {
// 获取列表数据
getList() {
this.loading = true;
// 合并筛选参数和分页参数
const params = {
...this.filterParams,
...this.pagination
};
listProfit(params)
.then((res) => {
this.profitList = res.rows || [];
this.total = res.total || 0;
this.loading = false;
})
.catch(() => {
this.loading = false;
uni.showToast({
title: '加载失败',
icon: 'none',
});
});
},
// 分页变化
onPageChange(e) {
this.pagination.pageNum = e.current;
this.pagination.pageSize = e.size;
this.getList();
},
// 盈亏相关计算
getProfitRate(row) {
// 计算盈亏百分比
const base = row.originalFunds && row.originalFunds !== 0
? row.originalFunds
: row.detailIncome;
if (!base || base === 0) return null;
return row.profitLoss / base;
},
getProfitRateTag(row) {
const rate = this.getProfitRate(row);
if (rate === null) return '-';
if (rate >= 0.2) return '高盈利';
if (rate <= -0.2) return '高亏损';
if (rate < 0) return '亏损';
if (rate >= 0 && rate <= 0.05) return '低盈利';
return '盈利';
},
getProfitRateType(row) {
const rate = this.getProfitRate(row);
if (rate === null) return 'default';
if (rate >= 0.2) return 'success';
if (rate <= -0.2) return 'error';
if (rate < 0) return 'warning';
return rate >= 0 && rate <= 0.05 ? 'info' : 'success';
},
getProfitLossStyle(row) {
const rate = this.getProfitRate(row);
if (rate === null) return {};
if (rate >= 0.2) {
return {
color: '#67C23A',
fontWeight: 'bold',
};
} else if (rate <= -0.2) {
return {
color: '#F56C6C',
fontWeight: 'bold',
};
} else if (rate < 0) {
return {
color: '#F56C6C',
};
} else if (rate >= 0 && rate <= 0.05) {
return {
color: '#E6A23C',
};
} else {
return { color: '#67C23A' };
}
},
// 获取贸易类型名称
getTradeTypeName(value) {
const item = this.tradeTypeDict.find(item => item.value === value);
return item ? item.label : value;
}
},
// 组件挂载时加载数据
mounted() {
this.getList();
}
};
</script>
<style scoped>
.container {
flex: 1;
flex-direction: column;
background-color: #f5f5f5;
min-height: 100vh;
}
/* 列表样式 */
.list-container {
padding: 10px;
}
.project-card {
background-color: #fff;
border-radius: 8px;
padding: 15px;
margin-bottom: 10px;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}
.card-header {
display: flex;
justify-content: space-between;
align-items: flex-start;
margin-bottom: 10px;
}
.header-left {
flex: 1;
}
.project-name {
font-size: 16px;
font-weight: bold;
display: block;
margin-bottom: 5px;
color: #333;
}
.project-num {
font-size: 12px;
color: #666;
}
.card-body {
margin-bottom: 10px;
}
.info-row {
display: flex;
margin-bottom: 8px;
font-size: 14px;
}
.info-label {
color: #666;
width: 80px;
flex-shrink: 0;
}
.info-value {
flex: 1;
color: #333;
}
.card-footer {
display: flex;
justify-content: space-between;
align-items: center;
padding-top: 10px;
border-top: 1px dashed #eee;
}
.profit-info {
display: flex;
align-items: center;
}
.profit-label {
color: #666;
margin-right: 5px;
}
.profit-value {
font-weight: bold;
}
/* 空状态 */
.empty-view {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
padding: 50px 0;
}
.empty-text {
color: #999;
margin-top: 10px;
font-size: 14px;
}
/* 解决uni组件样式冲突 */
::v-deep .uni-tag {
margin-top: 2px;
}
::v-deep .uni-pagination {
text-align: center;
}
</style>

View File

@@ -1,489 +1,28 @@
<template>
<view class="container">
<!-- 查询和排序区域 -->
<view class="">
<view class="">
<!-- 查询条件 -->
</view>
<uni-icons></uni-icons>
</view>
<view class="">
<!-- 排序规则 -->
</view>
<!-- 列表内容区域 -->
<view class="list-container">
<uni-skeleton
v-if="loading"
:row="5"
:loading="loading"
title
avatar
></uni-skeleton>
<view v-else-if="profitList.length === 0" class="empty-view">
<uni-icons type="empty" size="60" color="#ccc"></uni-icons>
<text class="empty-text">暂无数据</text>
</view>
<view
class="project-card"
v-for="(item, index) in profitList"
:key="index"
>
<view class="card-header">
<view class="header-left">
<text class="project-name">{{ item.projectName }}</text>
<text class="project-num">{{ item.projectNum }}</text>
</view>
<uni-tag
:text="item.projectStatus === '0' ? '进行中' : '完结'"
:type="item.projectStatus === '0' ? 'success' : 'primary'"
size="small"
></uni-tag>
</view>
<view class="card-body">
<view class="info-row">
<text class="info-label">贸易类型</text>
<text class="info-value">{{ getTradeTypeName(item.tradeType) }}</text>
</view>
<view class="info-row">
<text class="info-label">合同金额</text>
<text class="info-value">{{ item.originalFunds || item.detailIncome }}</text>
</view>
<view class="info-row">
<text class="info-label">人民币金额</text>
<text class="info-value">¥{{ item.totalIncomeCny }}</text>
</view>
<view class="info-row">
<text class="info-label">启动时间</text>
<text class="info-value">{{ item.beginTime }}</text>
</view>
</view>
<view class="card-footer">
<view class="profit-info" :style="getProfitLossStyle(item)">
<text class="profit-label">盈亏金额</text>
<text class="profit-value">{{ parseFloat(item.profitLoss || 0).toFixed(2) }}</text>
</view>
<uni-tag
v-if="getProfitRate(item) !== null"
:text="getProfitRateTag(item)"
:type="getProfitRateType(item)"
size="small"
></uni-tag>
</view>
</view>
</view>
<view>
<profit-filter @filter-change="handleFilterChange"></profit-filter>
<profit-list :filterParams="currentFilterParams"></profit-list>
</view>
</template>
<script>
import { listProfit } from '@/api/oa/finance/profit';
import ProfitFilter from './components/ProfitFilter.vue'
import ProfitList from './components/ProfitList.vue'
export default {
components: {
ProfitFilter,
ProfitList
},
data() {
return {
loading: false,
profitList: [],
total: 0,
showFilter: false,
showSort: false,
showColumns: false,
dateRangeText: '',
// 盈亏阈值配置
profitThresholds: {
highProfit: 100000, // 高盈利阈值
highLoss: -50000, // 高亏损阈值
warningProfit: 50000, // 警告盈利阈值
warningLoss: -20000 // 警告亏损阈值
},
queryParams: {
projectName: '',
projectNum: '',
projectStatus: '',
isDomestic: '',
minContractAmount: '',
maxContractAmount: '',
minProfitLoss: '',
maxProfitLoss: '',
beginTimeStart: '',
beginTimeEnd: '',
profitType: '',
sortField: '',
sortOrder: 'desc',
pageNum: 1,
pageSize: 9999,
projectCode: '',
tradeType: '',
},
// 贸易类型字典
tradeTypeDict: [
{ value: 1, label: '外贸' },
{ value: 0, label: '内贸' },
]
};
currentFilterParams: {}
}
},
onLoad() {
this.getList();
},
methods: {
getList() {
this.loading = true;
listProfit(this.queryParams).then(res => {
this.profitList = res.rows || [];
this.total = res.total || 0;
this.loading = false;
}).catch(() => {
this.loading = false;
uni.showToast({
title: '加载失败',
icon: 'none'
});
});
},
handleQuery() {
this.queryParams.pageNum = 1;
this.getList();
},
// 筛选相关方法
onDateChange(e) {
if (e.length === 2) {
this.queryParams.beginTimeStart = e[0];
this.queryParams.beginTimeEnd = e[1];
this.dateRangeText = `${e[0]} - ${e[1]}`;
} else {
this.queryParams.beginTimeStart = '';
this.queryParams.beginTimeEnd = '';
this.dateRangeText = '';
}
},
resetFilter() {
this.queryParams = {
...this.queryParams,
projectName: '',
projectNum: '',
projectStatus: '',
profitType: '',
beginTimeStart: '',
beginTimeEnd: '',
tradeType: ''
};
this.dateRangeText = '';
},
confirmFilter() {
this.showFilter = false;
this.handleQuery();
},
// 排序相关方法
setSort(field) {
this.queryParams.sortField = field;
this.handleQuery();
},
// 列显示控制
handleColumnChange() {
// 无需额外操作,数据驱动视图
},
// 分页相关
onPageChange(e) {
this.queryParams.pageNum = e.current;
this.queryParams.pageSize = e.pageSize;
this.getList();
},
// 盈亏相关计算
getProfitRate(row) {
// 计算盈亏百分比
const base = row.originalFunds && row.originalFunds !== 0 ? row.originalFunds : row.detailIncome;
if (!base || base === 0) return null;
return row.profitLoss / base;
},
getProfitRateTag(row) {
const rate = this.getProfitRate(row);
if (rate === null) return '-';
if (rate >= 0.2) return '高盈利';
if (rate <= -0.2) return '高亏损';
if (rate < 0) return '亏损';
if (rate >= 0 && rate <= 0.05) return '低盈利';
return '盈利';
},
getProfitRateType(row) {
const rate = this.getProfitRate(row);
if (rate === null) return 'default';
if (rate >= 0.2) return 'success';
if (rate <= -0.2) return 'error';
if (rate < 0) return 'warning';
return rate >= 0 && rate <= 0.05 ? 'info' : 'success';
},
getProfitLossStyle(row) {
const rate = this.getProfitRate(row);
if (rate === null) return {};
if (rate >= 0.2) {
return {
color: '#67C23A',
fontWeight: 'bold'
};
} else if (rate <= -0.2) {
return {
color: '#F56C6C',
fontWeight: 'bold'
};
} else if (rate < 0) {
return {
color: '#F56C6C'
};
} else if (rate >= 0 && rate <= 0.05) {
return {
color: '#E6A23C'
};
} else {
return { color: '#67C23A' };
}
},
// 获取贸易类型名称
getTradeTypeName(value) {
const item = this.tradeTypeDict.find(item => item.value === value);
return item ? item.label : value;
handleFilterChange(params) {
this.currentFilterParams = params
}
}
};
</script>
<style scoped>
.container {
flex: 1;
flex-direction: column;
background-color: #f5f5f5;
min-height: 100vh;
}
.navbar {
display: flex;
justify-content: space-between;
align-items: center;
height: 44px;
background-color: #007aff;
padding: 0 15px;
}
.title {
color: #fff;
font-size: 18px;
font-weight: bold;
}
.right-ops {
display: flex;
}
.btn-icon {
width: 40px;
height: 40px;
display: flex;
align-items: center;
justify-content: center;
background: transparent;
border: none;
padding: 0;
margin-left: 5px;
}
/* 弹窗样式 */
.popup-title {
padding: 15px;
font-size: 16px;
font-weight: bold;
border-bottom: 1px solid #eee;
}
.popup-content {
padding: 15px;
height: calc(100% - 120px);
}
.form-item {
margin-bottom: 15px;
display: flex;
flex-direction: column;
}
.form-label {
font-size: 14px;
color: #666;
margin-bottom: 5px;
}
.popup-btns {
display: flex;
padding: 10px;
border-top: 1px solid #eee;
}
.btn-reset, .btn-confirm {
flex: 1;
height: 40px;
line-height: 40px;
border-radius: 6px;
font-size: 16px;
}
.btn-reset {
background-color: #f5f5f5;
color: #333;
margin-right: 10px;
}
.btn-confirm {
background-color: #007aff;
color: #fff;
}
/* 排序弹窗样式 */
.sort-item {
padding: 15px;
display: flex;
justify-content: space-between;
align-items: center;
border-bottom: 1px solid #eee;
}
.sort-direction {
padding: 15px;
display: flex;
align-items: center;
}
.direction-btn {
margin-left: 10px;
padding: 5px 10px;
border-radius: 4px;
font-size: 14px;
}
.direction-btn.active {
background-color: #007aff;
color: #fff;
}
/* 列设置弹窗 */
.column-item {
padding: 15px;
display: flex;
justify-content: space-between;
align-items: center;
border-bottom: 1px solid #eee;
}
/* 列表样式 */
.list-container {
padding: 10px;
}
.project-card {
background-color: #fff;
border-radius: 8px;
padding: 15px;
margin-bottom: 10px;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}
.card-header {
display: flex;
justify-content: space-between;
align-items: flex-start;
margin-bottom: 10px;
}
.header-left {
flex: 1;
}
.project-name {
font-size: 16px;
font-weight: bold;
display: block;
margin-bottom: 5px;
}
.project-num {
font-size: 12px;
color: #666;
}
.card-body {
margin-bottom: 10px;
}
.info-row {
display: flex;
margin-bottom: 8px;
font-size: 14px;
}
.info-label {
color: #666;
width: 80px;
}
.info-value {
flex: 1;
}
.card-footer {
display: flex;
justify-content: space-between;
align-items: center;
padding-top: 10px;
border-top: 1px dashed #eee;
}
.profit-info {
display: flex;
align-items: center;
}
.profit-label {
color: #666;
margin-right: 5px;
}
.profit-value {
font-weight: bold;
}
/* 空状态 */
.empty-view {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
padding: 50px 0;
}
.empty-text {
color: #999;
margin-top: 10px;
font-size: 14px;
}
</style>
</script>

View File

@@ -0,0 +1,102 @@
<template>
<view class="charts-box">
<qiun-data-charts
type="column"
:chartData="chartData"
:opts="chartOpts"
/>
</view>
</template>
<script>
import { monthDataAnalysis } from "@/api/oa/wms/oaWarehouse";
export default {
data() {
return {
// 图表数据符合uCharts格式
chartData: {
categories: [], // 月份
series: [] // 入库量、出库量数据
},
// 图表配置项
chartOpts: {
legend: true, // 显示图例
dataLabel: false, // 不显示数据标签
column: {
type: "group" // 分组柱状图
},
xAxis: {
fontColor: "#666",
fontSize: 12
},
yAxis: {
fontColor: "#666",
fontSize: 12,
gridColor: "#eee"
},
color: ["#007aff", "#ff9500"] // 入库、出库颜色
}
};
},
mounted() {
// 页面就绪后获取数据
this.getServerData();
},
methods: {
getServerData() {
// 显示加载提示
uni.showLoading({
title: '加载数据中...',
mask: true
});
// 调用接口获取数据(当前年份作为参数)
const currentYear = new Date().getFullYear() + '-01';
monthDataAnalysis({ month: currentYear }).then(res => {
// 隐藏加载提示
uni.hideLoading();
// 格式化接口数据为uCharts所需格式
this.chartData = {
categories: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月'],
series: [
{
name: "入库量",
data: res.data.inData["月"] || [] // 从接口取入库数据
},
{
name: "出库量",
data: res.data.outData["月"] || [] // 从接口取出库数据
}
]
};
}).catch(err => {
// 隐藏加载提示
uni.hideLoading();
// 错误处理
uni.showToast({
title: '数据加载失败',
icon: 'none',
duration: 2000
});
console.error('获取出入库数据失败:', err);
});
}
}
};
</script>
<style scoped>
.charts-box {
width: 100%;
height: 300px; /* 固定图表高度,适配手机屏幕 */
padding: 16rpx;
box-sizing: border-box;
background-color: #fff;
border-radius: 12rpx;
box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.05);
margin-bottom: 20rpx;
}
</style>

View File

@@ -0,0 +1,142 @@
<template>
<view class="charts-box">
<qiun-data-charts
type="line"
:chartData="chartData"
:opts="chartOpts"
/>
</view>
</template>
<script>
import { monthDataAnalysis } from "@/api/oa/wms/oaWarehouse";
export default {
name: 'InventoryTrend',
// 接收父组件传入的日期参数YYYY-mm格式
props: {
date: {
type: String,
required: true,
validator: function(value) {
// 验证格式是否为YYYY-mm
const reg = /^\d{4}-\d{2}$/;
return reg.test(value);
}
}
},
data() {
return {
// 图表数据
chartData: {
categories: [], // 日期1日-当前日或当月总天数)
series: [] // 库存趋势数据
},
// 图表配置
chartOpts: {
legend: false,
dataLabel: false,
line: {
smooth: true,
type: "straight"
},
xAxis: {
fontColor: "#666",
fontSize: 12,
rotateLabel: true
},
yAxis: {
fontColor: "#666",
fontSize: 12,
gridColor: "#eee"
},
color: ["#00cc66"],
padding: [15, 15, 30, 15]
}
};
},
// 监听日期变化,重新加载数据
watch: {
date: {
immediate: true, // 初始化时立即执行
handler(newVal) {
this.getData(newVal);
}
}
},
methods: {
getData(selectedDate) {
// 显示加载提示
uni.showLoading({
title: '加载数据中...',
mask: true
});
// 从选中日期中提取年份(根据接口需求调整参数)
const year = selectedDate;
monthDataAnalysis({ month: year }).then(res => {
// 隐藏加载提示
uni.hideLoading();
// 解析选中的年月
const [year, month] = selectedDate.split('-').map(Number);
// 计算当月总天数
const daysInMonth = new Date(year, month, 0).getDate();
// 计算当前日期是否在选中月份内
const today = new Date();
const currentYear = today.getFullYear();
const currentMonth = today.getMonth() + 1;
// 确定需要显示的天数(如果是当前月则显示到今天,否则显示整月)
const daysToShow = (year === currentYear && month === currentMonth)
? today.getDate()
: daysInMonth;
// 生成日期类别
const dayCategories = Array.from(
{ length: daysToShow },
(_, i) => `${i + 1}`
);
// 格式化数据
this.chartData = {
categories: dayCategories,
series: [
{
name: "库存趋势",
data: res.data.dataMap["日"] || []
}
]
};
}).catch(err => {
// 隐藏加载提示
uni.hideLoading();
// 错误处理
uni.showToast({
title: '数据加载失败',
icon: 'none',
duration: 2000
});
console.error('获取库存趋势数据失败:', err);
});
}
}
};
</script>
<style scoped>
.charts-box {
width: 100%;
height: 300px;
padding: 16rpx;
box-sizing: border-box;
background-color: #fff;
border-radius: 12rpx;
box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.05);
margin-bottom: 20rpx;
}
</style>

View File

@@ -0,0 +1,179 @@
<template>
<view class="recent-records-container">
<view class="table-header">
<text class="title">最近记录</text>
</view>
<scroll-view
scroll-x="true"
class="table-scroll"
show-scrollbar="false"
>
<view class="table-wrapper">
<!-- 表头 -->
<view class="table-row header-row">
<view class="table-cell">物料名称</view>
<view class="table-cell">型号</view>
<view class="table-cell">当前库存</view>
<view class="table-cell">安全库存</view>
<view class="table-cell">在途数量</view>
<view class="table-cell">库存状态</view>
</view>
<!-- 表体 -->
<view
class="table-row"
v-for="(item, index) in tableData"
:key="index"
:class="{ 'odd-row': index % 2 === 1 }"
>
<view class="table-cell">{{ item.name }}</view>
<view class="table-cell">{{ item.model }}</view>
<view class="table-cell">{{ item.inventory }}</view>
<view class="table-cell">{{ item.threshold }}</view>
<view class="table-cell">{{ item.taskInventory }}</view>
<view class="table-cell">
<view
class="status-tag"
:class="calcInventoryStatus(item.inventory, item.taskInventory, item.threshold).type"
>
{{ calcInventoryStatus(item.inventory, item.taskInventory, item.threshold).status }}
</view>
</view>
</view>
<!-- 空状态 -->
<view v-if="tableData.length === 0" class="empty-state">
<uni-icons type="empty" size="60" color="#cccccc"></uni-icons>
<text class="empty-text">暂无记录</text>
</view>
</view>
</scroll-view>
</view>
</template>
<script>
export default {
name: 'RecentRecords',
props: {
// 接收表格数据
tableData: {
type: Array,
default: () => []
}
},
methods: {
// 计算库存状态
calcInventoryStatus(inventory, inTransit, threshold) {
const total = inventory + inTransit;
if (total > threshold + 10) {
return { status: '库存积压', type: 'warning' };
} else if (total > threshold) {
return { status: '正常', type: 'success' };
} else if (total <= threshold && total > threshold - 2) {
return { status: '库存预警', type: 'danger' };
} else {
return { status: '库存不足', type: 'info' };
}
}
}
};
</script>
<style scoped>
.recent-records-container {
width: 100%;
background-color: #ffffff;
border-radius: 12rpx;
box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.05);
overflow: hidden;
}
.table-header {
padding: 20rpx 16rpx;
border-bottom: 1px solid #f5f5f5;
}
.title {
font-size: 28rpx;
font-weight: bold;
color: #333333;
}
.table-scroll {
width: 100%;
}
.table-wrapper {
width: 100%;
min-width: 900rpx; /* 确保表格有足够宽度展示内容 */
}
.table-row {
display: flex;
width: 100%;
border-bottom: 1px solid #f5f5f5;
}
.table-row:last-child {
border-bottom: none;
}
.header-row {
background-color: #f9f9f9;
}
.odd-row {
background-color: #fafafa;
}
.table-cell {
flex: 1;
padding: 20rpx 10rpx;
font-size: 24rpx;
color: #666666;
text-align: center;
word-break: break-all;
display: flex;
align-items: center;
justify-content: center;
}
.status-tag {
padding: 4rpx 12rpx;
border-radius: 14rpx;
font-size: 22rpx;
color: #ffffff;
}
.status-tag.success {
background-color: #00b42a;
}
.status-tag.warning {
background-color: #ff7d00;
}
.status-tag.danger {
background-color: #f53f3f;
}
.status-tag.info {
background-color: #86909c;
}
.empty-state {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
padding: 80rpx 0;
}
.empty-text {
font-size: 26rpx;
color: #999999;
margin-top: 20rpx;
}
</style>

View File

@@ -0,0 +1,119 @@
<template>
<view class="summary-cards-container">
<scroll-view
scroll-x="true"
class="cards-scroll"
show-scrollbar="false"
>
<view class="cards-wrapper">
<view
class="summary-card"
v-for="(card, index) in cardsData"
:key="index"
>
<view class="card-title">{{ card.title }}</view>
<view class="card-value">{{ formatNumber(card.value) }}</view>
<view
class="card-trend"
:class="{ 'trend-up': card.trend > 0, 'trend-down': card.trend < 0, 'trend-flat': card.trend === 0 }"
>
<text v-if="card.trend !== 0">
<uni-icons
:type="card.trend > 0 ? 'arrowup' : 'arrowdown'"
size="16"
></uni-icons>
{{ Math.abs(card.trend) }}%
{{ card.trend > 0 ? '环比上月' : '环比昨日' }}
</text>
<text v-else>持平</text>
</view>
</view>
</view>
</scroll-view>
</view>
</template>
<script>
export default {
name: 'SummaryCards',
props: {
// 接收卡片数据,格式为数组对象
cardsData: {
type: Array,
default: () => [
{ title: '当前总库存量', value: 0, trend: 0 },
{ title: '在途物料数量', value: 0, trend: 0 },
{ title: '今日入库量', value: 0, trend: 0 },
{ title: '今日出库量', value: 0, trend: 0 },
{ title: '预警信息', value: 0, trend: 0 }
]
}
},
methods: {
// 格式化数字,添加千位分隔符
formatNumber(num) {
return num.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',');
}
}
};
</script>
<style scoped>
.summary-cards-container {
width: 100%;
margin-bottom: 20rpx;
}
.cards-scroll {
width: 100%;
white-space: nowrap;
padding: 10rpx 0;
}
.cards-wrapper {
display: inline-flex;
gap: 16rpx;
padding: 0 16rpx;
}
.summary-card {
min-width: 240rpx;
background-color: #ffffff;
border-radius: 12rpx;
padding: 20rpx;
box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.05);
}
.card-title {
font-size: 26rpx;
color: #666666;
margin-bottom: 10rpx;
}
.card-value {
font-size: 34rpx;
font-weight: bold;
color: #333333;
margin-bottom: 8rpx;
}
.card-trend {
font-size: 22rpx;
display: flex;
align-items: center;
justify-content: center;
gap: 4rpx;
}
.trend-up {
color: #00b42a;
}
.trend-down {
color: #f53f3f;
}
.trend-flat {
color: #888888;
}
</style>

View File

@@ -0,0 +1,201 @@
<template>
<view class="container">
<!-- 加载状态 -->
<view v-if="loading" class="loading-view">
<uni-loading-icon size="24" color="#007aff"></uni-loading-icon>
<text class="loading-text">加载中...</text>
</view>
<!-- 内容区域加载完成后显示 -->
<view v-else>
<!-- 1. 指标卡组件 - 折叠卡片 -->
<fad-collapse title="指标汇总">
<summary-cards-vue :cards-data="summaryCards"></summary-cards-vue>
</fad-collapse>
<!-- 2. 出入库对比图表 - 折叠卡片 -->
<fad-collapse title="出入库对比分析">
<in-out-compare-vue class="chart-item"></in-out-compare-vue>
</fad-collapse>
<!-- 3. 库存趋势图表 - 折叠卡片日期选择器作为额外内容 -->
<fad-collapse title="库存趋势分析">
<!-- 标题右侧额外内容日期选择器 -->
<template #extra>
<picker mode="date" fields="month" :value="selectedDate" @change="onDateChange">
<view class="picker-view">
<uni-icons type="calendar" size="20" color="#666" class="icon-margin"></uni-icons>
<text>{{ selectedDate }}</text>
</view>
</picker>
</template>
<!-- 折叠内容库存趋势图表 -->
<inventory-trend-vue class="chart-item" :date="selectedDate"></inventory-trend-vue>
</fad-collapse>
<!-- 4. 表格组件 - 折叠卡片 -->
<fad-collapse title="最近库存记录">
<recent-records-vue :table-data="tableData"></recent-records-vue>
</fad-collapse>
</view>
</view>
</template>
<script>
import SummaryCardsVue from './components/SummaryCards.vue';
import RecentRecordsVue from './components/RecentRecords.vue';
import InOutCompareVue from './components/InOutCompare.vue';
import InventoryTrendVue from './components/InventoryTrend.vue';
import {
getSummaryData,
recentWarehouse
} from '@/api/oa/wms/oaWarehouse';
export default {
data() {
return {
// 加载状态标记
loading: true,
// 指标卡数据
summaryCards: [],
// 表格数据
tableData: [],
// 选中的日期YYYY-mm格式
selectedDate: ''
};
},
components: {
SummaryCardsVue,
RecentRecordsVue,
InOutCompareVue,
InventoryTrendVue
},
onLoad() {
// 初始化默认日期为当前月份
this.selectedDate = this.formatCurrentDate();
// 页面加载时获取数据
this.fetchAllData();
},
methods: {
// 格式化当前日期为YYYY-mm
formatCurrentDate() {
const date = new Date();
const year = date.getFullYear();
const month = (date.getMonth() + 1).toString().padStart(2, '0');
return `${year}-${month}`;
},
// 处理日期选择变化
onDateChange(e) {
this.selectedDate = e.detail.value;
},
// 统一获取所有数据
fetchAllData() {
this.loading = true;
// 并行请求多个接口(提高效率)
Promise.all([
this.fetchSummaryData(),
this.fetchTableData()
]).then(() => {
// 所有数据加载完成
this.loading = false;
}).catch(err => {
console.error('数据加载失败', err);
this.loading = false;
uni.showToast({
title: '数据加载失败',
icon: 'none',
duration: 2000
});
});
},
// 获取指标卡数据
fetchSummaryData() {
return new Promise((resolve, reject) => {
getSummaryData().then(res => {
if (res.code === 200) {
this.summaryCards = res.data;
resolve();
} else {
reject(new Error('指标卡数据获取失败'));
}
}).catch(err => {
reject(err);
});
});
},
// 获取表格数据
fetchTableData() {
return new Promise((resolve, reject) => {
const params = {
pageNum: 1,
pageSize: 10
};
recentWarehouse(params).then(res => {
if (res.code === 200) {
this.tableData = res.data;
resolve();
} else {
reject(new Error('表格数据获取失败'));
}
}).catch(err => {
reject(err);
});
});
}
}
};
</script>
<style scoped>
.container {
padding: 16rpx;
background-color: #f5f5f5;
min-height: 100vh;
}
/* 日期选择器在折叠卡片额外内容中的样式 */
.picker-view {
display: flex;
align-items: center;
color: #666;
font-size: 24rpx;
padding: 4rpx 8rpx;
}
.icon-margin {
margin-right: 8rpx;
}
/* 图表样式调整 */
.chart-item {
width: 100%;
}
/* 加载状态样式 */
.loading-view {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
padding: 100rpx 0;
}
.loading-text {
margin-top: 20rpx;
font-size: 28rpx;
color: #666;
}
/* 折叠卡片间距 */
.fad-collapse {
margin-bottom: 16rpx;
}
</style>