增加项目成本页面

This commit is contained in:
砂糖
2025-10-14 13:58:33 +08:00
parent d0520e7872
commit de492664c3
10 changed files with 715 additions and 297 deletions

View File

@@ -1,8 +1,8 @@
<template>
<view class="charts-box">
<qiun-data-charts
type="column"
:chartData="chartData"
<qiun-data-charts
type="column"
:chartData="chartData"
:opts="chartOpts"
/>
</view>
@@ -16,7 +16,7 @@ export default {
chartData: {
type: Object,
default: {
categories: [], // 日期1日-当前日或当月总天数)
categories: [],
series: [] // 库存趋势数据
}
}
@@ -25,9 +25,18 @@ export default {
return {
// 图表配置
chartOpts: {
title: { text:'月度收支', left:'center' },
tooltip:{ trigger:'axis' },
legend:{ data:['支出','收入(CNY)','收入(USD)'], bottom:0 },
legend: true, // 显示图例
dataLabel: false, // 不显示数据标签
xAxis: {
fontColor: "#666",
fontSize: 12
},
yAxis: {
fontColor: "#666",
fontSize: 12,
gridColor: "#eee"
},
color: ["#007aff", "#ff9500", '#22bbff']
}
};
},

View File

@@ -0,0 +1,241 @@
<template>
<view class="cost-detail-container">
<!-- 新增根元素包裹所有内容 -->
<view class="content-wrapper">
<!-- 1. Tab 切换 -->
<view class="tab-header">
<view
class="tab-item"
:class="activeTab === 'material' ? 'tab-active' : ''"
@click="activeTab = 'material'"
>
物料花费详情
</view>
<view
class="tab-item"
:class="activeTab === 'user' ? 'tab-active' : ''"
@click="activeTab = 'user'"
>
人力成本
</view>
</view>
<!-- 2. 加载状态 -->
<view v-if="loading" class="loading-view">
<uni-loading-icon size="24" color="#007aff"></uni-loading-icon>
<text class="loading-text">加载中...</text>
</view>
<!-- 3. 物料花费详情 Tab -->
<view v-else-if="activeTab === 'material'" class="list-container">
<!-- 卡片列表 -->
<view
class="list-card"
v-for="(item, index) in detailData.materialList"
:key="item.id || index"
>
<view class="field-group">
<text class="field-label">出账名称</text>
<text class="field-value">{{ item.detailTitle || '-' }}</text>
</view>
<view class="field-group">
<text class="field-label">金额</text>
<text class="field-value text-red">-{{ item.price || 0 }}</text>
</view>
<view class="field-group">
<text class="field-label">经手人</text>
<text class="field-value">{{ item.financeParties || '-' }}</text>
</view>
<view class="field-group field-remark">
<text class="field-label">备注</text>
<text class="field-value">{{ item.remark || '无备注' }}</text>
</view>
</view>
<!-- 空数据提示 -->
<view v-if="!detailData.materialList.length" class="empty-tip">
<text>暂无物料花费数据</text>
</view>
</view>
<!-- 4. 人力成本 Tab -->
<view v-else-if="activeTab === 'user'" class="list-container">
<!-- 卡片列表 -->
<view
class="list-card"
v-for="(item, index) in detailData.userCostList"
:key="item.id || index"
>
<view class="field-group">
<text class="field-label">人员名称</text>
<text class="field-value">{{ item.nickName || '-' }}</text>
</view>
<view class="field-group">
<text class="field-label">人员成本</text>
<text class="field-value text-blue">{{ item.laborCost || 0 }}</text>
</view>
<view class="field-group">
<text class="field-label">人天计算</text>
<text class="field-value">{{ item.attendanceNum || '-' }}</text>
</view>
</view>
<!-- 空数据提示 -->
<view v-if="!detailData.userCostList.length" class="empty-tip">
<text>暂无人力成本数据</text>
</view>
</view>
</view>
</view>
</template>
<script>
export default {
props: {
detailData: {
required: true,
type: Object,
default: () => ({
materialList: [],
userCostList: []
})
},
loading: {
type: Boolean,
default: false
}
},
data() {
return {
activeTab: 'material'
};
}
};
</script>
<style scoped>
.cost-detail-container {
width: 100vw;
max-height: 90vh;
padding: 12rpx;
overflow-y: scroll;
box-sizing: border-box;
background-color: #f5f5f5;
}
/* 新增的根容器样式(可根据需要调整) */
.content-wrapper {
width: 100%;
}
.tab-header {
display: flex;
flex-direction: row;
margin-bottom: 20rpx;
background-color: #fff;
border-radius: 8rpx;
overflow: hidden;
}
.tab-item {
flex: 1;
text-align: center;
padding: 18rpx 0;
font-size: 26rpx;
color: #666;
cursor: pointer;
}
.tab-active {
color: #007aff;
font-weight: 500;
position: relative;
}
.tab-active::after {
content: '';
position: absolute;
bottom: 0;
left: 0;
width: 100%;
height: 4rpx;
background-color: #007aff;
}
.loading-view {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
padding: 150rpx 0;
}
.loading-text {
margin-top: 20rpx;
font-size: 24rpx;
color: #666;
}
.list-container {
width: 100%;
display: flex;
flex-direction: column;
gap: 16rpx;
}
.list-card {
background-color: #fff;
border-radius: 12rpx;
padding: 24rpx;
box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.05);
}
.field-group {
display: flex;
flex-direction: row;
margin-bottom: 18rpx;
align-items: flex-start;
}
.field-group:last-child {
margin-bottom: 0;
}
.field-label {
width: 140rpx;
font-size: 24rpx;
color: #999;
white-space: nowrap;
}
.field-value {
flex: 1;
font-size: 24rpx;
color: #333;
line-height: 36rpx;
}
.text-red {
color: #ff4d4f;
}
.text-blue {
color: #007aff;
}
.field-remark .field-value {
word-wrap: break-word;
word-break: break-all;
}
.empty-tip {
display: flex;
justify-content: center;
align-items: center;
padding: 150rpx 0;
font-size: 24rpx;
color: #999;
background-color: #fff;
border-radius: 12rpx;
margin-top: 16rpx;
}
</style>

