This commit is contained in:
浅念
2026-02-06 16:23:35 +08:00
parent bf3d85de0d
commit 8d8245ee4a
8 changed files with 474 additions and 342 deletions
+1 -1
View File
@@ -1,5 +1,5 @@
{ {
"name" : "uniapp", "name" : "物品领用",
"appid" : "__UNI__C9A60ED", "appid" : "__UNI__C9A60ED",
"description" : "应用描述", "description" : "应用描述",
"versionName" : "1.0.0", "versionName" : "1.0.0",
+7 -2
View File
@@ -35,8 +35,8 @@
<uni-tag :text="item1.item_name" size="mini" type="primary" v-for="(item1, index) in item.item" :key="index"/> <uni-tag :text="item1.item_name" size="mini" type="primary" v-for="(item1, index) in item.item" :key="index"/>
</view> </view>
<view class="card-info"> <view class="card-info">
<text class="info-item">申请人: {{ item.apply_user_name }}</text> <text class="info-item">申请人: {{ item.applicant_name }}</text>
<text class="info-item">归还时间: {{ item.return_at || '-' }}</text> <text class="info-item">归还时间: {{ formatDate(item.return_at) }}</text>
</view> </view>
<view class="action-btns"> <view class="action-btns">
@@ -128,6 +128,11 @@
} }
return actionMap[status] || '' return actionMap[status] || ''
}, },
// 格式化日期,只显示年月日
formatDate(dateStr) {
if (!dateStr) return '-'
return dateStr.split(' ')[0]
},
handleAction(item) { handleAction(item) {
uni.navigateTo({ uni.navigateTo({
url: '/pages/approval/return_approval_detils?id='+item.id url: '/pages/approval/return_approval_detils?id='+item.id
+130 -89
View File
@@ -1,10 +1,9 @@
<template> <template>
<view class="page"> <view class="page">
<uni-nav-bar <uni-nav-bar
leftText=" "
:fixed="true" :fixed="true"
leftIcon="back" leftIcon="back"
background-color="rgb(48, 116, 247)" backgroundColor="rgb(48, 116, 247)"
color="#fff" color="#fff"
:statusBar="true" :statusBar="true"
title="归还详情" title="归还详情"
@@ -21,80 +20,90 @@
</view> </view>
</view> </view>
<view class="row"><text class="label">申请人</text><text class="value">{{ detail.apply_user_name || '-' }}</text></view> <view class="row">
<view class="row"><text class="label">归还时间</text><text class="value">{{ detail.return_at || '-' }}</text></view> <text class="label">单号</text>
<view class="row" v-if="detail.apply_remark !== undefined"> <text class="value">{{ detail.order_no || '-' }}</text>
</view>
<view class="row">
<text class="label">申请人</text>
<text class="value">{{ detail.applicant_name || detail.apply_user_name || '-' }}</text>
</view>
<view class="row">
<text class="label">归还时间</text>
<text class="value">{{ formatDate(detail.return_at) }}</text>
</view>
<view class="row" v-if="detail.apply_remark">
<text class="label">归还备注</text> <text class="label">归还备注</text>
<text class="value">{{ detail.apply_remark || '-' }}</text> <text class="value">{{ detail.apply_remark || '-' }}</text>
</view> </view>
</view> </view>
<!-- 物品明细 --> <!-- 归还物品明细 -->
<view class="card"> <view class="card">
<view class="card-head"> <view class="card-head">
<text class="card-title">归还物品</text> <text class="card-title">归还物品明细</text>
</view> </view>
<view v-if="detail.item && detail.item.length === 0" class="empty">暂无物品</view> <view v-if="!detail.item_return || detail.item_return.length === 0" class="empty">暂无物品</view>
<view v-for="(it, idx) in detail.item" :key="it.id" class="item"> <view v-for="(it, idx) in detail.item_return" :key="it.id" class="item">
<view class="item-left"> <view class="item-left">
<text class="item-name">{{ it.item_name || '-' }}</text> <text class="item-name">{{ it.requisition_item && it.requisition_item.item_name_snap ? it.requisition_item.item_name_snap : '-' }}</text>
<text class="item-meta" v-if="it.spec_model">规格:{{ it.spec_model }}</text> <text class="item-meta" v-if="it.requisition_item && it.requisition_item.spec_model_snap">规格:{{ it.requisition_item.spec_model_snap }}</text>
<text class="item-meta" v-if="it.requisition_item && String(it.requisition_item.is_consumable_snap) === '1'">耗材</text>
</view> </view>
<view class="item-right"> <view class="item-right">
<text class="qty-label">归还数量</text> <view class="qty-info">
<text class="qty-val">{{ detail.return_qty || 0 }}</text> <view class="qty-row">
<text class="qty-label">借用数量</text>
<text class="qty-val">{{ safeNum(it.requisition_item && it.requisition_item.request_qty ? it.requisition_item.request_qty : 0) }}</text>
</view>
<view class="qty-row">
<text class="qty-label">已还数量</text>
<text class="qty-val">{{ safeNum(it.requisition_item && it.requisition_item.returned_qty ? it.requisition_item.returned_qty : 0) }}</text>
</view>
<view class="qty-row">
<text class="qty-label">本次归还</text>
<text class="qty-val">{{ safeNum(it.return_qty) }}</text>
</view>
</view>
</view> </view>
</view> </view>
</view> </view>
<!-- 借用详情 --> <!-- 附件信息 -->
<view class="card" v-if="borrowDetail.id"> <view class="card" v-if="detail.return_attachment && detail.return_attachment.length > 0">
<view class="card-head"> <view class="card-head">
<text class="card-title">借用信息</text> <text class="card-title">附件信息</text>
</view> </view>
<view class="row"><text class="label">申请人</text><text class="value">{{ borrowDetail.applicant_name || '-' }}</text></view> <view class="attachment-list">
<view class="row"><text class="label">借用时间</text><text class="value">{{ borrowDetail.use_start_date || '-' }} ~ {{ borrowDetail.use_end_date || '-' }}</text></view> <view v-for="(attach, idx) in detail.return_attachment" :key="attach.id" class="attachment-item">
<view class="row" v-if="borrowDetail.borrow_reason !== undefined"> <view class="attachment-info">
<text class="label">借用事由</text> <text class="attachment-name">{{ attach.file_name || '-' }}</text>
<text class="value">{{ borrowDetail.borrow_reason || '-' }}</text> <text class="attachment-size" v-if="attach.file_size">大小:{{ formatFileSize(attach.file_size) }}</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>
<image v-if="attach.file_path_pull" :src="attach.file_path_pull" mode="aspectFill" class="attachment-img" @click="previewAttachment(attach.file_path_pull)"></image>
</view> </view>
</view> </view>
</view> </view>
<!-- 审核信息 --> <!-- 审核信息 -->
<view class="card" v-if="detail.audit_info"> <view class="card" v-if="detail.handler_name || detail.audit_info">
<view class="card-head"> <view class="card-head">
<text class="card-title">审核信息</text> <text class="card-title">审核信息</text>
</view> </view>
<view class="row"><text class="label">审核人</text><text class="value">{{ detail.audit_info.handler_name || '-' }}</text></view> <view class="row">
<view class="row"><text class="label">审核时间</text><text class="value">{{ detail.audit_info.handle_time || '-' }}</text></view> <text class="label">审核人</text>
<view class="row" v-if="detail.audit_info.handle_remark"> <text class="value">{{ detail.handler_name || (detail.audit_info && detail.audit_info.handler_name ? detail.audit_info.handler_name : '-') }}</text>
</view>
<view class="row">
<text class="label">审核时间</text>
<text class="value">{{ detail.updated_at ? formatDateTime(detail.updated_at) : (detail.audit_info && detail.audit_info.handle_time ? detail.audit_info.handle_time : '-') }}</text>
</view>
<view class="row" v-if="detail.handle_remark || (detail.audit_info && detail.audit_info.handle_remark)">
<text class="label">审核意见</text> <text class="label">审核意见</text>
<text class="value">{{ detail.audit_info.handle_remark }}</text> <text class="value">{{ detail.handle_remark || (detail.audit_info && detail.audit_info.handle_remark ? detail.audit_info.handle_remark : '-') }}</text>
</view> </view>
</view> </view>
</view> </view>
@@ -108,8 +117,7 @@
data() { data() {
return { return {
id: '', id: '',
detail: {}, detail: {}
borrowDetail: {} // 借用详情数据
} }
}, },
computed: { computed: {
@@ -141,39 +149,51 @@
}).then((res) => { }).then((res) => {
if (res.data && res.data.code === 200) { if (res.data && res.data.code === 200) {
this.detail = res.data.data || {} this.detail = res.data.data || {}
// 兜底,避免 v-for 报错 this.detail.item_return = Array.isArray(this.detail.item_return) ? this.detail.item_return : []
this.detail.item = Array.isArray(this.detail.item) ? this.detail.item : [] this.detail.return_attachment = Array.isArray(this.detail.return_attachment) ? this.detail.return_attachment : []
// 如果有借用详情的id,则获取借用详情数据
const borrowId = this.detail.requisition_item_id || this.detail.item_id
if (borrowId) {
this.getBorrowDetail(borrowId)
}
} else { } else {
showToast({ title: res.data.message || '获取详情失败' }) 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) { safeNum(v) {
const n = Number(v) const n = Number(v)
return Number.isFinite(n) ? n : 0 return Number.isFinite(n) ? n : 0
},
formatDate(dateStr) {
if (!dateStr) return '-'
if (typeof dateStr === 'number') {
const date = new Date(dateStr * 1000)
const year = date.getFullYear()
const month = String(date.getMonth() + 1).padStart(2, '0')
const day = String(date.getDate()).padStart(2, '0')
return `${year}-${month}-${day}`
}
return dateStr.split(' ')[0]
},
formatDateTime(dateStr) {
if (!dateStr) return '-'
if (typeof dateStr === 'string' && dateStr.includes('T')) {
return dateStr.replace('T', ' ').replace('Z', '')
}
return dateStr
},
formatFileSize(size) {
if (!size) return '-'
if (size < 1024) {
return size + ' B'
} else if (size < 1024 * 1024) {
return (size / 1024).toFixed(2) + ' KB'
} else {
return (size / (1024 * 1024)).toFixed(2) + ' MB'
}
},
previewAttachment(url) {
if (!url) return
url = url.trim().replace(/^["'`]+|["'`]+$/g, '')
uni.previewImage({
urls: [url]
})
} }
} }
} }
@@ -262,6 +282,16 @@
gap: 10rpx; gap: 10rpx;
flex-shrink: 0; flex-shrink: 0;
} }
.qty-info {
display: flex;
flex-direction: column;
gap: 8rpx;
}
.qty-row {
display: flex;
align-items: center;
gap: 8rpx;
}
.qty-label { .qty-label {
font-size: 22rpx; font-size: 22rpx;
color: #667085; color: #667085;
@@ -284,25 +314,36 @@
font-size: 24rpx; font-size: 24rpx;
color: #98a2b3; color: #98a2b3;
} }
/* 借用物品明细样式 */ .attachment-list {
.grid-cell { display: flex;
// background: #fafbff; flex-direction: column;
border-radius: 10rpx; gap: 16rpx;
padding: 14rpx 10rpx;
text-align: center;
// border: 1rpx solid #f0f0f0;
margin-left: 10rpx;
} }
.g-label { .attachment-item {
display: flex;
align-items: center;
gap: 16rpx;
padding: 12rpx 0;
}
.attachment-info {
flex: 1;
min-width: 0;
}
.attachment-name {
display: block; display: block;
font-size: 26rpx;
color: #101828;
margin-bottom: 4rpx;
word-break: break-all;
}
.attachment-size {
font-size: 22rpx; font-size: 22rpx;
color: #888; color: #98a2b3;
margin-bottom: 6rpx;
} }
.g-val { .attachment-img {
display: block; width: 120rpx;
font-size: 30rpx; height: 120rpx;
font-weight: 700; border-radius: 12rpx;
color: #222; flex-shrink: 0;
} }
</style> </style>
+101 -23
View File
@@ -21,9 +21,10 @@
</view> </view>
</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.order_no || '-' }}</text></view>
<view class="row"><text class="label">归还时间</text><text class="value">{{ detail.return_at || '-' }}</text></view> <view class="row"><text class="label">申请人</text><text class="value">{{ detail.applicant_name || detail.apply_user_name || '-' }}</text></view>
<view class="row" v-if="detail.apply_remark !== undefined"> <view class="row"><text class="label">归还时间</text><text class="value">{{ formatDate(detail.return_at) }}</text></view>
<view class="row" v-if="detail.apply_remark">
<text class="label">归还备注</text> <text class="label">归还备注</text>
<text class="value">{{ detail.apply_remark || '-' }}</text> <text class="value">{{ detail.apply_remark || '-' }}</text>
</view> </view>
@@ -35,16 +36,40 @@
<text class="card-title">归还物品</text> <text class="card-title">归还物品</text>
</view> </view>
<view v-if="approveItems.length === 0" class="empty">暂无物品</view> <view v-if="!detail.item_return || detail.item_return.length === 0" class="empty">暂无物品</view>
<view v-for="(it, idx) in approveItems" :key="it.item_id" class="item"> <view v-for="(it, idx) in detail.item_return" :key="it.id" class="item">
<view class="item-left"> <view class="item-left">
<text class="item-name">{{ it.item_name }}</text> <text class="item-name">{{ it.requisition_item && it.requisition_item.item_name_snap ? it.requisition_item.item_name_snap : '-' }}</text>
<text class="item-meta" v-if="it.spec_model">规格:{{ it.spec_model }}</text> <text class="item-meta" v-if="it.requisition_item && it.requisition_item.spec_model_snap">规格:{{ it.requisition_item.spec_model_snap }}</text>
</view> </view>
<view class="item-right"> <view class="item-right">
<text class="qty-label">归还数量</text> <view class="qty-info">
<text class="qty-val">{{ detail.return_qty || 0 }}</text> <view class="qty-row">
<text class="qty-label">借用数量</text>
<text class="qty-val">{{ it.requisition_item && it.requisition_item.request_qty ? it.requisition_item.request_qty : 0 }}</text>
</view>
<view class="qty-row">
<text class="qty-label">本次归还</text>
<text class="qty-val">{{ it.return_qty || 0 }}</text>
</view>
</view>
</view>
</view>
</view>
<!-- 附件信息 -->
<view class="card" v-if="detail.return_attachment && detail.return_attachment.length > 0">
<view class="card-head">
<text class="card-title">附件信息</text>
</view>
<view class="attachment-list">
<view v-for="(attach, idx) in detail.return_attachment" :key="attach.id" class="attachment-item">
<view class="attachment-info">
<text class="attachment-name">{{ attach.file_name || '-' }}</text>
</view>
<image v-if="attach.file_path_pull" :src="attach.file_path_pull" mode="aspectFill" class="attachment-img" @click="previewAttachment(attach.file_path_pull)"></image>
</view> </view>
</view> </view>
</view> </view>
@@ -85,7 +110,6 @@
return { return {
id: '', id: '',
detail: {}, detail: {},
approveItems: [],
auditRemark: '' auditRemark: ''
} }
}, },
@@ -116,18 +140,13 @@
method: 'GET', method: 'GET',
data: { id: this.id } data: { id: this.id }
}).then((res) => { }).then((res) => {
this.detail = (res.data && res.data.data) || {} if (res.data && res.data.code === 200) {
this.initApproveItems() this.detail = res.data.data || {}
}) // 兜底,避免 v-for 报错
}, this.detail.item_return = Array.isArray(this.detail.item_return) ? this.detail.item_return : []
initApproveItems() { this.detail.return_attachment = Array.isArray(this.detail.return_attachment) ? this.detail.return_attachment : []
const list = Array.isArray(this.detail.item) ? this.detail.item : [] } else {
this.approveItems = list.map((it) => { showToast({ title: res.data.message || '获取详情失败' })
return {
item_id: it.id,
item_name: it.item_name || '',
spec_model: it.spec_model || '',
unit: it.unit || ''
} }
}) })
}, },
@@ -139,7 +158,7 @@
} }
}, },
doSubmit(action) { doSubmit(action) {
if (!this.approveItems.length) { if (!this.detail.item_return || this.detail.item_return.length === 0) {
showToast({ title: '没有可审核的物品' }) showToast({ title: '没有可审核的物品' })
return return
} }
@@ -187,6 +206,27 @@
if (r.confirm) this.doSubmit('2') if (r.confirm) this.doSubmit('2')
} }
}) })
},
// 格式化日期,只显示年月日
formatDate(dateStr) {
if (!dateStr) return '-'
if (typeof dateStr === 'number') {
const date = new Date(dateStr * 1000)
const year = date.getFullYear()
const month = String(date.getMonth() + 1).padStart(2, '0')
const day = String(date.getDate()).padStart(2, '0')
return `${year}-${month}-${day}`
}
return dateStr.split(' ')[0]
},
// 预览附件
previewAttachment(url) {
if (!url) return
// 去除可能的多余空格和引号
url = url.trim().replace(/^["'`]+|["'`]+$/g, '')
uni.previewImage({
urls: [url]
})
} }
} }
} }
@@ -345,4 +385,42 @@
background: rgb(48, 116, 247); background: rgb(48, 116, 247);
color: #fff; color: #fff;
} }
.qty-info {
display: flex;
flex-direction: column;
gap: 8rpx;
}
.qty-row {
display: flex;
align-items: center;
gap: 8rpx;
}
.attachment-list {
display: flex;
flex-direction: column;
gap: 16rpx;
}
.attachment-item {
display: flex;
align-items: center;
gap: 16rpx;
padding: 12rpx 0;
}
.attachment-info {
flex: 1;
min-width: 0;
}
.attachment-name {
display: block;
font-size: 26rpx;
color: #101828;
margin-bottom: 4rpx;
word-break: break-all;
}
.attachment-img {
width: 120rpx;
height: 120rpx;
border-radius: 12rpx;
flex-shrink: 0;
}
</style> </style>
+8
View File
@@ -52,6 +52,7 @@
placeholder="请选择时间" placeholder="请选择时间"
:border="false" :border="false"
:clear-icon="false" :clear-icon="false"
:start="formData.use_start_date"
@change="onReturnTimeChange" @change="onReturnTimeChange"
> >
<view class="custom-datetime-input"> <view class="custom-datetime-input">
@@ -168,6 +169,13 @@
onLoad() { onLoad() {
this.getinfo() this.getinfo()
this.getItemNameOptions() this.getItemNameOptions()
// 设置借用时间默认当天
const today = new Date()
const year = today.getFullYear()
const month = String(today.getMonth() + 1).padStart(2, '0')
const day = String(today.getDate()).padStart(2, '0')
const todayStr = `${year}-${month}-${day}`
this.formData.use_start_date = todayStr
}, },
methods: { methods: {
leftClick(){ leftClick(){
+1 -1
View File
@@ -112,7 +112,7 @@
current:pageNo, current:pageNo,
size:10, size:10,
applicant_id:'self', applicant_id:'self',
status: this.currentTab === 0 ? '' : (this.currentTab === 1 ? 'repaid' : (this.currentTab === 2 ? 'unreturned' : 'approve')) phase: this.currentTab === 0 ? '' : (this.currentTab === 1 ? 'repaid' : (this.currentTab === 2 ? 'unreturned' : 'approve'))
}; };
request({ request({
url:'mobile/inv/requisition/list', url:'mobile/inv/requisition/list',
+7 -7
View File
@@ -1,6 +1,6 @@
<template> <template>
<view class="home-page"> <view class="home-page">
<uni-nav-bar leftText=" " :fixed="true" :border="false" @clickLeft="leftClick" color="#fff" backgroundColor="rgb(79 137 247)" :statusBar="true" title="X-Server"></uni-nav-bar> <uni-nav-bar leftText=" " :fixed="true" :border="false" @clickLeft="leftClick" color="#fff" backgroundColor="rgb(79 137 247)" :statusBar="true" title="领用管理"></uni-nav-bar>
<view> <view>
<view class="cards"> <view class="cards">
<view class="title">审批管理</view> <view class="title">审批管理</view>
@@ -28,7 +28,7 @@
</u-grid-item> </u-grid-item>
</u-grid> </u-grid>
</view> </view>
<view class="cards"> <!-- <view class="cards">
<view class="title">备货单</view> <view class="title">备货单</view>
<u-grid :border="false" col="5" > <u-grid :border="false" col="5" >
<u-grid-item <u-grid-item
@@ -40,7 +40,7 @@
<text class="grid-text">{{listItem.title}}</text> <text class="grid-text">{{listItem.title}}</text>
</u-grid-item> </u-grid-item>
</u-grid> </u-grid>
</view> </view> -->
</view> </view>
</view> </view>
</template> </template>
@@ -51,10 +51,10 @@
data() { data() {
return { return {
list: [ list: [
{ // {
title: '备货单审批', // title: '备货单审批',
url:'' // url:''
}, // },
{ {
title: '借用审批', title: '借用审批',
url:'/pages/approval/borrow_approval' url:'/pages/approval/borrow_approval'
+6 -6
View File
@@ -67,12 +67,12 @@
async silentAuth() { async silentAuth() {
try { try {
// 1) 如果本地已有 token,直接进首页(丝滑) // 1) 如果本地已有 token,直接进首页(丝滑)
const token = uni.getStorageSync('token') // const token = uni.getStorageSync('token')
if (token) { // if (token) {
this.title = '已登录' // this.title = '已登录'
this.desc = '正在进入首页' // this.desc = '正在进入首页'
return this.goHomeSmooth() // return this.goHomeSmooth()
} // }
// 2) 获取飞书授权跳转地址(静默授权/免登) // 2) 获取飞书授权跳转地址(静默授权/免登)
this.title = '正在跳转飞书授权' this.title = '正在跳转飞书授权'