feat:仓储管理-物料入库模块
parent
872c0b58e1
commit
e13f3796f3
@ -0,0 +1,294 @@
|
||||
<template>
|
||||
<view class="page-container">
|
||||
<NavBar :title="'选择物料'" />
|
||||
|
||||
<!-- 搜索区 -->
|
||||
<view class="search-bar">
|
||||
<view class="search-input-wrap">
|
||||
<text class="search-icon iconfont icon-search"></text>
|
||||
<input class="search-input" v-model="searchText" placeholder="搜索物料名称/条码/规格" @input="onSearch" placeholder-class="search-placeholder" />
|
||||
<text v-if="searchText" class="search-clear" @click="clearSearch">✕</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 物料列表 -->
|
||||
<scroll-view scroll-y class="material-list" v-if="filteredList.length > 0">
|
||||
<view
|
||||
v-for="item in filteredList"
|
||||
:key="item.id"
|
||||
class="material-card"
|
||||
:class="{ active: selectedId === item.id }"
|
||||
@click="selectedId = item.id"
|
||||
>
|
||||
<view class="material-card-header">
|
||||
<text class="material-name">{{ textValue(item.name) }}</text>
|
||||
</view>
|
||||
<view class="material-card-body">
|
||||
<view class="material-info-row">
|
||||
<text class="info-label">物料编码</text>
|
||||
<text class="info-value">{{ textValue(item.barCode) }}</text>
|
||||
</view>
|
||||
<view class="material-info-row">
|
||||
<text class="info-label">规格</text>
|
||||
<text class="info-value">{{ textValue(item.standard || item.deviceSpec) }}</text>
|
||||
</view>
|
||||
<view class="material-info-row">
|
||||
<text class="info-label">分类</text>
|
||||
<text class="info-value">{{ textValue(item.categoryName) }}</text>
|
||||
</view>
|
||||
<view class="material-info-row">
|
||||
<text class="info-label">单位</text>
|
||||
<text class="info-value">{{ textValue(item.unitName) }}</text>
|
||||
</view>
|
||||
<view class="material-info-row">
|
||||
<text class="info-label">采购单位</text>
|
||||
<text class="info-value">{{ textValue(item.purchaseUnitName) }}</text>
|
||||
</view>
|
||||
<view class="material-info-row">
|
||||
<text class="info-label">换算关系</text>
|
||||
<text class="info-value">1{{ textValue(item.purchaseUnitName) }}={{ textValue(item.purchaseUnitConvertQuantity) }}{{ textValue(item.unitName) }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</scroll-view>
|
||||
|
||||
<!-- 空状态 -->
|
||||
<view v-else class="empty-wrap">
|
||||
<text v-if="loading" class="empty-text">加载中...</text>
|
||||
<text v-else class="empty-text">暂无物料数据</text>
|
||||
</view>
|
||||
|
||||
<!-- 底部确认按钮 -->
|
||||
<view class="bottom-actions">
|
||||
<view class="bottom-btn confirm-btn" @click="handleConfirm">
|
||||
确认
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, computed } from 'vue'
|
||||
import { onShow } from '@dcloudio/uni-app'
|
||||
import NavBar from '@/components/common/NavBar.vue'
|
||||
import { getMaterialSimpleList } from '@/api/mes/sparepart'
|
||||
|
||||
const materialList = ref([])
|
||||
const selectedId = ref(null)
|
||||
const searchText = ref('')
|
||||
const loading = ref(false)
|
||||
|
||||
function textValue(v) {
|
||||
if (v === 0) return '0'
|
||||
if (v == null) return '-'
|
||||
const s = String(v).trim()
|
||||
return s || '-'
|
||||
}
|
||||
|
||||
const filteredList = computed(() => {
|
||||
let list = materialList.value
|
||||
const keyword = searchText.value.trim().toLowerCase()
|
||||
if (keyword) {
|
||||
list = list.filter(item => {
|
||||
return (item.name || '').toLowerCase().includes(keyword) ||
|
||||
(item.barCode || '').toLowerCase().includes(keyword) ||
|
||||
(item.standard || '').toLowerCase().includes(keyword)
|
||||
})
|
||||
}
|
||||
return list
|
||||
})
|
||||
|
||||
function onSearch() {}
|
||||
|
||||
function clearSearch() {
|
||||
searchText.value = ''
|
||||
}
|
||||
|
||||
async function loadMaterials() {
|
||||
loading.value = true
|
||||
try {
|
||||
const raw = []
|
||||
let page = 1
|
||||
const maxPages = 5
|
||||
while (page <= maxPages) {
|
||||
const res = await getMaterialSimpleList(page)
|
||||
let root = res && res.data !== undefined ? res.data : res
|
||||
let pageList = Array.isArray(root)
|
||||
? root
|
||||
: Array.isArray(root?.list) ? root.list
|
||||
: Array.isArray(root?.rows) ? root.rows
|
||||
: []
|
||||
if (!pageList.length) break
|
||||
raw.push(...pageList)
|
||||
if (pageList.length < 100) break
|
||||
page++
|
||||
}
|
||||
// API 已按 categoryType=2 过滤物料
|
||||
materialList.value = raw
|
||||
console.log('[materialSelect] 加载全部物料:', raw.length)
|
||||
} catch (e) {
|
||||
console.error('loadMaterials error', e)
|
||||
uni.showToast({ title: '加载失败', icon: 'none' })
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function handleConfirm() {
|
||||
if (!selectedId.value) {
|
||||
uni.showToast({ title: '请选择物料', icon: 'none' })
|
||||
return
|
||||
}
|
||||
const item = materialList.value.find((d) => d.id === selectedId.value)
|
||||
if (!item) return
|
||||
getApp().globalData._materialBeforeConfirm = item
|
||||
uni.navigateTo({
|
||||
url: '/pages_function/pages/materialInbound/materialConfirm'
|
||||
})
|
||||
}
|
||||
|
||||
onShow(async () => {
|
||||
await loadMaterials()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.page-container {
|
||||
min-height: 100vh;
|
||||
background: #f5f6f8;
|
||||
padding-bottom: 140rpx;
|
||||
}
|
||||
|
||||
/* 搜索栏 */
|
||||
.search-bar {
|
||||
padding: 16rpx 24rpx;
|
||||
background: #fff;
|
||||
}
|
||||
|
||||
.search-input-wrap {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
height: 72rpx;
|
||||
padding: 0 16rpx;
|
||||
background: #f5f6f8;
|
||||
border-radius: 36rpx;
|
||||
}
|
||||
|
||||
.search-icon {
|
||||
font-size: 32rpx;
|
||||
color: #999;
|
||||
margin-right: 12rpx;
|
||||
}
|
||||
|
||||
.search-input {
|
||||
flex: 1;
|
||||
font-size: 28rpx;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.search-placeholder {
|
||||
color: #bbb;
|
||||
}
|
||||
|
||||
.search-clear {
|
||||
font-size: 28rpx;
|
||||
color: #999;
|
||||
padding: 8rpx;
|
||||
}
|
||||
|
||||
/* 物料列表 */
|
||||
.material-list {
|
||||
padding: 16rpx 24rpx;
|
||||
}
|
||||
|
||||
.material-card {
|
||||
background: #fff;
|
||||
border-radius: 14rpx;
|
||||
padding: 24rpx;
|
||||
margin-bottom: 16rpx;
|
||||
border: 2rpx solid transparent;
|
||||
|
||||
&.active {
|
||||
border-color: #2563eb;
|
||||
background: #f0f5ff;
|
||||
}
|
||||
}
|
||||
|
||||
.material-card-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
margin-bottom: 16rpx;
|
||||
}
|
||||
|
||||
.material-name {
|
||||
font-size: 30rpx;
|
||||
font-weight: 700;
|
||||
color: #1a1a1a;
|
||||
}
|
||||
|
||||
.material-card-body {
|
||||
border-top: 1rpx solid #f0f0f0;
|
||||
padding-top: 16rpx;
|
||||
}
|
||||
|
||||
.material-info-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
margin-bottom: 10rpx;
|
||||
|
||||
&:last-child {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.info-label {
|
||||
width: 140rpx;
|
||||
font-size: 24rpx;
|
||||
color: #999;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.info-value {
|
||||
font-size: 26rpx;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
/* 空状态 */
|
||||
.empty-wrap {
|
||||
padding: 120rpx 0;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.empty-text {
|
||||
font-size: 28rpx;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
/* 底部确认按钮 */
|
||||
.bottom-actions {
|
||||
position: fixed;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
padding: 18rpx 24rpx calc(18rpx + env(safe-area-inset-bottom));
|
||||
background: #fff;
|
||||
box-shadow: 0 -4rpx 20rpx rgba(0, 0, 0, 0.06);
|
||||
z-index: 99;
|
||||
}
|
||||
|
||||
.bottom-btn {
|
||||
width: 100%;
|
||||
height: 84rpx;
|
||||
line-height: 84rpx;
|
||||
text-align: center;
|
||||
border-radius: 16rpx;
|
||||
font-size: 30rpx;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.confirm-btn {
|
||||
background: #1f4b79;
|
||||
color: #fff;
|
||||
}
|
||||
</style>
|
||||
Loading…
Reference in New Issue