View File

@@ -1,102 +1,60 @@
<template>
<view class="charts-box">
<qiun-data-charts
type="line"
:chartData="chartData"
:opts="chartOpts"
/>
</view>
<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 {
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);
});
}
}
};
export default {
name: 'InventoryTrend',
// 接收父组件传入的日期参数YYYY-mm格式
props: {
chartData: {
type: Object,
default: {
categories: [],
series: [] // 库存趋势数据
}
}
},
data() {
return {
// 图表配置
chartOpts: {
legend: true, // 显示图例
dataLabel: false, // 不显示数据标签
xAxis: {
fontColor: "#666",
fontSize: 12
},
yAxis: {
fontColor: "#666",
fontSize: 12,
gridColor: "#eee"
},
color: ["#007aff", "#ff9500", '#22bbff'],
extra: {
line: {
type: "straight",
width: 2,
activeType: "hollow"
}
}
}
};
},
};
</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;
}
.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

@@ -14,10 +14,16 @@
},
data() {
return {
chartData: {},
chartData: {
series: []
},
chartOpts: {
color: ["#1890FF", "#91CB74", "#FAC858", "#EE6666", "#73C0DE", "#3CA272", "#FC8452", "#9A60B4", "#ea7ccc"],
padding: [5, 5, 5, 5],
legend: {
show: false
},
dataLabel: false, // 不显示数据标签
enableScroll: false,
extra: {
pie: {
@@ -37,20 +43,29 @@
projectList: {
handler(newVal) {
const pieData = this.projectList
// .filter(p => p.totalPrice > 0)
.filter(p => {
// 过滤 totalPrice 非数字/小于等于0的项
const price = Number(p.totalPrice);
return !isNaN(price) && price > 0;
})
.map(p => ({
name: p.projectName,
value: p.totalPrice,
value: parseInt(p.totalPrice)
}));
this.chartData = {
// this.chartData = {
// series: [{
// data: pieData
// }]
// }
let res = {
series: [{
data: pieData
}]
}
};
this.chartData = JSON.parse(JSON.stringify(res));
},
immediate: true,
},
}
}
</script>

View File

@@ -12,11 +12,11 @@
:key="index"
>
<view class="card-title">{{ card.title }}</view>
<view class="card-value">人民币{{ card.valueCNY }}</view>
<view class="card-value">美元{{ card.valueUSD }}</view>
<view class="card-value">人民币{{ formatNumber(card.valueCNY) }}</view>
<view class="card-value">美元{{ formatNumber(card.valueUSD) }}</view>
</view>
</view>
</scroll-view>
</scroll-view>
</view>
</template>
@@ -37,9 +37,9 @@ export default {
}
},
methods: {
// 格式化数字,添加千位分隔符
formatNumber(num) {
return num.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',');
if (isNaN(num)) return '0'; // 兜底处理
return num.toFixed(2).replace(/\B(?=(\d{3})+(?!\d))/g, ','); // 保留2位小数+千位分隔符
}
}
};

