feat: 增加项目盈亏和问题反馈

This commit is contained in:
砂糖
2025-08-20 13:44:05 +08:00
parent 384c4a7e38
commit f5ab69a431
11 changed files with 1445 additions and 42 deletions

61
api/oa/feedback.js Normal file
View File

@@ -0,0 +1,61 @@
import request from "@/util/oaRequest"
// 查询问题反馈列表
export function listFeedback(query) {
return request({
url: '/oa/feedback/list',
method: 'get',
params: query
})
}
// 查询问题反馈列表
export function indexListFeedback(query) {
return request({
url: '/oa/feedback/index-list',
method: 'get',
params: query
})
}
// 查询问题反馈详细
export function getFeedback(feedbackId) {
return request({
url: '/oa/feedback/' + feedbackId,
method: 'get'
})
}
// 新增问题反馈
export function addFeedback(data) {
return request({
url: '/oa/feedback',
method: 'post',
data: data
})
}
// 修改问题反馈
export function updateFeedback(data) {
return request({
url: '/oa/feedback',
method: 'put',
data: data
})
}
// 修改问题反馈
export function toRead(data) {
return request({
url: '/oa/feedback/toRead',
method: 'put',
data: data
})
}
// 删除问题反馈
export function delFeedback(feedbackId) {
return request({
url: '/oa/feedback/remove/' + feedbackId,
method: 'delete'
})
}

10
api/oa/finance/profit.js Normal file
View File

@@ -0,0 +1,10 @@
import request from "@/util/oaRequest"
// 查询项目盈亏
export const listProfit = (params) => {
return request({
url: '/oa/project/projectProfit',
method: 'get',
params
})
}

View File

