工器具台账

This commit is contained in:
hayu 2025-06-06 16:57:21 +08:00
parent 8d5ae253f4
commit 5f740e5b75
3 changed files with 90 additions and 79 deletions

View File

@ -45,7 +45,7 @@
v-for="(spec, specIndex) in category.specs"
:key="specIndex"
class="equipment-item"
@click="showDetail(category.name, spec)"
@click="showDetail(category.name , spec)"
>
<div class="equipment-info">
<div class="equipment-name">{{ category.name }}</div>
@ -135,7 +135,8 @@ const getList = async () => {
model: model.typeModelName,
quantity: model.storeNum || 0,
manageType: model.manageType,
buyPrice: model.buyPrice
buyPrice: model.buyPrice,
typeId: model.typeId
}
})
}
@ -155,11 +156,22 @@ const getList = async () => {
}
const showDetail = (categoryName, spec) => {
console.log('查看详情:', categoryName, spec)
uni.navigateTo({
url: '/pages/toolsLedger/toolsLedgerDetails'
})
console.log('查看详情:', spec.typeId, spec.manageType);
const qty = parseFloat(spec.quantity);
if (spec.manageType === '编码' && !isNaN(qty) && qty > 0) {
uni.navigateTo({
url: '/pages/toolsLedger/toolsLedgerDetails?typeId=' + spec.typeId,
});
} else {
uni.showModal({
title: `${categoryName}\n${spec.model}`,
content: `当前库存数量: ${!isNaN(qty) && qty >= 0 ? qty : 0}`,
showCancel: false
});
}
}
</script>
<style lang="scss" scoped>

View File

@ -11,14 +11,12 @@
<div class="content">
<!-- 搜索区域 -->
<div class="search-section">
<div class="search-row">
<div class="search-container">
<uni-easyinput
v-model="searchCode"
placeholder="输入设备编码"
class="search-input"
/>
</div>
<div class="search-row">
<picker
:value="selectedStatusIndex"
:range="statusOptions"
@ -30,7 +28,6 @@
<uni-icons type="bottom" size="14" color="#999"></uni-icons>
</view>
</picker>
<button class="search-btn" @click="handleSearch">查询</button>
</div>
</div>
@ -57,7 +54,7 @@
</div>
</div>
<div class="status-tag" :class="getStatusClass(item.status)">
{{ item.status }}
{{ getStatusText(item.status) }}
</div>
</div>
</div>
@ -67,9 +64,12 @@
<script setup>
import { ref, computed } from 'vue'
import {onLoad} from "@dcloudio/uni-app";
import {getToolsLedgerDetailsList} from "../../services/ledger";
const typeId = ref(0)
const searchCode = ref('')
const selectedStatusIndex = ref(0)
const equipmentList = ref([])
const statusOptions = [
'选择到期监测状态',
@ -85,52 +85,63 @@ const back = () => {
})
}
//
const equipmentList = ref([
{
code: '2025-0001',
name: '安全帽',
spec: '白',
status: '正常'
},
{
code: '2025-0002',
name: '安全帽',
spec: '蓝',
status: '三月内检测到期'
},
{
code: '2025-0002',
name: '安全帽',
spec: '蓝',
status: '一月内检测到期'
},
{
code: '2025-0002',
name: '安全帽',
spec: '蓝',
status: '已过期'
onLoad((options)=>{
console.log(options)
typeId.value = parseInt(options.typeId, 10);
getDetailsList()
})
//
const getDetailsList = async () => {
const params = {
typeId: typeId.value
}
])
try {
const res = await getToolsLedgerDetailsList(params)
console.log('获取设备详情列表数据:', res)
if (res.code === 200) {
// API
const formattedData = res.data.map(item => {
return {
code: item.maCode,
name: item.typeName,
spec: item.typeModelName,
status: item.status.toString() // status
}
})
equipmentList.value = formattedData
}
} catch (error) {
console.error('获取设备列表失败:', error)
equipmentList.value = []
}
}
//
const onStatusChange = (e) => {
selectedStatusIndex.value = e.detail.value
}
//
const getStatusText = (status) => {
switch (status) {
case '0': return '正常'
case '1': return '三月内检测到期'
case '2': return '一月内检测到期'
case '3': return '已过期'
default: return '未知状态'
}
}
//
const getStatusClass = (status) => {
switch (status) {
case '正常':
return 'status-normal'
case '三月内检测到期':
return 'status-warning-3'
case '一月内检测到期':
return 'status-warning-1'
case '已过期':
return 'status-expired'
default:
return ''
case '0': return 'status-normal'
case '1': return 'status-warning-3'
case '2': return 'status-warning-1'
case '3': return 'status-expired'
default: return ''
}
}
@ -147,29 +158,24 @@ const filteredEquipmentList = computed(() => {
//
if (selectedStatusIndex.value > 0) {
const selectedStatus = statusOptions[selectedStatusIndex.value]
filtered = filtered.filter(item => item.status === selectedStatus)
const selectedStatusValue = selectedStatusIndex.value - 1 // 0-3
filtered = filtered.filter(item => item.status === selectedStatusValue.toString())
}
return filtered
})
const handleSearch = () => {
//
console.log('搜索设备编码:', searchCode.value)
console.log('选择状态:', statusOptions[selectedStatusIndex.value])
}
const showDetail = (item) => {
uni.showModal({
title: `设备详情`,
content: `编码: ${item.code}\n名称: ${item.name}\n规格: ${item.spec}\n状态: ${item.status}`,
content: `编码: ${item.code}\n名称: ${item.name}\n规格: ${item.spec}\n状态: ${getStatusText(item.status)}`,
showCancel: false
})
}
</script>
<style lang="scss" scoped>
/* 样式部分保持不变 */
.content {
padding: 10px;
height: calc(100vh - 100px);
@ -180,14 +186,10 @@ const showDetail = (item) => {
padding: 15px;
margin-bottom: 10px;
.search-row {
.search-container {
display: flex;
gap: 10px;
align-items: center;
margin-bottom: 10px;
&:last-child {
margin-bottom: 0;
}
.search-input {
flex: 1;
@ -195,8 +197,7 @@ const showDetail = (item) => {
.status-picker {
flex: 1;
margin-right: 10px;
.picker-display {
display: flex;
justify-content: space-between;
@ -209,19 +210,6 @@ const showDetail = (item) => {
font-size: 14px;
}
}
.search-btn {
background: #4AA4EA;
color: #fff;
border: none;
border-radius: 4px;
padding: 10px 20px;
font-size: 14px;
&:active {
background: #3a8bc8;
}
}
}
}

View File

@ -1,7 +1,7 @@
import { http } from '@/utils/http'
/**
* 工器具退料 ---- 列表查询
* 工器具台账 ---- 列表查询
*/
export const getToolsLedgerList = (data) => {
return http({
@ -9,4 +9,15 @@ export const getToolsLedgerList = (data) => {
url: '/material/complex_query/getToolsLedgerList',
data,
})
}
/**
* 工器具台账详情 ---- 列表查询
*/
export const getToolsLedgerDetailsList = (data) => {
return http({
method: 'GET',
url: '/material/complex_query/getToolsDetailsList',
data,
})
}