View File

@@ -1,9 +1,5 @@
<template>
<view class="recent-records-container">
<view class="table-header">
<text class="title">最近记录</text>
</view>
<scroll-view
scroll-x="true"
class="table-scroll"
@@ -12,12 +8,12 @@
<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 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>
<!-- 表体 -->
@@ -26,20 +22,16 @@
v-for="(item, index) in tableData"
:key="index"
:class="{ 'odd-row': index % 2 === 1 }"
@click="rowClick(item)"
>
<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 class="table-cell">{{ item.projectName }}</view>
<view class="table-cell">{{ item.userCost }}</view>
<view class="table-cell">{{ item.peopleDay }}</view>
<view class="table-cell">{{ item.materialCost }}</view>
<view class="table-cell">{{ item.totalCost }}</view>
<view class="table-cell">
{{ item.funds }}
</view>
</view>
<!-- 空状态 -->
@@ -62,21 +54,30 @@ export default {
default: () => []
}
},
computed: {
renderData() {
return this.tableData.map(item => {
return {
projectName: item.projectName,
userCost: this.formatNumberToWan(item.userCost),
peopleDay: item.peopleDay,
materialCost: this.formatNumberToWan(item.materialCost),
totalCost: this.formatNumberToWan(item.materialCost + item.userCost + item.claimCost),
funds: this.formatNumberToWan(item.funds)
}
})
}
},
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' };
}
}
formatNumberToWan(num) {
if (num === 0) return 0;
const wanNum = num / 10000;
//
return Math.round(wanNum * 100) / 100;
},
rowClick(item) {
this.$emit('row', item);
}
}
};
</script>
@@ -87,7 +88,9 @@ export default {
background-color: #ffffff;
border-radius: 12rpx;
box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.05);
overflow: hidden;
overflow-y: scroll;
max-height: 800rpx;
overflow-x: hidden;
}
.table-header {

View File

@@ -12,37 +12,67 @@
<view class="date-picker-container">
<picker mode="date" @change="onDateChange" fields="month" :value="currentDate" class="date-picker">
<view class="picker-view">
<text>{{ formattedDate }}</text>
<text>{{ formattedDate }}</text>
</view>
</picker>
</view>
<fad-collapse title="指标汇总">
<SummaryCardsVue :cardsData="cardData"/>
<fad-collapse title="指标汇总">
<SummaryCardsVue :cardsData="cardData" />
</fad-collapse>
<fad-collapse title="月度收支">
<!-- <BarVue :chart-data="barChartData"></BarVue> -->
<template #extra>
<view @click.stop>
<uni-data-checkbox @click.stop mode="tag" v-model="chartType"
:localdata="[{ value: 'line', text: '折线图' }, { value: 'column', text: '柱状图' }]" />
</view>
</template>
<BarVue :chart-data="barChartData" v-if="chartType == 'column'"></BarVue>
<LineVue :chart-data="barChartData" v-else></LineVue>
</fad-collapse>
<fad-collapse title="近六月趋势">
<!-- <fad-collapse title="近六月趋势">
</fad-collapse>
</fad-collapse> -->
<fad-collapse title="项目支出占比">
<PieVue :project-list="projectList"></PieVue>
</fad-collapse>
<fad-collapse title="明细表格">
<TableVue :table-data="costList" @row="showCostDetail"></TableVue>
<view v-if="tableTotal > 0" class="simple-pagination">
<!-- 上一页按钮当前页=1时禁用 -->
<button class="page-btn" :disabled="tableQueryParams.pageNum === 1" @click="handlePrevPage">
上一页
</button>
<!-- 页数/总数显示 -->
<view class="page-info">
{{ tableQueryParams.pageNum }} / {{ totalPages }}
总计{{ tableTotal }}
</view>
<!-- 下一页按钮当前页=总页数时禁用 -->
<button class="page-btn" :disabled="tableQueryParams.pageNum === totalPages" @click="handleNextPage">
下一页
</button>
</view>
</fad-collapse>
</view>
<uni-popup ref="popup" type="top">
<DetailVue :detailData='costDetail'></DetailVue>
</uni-popup>
</view>
</template>
<script>
import {
barData,
findFinanceList2
findFinanceList2,
getCostDetailList,
getCostDetailById
} from '@/api/oa/finance/finance';
import {
getExchangeRate
@@ -54,6 +84,9 @@
import SummaryCardsVue from './components/SummaryCards.vue';
import PieVue from './components/Pie.vue'
import BarVue from './components/Bar.vue';
import LineVue from './components/Line.vue';
import TableVue from './components/Table.vue';
import DetailVue from './components/Detail.vue';
export default {
data() {
@@ -66,21 +99,37 @@
projectList: [], // projectData2接口返回的列表
financeList: [], // findFinanceList2接口返回的列表
queryFinanceParams: {}, // 接口请求参数(需确保已定义)
dateForProject: '' ,// 项目接口日期参数(需确保已定义)
dateForProject: '', // 项目接口日期参数(需确保已定义)
barChartData: {},
exchangeRate: 7,
chartType: 'column',
costList: [],
tableQueryParams: {
pageSize: 10,
pageNum: 1,
},
tableTotal: 0,
costDetail: {}
};
},
computed: {
formattedDate() {
const [year, month] = this.currentDate.split('-');
return `${year}${month}`;
},
totalPages() {
if (this.tableTotal === 0) return 0; // 无数据时总页数为0
// 总页数 = 总条数 ÷ 每页条数向上取整如15条/10条=2页
return Math.ceil(this.tableTotal / this.tableQueryParams.pageSize);
}
},
components: {
SummaryCardsVue,
PieVue,
BarVue
BarVue,
LineVue,
TableVue,
DetailVue
},
onLoad() {
// 初始化日期为当前月份
@@ -98,29 +147,63 @@
this.monthlyDataMap[m].exchangeRate = this.exchangeRate;
}
},
showCostDetail(row) {
getCostDetailById(row.projectId).then(response => {
this.costDetail = response.data;
this.$refs.popup.open()
})
},
/**
* 上一页按钮事件
*/
handlePrevPage() {
if (this.tableQueryParams.pageNum > 1) {
this.tableQueryParams.pageNum--; // 页码减1
this.loadTableData(); // 重新加载当前页数据
}
},
/**
* 下一页按钮事件
*/
handleNextPage() {
// 只有当前页 < 总页数时,才能切换下一页
if (this.tableQueryParams.pageNum < this.totalPages) {
this.tableQueryParams.pageNum++; // 页码加1
this.loadTableData(); // 重新加载当前页数据
}
},
onDateChange(e) {
const value = e.detail.value;
this.currentDate = value + '-01';
const value = e.detail.value;
this.currentDate = value + '-01';
this.tableQueryParams.pageNum = 1;
this.loadAllData()
},
loadTableData() {
getCostDetailList(this.tableQueryParams).then(res => {
this.costList = res.rows;
this.tableTotal = res.total;
})
},
async loadAllData() {
this.loading = true;
this.exchangeRate = await getExchangeRate()
barData(this.queryFinanceParams)
.then(res => {
this.currentList = res.data;
})
.then(async () => {
const months = this.currentList.map(i => i.month);
await this.loadAllExchangeRates(months);
return Promise.all([
projectData2(this.currentDate),
findFinanceList2({
date: this.currentDate
})
]);
})
const res = await barData(this.queryFinanceParams)
this.currentList = res.data;
const months = this.currentList.map(i => i.month);
await this.loadAllExchangeRates(months);
this.loadTableData()
Promise.all([
projectData2(this.currentDate),
findFinanceList2({
date: this.currentDate,
pageSize: 9999,
financeType: '',
pageNum: 1
})
])
.then(([projRes, finRes]) => {
this.projectList = projRes.data;
this.financeList = finRes.data;
@@ -128,103 +211,152 @@
})
.finally(() => {
this.loading = false;
console.log('loadAllData done', this.monthlyDataMap);
this.$nextTick(this.initCharts);
});
},
computeSummaries() {
// 1. 获取当前选中月份格式YYYY-MM从currentDate提取
const currentMonth = this.currentDate.slice(0, 7);
// 2. 初始化月度数据映射(确保每个月份的基础结构存在)
this.currentList.forEach(item => {
const month = item.month;
if (!this.monthlyDataMap[month]) {
this.monthlyDataMap[month] = {
outTotal: 0,
inCNY: 0,
inUSD: 0,
exchangeRate: this.monthlyDataMap[month]?.exchangeRate || 0 // 保留已有汇率
};
}
// 赋值出库总额从barData接口获取
this.monthlyDataMap[month].outTotal = item.totalOut;
});
// 3. 初始化统计变量(月度/项目收支
const initStats = {
monthlyOutCNY: 0, // 月度总支出(人民币)
monthlyOutUSD: 0, // 月度总支出(美元)
monthlyInCNY: 0, // 月度总收入(人民币)
monthlyInUSD: 0, // 月度总收入(美元)
projectOutCNY: 0, // 项目支出(人民币)
projectOutUSD: 0, // 项目支出(美元)
projectInCNY: 0, // 项目收入(人民币)
projectInUSD: 0 // 项目收入(美元)
};
Object.assign(this, initStats);
// 4. 遍历财务明细,计算收支数据
this.financeList.forEach(finItem => {
const itemMonth = finItem.date.slice(0, 7); // 明细所属月份
const amount = Number(finItem.amount) || 0; // 金额转数字避免NaN
const isOut = finItem.type === '0'; // 0=支出1=收入(按业务定义)
const currency = finItem.currency === 'USD' ? 'USD' : 'CNY'; // 货币类型
// 4.1 更新月度收入数据(存入monthlyDataMap
const monthData = this.monthlyDataMap[itemMonth];
if (monthData && !isOut) {
monthData[`in${currency}`] += amount;
}
// 4.2 计算「当前选中月份」的统计数据
if (itemMonth === currentMonth) {
if (isOut) {
// 支出:更新月度总支出 + 项目支出(有projectId才统计项目)
this[`monthlyOut${currency}`] += amount;
if (finItem.projectId) {
this[`projectOut${currency}`] += amount;
}
} else {
// 收入:更新月度总收入 + 项目收入(有projectId才统计项目)
this[`monthlyIn${currency}`] += amount;
if (finItem.projectId) {
this[`projectIn${currency}`] += amount;
}
}
}
});
// 5. 构建汇总卡片数据核心适配SummaryCards组件
// 1. 获取当前选中月份格式YYYY-MM从currentDate提取
const currentMonth = this.currentDate.slice(0, 7);
// 2. 初始化月度数据映射(确保每个月份的基础结构存在)
this.currentList.forEach(item => {
const month = item.month;
this.monthlyDataMap[month] = {
outTotal: 0,
inCNY: 0,
inUSD: 0,
exchangeRate: this.monthlyDataMap[month]?.exchangeRate || 0 // 保留已有汇率
};
// 赋值支出总额从barData接口获取
this.monthlyDataMap[month].outTotal = item.totalOut;
});
// 3. 初始化统计变量(月度/项目收支)
const initStats = {
monthlyOutCNY: 0, // 月度总支出(人民币
monthlyOutUSD: 0, // 月度总支出(美元)
monthlyInCNY: 0, // 月度总收入(人民币)
monthlyInUSD: 0, // 月度总收入(美元)
projectOutCNY: 0, // 项目支出(人民币)
projectOutUSD: 0, // 项目支出(美元)
projectInCNY: 0, // 项目收入(人民币)
projectInUSD: 0 // 项目收入(美元)
};
Object.assign(this, initStats);
// 4. 遍历财务明细,计算收支数据
this.financeList.forEach(finItem => {
const itemMonth = finItem.date.slice(0, 7); // 明细所属月份
const amount = Number(finItem.amount) || 0; // 金额转数字避免NaN
const isOut = finItem.type === '0'; // 0=支出1=收入(按业务定义)
const currency = finItem.currency === 'USD' ? 'USD' : 'CNY'; // 货币类型
// 4.1 更新月度收入数据存入monthlyDataMap
const monthData = this.monthlyDataMap[itemMonth];
if (monthData && !isOut) {
monthData[`in${currency}`] += amount;
}
// 4.2 计算「当前选中月份」的统计数据
if (itemMonth === currentMonth) {
if (isOut) {
// 支出:更新月度总支出 + 项目支出有projectId才统计项目
this[`monthlyOut${currency}`] += amount;
if (finItem.projectId) {
this[`projectOut${currency}`] += amount;
}
} else {
// 收入:更新月度总收入 + 项目收入有projectId才统计项目
this[`monthlyIn${currency}`] += amount;
if (finItem.projectId) {
this[`projectIn${currency}`] += amount;
}
}
}
});
// 5. 构建汇总卡片数据核心适配SummaryCards组件
console.log(this.monthlyDataMap, '月度数据')
this.cardData = [
{
title: '月度总支出',
valueCNY: Number(this.monthlyOutCNY.toFixed(2)), // 保留2位小数转数字
valueUSD: Number(this.monthlyOutUSD.toFixed(2))
},
{
title: '月度总收入',
valueCNY: Number(this.monthlyInCNY.toFixed(2)),
valueUSD: Number(this.monthlyInUSD.toFixed(2))
},
{
title: '项目支出',
valueCNY: Number(this.projectOutCNY.toFixed(2)),
valueUSD: Number(this.projectOutUSD.toFixed(2))
},
{
title: '项目收入',
valueCNY: Number(this.projectInCNY.toFixed(2)),
valueUSD: Number(this.projectInUSD.toFixed(2))
}
];
const categories = Object.keys(this.monthlyDataMap);
console.log('分类', categories)
const dataList =
this.barChartData = {
categories,
series: [{
name: '支出',
data: Object.values(this.monthlyDataMap).map(item => item.outTotal)
},
{
name: '收入(USD)',
data: Object.values(this.monthlyDataMap).map(item => item.inUSD)
},
{
name: '支出(CNY)',
data: Object.values(this.monthlyDataMap).map(item => item.inCNY)
}
]
}
console.log(this.barChartData)
this.cardData = [{
title: '月度总支出',
valueCNY: Number(this.monthlyOutCNY.toFixed(2)), // 保留2位小数转数字
valueUSD: Number(this.monthlyOutUSD.toFixed(2))
},
{
title: '月度总收入',
valueCNY: Number(this.monthlyInCNY.toFixed(2)),
valueUSD: Number(this.monthlyInUSD.toFixed(2))
},
{
title: '项目支出',
valueCNY: Number(this.projectOutCNY.toFixed(2)),
valueUSD: Number(this.projectOutUSD.toFixed(2))
},
{
title: '项目收入',
valueCNY: Number(this.projectInCNY.toFixed(2)),
valueUSD: Number(this.projectInUSD.toFixed(2))
}
];
},
}
};
</script>
<style scoped>
/* 简化版分页容器:居中显示,上下留间距 */
.simple-pagination {
display: flex;
align-items: center;
justify-content: center;
gap: 20rpx; /* 按钮与文字之间的间距 */
margin-top: 24rpx;
margin-bottom: 16rpx;
padding: 8rpx 0;
}
/* 分页按钮:统一样式,禁用时灰色 */
.page-btn {
padding: 8rpx 24rpx;
background-color: #007aff;
color: #fff;
border: none;
border-radius: 8rpx;
font-size: 24rpx;
}
/* 按钮禁用状态:灰色背景,无法点击 */
.page-btn:disabled {
background-color: #e5e5e5;
color: #999;
cursor: not-allowed;
}
/* 页数信息:灰色文字,适中大小 */
.page-info {
font-size: 24rpx;
color: #666;
}
.container {
padding: 16rpx;
background-color: #f5f5f5;
@@ -273,6 +405,7 @@
background-color: #fff;
border-radius: 8rpx;
padding: 16rpx;
margin-bottom: 10rpx;
box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.05);
}

