This commit is contained in:
浅念
2026-02-06 14:39:37 +08:00
parent 423fc8b7e1
commit bf3d85de0d
28 changed files with 5631 additions and 1164 deletions
+123 -108
View File
@@ -1,6 +1,6 @@
<template>
<view class="home-page">
<z-paging ref="paging" :auto="false" v-model="contList" @query="queryList" empty-view-text="暂无数据!">
<z-paging ref="paging" :auto="false" v-model="borrowList" @query="queryList" empty-view-text="暂无数据!">
<template #top>
<uni-nav-bar leftText=" " :fixed="true" leftIcon="back" :border="false" @clickLeft="leftClick" color="#fff" backgroundColor="rgb(48, 116, 247)" :statusBar="true" title="借用列表"></uni-nav-bar>
<!-- Tab栏 -->
@@ -21,9 +21,8 @@
<view class="list-container">
<view
class="borrow-card"
v-for="(item, index) in filteredList"
v-for="(item, index) in borrowList"
:key="index"
@click="handleCardClick(item)"
>
<!-- 状态标签(右上角旋转丝带) -->
<view class="status-ribbon" :class="'ribbon-' + item.status">
@@ -32,26 +31,29 @@
<!-- 卡片内容 -->
<view class="card-content">
<view class="card-title">{{ item.itemName }}</view>
<view class="card-info">
<text class="info-item">申请人: {{ item.applicant }}</text>
<text class="info-item">借用时间: {{ item.borrowTime }}</text>
<view class="action-btns">
<text class="info-item">公司名称: {{ item.companyName }}</text>
<!-- 操作按钮 -->
<view class="card-actions" v-if="item.status !== 'returned'">
<button
class="action-btn"
:class="'btn-' + item.status"
@click="handleAction(item)"
>
{{ getActionText(item.status) }}
</button>
</view>
<view class="card-title" @click="handleCardClick(item)">
<uni-tag :text="item1.item_name_snap" size="mini" type="primary" v-for="(item1, index) in item.item" :key="index"/>
</view>
<view class="card-info" @click="handleCardClick(item)">
<text class="info-item">申请人: {{ item.applicant_name }}</text>
<text class="info-item">借用时间: {{ item.use_start_date || '-' }} ~ {{ item.use_end_date || '-' }}</text>
</view>
<view class="action-btns">
<!-- <text class="info-item">公司名称: {{ item.companyName }}</text> -->
<text class="info-item"></text>
<!-- 操作按钮 -->
<view class="card-actions" v-if="item.status !== 'returned'">
<button
class="action-btn"
:class="'btn-' + item.status"
@click="handleAction(item)"
v-if="item.status==10||item.status==12||item.status==14||item.status==16"
>
{{ getActionText(item.status) }}
</button>
</view>
</view>
</view>
</view>
</view>
@@ -61,55 +63,23 @@
</template>
<script>
import { request,showToast } from '@/api/apiT.js'
export default {
data() {
return {
currentTab: 0,
tabList: ['全部', '已归还', '未归还', '待复核'],
borrowList: [
{
id: 1,
itemName: '公章',
applicant: '刘宇',
borrowTime: '2024-11-06 09:41:18',
companyName: '合塑',
status: 'returned' // returned, notReturned, pendingReview
},
{
id: 2,
itemName: '公章',
applicant: '刘宇',
borrowTime: '2024-11-06 09:41:18',
companyName: '合塑',
status: 'notReturned'
},
{
id: 3,
itemName: '公章',
applicant: '刘宇',
borrowTime: '2024-11-06 09:41:18',
companyName: '合塑',
status: 'pendingReview'
},
{
id: 4,
itemName: '公章',
applicant: '刘宇',
borrowTime: '2024-11-06 09:41:18',
companyName: '合塑',
status: 'pendingReview'
},
{
id: 5,
itemName: '公章',
applicant: '刘宇',
borrowTime: '2024-11-06 09:41:18',
companyName: '合塑',
status: 'pendingReview'
return {
currentTab: 0,
tabList: ['全部', '已归还', '未归还', '待审核'],
borrowList: []
}
},
onLoad() {
// 页面加载时初始化数据
this.$nextTick(() => {
if (this.$refs.paging) {
this.$refs.paging.reload()
}
]
}
},
})
},
computed: {
filteredList() {
if (this.currentTab === 0) {
@@ -130,19 +100,55 @@
},
switchTab(index) {
this.currentTab = index
// 重置分页并重新加载数据
if (this.$refs.paging) {
this.$refs.paging.reload()
}
},
queryList(pageNo, pageSize, from) {
this.loading = true;
var that = this;
const params = {
current:pageNo,
size:10,
applicant_id:'self',
status: this.currentTab === 0 ? '' : (this.currentTab === 1 ? 'repaid' : (this.currentTab === 2 ? 'unreturned' : 'approve'))
};
request({
url:'mobile/inv/requisition/list',
method:'get',
data: params
}).then(res => {
if(res.data.code ==200){
var datas = res.data.data.records;
this.$refs.paging.complete(datas);
}else{
}
uni.stopPullDownRefresh();
//
})
},
getStatusText(status) {
const statusMap = {
'returned': '已归还',
'notReturned': '未归还',
'pendingReview': '待复核'
'10': '待审核',
'11': '审批中',
'12': '待归还',
'13': '借用拒绝',
'14': '归还待审核',
'15': '归还审批中',
'16': '部分归还',
'17': '已归还',
'18': '归还拒绝',
'19': '损耗品'
}
return statusMap[status] || ''
},
getActionText(status) {
const actionMap = {
'notReturned': '立即归还',
'pendingReview': '立即复核'
'12': '归还',
'14': '编辑',
'10': '编辑',
'16': '归还',
}
return actionMap[status] || ''
},
@@ -152,28 +158,19 @@
});
},
handleAction(item) {
if (item.status === 'notReturned') {
if (item.status == 12 || item.status == 16) {
// 归还操作
uni.navigateTo({
url: '/pages/borrow/return'
url: '/pages/borrow/return?id='+item.id
});
// uni.showModal({
// title: '提示',
// content: '确定要归还该物品吗?',
// success: (res) => {
// if (res.confirm) {
// uni.showToast({
// title: '归还成功',
// icon: 'success'
// })
// // 这里可以调用API更新状态
// }
// }
// })
} else if (item.status === 'pendingReview') {
// 复核操作
} else if (item.status == 10) {
uni.navigateTo({
url: '/pages/borrow/review'
url: '/pages/borrow/borrow_edit?id='+item.id
});
} else if (item.status == 14) {
uni.navigateTo({
url: '/pages/borrow/return_edit?id='+item.id
});
}
}
@@ -242,10 +239,10 @@
// 状态标签(旋转丝带效果)
.status-ribbon {
position: absolute;
top: -5px;
right: -24px;
width: 75px;
height: 37px;
top: -4px;
right: -32px;
width: 100px;
height: 47px;
background: #08A400;
transform: rotate(45deg);
z-index: 10;
@@ -254,19 +251,39 @@
justify-content: center;
box-shadow: 0 2rpx 4rpx rgba(0, 0, 0, 0.15);
}
.ribbon-returned {
background: #08A400; // 绿色
}
.ribbon-notReturned {
background: #BD0000; // 红色
}
.ribbon-pendingReview {
.ribbon-10 {
background: #3471FF; // 蓝色
}
.ribbon-11 {
background: #FA8C16;
}
.ribbon-12 {
background: #722ED1;
}
.ribbon-13 {
background: #F5222D;
}
.ribbon-14 {
background: #13C2C2;
}
.ribbon-15 {
background: #FAAD14;
}
.ribbon-16 {
background: #52C41A;
}
.ribbon-17 {
background: #389E0D;
}
.ribbon-18 {
background: #A8071A;
}
.ribbon-19 {
background: #8C8C8C;
}
.ribbon-text {
color: #fff;
font-size: 20rpx;
@@ -290,6 +307,8 @@
font-weight: 500;
color: #333;
margin-bottom: 24rpx;
display: flex;
gap: 10px;
}
.card-info {
@@ -330,11 +349,7 @@
}
}
.btn-notReturned {
background: #3074F7;
}
.btn-pendingReview {
background: #3074F7;
.btn-12, .btn-16 {
background: #52C41A;
}
</style>