feat: 仓储管理-物料盘点执行模块

master
zhongwenkai 3 days ago
parent fc9730dfdc
commit 7c55b009e6

@ -0,0 +1,82 @@
import request from '@/utils/request'
// 创建盘点单
export function createMaterialCheck(data) {
return request({
url: '/admin-api/erp/stock-check/create',
method: 'post',
data
})
}
// 生成盘点项(按仓库/库区)
export function generateCheckItemsByLocation(data) {
return request({
url: '/admin-api/erp/stock-check/generate-items/by-location',
method: 'post',
data
})
}
// 生成盘点项(按产品)
export function generateCheckItemsByProduct(data) {
return request({
url: '/admin-api/erp/stock-check/generate-items/by-product',
method: 'post',
data
})
}
// 物料盘点单分页查询
export function getMaterialCheckPage(params = {}) {
return request({
url: '/admin-api/erp/stock-check/page',
method: 'get',
params
})
}
// 物料盘点单详情
export function getMaterialCheckDetail(id) {
return request({
url: '/admin-api/erp/stock-check/get',
method: 'get',
params: { id }
})
}
// 物料盘点执行(提交盘点结果)
export function executeMaterialCheck(data) {
return request({
url: '/admin-api/erp/stock-check/update',
method: 'put',
data
})
}
// 物料盘点单提交
export function submitMaterialCheck(data) {
return request({
url: '/admin-api/erp/stock-check/submit',
method: 'put',
data
})
}
// 物料盘点单审核status: 20=通过, 1=驳回)
export function auditMaterialCheck(data) {
return request({
url: '/admin-api/erp/stock-check/audit',
method: 'put',
data
})
}
// 物料盘点单删除
export function deleteMaterialCheck(id) {
return request({
url: '/admin-api/erp/stock-check/delete',
method: 'delete',
params: { ids: String(id) }
})
}