View File

@@ -109,12 +109,12 @@ export default {
category: '财务中心',
access: ['vice', 'baomi', 'ceo'] // 需要特定权限才能访问
},
// {
// text: '项目成本',
// icon: '/static/images/cost.png',
// url: '/pages/workbench/cost/cost',
// category: '财务中心',
// },
{
text: '项目成本',
icon: '/static/images/cost.png',
url: '/pages/workbench/cost/cost',
category: '财务中心',
},
{
text: '智慧库房',
icon: '/static/images/smartStock.png',
@@ -166,7 +166,7 @@ export default {
text: "用户管理",
icon: '/static/images/user.png',
url: '/pages/workbench/user/user',
// access: ['vice', 'ceo']
access: ['vice', 'ceo']
}
],
};

View File

@@ -31,11 +31,11 @@
<view class="drawer-form">
<view class="drawer-form-item">
<text class="drawer-label">手机号</text>
<uni-easyinput v-model="queryParams.phonenumber" placeholder="请输入手机号" />
<uni-easyinput v-model="queryParams.phonenumber" placeholder="请输入手机号" />
</view>
<view class="drawer-form-item">
<text class="drawer-label">状态</text>
<oa-dict-select v-model="queryParams.status" dictType="sys_normal_disable"/>
<oa-dict-select v-model="queryParams.status" dictType="sys_normal_disable" />
</view>
</view>
<view class="drawer-btns">
@@ -94,7 +94,7 @@
</view>
<view class="uni-form-item">
<text class="uni-form-label">用户名称</text>
<uni-easyinput v-model="form.userName" placeholder="请输入用户名称" />
<uni-easyinput v-model="form.userName" placeholder="请输入用户名称" />
</view>
<view class="uni-form-item" v-if="form.userId">
<text class="uni-form-label">用户密码</text>
@@ -106,11 +106,11 @@
</view>
<view class="uni-form-item">
<text class="uni-form-label">薪资</text>
<uni-easyinput v-model="form.laborCost" placeholder="请输入薪资(工人为日薪)" />
<uni-easyinput v-model="form.laborCost" placeholder="请输入薪资(工人为日薪)" />
</view>
<view class="uni-form-item">
<text class="uni-form-label">保险金</text>
<uni-easyinput v-model="form.insure" placeholder="请输入保险金" />
<uni-easyinput v-model="form.insure" placeholder="请输入保险金" />
</view>
<view class="uni-form-item">
<text class="uni-form-label">岗位</text>
@@ -130,6 +130,9 @@
</view>
</view>
<view class="popup-btns">
<text v-if="!form.userId">
<u-switch v-model="useIM"></u-switch>同时注册IM账号
</text>
<u-button type="primary" @click="submitForm">确定</u-button>
<u-button @click="closePopup">取消</u-button>
</view>
@@ -151,9 +154,16 @@
updateUser
} from "@/api/oa/user";
import {
businessSendSms,
businessVerifyCode,
businessRegister
} from '@/api/login'
export default {
data() {
return {
useIM: true,
// 查询参数
queryParams: {
pageNum: 1,
@@ -222,24 +232,24 @@
console.log(res.data, '部门数据')
// 递归转换函数value直接使用原id
function transformStructure(source) {
// 处理单个节点的转换
function transformNode(node) {
// 基础转换text映射labelvalue直接使用原id
const transformed = {
text: node.label,
value: node.id // 直接使用原始id作为value
};
// 递归处理子节点(如果存在)
if (node.children && node.children.length > 0) {
transformed.children = node.children.map(child => transformNode(child));
}
return transformed;
}
// 处理整个数组
return source.map(item => transformNode(item));
// 处理单个节点的转换
function transformNode(node) {
// 基础转换text映射labelvalue直接使用原id
const transformed = {
text: node.label,
value: node.id // 直接使用原始id作为value
};
// 递归处理子节点(如果存在)
if (node.children && node.children.length > 0) {
transformed.children = node.children.map(child => transformNode(child));
}
return transformed;
}
// 处理整个数组
return source.map(item => transformNode(item));
}
this.deptOptions = transformStructure(res.data)
})
@@ -348,7 +358,7 @@
this.form = {}
this.$refs.popupRef.open('bottom')
})
},
handleUpdate(row) {
getUser(row.userId).then(res => {
@@ -402,7 +412,46 @@
this.getList()
})
} else {
addUser(this.form).then(() => {
const phoneNumber = this.form.phoneNumber;
addUser(this.form).then(async () => {
if (useIM) {
// 1. 发送验证码
const res = await businessSendSms({
phoneNumber,
areaCode: "+86",
usedFor: 1, // 表示注册
})
if (res.errCode != 0) {
throw new Error(res.errMsg)
}
// 2. 检查验证码
const verifyRes = await businessVerifyCode({
phoneNumber,
areaCode: "+86",
usedFor: 1, // 表示注册
verifyCode: '666666', // 固定的验证码
})
if (verifyRes.errCode != 0) {
throw new Error(verifyRes.errMsg)
}
// // 3. 注册账号
const registerRes = await businessRegister({
verifyCode: '666666', // 固定的验证码
platform: 2, // 表示不是苹果
autoLogin: true,
user: {
phoneNumber,
areaCode: "+86",
nickname: this.form.nickName,
password: md5('FAD888888'),
confirmPassword: 'FAD888888',
},
})
if (registerRes.errCode != 0) {
this.$modal.msgError(registerRes.errMsg)
throw new Error(registerRes.errMsg)
}
}
uni.showToast({
title: '新增成功',
icon: 'success'

View File

@@ -33,4 +33,14 @@
+ 项目选择器增加搜索
## 4.7.3
+ 修复出库记录的显示错误
+ 修复出库记录的显示错误
## 4.8.0
+ 新增用户管理
+ 完善采购计划
## 4.8.1
+ 修复用户管理的权限问题
## 4.8.2
+ 增加项目成本页面