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
+344
View File
@@ -0,0 +1,344 @@
<template>
<view class="home-page">
<z-paging ref="paging" 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栏 -->
<view class="tab-bar">
<view
class="tab-item"
:class="{ 'tab-item-active': currentTab === index }"
v-for="(tab, index) in tabList"
:key="index"
@click="switchTab(index)"
>
<text class="tab-text">{{ tab }}</text>
<view v-if="currentTab === index" class="tab-underline"></view>
</view>
</view>
</template>
<!-- 列表内容 -->
<view class="list-container">
<view
class="borrow-card"
v-for="(item, index) in borrowList"
:key="index"
>
<!-- 状态标签(右上角旋转丝带) -->
<view class="status-ribbon" :class="'ribbon-' + item.status">
<text class="ribbon-text">{{ getStatusText(item.status) }}</text>
</view>
<!-- 卡片内容 -->
<view class="card-content" @click="handleCardClick(item)">
<view class="card-title">
<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">
<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"
v-if="item.status==10"
@click.stop="handleAction(item)"
>
{{ getActionText(item.status) }}
</button>
</view>
</view>
</view>
</view>
</view>
</z-paging>
</view>
</template>
<script>
import { request,showToast } from '@/api/apiT.js'
export default {
data() {
return {
currentTab: 0,
tabList: ['全部', '待审核', '已通过', '未通过'],
borrowList: []
}
},
computed: {
filteredList() {
if (this.currentTab === 0) {
return this.borrowList
} else if (this.currentTab === 1) {
return this.borrowList.filter(item => item.status === 'returned')
} else if (this.currentTab === 2) {
return this.borrowList.filter(item => item.status === 'notReturned')
} else if (this.currentTab === 3) {
return this.borrowList.filter(item => item.status === 'pendingReview')
}
return []
}
},
methods: {
leftClick(){
uni.navigateBack({})
},
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,
status: this.currentTab === 0 ? '' : (this.currentTab === 1 ? '10' : (this.currentTab === 2 ? '12' : '13'))
};
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 = {
'12': '待归还',
'13': '拒绝',
'14': '申请归还',
'15': '归还审核中',
'16': '部分归还',
'17': '已归还',
'18': '归还拒绝',
'11': '审批中',
'10': '待审核',
'19': '损耗品'
}
return statusMap[status] || ''
},
getActionText(status) {
const actionMap = {
'12': '待归还',
'13': '拒绝',
'14': '申请归还',
'15': '归还审核中',
'16': '部分归还',
'17': '已归还',
'18': '归还拒绝',
'11': '审批中',
'10': '去审核',
'19': '损耗品'
}
return actionMap[status] || ''
},
handleCardClick(item) {
uni.navigateTo({
url: '/pages/approval/borrow_approval_detail?id=' + item.id
});
},
handleAction(item) {
uni.navigateTo({
url: '/pages/approval/borrow_approval_detils?id='+item.id
});
}
}
}
</script>
<style lang="scss">
.home-page {
min-height: 100vh;
background: rgb(244, 246, 248);
}
.content-wrapper {
}
// Tab栏样式
.tab-bar {
display: flex;
background: #F4F6F8;
}
.tab-item {
flex: 1;
position: relative;
padding: 24rpx 0;
text-align: center;
}
.tab-text {
font-size: 28rpx;
color: #666;
}
.tab-item-active .tab-text {
color: #3074F7;
font-weight: 500;
}
.tab-underline {
position: absolute;
bottom: 0;
left: 50%;
transform: translateX(-50%);
width: 60rpx;
height: 4rpx;
background: #3074F7;
border-radius: 2rpx;
}
// 列表容器
.list-container {
padding: 24rpx 28rpx;
}
// 借用卡片
.borrow-card {
position: relative;
background: #fff;
border-radius: 12rpx;
margin-bottom: 24rpx;
box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.05);
overflow: hidden;
}
// 状态标签(旋转丝带效果)
.status-ribbon {
position: absolute;
top: -4px;
right: -32px;
width: 100px;
height: 47px;
background: #08A400;
transform: rotate(45deg);
z-index: 10;
display: flex;
align-items: center;
justify-content: center;
box-shadow: 0 2rpx 4rpx rgba(0, 0, 0, 0.15);
}
.ribbon-notReturned {
background: #BD0000; // 红色
}
.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;
font-weight: 500;
transform: rotate(0deg);
transform-origin: center;
display: block;
text-align: center;
margin-top: 16rpx;
white-space: nowrap;
letter-spacing: 1rpx;
}
// 卡片内容
.card-content {
padding: 28rpx;
}
.card-title {
font-size: 32rpx;
font-weight: 500;
color: #333;
margin-bottom: 24rpx;
display: flex;
gap: 10px;
}
.card-info {
display: flex;
flex-direction: column;
gap: 12rpx;
margin-bottom: 24rpx;
}
.info-item {
font-size: 26rpx;
color: #666;
line-height: 1.6;
}
// 操作按钮
.card-actions {
display: flex;
justify-content: flex-end;
}
.action-btns{
display: flex;
justify-content: space-between;
align-items: center;
}
.action-btn {
padding: 14rpx 40rpx;
background: #3074F7;
color: #fff;
border-radius: 8rpx;
font-size: 26rpx;
border: none;
line-height: 1;
&::after {
border: none;
}
}
.btn-notReturned {
background: #3074F7;
}
.btn-pendingReview {
background: #3074F7;
}
</style>
+274
View File
@@ -0,0 +1,274 @@
<template>
<view class="page">
<uni-nav-bar
leftText=" "
:fixed="true"
leftIcon="back"
background-color="rgb(48, 116, 247)"
color="#fff"
:statusBar="true"
title="借用审核详情"
@clickLeft="onBack"
/>
<view class="content">
<!-- 基本信息 -->
<view class="card">
<view class="card-head">
<text class="card-title">借用信息</text>
<view class="status-tag" :class="'s' + (detail.status || 0)">
<text class="status-text">{{ statusText }}</text>
</view>
</view>
<view class="row"><text class="label">单号</text><text class="value">{{ detail.order_no || '-' }}</text></view>
<view class="row"><text class="label">申请人</text><text class="value">{{ detail.applicant_name || '-' }}</text></view>
<view class="row">
<text class="label">借用时间</text>
<text class="value">{{ detail.use_start_date || '-' }} ~ {{ detail.use_end_date || '-' }}</text>
</view>
<view class="row"><text class="label">借用事由</text><text class="value">{{ detail.borrow_reason || '-' }}</text></view>
<view class="row" v-if="detail.remark !== undefined">
<text class="label">备注</text>
<text class="value">{{ detail.remark || '-' }}</text>
</view>
</view>
<!-- 物品明细 -->
<view class="card">
<view class="card-head">
<text class="card-title">物品明细</text>
</view>
<view v-if="detail.item && detail.item.length === 0" class="empty">暂无物品</view>
<view v-for="(it, idx) in detail.item" :key="it.id" class="item">
<view class="item-left">
<text class="item-name">{{ it.item_name_snap || '-' }}</text>
<text class="item-meta" v-if="it.spec_model_snap">规格:{{ it.spec_model_snap }}</text>
</view>
<view class="item-right">
<text class="qty-label">申请数量</text>
<text class="qty-val">{{ it.request_qty || 0 }}</text>
</view>
</view>
</view>
<!-- 申请附件 -->
<view class="card" v-if="(detail.attachment || []).length">
<view class="card-head">
<text class="card-title">申请附件</text>
</view>
<view class="img-grid">
<image
v-for="(a, i) in detail.attachment"
:key="a.id || i"
class="img"
:src="a.file_path_pull || ''"
mode="aspectFill"
@click="previewAttachment(i)"
/>
</view>
</view>
<!-- 审核信息 -->
<view class="card" v-if="detail.audit_info">
<view class="card-head">
<text class="card-title">审核信息</text>
</view>
<view class="row"><text class="label">审核人</text><text class="value">{{ detail.audit_info.handler_name || '-' }}</text></view>
<view class="row"><text class="label">审核时间</text><text class="value">{{ detail.audit_info.handle_time || '-' }}</text></view>
<view class="row" v-if="detail.audit_info.handle_remark">
<text class="label">审核意见</text>
<text class="value">{{ detail.audit_info.handle_remark }}</text>
</view>
</view>
</view>
</view>
</template>
<script>
import { request, showToast } from '@/api/apiT.js'
export default {
data() {
return {
id: '',
detail: {}
}
},
computed: {
statusText() {
const s = Number(this.detail.status || 0)
if (this.detail.is_returned === 1) return '已归还'
if (s === 10) return '待审核'
if (s === 11) return '审批中'
if (s === 12) return '待归还'
if (s === 13) return '借用拒绝'
if (s === 14) return '归还待审核'
if (s === 15) return '归还审批中'
if (s === 16) return '部分归还'
if (s === 17) return '已归还'
if (s === 18) return '归还拒绝'
return '处理中'
}
},
onLoad(option) {
this.id = option.id || option.requisition_id || option.requisitionId || ''
if (!this.id) {
showToast({ title: '缺少id参数' })
return
}
this.getDetail()
},
methods: {
onBack() {
uni.navigateBack()
},
getDetail() {
request({
url: 'admin/inv/requisition/show',
method: 'GET',
data: { id: this.id }
}).then((res) => {
if (res.data && res.data.code === 200) {
this.detail = res.data.data || {}
// 兜底,避免 v-for 报错
this.detail.item = Array.isArray(this.detail.item) ? this.detail.item : []
this.detail.attachment = Array.isArray(this.detail.attachment) ? this.detail.attachment : []
} else {
showToast({ title: res.data.message || '获取详情失败' })
}
})
},
previewAttachment(index) {
const urls = (this.detail.attachment || [])
.map((a) => a.file_path_pull)
.filter(Boolean)
if (!urls.length) return
uni.previewImage({
current: urls[index] || urls[0],
urls
})
}
}
}
</script>
<style lang="scss">
.page {
min-height: 100vh;
background: rgb(244, 246, 248);
}
.content {
padding: 20rpx;
}
.card {
background: #fff;
border-radius: 20rpx;
padding: 22rpx;
margin-bottom: 18rpx;
box-shadow: 0 6rpx 18rpx rgba(0, 0, 0, 0.04);
}
.card-head {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 16rpx;
}
.card-title {
font-size: 30rpx;
font-weight: 700;
color: #1f2d3d;
}
.row {
display: flex;
align-items: flex-start;
justify-content: space-between;
padding: 10rpx 0;
border-bottom: 1rpx solid #f1f3f5;
}
.row:last-child {
border-bottom: none;
}
.label {
width: 160rpx;
font-size: 26rpx;
color: #667085;
}
.value {
flex: 1;
text-align: right;
font-size: 26rpx;
color: #101828;
}
.status-tag {
padding: 6rpx 14rpx;
border-radius: 999rpx;
background: rgba(48, 116, 247, 0.12);
}
.status-text {
font-size: 24rpx;
color: rgb(48, 116, 247);
}
.empty {
padding: 24rpx 0;
text-align: center;
color: #98a2b3;
font-size: 26rpx;
}
.item {
padding: 16rpx 0;
border-top: 1rpx dashed #eef2f6;
display: flex;
align-items: center;
justify-content: space-between;
gap: 16rpx;
}
.item-left {
flex: 1;
min-width: 0;
display: flex;
flex-direction: column;
gap: 6rpx;
}
.item-right {
display: flex;
align-items: baseline;
gap: 10rpx;
flex-shrink: 0;
}
.qty-label {
font-size: 22rpx;
color: #667085;
}
.qty-val {
font-size: 30rpx;
font-weight: 700;
color: #101828;
}
.item:first-child {
border-top: none;
padding-top: 0;
}
.item-name {
font-size: 28rpx;
font-weight: 700;
color: #101828;
}
.item-meta {
font-size: 24rpx;
color: #98a2b3;
}
.img-grid {
display: flex;
flex-wrap: wrap;
gap: 12rpx;
}
.img {
width: 210rpx;
height: 210rpx;
border-radius: 16rpx;
background: #f2f4f7;
}
</style>
+450
View File
@@ -0,0 +1,450 @@
<template>
<view class="page">
<uni-nav-bar
leftText=" "
:fixed="true"
leftIcon="back"
background-color="rgb(48, 116, 247)"
color="#fff"
:statusBar="true"
title="借用审核"
@clickLeft="onBack"
/>
<view class="content">
<!-- 基本信息 -->
<view class="card">
<view class="card-head">
<text class="card-title">借用信息</text>
<view class="status-tag" :class="'s' + (detail.status || 0)">
<text class="status-text">{{ statusText }}</text>
</view>
</view>
<view class="row"><text class="label">单号</text><text class="value">{{ detail.order_no || '-' }}</text></view>
<view class="row"><text class="label">申请人</text><text class="value">{{ detail.applicant_name || '-' }}</text></view>
<view class="row">
<text class="label">借用时间</text>
<text class="value">{{ detail.use_start_date || '-' }} ~ {{ detail.use_end_date || '-' }}</text>
</view>
<view class="row"><text class="label">借用事由</text><text class="value">{{ detail.borrow_reason || '-' }}</text></view>
<view class="row" v-if="detail.remark !== undefined">
<text class="label">备注</text>
<text class="value">{{ detail.remark || '-' }}</text>
</view>
</view>
<!-- 物品明细 -->
<view class="card">
<view class="card-head">
<text class="card-title">物品明细</text>
</view>
<view v-if="approveItems.length === 0" class="empty">暂无物品</view>
<view v-for="(it, idx) in approveItems" :key="it.requisition_item_id" class="item">
<view class="item-left">
<text class="item-name">{{ it.requisition_item_name }}</text>
<text class="item-meta" v-if="it.spec_model_snap">规格:{{ it.spec_model_snap }}</text>
</view>
<view class="item-right">
<text class="qty-label">申请数量</text>
<text class="qty-val">{{ it.request_qty }}</text>
</view>
</view>
</view>
<!-- 申请附件 -->
<view class="card" v-if="(detail.attachment || []).length">
<view class="card-head">
<text class="card-title">申请附件</text>
</view>
<view class="img-grid">
<image
v-for="(a, i) in detail.attachment"
:key="a.id || i"
class="img"
:src="a.file_path_pull || ''"
mode="aspectFill"
@click="previewAttachment(i)"
/>
</view>
</view>
<!-- 审核意见 -->
<view class="card">
<view class="card-head">
<text class="card-title">审核意见</text>
</view>
<textarea
class="textarea"
v-model="auditRemark"
placeholder="请输入审核备注(可选)"
:auto-height="true"
maxlength="500"
/>
</view>
<view style="height: 120rpx;"></view>
</view>
<!-- 底部操作 -->
<view class="footer">
<button class="btn btn-ghost" @click="onReject">驳回</button>
<button class="btn btn-primary" @click="onApprove">同意</button>
</view>
</view>
</template>
<script>
import { request, showToast } from '@/api/apiT.js'
// ⚠️ 你需要把这里改成真实的“审核提交接口”
// 如果你后端有具体字段/接口名,发我,我可以帮你对齐成完全可用。
const AUDIT_API = 'admin/inv/requisition/approve'
export default {
data() {
return {
id: '',
detail: {},
approveItems: [],
auditRemark: ''
}
},
computed: {
statusText() {
// 你返回里 status=10;这里做个兼容显示
const s = Number(this.detail.status || 0)
if (this.detail.is_returned === 1) return '已归还'
if (s === 10) return '待审核'
if (s === 11) return '审批中'
if (s === 12) return '待归还'
if (s === 13) return '借用拒绝'
if (s === 14) return '归还待审核'
if (s === 15) return '归还审批中'
if (s === 16) return '部分归还'
if (s === 17) return '已归还'
if (s === 18) return '归还拒绝'
return '处理中'
}
},
onLoad(option) {
this.id = option.id || option.requisition_id || option.requisitionId || ''
if (!this.id) {
showToast({ title: '缺少id参数' })
return
}
this.getDetail()
},
methods: {
onBack() {
uni.navigateBack()
},
getDetail() {
request({
url: 'admin/inv/requisition/show',
method: 'GET',
data: { id: this.id }
}).then((res) => {
this.detail = (res.data && res.data.data) || {}
this.initApproveItems()
})
},
initApproveItems() {
const list = Array.isArray(this.detail.item) ? this.detail.item : []
this.approveItems = list.map((it) => {
// approved_qty 可能后端已经给了;没有就默认=申请数量
const req = Number(it.request_qty || 0)
const approved = it.approved_qty === undefined || it.approved_qty === null ? req : Number(it.approved_qty || 0)
return {
requisition_item_id: it.id,
requisition_item_name: it.item_name_snap || '',
spec_model_snap: it.spec_model_snap || '',
unit_snap: it.unit_snap || '',
request_qty: req,
returned_qty: Number(it.returned_qty || 0),
approved_qty: this.clamp(approved, 0, req)
}
})
},
clamp(v, min, max) {
const n = Number(v || 0)
if (n < min) return min
if (n > max) return max
return n
},
onApprovedQtyChange(idx, val) {
const it = this.approveItems[idx]
if (!it) return
it.approved_qty = this.clamp(val, 0, it.request_qty)
// 触发视图更新
this.$set(this.approveItems, idx, it)
},
previewAttachment(startIndex) {
const urls = (this.detail.attachment || [])
.map((a) => a.file_path_pull)
.filter(Boolean)
if (!urls.length) return
uni.previewImage({
current: urls[startIndex] || urls[0],
urls
})
},
buildPayload(action) {
return {
requisition_id: this.detail.id || this.id,
action, // 'approve' | 'reject'
approve_id:this.detail.approve_id,
comment: this.auditRemark || ''
// items: this.approveItems.map((it) => ({
// requisition_item_id: it.requisition_item_id,
// requisition_item_name: it.requisition_item_name,
// approved_qty: it.approved_qty
// }))
}
},
doSubmit(action) {
if (!this.approveItems.length) {
showToast({ title: '没有可审核的物品' })
return
}
const payload = this.buildPayload(action)
request({
url: AUDIT_API,
method: 'POST',
data: payload
}).then((res) => {
const msg = (res.data && (res.data.message || res.data.msg)) || '操作完成'
showToast({ title: msg })
if (res.data && Number(res.data.code) === 200) {
setTimeout(() => {
// 回到上一页并传递刷新参数
uni.navigateBack({
delta: 1,
success: function() {
// 触发上一页的刷新
const pages = getCurrentPages()
const prevPage = pages[pages.length - 2]
if (prevPage && prevPage.$refs.paging) {
prevPage.$refs.paging.reload()
}
}
})
}, 600)
}
})
},
onApprove() {
uni.showModal({
title: '确认通过',
content: '确认同意该借用申请?',
success: (r) => {
if (r.confirm) this.doSubmit('1')
}
})
},
onReject() {
uni.showModal({
title: '确认驳回',
content: '确认驳回该借用申请?',
success: (r) => {
if (r.confirm) this.doSubmit('2')
}
})
}
}
}
</script>
<style lang="scss">
.page {
min-height: 100vh;
background: rgb(244, 246, 248);
}
.content {
padding: 20rpx;
}
.card {
background: #fff;
border-radius: 20rpx;
padding: 22rpx;
margin-bottom: 18rpx;
box-shadow: 0 6rpx 18rpx rgba(0, 0, 0, 0.04);
}
.card-head {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 16rpx;
}
.card-title {
font-size: 30rpx;
font-weight: 700;
color: #1f2d3d;
}
.card-sub {
font-size: 24rpx;
color: #98a2b3;
}
.row {
display: flex;
align-items: flex-start;
justify-content: space-between;
padding: 10rpx 0;
border-bottom: 1rpx solid #f1f3f5;
}
.row:last-child {
border-bottom: none;
}
.label {
width: 160rpx;
font-size: 26rpx;
color: #667085;
}
.value {
flex: 1;
text-align: right;
font-size: 26rpx;
color: #101828;
}
.status-tag {
padding: 6rpx 14rpx;
border-radius: 999rpx;
background: rgba(48, 116, 247, 0.12);
}
.status-text {
font-size: 24rpx;
color: rgb(48, 116, 247);
}
.empty {
padding: 24rpx 0;
text-align: center;
color: #98a2b3;
font-size: 26rpx;
}
.item {
padding: 16rpx 0;
border-top: 1rpx dashed #eef2f6;
display: flex;
align-items: center;
justify-content: space-between;
gap: 16rpx;
}
.item-left {
flex: 1;
min-width: 0;
display: flex;
flex-direction: column;
gap: 6rpx;
}
.item-right {
display: flex;
align-items: baseline;
gap: 10rpx;
flex-shrink: 0;
}
.qty-label {
font-size: 22rpx;
color: #667085;
}
.qty-val {
font-size: 30rpx;
font-weight: 700;
color: #101828;
}
.item:first-child {
border-top: none;
padding-top: 0;
}
.item-top {
display: flex;
align-items: baseline;
justify-content: space-between;
margin-bottom: 12rpx;
}
.item-name {
font-size: 28rpx;
font-weight: 700;
color: #101828;
}
.item-meta {
font-size: 24rpx;
color: #98a2b3;
}
.grid {
display: flex;
gap: 16rpx;
}
.cell {
flex: 1;
background: #f8fafc;
border-radius: 16rpx;
padding: 14rpx;
}
.k {
display: block;
font-size: 22rpx;
color: #667085;
margin-bottom: 8rpx;
}
.v {
font-size: 26rpx;
color: #101828;
}
.hint {
margin-top: 10rpx;
font-size: 24rpx;
color: #667085;
}
.img-grid {
display: flex;
flex-wrap: wrap;
gap: 12rpx;
}
.img {
width: 210rpx;
height: 210rpx;
border-radius: 16rpx;
background: #f2f4f7;
}
.textarea {
width: 100%;
min-height: 140rpx;
font-size: 26rpx;
line-height: 1.6;
background: #f8fafc;
border-radius: 16rpx;
padding: 16rpx;
box-sizing: border-box;
}
.footer {
position: fixed;
left: 0;
right: 0;
bottom: 0;
padding: 16rpx 20rpx calc(16rpx + env(safe-area-inset-bottom));
background: rgba(255, 255, 255, 0.98);
border-top: 1rpx solid #eef2f6;
display: flex;
gap: 16rpx;
}
.btn {
flex: 1;
height: 84rpx;
line-height: 84rpx;
border-radius: 18rpx;
font-size: 30rpx;
font-weight: 700;
}
.btn-ghost {
background: #fff;
border: 2rpx solid #d0d5dd;
color: #344054;
}
.btn-primary {
background: rgb(48, 116, 247);
color: #fff;
}
</style>
+298
View File
@@ -0,0 +1,298 @@
<template>
<view class="home-page">
<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栏 -->
<view class="tab-bar">
<view
class="tab-item"
:class="{ 'tab-item-active': currentTab === index }"
v-for="(tab, index) in tabList"
:key="index"
@click="switchTab(index)"
>
<text class="tab-text">{{ tab }}</text>
<view v-if="currentTab === index" class="tab-underline"></view>
</view>
</view>
</template>
<!-- 列表内容 -->
<view class="list-container">
<view
class="borrow-card"
v-for="(item, index) in borrowList"
:key="index"
>
<!-- 状态标签(右上角旋转丝带) -->
<view class="status-ribbon" :class="'ribbon-' + item.status">
<text class="ribbon-text">{{ getStatusText(item.status) }}</text>
</view>
<!-- 卡片内容 -->
<view class="card-content" @click="handleCardClick(item)">
<view class="card-title">
<uni-tag :text="item1.item_name" size="mini" type="primary" v-for="(item1, index) in item.item" :key="index"/>
</view>
<view class="card-info">
<text class="info-item">申请人: {{ item.apply_user_name }}</text>
<text class="info-item">归还时间: {{ item.return_at || '-' }}</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"
v-if="item.status==0"
@click.stop="handleAction(item)"
>
{{ getActionText(item.status) }}
</button>
</view>
</view>
</view>
</view>
</view>
</z-paging>
</view>
</template>
<script>
import { request,showToast } from '@/api/apiT.js'
export default {
data() {
return {
currentTab: 0,
tabList: ['全部', '待审核', '已通过', '未通过'],
borrowList: []
}
},
onLoad() {
// 页面加载时初始化数据
this.$nextTick(() => {
if (this.$refs.paging) {
this.$refs.paging.reload()
}
})
},
methods: {
leftClick(){
uni.navigateBack({})
},
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,
status: this.currentTab === 0 ? '' : (this.currentTab === 1 ? '0' : (this.currentTab === 2 ? '1' : '2'))
};
request({
url:'mobile/inv/requisition/return/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 = {
'0': '待审核',
'1': '已通过',
'2': '未通过'
}
return statusMap[status] || ''
},
getActionText(status) {
const actionMap = {
'0': '去审核',
'1': '已通过',
'2': '未通过'
}
return actionMap[status] || ''
},
handleAction(item) {
uni.navigateTo({
url: '/pages/approval/return_approval_detils?id='+item.id
});
},
handleCardClick(item) {
uni.navigateTo({
url: '/pages/approval/return_approval_detail?id='+item.id
});
}
}
}
</script>
<style lang="scss">
.home-page {
min-height: 100vh;
background: rgb(244, 246, 248);
}
.content-wrapper {
}
// Tab栏样式
.tab-bar {
display: flex;
background: #F4F6F8;
}
.tab-item {
flex: 1;
position: relative;
padding: 24rpx 0;
text-align: center;
}
.tab-text {
font-size: 28rpx;
color: #666;
}
.tab-item-active .tab-text {
color: #3074F7;
font-weight: 500;
}
.tab-underline {
position: absolute;
bottom: 0;
left: 50%;
transform: translateX(-50%);
width: 60rpx;
height: 4rpx;
background: #3074F7;
border-radius: 2rpx;
}
// 列表容器
.list-container {
padding: 24rpx 28rpx;
}
// 借用卡片
.borrow-card {
position: relative;
background: #fff;
border-radius: 12rpx;
margin-bottom: 24rpx;
box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.05);
overflow: hidden;
}
// 状态标签(旋转丝带效果)
.status-ribbon {
position: absolute;
top: -4px;
right: -32px;
width: 100px;
height: 47px;
background: #08A400;
transform: rotate(45deg);
z-index: 10;
display: flex;
align-items: center;
justify-content: center;
box-shadow: 0 2rpx 4rpx rgba(0, 0, 0, 0.15);
}
.ribbon-0 {
background: #3471FF; // 蓝色
}
.ribbon-2 {
background: #F5222D;
}
.ribbon-1 {
background: #389E0D;
}
.ribbon-text {
color: #fff;
font-size: 20rpx;
font-weight: 500;
transform: rotate(0deg);
transform-origin: center;
display: block;
text-align: center;
margin-top: 16rpx;
white-space: nowrap;
letter-spacing: 1rpx;
}
// 卡片内容
.card-content {
padding: 28rpx;
}
.card-title {
font-size: 32rpx;
font-weight: 500;
color: #333;
margin-bottom: 24rpx;
}
.card-info {
display: flex;
flex-direction: column;
gap: 12rpx;
margin-bottom: 24rpx;
}
.info-item {
font-size: 26rpx;
color: #666;
line-height: 1.6;
}
// 操作按钮
.card-actions {
display: flex;
justify-content: flex-end;
}
.action-btns{
display: flex;
justify-content: space-between;
align-items: center;
}
.action-btn {
padding: 14rpx 40rpx;
background: #3074F7;
color: #fff;
border-radius: 8rpx;
font-size: 26rpx;
border: none;
line-height: 1;
&::after {
border: none;
}
}
.btn-notReturned {
background: #3074F7;
}
.btn-pendingReview {
background: #3074F7;
}
</style>
+308
View File
@@ -0,0 +1,308 @@
<template>
<view class="page">
<uni-nav-bar
leftText=" "
:fixed="true"
leftIcon="back"
background-color="rgb(48, 116, 247)"
color="#fff"
:statusBar="true"
title="归还详情"
@clickLeft="onBack"
/>
<view class="content">
<!-- 基本信息 -->
<view class="card">
<view class="card-head">
<text class="card-title">归还信息</text>
<view class="status-tag" :class="'s' + (detail.status || 0)">
<text class="status-text">{{ statusText }}</text>
</view>
</view>
<view class="row"><text class="label">申请人</text><text class="value">{{ detail.apply_user_name || '-' }}</text></view>
<view class="row"><text class="label">归还时间</text><text class="value">{{ detail.return_at || '-' }}</text></view>
<view class="row" v-if="detail.apply_remark !== undefined">
<text class="label">归还备注</text>
<text class="value">{{ detail.apply_remark || '-' }}</text>
</view>
</view>
<!-- 物品明细 -->
<view class="card">
<view class="card-head">
<text class="card-title">归还物品</text>
</view>
<view v-if="detail.item && detail.item.length === 0" class="empty">暂无物品</view>
<view v-for="(it, idx) in detail.item" :key="it.id" class="item">
<view class="item-left">
<text class="item-name">{{ it.item_name || '-' }}</text>
<text class="item-meta" v-if="it.spec_model">规格:{{ it.spec_model }}</text>
</view>
<view class="item-right">
<text class="qty-label">归还数量</text>
<text class="qty-val">{{ detail.return_qty || 0 }}</text>
</view>
</view>
</view>
<!-- 借用详情 -->
<view class="card" v-if="borrowDetail.id">
<view class="card-head">
<text class="card-title">借用信息</text>
</view>
<view class="row"><text class="label">申请人</text><text class="value">{{ borrowDetail.applicant_name || '-' }}</text></view>
<view class="row"><text class="label">借用时间</text><text class="value">{{ borrowDetail.use_start_date || '-' }} ~ {{ borrowDetail.use_end_date || '-' }}</text></view>
<view class="row" v-if="borrowDetail.borrow_reason !== undefined">
<text class="label">借用事由</text>
<text class="value">{{ borrowDetail.borrow_reason || '-' }}</text>
</view>
</view>
<!-- 借用物品明细 -->
<view class="card" v-if="borrowDetail.id">
<view class="card-head">
<text class="card-title">借用物品明细</text>
</view>
<view v-if="!borrowDetail.item || borrowDetail.item.length === 0" class="empty">暂无物品</view>
<view v-for="(it, idx) in borrowDetail.item" :key="it.id || idx" class="item">
<view class="item-left">
<text class="item-name">{{ it.item_name_snap || '-' }}</text>
<text class="item-meta" v-if="String(it.is_consumable_snap) === '1'">耗材</text>
</view>
<view class="item-right">
<view class="grid-cell">
<text class="g-label">数量</text>
<text class="g-val">{{ safeNum(it.request_qty) }}</text>
</view>
</view>
</view>
</view>
<!-- 审核信息 -->
<view class="card" v-if="detail.audit_info">
<view class="card-head">
<text class="card-title">审核信息</text>
</view>
<view class="row"><text class="label">审核人</text><text class="value">{{ detail.audit_info.handler_name || '-' }}</text></view>
<view class="row"><text class="label">审核时间</text><text class="value">{{ detail.audit_info.handle_time || '-' }}</text></view>
<view class="row" v-if="detail.audit_info.handle_remark">
<text class="label">审核意见</text>
<text class="value">{{ detail.audit_info.handle_remark }}</text>
</view>
</view>
</view>
</view>
</template>
<script>
import { request, showToast } from '@/api/apiT.js'
export default {
data() {
return {
id: '',
detail: {},
borrowDetail: {} // 借用详情数据
}
},
computed: {
statusText() {
const s = Number(this.detail.status || 0)
if (s === 0) return '待审核'
if (s === 1) return '已通过'
if (s === 2) return '已驳回'
return '处理中'
}
},
onLoad(option) {
this.id = option.id || ''
if (!this.id) {
showToast({ title: '缺少id参数' })
return
}
this.getDetail()
},
methods: {
onBack() {
uni.navigateBack()
},
getDetail() {
request({
url: 'mobile/inv/requisition/return/show',
method: 'GET',
data: { id: this.id }
}).then((res) => {
if (res.data && res.data.code === 200) {
this.detail = res.data.data || {}
// 兜底,避免 v-for 报错
this.detail.item = Array.isArray(this.detail.item) ? this.detail.item : []
// 如果有借用详情的id,则获取借用详情数据
const borrowId = this.detail.requisition_item_id || this.detail.item_id
if (borrowId) {
this.getBorrowDetail(borrowId)
}
} else {
showToast({ title: res.data.message || '获取详情失败' })
}
})
},
// 获取借用详情数据
getBorrowDetail(borrowId) {
request({
url: 'mobile/inv/requisition/show',
method: 'GET',
data: { id: borrowId }
}).then((res) => {
if (res.data && res.data.code === 200) {
this.borrowDetail = res.data.data || {}
// 兜底,避免 v-for 报错
this.borrowDetail.item = Array.isArray(this.borrowDetail.item) ? this.borrowDetail.item : []
} else {
showToast({ title: res.data.message || '获取借用详情失败' })
}
})
},
// 安全处理数字显示
safeNum(v) {
const n = Number(v)
return Number.isFinite(n) ? n : 0
}
}
}
</script>
<style lang="scss">
.page {
min-height: 100vh;
background: rgb(244, 246, 248);
}
.content {
padding: 20rpx;
}
.card {
background: #fff;
border-radius: 20rpx;
padding: 22rpx;
margin-bottom: 18rpx;
box-shadow: 0 6rpx 18rpx rgba(0, 0, 0, 0.04);
}
.card-head {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 16rpx;
}
.card-title {
font-size: 30rpx;
font-weight: 700;
color: #1f2d3d;
}
.row {
display: flex;
align-items: flex-start;
justify-content: space-between;
padding: 10rpx 0;
border-bottom: 1rpx solid #f1f3f5;
}
.row:last-child {
border-bottom: none;
}
.label {
width: 160rpx;
font-size: 26rpx;
color: #667085;
}
.value {
flex: 1;
text-align: right;
font-size: 26rpx;
color: #101828;
}
.status-tag {
padding: 6rpx 14rpx;
border-radius: 999rpx;
background: rgba(48, 116, 247, 0.12);
}
.status-text {
font-size: 24rpx;
color: rgb(48, 116, 247);
}
.empty {
padding: 24rpx 0;
text-align: center;
color: #98a2b3;
font-size: 26rpx;
}
.item {
padding: 16rpx 0;
border-top: 1rpx dashed #eef2f6;
display: flex;
align-items: center;
justify-content: space-between;
gap: 16rpx;
}
.item-left {
flex: 1;
min-width: 0;
display: flex;
flex-direction: column;
gap: 6rpx;
}
.item-right {
display: flex;
align-items: baseline;
gap: 10rpx;
flex-shrink: 0;
}
.qty-label {
font-size: 22rpx;
color: #667085;
}
.qty-val {
font-size: 30rpx;
font-weight: 700;
color: #101828;
}
.item:first-child {
border-top: none;
padding-top: 0;
}
.item-name {
font-size: 28rpx;
font-weight: 700;
color: #101828;
}
.item-meta {
font-size: 24rpx;
color: #98a2b3;
}
/* 借用物品明细样式 */
.grid-cell {
// background: #fafbff;
border-radius: 10rpx;
padding: 14rpx 10rpx;
text-align: center;
// border: 1rpx solid #f0f0f0;
margin-left: 10rpx;
}
.g-label {
display: block;
font-size: 22rpx;
color: #888;
margin-bottom: 6rpx;
}
.g-val {
display: block;
font-size: 30rpx;
font-weight: 700;
color: #222;
}
</style>
+348
View File
@@ -0,0 +1,348 @@
<template>
<view class="page">
<uni-nav-bar
leftText=" "
:fixed="true"
leftIcon="back"
background-color="rgb(48, 116, 247)"
color="#fff"
:statusBar="true"
title="归还审核"
@clickLeft="onBack"
/>
<view class="content">
<!-- 基本信息 -->
<view class="card">
<view class="card-head">
<text class="card-title">归还信息</text>
<view class="status-tag" :class="'s' + (detail.status || 0)">
<text class="status-text">{{ statusText }}</text>
</view>
</view>
<view class="row"><text class="label">申请人</text><text class="value">{{ detail.apply_user_name || '-' }}</text></view>
<view class="row"><text class="label">归还时间</text><text class="value">{{ detail.return_at || '-' }}</text></view>
<view class="row" v-if="detail.apply_remark !== undefined">
<text class="label">归还备注</text>
<text class="value">{{ detail.apply_remark || '-' }}</text>
</view>
</view>
<!-- 物品明细 -->
<view class="card">
<view class="card-head">
<text class="card-title">归还物品</text>
</view>
<view v-if="approveItems.length === 0" class="empty">暂无物品</view>
<view v-for="(it, idx) in approveItems" :key="it.item_id" class="item">
<view class="item-left">
<text class="item-name">{{ it.item_name }}</text>
<text class="item-meta" v-if="it.spec_model">规格:{{ it.spec_model }}</text>
</view>
<view class="item-right">
<text class="qty-label">归还数量</text>
<text class="qty-val">{{ detail.return_qty || 0 }}</text>
</view>
</view>
</view>
<!-- 审核意见 -->
<view class="card">
<view class="card-head">
<text class="card-title">审核意见</text>
</view>
<textarea
class="textarea"
v-model="auditRemark"
placeholder="请输入审核备注(可选)"
:auto-height="true"
maxlength="500"
/>
</view>
<view style="height: 120rpx;"></view>
</view>
<!-- 底部操作 -->
<view class="footer">
<button class="btn btn-ghost" @click="onReject">驳回</button>
<button class="btn btn-primary" @click="onApprove">同意</button>
</view>
</view>
</template>
<script>
import { request, showToast } from '@/api/apiT.js'
// 归还审核提交接口
const AUDIT_API = 'mobile/inv/requisition/return/confirm'
export default {
data() {
return {
id: '',
detail: {},
approveItems: [],
auditRemark: ''
}
},
computed: {
statusText() {
const s = Number(this.detail.status || 0)
if (s === 0) return '待审核'
if (s === 1) return '已通过'
if (s === 2) return '已驳回'
return '处理中'
}
},
onLoad(option) {
this.id = option.id || ''
if (!this.id) {
showToast({ title: '缺少id参数' })
return
}
this.getDetail()
},
methods: {
onBack() {
uni.navigateBack()
},
getDetail() {
request({
url: 'mobile/inv/requisition/return/show',
method: 'GET',
data: { id: this.id }
}).then((res) => {
this.detail = (res.data && res.data.data) || {}
this.initApproveItems()
})
},
initApproveItems() {
const list = Array.isArray(this.detail.item) ? this.detail.item : []
this.approveItems = list.map((it) => {
return {
item_id: it.id,
item_name: it.item_name || '',
spec_model: it.spec_model || '',
unit: it.unit || ''
}
})
},
buildPayload(action) {
return {
requisition_item_return_id: this.id,
status: action, // '1' 同意 | '2' 驳回
handle_remark: this.auditRemark || ''
}
},
doSubmit(action) {
if (!this.approveItems.length) {
showToast({ title: '没有可审核的物品' })
return
}
const payload = this.buildPayload(action)
request({
url: AUDIT_API,
method: 'POST',
data: payload
}).then((res) => {
const msg = (res.data && (res.data.message || res.data.msg)) || '操作完成'
showToast({ title: msg })
if (res.data && Number(res.data.code) === 200) {
setTimeout(() => {
// 回到上一页并传递刷新参数
uni.navigateBack({
delta: 1,
success: function() {
// 触发上一页的刷新
const pages = getCurrentPages()
const prevPage = pages[pages.length - 2]
if (prevPage && prevPage.$refs.paging) {
prevPage.$refs.paging.reload()
}
}
})
}, 600)
}
})
},
onApprove() {
uni.showModal({
title: '确认通过',
content: '确认同意该归还申请?',
success: (r) => {
if (r.confirm) this.doSubmit('1')
}
})
},
onReject() {
uni.showModal({
title: '确认驳回',
content: '确认驳回该归还申请?',
success: (r) => {
if (r.confirm) this.doSubmit('2')
}
})
}
}
}
</script>
<style lang="scss">
.page {
min-height: 100vh;
background: rgb(244, 246, 248);
}
.content {
padding: 20rpx;
}
.card {
background: #fff;
border-radius: 20rpx;
padding: 22rpx;
margin-bottom: 18rpx;
box-shadow: 0 6rpx 18rpx rgba(0, 0, 0, 0.04);
}
.card-head {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 16rpx;
}
.card-title {
font-size: 30rpx;
font-weight: 700;
color: #1f2d3d;
}
.card-sub {
font-size: 24rpx;
color: #98a2b3;
}
.row {
display: flex;
align-items: flex-start;
justify-content: space-between;
padding: 10rpx 0;
border-bottom: 1rpx solid #f1f3f5;
}
.row:last-child {
border-bottom: none;
}
.label {
width: 160rpx;
font-size: 26rpx;
color: #667085;
}
.value {
flex: 1;
text-align: right;
font-size: 26rpx;
color: #101828;
}
.status-tag {
padding: 6rpx 14rpx;
border-radius: 999rpx;
background: rgba(48, 116, 247, 0.12);
}
.status-text {
font-size: 24rpx;
color: rgb(48, 116, 247);
}
.empty {
padding: 24rpx 0;
text-align: center;
color: #98a2b3;
font-size: 26rpx;
}
.item {
padding: 16rpx 0;
border-top: 1rpx dashed #eef2f6;
display: flex;
align-items: center;
justify-content: space-between;
gap: 16rpx;
}
.item-left {
flex: 1;
min-width: 0;
display: flex;
flex-direction: column;
gap: 6rpx;
}
.item-right {
display: flex;
align-items: baseline;
gap: 10rpx;
flex-shrink: 0;
}
.qty-label {
font-size: 22rpx;
color: #667085;
}
.qty-val {
font-size: 30rpx;
font-weight: 700;
color: #101828;
}
.item:first-child {
border-top: none;
padding-top: 0;
}
.item-top {
display: flex;
align-items: baseline;
justify-content: space-between;
margin-bottom: 12rpx;
}
.item-name {
font-size: 28rpx;
font-weight: 700;
color: #101828;
}
.item-meta {
font-size: 24rpx;
color: #98a2b3;
}
.textarea {
width: 100%;
min-height: 140rpx;
font-size: 26rpx;
line-height: 1.6;
background: #f8fafc;
border-radius: 16rpx;
padding: 16rpx;
box-sizing: border-box;
}
.footer {
position: fixed;
left: 0;
right: 0;
bottom: 0;
padding: 16rpx 20rpx calc(16rpx + env(safe-area-inset-bottom));
background: rgba(255, 255, 255, 0.98);
border-top: 1rpx solid #eef2f6;
display: flex;
gap: 16rpx;
}
.btn {
flex: 1;
height: 84rpx;
line-height: 84rpx;
border-radius: 18rpx;
font-size: 30rpx;
font-weight: 700;
}
.btn-ghost {
background: #fff;
border: 2rpx solid #d0d5dd;
color: #344054;
}
.btn-primary {
background: rgb(48, 116, 247);
color: #fff;
}
</style>
+303 -228
View File
@@ -1,103 +1,108 @@
<template>
<view class="home-page">
<uni-nav-bar leftText=" " :fixed="true" leftIcon="back" :border="false" @clickLeft="leftClick" color="#fff" backgroundColor="rgb(79 137 247)" :statusBar="true" title="借用申请"></uni-nav-bar>
<uni-nav-bar leftText=" " :fixed="true" leftIcon="back" :border="false" color="#fff" backgroundColor="rgb(79 137 247)" :statusBar="true" title="借用申请" @clickLeft="leftClick"></uni-nav-bar>
<view class="content-wrapper">
<!-- 申请人信息卡片 -->
<view class="form-card">
<view class="form-item form-item-row">
<text class="form-label">申请人:</text>
<text class="form-value">{{ formData.applicant || '犇犇' }}</text>
<text class="form-value">{{ userinfo.name || '犇犇' }}</text>
</view>
<view class="form-item form-item-row">
<text class="form-label">公司名称:</text>
<text class="form-value">{{ formData.companyName || '合塑' }}</text>
<text class="form-value">{{ userinfo.corp_name || '合塑' }}</text>
</view>
</view>
<!-- 借用详情卡片 -->
<!-- 借用时间 -->
<view class="form-card4">
<!-- 借用时间 -->
<view class="form-item form-item-row">
<text class="form-label required">借用时间</text>
<view class="form-input-container">
<uni-datetime-picker
ref="borrowTimePicker"
type="datetime"
v-model="formData.borrowTime"
type="date"
v-model="formData.use_start_date"
placeholder="请选择时间"
:border="false"
:clear-icon="false"
@change="onBorrowTimeChange"
>
<view class="custom-datetime-input">
<text class="custom-datetime-text" :class="{ 'placeholder': !formData.borrowTime }">
{{ formData.borrowTime || '请选择时间' }}
<text class="custom-datetime-text" :class="{ 'placeholder': !formData.use_start_date }">
{{ formData.use_start_date || '请选择时间' }}
</text>
<uni-icons type="calendar" size="18" color="#999"></uni-icons>
<uni-icons type="calendar" size="16" color="#999"></uni-icons>
</view>
</uni-datetime-picker>
</view>
</view>
</view>
<view class="form-card4">
<!-- 计划归还时间 -->
<!-- 计划归还时间 -->
<view class="form-card4">
<view class="form-item form-item-row">
<text class="form-label required">计划归还时间</text>
<view class="form-input-container">
<uni-datetime-picker
ref="returnTimePicker"
type="datetime"
v-model="formData.returnTime"
type="date"
v-model="formData.use_end_date"
placeholder="请选择时间"
:border="false"
:clear-icon="false"
@change="onReturnTimeChange"
>
<view class="custom-datetime-input">
<text class="custom-datetime-text" :class="{ 'placeholder': !formData.returnTime }">
{{ formData.returnTime || '请选择时间' }}
<text class="custom-datetime-text" :class="{ 'placeholder': !formData.use_end_date }">
{{ formData.use_end_date || '请选择时间' }}
</text>
<uni-icons type="calendar" size="18" color="#999"></uni-icons>
<uni-icons type="calendar" size="16" color="#999"></uni-icons>
</view>
</uni-datetime-picker>
</view>
</view>
</view>
<view class="form-card4">
<!-- 物品名称 -->
<view class="form-item form-item-row">
<text class="form-label required">物品名称</text>
<view class="form-input-container">
<uni-data-select
v-model="formData.itemName"
:localdata="itemNameOptions"
placeholder="请选择"
:clear="false"
></uni-data-select>
</view>
<!-- ✅ 物品(可添加多条) -->
<view class="goods-card">
<view class="goods-head">
<text class="form-label required">物品</text>
<button class="goods-add-btn" size="mini" @click="addItem">+ 添加</button>
</view>
</view>
<view class="form-card4">
<!-- 物品所属公司 -->
<view class="form-item form-item-row">
<text class="form-label required">物品所属公司</text>
<view class="form-input-container">
<uni-data-select
v-model="formData.itemCompany"
:localdata="itemCompanyOptions"
placeholder="请选择"
:clear="false"
></uni-data-select>
<view class="goods-module" v-for="(it, idx) in formData.items" :key="idx">
<view class="goods-module-top">
<text class="goods-module-title">物品 {{ idx + 1 }}</text>
<uni-icons
v-if="formData.items.length > 1"
type="trash"
size="18"
color="#ff4d4f"
@click="removeItem(idx)"
></uni-icons>
</view>
<view class="goods-module-body">
<view class="goods-name">
<picker mode="selector" :range="itemNameOptions" range-key="item_name" @change="(e) => onItemNameChange(e, idx)">
<view class="category-content">
<text class="category-text">{{it.item_name_snap || '请选择物品'}}</text>
</view>
</picker>
</view>
<view class="goods-qty">
<uni-number-box v-model="it.request_qty" :min="1" :max="999"></uni-number-box>
</view>
</view>
</view>
</view>
<view class="form-card">
<!-- 借用事由 -->
<view class="form-item">
<text class="form-label required">借用事由</text>
<text class="form-label required form-label1">借用事由</text>
<uni-easyinput
v-model="formData.borrowReason"
v-model="formData.borrow_reason"
type="textarea"
:autoHeight="true"
placeholder="请填写借用事由"
@@ -105,12 +110,13 @@
></uni-easyinput>
</view>
</view>
<!-- 备注卡片 -->
<view class="form-card " style="margin-bottom: 8rpx;">
<view class="form-item">
<text class="form-label">备注</text>
<uni-easyinput
v-model="formData.remarks"
v-model="formData.remark"
type="textarea"
:autoHeight="true"
placeholder="请填写备注"
@@ -118,116 +124,204 @@
></uni-easyinput>
</view>
</view>
<!-- 附件卡片 -->
<!-- 附件上传 -->
<view class="form-card">
<view class="form-item">
<text class="form-label form-label1">附件</text>
<uni-file-picker
v-model="formData.attachments"
file-mediatype="image"
mode="grid"
:limit="9"
:auto-upload="false"
@select="onFileSelect"
>
<image src="/static/image/upload.png" mode="" class="addimg"></image>
</uni-file-picker>
<text class="form-label">附件</text>
<view class="media-upload-wrapper">
<uni-file-picker ref="mediaPicker" limit="20" fileMediatype="image" @select="selectMedia" @delete="delfn" >
<view class="upload-icon-wrapper">
<image src="/static/image/upload.png" mode="" class="addimg"></image>
</view>
</uni-file-picker>
</view>
</view>
</view>
<!-- 提交按钮 -->
<view class="submit-btn-wrapper">
<button class="submit-btn" @click="handleSubmit">提交</button>
<view class="submit-container">
<button class="submit-btn" @click="handleSubmit">提交申请</button>
</view>
</view>
</view>
</template>
<script>
import { request,showToast } from '@/api/apiT.js'
export default {
data() {
return {
userinfo: {},
maxMedia:20,
formData: {
applicant: '犇犇',
companyName: '合塑',
borrowTime: '',
returnTime: '',
itemName: '',
itemCompany: '',
borrowReason: '',
remarks: '',
attachments: []
use_start_date: '',
use_end_date: '',
items: [{ item_name_snap: '',item_id:'',request_qty:1}],
borrow_reason: '',
remark: '',
attachment: []
},
itemNameOptions: [
{ text: '物品1', value: 'item1' },
{ text: '物品2', value: 'item2' },
{ text: '物品3', value: 'item3' }
],
itemCompanyOptions: [
{ text: '公司A', value: 'companyA' },
{ text: '公司B', value: 'companyB' },
{ text: '公司C', value: 'companyC' }
]
itemNameOptions: [],
}
},
onLoad() {
this.getinfo()
this.getItemNameOptions()
},
methods: {
leftClick(){
uni.navigateBack({})
},
getinfo(){
request({
url:'common/user/info',
method:'get',
}).then(res => {
this.userinfo=res.data.data.user
})
},
//物品下拉
getItemNameOptions() {
request({
url:'mobile/inv/item/preset',
method:'get',
}).then(res => {
this.itemNameOptions = res.data.data
this.itemNameOptions.forEach(item => {
item.item_name = item.item_name + '(' + item.company_name + ')'
})
console.log(this.itemNameOptions)
})
},
onItemNameChange(e, itemIndex) {
console.log(e, itemIndex)
const index = e.detail.value; // picker 返回的 index
const selectItem = this.itemNameOptions[index]; // 直接取整条数据
if (this.formData.items[itemIndex]) {
this.formData.items[itemIndex].item_name_snap = selectItem.item_name
this.formData.items[itemIndex].item_id = selectItem.id
}
},
onBorrowTimeChange(e) {
// uni-datetime-picker返回的已经是格式化后的字符串
this.formData.borrowTime = e
this.formData.use_start_date = e
},
onReturnTimeChange(e) {
// uni-datetime-picker返回的已经是格式化后的字符串
this.formData.returnTime = e
this.formData.use_end_date = e
},
onFileSelect(e) {
console.log('文件选择:', e)
},
addItem() {
// 追加一条物品
this.formData.items = Array.isArray(this.formData.items) ? this.formData.items : []
this.formData.items.push({
item_name_snap: '',
item_id: '',
request_qty: 1
})
},
removeItem(index) {
// 删除指定物品(至少保留 1 条)
if (!Array.isArray(this.formData.items)) return
if (this.formData.items.length <= 1) return
this.formData.items.splice(index, 1)
},
uploadfn(imgUrl){
return new Promise((resolve, reject) => {
uni.uploadFile({
url: 'https://fdesk.hnxinyouhe.com/upload?scene=itemsimg',
filePath: imgUrl,
name: 'file',
header:{'Fdesk-Corp-Abbr':uni.getStorageSync('corp_abbr'),'Fdesk-Auth-Token': 'Bearer ' + uni.getStorageSync('token'),'Fdesk-Language': uni.getStorageSync('i18locale')?uni.getStorageSync('i18locale'):'zh','Fdesk-Login-Type': 'feishu','Fdesk-System-Code':'fdesk'},
success: (uploadFileRes) => {
const res = JSON.parse(uploadFileRes.data || '{}')
if(res && res.data && res.data.file_name){
resolve(res.data)
}else{
reject('上传失败')
}
},
fail: (err) => reject(err)
});
})
},
selectMedia(e){
const allowCount = this.maxMedia - this.formData.attachment.length
const tempFilePaths = e.tempFilePaths || (e.tempFiles || []).map(item => item.path || item.url)
const paths = tempFilePaths.slice(0, allowCount)
if(paths.length === 0){
return
}
Promise.all(paths.map(p => this.uploadfn(p))).then(urls => {
urls.forEach(url => {
const obj={}
obj.original_name =url.original_name
obj.file_path =url.file_name
this.formData.attachment.push(obj)
})
}).catch(() => {
uni.showToast({
title:'图片上传失败,请重试',
icon:'none'
})
})
},
delfn(e){
this.formData.attachment.splice(e.index, 1)
},
handleSubmit() {
// 表单验证
if (!this.formData.borrowTime) {
uni.showToast({
title: '请选择借用时间',
icon: 'none'
})
if (!this.formData.use_start_date) {
uni.showToast({ title: '请选择借用时间', icon: 'none' })
return
}
if (!this.formData.returnTime) {
uni.showToast({
title: '请选择计划归还时间',
icon: 'none'
})
return
}
if (!this.formData.itemName) {
uni.showToast({
title: '请选择物品名称',
icon: 'none'
})
return
}
if (!this.formData.itemCompany) {
uni.showToast({
title: '请选择物品所属公司',
icon: 'none'
})
return
}
if (!this.formData.borrowReason) {
uni.showToast({
title: '请填写借用事由',
icon: 'none'
})
if (!this.formData.use_end_date) {
uni.showToast({ title: '请选择计划归还时间', icon: 'none' })
return
}
// 物品列表校验(至少 1 条,且每条需选择名称 + 数量)
if (!Array.isArray(this.formData.items) || this.formData.items.length === 0) {
uni.showToast({ title: '请添加物品', icon: 'none' })
return
}
for (let i = 0; i < this.formData.items.length; i++) {
const it = this.formData.items[i] || {}
if (!it.item_name_snap) {
uni.showToast({ title: `请选择第${i + 1}个物品名称`, icon: 'none' })
return
}
const request_qty = Number(it.request_qty)
if (!request_qty || request_qty <= 0) {
uni.showToast({ title: `请填写第${i + 1}个物品数量`, icon: 'none' })
return
}
}
if (!this.formData.borrow_reason) {
uni.showToast({ title: '请填写借用事由', icon: 'none' })
return
}
// 提交表单
console.log('提交表单:', this.formData)
uni.showToast({
title: '提交成功',
icon: 'success'
request({
url:'mobile/inv/requisition/apply',
method:'post',
data:this.formData
}).then(res => {
uni.showToast({
title: res.data.message,
icon: 'none'
});
if(res.data.code==200){
setTimeout(() => {
uni.reLaunch({
url: '/pages/index/index',// 替换为你要跳转的页面路径
});
}, 1000);
}
})
// 这里可以调用API提交数据
}
@@ -246,16 +340,21 @@
.content-wrapper{
margin-top: 20rpx;
}
.media-upload-wrapper{
display: flex;
flex-wrap: wrap;
gap: 16rpx;
}
.addimg{
width: 50px;
height:50px;
}
.form-card {
background: #fff;
border-radius: 12rpx;
padding:20rpx 34rpx;
border-radius: 16rpx;
padding: 24rpx;
margin-bottom: 24rpx;
box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.05);
box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
}
.form-card4 {
background: #fff;
@@ -266,152 +365,130 @@
height: 35px;
line-height: 35px;
}
.form-item {
margin-bottom: 32rpx;
&:last-child {
margin-bottom: 0;
}
&.form-item-row {
display: flex;
align-items: center;
flex-wrap: nowrap;
}
/* 物品(可添加多条) */
.goods-card {
background: #fff;
border-radius: 6px;
padding: 12px 17px;
margin-bottom: 4px;
box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
}
.goods-head {
display: flex;
align-items: center;
justify-content: space-between;
width: 100%;
margin-bottom: 10px;
}
.goods-add-btn {
background: #3074F7;
color: #fff;
border-radius: 14px;
font-size: 24rpx;
margin-left: auto;
margin-right: inherit;
}
.goods-module {
background: #F7F8FA;
border-radius: 8px;
padding: 10px;
margin-bottom: 10px;
}
.goods-module-top {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 8px;
}
.goods-module-title {
font-size: 26rpx;
color: #333;
}
.goods-module-body {
display: flex;
align-items: center;
}
.goods-name {
flex: 1;
min-width: 0;
}
.goods-qty {
width: 220rpx;
display: flex;
justify-content: flex-end;
margin-left: 16rpx;
}
::v-deep .goods-qty .uni-numbox {
scale: 0.95;
transform-origin: right center;
}
.form-item {
margin-bottom: 32rpx;
&:last-child { margin-bottom: 0; }
}
.form-item-row {
display: flex;
align-items: center;
justify-content: space-between;
}
.form-label1{
margin-bottom: 16rpx;
}
.form-item-row .form-label {
margin-bottom: 0;
margin-right: 24rpx;
}
.form-input-container {
flex: 1;
min-width: 0;
}
.form-label {
font-size: 28rpx;
color: #333;
// margin-bottom: 16rpx;
display: block;
flex-shrink: 0;
min-width: 160rpx;
&.required::before {
content: '*';
color: #ff0000;
margin-right: 4rpx;
}
}
.form-label1{
margin-bottom: 16rpx;
}
.form-item-row .form-label {
margin-bottom: 0;
margin-right: 24rpx;
}
.form-input-container {
flex: 1;
min-width: 0;
}
.form-value {
font-size: 28rpx;
color: #666;
flex: 1;
text-align: right;
}
.form-input-wrapper {
width: 100%;
.category-text{
font-size: 28rpx;
color: #333;
}
.form-input-container .form-input-wrapper {
width: 100%;
}
.custom-datetime-input {
border-radius: 4px;
box-sizing: border-box;
display: flex;
align-items: center;
justify-content: space-between;
width: 100%;
text-align: right;
}
.custom-datetime-text {
font-size: 28rpx;
color: #333;
flex: 1;
&.placeholder {
color: #999;
}
}
// uni-datetime-picker 样式覆盖
::v-deep .uni-date-editor {
width: 100%;
}
::v-deep .uni-date-editor--x {
border: none !important;
background: transparent !important;
padding: 0 !important;
}
::v-deep .uni-date-x {
width: 100%;
padding: 0 !important;
}
::v-deep .uni-date__x-input {
display: none;
}
::v-deep .icon-calendar {
display: none;
}
.submit-btn-wrapper {
.submit-container {
margin-top: 40rpx;
padding-bottom: 40rpx;
}
.submit-btn {
width: 70%;
height: 88rpx;
background: #3074F7;
color: #fff;
border-radius: 44rpx;
font-size: 32rpx;
border-radius: 12rpx;
height: 88rpx;
line-height: 88rpx;
border: none;
&::after {
border: none;
}
}
// uni-data-select 样式调整
::v-deep .uni-stat__select {
width: 100%;
}
::v-deep .uni-select {
width: 100%;
border: none;
text-align: right;
}
::v-deep .uni-select__input-text {
font-size: 28rpx;
color: #333;
}
::v-deep .uni-select__input-placeholder {
color: #999;
}
// uni-easyinput 样式调整
::v-deep .uni-easyinput {
width: 100%;
}
::v-deep .uni-easyinput__content {
border: none;
min-height: 120rpx;
}
::v-deep .uni-easyinput__content-textarea {
@@ -420,8 +497,6 @@
min-height: 120rpx;
padding-left: 0px;
}
// uni-file-picker 样式调整
::v-deep .uni-file-picker {
width: 100%;
}
+406 -135
View File
@@ -1,71 +1,122 @@
<template>
<view class="home-page">
<uni-nav-bar leftText=" " :fixed="true" leftIcon="back" :border="false" @clickLeft="leftClick" color="#fff" backgroundColor="rgb(79 137 247)" :statusBar="true" title="详情"></uni-nav-bar>
<uni-nav-bar
leftText=" "
:fixed="true"
leftIcon="back"
:border="false"
@clickLeft="leftClick"
color="#fff"
backgroundColor="rgb(79 137 247)"
:statusBar="true"
title="详情"
></uni-nav-bar>
<view class="content-wrapper">
<view class="detail-card">
<!-- 状态丝带 -->
<view class="status-ribbon" :class="statusClass">
<text class="ribbon-text">{{ statusText }}</text>
<view class="status-ribbon" :class="statusMeta.cls">
<text class="ribbon-text">{{ statusMeta.text }}</text>
</view>
<!-- 标题 -->
<!-- 头部信息 -->
<view class="card-header">
<text class="item-title">{{ detail.itemName }}</text>
</view>
<!-- 申请信息 -->
<view class="section">
<text class="section-title">申请信息</text>
<view class="info-row">
<text class="label">申请人</text>
<text class="value">{{ detail.applicant }}</text>
</view>
<view class="info-row">
<text class="label">公司名称</text>
<text class="value">{{ detail.companyName }}</text>
</view>
<view class="info-row">
<text class="label">物品所属公司</text>
<text class="value">{{ detail.itemCompany }}</text>
</view>
<view class="info-row">
<text class="label">借用时间</text>
<text class="value">{{ detail.borrowTime }}</text>
</view>
<view class="info-row">
<text class="label">计划归还时间</text>
<text class="value">{{ detail.returnTime }}</text>
</view>
<view class="info-row">
<text class="label">借用事由</text>
<text class="value">{{ detail.borrowReason }}</text>
</view>
<view class="info-row" v-if="detail.remarks">
<text class="label">备注</text>
<text class="value">{{ detail.remarks }}</text>
<view class="header-left">
<text class="order-no">{{ detail.order_no || ('#' + id) }}</text>
<text class="sub-line">
申请人:{{ detail.applicant_name || '—' }}
<text class="dot">·</text>
提交:{{ detail.created_at || '—' }}
</text>
</view>
</view>
<!-- 复核信息 -->
<!-- 使用时间 -->
<view class="section">
<text class="section-title">复核信息</text>
<view class="info-row">
<text class="label">复核人</text>
<text class="value">{{ detail.reviewer || '—' }}</text>
<text class="section-title">借用时间</text>
<view class="kv">
<text class="kv-label">开始</text>
<text class="kv-value">{{ detail.use_start_date || '—' }}</text>
</view>
<view class="info-row">
<text class="label">复核时间</text>
<text class="value">{{ detail.reviewTime || '—' }}</text>
<view class="kv">
<text class="kv-label">结束</text>
<text class="kv-value">{{ detail.use_end_date || '—' }}</text>
</view>
<view class="info-row">
<text class="label">复核结果</text>
<text class="value">{{ detail.reviewResult || '—' }}</text>
</view>
<!-- 物品列表 -->
<view class="section">
<view class="section-title-row">
<text class="section-title">物品明细</text>
<text class="section-sub" v-if="Array.isArray(detail.item)">
共 {{ detail.item.length }} 条
</text>
</view>
<view class="info-row" v-if="detail.reviewRemark">
<text class="label">复核说明</text>
<text class="value">{{ detail.reviewRemark }}</text>
<view v-if="Array.isArray(detail.item) && detail.item.length" class="items">
<view class="item-card" v-for="(it, idx) in detail.item" :key="it.id || idx">
<view class="item-top">
<text class="item-name">{{ it.item_name_snap || '—' }}</text>
<text class="item-tag" v-if="String(it.is_consumable_snap) === '1'">耗材</text>
</view>
<view class="item-grid">
<view class="grid-cell">
<text class="g-label">申请</text>
<text class="g-val">{{ safeNum(it.request_qty) }}</text>
</view>
<view class="grid-cell">
<text class="g-label">归还</text>
<text class="g-val">{{ safeNum(it.returned_qty) }}</text>
</view>
</view>
<view class="item-remark" v-if="it.remark">
<text class="remark-label">备注</text>
<text class="remark-value">{{ it.remark }}</text>
</view>
</view>
</view>
<view v-else class="empty-hint">暂无物品明细</view>
</view>
<!-- 借用事由/备注 -->
<view class="section">
<text class="section-title">借用说明</text>
<view class="text-block">
<text class="text-label">借用事由</text>
<text class="text-value">{{ detail.borrow_reason || '—' }}</text>
</view>
<view class="text-block" v-if="detail.remark">
<text class="text-label">备注</text>
<text class="text-value">{{ detail.remark }}</text>
</view>
</view>
<!-- 附件 -->
<view class="section">
<view class="section-title-row">
<text class="section-title">附件</text>
<text class="section-sub" v-if="Array.isArray(detail.attachment)">
{{ detail.attachment.length || 0 }} 张
</text>
</view>
<view v-if="Array.isArray(detail.attachment) && detail.attachment.length" class="attach-grid">
<view
class="attach-item"
v-for="(a, index) in detail.attachment"
:key="a.id || index"
@click="previewAttachment(index)"
>
<image class="attach-img" :src="a.file_path_pull" mode="aspectFill"></image>
</view>
</view>
<view v-else class="empty-hint">暂无附件</view>
</view>
<!-- 底部操作(可选:与列表页一致) -->
<view class="bottom-actions" v-if="showBottomAction">
<button class="primary-btn" @click="goAction">{{ bottomActionText }}</button>
</view>
</view>
</view>
@@ -73,121 +124,343 @@
</template>
<script>
import { request, showToast } from '@/api/apiT.js'
export default {
data() {
return {
id: '',
detail: {
status: 'returned', // returned | notReturned | pendingReview
itemName: '公章',
applicant: '刘宇',
companyName: '合塑',
itemCompany: '合塑',
borrowTime: '2024-11-06 09:41:18',
returnTime: '2024-11-10 18:00:00',
borrowReason: '合同签署使用',
remarks: '请保持物品完整',
reviewer: '张伟',
reviewTime: '2024-11-07 09:00:00',
reviewResult: '已复核',
reviewRemark: '流程符合规定'
}
detail: {}
}
},
computed: {
statusText() {
const map = {
returned: '已归还',
notReturned: '未归还',
pendingReview: '待复核'
// 状态映射
statusMeta() {
const status = String(this.detail.status)
const isReturned = String(this.detail.is_returned) === '1'
const statusMap = {
'10': { text: '待审核', cls: 'ribbon-pendingReview' },
'11': { text: '审批中', cls: 'ribbon-pendingReview' },
'12': { text: '待归还', cls: 'ribbon-notReturned' },
'13': { text: '借用拒绝', cls: 'ribbon-notReturned' },
'14': { text: '归还待审核', cls: 'ribbon-pendingReview' },
'15': { text: '归还审批中', cls: 'ribbon-pendingReview' },
'16': { text: '部分归还', cls: 'ribbon-notReturned' },
'17': { text: '已归还', cls: 'ribbon-returned' },
'18': { text: '归还拒绝', cls: 'ribbon-notReturned' },
'19': { text: '损耗品', cls: 'ribbon-notReturned' }
}
return map[this.detail.status] || ''
if (isReturned) return { text: '已归还', cls: 'ribbon-returned' }
return statusMap[status] || { text: '未知状态', cls: 'ribbon-notReturned' }
},
statusClass() {
return `ribbon-${this.detail.status}`
showBottomAction() {
// 仅在“待归还”和“部分归还”时展示按钮
const status = String(this.detail.status)
const isReturned = String(this.detail.is_returned) === '1'
if (isReturned) return false
return ['12', '16'].includes(status)
},
bottomActionText() {
// 待归还和部分归还状态显示“去归还”按钮
return '去归还'
}
},
onLoad(options) {
this.id = options.id;
this.id = options.id || ''
this.getDetails()
},
methods: {
leftClick(){
leftClick() {
uni.navigateBack({})
},
getDetails() {
if (!this.id) return
request({
url: 'mobile/inv/requisition/show',
method: 'get',
data: { id: this.id }
}).then((res) => {
if (res?.data?.code !== 200) {
showToast({ title: res?.data?.msg || '获取详情失败' })
return
}
const d = res.data.data || {}
// 兜底,避免 v-for 报错
d.item = Array.isArray(d.item) ? d.item : []
d.attachment = Array.isArray(d.attachment) ? d.attachment : []
this.detail = d
})
},
safeNum(v) {
const n = Number(v)
return Number.isFinite(n) ? n : 0
},
previewAttachment(index) {
const urls = (this.detail.attachment || [])
.map((a) => a.file_path_pull)
.filter(Boolean)
if (!urls.length) return
uni.previewImage({
current: urls[index] || urls[0],
urls
})
},
goAction() {
// 待归还和部分归还状态点击按钮导航到归还页面
uni.navigateTo({
url: '/pages/borrow/return?id=' + this.id
})
}
}
}
</script>
<style lang="scss">
.home-page{
.home-page {
min-height: 100vh;
background: linear-gradient(180.05deg, #3074F7 0.04%, #F4F6F8 34.07%);
background: linear-gradient(180.05deg, #3074f7 0.04%, #f4f6f8 34.07%);
box-sizing: border-box;
padding-bottom: 120rpx;
padding: 0px 28rpx;
padding: 0 28rpx 120rpx;
}
.content-wrapper{
.content-wrapper {
margin-top: 20rpx;
}
.detail-card{
.detail-card {
position: relative;
background: #fff;
border-radius: 12rpx;
padding: 32rpx;
box-shadow: 0 2rpx 8rpx rgba(0,0,0,0.05);
padding: 28rpx;
box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.05);
overflow: hidden;
}
.card-header{
margin-bottom: 16rpx;
.card-header {
display: flex;
align-items: flex-start;
justify-content: space-between;
padding-top: 10rpx;
margin-bottom: 18rpx;
}
.item-title{
.header-left {
display: flex;
flex-direction: column;
gap: 8rpx;
}
.order-no {
font-size: 32rpx;
font-weight: 700;
color: #222;
}
.sub-line {
font-size: 24rpx;
color: #8a8a8a;
}
.dot {
padding: 0 10rpx;
color: #c0c0c0;
}
.section {
margin-top: 22rpx;
padding-top: 10rpx;
border-top: 1rpx solid #f2f2f2;
}
.section-title-row {
display: flex;
align-items: baseline;
justify-content: space-between;
margin-bottom: 10rpx;
}
.section-title {
font-size: 28rpx;
font-weight: 600;
color: #333;
}
.section{
margin-top: 24rpx;
padding-top: 12rpx;
}
.section-title{
font-size: 28rpx;
font-weight: 500;
color: #444;
margin-bottom: 12rpx;
margin-bottom: 10rpx;
display: block;
}
.info-row{
.section-sub {
font-size: 24rpx;
color: #9a9a9a;
}
.kv {
display: flex;
justify-content: space-between;
align-items: flex-start;
margin-bottom: 12rpx;
align-items: center;
padding: 8rpx 0;
}
.label{
.kv-label {
font-size: 26rpx;
color: #666;
font-size: 26rpx;
}
.value{
color: #333;
.kv-value {
font-size: 26rpx;
color: #333;
text-align: right;
max-width: 66%;
}
.status-ribbon{
.items {
display: flex;
flex-direction: column;
gap: 14rpx;
margin-top: 8rpx;
}
.item-card {
background: #fafbff;
border: 1rpx solid #eef2ff;
border-radius: 12rpx;
padding: 18rpx;
}
.item-top {
display: flex;
align-items: center;
justify-content: space-between;
gap: 12rpx;
margin-bottom: 14rpx;
}
.item-name {
font-size: 28rpx;
font-weight: 600;
color: #2b2b2b;
flex: 1;
}
.item-tag {
font-size: 22rpx;
padding: 6rpx 12rpx;
border-radius: 999rpx;
color: #3074f7;
background: rgba(48, 116, 247, 0.1);
white-space: nowrap;
}
.item-grid {
display: flex;
gap: 10rpx;
}
.grid-cell {
flex: 1;
background: #ffffff;
border-radius: 10rpx;
padding: 14rpx 10rpx;
text-align: center;
border: 1rpx solid #f0f0f0;
}
.g-label {
display: block;
font-size: 22rpx;
color: #888;
margin-bottom: 6rpx;
}
.g-val {
display: block;
font-size: 30rpx;
font-weight: 700;
color: #222;
}
.item-remark {
margin-top: 12rpx;
display: flex;
gap: 12rpx;
align-items: flex-start;
}
.remark-label {
font-size: 24rpx;
color: #888;
white-space: nowrap;
}
.remark-value {
font-size: 24rpx;
color: #333;
flex: 1;
}
.text-block {
padding: 10rpx 0;
}
.text-label {
display: block;
font-size: 24rpx;
color: #888;
margin-bottom: 6rpx;
}
.text-value {
display: block;
font-size: 26rpx;
color: #333;
line-height: 1.6;
white-space: pre-wrap;
}
.attach-grid {
display: flex;
flex-wrap: wrap;
gap: 12rpx;
margin-top: 10rpx;
}
.attach-item {
width: 32%;
height: 208rpx;
border-radius: 12rpx;
overflow: hidden;
background: #f6f6f6;
}
.attach-img {
width: 100%;
height: 100%;
}
.empty-hint {
padding: 18rpx 0 6rpx;
font-size: 24rpx;
color: #9a9a9a;
}
.bottom-actions {
margin-top: 26rpx;
}
.primary-btn {
width: 100%;
height: 88rpx;
line-height: 88rpx;
border-radius: 14rpx;
background: #3074f7;
color: #fff;
font-size: 30rpx;
font-weight: 600;
}
.status-ribbon {
position: absolute;
top: -5px;
right: -24px;
width: 75px;
height: 37px;
background: #08A400;
top: -4px;
right: -32px;
width: 100px;
height: 47px;
transform: rotate(45deg);
z-index: 10;
display: flex;
@@ -195,25 +468,23 @@
justify-content: center;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
}
.ribbon-returned{
background: #08A400;
.ribbon-returned {
background: #08a400;
}
.ribbon-notReturned{
background: #BD0000;
.ribbon-notReturned {
background: #bd0000;
}
.ribbon-pendingReview{
background: #3471FF;
.ribbon-pendingReview {
background: #3471ff;
}
.ribbon-text{
.ribbon-text {
color: #fff;
font-size: 20rpx;
font-weight: 500;
transform: rotate(0deg);
transform-origin: center;
display: block;
text-align: center;
margin-top: 16rpx;
+621
View File
@@ -0,0 +1,621 @@
<template>
<view class="home-page">
<uni-nav-bar leftText=" " :fixed="true" leftIcon="back" :border="false" color="#fff" backgroundColor="rgb(79 137 247)" :statusBar="true" title="借用申请" @clickLeft="leftClick"></uni-nav-bar>
<view class="content-wrapper">
<!-- 申请人信息卡片 -->
<view class="form-card">
<view class="form-item form-item-row">
<text class="form-label">申请人:</text>
<text class="form-value">{{ userinfo.name || '犇犇' }}</text>
</view>
<view class="form-item form-item-row">
<text class="form-label">公司名称:</text>
<text class="form-value">{{ userinfo.corp_name || '合塑' }}</text>
</view>
</view>
<!-- 借用时间 -->
<view class="form-card4">
<view class="form-item form-item-row">
<text class="form-label required">借用时间</text>
<view class="form-input-container">
<uni-datetime-picker
ref="borrowTimePicker"
type="date"
v-model="formData.use_start_date"
placeholder="请选择时间"
:border="false"
:clear-icon="false"
@change="onBorrowTimeChange"
>
<view class="custom-datetime-input">
<text class="custom-datetime-text" :class="{ 'placeholder': !formData.use_start_date }">
{{ formData.use_start_date || '请选择时间' }}
</text>
<uni-icons type="calendar" size="16" color="#999"></uni-icons>
</view>
</uni-datetime-picker>
</view>
</view>
</view>
<!-- 计划归还时间 -->
<view class="form-card4">
<view class="form-item form-item-row">
<text class="form-label required">计划归还时间</text>
<view class="form-input-container">
<uni-datetime-picker
ref="returnTimePicker"
type="date"
v-model="formData.use_end_date"
placeholder="请选择时间"
:border="false"
:clear-icon="false"
@change="onReturnTimeChange"
>
<view class="custom-datetime-input">
<text class="custom-datetime-text" :class="{ 'placeholder': !formData.use_end_date }">
{{ formData.use_end_date || '请选择时间' }}
</text>
<uni-icons type="calendar" size="16" color="#999"></uni-icons>
</view>
</uni-datetime-picker>
</view>
</view>
</view>
<!-- ✅ 物品(可添加多条) -->
<view class="goods-card">
<view class="goods-head">
<text class="form-label required">物品</text>
<button class="goods-add-btn" size="mini" @click="addItem">+ 添加</button>
</view>
<view class="goods-module" v-for="(it, idx) in formData.items" :key="idx">
<view class="goods-module-top">
<text class="goods-module-title">物品 {{ idx + 1 }}</text>
<uni-icons
v-if="formData.items.length > 1"
type="trash"
size="18"
color="#ff4d4f"
@click="removeItem(idx)"
></uni-icons>
</view>
<view class="goods-module-body">
<view class="goods-name">
<picker mode="selector" :range="itemNameOptions" range-key="item_name" @change="onItemNameChange($event, idx)">
<view class="category-content">
<text class="category-text">{{it.item_name_snap || '请选择物品'}}</text>
</view>
</picker>
</view>
<view class="goods-qty">
<uni-number-box v-model="it.request_qty" :min="1" :max="999"></uni-number-box>
</view>
</view>
</view>
</view>
<view class="form-card">
<!-- 借用事由 -->
<view class="form-item">
<text class="form-label required form-label1">借用事由</text>
<uni-easyinput
v-model="formData.borrow_reason"
type="textarea"
:autoHeight="true"
placeholder="请填写借用事由"
:maxlength="500"
></uni-easyinput>
</view>
</view>
<!-- 备注卡片 -->
<view class="form-card " style="margin-bottom: 8rpx;">
<view class="form-item">
<text class="form-label">备注</text>
<uni-easyinput
v-model="formData.remark"
type="textarea"
:autoHeight="true"
placeholder="请填写备注"
:maxlength="500"
></uni-easyinput>
</view>
</view>
<!-- 附件上传 -->
<view class="form-card">
<view class="form-item">
<text class="form-label">附件</text>
<view class="media-upload-wrapper">
<!--
说明:
1) 回显用 :value="mediaValue",每项至少包含 { url }。
2) 关闭组件自带自动上传(auto-upload=false),我们用自己的 uploadfn 上传到后端。
3) 提交给后台时只传 file_path(formData.attachment),展示用 file_path_pull(mediaValue.url)。
-->
<uni-file-picker
ref="mediaPicker"
:limit="maxMedia"
fileMediatype="image"
:auto-upload="false"
:value="mediaValue"
@select="selectMedia"
@delete="delfn"
>
<view class="upload-icon-wrapper">
<image src="/static/image/upload.png" mode="" class="addimg"></image>
</view>
</uni-file-picker>
</view>
</view>
</view>
<!-- 提交按钮 -->
<view class="submit-container">
<button class="submit-btn" @click="handleSubmit">提交申请</button>
</view>
</view>
</view>
</template>
<script>
import { request,showToast } from '@/api/apiT.js'
export default {
data() {
return {
id:'',
userinfo: {},
maxMedia:20,
// uni-file-picker 用于回显的文件列表(展示用)
// 结构:[{ url: 'https://...', name: 'xxx.jpg' }]
mediaValue: [],
formData: {
use_start_date: '',
use_end_date: '',
items: [{ item_name_snap: '',item_id:'',request_qty:1}],
borrow_reason: '',
remark: '',
attachment: []
},
itemNameOptions: [],
}
},
onLoad(options) {
this.id = options.id
this.getinfo()
this.getItemNameOptions()
// 编辑页:有 id 则回显详情
if (this.id) {
this.getdetils()
}
},
methods: {
leftClick(){
uni.navigateBack({})
},
// 获取详情并回显
getdetils() {
request({
url:'mobile/inv/requisition/show',
method:'get',
data:{id:this.id}
}).then(res => {
const d = (res.data && res.data.data) ? res.data.data : {}
// 1) 基础字段
this.formData.id = d.id
this.formData.use_start_date = d.use_start_date || ''
this.formData.use_end_date = d.use_end_date || ''
this.formData.borrow_reason = d.borrow_reason || ''
this.formData.remark = d.remark || ''
// 2) 物品列表:后端字段是 item,这里统一成 items
const items = Array.isArray(d.item) ? d.item : []
this.formData.items = items.length
? items.map(it => ({
// 保留 id 等字段,方便后端识别是更新还是新增
id: it.id,
requisition_id: it.requisition_id,
item_id: it.item_id,
item_name_snap: it.item_name_snap,
request_qty: Number(it.request_qty || 1),
approved_qty: it.approved_qty,
returned_qty: it.returned_qty,
remark: it.remark || ''
}))
: [{ item_name_snap: '', item_id: '', request_qty: 1 }]
// 3) 附件:
// - formData.attachment:提交给后台(file_path)
// - mediaValue:回显展示(file_path_pull)
const atts = Array.isArray(d.attachment) ? d.attachment : []
this.formData.attachment = atts.map(a => ({
id: a.id,
original_name: a.file_name,
file_path: a.file_path
}))
this.mediaValue = atts.map(a => ({
url: a.file_path_pull || a.file_path,
name: a.file_name
}))
})
},
getinfo(){
request({
url:'common/user/info',
method:'get',
}).then(res => {
this.userinfo=res.data.data.user
})
},
//物品下拉
getItemNameOptions() {
request({
url:'mobile/inv/item/preset',
method:'get',
}).then(res => {
this.itemNameOptions = res.data.data
this.itemNameOptions.forEach(item => {
item.item_name = item.item_name + '(' + item.company_name + ')'
})
console.log(this.itemNameOptions)
})
},
// 选择物品(注意:需要知道是第几行物品)
onItemNameChange(e, rowIndex) {
const optIndex = e.detail.value // picker 返回选项下标
const selectItem = this.itemNameOptions[optIndex]
if (!selectItem) return
if (!Array.isArray(this.formData.items)) this.formData.items = []
if (!this.formData.items[rowIndex]) return
this.formData.items[rowIndex].item_name_snap = selectItem.item_name
this.formData.items[rowIndex].item_id = selectItem.id
},
onBorrowTimeChange(e) {
this.formData.use_start_date = e
},
onReturnTimeChange(e) {
this.formData.use_end_date = e
},
onFileSelect(e) {
console.log('文件选择:', e)
},
addItem() {
// 追加一条物品
this.formData.items = Array.isArray(this.formData.items) ? this.formData.items : []
this.formData.items.push({
item_name_snap: '',
item_id: '',
request_qty: 1
})
},
removeItem(index) {
// 删除指定物品(至少保留 1 条)
if (!Array.isArray(this.formData.items)) return
if (this.formData.items.length <= 1) return
this.formData.items.splice(index, 1)
},
uploadfn(imgUrl){
return new Promise((resolve, reject) => {
uni.uploadFile({
url: 'https://fdesk.hnxinyouhe.com/upload?scene=itemsimg',
filePath: imgUrl,
name: 'file',
header:{'Fdesk-Corp-Abbr':uni.getStorageSync('corp_abbr'),'Fdesk-Auth-Token': 'Bearer ' + uni.getStorageSync('token'),'Fdesk-Language': uni.getStorageSync('i18locale')?uni.getStorageSync('i18locale'):'zh','Fdesk-Login-Type': 'feishu','Fdesk-System-Code':'fdesk'},
success: (uploadFileRes) => {
const res = JSON.parse(uploadFileRes.data || '{}')
if(res && res.data && res.data.file_name){
resolve(res.data)
}else{
reject('上传失败')
}
},
fail: (err) => reject(err)
});
})
},
selectMedia(e){
// 选择图片后:先占位写入 attachment,确保“删除”时 index 一致
this.formData.attachment = Array.isArray(this.formData.attachment) ? this.formData.attachment : []
const allowCount = this.maxMedia - this.formData.attachment.length
const tempFilePaths = e.tempFilePaths || (e.tempFiles || []).map(item => item.path || item.url)
const paths = tempFilePaths.slice(0, allowCount)
if(paths.length === 0) return
const startIndex = this.formData.attachment.length
paths.forEach(p => {
this.formData.attachment.push({
__local_path: p,
original_name: '',
file_path: ''
})
})
Promise.all(
paths.map((p, i) =>
this.uploadfn(p)
.then(data => ({ i, ok: true, data }))
.catch(err => ({ i, ok: false, err }))
)
).then(results => {
// 先写入成功结果
results.forEach(r => {
if (!r.ok) return
const idx = startIndex + r.i
const row = this.formData.attachment[idx]
if (!row) return
row.original_name = r.data.original_name
// 后端需要的路径字段(注意:接口返回里叫 file_name,但实际是存储路径)
row.file_path = r.data.file_name
delete row.__local_path
})
// 再从后往前移除失败项(同时把 picker 里也删掉)
const failed = results.filter(r => !r.ok).map(r => r.i).sort((a,b) => b - a)
if (failed.length) {
failed.forEach(i => {
const idx = startIndex + i
// 删除占位
this.formData.attachment.splice(idx, 1)
// 同步删除 picker 中对应图片
this.$nextTick(() => {
if (this.$refs.mediaPicker && this.$refs.mediaPicker.clearFiles) {
this.$refs.mediaPicker.clearFiles(idx)
}
})
})
uni.showToast({
title:'部分图片上传失败,已自动移除,请重试',
icon:'none'
})
}
})
},
delfn(e){
this.formData.attachment.splice(e.index, 1)
// 仅删除“回显列表”里对应的旧附件(新选的图片不在 mediaValue 中)
if (Array.isArray(this.mediaValue) && e.index < this.mediaValue.length) {
this.mediaValue.splice(e.index, 1)
}
},
handleSubmit() {
// 表单验证
if (!this.formData.use_start_date) {
uni.showToast({ title: '请选择借用时间', icon: 'none' })
return
}
if (!this.formData.use_end_date) {
uni.showToast({ title: '请选择计划归还时间', icon: 'none' })
return
}
// 物品列表校验(至少 1 条,且每条需选择名称 + 数量)
if (!Array.isArray(this.formData.items) || this.formData.items.length === 0) {
uni.showToast({ title: '请添加物品', icon: 'none' })
return
}
for (let i = 0; i < this.formData.items.length; i++) {
const it = this.formData.items[i] || {}
if (!it.item_name_snap) {
uni.showToast({ title: `请选择第${i + 1}个物品名称`, icon: 'none' })
return
}
const request_qty = Number(it.request_qty)
if (!request_qty || request_qty <= 0) {
uni.showToast({ title: `请填写第${i + 1}个物品数量`, icon: 'none' })
return
}
}
if (!this.formData.borrow_reason) {
uni.showToast({ title: '请填写借用事由', icon: 'none' })
return
}
// 附件:如有占位未上传完成,不允许提交
if (Array.isArray(this.formData.attachment)) {
const uploading = this.formData.attachment.some(a => !a || !a.file_path)
if (uploading) {
uni.showToast({ title: '附件上传中,请稍后再提交', icon: 'none' })
return
}
}
// 提交表单
console.log('提交表单:', this.formData)
request({
url:'mobile/inv/requisition/update',
method:'post',
data:this.formData
}).then(res => {
uni.showToast({
title: res.data.message,
icon: 'none'
});
if(res.data.code==200){
setTimeout(() => {
uni.reLaunch({
url: '/pages/index/index',// 替换为你要跳转的页面路径
});
}, 1000);
}
})
// 这里可以调用API提交数据
}
}
}
</script>
<style lang="scss">
.home-page{
min-height: 100vh;
background: linear-gradient(180.05deg, #3074F7 0.04%, #F4F6F8 34.07%);
box-sizing: border-box;
padding-bottom: 120rpx;
padding: 0px 28rpx;
}
.content-wrapper{
margin-top: 20rpx;
}
.media-upload-wrapper{
display: flex;
flex-wrap: wrap;
gap: 16rpx;
}
.addimg{
width: 50px;
height:50px;
}
.form-card {
background: #fff;
border-radius: 16rpx;
padding: 24rpx;
margin-bottom: 24rpx;
box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
}
.form-card4 {
background: #fff;
border-radius: 6px;
padding: 3px 17px;
margin-bottom: 4px;
box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
height: 35px;
line-height: 35px;
}
/* 物品(可添加多条) */
.goods-card {
background: #fff;
border-radius: 6px;
padding: 12px 17px;
margin-bottom: 4px;
box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
}
.goods-head {
display: flex;
align-items: center;
justify-content: space-between;
width: 100%;
margin-bottom: 10px;
}
.goods-add-btn {
background: #3074F7;
color: #fff;
border-radius: 14px;
font-size: 24rpx;
margin-left: auto;
margin-right: inherit;
}
.goods-module {
background: #F7F8FA;
border-radius: 8px;
padding: 10px;
margin-bottom: 10px;
}
.goods-module-top {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 8px;
}
.goods-module-title {
font-size: 26rpx;
color: #333;
}
.goods-module-body {
display: flex;
align-items: center;
}
.goods-name {
flex: 1;
min-width: 0;
}
.goods-qty {
width: 220rpx;
display: flex;
justify-content: flex-end;
margin-left: 16rpx;
}
::v-deep .goods-qty .uni-numbox {
scale: 0.95;
transform-origin: right center;
}
.form-item {
margin-bottom: 32rpx;
&:last-child { margin-bottom: 0; }
}
.form-item-row {
display: flex;
align-items: center;
justify-content: space-between;
}
.form-label1{
margin-bottom: 16rpx;
}
.form-item-row .form-label {
margin-bottom: 0;
margin-right: 24rpx;
}
.form-input-container {
flex: 1;
min-width: 0;
}
.form-label {
font-size: 28rpx;
color: #333;
display: block;
flex-shrink: 0;
min-width: 160rpx;
&.required::before {
content: '*';
color: #ff0000;
margin-right: 4rpx;
}
}
.form-value {
font-size: 28rpx;
color: #666;
flex: 1;
}
.category-text{
font-size: 28rpx;
color: #333;
}
.custom-datetime-input {
display: flex;
align-items: center;
justify-content: space-between;
width: 100%;
}
.custom-datetime-text {
font-size: 28rpx;
color: #333;
&.placeholder {
color: #999;
}
}
.submit-container {
margin-top: 40rpx;
padding-bottom: 40rpx;
}
.submit-btn {
background: #3074F7;
color: #fff;
font-size: 32rpx;
border-radius: 12rpx;
height: 88rpx;
line-height: 88rpx;
}
::v-deep .uni-easyinput__content-textarea {
font-size: 28rpx;
color: #333;
min-height: 120rpx;
padding-left: 0px;
}
::v-deep .uni-file-picker {
width: 100%;
}
</style>
+4 -4
View File
@@ -223,10 +223,10 @@
// 状态标签(旋转丝带效果)
.status-ribbon {
position: absolute;
top: -5px;
right: -24px;
width: 75px;
height: 37px;
top: -4px;
right: -32px;
width: 100px;
height: 47px;
background: #4CAF50;
transform: rotate(45deg);
z-index: 10;
+4 -4
View File
@@ -221,10 +221,10 @@
// 状态标签(旋转丝带效果)
.status-ribbon {
position: absolute;
top: -5px;
right: -24px;
width: 75px;
height: 37px;
top: -4px;
right: -32px;
width: 100px;
height: 47px;
background: #4CAF50;
transform: rotate(45deg);
z-index: 10;
+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>
+417 -274
View File
@@ -1,398 +1,567 @@
<template>
<view class="home-page">
<uni-nav-bar leftText=" " :fixed="true" leftIcon="back" :border="false" @clickLeft="leftClick" color="#fff" backgroundColor="rgb(79 137 247)" :statusBar="true" title="物品归还"></uni-nav-bar>
<uni-nav-bar
leftText=" "
:fixed="true"
leftIcon="back"
:border="false"
color="#fff"
backgroundColor="rgb(79 137 247)"
:statusBar="true"
title="物品归还"
@clickLeft="leftClick"
></uni-nav-bar>
<view class="content-wrapper">
<!-- 申请人信息卡片 -->
<!-- 借用基本信息 -->
<view class="form-card">
<view class="form-item form-item-row">
<text class="form-label">申请人:</text>
<text class="form-value">{{ formData.applicant || '犇犇' }}</text>
<text class="form-label">申请人</text>
<text class="form-value">{{ detail.applicant_name || '-' }}</text>
</view>
<view class="form-item form-item-row">
<text class="form-label">公司名称:</text>
<text class="form-value">{{ formData.companyName || '合塑' }}</text>
<text class="form-label">单号</text>
<text class="form-value">{{ detail.order_no || '-' }}</text>
</view>
</view>
<!-- 借用详情卡片 -->
<view class="form-card4">
<!-- 借用时间 -->
<view class="form-item form-item-row">
<text class="form-label">借用时间</text>
<view class="form-input-container">
<uni-datetime-picker
ref="borrowTimePicker"
type="datetime"
v-model="formData.borrowTime"
placeholder="请选择时间"
:border="false"
:clear-icon="false"
@change="onBorrowTimeChange"
>
<view class="custom-datetime-input">
<text class="custom-datetime-text" :class="{ 'placeholder': !formData.borrowTime }">
{{ formData.borrowTime || '请选择时间' }}
</text>
<uni-icons type="calendar" size="18" color="#999"></uni-icons>
</view>
</uni-datetime-picker>
</view>
<text class="form-value">{{ detail.use_start_date || '-' }}</text>
</view>
</view>
<view class="form-card4">
<!-- 计划归还时间 -->
<view class="form-item form-item-row">
<text class="form-label">计划归还时间</text>
<view class="form-input-container">
<uni-datetime-picker
ref="returnTimePicker"
type="datetime"
v-model="formData.returnTime"
placeholder="请选择时间"
:border="false"
:clear-icon="false"
@change="onReturnTimeChange"
>
<view class="custom-datetime-input">
<text class="custom-datetime-text" :class="{ 'placeholder': !formData.returnTime }">
{{ formData.returnTime || '请选择时间' }}
</text>
<uni-icons type="calendar" size="18" color="#999"></uni-icons>
</view>
</uni-datetime-picker>
</view>
<text class="form-label">计划归还</text>
<text class="form-value">{{ detail.use_end_date || '-' }}</text>
</view>
</view>
<view class="form-card4">
<!-- 物品所属公司 -->
<view class="form-item form-item-row">
<text class="form-label">物品所属公司</text>
<view class="form-input-container">
<uni-data-select
v-model="formData.itemCompany"
:localdata="itemCompanyOptions"
placeholder="请选择"
:clear="false"
></uni-data-select>
</view>
</view>
</view>
<view class="form-card">
<!-- 借用事由 -->
<view class="form-item">
<text class="form-label">借用事由</text>
<uni-easyinput
v-model="formData.borrowReason"
type="textarea"
:autoHeight="true"
placeholder="请填写借用事由"
:maxlength="500"
></uni-easyinput>
<view class="text-block">{{ detail.borrow_reason || '-' }}</view>
</view>
</view>
<view class="form-card4">
<!-- 物品名称 -->
<view class="form-item form-item-row">
<text class="form-label required">归还物品名称</text>
<view class="form-input-container">
<uni-data-select
v-model="formData.itemName"
:localdata="itemNameOptions"
placeholder="请选择"
:clear="false"
></uni-data-select>
<!-- 归还物品(可删减 + 改数量) -->
<view class="goods-card">
<view class="goods-head">
<text class="goods-title">归还物品</text>
<text class="goods-sub">可删减物品,数量不超过“可归还”</text>
</view>
<view v-if="returnItems.length === 0" class="empty-tip">
暂无可归还物品
</view>
<view class="goods-module" v-for="(it, idx) in returnItems" :key="it._key">
<view class="goods-module-top">
<view class="goods-module-title">
<text class="name">{{ it.item_name_snap || '-' }}</text>
</view>
<uni-icons
type="trash"
size="18"
color="#ff4d4f"
@click="removeReturnItem(idx)"
></uni-icons>
</view>
<view class="goods-meta">
<view class="meta">
<text class="k">借用</text>
<text class="v">{{ it.approved_qty }}</text>
</view>
<view class="meta">
<text class="k">已还</text>
<text class="v">{{ it.returned_qty }}</text>
</view>
<view class="meta">
<text class="k">可归还</text>
<text class="v">{{ it.can_return }}</text>
</view>
</view>
<view class="goods-module-body">
<text class="qty-label required">本次归还数量</text>
<uni-number-box
v-model="it.return_qty"
:min="1"
:max="it.can_return"
></uni-number-box>
</view>
</view>
</view>
<view class="form-card">
<!-- 计划归还时间 -->
</view>
<!-- 实际归还时间 -->
<view class="form-card4">
<view class="form-item form-item-row">
<text class="form-label required">实际归还时间</text>
<view class="form-input-container">
<uni-datetime-picker
ref="returnTimePicker"
type="datetime"
v-model="formData.returnTime"
type="date"
v-model="formData.return_at"
placeholder="请选择时间"
:border="false"
:clear-icon="false"
@change="onReturnTimeChange"
>
<view class="custom-datetime-input">
<text class="custom-datetime-text" :class="{ 'placeholder': !formData.returnTime }">
{{ formData.returnTime || '请选择时间' }}
<text class="custom-datetime-text" :class="{ placeholder: !formData.return_at }">
{{ formData.return_at || '请选择时间' }}
</text>
<uni-icons type="calendar" size="18" color="#999"></uni-icons>
<uni-icons type="calendar" size="16" color="#999"></uni-icons>
</view>
</uni-datetime-picker>
</view>
</view>
</view>
<!-- 备注卡片 -->
<view class="form-card " style="margin-bottom: 8rpx;">
<!-- 备注 -->
<view class="form-card" style="margin-bottom: 8rpx;">
<view class="form-item">
<text class="form-label">备注</text>
<uni-easyinput
v-model="formData.remarks"
type="textarea"
<text class="form-label">归还备注</text>
<uni-easyinput
v-model="formData.apply_remark"
type="textarea"
:autoHeight="true"
placeholder="请填写备注"
placeholder="请填写归还备注"
:maxlength="500"
></uni-easyinput>
</view>
</view>
<!-- 附件卡片 -->
<!-- 附件(多图) -->
<view class="form-card">
<view class="form-item">
<text class="form-label form-label1">附件</text>
<uni-file-picker
v-model="formData.attachments"
file-mediatype="image"
mode="grid"
:limit="9"
:auto-upload="false"
@select="onFileSelect"
>
<image src="/static/image/upload.png" mode="" class="addimg"></image>
</uni-file-picker>
<text class="form-label">附件</text>
<view class="media-upload-wrapper">
<uni-file-picker
:value="mediaValue"
limit="20"
fileMediatype="image"
:disabled="uploading"
:auto-upload="false"
@select="selectMedia"
@delete="delfn"
>
<view class="upload-icon-wrapper">
<image src="/static/image/upload.png" class="addimg"></image>
</view>
</uni-file-picker>
</view>
</view>
</view>
<!-- 提交按钮 -->
<view class="submit-btn-wrapper">
<button class="submit-btn" @click="handleSubmit">提交</button>
<!-- 提交 -->
<view class="submit-container">
<button class="submit-btn" :disabled="submitting || uploading" @click="handleSubmit">
{{ submitting ? '提交中...' : '提交归还' }}
</button>
</view>
</view>
</view>
</template>
<script>
import { request } from '@/api/apiT.js'
export default {
data() {
return {
id: '',
detail: {},
returnItems: [],
formData: {
applicant: '犇犇',
companyName: '合塑',
borrowTime: '',
returnTime: '',
itemName: '',
itemCompany: '',
borrowReason: '',
remarks: '',
attachments: []
},
itemNameOptions: [
{ text: '物品1', value: 'item1' },
{ text: '物品2', value: 'item2' },
{ text: '物品3', value: 'item3' }
],
itemCompanyOptions: [
{ text: '公司A', value: 'companyA' },
{ text: '公司B', value: 'companyB' },
{ text: '公司C', value: 'companyC' }
]
return_at: '',
apply_remark: '',
attachment: [] // 仅用于提交后台:[{original_name,file_path}]
},
mediaValue: [], // 仅用于 file-picker 展示:[{url,name,...}]
uploading: false,
submitting: false,
maxMedia: 20,
// 注意:根据你后端实际路由调整(目前项目里只有 apply/list/show)
RETURN_API: 'mobile/inv/requisition/return/store'
}
},
onLoad(options) {
this.id = options.id || ''
if (this.id) {
this.getDetails()
}
},
methods: {
leftClick(){
leftClick() {
uni.navigateBack({})
},
onBorrowTimeChange(e) {
// uni-datetime-picker返回的已经是格式化后的字符串
this.formData.borrowTime = e
},
onReturnTimeChange(e) {
// uni-datetime-picker返回的已经是格式化后的字符串
this.formData.returnTime = e
},
onFileSelect(e) {
console.log('文件选择:', e)
},
handleSubmit() {
// 表单验证
if (!this.formData.borrowTime) {
uni.showToast({
title: '请选择借用时间',
icon: 'none'
})
return
}
if (!this.formData.returnTime) {
uni.showToast({
title: '请选择计划归还时间',
icon: 'none'
})
return
}
if (!this.formData.itemName) {
uni.showToast({
title: '请选择物品名称',
icon: 'none'
})
return
}
if (!this.formData.itemCompany) {
uni.showToast({
title: '请选择物品所属公司',
icon: 'none'
})
return
}
if (!this.formData.borrowReason) {
uni.showToast({
title: '请填写借用事由',
icon: 'none'
})
return
}
// 提交表单
console.log('提交表单:', this.formData)
uni.showToast({
title: '提交成功',
icon: 'success'
// 拉取详情并回显
getDetails() {
request({
url: 'mobile/inv/requisition/show',
method: 'get',
data: { id: this.id }
}).then(res => {
const d = (res && res.data && res.data.data) ? res.data.data : {}
this.detail = d || {}
this.buildReturnItems(d)
})
},
// 把借用明细转换为“可归还”明细
buildReturnItems(d) {
const list = Array.isArray(d && d.item) ? d.item : []
const items = []
list.forEach(row => {
const approved = Number(row.approved_qty || row.request_qty || 0)
const returned = Number(row.returned_qty || 0)
const canReturn = Math.max(approved - returned, 0)
if (canReturn <= 0) return
items.push({
_key: `${row.id || row.item_id || ''}_${Date.now()}_${Math.random()}`,
id: row.id, // requisition_item_id
item_id: row.item_id,
item_name_snap: row.item_name_snap,
approved_qty: approved,
returned_qty: returned,
can_return: canReturn,
return_qty: canReturn // 默认全部归还(可自行改小/删减)
})
})
this.returnItems = items
},
removeReturnItem(idx) {
if (!Array.isArray(this.returnItems)) return
this.returnItems.splice(idx, 1)
},
// 上传单张(复用你项目里的 OSS 上传地址 + Header)
uploadfn(imgUrl) {
return new Promise((resolve, reject) => {
uni.uploadFile({
url: 'https://fdesk.hnxinyouhe.com/upload?scene=itemsimg',
filePath: imgUrl,
name: 'file',
header: {
'Fdesk-Corp-Abbr': uni.getStorageSync('corp_abbr'),
'Fdesk-Auth-Token': 'Bearer ' + uni.getStorageSync('token'),
'Fdesk-Language': uni.getStorageSync('i18locale') ? uni.getStorageSync('i18locale') : 'zh',
'Fdesk-Login-Type': 'feishu',
'Fdesk-System-Code': 'fdesk'
},
success: (uploadFileRes) => {
let json = {}
try {
json = JSON.parse(uploadFileRes.data || '{}')
} catch (e) {}
if (json && json.data && (json.data.file_name || json.data.file_path || json.data.file)) {
resolve(json.data)
} else {
reject('上传失败')
}
},
fail: (err) => reject(err)
})
})
},
selectMedia(e) {
if (this.uploading) return
const allowCount = this.maxMedia - this.formData.attachment.length
const tempFilePaths = e.tempFilePaths || (e.tempFiles || []).map(item => item.path || item.url)
const paths = tempFilePaths.slice(0, allowCount)
if (paths.length === 0) return
this.uploading = true
Promise.all(paths.map(p => this.uploadfn(p)))
.then(list => {
list.forEach((u, i) => {
// 兼容后端返回字段(你上面示例是 file_name/original_name)
const original = u.original_name || u.file_original_name || u.name || ('image_' + Date.now())
const filePath = u.file_name || u.file_path || u.path || ''
this.formData.attachment.push({
original_name: original,
file_path: filePath
})
// file-picker 展示用:本地选择的临时路径更直观
this.mediaValue.push({
name: original,
url: paths[i]
})
})
})
.catch(() => {
uni.showToast({ title: '图片上传失败,请重试', icon: 'none' })
})
.finally(() => {
this.uploading = false
})
},
delfn(e) {
// file-picker 的 index 和本地 mediaValue 一致;我们让 attachment 同步删除
const idx = e.index
if (idx >= 0) {
this.mediaValue.splice(idx, 1)
this.formData.attachment.splice(idx, 1)
}
},
handleSubmit() {
if (this.submitting || this.uploading) return
if (!this.id) {
uni.showToast({ title: '缺少借用申请ID', icon: 'none' })
return
}
if (!this.formData.return_at) {
uni.showToast({ title: '请选择归还时间', icon: 'none' })
return
}
if (!Array.isArray(this.returnItems) || this.returnItems.length === 0) {
uni.showToast({ title: '请选择需要归还的物品', icon: 'none' })
return
}
for (let i = 0; i < this.returnItems.length; i++) {
const it = this.returnItems[i] || {}
const qty = Number(it.return_qty)
if (!qty || qty <= 0) {
uni.showToast({ title: `请填写第${i + 1}个物品的归还数量`, icon: 'none' })
return
}
if (qty > Number(it.can_return || 0)) {
uni.showToast({ title: `第${i + 1}个物品归还数量超过可归还`, icon: 'none' })
return
}
}
const payload = {
requisition_id: this.id,
return_at: this.formData.return_at,
apply_remark: this.formData.apply_remark,
attachment: this.formData.attachment,
items: this.returnItems.map(it => ({
requisition_item_name: it.item_name_snap || '',
requisition_item_id: it.id, // requisition_item_id
return_qty: it.return_qty
}))
}
this.submitting = true
request({
url: this.RETURN_API,
method: 'post',
data: payload
}).then(res => {
uni.showToast({
title: res.data.message,
icon: 'none'
});
if(res.data.code==200){
setTimeout(() => {
uni.navigateTo({
url: '/pages/borrow/borrow_list'
});
}, 1000);
}
}).finally(() => {
this.submitting = false
})
// 这里可以调用API提交数据
}
}
}
</script>
<style lang="scss">
.home-page{
.home-page {
min-height: 100vh;
background: linear-gradient(180.05deg, #3074F7 0.04%, #F4F6F8 34.07%);
box-sizing: border-box;
padding-bottom: 120rpx;
padding: 0px 28rpx;
}
.content-wrapper{
.content-wrapper {
margin-top: 20rpx;
}
.addimg{
width: 50px;
height:50px;
}
.form-card {
background: #fff;
border-radius: 12rpx;
padding:20rpx 34rpx;
border-radius: 16rpx;
padding: 24rpx;
margin-bottom: 24rpx;
box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.05);
box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
}
.form-card4 {
background: #fff;
border-radius: 6px;
padding: 3px 17px;
margin-bottom: 4px;
margin-bottom: 10px;
box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
height: 35px;
line-height: 35px;
}
.form-item {
margin-bottom: 32rpx;
margin-bottom: 20rpx;
&:last-child {
margin-bottom: 0;
}
&.form-item-row {
display: flex;
align-items: center;
flex-wrap: nowrap;
}
}
.form-label {
font-size: 28rpx;
color: #333;
// margin-bottom: 16rpx;
display: block;
flex-shrink: 0;
min-width: 160rpx;
&.required::before {
content: '*';
color: #ff0000;
margin-right: 4rpx;
}
}
.form-label1{
margin-bottom: 16rpx;
}
.form-item-row .form-label {
margin-bottom: 0;
margin-right: 24rpx;
}
.form-input-container {
flex: 1;
min-width: 0;
}
.form-value {
font-size: 28rpx;
color: #666;
flex: 1;
text-align: right;
}
.form-input-wrapper {
width: 100%;
.text-block {
font-size: 28rpx;
color: #666;
line-height: 1.6;
padding-top: 10rpx;
}
.form-input-container .form-input-wrapper {
width: 100%;
}
.custom-datetime-input {
border-radius: 4px;
box-sizing: border-box;
width: 100%;
text-align: right;
}
.custom-datetime-text {
font-size: 28rpx;
color: #333;
flex: 1;
&.placeholder {
color: #999;
}
}
// uni-datetime-picker 样式覆盖
::v-deep .uni-date-editor {
width: 100%;
}
::v-deep .uni-date-editor--x {
border: none !important;
background: transparent !important;
padding: 0 !important;
}
::v-deep .uni-date-x {
width: 100%;
padding: 0 !important;
}
::v-deep .uni-date__x-input {
display: none;
}
::v-deep .icon-calendar {
display: none;
}
.submit-btn-wrapper {
margin-top: 40rpx;
padding-bottom: 40rpx;
.goods-card {
background: #fff;
border-radius: 16rpx;
padding: 24rpx;
margin-bottom: 24rpx;
box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
}
.goods-head {
display: flex;
flex-direction: column;
gap: 6rpx;
margin-bottom: 12rpx;
}
.goods-title {
font-size: 30rpx;
color: #111;
font-weight: 600;
}
.goods-sub {
font-size: 24rpx;
color: #999;
}
.empty-tip {
padding: 24rpx 0;
text-align: center;
color: #999;
font-size: 26rpx;
}
.goods-module {
border: 1px solid #eef0f3;
border-radius: 14rpx;
padding: 18rpx;
margin-top: 16rpx;
}
.goods-module-top {
display: flex;
align-items: center;
justify-content: space-between;
}
.goods-module-title .name {
font-size: 28rpx;
color: #333;
font-weight: 600;
}
.goods-meta {
display: flex;
justify-content: space-between;
margin-top: 12rpx;
padding: 12rpx;
border-radius: 12rpx;
background: #f7f8fa;
}
.goods-meta .meta {
display: flex;
flex-direction: column;
align-items: center;
flex: 1;
}
.goods-meta .k {
font-size: 22rpx;
color: #999;
}
.goods-meta .v {
font-size: 28rpx;
color: #333;
margin-top: 6rpx;
}
.goods-module-body {
display: flex;
align-items: center;
justify-content: space-between;
margin-top: 14rpx;
}
.qty-label {
font-size: 26rpx;
color: #333;
&.required::before {
content: '*';
color: #ff0000;
margin-right: 4rpx;
}
}
.media-upload-wrapper {
display: flex;
flex-wrap: wrap;
gap: 16rpx;
}
.addimg {
width: 50px;
height: 50px;
}
.submit-container {
margin-top: 30rpx;
padding-bottom: 40rpx;
display: flex;
justify-content: center;
}
.submit-btn {
width: 70%;
height: 88rpx;
@@ -402,50 +571,24 @@
font-size: 32rpx;
line-height: 88rpx;
border: none;
&::after {
border: none;
}
&[disabled] {
opacity: 0.6;
}
}
// uni-data-select 样式调整
::v-deep .uni-stat__select {
width: 100%;
}
::v-deep .uni-select {
width: 100%;
border: none;
text-align: right;
}
::v-deep .uni-select__input-text {
font-size: 28rpx;
color: #333;
}
::v-deep .uni-select__input-placeholder {
color: #999;
}
// uni-easyinput 样式调整
::v-deep .uni-easyinput {
width: 100%;
}
::v-deep .uni-easyinput__content {
border: none;
min-height: 120rpx;
}
::v-deep .uni-easyinput__content-textarea {
font-size: 28rpx;
color: #333;
min-height: 120rpx;
padding-left: 0px;
}
// uni-file-picker 样式调整
::v-deep .uni-file-picker {
width: 100%;
}
+724
View File
@@ -0,0 +1,724 @@
<template>
<view class="home-page">
<uni-nav-bar
leftText=" "
:fixed="true"
leftIcon="back"
:border="false"
color="#fff"
backgroundColor="rgb(79 137 247)"
:statusBar="true"
title="编辑物品归还"
@clickLeft="leftClick"
></uni-nav-bar>
<view class="content-wrapper">
<!-- 借用基本信息 -->
<view class="form-card">
<view class="form-item form-item-row">
<text class="form-label">申请人</text>
<text class="form-value">{{ detail.apply_user_name || borrowDetail.applicant_name || '-' }}</text>
</view>
<view class="form-item form-item-row">
<text class="form-label">单号</text>
<text class="form-value">{{ detail.order_no || borrowDetail.order_no || '-' }}</text>
</view>
<view class="form-item form-item-row">
<text class="form-label">借用时间</text>
<text class="form-value">{{ borrowDetail.use_start_date || '-' }} ~ {{ borrowDetail.use_end_date || '-' }}</text>
</view>
<view class="form-item">
<text class="form-label">借用事由</text>
<view class="text-block">{{ borrowDetail.borrow_reason || '-' }}</view>
</view>
</view>
<!-- 归还物品(可删减 + 改数量) -->
<view class="goods-card">
<view class="goods-head">
<text class="goods-title">归还物品</text>
<text class="goods-sub">可删减物品,数量不超过"可归还"</text>
</view>
<view v-if="returnItems.length === 0" class="empty-tip">
暂无可归还物品
</view>
<view class="goods-module" v-for="(it, idx) in returnItems" :key="it._key">
<view class="goods-module-top">
<view class="goods-module-title">
<text class="name">{{ it.item_name_snap || '-' }}</text>
</view>
<uni-icons
type="trash"
size="18"
color="#ff4d4f"
@click="removeReturnItem(idx)"
></uni-icons>
</view>
<view class="goods-meta">
<view class="meta">
<text class="k">借用</text>
<text class="v">{{ it.approved_qty }}</text>
</view>
<view class="meta">
<text class="k">已还</text>
<text class="v">{{ it.returned_qty }}</text>
</view>
<view class="meta">
<text class="k">可归还</text>
<text class="v">{{ it.can_return }}</text>
</view>
</view>
<view class="goods-module-body">
<text class="qty-label required">本次归还数量</text>
<uni-number-box
v-model="it.return_qty"
:min="1"
:max="it.can_return"
></uni-number-box>
</view>
</view>
</view>
<!-- 实际归还时间 -->
<view class="form-card4">
<view class="form-item form-item-row">
<text class="form-label required">实际归还时间</text>
<view class="form-input-container">
<uni-datetime-picker
type="date"
v-model="formData.return_at"
placeholder="请选择时间"
:border="false"
:clear-icon="false"
>
<view class="custom-datetime-input">
<text class="custom-datetime-text" :class="{ placeholder: !formData.return_at }">
{{ formData.return_at || '请选择时间' }}
</text>
<uni-icons type="calendar" size="16" color="#999"></uni-icons>
</view>
</uni-datetime-picker>
</view>
</view>
</view>
<!-- 备注 -->
<view class="form-card" style="margin-bottom: 8rpx;">
<view class="form-item">
<text class="form-label">归还备注</text>
<uni-easyinput
v-model="formData.apply_remark"
type="textarea"
:autoHeight="true"
placeholder="请填写归还备注"
:maxlength="500"
></uni-easyinput>
</view>
</view>
<!-- 附件(多图) -->
<view class="form-card">
<view class="form-item">
<text class="form-label">附件</text>
<view class="media-upload-wrapper">
<uni-file-picker
:value="mediaValue"
limit="20"
fileMediatype="image"
:disabled="uploading"
:auto-upload="false"
@select="selectMedia"
@delete="delfn"
>
<view class="upload-icon-wrapper">
<image src="/static/image/upload.png" class="addimg"></image>
</view>
</uni-file-picker>
</view>
</view>
</view>
<!-- 提交 -->
<view class="submit-container">
<button class="submit-btn" :disabled="submitting || uploading" @click="handleSubmit">
{{ submitting ? '提交中...' : '更新归还' }}
</button>
</view>
</view>
</view>
</template>
<script>
import { request } from '@/api/apiT.js'
export default {
data() {
return {
id: '',
return_id: '',
detail: {},
borrowDetail: {}, // 借用详情数据
returnItems: [],
formData: {
return_at: '',
apply_remark: '',
attachment: [] // 仅用于提交后台:[{original_name,file_path}]
},
mediaValue: [], // 仅用于 file-picker 展示:[{url,name,...}]
uploading: false,
submitting: false,
maxMedia: 20,
// 注意:根据你后端实际路由调整
RETURN_API: 'mobile/inv/requisition/return/update'
}
},
onLoad(options) {
this.id = options.id || ''
this.return_id = options.id
this.getDetails()
},
methods: {
leftClick() {
uni.navigateBack({})
},
// 拉取详情并回显
getDetails() {
request({
url: 'mobile/inv/requisition/return/show',
method: 'get',
data: { id: this.id }
}).then(res => {
const d = (res && res.data && res.data.data) ? res.data.data : {}
this.detail = d || {}
this.formData.return_at = d.return_at || ''
this.formData.apply_remark = d.apply_remark || ''
// 处理附件
if (Array.isArray(d.return_attachment)) {
d.return_attachment.forEach(item => {
this.formData.attachment.push({
original_name: item.file_name || '',
file_path: item.file_path || ''
})
this.mediaValue.push({
name: item.file_name || '',
url: item.file_path_pull || item.file_path || ''
})
})
} else if (Array.isArray(d.attachment)) {
// 兼容旧的 attachment 字段
d.attachment.forEach(item => {
this.formData.attachment.push({
original_name: item.original_name || '',
file_path: item.file_path || ''
})
this.mediaValue.push({
name: item.original_name || '',
url: item.file_path_pull || item.file_path || ''
})
})
}
// 如果有借用详情的id,则获取借用详情数据
// 注意:这里应该使用 requisition_id 来获取借用详情
const borrowId = d.requisition_id || d.item_id
if (borrowId) {
this.getBorrowDetail(borrowId)
} else {
// 如果没有借用详情的id,则直接构建归还物品列表
this.buildReturnItems(d)
}
})
},
// 获取借用详情数据
getBorrowDetail(borrowId) {
request({
url: 'mobile/inv/requisition/show',
method: 'GET',
data: { id: borrowId }
}).then((res) => {
if (res.data && res.data.code === 200) {
this.borrowDetail = res.data.data || {}
// 兜底,避免 v-for 报错
this.borrowDetail.item = Array.isArray(this.borrowDetail.item) ? this.borrowDetail.item : []
// 获取借用详情后重新构建归还物品列表
this.buildReturnItems(this.detail)
} else {
uni.showToast({ title: res.data.message || '获取借用详情失败', icon: 'none' })
}
})
},
// 安全处理数字显示
safeNum(v) {
const n = Number(v)
return Number.isFinite(n) ? n : 0
},
// 把借用明细转换为“可归还”明细
buildReturnItems(d) {
const items = []
// 从借用详情中获取完整的物品列表
if (this.borrowDetail.id && this.borrowDetail.item && this.borrowDetail.item.length > 0) {
console.log('从借用详情中获取物品列表:', this.borrowDetail.item)
this.borrowDetail.item.forEach(row => {
const approved = Number(row.approved_qty || row.request_qty || 0)
const returned = Number(row.returned_qty || 0)
const canReturn = Math.max(approved - returned, 0)
if (canReturn <= 0) return
// 检查是否已经在归还列表中
let returnQty = 0
if (Array.isArray(d.item_return)) {
const existingReturn = d.item_return.find(item => {
// 尝试匹配 item_id 或 requisition_item_id
return item.item_id === row.id ||
(item.requisition_item && (item.requisition_item.item_id === row.id || item.requisition_item.id === row.id))
})
if (existingReturn) {
returnQty = Number(existingReturn.return_qty || 0)
}
}
console.log('处理物品:', row.item_name_snap || row.item_name, '可归还数量:', canReturn, '已归还数量:', returnQty)
items.push({
_key: `${row.id || ''}_${Date.now()}_${Math.random()}`,
id: row.id,
item_id: row.id,
item_name_snap: row.item_name_snap || row.item_name,
approved_qty: approved,
returned_qty: returned,
can_return: canReturn,
return_qty: returnQty
})
})
console.log('构建完成的归还物品列表:', items)
} else if (Array.isArray(d.item_return)) {
// 从 item_return 中获取归还物品信息
console.log('从 item_return 中获取物品列表:', d.item_return)
d.item_return.forEach(returnItem => {
if (returnItem.requisition_item) {
const reqItem = returnItem.requisition_item
const approved = Number(reqItem.approved_qty || reqItem.request_qty || 0)
const returned = Number(reqItem.returned_qty || 0)
const canReturn = Math.max(approved - returned, 0)
if (canReturn <= 0) return
items.push({
_key: `${reqItem.id || ''}_${Date.now()}_${Math.random()}`,
id: reqItem.id,
item_id: reqItem.item_id,
item_name_snap: reqItem.item_name_snap || '',
approved_qty: approved,
returned_qty: returned,
can_return: canReturn,
return_qty: Number(returnItem.return_qty || 0)
})
}
})
} else {
// 尝试从不同字段获取物品列表,确保兼容性
const list = Array.isArray(d && d.items) ? d.items : (Array.isArray(d && d.item) ? d.item : [])
if (list.length > 0 && d.return_qty) {
list.forEach(row => {
items.push({
_key: `${row.id || d.item_id || ''}_${Date.now()}_${Math.random()}`,
id: d.requisition_item_id,
item_id: row.id,
item_name_snap: row.item_name,
approved_qty: d.return_qty,
returned_qty: 0,
can_return: d.return_qty,
return_qty: d.return_qty
})
})
}
}
this.returnItems = items
console.log('最终的归还物品列表:', this.returnItems)
},
removeReturnItem(idx) {
if (!Array.isArray(this.returnItems)) return
this.returnItems.splice(idx, 1)
},
// 上传单张(复用你项目里的 OSS 上传地址 + Header)
uploadfn(imgUrl) {
return new Promise((resolve, reject) => {
uni.uploadFile({
url: 'https://fdesk.hnxinyouhe.com/upload?scene=itemsimg',
filePath: imgUrl,
name: 'file',
header: {
'Fdesk-Corp-Abbr': uni.getStorageSync('corp_abbr'),
'Fdesk-Auth-Token': 'Bearer ' + uni.getStorageSync('token'),
'Fdesk-Language': uni.getStorageSync('i18locale') ? uni.getStorageSync('i18locale') : 'zh',
'Fdesk-Login-Type': 'feishu',
'Fdesk-System-Code': 'fdesk'
},
success: (uploadFileRes) => {
let json = {}
try {
json = JSON.parse(uploadFileRes.data || '{}')
} catch (e) {}
if (json && json.data && (json.data.file_name || json.data.file_path || json.data.file)) {
resolve(json.data)
} else {
reject('上传失败')
}
},
fail: (err) => reject(err)
})
})
},
selectMedia(e) {
if (this.uploading) return
const allowCount = this.maxMedia - this.formData.attachment.length
const tempFilePaths = e.tempFilePaths || (e.tempFiles || []).map(item => item.path || item.url)
const paths = tempFilePaths.slice(0, allowCount)
if (paths.length === 0) return
this.uploading = true
Promise.all(paths.map(p => this.uploadfn(p)))
.then(list => {
list.forEach((u, i) => {
// 兼容后端返回字段(你上面示例是 file_name/original_name)
const original = u.original_name || u.file_original_name || u.name || ('image_' + Date.now())
const filePath = u.file_name || u.file_path || u.path || ''
this.formData.attachment.push({
original_name: original,
file_path: filePath
})
// file-picker 展示用:本地选择的临时路径更直观
this.mediaValue.push({
name: original,
url: paths[i]
})
})
})
.catch(() => {
uni.showToast({ title: '图片上传失败,请重试', icon: 'none' })
})
.finally(() => {
this.uploading = false
})
},
delfn(e) {
// file-picker 的 index 和本地 mediaValue 一致;我们让 attachment 同步删除
const idx = e.index
if (idx >= 0) {
this.mediaValue.splice(idx, 1)
this.formData.attachment.splice(idx, 1)
}
},
handleSubmit() {
if (this.submitting || this.uploading) return
if (!this.id || !this.return_id) {
uni.showToast({ title: '缺少必要参数', icon: 'none' })
return
}
if (!this.formData.return_at) {
uni.showToast({ title: '请选择归还时间', icon: 'none' })
return
}
if (!Array.isArray(this.returnItems) || this.returnItems.length === 0) {
uni.showToast({ title: '请选择需要归还的物品', icon: 'none' })
return
}
// 过滤掉归还数量为0的物品
const validReturnItems = this.returnItems.filter(item => {
const qty = Number(item.return_qty)
return qty > 0
})
// 检查是否有有效的归还物品
if (validReturnItems.length === 0) {
uni.showToast({ title: '请至少选择一个物品并填写归还数量', icon: 'none' })
return
}
// 检查每个有效物品的归还数量是否超过可归还数量
for (let i = 0; i < validReturnItems.length; i++) {
const it = validReturnItems[i] || {}
const qty = Number(it.return_qty)
if (qty > Number(it.can_return || 0)) {
uni.showToast({ title: `第${i + 1}个物品归还数量超过可归还`, icon: 'none' })
return
}
}
const payload = {
id: this.return_id,
requisition_id: this.id,
return_at: this.formData.return_at,
apply_remark: this.formData.apply_remark,
attachment: this.formData.attachment,
items: validReturnItems.map(it => ({
requisition_item_id: it.id,
item_id: it.item_id,
return_qty: it.return_qty
}))
}
this.submitting = true
request({
url: this.RETURN_API,
method: 'post',
data: payload
}).then(res => {
uni.showToast({
title: res.data.message,
icon: 'none'
});
if(res.data.code==200){
setTimeout(() => {
uni.navigateTo({
url: '/pages/borrow/borrow_list'
});
}, 1000);
}
}).finally(() => {
this.submitting = false
})
}
}
}
</script>
<style lang="scss">
.home-page {
min-height: 100vh;
background: linear-gradient(180.05deg, #3074F7 0.04%, #F4F6F8 34.07%);
box-sizing: border-box;
padding-bottom: 120rpx;
padding: 0px 28rpx;
}
.content-wrapper {
margin-top: 20rpx;
}
.form-card {
background: #fff;
border-radius: 16rpx;
padding: 24rpx;
margin-bottom: 24rpx;
box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
}
.form-card4 {
background: #fff;
border-radius: 6px;
padding: 3px 17px;
margin-bottom: 10px;
box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
height: 35px;
line-height: 35px;
}
.form-item {
margin-bottom: 20rpx;
&:last-child {
margin-bottom: 0;
}
&.form-item-row {
display: flex;
align-items: center;
flex-wrap: nowrap;
}
}
.form-label {
font-size: 28rpx;
color: #333;
display: block;
flex-shrink: 0;
min-width: 160rpx;
&.required::before {
content: '*';
color: #ff0000;
margin-right: 4rpx;
}
}
.form-item-row .form-label {
margin-bottom: 0;
margin-right: 24rpx;
}
.form-input-container {
flex: 1;
min-width: 0;
}
.form-value {
font-size: 28rpx;
color: #666;
flex: 1;
text-align: right;
}
.text-block {
font-size: 28rpx;
color: #666;
line-height: 1.6;
padding-top: 10rpx;
}
.custom-datetime-input {
border-radius: 4px;
box-sizing: border-box;
width: 100%;
text-align: right;
}
.custom-datetime-text {
font-size: 28rpx;
color: #333;
&.placeholder {
color: #999;
}
}
::v-deep .uni-date-editor {
width: 100%;
}
::v-deep .uni-date-editor--x {
border: none !important;
background: transparent !important;
padding: 0 !important;
}
::v-deep .uni-date__x-input {
display: none;
}
::v-deep .icon-calendar {
display: none;
}
.goods-card {
background: #fff;
border-radius: 16rpx;
padding: 24rpx;
margin-bottom: 24rpx;
box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
}
.goods-head {
display: flex;
flex-direction: column;
gap: 6rpx;
margin-bottom: 12rpx;
}
.goods-title {
font-size: 30rpx;
color: #111;
font-weight: 600;
}
.goods-sub {
font-size: 24rpx;
color: #999;
}
.empty-tip {
padding: 24rpx 0;
text-align: center;
color: #999;
font-size: 26rpx;
}
.goods-module {
border: 1px solid #eef0f3;
border-radius: 14rpx;
padding: 18rpx;
margin-top: 16rpx;
}
.goods-module-top {
display: flex;
align-items: center;
justify-content: space-between;
}
.goods-module-title .name {
font-size: 28rpx;
color: #333;
font-weight: 600;
}
.goods-meta {
display: flex;
justify-content: space-between;
margin-top: 12rpx;
padding: 12rpx;
border-radius: 12rpx;
background: #f7f8fa;
}
.goods-meta .meta {
display: flex;
flex-direction: column;
align-items: center;
flex: 1;
}
.goods-meta .k {
font-size: 22rpx;
color: #999;
}
.goods-meta .v {
font-size: 28rpx;
color: #333;
margin-top: 6rpx;
}
.goods-module-body {
display: flex;
align-items: center;
justify-content: space-between;
margin-top: 14rpx;
}
.qty-label {
font-size: 26rpx;
color: #333;
&.required::before {
content: '*';
color: #ff0000;
margin-right: 4rpx;
}
}
.media-upload-wrapper {
display: flex;
flex-wrap: wrap;
gap: 16rpx;
}
.addimg {
width: 50px;
height: 50px;
}
.submit-container {
margin-top: 30rpx;
padding-bottom: 40rpx;
display: flex;
justify-content: center;
}
.submit-btn {
width: 70%;
height: 88rpx;
background: #3074F7;
color: #fff;
border-radius: 44rpx;
font-size: 32rpx;
line-height: 88rpx;
border: none;
&::after {
border: none;
}
&[disabled] {
opacity: 0.6;
}
}
::v-deep .uni-easyinput__content {
border: none;
min-height: 120rpx;
}
::v-deep .uni-easyinput__content-textarea {
font-size: 28rpx;
color: #333;
min-height: 120rpx;
padding-left: 0px;
}
::v-deep .uni-file-picker {
width: 100%;
}
</style>
+3 -3
View File
@@ -38,7 +38,7 @@
<text class="custom-datetime-text" :class="{ 'placeholder': !formData.borrowTime }">
{{ formData.borrowTime || '请选择时间' }}
</text>
<uni-icons type="calendar" size="18" color="#999"></uni-icons>
<uni-icons type="calendar" size="16" color="#999"></uni-icons>
</view>
</uni-datetime-picker>
</view>
@@ -62,7 +62,7 @@
<text class="custom-datetime-text" :class="{ 'placeholder': !formData.returnTime }">
{{ formData.returnTime || '请选择时间' }}
</text>
<uni-icons type="calendar" size="18" color="#999"></uni-icons>
<uni-icons type="calendar" size="16" color="#999"></uni-icons>
</view>
</uni-datetime-picker>
</view>
@@ -127,7 +127,7 @@
<text class="custom-datetime-text" :class="{ 'placeholder': !formData.returnTime }">
{{ formData.returnTime || '请选择时间' }}
</text>
<uni-icons type="calendar" size="18" color="#999"></uni-icons>
<uni-icons type="calendar" size="16" color="#999"></uni-icons>
</view>
</uni-datetime-picker>
</view>
+23 -10
View File
@@ -8,6 +8,7 @@
<u-grid-item
v-for="(listItem,listIndex) in list"
:key="listIndex"
@click="navTo(listItem.url)"
>
<image class="icons" src="/static/image/icon.png" mode=""></image>
<text class="grid-text">{{listItem.title}}</text>
@@ -31,7 +32,7 @@
<view class="title">备货单</view>
<u-grid :border="false" col="5" >
<u-grid-item
v-for="(listItem,listIndex) in list"
v-for="(listItem,listIndex) in list2"
:key="listIndex"
@click="navTo('/pages/stock/stock_list')"
>
@@ -51,19 +52,21 @@
return {
list: [
{
title: '备货单审批'
title: '备货单审批',
url:''
},
{
title: '备货单审批'
title: '借用审批',
url:'/pages/approval/borrow_approval'
},
{
title: '备货单审批'
},
title: '归还审批',
url:'/pages/approval/return_approval'
}
],
list2: [
{
title: '备货单审批'
},
{
title: '备货单审批'
title: '备货单'
}
],
bannerList: [],
@@ -71,11 +74,21 @@
}
},
onLoad() {
if (!uni.getStorageSync('token')) {}
if (uni.getStorageSync('token')) {
this.getinfo()
}
},
onShow() {
},
methods: {
getinfo(){
request({
url:'common/user/info',
method:'get',
}).then(res => {
this.userinfo=res.data.data.user
})
},
navTo(url) {
uni.navigateTo({
url: url
+226
View File
@@ -0,0 +1,226 @@
<template>
<view class="auth-page">
<view class="auth-card">
<view v-if="status === 'loading'">
<view class="spinner"></view>
<view class="text-wrap">
<text class="title">{{ title }}</text>
<text class="desc">{{ desc }}<text class="dots">{{ dots }}</text></text>
</view>
<view class="progress">
<view class="bar"></view>
</view>
</view>
<view v-else class="error-wrap">
<uni-icons type="clear" size="44" color="#ff4d4f"></uni-icons>
<text class="title">登录失败</text>
<text class="desc">{{ errorMsg }}</text>
<button class="retry-btn" @click="retry">重试</button>
</view>
</view>
</view>
</template>
<script>
import { request, showToast } from '@/api/apiT.js'
export default {
data() {
return {
status: 'loading',
title: '正在完成登录',
desc: '处理中',
dots: '',
errorMsg: '请稍后重试',
_dotTimer: null,
minStayMs: 600,
_startedAt: 0,
_code: ''
}
},
onLoad(options) {
this._startedAt = Date.now()
this.startDots()
// #ifdef H5
this._code = options.code || ''
// #endif
if (!this._code) {
this.fail('缺少 code 参数')
return
}
this.logins(this._code)
},
onUnload() {
this.stopDots()
},
methods: {
startDots() {
this.stopDots()
let n = 0
this._dotTimer = setInterval(() => {
n = (n + 1) % 4
this.dots = '.'.repeat(n)
}, 350)
},
stopDots() {
if (this._dotTimer) {
clearInterval(this._dotTimer)
this._dotTimer = null
}
},
fail(msg) {
this.status = 'error'
this.errorMsg = msg || '请稍后重试'
uni.showToast({ title: msg || '登录失败', icon: 'none' })
},
async logins(code) {
try {
this.title = '正在交换登录凭证'
this.desc = '请稍候'
const res = await request({
url: 'common/auth/login',
method: 'POST',
data: { feishu_code: code,is_mob:1}
})
const token = res?.data?.data?.access_token
if (!token) {
throw new Error(res?.data?.msg || '未获取到 access_token')
}
uni.setStorageSync('token', token)
this.title = '登录成功'
this.desc = '正在进入首页'
this.goHomeSmooth()
} catch (err) {
console.error('[feishu callback] error:', err)
this.fail(err?.message || '登录失败')
}
},
goHomeSmooth() {
const elapsed = Date.now() - this._startedAt
const wait = Math.max(0, this.minStayMs - elapsed)
setTimeout(() => {
uni.reLaunch({ url: '/pages/index/index' })
}, wait)
},
retry() {
this.status = 'loading'
this.title = '正在完成登录'
this.desc = '处理中'
this.startDots()
if (this._code) this.logins(this._code)
else this.fail('缺少 code 参数')
}
}
}
</script>
<style scoped lang="scss">
.auth-page {
min-height: 100vh;
display: flex;
align-items: center;
justify-content: center;
padding: 40rpx;
box-sizing: border-box;
background: linear-gradient(180deg, #3074F7 0%, #F4F6F8 38%, #F4F6F8 100%);
}
.auth-card {
width: 100%;
max-width: 640rpx;
background: rgba(255, 255, 255, 0.92);
border-radius: 20rpx;
padding: 44rpx 36rpx 32rpx;
box-shadow: 0 10rpx 40rpx rgba(0, 0, 0, 0.08);
display: flex;
flex-direction: column;
align-items: center;
backdrop-filter: blur(10px);
}
.spinner {
width: 88rpx;
height: 88rpx;
border-radius: 50%;
border: 8rpx solid rgba(48, 116, 247, 0.18);
border-top-color: rgba(48, 116, 247, 1);
animation: spin 0.9s linear infinite;
margin-bottom: 24rpx;
}
.text-wrap {
text-align: center;
}
.title {
display: block;
font-size: 34rpx;
color: #1f2937;
font-weight: 600;
margin-bottom: 8rpx;
}
.desc {
display: block;
font-size: 26rpx;
color: #6b7280;
}
.dots {
display: inline-block;
width: 40rpx;
text-align: left;
}
.progress {
width: 100%;
height: 10rpx;
border-radius: 999rpx;
background: rgba(48, 116, 247, 0.10);
overflow: hidden;
margin-top: 26rpx;
}
.progress .bar {
height: 100%;
width: 40%;
border-radius: 999rpx;
background: rgba(48, 116, 247, 0.55);
animation: move 1.1s ease-in-out infinite;
}
.error-wrap {
display: flex;
flex-direction: column;
align-items: center;
text-align: center;
}
.retry-btn {
margin-top: 24rpx;
width: 240rpx;
height: 72rpx;
line-height: 72rpx;
border-radius: 999rpx;
background: #3074F7;
color: #fff;
font-size: 28rpx;
}
@keyframes spin {
to { transform: rotate(360deg); }
}
@keyframes move {
0% { transform: translateX(-60%); }
50% { transform: translateX(140%); }
100% { transform: translateX(-60%); }
}
</style>
+180 -231
View File
@@ -1,263 +1,212 @@
<template>
<view class="content">
<image class="logo" src="/static/image/bg.jpg"></image>
<view class="contop">
<text class="text">2025 USED CAR</text>
<text class="cont">
河南合塑实业有限公司
</text>
</view>
<view class="foot">
<button v-if="is_login" class="btn" @click="mini_login">一键登录</button>
<button v-else="is_login" class="btn" open-type="getPhoneNumber" @getphonenumber="getPhoneNumber">一键登录</button>
<view class="check">
<checkbox-group name="" style="width: 28px;">
<label>
<checkbox :checked="selfChecked" activeBackgroundColor="#3F435B" style="transform:scale(0.7);border-radius: 50%"/>
</label>
</checkbox-group>
我同意并遵守<text class="argeen" @click="gouser">《用户服务协议》</text>以及<text class="argeen" @click="goprivacy">《隐私政策》</text>
<view class="auth-page">
<view class="auth-card">
<!-- 这里如果你有站点 logo,可替换为自己的路径;没有也不影响 -->
<!-- <image class="logo" src="/static/logo.png" mode="heightFix"></image> -->
<view class="spinner"></view>
<view class="text-wrap">
<text class="title">{{ title }}</text>
<text class="desc">{{ desc }}<text class="dots">{{ dots }}</text></text>
</view>
<view class="progress">
<view class="bar"></view>
</view>
</view>
</view>
</template>
<script>
import { request,showToast } from '@/api/apiT.js'
import { request, showToast } from '@/api/apiT.js'
export default {
data() {
return {
selfChecked: false,
is_login:false,
corp_abbr: '',
corp_id: '',
title: '正在为你登录',
desc: '加载中',
dots: '',
_dotTimer: null,
// 最短停留时间,避免“闪一下就跳”的割裂感
minStayMs: 600,
_startedAt: 0
}
},
onLoad() {
// this.Props.statusBarHeight = getApp().globalData.statusBarHeight
// console.log(this.Props.statusBarHeight)
// this.Props.capsuleTop = getApp().globalData.capsuleTop
// this.getbg()
onLoad(options) {
this.corp_abbr = options.corp_abbr || '';
this.corp_id = options.corp_id || '';
uni.setStorageSync('corp_abbr', this.corp_abbr);
uni.setStorageSync('corp_id', this.corp_id);
// uni.setStorageSync('token', 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJmZGVzay5obnhpbnlvdWhlLmNvbSIsImp0aSI6ImEwNzFlYTE1ODQ1NWNmYzA1YTkyOTgxOWUxNzQwNTJkIiwic3ViIjoidXNlcl8xIiwiYXVkIjoiZmRlc2siLCJpYXQiOjE3Njc2NjM0MTcsIm5iZiI6MTc2NzY2MzQxNywiZXhwIjoxNzcwMjU1NDE3LCJ0eXAiOiJhY2Nlc3MiLCJ1aWQiOjEsInVuYW1lIjoiXHU2NzRlXHU0ZjczXHU1MzVhIiwicm9sZV9pZHMiOlsxLDIsNF0sInN5c3RlbV9pZHMiOlsxLDIsM119.vyhbWUVIvEF4VGv1hHi3-4cja9r8q7K8dhSW1ejhKgk')
// console.log(uni.getStorageSync('token'))
this._startedAt = Date.now()
this.startDots()
this.silentAuth()
},
onShow() {
// #ifdef MP-WEIXIN
//小程序登录检测
this.mini_login()
// #endif
// #ifndef MP-WEIXIN
this.is_login = true
// #endif
onUnload() {
this.stopDots()
},
methods: {
selfChangde(e) {
this.selfChecked = !this.selfChecked;
startDots() {
this.stopDots()
let n = 0
this._dotTimer = setInterval(() => {
n = (n + 1) % 4
this.dots = '.'.repeat(n)
}, 350)
},
goprivacy(){
uni.navigateTo({
url: '/pages/login/agreement',// 替换为你要跳转的页面路径
});
stopDots() {
if (this._dotTimer) {
clearInterval(this._dotTimer)
this._dotTimer = null
}
},
gouser(){
uni.navigateTo({
url: '/pages/login/agreementuser',// 替换为你要跳转的页面路径
});
},
getPhoneNumber(e) {
console.log(e.detail.code) // 动态令牌
let that = this;
request({
url:'miniapp/phone',
// url:'customerLogin',
method:'POST',
data:{
phone_code: e.detail.code,
async silentAuth() {
try {
// 1) 如果本地已有 token,直接进首页(丝滑)
const token = uni.getStorageSync('token')
if (token) {
this.title = '已登录'
this.desc = '正在进入首页'
return this.goHomeSmooth()
}
}).then(res => {
console.log(res.data.data)
if (res.data.code == -1) {
uni.showToast({
title: res.data.msg,
icon: 'none'
});
} else if (res.data.code == 0) {
//返回数据接收成功
this.mini_login();
// 2) 获取飞书授权跳转地址(静默授权/免登)
this.title = '正在跳转飞书授权'
this.desc = '准备中'
const res = await request({
url: 'common/auth/feishu/scope',
method: 'get',
data:{is_mob:1}
})
const auth_url = res?.data?.data?.auth_url
if (!auth_url) {
throw new Error('未获取到授权地址')
}
})
// 3) 给一点点过渡时间,让动画先跑起来再跳转
await this.sleep(180)
// 仅 H5 才能用 window.location
// #ifdef H5
window.location.replace(auth_url)
// #endif
// #ifndef H5
showToast && showToast('仅 H5 环境支持飞书静默授权')
// #endif
} catch (err) {
console.error('[feishu silentAuth] error:', err)
uni.showToast({ title: err?.message || '登录失败', icon: 'none' })
}
},
mini_login() {
let that = this;
// if(!this.selfChecked){
// uni.showToast({
// title:'请先勾选同意用户服务协议以及隐私政策',
// icon: 'none'
// });
// return false
// }
uni.login({
provider: 'weixin',
success: loginRes => {
console.log(loginRes);
that.code = loginRes.code;
// 2. 将用户登录code传递到后台置换用户SessionKey、OpenId等信息
request({
url:'miniapp/login',
method:'POST',
data:{
code: loginRes.code
}
}).then(res => {
console.log(res.data);
uni.hideLoading()
if (res.data.code == 0) {
//存取session
uni.setStorageSync('openid', res.data.data.openid);
uni.setStorageSync('token', res.data.data.token);
if(res.data.data.phone&&res.data.data.phone!=''&&res.data.data.phone!=null){
uni.reLaunch({
url: '/pages/index/index',// 替换为你要跳转的页面路径
});
this.is_login = true;
}
} else {
uni.showToast({
title: res.data.msg,
icon: 'none'
})
}
})
},
fail: () => {
uni.showToast({
title: '获取 code 失败',
icon: 'none'
});
}
});
},
pd_login(openid) {
let that = this;
request({
url:'miniapp/phone',
method:'POST',
data:{
phone_code: openid
}
}).then(res => {
console.log(res.data)
goHomeSmooth() {
const elapsed = Date.now() - this._startedAt
const wait = Math.max(0, this.minStayMs - elapsed)
setTimeout(() => {
uni.reLaunch({
url: '/pages/index/index',// 替换为你要跳转的页面路径
});
// if (res.data.code == -1) {
// //unionid在数据库没有记录 记录就可以不需要操作
// console.log('unionid在数据库没有记录 记录就可以不需要操作')
// } else if (res.data.code == 0) {
// var userid = res.data.data;
// this.is_login = true;
// this.getCard(openid);
// }
})
url: '/pages/index/index'
})
}, wait)
},
sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms))
}
}
}
</script>
<style scoped>
>>>checkbox .wx-checkbox-input {
border-radius: 50% !important;
border: 2rpx solid #3F435B !important;
}
>>>checkbox .wx-checkbox-input.wx-checkbox-input-checked {
border: 2rpx solid #3F435B !important;
background-color:#3F435B !important;
color: #FFFFFF !important;
}
>>>checkbox .wx-checkbox-input.wx-checkbox-input-checked::before {
color: #FFFFFF !important;
}
>>>uni-checkbox .uni-checkbox-input {
margin-right: 0;
border-radius: 50%;
border: 2rpx solid #3F435B;
}
>>>uni-checkbox .uni-checkbox-input:empty {
border: 2rpx solid #3F435B;
background-color: #5FFFFFF;
opacity: 0.5;
}
>>>uni-checkbox .uni-checkbox-input:not(:empty) {
border: 2rpx solid #3F435B;
background-color: #3F435B;
color: #FFFFFF;
}
.argeen{
color: #3F435B;
}
.content{
height: 100%;
width: 100%;
position: relative;
background-color: white;
}
.logo{
width: 100%;
height: 830rpx;
}
.contop{
position: absolute;
top: 16%;
text-align: center;
}
.text{
font-size: 32px;
font-weight: bold;
background: linear-gradient(120deg, #B9773C 0%, #67450D 100%);
-webkit-background-clip: text;
color: transparent;
background-clip: text;
display: inline-block;
}
.cont{
background-image: linear-gradient(#4C392B, #0A0604);
padding: 4px 15px;
color: #FFEBCC;
text-align: center;
border-radius: 6px;
display: inline-block;
margin-top: 12px;
font-size: 16px;
}
.foot{
width: 88%;
margin: 30px auto;
text-align: center;
}
.foot label{
color: #929292;
}
.check{
<style scoped lang="scss">
.auth-page {
min-height: 100vh;
display: flex;
align-items: center;
font-size: 26rpx;
justify-content: center;
padding: 40rpx;
box-sizing: border-box;
/* 更“高级”的登录背景 */
background: linear-gradient(180deg, #3074F7 0%, #F4F6F8 38%, #F4F6F8 100%);
}
.btn{
background-color: #3F435B;
color: white;
border-radius: 50px;
.auth-card {
width: 100%;
margin-bottom: 40px;
height: 50px;
line-height: 50px;
max-width: 640rpx;
background: rgba(255, 255, 255, 0.92);
border-radius: 20rpx;
padding: 44rpx 36rpx 32rpx;
box-shadow: 0 10rpx 40rpx rgba(0, 0, 0, 0.08);
display: flex;
flex-direction: column;
align-items: center;
backdrop-filter: blur(10px);
}
.radio{
color: #929292;
font-size: 12px;
.logo {
height: 72rpx;
margin-bottom: 26rpx;
}
</style>
.spinner {
width: 88rpx;
height: 88rpx;
border-radius: 50%;
border: 8rpx solid rgba(48, 116, 247, 0.18);
border-top-color: rgba(48, 116, 247, 1);
animation: spin 0.9s linear infinite;
margin-bottom: 24rpx;
}
.text-wrap {
text-align: center;
}
.title {
display: block;
font-size: 34rpx;
color: #1f2937;
font-weight: 600;
margin-bottom: 8rpx;
}
.desc {
display: block;
font-size: 26rpx;
color: #6b7280;
}
.dots {
display: inline-block;
width: 40rpx; /* 固定宽度避免文字抖动 */
text-align: left;
}
.progress {
width: 100%;
height: 10rpx;
border-radius: 999rpx;
background: rgba(48, 116, 247, 0.10);
overflow: hidden;
margin-top: 26rpx;
}
.progress .bar {
height: 100%;
width: 40%;
border-radius: 999rpx;
background: rgba(48, 116, 247, 0.55);
animation: move 1.1s ease-in-out infinite;
}
@keyframes spin {
to { transform: rotate(360deg); }
}
@keyframes move {
0% { transform: translateX(-60%); }
50% { transform: translateX(140%); }
100% { transform: translateX(-60%); }
}
</style>
+4 -4
View File
@@ -222,10 +222,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;