工器具台账

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" v-for="(spec, specIndex) in category.specs"
:key="specIndex" :key="specIndex"
class="equipment-item" class="equipment-item"
@click="showDetail(category.name, spec)" @click="showDetail(category.name , spec)"
> >
<div class="equipment-info"> <div class="equipment-info">
<div class="equipment-name">{{ category.name }}</div> <div class="equipment-name">{{ category.name }}</div>
@ -135,7 +135,8 @@ const getList = async () => {
model: model.typeModelName, model: model.typeModelName,
quantity: model.storeNum || 0, quantity: model.storeNum || 0,
manageType: model.manageType, manageType: model.manageType,
buyPrice: model.buyPrice buyPrice: model.buyPrice,
typeId: model.typeId
} }
}) })
} }
@ -155,11 +156,22 @@ const getList = async () => {
} }
const showDetail = (categoryName, spec) => { const showDetail = (categoryName, spec) => {
console.log('查看详情:', categoryName, spec) console.log('查看详情:', spec.typeId, spec.manageType);
const qty = parseFloat(spec.quantity);
if (spec.manageType === '编码' && !isNaN(qty) && qty > 0) {
uni.navigateTo({ uni.navigateTo({
url: '/pages/toolsLedger/toolsLedgerDetails' 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> </script>
<style lang="scss" scoped> <style lang="scss" scoped>

View File

@ -11,14 +11,12 @@
<div class="content"> <div class="content">
<!-- 搜索区域 --> <!-- 搜索区域 -->
<div class="search-section"> <div class="search-section">
<div class="search-row"> <div class="search-container">
<uni-easyinput <uni-easyinput
v-model="searchCode" v-model="searchCode"
placeholder="输入设备编码" placeholder="输入设备编码"
class="search-input" class="search-input"
/> />
</div>
<div class="search-row">
<picker <picker
:value="selectedStatusIndex" :value="selectedStatusIndex"
:range="statusOptions" :range="statusOptions"
@ -30,7 +28,6 @@
<uni-icons type="bottom" size="14" color="#999"></uni-icons> <uni-icons type="bottom" size="14" color="#999"></uni-icons>
</view> </view>
</picker> </picker>
<button class="search-btn" @click="handleSearch">查询</button>
</div> </div>
</div> </div>
@ -57,7 +54,7 @@
</div> </div>
</div> </div>
<div class="status-tag" :class="getStatusClass(item.status)"> <div class="status-tag" :class="getStatusClass(item.status)">
{{ item.status }} {{ getStatusText(item.status) }}
</div> </div>
</div> </div>
</div> </div>
@ -67,9 +64,12 @@
<script setup> <script setup>
import { ref, computed } from 'vue' import { ref, computed } from 'vue'
import {onLoad} from "@dcloudio/uni-app";
import {getToolsLedgerDetailsList} from "../../services/ledger";
const typeId = ref(0)
const searchCode = ref('') const searchCode = ref('')
const selectedStatusIndex = ref(0) const selectedStatusIndex = ref(0)
const equipmentList = ref([])
const statusOptions = [ const statusOptions = [
'选择到期监测状态', '选择到期监测状态',
@ -85,52 +85,63 @@ const back = () => {
}) })
} }
// onLoad((options)=>{
const equipmentList = ref([ console.log(options)
{ typeId.value = parseInt(options.typeId, 10);
code: '2025-0001', getDetailsList()
name: '安全帽', })
spec: '白',
status: '正常' //
}, const getDetailsList = async () => {
{ const params = {
code: '2025-0002', typeId: typeId.value
name: '安全帽',
spec: '蓝',
status: '三月内检测到期'
},
{
code: '2025-0002',
name: '安全帽',
spec: '蓝',
status: '一月内检测到期'
},
{
code: '2025-0002',
name: '安全帽',
spec: '蓝',
status: '已过期'
} }
]) 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) => { const onStatusChange = (e) => {
selectedStatusIndex.value = e.detail.value 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) => { const getStatusClass = (status) => {
switch (status) { switch (status) {
case '正常': case '0': return 'status-normal'
return 'status-normal' case '1': return 'status-warning-3'
case '三月内检测到期': case '2': return 'status-warning-1'
return 'status-warning-3' case '3': return 'status-expired'
case '一月内检测到期': default: return ''
return 'status-warning-1'
case '已过期':
return 'status-expired'
default:
return ''
} }
} }
@ -147,29 +158,24 @@ const filteredEquipmentList = computed(() => {
// //
if (selectedStatusIndex.value > 0) { if (selectedStatusIndex.value > 0) {
const selectedStatus = statusOptions[selectedStatusIndex.value] const selectedStatusValue = selectedStatusIndex.value - 1 // 0-3
filtered = filtered.filter(item => item.status === selectedStatus) filtered = filtered.filter(item => item.status === selectedStatusValue.toString())
} }
return filtered return filtered
}) })
const handleSearch = () => {
//
console.log('搜索设备编码:', searchCode.value)
console.log('选择状态:', statusOptions[selectedStatusIndex.value])
}
const showDetail = (item) => { const showDetail = (item) => {
uni.showModal({ uni.showModal({
title: `设备详情`, 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 showCancel: false
}) })
} }
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
/* 样式部分保持不变 */
.content { .content {
padding: 10px; padding: 10px;
height: calc(100vh - 100px); height: calc(100vh - 100px);
@ -180,14 +186,10 @@ const showDetail = (item) => {
padding: 15px; padding: 15px;
margin-bottom: 10px; margin-bottom: 10px;
.search-row { .search-container {
display: flex; display: flex;
gap: 10px;
align-items: center; align-items: center;
margin-bottom: 10px;
&:last-child {
margin-bottom: 0;
}
.search-input { .search-input {
flex: 1; flex: 1;
@ -195,7 +197,6 @@ const showDetail = (item) => {
.status-picker { .status-picker {
flex: 1; flex: 1;
margin-right: 10px;
.picker-display { .picker-display {
display: flex; display: flex;
@ -209,19 +210,6 @@ const showDetail = (item) => {
font-size: 14px; 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' import { http } from '@/utils/http'
/** /**
* 工器具退料 ---- 列表查询 * 工器具台账 ---- 列表查询
*/ */
export const getToolsLedgerList = (data) => { export const getToolsLedgerList = (data) => {
return http({ return http({
@ -10,3 +10,14 @@ export const getToolsLedgerList = (data) => {
data, data,
}) })
} }
/**
* 工器具台账详情 ---- 列表查询
*/
export const getToolsLedgerDetailsList = (data) => {
return http({
method: 'GET',
url: '/material/complex_query/getToolsDetailsList',
data,
})
}