@ -647,6 +647,64 @@
"navigationStyle": "custom"
}
},
{
"path": "sparepartCheck/areaSelect",
"style": {
"navigationBarTitleText": "选择库区",
"navigationStyle": "custom"
}
},
{
"path": "materialCheck/index",
"style": {
"navigationBarTitleText": "物料盘点",
"navigationStyle": "custom"
}
},
{
"path": "materialCheck/execute",
"style": {
"navigationBarTitleText": "执行盘点",
"navigationStyle": "custom"
}
},
{
"path": "materialCheck/create",
"style": {
"navigationBarTitleText": "新增盘点单",
"navigationStyle": "custom"
}
},
{
"path": "materialCheck/itemSelect",
"style": {
"navigationBarTitleText": "选择盘点项",
"navigationStyle": "custom"
}
},
{
"path": "materialCheck/itemSelectByProduct",
"style": {
"navigationBarTitleText": "选择盘点项",
"navigationStyle": "custom"
}
},
{
"path": "materialCheck/productSelect",
"style": {
"navigationBarTitleText": "选择产品",
"navigationStyle": "custom"
}
},
{
"path": "materialCheck/areaSelect",
"style": {
"navigationBarTitleText": "选择库区",
"navigationStyle": "custom"
}
},
{
"path": "keypart/index",

@ -0,0 +1,190 @@
<template>
<view class="page-container">
<NavBar :title="'选择库区'" />
<view class="search-bar">
<input
v-model="keyword"
class="search-input"
placeholder="搜索库区编码/名称"
confirm-type="search"
@confirm="handleSearch"
/>
<text class="search-btn" @click="handleSearch"></text>
</view>
<view class="select-all-bar">
<view class="checkbox-wrap" @click="toggleSelectAll">
<text :class="['checkbox', isAllSelected ? 'checkbox-checked' : '']">{{ isAllSelected ? '✓' : '' }}</text>
<text class="select-all-text">全选</text>
</view>
<text class="select-count">已选 {{ selectedItems.length }} </text>
</view>
<scroll-view scroll-y class="list-scroll">
<view v-for="item in filteredList" :key="item.id" class="item-row" @click="toggleSelect(item)">
<view class="checkbox-wrap">
<text :class="['checkbox', isSelected(item) ? 'checkbox-checked' : '']">{{ isSelected(item) ? '✓' : '' }}</text>
</view>
<view class="item-info">
<view class="info-row">
<text class="info-label">库区编码</text>
<text class="info-val code">{{ textValue(item.areaCode) }}</text>
</view>
<view class="info-row">
<text class="info-label">库区名称</text>
<text class="info-val name">{{ textValue(item.areaName) }}</text>
</view>
</view>
</view>
<view v-if="loading" class="loading-text">...</view>
<view v-if="!loading && !list.length" class="empty-text"></view>
</scroll-view>
<view class="bottom-actions">
<view class="bottom-btn cancel-btn" @click="handleCancel"></view>
<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 { getWarehouseAreaSimpleList } from '@/api/mes/moldget'
const list = ref([])
const selectedItems = ref([])
const loading = ref(false)
const keyword = ref('')
const warehouseId = ref('')
const filteredList = computed(() => {
if (!keyword.value) return list.value
return list.value.filter(item =>
(item.areaCode || '').includes(keyword.value) ||
(item.areaName || '').includes(keyword.value)
)
})
const isAllSelected = computed(() => {
return filteredList.value.length > 0 && filteredList.value.every(item => isSelected(item))
})
function textValue(v) {
if (v === 0) return '0'
if (v == null) return '-'
return String(v).trim() || '-'
}
function isSelected(item) {
return selectedItems.value.some(s => String(s.id) === String(item.id))
}
function toggleSelect(item) {
const idx = selectedItems.value.findIndex(s => String(s.id) === String(item.id))
if (idx >= 0) {
selectedItems.value.splice(idx, 1)
} else {
selectedItems.value.push({
id: item.id,
code: item.areaCode || '',
name: item.areaName || ''
})
}
}
function toggleSelectAll() {
if (isAllSelected.value) {
selectedItems.value = []
} else {
selectedItems.value = filteredList.value.map(item => ({
id: item.id,
code: item.areaCode || '',
name: item.areaName || ''
}))
}
}
async function loadData() {
loading.value = true
try {
const res = await getWarehouseAreaSimpleList(warehouseId.value)
const data = Array.isArray(res) ? res : (Array.isArray(res?.data) ? res.data : [])
list.value = data
} catch (e) {
console.error('loadAreaData error', e)
uni.showToast({ title: '加载失败', icon: 'none' })
} finally {
loading.value = false
}
}
function handleSearch() {}
function handleCancel() {
uni.navigateBack()
}
function handleConfirm() {
if (!selectedItems.value.length) {
uni.showToast({ title: '请至少选择一项', icon: 'none' })
return
}
getApp().globalData._materialCheckAreaSelectResult = [...selectedItems.value]
uni.navigateBack()
}
onShow(() => {
const prevSelected = getApp().globalData?._materialCheckAreaSelected
if (prevSelected && Array.isArray(prevSelected)) {
selectedItems.value = prevSelected.map(a => ({
id: a.value,
code: a.code || '',
name: a.label || ''
}))
getApp().globalData._materialCheckAreaSelected = null
}
warehouseId.value = getApp().globalData?._materialCheckAreaWarehouseId || ''
loadData()
})
</script>
<style lang="scss" scoped>
.page-container { min-height: 100vh; background: #f5f6f8; padding-bottom: calc(120rpx + env(safe-area-inset-bottom)); }
.search-bar { display: flex; gap: 16rpx; padding: 20rpx 24rpx; background: #fff; }
.search-input { flex: 1; height: 72rpx; padding: 0 24rpx; background: #f3f4f6; border-radius: 12rpx; font-size: 28rpx; }
.search-btn { display: flex; align-items: center; justify-content: center; width: 120rpx; height: 72rpx; background: #1f4b79; color: #fff; border-radius: 12rpx; font-size: 28rpx; }
.select-all-bar { display: flex; align-items: center; justify-content: space-between; padding: 20rpx 24rpx; background: #fff; border-bottom: 1rpx solid #f0f0f0; }
.checkbox-wrap { display: flex; align-items: center; gap: 12rpx; }
.checkbox { width: 40rpx; height: 40rpx; border: 2rpx solid #d1d5db; border-radius: 8rpx; display: flex; align-items: center; justify-content: center; font-size: 24rpx; color: #fff; background: #fff;
&.checkbox-checked { background: #1f4b79; border-color: #1f4b79; }
}
.select-all-text { font-size: 28rpx; color: #374151; }
.select-count { font-size: 26rpx; color: #1f4b79; font-weight: 600; }
.list-scroll { height: calc(100vh - 330rpx - env(safe-area-inset-bottom)); }
.item-row { display: flex; align-items: flex-start; gap: 16rpx; padding: 20rpx 24rpx; background: #fff; border-bottom: 1rpx solid #f0f0f0;
&:active { background: #f9fafb; }
}
.item-info { flex: 1; display: flex; flex-direction: column; gap: 8rpx; }
.info-row { display: flex; align-items: center; gap: 16rpx; }
.info-label { width: 120rpx; font-size: 24rpx; color: #9ca3af; flex-shrink: 0; }
.info-val { flex: 1; font-size: 26rpx; color: #374151;
&.code { font-family: monospace; color: #6b7280; }
&.name { font-weight: 500; color: #1a1a1a; }
}
.loading-text, .empty-text { padding: 40rpx; text-align: center; color: #9ca3af; font-size: 26rpx; }
.bottom-actions { position: fixed; left: 0; right: 0; bottom: 0; display: flex; gap: 18rpx; padding: 18rpx 24rpx calc(18rpx + env(safe-area-inset-bottom)); background: #fff; box-shadow: 0 -8rpx 24rpx rgba(15,23,42,0.06); z-index: 99; }
.bottom-btn { flex: 1; height: 84rpx; line-height: 84rpx; text-align: center; border-radius: 16rpx; font-size: 30rpx; font-weight: 600;
&:active { opacity: 0.85; }
}
.cancel-btn { background: #eef2f7; color: #475569; }
.confirm-btn { background: #1f4b79; color: #fff; }
</style>

@ -0,0 +1,407 @@
<template>
<view class="page-container">
<NavBar :title="'新增物料盘点单'" />
<view class="section-title-bar">
<view class="section-bar-line"></view>
<text class="section-title"><text class="required">*</text>盘点时间</text>
</view>
<view class="form-row-card datetime-picker-card">
<uni-datetime-picker
v-model="checkTime"
type="datetime"
placeholder="请选择盘点时间"
:clear-icon="false"
return-type="string"
/>
</view>
<view class="section-title-bar">
<view class="section-bar-line"></view>
<text class="section-title"><text class="required">*</text>生成来源</text>
</view>
<view class="radio-group">
<view :class="['radio-item', sourceType === 1 ? 'radio-active' : '']" @click="switchSourceType(1)">
<text class="radio-text">按库存</text>
</view>
<view :class="['radio-item', sourceType === 2 ? 'radio-active' : '']" @click="switchSourceType(2)">
<text class="radio-text">按产品</text>
</view>
</view>
<!-- 按库存 -->
<template v-if="sourceType === 1">
<view class="section-title-bar">
<view class="section-bar-line"></view>
<text class="section-title">仓库/库区/盘点项</text>
</view>
<view class="select-row-card">
<view class="warehouse-area-rows">
<view class="warehouse-area-row">
<text class="warehouse-area-label">仓库</text>
<view class="warehouse-area-dropdown">
<view class="dropdown-input">
<text class="dropdown-value">原料仓</text>
</view>
</view>
</view>
<view class="warehouse-area-row">
<text class="warehouse-area-label">库区</text>
<view class="warehouse-area-dropdown">
<view class="dropdown-input" @click="goSelectArea">
<text :class="['dropdown-value', { placeholder: !selectedAreas.length }]">
{{ selectedAreas.length ? selectedAreas.map(a => a.label).join('、') : '请选择' }}
</text>
<text class="dropdown-arrow"></text>
</view>
</view>
</view>
<view class="warehouse-area-row" v-if="selectedAreas.length">
<text class="warehouse-area-label">盘点项</text>
<view class="item-select-btn" @click="goSelectItems">
<text class="item-select-text">{{ items.length ? `已选${items.length}` : '点击选择' }}</text>
<text class="dropdown-arrow"></text>
</view>
</view>
</view>
</view>
</template>
<!-- 按产品 -->
<template v-if="sourceType === 2">
<view class="section-title-bar">
<view class="section-bar-line"></view>
<text class="section-title"><text class="required">*</text>产品/盘点项</text>
</view>
<view class="select-row-card">
<view class="warehouse-area-rows">
<view class="warehouse-area-row">
<text class="warehouse-area-label">产品</text>
<view class="warehouse-area-dropdown" @click="goSelectProduct">
<view class="dropdown-input">
<text :class="['dropdown-value', { placeholder: !selectedProducts.length }]">
{{ selectedProducts.length ? selectedProducts.map(p => p.name).join('、') : '请选择' }}
</text>
<text class="dropdown-arrow"></text>
</view>
</view>
</view>
<view class="warehouse-area-row" v-if="selectedProducts.length">
<text class="warehouse-area-label">盘点项</text>
<view class="warehouse-area-dropdown" @click="goSelectItemsByProduct">
<view class="dropdown-input">
<text class="dropdown-value">{{ items.length ? `已选择 ${items.length}` : '请选择' }}</text>
<text class="dropdown-arrow"></text>
</view>
</view>
</view>
</view>
</view>
</template>
<!-- 已选盘点项列表 -->
<view class="section-title-bar" v-if="items.length">
<view class="section-bar-line"></view>
<text class="section-title">已选盘点项{{ items.length }}</text>
</view>
<view v-if="items.length" class="item-list">
<view v-for="(item, idx) in items" :key="idx" class="item-card">
<view class="item-header">
<text class="item-name">{{ textValue(item.productName) }}</text>
<text class="item-code">{{ textValue(item.productBarCode) }}</text>
</view>
<view class="item-body">
<view class="item-row">
<text class="item-lbl">仓库</text>
<text class="item-val">{{ textValue(item.warehouseName) }}</text>
</view>
<view class="item-row">
<text class="item-lbl">库区</text>
<text class="item-val">{{ textValue(item.areaName) }}</text>
</view>
<view class="item-row">
<text class="item-lbl">账面数量</text>
<text class="item-val highlight">{{ textValue(item.stockCount) }}</text>
</view>
</view>
<view class="item-delete" @click="items.splice(idx, 1)">
<text class="item-delete-text">删除</text>
</view>
</view>
</view>
<view class="section-title-bar">
<view class="section-bar-line"></view>
<text class="section-title">备注</text>
</view>
<view class="form-row-card remark-card">
<textarea v-model="remark" class="remark-textarea" placeholder="请输入备注" :maxlength="200" auto-height />
</view>
<view class="bottom-actions" v-if="items.length">
<view class="bottom-btn cancel-btn" @click="handleCancel"></view>
<view class="bottom-btn confirm-btn" @click="handleSubmit"></view>
</view>
</view>
</template>
<script setup>
import { ref } from 'vue'
import { onShow } from '@dcloudio/uni-app'
import NavBar from '@/components/common/NavBar.vue'
import UniDatetimePicker from '@dcloudio/uni-ui/lib/uni-datetime-picker/uni-datetime-picker.vue'
import { getWarehouseSimpleList } from '@/api/mes/moldget'
import { createMaterialCheck } from '@/api/mes/materialCheck'
const now = new Date()
const pad = (n) => String(n).padStart(2, '0')
const checkTime = ref(`${now.getFullYear()}-${pad(now.getMonth() + 1)}-${pad(now.getDate())} ${pad(now.getHours())}:${pad(now.getMinutes())}:${pad(now.getSeconds())}`)
const sourceType = ref(1)
const categoryType = ref(2)
function switchSourceType(type) {
sourceType.value = type
items.value = []
selectedProducts.value = []
selectedAreas.value = []
}
const warehouseOptions = ref([])
const selectedWarehouse = ref(null)
const selectedAreas = ref([])
const selectedProducts = ref([])
const items = ref([])
const remark = ref('')
function textValue(v) {
if (v === 0) return '0'
if (v == null) return '-'
const s = String(v).trim()
return s || '-'
}
async function loadWarehouses() {
try {
const res = await getWarehouseSimpleList()
const data = Array.isArray(res) ? res : (Array.isArray(res?.data) ? res.data : [])
warehouseOptions.value = data.map(w => ({ value: w.id, label: w.name || String(w.id) }))
if (warehouseOptions.value.length && !selectedWarehouse.value) {
selectedWarehouse.value = warehouseOptions.value.find(w => w.label === '原料仓') || warehouseOptions.value[0]
}
} catch (e) {
console.error('loadWarehouses error', e)
}
}
function goSelectArea() {
getApp().globalData._materialCheckAreaSelectResult = null
getApp().globalData._materialCheckAreaWarehouseId = selectedWarehouse.value?.value || ''
getApp().globalData._materialCheckAreaSelected = selectedAreas.value.length
? JSON.parse(JSON.stringify(selectedAreas.value))
: null
uni.navigateTo({
url: `/pages_function/pages/materialCheck/areaSelect`
})
}
function goSelectItems() {
if (!selectedAreas.value.length) return
getApp().globalData._materialCheckItemSelectResult = null
getApp().globalData._materialCheckItemSelected = items.value.length
? JSON.parse(JSON.stringify(items.value))
: null
const areaIds = selectedAreas.value.map(a => a.value).join(',')
uni.navigateTo({
url: `/pages_function/pages/materialCheck/itemSelect?warehouseId=${selectedWarehouse.value.value}&areaIds=${areaIds}`
})
}
function goSelectProduct() {
getApp().globalData._materialCheckProductSelectResult = null
getApp().globalData._materialCheckProductSelected = selectedProducts.value.length
? JSON.parse(JSON.stringify(selectedProducts.value))
: null
uni.navigateTo({
url: `/pages_function/pages/materialCheck/productSelect`
})
}
function goSelectItemsByProduct() {
if (!selectedProducts.value.length) return
getApp().globalData._materialCheckItemSelectResult = null
getApp().globalData._materialCheckItemSelected = items.value.length
? JSON.parse(JSON.stringify(items.value))
: null
const ids = selectedProducts.value.map(p => p.id).join(',')
uni.navigateTo({
url: `/pages_function/pages/materialCheck/itemSelectByProduct?productIds=${ids}`
})
}
async function handleSubmit() {
if (!items.value.length) {
uni.showToast({ title: '请先选择盘点项', icon: 'none' })
return
}
const submitItems = items.value.map(item => ({
warehouseId: Number(item.warehouseId),
areaId: item.areaId ? Number(item.areaId) : undefined,
productId: Number(item.productId),
productBarCode: item.productBarCode || '',
productName: item.productName || '',
stockCount: item.stockCount != null ? Number(item.stockCount) : 0,
actualCount: null,
productPrice: item.productPrice != null ? Number(item.productPrice) : 0,
count: 0,
remark: ''
}))
try {
uni.showLoading({ title: '保存中...', mask: true })
await createMaterialCheck({
checkTime: checkTime.value,
sourceType: sourceType.value,
categoryType: categoryType.value,
checkStatus: 0,
remark: remark.value || '',
items: submitItems
})
uni.hideLoading()
uni.showToast({ title: '创建成功', icon: 'success' })
setTimeout(() => uni.navigateBack(), 1500)
} catch (e) {
uni.hideLoading()
const msg = e?.message || e?.data?.msg || '创建失败'
uni.showToast({ title: String(msg).substring(0, 50), icon: 'none' })
}
}
function handleCancel() { uni.navigateBack() }
onShow(() => {
loadWarehouses()
const productResult = getApp().globalData?._materialCheckProductSelectResult
if (productResult && Array.isArray(productResult)) {
selectedProducts.value = productResult.map(p => ({
id: p.id,
name: p.name || '物料'
}))
items.value = []
getApp().globalData._materialCheckProductSelectResult = null
}
const areaResult = getApp().globalData?._materialCheckAreaSelectResult
if (areaResult && Array.isArray(areaResult)) {
selectedAreas.value = areaResult.map(a => ({
value: a.id,
label: a.name || '库区'
}))
items.value = []
getApp().globalData._materialCheckAreaSelectResult = null
}
const itemResult = getApp().globalData?._materialCheckItemSelectResult
if (itemResult && Array.isArray(itemResult)) {
const existingKeys = new Set(items.value.map(i => `${i.productId || i.id}_${i.warehouseId || ''}_${i.areaId || ''}`))
const newItems = itemResult.filter(i => !existingKeys.has(`${i.productId || i.id}_${i.warehouseId || ''}_${i.areaId || ''}`))
if (newItems.length) {
items.value = [...items.value, ...newItems]
}
getApp().globalData._materialCheckItemSelectResult = null
}
})
</script>
<style lang="scss" scoped>
.page-container {
min-height: 100vh;
background: #f5f6f8;
padding-bottom: calc(120rpx + env(safe-area-inset-bottom));
}
.section-title-bar {
display: flex; align-items: center; gap: 10rpx;
padding: 24rpx 24rpx 18rpx;
}
.section-bar-line { width: 6rpx; height: 32rpx; border-radius: 3rpx; background: #2563eb; flex-shrink: 0; }
.section-title { font-size: 30rpx; font-weight: 700; color: #1a1a1a; }
.required { color: #ef4444; }
.form-row-card {
display: flex; align-items: center; justify-content: space-between;
background: #fff; border-radius: 16rpx; padding: 26rpx 24rpx; margin: 0 24rpx 16rpx;
box-shadow: 0 4rpx 16rpx rgba(15,23,42,0.04);
font-size: 28rpx; color: #374151;
.placeholder { color: #9ca3af; }
}
.datetime-picker-card {
flex-direction: column;
align-items: stretch;
padding: 16rpx 24rpx;
:deep(.uni-date) { width: 100%; }
}
.radio-group { display: flex; gap: 12rpx; padding: 0 24rpx 16rpx; }
.radio-item {
padding: 16rpx 36rpx; border-radius: 12rpx;
background: #fff; border: 2rpx solid #e5e7eb;
font-size: 26rpx; color: #6b7280; text-align: center;
&.radio-active { background: #1f4b79; border-color: #1f4b79; .radio-text { color: #fff; } }
}
.radio-text { font-size: 26rpx; color: #6b7280; }
.item-list { padding: 0 24rpx; }
.item-card {
background: #fff; border-radius: 14rpx; padding: 20rpx; margin-bottom: 16rpx;
box-shadow: 0 2rpx 12rpx rgba(15,23,42,0.04); position: relative;
}
.item-header { margin-bottom: 14rpx; padding-bottom: 14rpx; border-bottom: 1rpx solid #f0f0f0; }
.item-name { font-size: 28rpx; font-weight: 600; color: #1a1a1a; display: block; }
.item-code { font-size: 24rpx; color: #9ca3af; margin-top: 4rpx; display: block; }
.item-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12rpx;
&:last-child { margin-bottom: 0; }
}
.item-lbl { font-size: 26rpx; color: #6b7280; }
.item-val { font-size: 26rpx; color: #374151; &.highlight { font-weight: 700; color: #1f4b79; } }
.item-delete { position: absolute; top: 20rpx; right: 20rpx; }
.item-delete-text { font-size: 24rpx; color: #dc2626; }
.remark-card { padding: 20rpx 24rpx; }
.remark-textarea { width: 100%; min-height: 120rpx; font-size: 27rpx; color: #374151; line-height: 1.6; box-sizing: border-box; }
.bottom-actions {
position: fixed; left: 0; right: 0; bottom: 0; display: flex; gap: 18rpx;
padding: 18rpx 24rpx calc(18rpx + env(safe-area-inset-bottom));
background: #fff; box-shadow: 0 -8rpx 24rpx rgba(15,23,42,0.06); z-index: 99;
}
.bottom-btn { flex: 1; height: 84rpx; line-height: 84rpx; text-align: center; border-radius: 16rpx; font-size: 30rpx; font-weight: 600;
&:active { opacity: 0.85; }
}
.cancel-btn { background: #eef2f7; color: #475569; }
.confirm-btn { background: #1f4b79; color: #fff; }
.select-row-card { background: #fff; border-radius: 16rpx; padding: 24rpx; margin: 0 24rpx 16rpx; box-shadow: 0 4rpx 16rpx rgba(15,23,42,0.04); min-height: 0 !important; height: auto !important; }
.warehouse-area-rows { display: flex; flex-direction: column; gap: 16rpx; }
.warehouse-area-row { display: flex; align-items: center; }
.warehouse-area-label { width: 100rpx; font-size: 26rpx; color: #6b7280; flex-shrink: 0; }
.warehouse-area-dropdown { flex: 1; position: relative; }
.dropdown-input { display: flex; align-items: center; min-height: 64rpx !important; height: 64rpx !important; padding: 0 20rpx; border: 1rpx solid #e0e0e0; border-radius: 10rpx; background: #f9fafb; }
.dropdown-value { flex: 1; font-size: 27rpx; color: #333; &.placeholder { color: #bbb; } }
.dropdown-arrow { font-size: 20rpx; color: #999; }
.dropdown-panel { position: absolute; top: 68rpx; left: 0; right: 0; z-index: 100; background: #fff; border: 1rpx solid #e0e0e0; border-radius: 12rpx; box-shadow: 0 8rpx 30rpx rgba(0,0,0,0.1); overflow: hidden; }
.dropdown-scroll { max-height: 360rpx; overflow-y: auto; }
.dropdown-item { display: flex; align-items: center; padding: 20rpx 24rpx; border-bottom: 1rpx solid #f0f0f0;
&:last-child { border-bottom: 0; }
&.active { background: #f0f5ff; }
}
.item-select-btn {
flex: 1; display: flex; align-items: center; justify-content: space-between;
height: 64rpx; padding: 0 20rpx; border: 1rpx solid #e0e0e0;
border-radius: 10rpx; background: #f9fafb;
}
.item-select-text { font-size: 27rpx; color: #333; }
.item-select-btn .dropdown-arrow { font-size: 20rpx; color: #999; }
</style>

@ -0,0 +1,392 @@
<template>
<view class="page-container">
<NavBar :title="'盘点执行'" />
<view class="header-card" v-if="detail">
<view class="header-top">
<text class="header-no">{{ textValue(detail.no) }}</text>
</view>
<view class="header-info">
<view class="info-row">
<text class="info-label">盘点仓库</text>
<text class="info-value">{{ textValue(detail.warehouseName || getWarehouseName()) }}</text>
</view>
<view class="info-row">
<text class="info-label">盘点库位</text>
<text class="info-value">{{ textValue(getAreaName()) }}</text>
</view>
<view class="info-row">
<text class="info-label">盘点时间</text>
<text class="info-value">{{ formatDateTime(detail.checkTime) }}</text>
</view>
<view class="info-row">
<text class="info-label">盘点人</text>
<text class="info-value">{{ textValue(detail.creatorName || detail.creator) }}</text>
</view>
</view>
</view>
<view v-if="loading" class="hint">...</view>
<view v-else-if="items.length" class="check-list">
<view v-for="(item, idx) in items" :key="idx" class="check-card">
<view class="check-card-header">
<text class="check-card-index">{{ idx + 1 }}</text>
<view class="check-card-header-info">
<text class="check-card-name">{{ textValue(item.productName) }}</text>
<text class="check-card-code">{{ textValue(item.productBarCode) }}</text>
</view>
</view>
<view class="sparepart-info">
<view class="sp-row">
<text class="sp-label">规格型号</text>
<text class="sp-value">{{ textValue(item.standard || item.productStandard || item.deviceSpec) }}</text>
</view>
</view>
<view class="stock-info">
<view class="st-row">
<text class="st-label">账面库存</text>
<text class="st-value">{{ formatNumber(item.stockCount) }} {{ textValue(item.productUnitName || item.unitName || '个') }}</text>
</view>
<view class="st-row">
<text class="st-label">最小单位</text>
<text class="st-value">{{ textValue(item.productUnitName || item.unitName || '个') }}</text>
</view>
<view class="st-row">
<text class="st-label">换算关系</text>
<text class="st-value">{{ getConvertText(item) }}</text>
</view>
</view>
<view class="input-row">
<text class="input-label">实盘数量</text>
<view class="input-control">
<view class="input-btn minus" @click="handleMinus(idx)">-</view>
<input v-model="item._checkCount" class="input-field" type="digit" placeholder="0" />
<view class="input-btn plus" @click="handlePlus(idx)">+</view>
</view>
</view>
<view class="diff-row">
<text class="diff-label">差异</text>
<text :class="['diff-value', diffClass(item)]">{{ getDiffText(item) }}</text>
</view>
<view class="remark-row">
<text class="remark-label">备注</text>
<input v-model="item._remark" class="remark-input" placeholder="请输入备注" />
</view>
</view>
</view>
<view v-else class="hint">暂无盘点数据</view>
<view v-if="items.length" class="bottom-actions">
<view class="submit-btn" @click="handleSubmit"></view>
</view>
</view>
</template>
<script setup>
import { ref } from 'vue'
import { onLoad } from '@dcloudio/uni-app'
import NavBar from '@/components/common/NavBar.vue'
import { getMaterialCheckDetail, executeMaterialCheck } from '@/api/mes/materialCheck'
import { getProductDetail } from '@/api/mes/sparepart'
const detail = ref(null)
const items = ref([])
const loading = ref(false)
function textValue(v) {
if (v === 0) return '0'
if (v == null) return '-'
const s = String(v).trim()
return s || '-'
}
function formatNumber(v) {
if (v == null) return '0'
return String(v)
}
function formatDateTime(value) {
if (!value) return '-'
if (Array.isArray(value) && value.length >= 5) {
const [y, m, d, h = 0, min = 0, s = 0] = value
const pad = (n) => String(n).padStart(2, '0')
return `${y}-${pad(m)}-${pad(d)} ${pad(h)}:${pad(min)}:${pad(s)}`
}
const date = new Date(Number(value))
if (Number.isNaN(date.getTime())) return String(value)
const pad = (n) => String(n).padStart(2, '0')
return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())} ${pad(date.getHours())}:${pad(date.getMinutes())}:${pad(date.getSeconds())}`
}
function getWarehouseName() {
const item = items.value[0]
return item?.warehouseName || ''
}
function getAreaName() {
const item = items.value[0]
return item?.areaName || ''
}
function getConvertText(item) {
const purchaseUnit = item?.purchaseUnitName
const ratio = item?.purchaseUnitConvertQuantity
const unit = item?.productUnitName || item?.unitName || '个'
if (purchaseUnit && ratio) {
return `1${purchaseUnit}=${ratio}${unit}`
}
return '-'
}
function getDiff(item) {
const count = Number(item._checkCount) || 0
const stock = Number(item.stockCount) || 0
return count - stock
}
function getDiffText(item) {
const d = getDiff(item)
const unit = item?.productUnitName || item?.unitName || '个'
if (d === 0) return `0 ${unit}`
return `${d > 0 ? '+' : ''}${d} ${unit}`
}
function diffClass(item) {
const d = getDiff(item)
if (d > 0) return 'positive'
if (d < 0) return 'negative'
return ''
}
function handleMinus(idx) {
const val = Number(items.value[idx]._checkCount) || 0
if (val > 0) {
items.value[idx]._checkCount = String(val - 1)
}
}
function handlePlus(idx) {
const val = Number(items.value[idx]._checkCount) || 0
items.value[idx]._checkCount = String(val + 1)
}
onLoad(async (options) => {
const id = options?.id
if (!id) {
uni.showToast({ title: '参数错误', icon: 'none' })
return
}
loading.value = true
try {
const res = await getMaterialCheckDetail(id)
const data = res?.data || res
detail.value = data
const rawItems = data?.items || []
const enrichedItems = await Promise.all(
rawItems.map(async (item) => {
if (!item.productId) return item
try {
const productRes = await getProductDetail(item.productId)
const product = productRes?.data || productRes
if (product && product.id) {
return {
...item,
standard: item.standard || product.standard || product.deviceSpec,
productUnitName: item.productUnitName || product.unitName || product.minStockUnitName,
minStockUnitName: item.minStockUnitName || product.minStockUnitName,
purchaseUnitName: item.purchaseUnitName || product.purchaseUnitName,
purchaseUnitConvertQuantity: item.purchaseUnitConvertQuantity || product.purchaseUnitConvertQuantity,
_checkCount: item.checkCount != null ? String(item.checkCount) : '',
_remark: item.remark || ''
}
}
} catch (e) {
console.error('补全物料信息失败:', item.productId, e)
}
return {
...item,
_checkCount: '',
_remark: ''
}
})
)
items.value = enrichedItems
} catch (e) {
const msg = e?.message || e?.data?.msg || '加载失败'
console.error('加载盘点单失败:', e)
uni.showToast({ title: String(msg).substring(0, 50), icon: 'none' })
} finally {
loading.value = false
}
})
async function handleSubmit() {
const submitItems = items.value.map((item) => {
const actual = Number(item._checkCount) || 0
const stock = item.stockCount != null ? Number(item.stockCount) : 0
return {
id: Number(item.id),
warehouseId: Number(item.warehouseId),
areaId: item.areaId ? Number(item.areaId) : undefined,
productId: Number(item.productId),
productPrice: item.productPrice != null ? Number(item.productPrice) : 0,
stockCount: stock,
actualCount: actual,
count: actual - stock,
remark: item._remark || ''
}
})
try {
const now = new Date()
const pad = (n) => String(n).padStart(2, '0')
const checkTimeStr = `${now.getFullYear()}-${pad(now.getMonth() + 1)}-${pad(now.getDate())} ${pad(now.getHours())}:${pad(now.getMinutes())}:${pad(now.getSeconds())}`
const payload = {
id: Number(detail.value.id),
checkTime: checkTimeStr,
sourceType: detail.value.sourceType,
categoryType: detail.value.categoryType,
checkStatus: 1,
remark: '',
fileUrl: '',
items: submitItems
}
console.log('[物料盘点提交]', JSON.stringify(payload))
uni.showLoading({ title: '提交中...', mask: true })
await executeMaterialCheck(payload)
uni.hideLoading()
uni.showToast({ title: '盘点完成', icon: 'success' })
setTimeout(() => uni.navigateBack(), 1500)
} catch (e) {
uni.hideLoading()
const msg = e?.message || e?.data?.msg || e?.response?.data?.msg || '盘点失败'
console.error('盘点提交失败:', e)
uni.showToast({ title: String(msg).substring(0, 50), icon: 'none' })
}
}
</script>
<style lang="scss" scoped>
.page-container {
min-height: 100vh;
background: #f5f6f8;
padding-bottom: calc(120rpx + env(safe-area-inset-bottom));
}
.header-card {
background: #fff;
margin: 20rpx 24rpx;
padding: 24rpx;
border-radius: 16rpx;
}
.header-top { margin-bottom: 20rpx; }
.header-no { font-size: 32rpx; font-weight: 700; color: #1a1a1a; }
.header-info { border-top: 1rpx solid #f0f0f0; padding-top: 20rpx; }
.info-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16rpx;
&:last-child { margin-bottom: 0; }
}
.info-label { font-size: 26rpx; color: #6b7280; }
.info-value { font-size: 26rpx; color: #1a1a1a; font-weight: 500; }
.check-list { padding: 0 24rpx; }
.check-card {
background: #fff;
border-radius: 16rpx;
padding: 24rpx;
margin-bottom: 20rpx;
}
.check-card-header {
display: flex;
align-items: center;
gap: 16rpx;
margin-bottom: 20rpx;
padding-bottom: 20rpx;
border-bottom: 1rpx solid #f0f0f0;
}
.check-card-index {
width: 48rpx;
height: 48rpx;
border-radius: 24rpx;
background: #1f4b79;
color: #fff;
font-size: 26rpx;
font-weight: 700;
display: flex;
align-items: center;
justify-content: center;
flex-shrink: 0;
}
.check-card-header-info { flex: 1; }
.check-card-name { font-size: 30rpx; font-weight: 700; color: #1a1a1a; display: block; }
.check-card-code { font-size: 24rpx; color: #9ca3af; margin-top: 4rpx; display: block; }
.sparepart-info { margin-bottom: 20rpx; }
.sp-row { display: flex; align-items: center; justify-content: space-between; }
.sp-label { font-size: 26rpx; color: #6b7280; }
.sp-value { font-size: 26rpx; color: #1a1a1a; font-weight: 500; }
.stock-info {
background: #f8fafc;
border-radius: 12rpx;
padding: 20rpx;
margin-bottom: 20rpx;
}
.st-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12rpx;
&:last-child { margin-bottom: 0; }
}
.st-label { font-size: 24rpx; color: #6b7280; }
.st-value { font-size: 26rpx; color: #16a34a; font-weight: 600; }
.input-row { margin-bottom: 20rpx; }
.input-label { font-size: 26rpx; color: #1a1a1a; font-weight: 500; margin-bottom: 12rpx; display: block; }
.input-control { display: flex; align-items: center; gap: 12rpx; }
.input-btn {
width: 64rpx; height: 64rpx; border-radius: 12rpx;
background: #f3f4f6; display: flex; align-items: center; justify-content: center;
font-size: 36rpx; color: #374151; font-weight: 600;
&:active { background: #e5e7eb; }
}
.input-field {
flex: 1; height: 64rpx; text-align: center;
background: #f8fafc; border: 1rpx solid #e0e0e0; border-radius: 10rpx;
font-size: 30rpx; color: #1a1a1a; font-weight: 600;
}
.diff-row { display: flex; align-items: center; justify-content: space-between; padding: 16rpx 0; border-top: 1rpx solid #f0f0f0; margin-bottom: 16rpx; }
.diff-label { font-size: 26rpx; color: #6b7280; }
.diff-value { font-size: 28rpx; font-weight: 700;
&.positive { color: #16a34a; }
&.negative { color: #dc2626; }
}
.remark-row { display: flex; align-items: center; gap: 16rpx; }
.remark-label { font-size: 26rpx; color: #6b7280; flex-shrink: 0; }
.remark-input {
flex: 1; height: 64rpx;
background: #f8fafc; border: 1rpx solid #e0e0e0; border-radius: 10rpx;
padding: 0 16rpx; font-size: 26rpx; color: #374151;
}
.hint { padding: 120rpx 0; text-align: center; color: #94a3b8; font-size: 28rpx; }
.bottom-actions {
position: fixed; left: 0; right: 0; bottom: 0;
padding: 20rpx 24rpx calc(20rpx + env(safe-area-inset-bottom));
background: #fff; box-shadow: 0 -4rpx 20rpx rgba(0,0,0,0.06);
}
.submit-btn {
height: 88rpx; line-height: 88rpx; text-align: center;
background: #1a3a5c; color: #fff; font-size: 30rpx; font-weight: 600;
border-radius: 12rpx;
&:active { opacity: 0.9; }
}
</style>

@ -0,0 +1,872 @@
<template>
<view class="page-container">
<NavBar :title="'物料盘点'" />
<view class="filter-bar">
<view class="keyword-box">
<input
v-model="searchKeyword"
class="keyword-input"
placeholder="搜索单号"
confirm-type="search"
@input="handleKeywordInput"
@confirm="handleSearch"
/>
</view>
<picker mode="selector" :range="statusLabels" :value="statusIndex" @change="onStatusChange">
<view class="status-box">
<text class="status-box-text">{{ currentStatusLabel }}</text>
<uni-icons type="bottom" size="14" color="#9ca3af"></uni-icons>
</view>
</picker>
<view class="reset-filter-btn" @click="resetFilters"></view>
</view>
<scroll-view
scroll-y
class="list-scroll"
:scroll-top="scrollTop"
@scroll="onScroll"
@scrolltolower="loadMore"
:lower-threshold="80"
>
<view class="list-wrap">
<view
v-for="item in list"
:key="item.id"
class="task-card"
@click="openDetail(item)"
>
<view class="card-header">
<view class="header-main">
<view class="header-left">
<text class="task-no">{{ textValue(item.no) }}</text>
</view>
<view class="header-tags">
<text :class="['record-tag', statusClass(item.status)]">{{ statusText(item.status) }}</text>
<text :class="['record-tag', checkStatusClass(item.checkStatus)]">{{ checkStatusText(item.checkStatus) }}</text>
</view>
</view>
</view>
<view class="card-body">
<view class="row">
<text class="label">产品物料名称</text>
<text class="value">{{ textValue(item.productNames) }}</text>
</view>
<view class="row">
<text class="label">仓库</text>
<text class="value">{{ textValue(item.warehouseName || getItemsWarehouseName(item.items)) }}</text>
</view>
<view class="row">
<text class="label">盘点时间</text>
<text class="value">{{ formatDateTime(item.checkTime) }}</text>
</view>
<view class="row">
<text class="label">创建人</text>
<text class="value">{{ textValue(item.creatorName || item.creator) }}</text>
</view>
<view class="row">
<text class="label">创建时间</text>
<text class="value">{{ formatDateTime(item.createTime) }}</text>
</view>
<view class="row">
<text class="label">审核人</text>
<text class="value">{{ textValue(item.auditUserName) }}</text>
</view>
<view class="row">
<text class="label">备注</text>
<text class="value">{{ textValue(item.remark) }}</text>
</view>
</view>
<view class="card-actions" v-if="showActions(item)">
<view v-if="Number(item.status) === 10" class="action-btn approve-btn" @click.stop="handleApprove(item)"></view>
<view v-if="Number(item.status) === 10" class="action-btn reject-btn" @click.stop="handleReject(item)"></view>
<view v-if="showSubmit(item)" class="action-btn submit-btn" @click.stop="openSubmitDialog(item)"></view>
<view v-if="showCheck(item)" class="action-btn execute-btn" @click.stop="goExecute(item)"></view>
<view v-if="Number(item.status) !== 20" class="action-btn delete-btn" @click.stop="handleDelete(item)"></view>
</view>
</view>
<view v-if="loading && pageNo === 1" class="hint">...</view>
<view v-else-if="!list.length" class="hint">暂无盘点数据</view>
<view v-else-if="loadingMore" class="hint">加载更多...</view>
<view v-else-if="finished" class="hint">没有更多了</view>
</view>
</scroll-view>
<view v-if="showGoTop" class="go-top-btn" @click="goTop">
<uni-icons type="arrow-up" size="20" color="#1f4b79"></uni-icons>
</view>
<view class="add-btn" @click="goAdd">
<text class="add-icon">+</text>
</view>
<!-- 提交弹框 -->
<view v-if="showSubmitModal" class="modal-overlay" @click="closeSubmitDialog">
<view class="modal-card" @click.stop>
<view class="modal-header">
<text class="modal-title">提交审核</text>
<text class="modal-close" @click="closeSubmitDialog"></text>
</view>
<view class="modal-body">
<view class="modal-field">
<text class="modal-label"><text class="required">*</text>审核人</text>
<view class="modal-dropdown" @click="toggleSubmitAuditorDropdown">
<text :class="{ placeholder: !selectedSubmitAuditor }">{{ selectedSubmitAuditor ? selectedSubmitAuditor.label : '请选择' }}</text>
<text class="dropdown-arrow"></text>
<view v-if="showSubmitAuditorDropdown" class="dropdown-panel">
<scroll-view scroll-y class="dropdown-scroll">
<view v-for="u in submitAuditorOptions" :key="u.value" class="dropdown-item" :class="{ active: selectedSubmitAuditor?.value === u.value }" @click.stop="selectSubmitAuditor(u)">
<text class="dropdown-item-text">{{ u.label }}</text>
<text v-if="selectedSubmitAuditor?.value === u.value" class="dropdown-check"></text>
</view>
</scroll-view>
</view>
</view>
</view>
<view class="modal-field">
<text class="modal-label">备注</text>
<textarea v-model="submitRemark" class="modal-textarea" placeholder="请输入备注" placeholder-class="textarea-placeholder" :maxlength="200" />
</view>
</view>
<view class="modal-footer">
<view class="modal-btn cancel-btn" @click="closeSubmitDialog"></view>
<view class="modal-btn confirm-btn" @click="confirmSubmitAudit"></view>
</view>
</view>
</view>
</view>
</template>
<script setup>
import { computed, ref } from 'vue'
import { onShow, onUnload } from '@dcloudio/uni-app'
import NavBar from '@/components/common/NavBar.vue'
import { getMaterialCheckPage, deleteMaterialCheck, submitMaterialCheck, auditMaterialCheck } from '@/api/mes/materialCheck'
import { getWarehouseSimpleList } from '@/api/mes/sparepart'
import { getSimpleUserList } from '@/api/mes/moldget'
const selectedStatus = ref('')
const searchKeyword = ref('')
const materialWarehouseId = ref('')
const statusOptions = computed(() => [
{ label: '全部', value: '' },
{ label: '待提交', value: '0' },
{ label: '审核中', value: '10' },
{ label: '已通过', value: '20' },
{ label: '已驳回', value: '1' }
])
const statusLabels = computed(() => statusOptions.value.map((item) => item.label))
const statusIndex = computed(() => {
const index = statusOptions.value.findIndex((item) => item.value === selectedStatus.value)
return index >= 0 ? index : 0
})
const currentStatusLabel = computed(() => {
const current = statusOptions.value.find((item) => item.value === selectedStatus.value)
return current ? current.label : '全部'
})
const list = ref([])
const loading = ref(false)
const loadingMore = ref(false)
const finished = ref(false)
const pageNo = ref(1)
const pageSize = ref(10)
const scrollTop = ref(0)
const showGoTop = ref(false)
let searchTimer = null
async function loadMaterialWarehouse() {
try {
const res = await getWarehouseSimpleList()
const data = Array.isArray(res) ? res : (Array.isArray(res?.data) ? res.data : [])
const material = data.find((w) => (w.name || '').includes('原料'))
materialWarehouseId.value = material ? String(material.id) : ''
} catch (e) {
console.error('loadMaterialWarehouse error', e)
}
}
function textValue(v) {
if (v === 0) return '0'
if (v == null) return '-'
const s = String(v).trim()
return s || '-'
}
function getItemsWarehouseName(items) {
if (!Array.isArray(items) || !items.length) return ''
const names = [...new Set(items.map(i => i.warehouseName || i.areaName).filter(Boolean))]
return names.join('、') || ''
}
function formatDateTime(value) {
if (!value) return '-'
if (Array.isArray(value) && value.length >= 3) {
const [year, month, day, hour = 0, minute = 0, second = 0] = value
const pad = (n) => String(n).padStart(2, '0')
return `${year}-${pad(month)}-${pad(day)} ${pad(hour)}:${pad(minute)}:${pad(second)}`
}
const date = new Date(Number(value))
if (Number.isNaN(date.getTime())) return String(value)
const pad = (n) => String(n).padStart(2, '0')
return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())} ${pad(date.getHours())}:${pad(date.getMinutes())}:${pad(date.getSeconds())}`
}
const STATUS_MAP = { 0: '待提交', 10: '审核中', 20: '已通过', 1: '已驳回' }
function statusText(s) {
const num = Number(s)
return STATUS_MAP[num] || textValue(num)
}
function statusClass(s) {
const num = Number(s)
if (num === 0) return 'text-primary'
if (num === 10) return 'text-muted'
if (num === 20) return 'text-success'
if (num === 1) return 'text-danger'
return ''
}
const CHECK_STATUS_MAP = { 0: '未盘点', 1: '已盘点' }
function checkStatusText(s) {
const num = Number(s)
return CHECK_STATUS_MAP[num] || textValue(num)
}
function checkStatusClass(s) {
const num = Number(s)
if (num === 0) return 'text-muted'
if (num === 1) return 'text-success'
return ''
}
function normalizePageData(res) {
const root = res && res.data !== undefined ? res.data : res
const candidateList = root?.list || root?.rows || root?.records || root?.data?.list || root?.data?.rows || []
const candidateTotal = root?.total ?? root?.data?.total ?? (Array.isArray(candidateList) ? candidateList.length : 0)
return {
list: Array.isArray(candidateList) ? candidateList : [],
total: Number(candidateTotal || 0)
}
}
async function fetchList(reset) {
if (reset) {
pageNo.value = 1
finished.value = false
}
if (pageNo.value === 1) {
loading.value = true
} else {
loadingMore.value = true
}
try {
const params = {
pageNo: pageNo.value,
pageSize: pageSize.value,
no: searchKeyword.value.trim() || undefined,
status: selectedStatus.value || undefined,
warehouseId: materialWarehouseId.value || undefined,
categoryType: 2
}
const res = await getMaterialCheckPage(params)
const page = normalizePageData(res)
list.value = reset ? page.list : [...list.value, ...page.list]
finished.value = list.value.length >= page.total || page.list.length < pageSize.value
} catch (e) {
if (!reset) pageNo.value = Math.max(1, pageNo.value - 1)
uni.showToast({ title: '加载失败', icon: 'none' })
} finally {
loading.value = false
loadingMore.value = false
}
}
function onStatusChange(event) {
const index = Number(event?.detail?.value || 0)
selectedStatus.value = statusOptions.value[index]?.value ?? ''
fetchList(true)
}
function handleSearch() {
clearSearchTimer()
uni.hideKeyboard()
fetchList(true)
}
function handleKeywordInput() {
clearSearchTimer()
searchTimer = setTimeout(() => {
fetchList(true)
}, 300)
}
function resetFilters() {
clearSearchTimer()
searchKeyword.value = ''
selectedStatus.value = ''
fetchList(true)
}
async function loadMore() {
if (loading.value || loadingMore.value || finished.value) return
pageNo.value += 1
await fetchList(false)
}
function openDetail(item) {
if (!item?.id) {
uni.showToast({ title: '无法查看详情', icon: 'none' })
return
}
uni.navigateTo({
url: `/pages_function/pages/materialCheck/detail?id=${encodeURIComponent(String(item.id))}`
})
}
function showActions(item) {
if (!item) return false
const status = Number(item.status)
const checkStatus = Number(item.checkStatus)
if (status === 10) return true
if ((status === 0 || status === 1) && checkStatus === 1) return true
if (checkStatus !== 1 && status !== 20) return true
if (status !== 20) return true
return false
}
function showSubmit(item) {
if (!item) return false
const status = Number(item.status)
const checkStatus = Number(item.checkStatus)
return (status === 0 || status === 1) && checkStatus === 1
}
function showCheck(item) {
if (!item) return false
const checkStatus = Number(item.checkStatus)
const status = Number(item.status)
return checkStatus !== 1 && status !== 20
}
const showSubmitModal = ref(false)
const currentSubmitItem = ref(null)
const submitAuditorOptions = ref([])
const selectedSubmitAuditor = ref(null)
const showSubmitAuditorDropdown = ref(false)
const submitRemark = ref('')
function openSubmitDialog(item) {
currentSubmitItem.value = item
selectedSubmitAuditor.value = null
submitRemark.value = ''
showSubmitModal.value = true
loadSubmitAuditorOptions()
}
function closeSubmitDialog() {
showSubmitModal.value = false
currentSubmitItem.value = null
showSubmitAuditorDropdown.value = false
}
function toggleSubmitAuditorDropdown() {
showSubmitAuditorDropdown.value = !showSubmitAuditorDropdown.value
}
function selectSubmitAuditor(u) {
selectedSubmitAuditor.value = u
showSubmitAuditorDropdown.value = false
}
async function loadSubmitAuditorOptions() {
if (submitAuditorOptions.value.length) return
try {
const res = await getSimpleUserList()
const data = Array.isArray(res) ? res : (Array.isArray(res?.data) ? res.data : [])
submitAuditorOptions.value = data.map((u) => ({
value: u.id || u.userId,
label: u.nickname || u.userName || u.name || String(u.id || '')
}))
} catch (e) {
console.error('loadSubmitAuditorOptions error', e)
}
}
async function confirmSubmitAudit() {
if (!selectedSubmitAuditor.value) {
uni.showToast({ title: '请选择审核人', icon: 'none' })
return
}
if (!currentSubmitItem.value?.id) return
try {
uni.showLoading({ title: '提交中...', mask: true })
await submitMaterialCheck({
id: currentSubmitItem.value.id,
auditUserId: selectedSubmitAuditor.value.value,
remark: submitRemark.value || undefined
})
uni.hideLoading()
uni.showToast({ title: '提交成功', icon: 'success' })
closeSubmitDialog()
fetchList(true)
} catch (e) {
uni.hideLoading()
uni.showToast({ title: '提交失败', icon: 'none' })
}
}
async function handleApprove(item) {
if (!item?.id) return
uni.showModal({
title: '确认',
content: '确认审核通过该盘点单?',
confirmColor: '#16a34a',
success: async (res) => {
if (res.confirm) {
try {
uni.showLoading({ title: '审核中...' })
await auditMaterialCheck({ id: item.id, status: 20 })
uni.hideLoading()
uni.showToast({ title: '审核通过', icon: 'success' })
fetchList(true)
} catch (e) {
uni.hideLoading()
uni.showToast({ title: '操作失败', icon: 'none' })
}
}
}
})
}
async function handleReject(item) {
if (!item?.id) return
uni.showModal({
title: '确认',
content: '确认驳回该盘点单?',
confirmColor: '#dc2626',
success: async (res) => {
if (res.confirm) {
try {
uni.showLoading({ title: '审核中...' })
await auditMaterialCheck({ id: item.id, status: 1 })
uni.hideLoading()
uni.showToast({ title: '已驳回', icon: 'success' })
fetchList(true)
} catch (e) {
uni.hideLoading()
uni.showToast({ title: '操作失败', icon: 'none' })
}
}
}
})
}
async function handleDelete(item) {
if (!item?.id) return
uni.showModal({
title: '确认删除',
content: '确认删除该盘点单?',
confirmColor: '#dc2626',
success: async (res) => {
if (res.confirm) {
try {
uni.showLoading({ title: '删除中...' })
await deleteMaterialCheck(item.id)
uni.hideLoading()
uni.showToast({ title: '删除成功', icon: 'success' })
fetchList(true)
} catch (e) {
uni.hideLoading()
uni.showToast({ title: '删除失败', icon: 'none' })
}
}
}
})
}
function goExecute(item) {
if (!item?.id) {
uni.showToast({ title: '数据异常', icon: 'none' })
return
}
uni.navigateTo({
url: `/pages_function/pages/materialCheck/execute?id=${encodeURIComponent(String(item.id))}`
})
}
function onScroll(event) {
showGoTop.value = (event?.detail?.scrollTop || 0) > 600
}
function goTop() {
scrollTop.value = 0
}
function goAdd() {
uni.navigateTo({
url: '/pages_function/pages/materialCheck/create'
})
}
function clearSearchTimer() {
if (searchTimer) {
clearTimeout(searchTimer)
searchTimer = null
}
}
onShow(() => {
loadMaterialWarehouse()
fetchList(true)
})
onUnload(() => {
clearSearchTimer()
})
</script>
<style lang="scss" scoped>
.page-container {
min-height: 100vh;
background: #f4f5f7;
}
.filter-bar {
display: flex;
align-items: center;
gap: 12rpx;
padding: 18rpx 24rpx;
background: #fff;
}
.keyword-box {
flex: 1;
min-width: 0;
height: 66rpx;
padding: 0 28rpx;
background: #f4f5f7;
border: 1rpx solid #e5e7eb;
border-radius: 12rpx;
display: flex;
align-items: center;
}
.keyword-input {
width: 100%;
font-size: 24rpx;
color: #374151;
}
.status-box {
flex-shrink: 0;
display: flex;
align-items: center;
justify-content: space-between;
height: 66rpx;
padding: 0 28rpx;
min-width: 160rpx;
background: #fff;
border: 1rpx solid #e5e7eb;
border-radius: 12rpx;
}
.status-box-text {
font-size: 24rpx;
color: #374151;
min-width: 0;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.reset-filter-btn {
height: 66rpx;
line-height: 66rpx;
padding: 0 28rpx;
font-size: 24rpx;
color: #4b5563;
background: #fff;
border: 1rpx solid #e5e7eb;
border-radius: 12rpx;
flex-shrink: 0;
}
.list-scroll {
height: calc(100vh - 194rpx);
}
.list-wrap {
padding: 0 24rpx 60rpx;
}
.task-card {
position: relative;
margin-top: 20rpx;
padding: 28rpx;
background: #fff;
border-radius: 22rpx;
box-shadow: 0 8rpx 28rpx rgba(15, 23, 42, 0.06);
}
.card-header {
margin-bottom: 18rpx;
}
.header-main {
display: flex;
align-items: center;
justify-content: space-between;
gap: 16rpx;
}
.header-left {
min-width: 0;
flex: 1;
}
.task-no {
font-size: 32rpx;
font-weight: 700;
color: #0f172a;
}
.header-tags {
display: flex;
align-items: center;
gap: 12rpx;
flex-shrink: 0;
}
.record-tag {
padding: 8rpx 18rpx;
border-radius: 999rpx;
font-size: 22rpx;
line-height: 1;
background: #e2e8f0;
color: #64748b;
}
.card-body .row {
display: flex;
justify-content: space-between;
align-items: flex-start;
gap: 20rpx;
margin-top: 12rpx;
&:first-child {
margin-top: 0;
}
}
.label {
width: 140rpx;
font-size: 25rpx;
color: #94a3b8;
flex-shrink: 0;
}
.value {
flex: 1;
text-align: right;
font-size: 27rpx;
color: #334155;
line-height: 1.5;
&.highlight {
color: #1f4b79;
font-weight: 600;
}
}
.card-actions {
display: flex;
gap: 16rpx;
margin-top: 20rpx;
padding-top: 20rpx;
border-top: 1rpx solid #f0f0f0;
}
.action-btn {
flex: 1;
height: 64rpx;
line-height: 64rpx;
text-align: center;
border-radius: 10rpx;
font-size: 26rpx;
font-weight: 500;
&.execute-btn {
background: #dbeafe;
color: #1d4ed8;
}
&.submit-btn {
background: #dbeafe;
color: #1d4ed8;
}
&.delete-btn {
background: #fee2e2;
color: #dc2626;
}
&.approve-btn {
background: #dcfce7;
color: #16a34a;
}
&.reject-btn {
background: #fee2e2;
color: #dc2626;
}
&:active {
opacity: 0.8;
}
}
.text-success {
color: #16a34a;
}
.text-danger {
color: #dc2626;
}
.text-warning {
color: #d97706;
}
.text-primary {
color: #2563eb;
}
.text-muted {
color: #64748b;
}
.record-tag.text-success {
color: #15803d;
background: #dcfce7;
}
.record-tag.text-danger {
color: #dc2626;
background: #fee2e2;
}
.record-tag.text-warning {
color: #d97706;
background: #fef3c7;
}
.record-tag.text-primary {
color: #1d4ed8;
background: #dbeafe;
}
.record-tag.text-muted {
color: #64748b;
background: #e2e8f0;
}
.hint {
padding: 36rpx 0;
text-align: center;
color: #94a3b8;
font-size: 26rpx;
}
.add-btn {
position: fixed;
right: 28rpx;
bottom: calc(56rpx + env(safe-area-inset-bottom));
width: 92rpx;
height: 92rpx;
border-radius: 46rpx;
background: #1f4b79;
box-shadow: 0 14rpx 30rpx rgba(24, 63, 108, 0.24);
display: flex;
align-items: center;
justify-content: center;
}
.add-icon {
color: #ffffff;
font-size: 64rpx;
line-height: 1;
margin-top: -4rpx;
}
.go-top-btn {
position: fixed;
right: 28rpx;
bottom: calc(140rpx + env(safe-area-inset-bottom));
width: 92rpx;
height: 92rpx;
border-radius: 46rpx;
background: rgba(255, 255, 255, 0.96);
box-shadow: 0 8rpx 24rpx rgba(15, 23, 42, 0.12);
display: flex;
align-items: center;
justify-content: center;
}
.modal-overlay {
position: fixed; top: 0; left: 0; right: 0; bottom: 0;
background: rgba(0, 0, 0, 0.45); z-index: 999;
display: flex; align-items: center; justify-content: center;
}
.modal-card {
width: 640rpx; background: #fff; border-radius: 20rpx;
box-shadow: 0 16rpx 48rpx rgba(0,0,0,0.15);
}
.modal-header {
display: flex; align-items: center; justify-content: space-between;
padding: 32rpx 32rpx 20rpx; border-bottom: 1rpx solid #f0f0f0;
}
.modal-title { font-size: 32rpx; font-weight: 700; color: #1a1a1a; }
.modal-close { font-size: 32rpx; color: #999; padding: 8rpx; }
.modal-body { padding: 28rpx 32rpx; }
.modal-field { margin-bottom: 28rpx;
&:last-child { margin-bottom: 0; }
}
.modal-label { font-size: 28rpx; color: #374151; font-weight: 500; margin-bottom: 14rpx; display: block; }
.modal-label .required { color: #ef4444; }
.modal-dropdown {
position: relative; display: flex; align-items: center; justify-content: space-between;
height: 80rpx; padding: 0 24rpx;
background: #f8fafc; border: 1rpx solid #e0e0e0; border-radius: 12rpx;
font-size: 28rpx; color: #374151;
.placeholder { color: #bbb; }
.dropdown-arrow { font-size: 20rpx; color: #999; }
}
.modal-textarea {
width: 100%; min-height: 140rpx; padding: 20rpx;
background: #f8fafc; border: 1rpx solid #e0e0e0;
border-radius: 12rpx; font-size: 27rpx; color: #374151;
box-sizing: border-box;
}
.textarea-placeholder { color: #bbb; }
.dropdown-panel {
position: absolute; top: 100%; left: 0; right: 0; z-index: 200; margin-top: 4rpx;
background: #fff; border: 1rpx solid #e0e0e0; border-radius: 12rpx;
box-shadow: 0 8rpx 30rpx rgba(0,0,0,0.1); overflow: hidden;
}
.dropdown-scroll { height: 300rpx; }
.dropdown-item { display: flex; align-items: center; justify-content: space-between; padding: 20rpx 24rpx; border-bottom: 1rpx solid #f0f0f0;
&:last-child { border-bottom: 0; }
&.active { background: #f0f5ff; }
}
.dropdown-item-text { font-size: 27rpx; color: #333; }
.dropdown-check { font-size: 28rpx; color: #2563eb; font-weight: 700; }
.modal-footer { display: flex; gap: 18rpx; padding: 24rpx 32rpx; border-top: 1rpx solid #f0f0f0; }
.modal-btn { flex: 1; height: 80rpx; line-height: 80rpx; text-align: center; border-radius: 14rpx; font-size: 30rpx; font-weight: 600;
&:active { opacity: 0.85; }
&.cancel-btn { background: #f0f0f0; color: #6b7280; }
&.confirm-btn { background: #1f4b79; color: #fff; }
}
</style>

@ -0,0 +1,269 @@
<template>
<view class="page-container">
<NavBar :title="'选择盘点项'" />
<view class="search-bar">
<input
v-model="keyword"
class="search-input"
placeholder="搜索编码/名称"
confirm-type="search"
@confirm="handleSearch"
/>
<text class="search-btn" @click="handleSearch"></text>
</view>
<view class="select-all-bar">
<view class="checkbox-wrap" @click="toggleSelectAll">
<text :class="['checkbox', isAllSelected ? 'checkbox-checked' : '']">{{ isAllSelected ? '✓' : '' }}</text>
<text class="select-all-text">全选</text>
</view>
<text class="select-count">已选 {{ selectedItems.length }} </text>
</view>
<scroll-view scroll-y class="list-scroll" @scrolltolower="loadMore">
<view v-for="item in list" :key="item.id || item.productId" class="item-row" @click="toggleSelect(item)">
<view class="checkbox-wrap">
<text :class="['checkbox', isSelected(item) ? 'checkbox-checked' : '']">{{ isSelected(item) ? '✓' : '' }}</text>
</view>
<view class="item-info">
<view class="info-row">
<text class="info-label">仓库</text>
<text class="info-val">{{ textValue(item.warehouseName) }}</text>
</view>
<view class="info-row">
<text class="info-label">库区</text>
<text class="info-val">{{ textValue(item.areaName) }}</text>
</view>
<view class="info-row">
<text class="info-label">编码</text>
<text class="info-val code">{{ textValue(item.productBarCode) }}</text>
</view>
<view class="info-row">
<text class="info-label">名称</text>
<text class="info-val name">{{ textValue(item.productName) }}</text>
</view>
<view class="info-row">
<text class="info-label">库存数量</text>
<text class="info-val stock">{{ textValue(item.stockCount) }}</text>
</view>
</view>
</view>
<view v-if="loading" class="loading-text">...</view>
<view v-if="!loading && !list.length" class="empty-text"></view>
<view v-if="!loading && list.length && noMore" class="no-more-text"></view>
</scroll-view>
<view class="bottom-actions">
<view class="bottom-btn cancel-btn" @click="handleCancel"></view>
<view class="bottom-btn confirm-btn" @click="handleConfirm"></view>
</view>
</view>
</template>
<script setup>
import { ref, computed } from 'vue'
import { onShow, onLoad } from '@dcloudio/uni-app'
import NavBar from '@/components/common/NavBar.vue'
import { generateCheckItemsByLocation } from '@/api/mes/materialCheck'
const routeWarehouseId = ref('')
const routeAreaIds = ref('')
let isFirstLoad = true
onLoad((options) => {
routeWarehouseId.value = options?.warehouseId || ''
routeAreaIds.value = options?.areaIds || ''
})
onShow(() => {
const prevSelected = getApp().globalData?._materialCheckItemSelected
if (prevSelected && Array.isArray(prevSelected)) {
selectedItems.value = prevSelected.map(item => ({
id: item.id || item.productId,
productId: item.productId || item.id,
warehouseId: item.warehouseId,
areaId: item.areaId,
warehouseName: item.warehouseName,
areaName: item.areaName,
productBarCode: item.productBarCode,
productName: item.productName,
stockCount: item.stockCount,
productPrice: item.productPrice
}))
getApp().globalData._materialCheckItemSelected = null
}
if (isFirstLoad) {
isFirstLoad = false
loadData(true)
}
})
const list = ref([])
const selectedItems = ref([])
const loading = ref(false)
const noMore = ref(false)
const pageNo = ref(1)
const pageSize = 20
const keyword = ref('')
const isAllSelected = computed(() => {
return list.value.length > 0 && list.value.every(item => isSelected(item))
})
function textValue(v) {
if (v === 0) return '0'
if (v == null) return '-'
return String(v).trim() || '-'
}
function getItemKey(item) {
return `${item.productId || item.id}_${item.warehouseId || ''}_${item.areaId || ''}`
}
function isSelected(item) {
const key = getItemKey(item)
return selectedItems.value.some(s => getItemKey(s) === key)
}
function toggleSelect(item) {
const key = getItemKey(item)
const idx = selectedItems.value.findIndex(s => getItemKey(s) === key)
if (idx >= 0) {
selectedItems.value.splice(idx, 1)
} else {
selectedItems.value.push({ ...item })
}
}
function toggleSelectAll() {
if (isAllSelected.value) {
selectedItems.value = []
} else {
selectedItems.value = [...list.value]
}
}
async function loadData(reset = false) {
if (loading.value) return
if (reset) {
pageNo.value = 1
list.value = []
noMore.value = false
}
loading.value = true
try {
const res = await generateCheckItemsByLocation({
warehouseIds: routeWarehouseId.value ? [Number(routeWarehouseId.value)] : undefined,
areaIds: routeAreaIds.value ? routeAreaIds.value.split(',').map(id => Number(id.trim())).filter(Boolean) : undefined,
categoryType: 2,
allowEmpty: true
})
const data = Array.isArray(res) ? res : (Array.isArray(res?.data) ? res.data : [])
const filtered = keyword.value
? data.filter(item =>
(item.productBarCode || '').includes(keyword.value) ||
(item.productName || '').includes(keyword.value)
)
: data
list.value = reset ? filtered : [...list.value, ...filtered]
noMore.value = true
} catch (e) {
console.error('loadData error', e)
uni.showToast({ title: '加载失败', icon: 'none' })
} finally {
loading.value = false
}
}
function loadMore() {
if (!noMore.value && !loading.value) {
pageNo.value++
loadData()
}
}
function handleSearch() {
loadData(true)
}
function handleCancel() {
uni.navigateBack()
}
function handleConfirm() {
if (!selectedItems.value.length) {
uni.showToast({ title: '请至少选择一项', icon: 'none' })
return
}
getApp().globalData._materialCheckItemSelectResult = [...selectedItems.value]
uni.navigateBack()
}
</script>
<style lang="scss" scoped>
.page-container {
min-height: 100vh;
background: #f5f6f8;
padding-bottom: calc(120rpx + env(safe-area-inset-bottom));
}
.search-bar {
display: flex; gap: 16rpx; padding: 20rpx 24rpx; background: #fff;
}
.search-input {
flex: 1; height: 72rpx; padding: 0 24rpx;
background: #f3f4f6; border-radius: 12rpx; font-size: 28rpx;
}
.search-btn {
display: flex; align-items: center; justify-content: center;
width: 120rpx; height: 72rpx; background: #1f4b79;
color: #fff; border-radius: 12rpx; font-size: 28rpx;
}
.select-all-bar {
display: flex; align-items: center; justify-content: space-between;
padding: 20rpx 24rpx; background: #fff; border-bottom: 1rpx solid #f0f0f0;
}
.checkbox-wrap {
display: flex; align-items: center; gap: 12rpx;
}
.checkbox {
width: 40rpx; height: 40rpx; border: 2rpx solid #d1d5db; border-radius: 8rpx;
display: flex; align-items: center; justify-content: center;
font-size: 24rpx; color: #fff; background: #fff;
&.checkbox-checked { background: #1f4b79; border-color: #1f4b79; }
}
.select-all-text { font-size: 28rpx; color: #374151; }
.select-count { font-size: 26rpx; color: #1f4b79; font-weight: 600; }
.list-scroll { height: calc(100vh - 200rpx - env(safe-area-inset-bottom)); }
.item-row {
display: flex; align-items: flex-start; gap: 16rpx;
padding: 20rpx 24rpx; background: #fff; border-bottom: 1rpx solid #f0f0f0;
&:active { background: #f9fafb; }
}
.item-info { flex: 1; display: flex; flex-direction: column; gap: 8rpx; }
.info-row { display: flex; align-items: center; gap: 16rpx; }
.info-label { width: 120rpx; font-size: 24rpx; color: #9ca3af; flex-shrink: 0; }
.info-val {
flex: 1; font-size: 26rpx; color: #374151;
&.code { font-family: monospace; color: #6b7280; }
&.name { font-weight: 500; color: #1a1a1a; }
&.stock { font-weight: 600; color: #1f4b79; }
}
.loading-text, .empty-text, .no-more-text { padding: 40rpx; text-align: center; color: #9ca3af; font-size: 26rpx; }
.bottom-actions {
position: fixed; left: 0; right: 0; bottom: 0; display: flex; gap: 18rpx;
padding: 18rpx 24rpx calc(18rpx + env(safe-area-inset-bottom));
background: #fff; box-shadow: 0 -8rpx 24rpx rgba(15,23,42,0.06); z-index: 99;
}
.bottom-btn { flex: 1; height: 84rpx; line-height: 84rpx; text-align: center; border-radius: 16rpx; font-size: 30rpx; font-weight: 600;
&:active { opacity: 0.85; }
}
.cancel-btn { background: #eef2f7; color: #475569; }
.confirm-btn { background: #1f4b79; color: #fff; }
</style>

@ -0,0 +1,225 @@
<template>
<view class="page-container">
<NavBar :title="'选择盘点项'" />
<view class="search-bar">
<input
v-model="keyword"
class="search-input"
placeholder="搜索编码/名称"
confirm-type="search"
@confirm="handleSearch"
/>
<text class="search-btn" @click="handleSearch"></text>
</view>
<view class="select-all-bar">
<view class="checkbox-wrap" @click="toggleSelectAll">
<text :class="['checkbox', isAllSelected ? 'checkbox-checked' : '']">{{ isAllSelected ? '✓' : '' }}</text>
<text class="select-all-text">全选</text>
</view>
<text class="select-count">已选 {{ selectedItems.length }} </text>
</view>
<scroll-view scroll-y class="list-scroll">
<view v-for="item in filteredList" :key="item.productId + '_' + (item.warehouseId || '')" class="item-row" @click="toggleSelect(item)">
<view class="checkbox-wrap">
<text :class="['checkbox', isSelected(item) ? 'checkbox-checked' : '']">{{ isSelected(item) ? '✓' : '' }}</text>
</view>
<view class="item-info">
<view class="info-row">
<text class="info-label">仓库</text>
<text class="info-val">{{ textValue(item.warehouseName) }}</text>
</view>
<view class="info-row">
<text class="info-label">库区</text>
<text class="info-val">{{ textValue(item.areaName) }}</text>
</view>
<view class="info-row">
<text class="info-label">编码</text>
<text class="info-val code">{{ textValue(item.productBarCode) }}</text>
</view>
<view class="info-row">
<text class="info-label">名称</text>
<text class="info-val name">{{ textValue(item.productName) }}</text>
</view>
<view class="info-row">
<text class="info-label">库存数量</text>
<text class="info-val stock">{{ textValue(item.stockCount) }}</text>
</view>
</view>
</view>
<view v-if="loading" class="loading-text">...</view>
<view v-if="!loading && !list.length" class="empty-text"></view>
</scroll-view>
<view class="bottom-actions">
<view class="bottom-btn cancel-btn" @click="handleCancel"></view>
<view class="bottom-btn confirm-btn" @click="handleConfirm"></view>
</view>
</view>
</template>
<script setup>
import { ref, computed } from 'vue'
import { onShow, onLoad } from '@dcloudio/uni-app'
import NavBar from '@/components/common/NavBar.vue'
import { generateCheckItemsByProduct } from '@/api/mes/materialCheck'
const routeProductId = ref('')
const list = ref([])
const selectedItems = ref([])
const loading = ref(false)
const keyword = ref('')
let isFirstLoad = true
const filteredList = computed(() => {
if (!keyword.value) return list.value
return list.value.filter(item =>
(item.productBarCode || '').includes(keyword.value) ||
(item.productName || '').includes(keyword.value) ||
(item.warehouseName || '').includes(keyword.value)
)
})
const isAllSelected = computed(() => {
return filteredList.value.length > 0 && filteredList.value.every(item => isSelected(item))
})
function textValue(v) {
if (v === 0) return '0'
if (v == null) return '-'
return String(v).trim() || '-'
}
function getItemKey(item) {
return `${item.productId || item.id}_${item.warehouseId || ''}_${item.areaId || ''}`
}
function isSelected(item) {
const key = getItemKey(item)
return selectedItems.value.some(s => getItemKey(s) === key)
}
function toggleSelect(item) {
const key = getItemKey(item)
const idx = selectedItems.value.findIndex(s => getItemKey(s) === key)
if (idx >= 0) {
selectedItems.value.splice(idx, 1)
} else {
selectedItems.value.push({ ...item })
}
}
function toggleSelectAll() {
if (isAllSelected.value) {
selectedItems.value = []
} else {
selectedItems.value = [...filteredList.value]
}
}
async function loadData() {
loading.value = true
try {
const ids = routeProductId.value.split(',').map(id => Number(id.trim())).filter(Boolean)
const res = await generateCheckItemsByProduct({
productIds: ids,
categoryType: 2,
allowEmpty: true
})
const data = Array.isArray(res) ? res : (Array.isArray(res?.data) ? res.data : [])
list.value = data
} catch (e) {
console.error('loadData error', e)
uni.showToast({ title: '加载失败', icon: 'none' })
} finally {
loading.value = false
}
}
function handleSearch() {}
function handleCancel() {
uni.navigateBack()
}
function handleConfirm() {
if (!selectedItems.value.length) {
uni.showToast({ title: '请至少选择一项', icon: 'none' })
return
}
getApp().globalData._materialCheckItemSelectResult = [...selectedItems.value]
uni.navigateBack()
}
onLoad((options) => {
routeProductId.value = options?.productIds || options?.productId || ''
})
onShow(() => {
const prevSelected = getApp().globalData?._materialCheckItemSelected
if (prevSelected && Array.isArray(prevSelected)) {
selectedItems.value = prevSelected.map(item => ({
id: item.id || item.productId,
productId: item.productId || item.id,
warehouseId: item.warehouseId,
areaId: item.areaId,
warehouseName: item.warehouseName,
areaName: item.areaName,
productBarCode: item.productBarCode,
productName: item.productName,
stockCount: item.stockCount,
productPrice: item.productPrice
}))
getApp().globalData._materialCheckItemSelected = null
}
if (isFirstLoad) {
isFirstLoad = false
loadData()
}
})
</script>
<style lang="scss" scoped>
.page-container {
min-height: 100vh;
background: #f5f6f8;
padding-bottom: calc(120rpx + env(safe-area-inset-bottom));
}
.search-bar { display: flex; gap: 16rpx; padding: 20rpx 24rpx; background: #fff; }
.search-input { flex: 1; height: 72rpx; padding: 0 24rpx; background: #f3f4f6; border-radius: 12rpx; font-size: 28rpx; }
.search-btn { display: flex; align-items: center; justify-content: center; width: 120rpx; height: 72rpx; background: #1f4b79; color: #fff; border-radius: 12rpx; font-size: 28rpx; }
.select-all-bar { display: flex; align-items: center; justify-content: space-between; padding: 20rpx 24rpx; background: #fff; border-bottom: 1rpx solid #f0f0f0; }
.checkbox-wrap { display: flex; align-items: center; gap: 12rpx; }
.checkbox { width: 40rpx; height: 40rpx; border: 2rpx solid #d1d5db; border-radius: 8rpx; display: flex; align-items: center; justify-content: center; font-size: 24rpx; color: #fff; background: #fff;
&.checkbox-checked { background: #1f4b79; border-color: #1f4b79; }
}
.select-all-text { font-size: 28rpx; color: #374151; }
.select-count { font-size: 26rpx; color: #1f4b79; font-weight: 600; }
.list-scroll { height: calc(100vh - 330rpx - env(safe-area-inset-bottom)); }
.item-row { display: flex; align-items: flex-start; gap: 16rpx; padding: 20rpx 24rpx; background: #fff; border-bottom: 1rpx solid #f0f0f0;
&:active { background: #f9fafb; }
}
.item-info { flex: 1; display: flex; flex-direction: column; gap: 8rpx; }
.info-row { display: flex; align-items: center; gap: 16rpx; }
.info-label { width: 120rpx; font-size: 24rpx; color: #9ca3af; flex-shrink: 0; }
.info-val { flex: 1; font-size: 26rpx; color: #374151;
&.code { font-family: monospace; color: #6b7280; }
&.name { font-weight: 500; color: #1a1a1a; }
&.stock { font-weight: 600; color: #1f4b79; }
}
.loading-text, .empty-text { padding: 40rpx; text-align: center; color: #9ca3af; font-size: 26rpx; }
.bottom-actions { position: fixed; left: 0; right: 0; bottom: 0; display: flex; gap: 18rpx; padding: 18rpx 24rpx calc(18rpx + env(safe-area-inset-bottom)); background: #fff; box-shadow: 0 -8rpx 24rpx rgba(15,23,42,0.06); z-index: 99; }
.bottom-btn { flex: 1; height: 84rpx; line-height: 84rpx; text-align: center; border-radius: 16rpx; font-size: 30rpx; font-weight: 600;
&:active { opacity: 0.85; }
}
.cancel-btn { background: #eef2f7; color: #475569; }
.confirm-btn { background: #1f4b79; color: #fff; }
</style>

@ -0,0 +1,228 @@
<template>
<view class="page-container">
<NavBar :title="'选择产品'" />
<view class="search-bar">
<input
v-model="keyword"
class="search-input"
placeholder="搜索编码/名称"
confirm-type="search"
@confirm="handleSearch"
/>
<text class="search-btn" @click="handleSearch"></text>
</view>
<view class="select-all-bar">
<view class="checkbox-wrap" @click="toggleSelectAll">
<text :class="['checkbox', isAllSelected ? 'checkbox-checked' : '']">{{ isAllSelected ? '✓' : '' }}</text>
<text class="select-all-text">全选</text>
</view>
<text class="select-count">已选 {{ selectedItems.length }} </text>
</view>
<scroll-view scroll-y class="list-scroll" @scrolltolower="loadMore">
<view v-for="item in list" :key="item.id" class="item-row" @click="toggleSelect(item)">
<view class="checkbox-wrap">
<text :class="['checkbox', isSelected(item) ? 'checkbox-checked' : '']">{{ isSelected(item) ? '✓' : '' }}</text>
</view>
<view class="item-info">
<view class="info-row">
<text class="info-label">编码</text>
<text class="info-val code">{{ textValue(item.barCode || item.productBarCode) }}</text>
</view>
<view class="info-row">
<text class="info-label">名称</text>
<text class="info-val name">{{ textValue(item.name || item.productName) }}</text>
</view>
<view class="info-row">
<text class="info-label">单位</text>
<text class="info-val">{{ textValue(item.unitName || item.productUnitName) }}</text>
</view>
<view class="info-row">
<text class="info-label">规格型号</text>
<text class="info-val">{{ textValue(item.standard || item.productStandard) }}</text>
</view>
</view>
</view>
<view v-if="loading" class="loading-text">...</view>
<view v-if="!loading && !list.length" class="empty-text"></view>
<view v-if="!loading && list.length && noMore" class="no-more-text"></view>
</scroll-view>
<view class="bottom-actions">
<view class="bottom-btn cancel-btn" @click="handleCancel"></view>
<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 list = ref([])
const selectedItems = ref([])
const loading = ref(false)
const noMore = ref(false)
const pageNo = ref(1)
const pageSize = 20
const keyword = ref('')
const isAllSelected = computed(() => {
return list.value.length > 0 && list.value.every(item => isSelected(item))
})
function textValue(v) {
if (v === 0) return '0'
if (v == null) return '-'
return String(v).trim() || '-'
}
function isSelected(item) {
return selectedItems.value.some(s => String(s.id) === String(item.id))
}
function toggleSelect(item) {
const idx = selectedItems.value.findIndex(s => String(s.id) === String(item.id))
if (idx >= 0) {
selectedItems.value.splice(idx, 1)
} else {
selectedItems.value.push({
id: item.id,
name: item.name || item.productName,
barCode: item.barCode || item.productBarCode,
unitName: item.unitName || item.productUnitName,
standard: item.standard || item.productStandard
})
}
}
function toggleSelectAll() {
if (isAllSelected.value) {
selectedItems.value = []
} else {
selectedItems.value = list.value.map(item => ({
id: item.id,
name: item.name || item.productName,
barCode: item.barCode || item.productBarCode,
unitName: item.unitName || item.productUnitName,
standard: item.standard || item.productStandard
}))
}
}
async function loadData(reset = false) {
if (loading.value) return
if (reset) {
pageNo.value = 1
list.value = []
noMore.value = false
}
loading.value = true
try {
const res = await getMaterialSimpleList(pageNo.value)
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 (keyword.value) {
pageList = pageList.filter(item =>
(item.barCode || item.productBarCode || '').includes(keyword.value) ||
(item.name || item.productName || '').includes(keyword.value)
)
}
if (reset) {
list.value = pageList
} else {
list.value.push(...pageList)
}
if (pageList.length < pageSize) {
noMore.value = true
}
} catch (e) {
console.error('loadData error', e)
uni.showToast({ title: '加载失败', icon: 'none' })
} finally {
loading.value = false
}
}
function loadMore() {
if (!noMore.value && !loading.value) {
pageNo.value++
loadData()
}
}
function handleSearch() {
loadData(true)
}
function handleCancel() {
uni.navigateBack()
}
function handleConfirm() {
if (!selectedItems.value.length) {
uni.showToast({ title: '请至少选择一项', icon: 'none' })
return
}
getApp().globalData._materialCheckProductSelectResult = [...selectedItems.value]
uni.navigateBack()
}
onShow(() => {
const prevSelected = getApp().globalData?._materialCheckProductSelected
if (prevSelected && Array.isArray(prevSelected)) {
selectedItems.value = prevSelected
getApp().globalData._materialCheckProductSelected = null
}
loadData(true)
})
</script>
<style lang="scss" scoped>
.page-container { min-height: 100vh; background: #f5f6f8; padding-bottom: calc(120rpx + env(safe-area-inset-bottom)); }
.search-bar { display: flex; gap: 16rpx; padding: 20rpx 24rpx; background: #fff; }
.search-input { flex: 1; height: 72rpx; padding: 0 24rpx; background: #f3f4f6; border-radius: 12rpx; font-size: 28rpx; }
.search-btn { display: flex; align-items: center; justify-content: center; width: 120rpx; height: 72rpx; background: #1f4b79; color: #fff; border-radius: 12rpx; font-size: 28rpx; }
.select-all-bar { display: flex; align-items: center; justify-content: space-between; padding: 20rpx 24rpx; background: #fff; border-bottom: 1rpx solid #f0f0f0; }
.checkbox-wrap { display: flex; align-items: center; gap: 12rpx; }
.checkbox { width: 40rpx; height: 40rpx; border: 2rpx solid #d1d5db; border-radius: 8rpx; display: flex; align-items: center; justify-content: center; font-size: 24rpx; color: #fff; background: #fff;
&.checkbox-checked { background: #1f4b79; border-color: #1f4b79; }
}
.select-all-text { font-size: 28rpx; color: #374151; }
.select-count { font-size: 26rpx; color: #1f4b79; font-weight: 600; }
.list-scroll { height: calc(100vh - 330rpx - env(safe-area-inset-bottom)); }
.item-row { display: flex; align-items: flex-start; gap: 16rpx; padding: 20rpx 24rpx; background: #fff; border-bottom: 1rpx solid #f0f0f0;
&:active { background: #f9fafb; }
}
.item-info { flex: 1; display: flex; flex-direction: column; gap: 8rpx; }
.info-row { display: flex; align-items: center; gap: 16rpx; }
.info-label { width: 120rpx; font-size: 24rpx; color: #9ca3af; flex-shrink: 0; }
.info-val { flex: 1; font-size: 26rpx; color: #374151;
&.code { font-family: monospace; color: #6b7280; }
&.name { font-weight: 500; color: #1a1a1a; }
}
.loading-text, .empty-text, .no-more-text { padding: 40rpx; text-align: center; color: #9ca3af; font-size: 26rpx; }
.bottom-actions { position: fixed; left: 0; right: 0; bottom: 0; display: flex; gap: 18rpx; padding: 18rpx 24rpx calc(18rpx + env(safe-area-inset-bottom)); background: #fff; box-shadow: 0 -8rpx 24rpx rgba(15,23,42,0.06); z-index: 99; }
.bottom-btn { flex: 1; height: 84rpx; line-height: 84rpx; text-align: center; border-radius: 16rpx; font-size: 30rpx; font-weight: 600;
&:active { opacity: 0.85; }
}
.cancel-btn { background: #eef2f7; color: #475569; }
.confirm-btn { background: #1f4b79; color: #fff; }
</style>

@ -0,0 +1,190 @@
<template>
<view class="page-container">
<NavBar :title="'选择库区'" />
<view class="search-bar">
<input
v-model="keyword"
class="search-input"
placeholder="搜索库区编码/名称"
confirm-type="search"
@confirm="handleSearch"
/>
<text class="search-btn" @click="handleSearch"></text>
</view>
<view class="select-all-bar">
<view class="checkbox-wrap" @click="toggleSelectAll">
<text :class="['checkbox', isAllSelected ? 'checkbox-checked' : '']">{{ isAllSelected ? '✓' : '' }}</text>
<text class="select-all-text">全选</text>
</view>
<text class="select-count">已选 {{ selectedItems.length }} </text>
</view>
<scroll-view scroll-y class="list-scroll">
<view v-for="item in filteredList" :key="item.id" class="item-row" @click="toggleSelect(item)">
<view class="checkbox-wrap">
<text :class="['checkbox', isSelected(item) ? 'checkbox-checked' : '']">{{ isSelected(item) ? '✓' : '' }}</text>
</view>
<view class="item-info">
<view class="info-row">
<text class="info-label">库区编码</text>
<text class="info-val code">{{ textValue(item.areaCode) }}</text>
</view>
<view class="info-row">
<text class="info-label">库区名称</text>
<text class="info-val name">{{ textValue(item.areaName) }}</text>
</view>
</view>
</view>
<view v-if="loading" class="loading-text">...</view>
<view v-if="!loading && !list.length" class="empty-text"></view>
</scroll-view>
<view class="bottom-actions">
<view class="bottom-btn cancel-btn" @click="handleCancel"></view>
<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 { getWarehouseAreaSimpleList } from '@/api/mes/moldget'
const list = ref([])
const selectedItems = ref([])
const loading = ref(false)
const keyword = ref('')
const warehouseId = ref('')
const filteredList = computed(() => {
if (!keyword.value) return list.value
return list.value.filter(item =>
(item.areaCode || '').includes(keyword.value) ||
(item.areaName || '').includes(keyword.value)
)
})
const isAllSelected = computed(() => {
return filteredList.value.length > 0 && filteredList.value.every(item => isSelected(item))
})
function textValue(v) {
if (v === 0) return '0'
if (v == null) return '-'
return String(v).trim() || '-'
}
function isSelected(item) {
return selectedItems.value.some(s => String(s.id) === String(item.id))
}
function toggleSelect(item) {
const idx = selectedItems.value.findIndex(s => String(s.id) === String(item.id))
if (idx >= 0) {
selectedItems.value.splice(idx, 1)
} else {
selectedItems.value.push({
id: item.id,
code: item.areaCode || '',
name: item.areaName || ''
})
}
}
function toggleSelectAll() {
if (isAllSelected.value) {
selectedItems.value = []
} else {
selectedItems.value = filteredList.value.map(item => ({
id: item.id,
code: item.areaCode || '',
name: item.areaName || ''
}))
}
}
async function loadData() {
loading.value = true
try {
const res = await getWarehouseAreaSimpleList(warehouseId.value)
const data = Array.isArray(res) ? res : (Array.isArray(res?.data) ? res.data : [])
list.value = data
} catch (e) {
console.error('loadAreaData error', e)
uni.showToast({ title: '加载失败', icon: 'none' })
} finally {
loading.value = false
}
}
function handleSearch() {}
function handleCancel() {
uni.navigateBack()
}
function handleConfirm() {
if (!selectedItems.value.length) {
uni.showToast({ title: '请至少选择一项', icon: 'none' })
return
}
getApp().globalData._checkAreaSelectResult = [...selectedItems.value]
uni.navigateBack()
}
onShow(() => {
const prevSelected = getApp().globalData?._checkAreaSelected
if (prevSelected && Array.isArray(prevSelected)) {
selectedItems.value = prevSelected.map(a => ({
id: a.value,
code: a.code || '',
name: a.label || ''
}))
getApp().globalData._checkAreaSelected = null
}
warehouseId.value = getApp().globalData?._checkAreaWarehouseId || ''
loadData()
})
</script>
<style lang="scss" scoped>
.page-container { min-height: 100vh; background: #f5f6f8; padding-bottom: calc(120rpx + env(safe-area-inset-bottom)); }
.search-bar { display: flex; gap: 16rpx; padding: 20rpx 24rpx; background: #fff; }
.search-input { flex: 1; height: 72rpx; padding: 0 24rpx; background: #f3f4f6; border-radius: 12rpx; font-size: 28rpx; }
.search-btn { display: flex; align-items: center; justify-content: center; width: 120rpx; height: 72rpx; background: #1f4b79; color: #fff; border-radius: 12rpx; font-size: 28rpx; }
.select-all-bar { display: flex; align-items: center; justify-content: space-between; padding: 20rpx 24rpx; background: #fff; border-bottom: 1rpx solid #f0f0f0; }
.checkbox-wrap { display: flex; align-items: center; gap: 12rpx; }
.checkbox { width: 40rpx; height: 40rpx; border: 2rpx solid #d1d5db; border-radius: 8rpx; display: flex; align-items: center; justify-content: center; font-size: 24rpx; color: #fff; background: #fff;
&.checkbox-checked { background: #1f4b79; border-color: #1f4b79; }
}
.select-all-text { font-size: 28rpx; color: #374151; }
.select-count { font-size: 26rpx; color: #1f4b79; font-weight: 600; }
.list-scroll { height: calc(100vh - 330rpx - env(safe-area-inset-bottom)); }
.item-row { display: flex; align-items: flex-start; gap: 16rpx; padding: 20rpx 24rpx; background: #fff; border-bottom: 1rpx solid #f0f0f0;
&:active { background: #f9fafb; }
}
.item-info { flex: 1; display: flex; flex-direction: column; gap: 8rpx; }
.info-row { display: flex; align-items: center; gap: 16rpx; }
.info-label { width: 120rpx; font-size: 24rpx; color: #9ca3af; flex-shrink: 0; }
.info-val { flex: 1; font-size: 26rpx; color: #374151;
&.code { font-family: monospace; color: #6b7280; }
&.name { font-weight: 500; color: #1a1a1a; }
}
.loading-text, .empty-text { padding: 40rpx; text-align: center; color: #9ca3af; font-size: 26rpx; }
.bottom-actions { position: fixed; left: 0; right: 0; bottom: 0; display: flex; gap: 18rpx; padding: 18rpx 24rpx calc(18rpx + env(safe-area-inset-bottom)); background: #fff; box-shadow: 0 -8rpx 24rpx rgba(15,23,42,0.06); z-index: 99; }
.bottom-btn { flex: 1; height: 84rpx; line-height: 84rpx; text-align: center; border-radius: 16rpx; font-size: 30rpx; font-weight: 600;
&:active { opacity: 0.85; }
}
.cancel-btn { background: #eef2f7; color: #475569; }
.confirm-btn { background: #1f4b79; color: #fff; }
</style>

@ -51,24 +51,17 @@
<!-- 库区 -->
<view class="warehouse-area-row">
<text class="warehouse-area-label">库区</text>
<view class="warehouse-area-dropdown" @click="toggleAreaDropdown">
<view class="dropdown-input">
<text :class="['dropdown-value', { placeholder: !selectedArea }]">{{ selectedArea ? selectedArea.label : (loadingAreas ? '加载中...' : '请选择') }}</text>
<text class="dropdown-arrow"></text>
</view>
<view v-if="showAreaDropdown" class="dropdown-panel">
<view class="dropdown-scroll">
<view v-for="a in areaOptions" :key="a.value" class="dropdown-item" :class="{ active: selectedArea?.value === a.value }" @click.stop="handleSelectArea(a)">
<text class="dropdown-item-text">{{ a.label }}</text>
<text v-if="selectedArea?.value === a.value" class="dropdown-check"></text>
</view>
<view v-if="!areaOptions.length" class="dropdown-empty"></view>
</view>
<view class="warehouse-area-dropdown">
<view class="dropdown-input" @click="goSelectArea">
<text :class="['dropdown-value', { placeholder: !selectedAreas.length }]">
{{ selectedAreas.length ? selectedAreas.map(a => a.label).join('、') : '请选择' }}
</text>
<text class="dropdown-arrow"></text>
</view>
</view>
</view>
<!-- 盘点项 -->
<view class="warehouse-area-row" v-if="selectedArea">
<view class="warehouse-area-row" v-if="selectedAreas.length">
<text class="warehouse-area-label">盘点项</text>
<view class="item-select-btn" @click="goSelectItems">
<text class="item-select-text">{{ items.length ? `已选${items.length}` : '点击选择' }}</text>
@ -165,10 +158,10 @@
<script setup>
import { ref } from 'vue'
import { onShow, onHide } from '@dcloudio/uni-app'
import { onShow } from '@dcloudio/uni-app'
import NavBar from '@/components/common/NavBar.vue'
import UniDatetimePicker from '@dcloudio/uni-ui/lib/uni-datetime-picker/uni-datetime-picker.vue'
import { getWarehousePage, getWarehouseAreaSimpleList } from '@/api/mes/moldget'
import { getWarehousePage } from '@/api/mes/moldget'
import { createCheck } from '@/api/mes/sparepartCheck'
//
@ -184,18 +177,15 @@ function switchSourceType(type) {
sourceType.value = type
items.value = []
selectedProducts.value = []
selectedArea.value = null
selectedAreas.value = []
}
//
const warehouseOptions = ref([])
const selectedWarehouse = ref(null)
//
const areaOptions = ref([])
const selectedArea = ref(null)
const showAreaDropdown = ref(false)
const loadingAreas = ref(false)
//
const selectedAreas = ref([])
//
const selectedProducts = ref([])
@ -216,47 +206,37 @@ async function loadWarehouses() {
try {
const res = await getWarehousePage({ pageNo: 1, pageSize: 100, categoryType: 3 })
const data = Array.isArray(res) ? res : (Array.isArray(res?.data) ? res.data : (Array.isArray(res?.data?.list) ? res.data.list : []))
console.log('[loadWarehouses] categoryType=3, data:', data)
warehouseOptions.value = data.map(w => ({ value: w.id, label: w.name || String(w.id) }))
//
if (warehouseOptions.value.length && !selectedWarehouse.value) {
selectedWarehouse.value = warehouseOptions.value[0]
loadAreas(selectedWarehouse.value.value)
}
} catch (e) {
console.error('loadWarehouses error', e)
}
}
async function loadAreas(warehouseId) {
if (!warehouseId) return
loadingAreas.value = true
areaOptions.value = []
try {
const res = await getWarehouseAreaSimpleList(warehouseId)
const data = Array.isArray(res) ? res : (Array.isArray(res?.data) ? res.data : [])
console.log('[loadAreas] warehouseId:', warehouseId, 'data:', data)
areaOptions.value = data.map(a => ({ value: a.id, label: a.name || a.areaName || String(a.id || '') }))
} catch (e) {
console.error('loadAreas error', e)
} finally {
loadingAreas.value = false
}
}
//
function toggleAreaDropdown() { showAreaDropdown.value = !showAreaDropdown.value }
function handleSelectArea(a) {
selectedArea.value = a
showAreaDropdown.value = false
items.value = []
//
function goSelectArea() {
getApp().globalData._checkAreaSelectResult = null
getApp().globalData._checkAreaWarehouseId = selectedWarehouse.value?.value || ''
getApp().globalData._checkAreaSelected = selectedAreas.value.length
? JSON.parse(JSON.stringify(selectedAreas.value))
: null
uni.navigateTo({
url: `/pages_function/pages/sparepartCheck/areaSelect`
})
}
//
function goSelectItems() {
if (!selectedAreas.value.length) return
getApp().globalData._checkItemSelectResult = null
getApp().globalData._checkItemSelected = items.value.length
? JSON.parse(JSON.stringify(items.value))
: null
const areaIds = selectedAreas.value.map(a => a.value).join(',')
uni.navigateTo({
url: `/pages_function/pages/sparepartCheck/itemSelect?warehouseId=${selectedWarehouse.value.value}&areaId=${selectedArea.value.value}`
url: `/pages_function/pages/sparepartCheck/itemSelect?warehouseId=${selectedWarehouse.value.value}&areaIds=${areaIds}`
})
}
@ -276,6 +256,9 @@ function goSelectProduct() {
function goSelectItemsByProduct() {
if (!selectedProducts.value.length) return
getApp().globalData._checkItemSelectResult = null
getApp().globalData._checkItemSelected = items.value.length
? JSON.parse(JSON.stringify(items.value))
: null
const ids = selectedProducts.value.map(p => p.id).join(',')
uni.navigateTo({
url: `/pages_function/pages/sparepartCheck/itemSelectByProduct?productIds=${ids}`
@ -326,32 +309,37 @@ function handleCancel() { uni.navigateBack() }
onShow(() => {
loadWarehouses()
//
//
const productResult = getApp().globalData?._checkProductSelectResult
if (productResult && Array.isArray(productResult)) {
selectedProducts.value = productResult.map(p => ({
id: p.id,
name: p.name || '备件'
}))
items.value = [] //
items.value = []
getApp().globalData._checkProductSelectResult = null
}
//
//
const areaResult = getApp().globalData?._checkAreaSelectResult
if (areaResult && Array.isArray(areaResult)) {
selectedAreas.value = areaResult.map(a => ({
value: a.id,
label: a.name || '库区'
}))
items.value = []
getApp().globalData._checkAreaSelectResult = null
}
//
const itemResult = getApp().globalData?._checkItemSelectResult
if (itemResult && Array.isArray(itemResult)) {
//
const existingIds = new Set(items.value.map(i => String(i.productId || i.id)))
const newItems = itemResult.filter(i => !existingIds.has(String(i.productId || i.id)))
const existingKeys = new Set(items.value.map(i => `${i.productId || i.id}_${i.warehouseId || ''}_${i.areaId || ''}`))
const newItems = itemResult.filter(i => !existingKeys.has(`${i.productId || i.id}_${i.warehouseId || ''}_${i.areaId || ''}`))
if (newItems.length) {
items.value = [...items.value, ...newItems]
}
getApp().globalData._checkItemSelectResult = null
}
})
onHide(() => {
showAreaDropdown.value = false
})
</script>
<style lang="scss" scoped>

@ -68,17 +68,40 @@
<script setup>
import { ref, computed } from 'vue'
import { onLoad } from '@dcloudio/uni-app'
import { onShow, onLoad } from '@dcloudio/uni-app'
import NavBar from '@/components/common/NavBar.vue'
import { generateCheckItemsByLocation } from '@/api/mes/sparepartCheck'
const routeWarehouseId = ref('')
const routeAreaId = ref('')
const routeAreaIds = ref('')
let isFirstLoad = true
onLoad((options) => {
routeWarehouseId.value = options?.warehouseId || ''
routeAreaId.value = options?.areaId || ''
loadData(true)
routeAreaIds.value = options?.areaIds || ''
})
onShow(() => {
const prevSelected = getApp().globalData?._checkItemSelected
if (prevSelected && Array.isArray(prevSelected)) {
selectedItems.value = prevSelected.map(item => ({
id: item.id || item.productId,
productId: item.productId || item.id,
warehouseId: item.warehouseId,
areaId: item.areaId,
warehouseName: item.warehouseName,
areaName: item.areaName,
productBarCode: item.productBarCode,
productName: item.productName,
stockCount: item.stockCount,
productPrice: item.productPrice
}))
getApp().globalData._checkItemSelected = null
}
if (isFirstLoad) {
isFirstLoad = false
loadData(true)
}
})
const list = ref([])
@ -99,12 +122,18 @@ function textValue(v) {
return String(v).trim() || '-'
}
function getItemKey(item) {
return `${item.productId || item.id}_${item.warehouseId || ''}_${item.areaId || ''}`
}
function isSelected(item) {
return selectedItems.value.some(s => String(s.productId || s.id) === String(item.productId || item.id))
const key = getItemKey(item)
return selectedItems.value.some(s => getItemKey(s) === key)
}
function toggleSelect(item) {
const idx = selectedItems.value.findIndex(s => String(s.productId || s.id) === String(item.productId || item.id))
const key = getItemKey(item)
const idx = selectedItems.value.findIndex(s => getItemKey(s) === key)
if (idx >= 0) {
selectedItems.value.splice(idx, 1)
} else {
@ -131,7 +160,7 @@ async function loadData(reset = false) {
try {
const res = await generateCheckItemsByLocation({
warehouseIds: routeWarehouseId.value ? [Number(routeWarehouseId.value)] : undefined,
areaIds: routeAreaId.value ? [Number(routeAreaId.value)] : undefined,
areaIds: routeAreaIds.value ? routeAreaIds.value.split(',').map(id => Number(id.trim())).filter(Boolean) : undefined,
categoryType: 3,
allowEmpty: true
})
@ -177,11 +206,6 @@ function handleConfirm() {
uni.navigateBack()
}
onLoad((options) => {
routeWarehouseId.value = options?.warehouseId || ''
routeAreaId.value = options?.areaId || ''
loadData(true)
})
</script>
<style lang="scss" scoped>

@ -67,7 +67,7 @@
<script setup>
import { ref, computed } from 'vue'
import { onLoad } from '@dcloudio/uni-app'
import { onShow, onLoad } from '@dcloudio/uni-app'
import NavBar from '@/components/common/NavBar.vue'
import { generateCheckItemsByProduct } from '@/api/mes/sparepartCheck'
@ -76,6 +76,7 @@ const list = ref([])
const selectedItems = ref([])
const loading = ref(false)
const keyword = ref('')
let isFirstLoad = true
const filteredList = computed(() => {
if (!keyword.value) return list.value
@ -96,16 +97,18 @@ function textValue(v) {
return String(v).trim() || '-'
}
function getItemKey(item) {
return `${item.productId || item.id}_${item.warehouseId || ''}_${item.areaId || ''}`
}
function isSelected(item) {
return selectedItems.value.some(s =>
String(s.productId) === String(item.productId) && String(s.warehouseId) === String(item.warehouseId)
)
const key = getItemKey(item)
return selectedItems.value.some(s => getItemKey(s) === key)
}
function toggleSelect(item) {
const idx = selectedItems.value.findIndex(s =>
String(s.productId) === String(item.productId) && String(s.warehouseId) === String(item.warehouseId)
)
const key = getItemKey(item)
const idx = selectedItems.value.findIndex(s => getItemKey(s) === key)
if (idx >= 0) {
selectedItems.value.splice(idx, 1)
} else {
@ -159,7 +162,29 @@ function handleConfirm() {
onLoad((options) => {
routeProductId.value = options?.productIds || options?.productId || ''
loadData()
})
onShow(() => {
const prevSelected = getApp().globalData?._checkItemSelected
if (prevSelected && Array.isArray(prevSelected)) {
selectedItems.value = prevSelected.map(item => ({
id: item.id || item.productId,
productId: item.productId || item.id,
warehouseId: item.warehouseId,
areaId: item.areaId,
warehouseName: item.warehouseName,
areaName: item.areaName,
productBarCode: item.productBarCode,
productName: item.productName,
stockCount: item.stockCount,
productPrice: item.productPrice
}))
getApp().globalData._checkItemSelected = null
}
if (isFirstLoad) {
isFirstLoad = false
loadData()
}
})
</script>

@ -105,6 +105,10 @@ const MENU_ROUTE_MAP = {
sparepartCheck: '/pages_function/pages/sparepartCheck/index',
sparepartcheck: '/pages_function/pages/sparepartCheck/index',
'备件盘点': '/pages_function/pages/sparepartCheck/index',
materialCheck: '/pages_function/pages/materialCheck/index',
materialcheck: '/pages_function/pages/materialCheck/index',
'物料盘点': '/pages_function/pages/materialCheck/index',
'物料盘点执行': '/pages_function/pages/materialCheck/index',
materialInbound: '/pages_function/pages/materialInbound/index',
materialinbound: '/pages_function/pages/materialInbound/index',
'物料入库': '/pages_function/pages/materialInbound/index',

Loading…
Cancel
Save