@@ -131,8 +131,9 @@ export default {
},
onInput(e) {
// 触发v-model
this.$emit('input', e.detail.html);
this.$emit('update:value', e.detail.html);
console.log(e)
this.$emit('input', e.html);
this.$emit('update:value', e.html);
},
onAt(e) {
addAt({ username: e.name, userid: e.id }, () => {

View File

@@ -357,6 +357,38 @@
"navigationBarTitleText" : "线上营销",
"navigationStyle": "default"
}
},
{
"path" : "pages/workbench/feedback/feedback",
"style" :
{
"navigationBarTitleText" : "问题反馈",
"navigationStyle": "default"
}
},
{
"path" : "pages/workbench/feedback/detail",
"style" :
{
"navigationBarTitleText" : "反馈详情",
"navigationStyle": "default"
}
},
{
"path" : "pages/workbench/feedback/create",
"style" :
{
"navigationBarTitleText" : "新建反馈",
"navigationStyle": "default"
}
},
{
"path" : "pages/workbench/profit/profit",
"style" :
{
"navigationBarTitleText" : "项目盈亏",
"navigationStyle": "default"
}
}
],
"tabBar": {

View File

@@ -0,0 +1,161 @@
<template>
<view class="message-add-page">
<button class="save-btn" @click="handleAddFeedback">
<text>保存</text>
</button>
<!-- 表单内容 -->
<view class="form-container">
<uni-forms
ref="formRef"
:model="form"
:rules="rules"
labelPosition="left"
>
<uni-forms-item
label="标题"
name="title"
required
>
<uni-easyinput
v-model="form.title"
placeholder="请输入标题"
></uni-easyinput>
</uni-forms-item>
<uni-forms-item
label="项目"
name="projectId"
>
<oa-project-select
v-model="form.projectId"
></oa-project-select>
</uni-forms-item>
<uni-forms-item
label="内容"
name="content"
required
>
<uni-easyinput
v-model="form.content"
type="textarea"
placeholder="请输入反馈内容"
:height="200"
></uni-easyinput>
</uni-forms-item>
</uni-forms>
</view>
</view>
</template>
<script>
import { addFeedback } from "@/api/oa/feedback";
export default {
data() {
return {
// 表单数据
form: {
title: "",
content: "",
projectId: null,
},
// 表单校验规则
rules: {
title: [
{ required: true, message: "请输入标题", trigger: "blur" },
{ min: 2, max: 50, message: "标题长度在 2 到 50 个字符", trigger: "blur" },
],
content: [
{ required: true, message: "请输入反馈内容", trigger: "blur" },
],
}
};
},
methods: {
// 提交新增反馈
handleAddFeedback() {
this.$refs.formRef.validate().then(() => {
addFeedback(this.form)
.then(() => {
uni.showToast({
title: "反馈新增成功!",
icon: "success"
});
// 返回列表页
setTimeout(() => {
uni.navigateBack();
}, 1500);
})
.catch(err => {
uni.showToast({
title: err.message || "新增失败",
icon: "none"
});
});
}).catch(err => {
console.log('表单验证失败:', err);
});
},
// 返回上一页
navigateBack() {
uni.navigateBack();
}
}
};
</script>
<style scoped>
.message-add-page {
background-color: #f5f5f5;
min-height: 100vh;
}
.navbar {
display: flex;
justify-content: space-between;
align-items: center;
height: 44px;
padding: 0 15px;
background-color: #3e7bfa;
color: #fff;
}
.back-btn {
background-color: transparent;
border: none;
color: #fff;
padding: 5px 10px;
}
.title {
font-size: 18px;
font-weight: bold;
}
.save-btn {
background-color: transparent;
border: none;
color: #fff;
padding: 5px 10px;
font-size: 16px;
}
.form-container {
padding: 15px;
background-color: #fff;
margin: 10px;
border-radius: 8px;
}
.uni-forms {
--label-width: 80px;
}
.uni-forms-item {
margin-bottom: 15px;
}
</style>

View File

@@ -0,0 +1,186 @@
<template>
<view class="message-detail-page">
<!-- 详情内容 -->
<view class="detail-content" v-loading="loading">
<view class="detail-header">
<text class="detail-title">{{ message.title }}</text>
<view class="detail-meta">
<view class="meta-item">
<uni-icons type="user" size="14" color="#666"></uni-icons>
<text>创建人{{ message.createBy || '未知' }}</text>
</view>
<view class="meta-item">
<uni-icons type="time" size="14" color="#666"></uni-icons>
<text>创建时间{{ formatTime(message.createTime) }}</text>
</view>
</view>
<view class="project-info" v-if="message.projectId">
<text class="label">项目信息</text>
<text>{{ message.projectName }}</text>
<text v-if="message.projectCode"> ({{ message.projectCode }})</text>
</view>
</view>
<view class="detail-divider"></view>
<mp-html :content="message.content"></mp-html>
</view>
</view>
</template>
<script>
import { getFeedback, listFeedback, toRead } from "@/api/oa/feedback";
export default {
data() {
return {
message: {},
feedbackId: '',
loading: false
};
},
onLoad(options) {
this.feedbackId = options.feedbackId;
this.getMessageDetail();
},
methods: {
// 获取消息详情
getMessageDetail() {
this.loading = true;
// 调用列表接口获取单条数据,实际项目中应该有专门的详情接口
getFeedback(this.feedbackId)
.then(res => {
if (res.data) {
this.message = res.data;
// 标记为已读
toRead(this.message);
} else {
uni.showToast({
title: '未找到消息',
icon: 'none'
});
}
})
.catch(err => {
uni.showToast({
title: err.message || '获取消息失败',
icon: 'none'
});
})
.finally(() => {
this.loading = false;
});
},
// 格式化时间
formatTime(time) {
if (!time) return '';
const date = new Date(time);
return `${date.getFullYear()}-${(date.getMonth() + 1).toString().padStart(2, '0')}-${date.getDate().toString().padStart(2, '0')} ${date.getHours().toString().padStart(2, '0')}:${date.getMinutes().toString().padStart(2, '0')}`;
},
// 返回上一页
navigateBack() {
uni.navigateBack();
}
}
};
</script>
<style scoped>
.message-detail-page {
background-color: #f5f5f5;
min-height: 100vh;
}
.navbar {
display: flex;
align-items: center;
height: 44px;
padding: 0 15px;
background-color: #3e7bfa;
color: #fff;
}
.back-btn {
background-color: transparent;
border: none;
color: #fff;
padding: 5px 10px;
}
.title {
font-size: 18px;
font-weight: bold;
flex: 1;
text-align: center;
}
.detail-content {
padding: 15px;
background-color: #fff;
margin: 10px;
border-radius: 8px;
}
.detail-header {
margin-bottom: 20px;
}
.detail-title {
font-size: 18px;
font-weight: bold;
margin-bottom: 15px;
display: block;
color: #333;
}
.detail-meta {
display: flex;
flex-direction: column;
gap: 8px;
margin-bottom: 15px;
color: #666;
font-size: 14px;
}
.meta-item {
display: flex;
align-items: center;
gap: 5px;
}
.project-info {
padding: 10px;
background-color: #f5f7fa;
border-radius: 4px;
font-size: 14px;
color: #333;
}
.label {
color: #666;
font-weight: 500;
}
.detail-divider {
height: 1px;
background-color: #eee;
margin: 15px 0;
}
.detail-body {
color: #333;
line-height: 1.8;
font-size: 15px;
padding: 10px 0;
}
image {
max-width: 100vw;
object-fit: contain;
}
</style>

View File

@@ -0,0 +1,375 @@
<template>
<view class="message-list-page">
<!-- 顶部导航栏 -->
<view class="navbar">
<view class="icon-btn" @click="toggleFilter">
<uni-icons type="gear" size="22"></uni-icons>
</view>
<uni-easyinput v-model="queryParams.title" placeholder="搜索反馈..." @confirm="handleSearch"
@clear="handleClearSearch"></uni-easyinput>
<view class="icon-btn" @click="navigateToAdd">
<uni-icons type="plus" size="22"></uni-icons>
</view>
</view>
<!-- 搜索和筛选区域 -->
<view class="filter-row" v-if="showFilter">
<uni-datetime-picker type="daterange" v-model="dateRange" startDate="2020-01-01" endDate="2030-12-31"
@change="handleDateChange" placeholder="选择时间范围"></uni-datetime-picker>
<oa-project-select v-model="queryParams.projectId" @change="handleSearch"></oa-project-select>
</view>
<!-- 消息列表使用scroll-view实现下拉加载 -->
<scroll-view scroll-y @scrolltolower="loadMore" :style="{ height: scrollHeight + 'px' }" class="message-scroll">
<view class="message-list">
<view v-for="(msg, index) in messageList" :key="msg.feedbackId" class="message-item"
:class="{ 'unread': msg.state === 0 }" @click="navigateToDetail(msg)" @longpress="handleDel(msg)"
>
<!-- 消息标题 -->
<view class="message-title">
<view class="state-dot" v-if="msg.state === 0"></view>
<text>{{ msg.title }}</text>
</view>
<!-- 消息信息 -->
<view class="message-info">
<text class="message-status">{{ msg.state === 0 ? '未读' : '已读' }}</text>
<text class="project-name">
{{ msg.projectName ? truncateText(msg.projectName, 15) : '无项目' }}
</text>
<text class="create-time">{{ formatTime(msg.createTime) }}</text>
</view>
</view>
<!-- 空状态 -->
<uni-empty v-if="messageList.length === 0 && !loading" text="暂无消息"></uni-empty>
</view>
<!-- 加载更多组件 -->
<uni-load-more :status="loadMoreStatus" class="load-more"></uni-load-more>
</scroll-view>
</view>
</template>
<script>
import {
delFeedback,
listFeedback
} from "@/api/oa/feedback";
export default {
data() {
return {
// 消息列表数据不再需要filteredMessageList
messageList: [],
// 分页查询参数
queryParams: {
pageSize: 10,
pageNum: 1,
title: '',
projectId: '',
startTime: '',
endTime: ''
},
total: 0, // 总条数
loading: false, // 加载状态
showFilter: false, // 筛选框显示状态
dateRange: [], // 日期范围
loadMoreStatus: 'more', // 加载更多状态more/noMore/loading
scrollHeight: 0 // 滚动区域高度
};
},
onShow() {
// 重置分页数据并重新加载
this.resetPageData();
this.calculateScrollHeight();
},
methods: {
// 计算滚动区域高度
calculateScrollHeight() {
const systemInfo = uni.getSystemInfoSync();
const navbarHeight = 44; // 导航栏高度
const searchFilterHeight = 0; // 搜索筛选区域高度
this.scrollHeight = systemInfo.windowHeight - navbarHeight - searchFilterHeight;
},
// 重置分页数据
resetPageData() {
this.queryParams.pageNum = 1;
this.messageList = [];
this.loadMoreStatus = 'more';
this.getList();
},
// 获取消息列表
getList() {
// 如果正在加载或没有更多数据,直接返回
if (this.loading || this.loadMoreStatus !== 'more') return;
this.loading = true;
this.loadMoreStatus = 'loading'; // 显示加载中状态
listFeedback(this.queryParams)
.then(res => {
this.total = res.total || 0;
const newList = res.rows || [];
// 第一页直接赋值,后续页追加
if (this.queryParams.pageNum === 1) {
this.messageList = newList;
} else {
this.messageList = [...this.messageList, ...newList];
}
// 判断是否还有更多数据
if (this.messageList.length >= this.total) {
this.loadMoreStatus = 'noMore';
} else {
this.loadMoreStatus = 'more';
}
})
.catch(err => {
uni.showToast({
title: err.message || '获取消息失败',
icon: 'none'
});
this.loadMoreStatus = 'more'; // 加载失败时允许重试
})
.finally(() => {
this.loading = false;
});
},
// 加载更多
loadMore() {
if (this.loadMoreStatus === 'more' && !this.loading) {
this.queryParams.pageNum++;
this.getList();
}
},
// 搜索处理
handleSearch() {
// 搜索时重置分页
this.resetPageData();
},
// 处理删除
handleDel(row) {
uni.showModal({
title: '提示',
content: '确定要删除这条消息吗?',
success: (res) => {
if (res.confirm) {
delFeedback(row.feedbackId)
.then(() => {
uni.showToast({
title: '删除成功',
icon: 'success'
});
// 删除后重新加载列表
this.resetPageData();
})
.catch(err => {
uni.showToast({
title: err.message || '删除失败',
icon: 'none'
});
});
}
}
});
},
// 切换筛选
toggleFilter() {
this.showFilter = !this.showFilter;
},
// 处理日期范围变化
handleDateChange(e) {
if (e.length === 2) {
this.queryParams.startTime = e[0] + ' 00:00:00';
this.queryParams.endTime = e[1] + " 00:00:00";
this.resetPageData(); // 筛选后重置分页
}
},
// 清除搜索
handleClearSearch() {
this.queryParams.title = '';
this.resetPageData();
},
// 格式化时间
formatTime(time) {
if (!time) return '';
const date = new Date(time);
return `${date.getMonth() + 1}-${date.getDate()} ${date.getHours()}:${date.getMinutes()}`;
},
// 截断文本
truncateText(text, length = 15) {
if (!text) return '';
if (text.length <= length) return text;
return text.substring(0, length) + '...';
},
// 跳转到详情页
navigateToDetail(msg) {
uni.navigateTo({
url: `/pages/workbench/feedback/detail?feedbackId=${msg.feedbackId}`
});
},
// 跳转到新增页
navigateToAdd() {
uni.navigateTo({
url: '/pages/workbench/feedback/create'
});
}
}
};
</script>
<style scoped>
.message-list-page {
background-color: #f5f5f5;
min-height: 100vh;
}
.navbar {
display: flex;
justify-content: space-between;
align-items: center;
height: 44px;
width: 100vw;
box-sizing: border-box;
padding: 0 15px;
color: #fff;
}
.title {
font-size: 18px;
font-weight: bold;
}
.add-btn {
background-color: transparent;
border: none;
color: #fff;
padding: 5px 10px;
}
.search-filter {
padding: 10px 15px;
background-color: #fff;
position: relative;
/* 用于筛选按钮定位 */
}
.filter-row {
display: flex;
gap: 10px;
margin-top: 10px;
flex-wrap: wrap;
}
.filter-btn {
position: absolute;
right: 20px;
top: 15px;
background-color: transparent;
border: none;
display: flex;
align-items: center;
gap: 5px;
color: #666;
}
/* 滚动区域样式 */
.message-scroll {
width: 100%;
overflow: hidden;
}
.message-list {
padding: 10px 15px;
}
.message-item {
background-color: #fff;
border-radius: 8px;
padding: 15px;
margin-bottom: 10px;
display: flex;
flex-direction: column;
position: relative;
}
.message-item.unread {
border-left: 3px solid #fa5555;
}
.message-title {
display: flex;
align-items: center;
margin-bottom: 10px;
font-weight: 500;
font-size: 16px;
}
.state-dot {
width: 8px;
height: 8px;
border-radius: 50%;
background-color: #fa5555;
margin-right: 8px;
}
.message-info {
display: flex;
justify-content: space-between;
align-items: center;
color: #999;
font-size: 14px;
}
.message-status {
color: #fa5555;
}
.project-name {
flex: 1;
text-align: center;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.create-time {
text-align: right;
}
.delete-btn {
position: absolute;
right: 10px;
top: 10px;
background-color: transparent;
border: none;
padding: 5px;
}
/* 加载更多样式 */
.load-more {
padding: 20rpx 0;
text-align: center;
}
.icon-btn {
padding: 10rpx;
margin: 10rpx;
box-sizing: border-box;
}
</style>

View File

@@ -5,9 +5,18 @@
<text>工作台</text>
</view>
</custom-nav-bar>
<!-- 按分类展示入口项 -->
<view class="category-container" v-for="(group, category) in groupedEntries" :key="category">
<!-- 分类标题 -->
<view class="category-title">
<text>{{ category || '其他' }}</text>
</view>
<!-- 分类下的入口列表 -->
<view class="entry-list">
<view
v-for="item in entryList"
v-for="item in group"
:key="item.text"
class="entry-item"
@click="handleEntryClick(item)"
@@ -16,7 +25,7 @@
<text class="entry-text">{{ item.text }}</text>
</view>
</view>
</view>
</view>
</template>
@@ -30,47 +39,69 @@ export default {
CustomNavBar,
},
onShow() {
console.log('页面onLoad被调用');
// 页面加载时调用getUserProfile
console.log('页面onShow被调用');
this.fetchUserProfile();
},
data() {
return {
roleGroup: [], // 存储用户拥有的权限集合
loading: true,
entryList: [
{
text: '每日报工',
icon: '/static/images/baogong.png',
url: '/pages/workbench/reportWork/reportWork',
},
{
text: '施工进度',
icon: '/static/images/shigong.png',
url: '/pages/workbench/construction/construction',
category: "信息中心"
// 未设置access时默认允许所有用户访问
},
{
text: '任务中心',
icon: '/static/images/task.png',
url: '/pages/workbench/task/task',
category: "信息中心"
},
{
text: '项目排产',
icon: '/static/images/paichan.png',
url: '/pages/workbench/reportSchedule/reportSchedule',
category: '车间管理'
},
{
text: '施工进度',
icon: '/static/images/shigong.png',
url: '/pages/workbench/construction/construction',
category: '车间管理'
},
{
text: '快递信息',
icon: '/static/images/express.svg',
url: '/pages/workbench/express/express',
category: '车间管理'
},
{
text: '项目中心',
icon: '/static/images/project.png',
url: '/pages/workbench/project/project',
category: "信息中心"
},
{
text: '问题反馈',
icon: '/static/images/wenti.png',
url: '/pages/workbench/feedback/feedback',
category: "信息中心"
},
{
text: '库存盘点',
icon: '/static/images/stock.png',
url: '/pages/workbench/wms/wms',
category: "库房管理"
},
{
text: '项目盈亏',
icon: '/static/images/yingkui.png',
url: '/pages/workbench/profit/profit',
category: '财务中心',
access: ['vice', 'baomi', 'ceo'] // 需要特定权限才能访问
},
{
text: '线上营销',
@@ -80,17 +111,47 @@ export default {
],
};
},
computed: {
// 按category分组并过滤权限的计算属性
groupedEntries() {
const groups = {};
this.entryList.forEach(item => {
// 权限判断逻辑:
// 1. 如果item没有access属性默认允许访问
// 2. 如果有access属性检查用户权限(roleGroup)是否包含其中任意一个
const hasAccess = !item.access || item.access.some(access => this.roleGroup.includes(access));
// 没有权限则跳过当前项
if (!hasAccess) return;
// 按分类分组
const category = item.category || '其他';
if (!groups[category]) {
groups[category] = [];
}
groups[category].push(item);
});
return groups;
}
},
methods: {
// 获取用户个人信息
async fetchUserProfile() {
console.log('fetchUserProfile方法开始执行');
try {
// this.loading = true;
uni.showLoading()
console.log('开始调用getUserProfile API');
const response = await getUserProfile();
console.log('用户个人信息:', response);
// 这里可以根据需要处理返回的用户信息
// 从接口返回数据中提取用户权限(roleKey)
const roles = response.data.user?.roles?.map(item => item.roleKey) || [];
console.log('用户权限字段', roles);
this.roleGroup = roles;
uni.hideLoading()
} catch (error) {
console.error('获取用户个人信息失败:', error);
// 错误处理:可以设置默认权限或提示用户
this.roleGroup = [];
}
},
handleEntryClick(item) {
@@ -105,41 +166,68 @@ export default {
<style lang="scss" scoped>
.workbench-container {
min-height: 100vh;
background: #fff;
background: #f5f5f5;
display: flex;
flex-direction: column;
}
.workbench-title {
padding-left: 44rpx;
font-size: 40rpx;
font-weight: 600;
color: #0c1c33;
}
// 分类容器样式
.category-container {
margin-top: 30rpx;
background: #fff;
border-radius: 16rpx;
overflow: hidden;
margin-left: 30rpx;
margin-right: 30rpx;
}
// 分类标题样式
.category-title {
padding: 28rpx 44rpx;
font-size: 28rpx;
color: #666;
background-color: #fafafa;
border-bottom: 1px solid #f0f0f0;
}
// 入口列表样式
.entry-list {
display: flex;
flex-direction: column;
margin-top: 40rpx;
flex-wrap: wrap; // 允许换行
padding: 10rpx 0;
}
// 入口项样式
.entry-item {
display: flex;
flex-direction: row;
flex-direction: column; // 纵向排列(图标在上,文字在下)
align-items: center;
padding: 32rpx 44rpx;
background: #fff;
justify-content: center;
width: 25%; // 一行显示4个
padding: 30rpx 0;
box-sizing: border-box;
}
.entry-icon {
width: 56rpx;
height: 56rpx;
margin-right: 32rpx;
width: 80rpx;
height: 80rpx;
margin-bottom: 16rpx; // 图标与文字间距
}
.entry-text {
color: #333;
font-size: 32rpx;
}
.divider {
height: 1px;
background: #f0f0f0;
margin-left: 44rpx;
margin-right: 44rpx;
font-size: 26rpx;
text-align: center; // 文字居中
white-space: nowrap; // 防止文字换行
overflow: hidden;
text-overflow: ellipsis; // 文字过长时显示省略号
width: 100%; // 限制文字宽度
}
</style>

View File

@@ -0,0 +1,489 @@
<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>
</template>
<script>
import { listProfit } from '@/api/oa/finance/profit';
export default {
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: '内贸' },
]
};
},
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;
}
}
};
</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>

BIN
static/images/wenti.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.9 KiB

BIN
static/images/yingkui.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB