Merge remote-tracking branch 'origin/master'

# Conflicts:
#	src/pages_function/pages/moldRepair/userSelect.vue
master
黄伟杰 4 days ago
commit 89d1d13f6c

File diff suppressed because it is too large Load Diff

@ -0,0 +1,45 @@
import request from '@/utils/request'
// 物料入库单创建
export function createMaterialInbound(data) {
return request({
url: '/admin-api/erp/stock-in/create',
method: 'post',
data: { ...data, inType: '物料入库' }
})
}
// 物料入库单分页查询(待入库/待审核)
export function getMaterialInboundPage(params = {}) {
return request({
url: '/admin-api/erp/stock-in/page',
method: 'get',
params: { ...params, inType: '物料入库' }
})
}
// 物料入库单提交审核(提交后变为待审核状态)
export function submitMaterialInbound(data) {
return request({
url: '/admin-api/erp/stock-in/submit',
method: 'put',
data
})
}
// 物料入库单审核status: 20=通过, 1=驳回)
export function auditMaterialInbound(data) {
return request({
url: '/admin-api/erp/stock-in/audit',
method: 'put',
data
})
}
// 物料入库单删除
export function deleteMaterialInbound(id) {
return request({
url: '/admin-api/erp/stock-in/delete',
method: 'delete',
params: { ids: String(id) }
})
}

@ -48,10 +48,20 @@ export function deleteMoldGet(ids = []) {
}) })
} }
export function getWarehouseSimpleList() { export function getWarehouseSimpleList(params = {}) {
return request({ return request({
url: '/admin-api/erp/warehouse/simple-list', url: '/admin-api/erp/warehouse/simple-list',
method: 'get' method: 'get',
params
})
}
// 仓库分页列表(支持 categoryType 过滤)
export function getWarehousePage(params = {}) {
return request({
url: '/admin-api/erp/warehouse/page',
method: 'get',
params
}) })
} }

@ -13,6 +13,28 @@ export function getSparepartSimpleList(pageNo = 1) {
}) })
} }
// 物料列表(分页查询,后端按 categoryType=2 过滤物料)
export function getMaterialSimpleList(pageNo = 1) {
return request({
url: '/admin-api/erp/product/page',
method: 'get',
params: {
pageNo,
pageSize: 100,
categoryType: 2
}
})
}
// 产品详情(含供应商、图片等完整信息,备件/物料通用)
export function getProductDetail(id) {
return request({
url: '/admin-api/erp/product/get',
method: 'get',
params: { id }
})
}
// 备件详情(含供应商、图片等完整信息) // 备件详情(含供应商、图片等完整信息)
export function getSparepartDetail(id) { export function getSparepartDetail(id) {
return request({ return request({

@ -0,0 +1,82 @@
import request from '@/utils/request'
// 创建盘点单
export function createCheck(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 getSparepartCheckPage(params = {}) {
return request({
url: '/admin-api/erp/stock-check/page',
method: 'get',
params
})
}
// 备件盘点单详情
export function getSparepartCheckDetail(id) {
return request({
url: '/admin-api/erp/stock-check/get',
method: 'get',
params: { id }
})
}
// 备件盘点执行(提交盘点结果)
export function executeSparepartCheck(data) {
return request({
url: '/admin-api/erp/stock-check/update',
method: 'put',
data
})
}
// 备件盘点单提交
export function submitSparepartCheck(data) {
return request({
url: '/admin-api/erp/stock-check/submit',
method: 'put',
data
})
}
// 备件盘点单审核status: 20=通过, 1=驳回)
export function auditSparepartCheck(data) {
return request({
url: '/admin-api/erp/stock-check/audit',
method: 'put',
data
})
}
// 备件盘点单删除
export function deleteSparepartCheck(id) {
return request({
url: '/admin-api/erp/stock-check/delete',
method: 'delete',
params: { ids: String(id) }
})
}

@ -380,7 +380,6 @@ export default {
historySuffix: ' History', historySuffix: ' History',
historyTitle: 'Mold Operate History', historyTitle: 'Mold Operate History',
searchPlaceholder: 'Search device/mold name', searchPlaceholder: 'Search device/mold name',
operator: 'Operator',
placeholderOperator: 'Select operator', placeholderOperator: 'Select operator',
filterAll: 'All', filterAll: 'All',
filterToday: 'Today', filterToday: 'Today',

@ -380,7 +380,6 @@ export default {
historySuffix: '历史', historySuffix: '历史',
historyTitle: '上下模历史', historyTitle: '上下模历史',
searchPlaceholder: '搜索设备/模具名称', searchPlaceholder: '搜索设备/模具名称',
operator: '操作人',
placeholderOperator: '请选择操作人', placeholderOperator: '请选择操作人',
filterAll: '全部', filterAll: '全部',
filterToday: '今天', filterToday: '今天',
@ -1559,7 +1558,6 @@ export default {
purchaseUnit: '采购单位', purchaseUnit: '采购单位',
convertRatio: '换算关系', convertRatio: '换算关系',
defaultWarehouse: '默认仓库/库区', defaultWarehouse: '默认仓库/库区',
selectSparepart: '选择备件',
selectedSpareparts: '已选备件', selectedSpareparts: '已选备件',
noSelectedSparepart: '请扫码或选择备件', noSelectedSparepart: '请扫码或选择备件',
alreadySelected: '该备件已添加', alreadySelected: '该备件已添加',
@ -1594,8 +1592,8 @@ export default {
sparepartInventory: { sparepartInventory: {
moduleName: '备件库存查询', moduleName: '备件库存查询',
searchPlaceholder: '请输入备件编码或名称', searchPlaceholder: '请输入备件编码或名称',
allWarehouse: '全部仓库', allArea: '全部库区',
warehousePlaceholder: '仓库筛选', areaPlaceholder: '库区筛选',
productName: '物料名称', productName: '物料名称',
barCode: '物料编码', barCode: '物料编码',
warehouse: '仓库', warehouse: '仓库',

@ -493,6 +493,76 @@
"navigationStyle": "custom" "navigationStyle": "custom"
} }
}, },
{
"path": "materialInbound/index",
"style": {
"navigationBarTitleText": "物料入库",
"navigationStyle": "custom"
}
},
{
"path": "materialInbound/create",
"style": {
"navigationBarTitleText": "新增物料入库",
"navigationStyle": "custom"
}
},
{
"path": "materialInbound/materialSelect",
"style": {
"navigationBarTitleText": "选择物料",
"navigationStyle": "custom"
}
},
{
"path": "materialInbound/materialConfirm",
"style": {
"navigationBarTitleText": "确认物料入库",
"navigationStyle": "custom"
}
},
{
"path": "sparepartCheck/index",
"style": {
"navigationBarTitleText": "备件盘点",
"navigationStyle": "custom"
}
},
{
"path": "sparepartCheck/execute",
"style": {
"navigationBarTitleText": "执行盘点",
"navigationStyle": "custom"
}
},
{
"path": "sparepartCheck/create",
"style": {
"navigationBarTitleText": "新增盘点单",
"navigationStyle": "custom"
}
},
{
"path": "sparepartCheck/itemSelect",
"style": {
"navigationBarTitleText": "选择盘点项",
"navigationStyle": "custom"
}
},
{
"path": "sparepartCheck/itemSelectByProduct",
"style": {
"navigationBarTitleText": "选择盘点项",
"navigationStyle": "custom"
}
},
{
"path": "sparepartCheck/productSelect",
"style": {
"navigationBarTitleText": "选择产品",
"navigationStyle": "custom"
}
},
{ {
"path": "keypart/index", "path": "keypart/index",

@ -1,4 +1,4 @@
<template> <template>
<view class="page-container"> <view class="page-container">
<NavBar :title="pageTitle" /> <NavBar :title="pageTitle" />
<scroll-view scroll-y class="main-scroll" :scroll-top="scrollTop" scroll-with-animation @scroll="onScroll"> <scroll-view scroll-y class="main-scroll" :scroll-top="scrollTop" scroll-with-animation @scroll="onScroll">

@ -0,0 +1,576 @@
<template>
<view class="page-container">
<NavBar :title="'新增物料入库'" />
<!-- 操作按钮区 -->
<view class="action-row">
<view class="scan-input-row">
<input
id="material-inbound-scan-input"
class="scan-input"
v-model="scanCodeInput"
placeholder="红外扫码或输入物料码"
confirm-type="done"
@confirm="onScanInputConfirm"
/>
</view>
<view class="action-btn select-btn" @click="handleSelectMaterial">
<text class="btn-text">选择物料</text>
</view>
</view>
<!-- 入库信息 -->
<view class="form-section">
<!-- 入库时间 -->
<view class="section-title-bar">
<view class="section-bar-line"></view>
<text class="section-title"><text class="required">*</text>入库时间</text>
</view>
<picker mode="date" :value="inboundDate" @change="handleDateChange">
<view class="form-row-card">
<text :class="{ placeholder: !inboundDate }">{{ inboundDate || '请选择入库时间' }}</text>
<text class="form-row-arrow"></text>
</view>
</picker>
<!-- 经办人 -->
<view class="section-title-bar" style="padding-top: 24rpx;">
<view class="section-bar-line"></view>
<text class="section-title"><text class="required">*</text>经办人</text>
</view>
<view class="form-row-card" @click="goSelectOperator">
<text :class="{ placeholder: !selectedOperatorName }">
{{ selectedOperatorName || '请选择经办人' }}
</text>
<text class="form-row-arrow"></text>
</view>
<!-- 备注 -->
<view class="section-title-bar" style="padding-top: 24rpx;">
<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="请输入备注信息"
placeholder-class="remark-placeholder"
:maxlength="500"
auto-height
/>
</view>
<!-- 附件 -->
<view class="section-title-bar" style="padding-top: 24rpx;">
<view class="section-bar-line"></view>
<text class="section-title">附件</text>
</view>
<view class="attachment-area">
<view class="attachment-list">
<view v-for="(file, idx) in attachmentList" :key="idx" class="attachment-file-item">
<view class="file-icon">
<text class="file-icon-text">{{ getFileIcon(file.name) }}</text>
</view>
<view class="file-info">
<text class="file-name" :title="file.name">{{ file.name }}</text>
<text class="file-size">{{ formatFileSize(file.size) }}</text>
</view>
<view class="file-delete" @click="removeAttachment(idx)">
<text class="delete-icon-sm"></text>
</view>
</view>
<view class="attachment-add-file" @click="handleAddAttachment">
<text class="add-text">选取文件</text>
</view>
</view>
</view>
</view>
<!-- 已选物料列表 -->
<view class="material-section">
<view class="section-title-bar">
<view class="section-bar-line"></view>
<text class="section-title">入库清单{{ itemList.length }}</text>
</view>
<view v-if="itemList.length" class="item-list">
<view v-for="(item, idx) in itemList" :key="idx" class="item-card">
<view class="item-delete-top" @click="removeItem(idx)"><text class="delete-icon"></text></view>
<view class="item-left">
<view class="item-image-wrap">
<image
v-if="item._material && getItemImage(item._material)"
:src="getItemImage(item._material)"
class="item-image"
mode="aspectFill"
/>
<text v-else class="item-image-empty">📦</text>
</view>
<view class="item-info">
<text class="item-name">{{ item.productName }}</text>
<text class="item-spec">{{ item.productBarCode || '-' }}</text>
</view>
</view>
<view class="item-right">
<view class="item-qty-row">
<text class="item-qty-label">入库数量</text>
<text class="item-qty-value">{{ item.inputCount }}{{ item.purchaseUnitName }}</text>
</view>
</view>
</view>
</view>
<view v-else class="empty-wrap">
<text class="empty-text">请扫码或选择物料</text>
</view>
</view>
<!-- 底部操作栏 -->
<view class="bottom-actions">
<view class="bottom-btn cancel-btn" @click="handleCancel"></view>
<view class="bottom-btn confirm-btn" @click="handleSubmit"></view>
</view>
<sv-focus-no-keyboard ref="focusNoKeyboardRef"></sv-focus-no-keyboard>
</view>
</template>
<script setup>
import { ref, nextTick } from 'vue'
import { onReady, onShow, onHide } from '@dcloudio/uni-app'
import NavBar from '@/components/common/NavBar.vue'
import { createMaterialInbound } from '@/api/mes/materialInbound'
import { getProductDetail } from '@/api/mes/sparepart'
const itemList = ref([])
const scanCodeInput = ref('')
//
const focusNoKeyboardRef = ref(null)
const keywordInputSelector = '#material-inbound-scan-input input, input#material-inbound-scan-input'
function focusKeywordNoKeyboard() {
nextTick(() => {
setTimeout(() => {
focusNoKeyboardRef.value?.focus(keywordInputSelector)
}, 80)
})
}
//
function onScanInputConfirm() {
const code = scanCodeInput.value.trim()
if (!code) return
handleScanCode(code)
}
async function handleScanCode(code) {
let materialId = null
if (code.toUpperCase().startsWith('MATERIAL-')) {
materialId = code.replace(/MATERIAL-/i, '')
} else {
const idMatch = code.match(/(\d+)$/)
if (idMatch) materialId = idMatch[1]
}
if (!materialId) {
uni.showToast({ title: '无法识别物料码', icon: 'none' })
return
}
try {
const apiRes = await getProductDetail(materialId)
const detail = apiRes?.data || apiRes
if (detail && detail.id) {
getApp().globalData._materialFromScan = true
getApp().globalData._materialBeforeConfirm = detail
uni.navigateTo({
url: '/pages_function/pages/materialInbound/materialConfirm'
})
} else {
uni.showToast({ title: '未找到物料: ' + materialId, icon: 'none' })
}
} catch (e) {
console.error('[物料入库] 扫码查询物料失败:', e)
uni.showToast({ title: '扫码失败', icon: 'none' })
}
}
//
const inboundDate = ref(formatDate(new Date()))
//
const selectedOperatorId = ref(null)
const selectedOperatorName = ref('')
//
const remark = ref('')
//
const attachmentList = ref([])
function formatDate(date) {
const y = date.getFullYear()
const m = String(date.getMonth() + 1).padStart(2, '0')
const d = String(date.getDate()).padStart(2, '0')
return `${y}-${m}-${d}`
}
function handleDateChange(e) {
inboundDate.value = e.detail.value
}
function getItemImage(material) {
const images = material.images
if (!images) return ''
if (Array.isArray(images)) return String(images[0] || '')
return String(images).split(',')[0]?.trim() || ''
}
function handleCancel() {
getApp().globalData._materialInboundItems = []
uni.navigateBack()
}
function handleSelectMaterial() {
getApp().globalData._materialSelectFrom = 'inbound'
uni.navigateTo({
url: '/pages_function/pages/materialInbound/materialSelect'
})
}
function handleScan() {
uni.scanCode({
onlyFromCamera: false,
scanType: ['barCode', 'qrCode'],
success: (res) => {
const code = (res.result || '').trim()
if (!code) return
scanCodeInput.value = code
handleScanCode(code)
},
fail: () => {
uni.showToast({ title: '扫码失败', icon: 'none' })
}
})
}
function removeItem(idx) {
itemList.value.splice(idx, 1)
getApp().globalData._materialInboundItems = [...itemList.value]
}
//
function goSelectOperator() {
getApp().globalData._materialInboundUserFrom = 'materialInbound'
uni.navigateTo({
url: '/pages_function/pages/moldRepair/userSelect?field=operator&from=materialInbound'
})
}
//
function getFileIcon(fileName) {
const ext = (fileName || '').split('.').pop()?.toLowerCase()
const iconMap = {
pdf: '📄', doc: '📝', docx: '📝', xls: '📊', xlsx: '📊',
ppt: '📽', pptx: '📽', txt: '📃', zip: '📦', rar: '📦',
jpg: '🖼', jpeg: '🖼', png: '🖼', gif: '🖼', webp: '🖼'
}
return iconMap[ext] || '📎'
}
function formatFileSize(bytes) {
if (!bytes) return '0 B'
if (bytes < 1024) return bytes + ' B'
if (bytes < 1024 * 1024) return (bytes / 1024).toFixed(1) + ' KB'
return (bytes / (1024 * 1024)).toFixed(1) + ' MB'
}
function handleAddAttachment() {
// #ifdef APP-PLUS
plus.gallery.pick(
(res) => {
const files = (res?.files || []).map(f => ({
name: f.name || 'unknown',
size: f.size || 0,
path: f
}))
attachmentList.value.push(...files)
},
(e) => {
console.log('选择文件失败:', e)
},
{ filter: 'all', multiple: true, maximum: 9 - attachmentList.value.length }
)
// #endif
// #ifndef APP-PLUS
uni.chooseImage({
count: 9 - attachmentList.value.length,
sizeType: ['compressed'],
sourceType: ['album', 'camera'],
success: (res) => {
res.tempFilePaths.forEach(path => {
const parts = path.split('/')
const name = parts[parts.length - 1] || 'image.jpg'
attachmentList.value.push({ name, size: 0, path })
})
}
})
// #endif
}
function removeAttachment(idx) {
attachmentList.value.splice(idx, 1)
}
async function handleSubmit() {
if (!itemList.value.length) {
uni.showToast({ title: '请先添加物料', icon: 'none' })
return
}
if (!inboundDate.value) {
uni.showToast({ title: '请选择入库时间', icon: 'none' })
return
}
if (!selectedOperatorId.value) {
uni.showToast({ title: '请选择经办人', icon: 'none' })
return
}
let totalCount = 0
const items = itemList.value.map(item => {
totalCount += item.count || 0
return {
warehouseId: item.warehouseId,
areaId: item.areaId,
productId: item.productId,
productName: item.productName,
productBarCode: item.productBarCode,
productUnitName: item.productUnitName,
purchaseUnitName: item.purchaseUnitName,
purchaseUnitConvertQuantity: item.purchaseUnitConvertQuantity,
inputCount: item.inputCount,
count: item.count
}
})
const now = new Date()
const [y, m, d] = inboundDate.value.split('-').map(Number)
const inTime = new Date(y, m - 1, d, now.getHours(), now.getMinutes(), now.getSeconds()).getTime()
const submitData = {
isCode: true,
inTime: inTime,
stockUserId: String(selectedOperatorId.value),
supplierId: itemList.value[0]?.supplierId,
status: 0,
totalCount: totalCount,
totalPrice: 0,
remark: remark.value,
items: items
}
if (attachmentList.value.length) {
submitData.attachments = attachmentList.value.map(f => f.path || f)
}
console.log('提交数据:', JSON.stringify(submitData))
uni.showLoading({ title: '提交中...', mask: true })
try {
await createMaterialInbound(submitData)
uni.hideLoading()
getApp().globalData._materialInboundItems = []
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' })
}
}
onReady(() => {
focusKeywordNoKeyboard()
})
onShow(() => {
const items = getApp().globalData?._materialInboundItems
if (Array.isArray(items)) {
itemList.value = [...items]
}
//
const userResult = getApp().globalData?._materialInboundUserSelectResult
if (userResult) {
selectedOperatorId.value = userResult.user.id
selectedOperatorName.value = userResult.user.nickname || userResult.user.userName || userResult.user.name || ''
getApp().globalData._materialInboundUserSelectResult = null
}
})
onHide(() => {})
</script>
<style lang="scss" scoped>
.page-container {
min-height: 100vh;
background: #f5f6f8;
padding-bottom: calc(120rpx + env(safe-area-inset-bottom));
}
/* 操作按钮区 */
.action-row {
display: flex;
align-items: center;
gap: 16rpx;
padding: 20rpx 24rpx;
}
.scan-input-row {
flex: 1;
display: flex;
align-items: center;
height: 72rpx;
border-radius: 10rpx;
overflow: hidden;
}
.scan-input {
flex: 1;
height: 72rpx;
padding: 0 20rpx;
font-size: 26rpx;
color: #333;
background: #fff;
border: 1rpx solid #d0d5dd;
border-radius: 10rpx;
}
.action-btn {
display: flex;
align-items: center;
justify-content: center;
height: 72rpx;
padding: 0 24rpx;
border-radius: 10rpx;
background: #1f4b79;
color: #fff;
font-size: 26rpx;
font-weight: 600;
white-space: nowrap;
.btn-text { font-size: 26rpx; font-weight: 600; color: #fff; }
}
/* 物料列表 */
.material-section { padding: 0; }
.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; margin-right: 2rpx; }
.item-list { padding: 0 24rpx; }
.item-card {
position: relative; display: flex; align-items: center; justify-content: space-between;
background: #fff; border-radius: 14rpx; padding: 20rpx; margin-bottom: 16rpx;
box-shadow: 0 2rpx 12rpx rgba(15, 23, 42, 0.04);
}
.item-delete-top { position: absolute; top: 10rpx; right: 10rpx; width: 40rpx; height: 40rpx; border-radius: 20rpx; background: #fee2e2; display: flex; align-items: center; justify-content: center; z-index: 1; .delete-icon { font-size: 20rpx; color: #dc2626; } }
.item-left { display: flex; align-items: center; flex: 1; min-width: 0; padding-right: 36rpx; }
.item-image-wrap {
width: 80rpx; height: 80rpx; border-radius: 10rpx; overflow: hidden;
background: #f8fafc; border: 1rpx solid #f0f0f0; flex-shrink: 0;
display: flex; align-items: center; justify-content: center;
}
.item-image { width: 100%; height: 100%; }
.item-image-empty { font-size: 36rpx; opacity: 0.3; }
.item-info { margin-left: 16rpx; flex: 1; min-width: 0; }
.item-name {
font-size: 28rpx; font-weight: 600; color: #1a1a1a; display: block;
overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.item-spec { font-size: 24rpx; color: #9ca3af; margin-top: 6rpx; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-right { display: flex; flex-direction: column; align-items: flex-end; margin-left: 16rpx; flex-shrink: 0; padding-right: 50rpx; }
.item-qty-row { display: flex; flex-direction: column; align-items: flex-end; }
.item-qty-label { font-size: 22rpx; color: #9ca3af; }
.item-qty-value { font-size: 28rpx; font-weight: 700; color: #2563eb; margin-top: 4rpx; }
.empty-wrap { padding: 160rpx 0; text-align: center; }
.empty-text { font-size: 28rpx; color: #94a3b8; }
/* 入库信息区 */
.form-section { padding-bottom: 16rpx; }
.form-row-card {
position: relative;
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; }
}
.form-row-arrow { font-size: 20rpx; color: #999; flex-shrink: 0; }
/* 备注 */
.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; }
.remark-placeholder { color: #bbb; }
/* 附件 */
.attachment-area { padding: 0 24rpx 16rpx; }
.attachment-list { display: flex; flex-direction: column; gap: 12rpx; }
.attachment-file-item {
display: flex; align-items: center; gap: 16rpx;
background: #fff; border-radius: 12rpx; padding: 18rpx 20rpx;
box-shadow: 0 2rpx 8rpx rgba(15, 23, 42, 0.03);
}
.file-icon {
width: 72rpx; height: 72rpx; border-radius: 10rpx;
background: #f1f5f9; display: flex; align-items: center; justify-content: center;
flex-shrink: 0;
}
.file-icon-text { font-size: 36rpx; }
.file-info { flex: 1; min-width: 0; }
.file-name {
font-size: 26rpx; color: #1f2937; display: block;
overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.file-size { font-size: 22rpx; color: #9ca3af; margin-top: 4rpx; display: block; }
.file-delete {
width: 48rpx; height: 48rpx; border-radius: 24rpx;
background: #fee2e2; display: flex; align-items: center; justify-content: center;
flex-shrink: 0;
}
.delete-icon-sm { font-size: 22rpx; color: #dc2626; }
.attachment-add-file {
display: flex; align-items: center; justify-content: center; gap: 10rpx;
height: 88rpx; background: #fff; border: 2rpx dashed #cbd5e1;
border-radius: 12rpx;
}
.add-text { font-size: 26rpx; color: #6b7280; }
/* 底部操作栏 */
.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: #ffffff; 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: #ffffff; }
</style>

@ -0,0 +1,825 @@
<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>
<view class="status-box-wrapper">
<view class="status-box" @click="toggleStatusDropdown">
<text class="status-box-text">{{ currentStatusLabel }}</text>
<uni-icons type="bottom" size="14" color="#9ca3af"></uni-icons>
</view>
<view v-if="showStatusDropdown" class="status-dropdown-panel">
<view
v-for="(item, idx) in statusOptions"
:key="idx"
class="status-dropdown-item"
:class="{ active: selectedStatus === item.value }"
@click.stop="selectStatus(item, idx)"
>
<text class="status-dropdown-item-text">{{ item.label }}</text>
<text v-if="selectedStatus === item.value" class="status-dropdown-check"></text>
</view>
</view>
</view>
<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>
</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">{{ formatDateTime(item.inTime || item.createTime) }}</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 highlight">{{ textValue(item.totalCount) }}</text>
</view>
<view class="row">
<text class="label">审核人</text>
<text class="value">{{ textValue(item.auditUserName) }}</text>
</view>
</view>
<!-- 待入库提交审核 -->
<view v-if="Number(item.status) === 0" class="card-actions">
<view class="action-btn submit-btn" @click.stop="openSubmitAudit(item)">提交审核</view>
</view>
<!-- 待审核通过 / 驳回 -->
<view v-if="Number(item.status) === 10" class="card-actions">
<view class="action-btn approve-btn" @click.stop="handleApprove(item)">审核通过</view>
<view class="action-btn reject-btn" @click.stop="handleReject(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="showAuditModal" class="modal-overlay" @click="closeAuditModal">
<view class="modal-card" @click.stop>
<view class="modal-header">
<text class="modal-title">提交审核</text>
<text class="modal-close" @click="closeAuditModal"></text>
</view>
<view class="modal-body">
<!-- 审核人 -->
<view class="modal-field">
<text class="modal-label"><text class="required">*</text>审核人</text>
<view class="modal-dropdown" @click="toggleAuditorDropdown">
<text :class="{ placeholder: !selectedAuditor }">{{ selectedAuditor ? selectedAuditor.label : '请选择' }}</text>
<text class="dropdown-arrow"></text>
<view v-if="showAuditorDropdown" class="dropdown-panel">
<scroll-view scroll-y class="dropdown-scroll">
<view v-for="u in auditorOptions" :key="u.value" class="dropdown-item" :class="{ active: selectedAuditor?.value === u.value }" @click.stop="selectAuditor(u)">
<text class="dropdown-item-text">{{ u.label }}</text>
<text v-if="selectedAuditor?.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="auditRemark" class="modal-textarea" placeholder="请输入备注" placeholder-class="textarea-placeholder" :maxlength="200" />
</view>
</view>
<view class="modal-footer">
<view class="modal-btn cancel-btn" @click="closeAuditModal"></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, onHide } from '@dcloudio/uni-app'
import NavBar from '@/components/common/NavBar.vue'
import { getMaterialInboundPage, auditMaterialInbound, submitMaterialInbound } from '@/api/mes/materialInbound'
import { getSimpleUserList } from '@/api/mes/moldget'
const selectedStatus = ref('')
const searchKeyword = ref('')
const showStatusDropdown = ref(false)
const statusOptions = computed(() => [
{ label: '全部', value: '' },
{ label: '待入库', value: '0' },
{ label: '待审核', value: '10' },
{ label: '已入库', value: '20' },
{ label: '已驳回', value: '1' }
])
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
function textValue(v) {
if (v === 0) return '0'
if (v == null) return '-'
const s = String(v).trim()
return s || '-'
}
function formatDateTime(value) {
if (!value) return '-'
if (Array.isArray(value) && value.length >= 3) {
const [year, month, day] = value
const pad = (n) => String(n).padStart(2, '0')
return `${year}-${pad(month)}-${pad(day)}`
}
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())}`
}
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-warning'
if (num === 20) return 'text-success'
if (num === 1) return 'text-danger'
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,
statusList: selectedStatus.value !== '' ? [Number(selectedStatus.value)] : undefined
}
const res = await getMaterialInboundPage(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 toggleStatusDropdown() {
showStatusDropdown.value = !showStatusDropdown.value
}
function selectStatus(item, _idx) {
selectedStatus.value = item.value
showStatusDropdown.value = false
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/sparepartInbound/detail?id=${encodeURIComponent(String(item.id))}`
})
}
async function handleApprove(item) {
if (!item?.id) return
uni.showModal({
title: '确认',
content: '确认审核通过?',
confirmColor: '#16a34a',
success: async (res) => {
if (res.confirm) {
try {
await auditMaterialInbound({ id: item.id, status: 20 })
uni.showToast({ title: '审核通过', icon: 'success' })
fetchList(true)
} catch (e) {
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 {
await auditMaterialInbound({ id: item.id, status: 1 })
uni.showToast({ title: '已驳回', icon: 'success' })
fetchList(true)
} catch (e) {
uni.showToast({ title: '操作失败', icon: 'none' })
}
}
}
})
}
//
const showAuditModal = ref(false)
const currentAuditItem = ref(null)
const auditorOptions = ref([])
const selectedAuditor = ref(null)
const showAuditorDropdown = ref(false)
const auditRemark = ref('')
function openSubmitAudit(item) {
currentAuditItem.value = item
selectedAuditor.value = null
auditRemark.value = ''
showAuditModal.value = true
loadAuditorOptions()
}
function closeAuditModal() {
showAuditModal.value = false
currentAuditItem.value = null
showAuditorDropdown.value = false
}
function toggleAuditorDropdown() {
showAuditorDropdown.value = !showAuditorDropdown.value
}
function selectAuditor(u) {
selectedAuditor.value = u
showAuditorDropdown.value = false
}
async function loadAuditorOptions() {
if (auditorOptions.value.length) return
try {
const res = await getSimpleUserList()
const data = Array.isArray(res) ? res : (Array.isArray(res?.data) ? res.data : [])
auditorOptions.value = data.map((u) => ({
value: u.id || u.userId,
label: u.nickname || u.userName || u.name || String(u.id || '')
}))
} catch (e) {
console.error('loadAuditorOptions error', e)
}
}
async function confirmSubmitAudit() {
if (!selectedAuditor.value) {
uni.showToast({ title: '请选择审核人', icon: 'none' })
return
}
if (!currentAuditItem.value?.id) return
try {
uni.showLoading({ title: '提交中...', mask: true })
await submitMaterialInbound({
id: currentAuditItem.value.id,
auditUserId: selectedAuditor.value.value,
remark: auditRemark.value || undefined
})
uni.hideLoading()
uni.showToast({ title: '提交审核成功', icon: 'success' })
closeAuditModal()
fetchList(true)
} catch (e) {
uni.hideLoading()
uni.showToast({ title: '提交失败', icon: 'none' })
}
}
function onScroll(event) {
showGoTop.value = (event?.detail?.scrollTop || 0) > 600
}
function goTop() {
scrollTop.value = 0
}
function goAdd() {
uni.navigateTo({
url: '/pages_function/pages/materialInbound/create'
})
}
function clearSearchTimer() {
if (searchTimer) {
clearTimeout(searchTimer)
searchTimer = null
}
}
onShow(() => {
fetchList(true)
})
onUnload(() => {
clearSearchTimer()
})
onHide(() => {
showStatusDropdown.value = false
})
</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-wrapper {
position: relative;
flex-shrink: 0;
}
.status-box {
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-dropdown-panel {
position: absolute;
top: 74rpx;
left: 0;
right: 0;
z-index: 200;
background: #fff;
border: 1rpx solid #e0e0e0;
border-radius: 12rpx;
box-shadow: 0 8rpx 30rpx rgba(0, 0, 0, 0.12);
overflow: hidden;
}
.status-dropdown-item {
display: flex;
align-items: center;
justify-content: space-between;
padding: 18rpx 24rpx;
border-bottom: 1rpx solid #f0f0f0;
&:last-child {
border-bottom: 0;
}
&.active {
background: #f0f5ff;
}
}
.status-dropdown-item-text {
font-size: 26rpx;
color: #374151;
}
.status-dropdown-check {
font-size: 26rpx;
color: #2563eb;
font-weight: 700;
}
.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;
&.approve-btn {
background: #dcfce7;
color: #16a34a;
}
&.reject-btn {
background: #fee2e2;
color: #dc2626;
}
&.submit-btn {
background: #dbeafe;
color: #1d4ed8;
}
&:active {
opacity: 0.8;
}
}
/* ====== 状态标签颜色 ====== */
.text-success {
color: #16a34a;
}
.text-danger {
color: #dc2626;
}
.text-warning {
color: #d97706;
}
.text-primary {
color: #2563eb;
}
.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;
}
/* ====== 提示 ====== */
.hint {
padding: 36rpx 0;
text-align: center;
color: #94a3b8;
font-size: 26rpx;
}
/* ====== 回顶部 ====== */
.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;
}
/* ====== 新增按钮 ====== */
.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;
}
/* ====== 提交审核弹框 ====== */
.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,441 @@
<template>
<view class="page-container">
<NavBar :title="'确认物料入库'" />
<!-- 已选物料 -->
<view class="material-section">
<view class="section-title-bar">
<view class="section-bar-line"></view>
<text class="section-title">已选物料</text>
</view>
<view class="material-card">
<view class="card-top">
<view class="card-image-wrap">
<image
v-if="materialImage"
:src="materialImage"
class="card-image"
mode="aspectFill"
/>
<view v-else class="card-image-empty">
<text class="empty-img-icon">📦</text>
</view>
</view>
<view class="card-info-right">
<view class="info-item">
<text class="info-label">物料名称</text>
<text class="info-name">{{ textValue(material.name) }}</text>
</view>
<view class="info-item">
<text class="info-label">规格</text>
<text class="info-value">{{ textValue(material.standard || material.deviceSpec) }}</text>
</view>
<view class="info-item">
<text class="info-label">当前总库存</text>
<text class="info-value stock-highlight">{{ material.count != null ? material.count : 0 }}{{ textUnit(material.unitName || material.minStockUnitName || '个') }}</text>
</view>
</view>
</view>
<view class="card-bottom">
<view class="detail-row two-col">
<view class="detail-col">
<text class="detail-label">采购单位</text>
<text class="detail-value">{{ textValue(material.purchaseUnitName) }}</text>
</view>
<view class="detail-col">
<text class="detail-label">库存单位</text>
<text class="detail-value">{{ textValue(material.unitName || material.minStockUnitName || '个') }}</text>
</view>
</view>
<view class="detail-row">
<text class="detail-label">换算关系</text>
<text class="detail-value">1{{ textValue(material.purchaseUnitName) }}={{ textValue(material.purchaseUnitConvertQuantity) }}{{ stockUnitLabel(material) }}</text>
</view>
</view>
</view>
<!-- 仓库/库区 -->
<view class="section-title-bar" style="padding-top: 24rpx;">
<view class="section-bar-line"></view>
<text class="section-title">仓库/库区</text>
</view>
<view class="select-row-card warehouse-area-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">{{ selectedWarehouse ? selectedWarehouse.label : '原料仓' }}</text>
</view>
</view>
</view>
<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="item in areaOptions"
:key="item.value"
class="dropdown-item"
:class="{ active: selectedArea?.value === item.value }"
@click.stop="handleSelectArea(item)"
>
<text class="dropdown-item-text">{{ item.label }}</text>
<text v-if="selectedArea?.value === item.value" class="dropdown-check"></text>
</view>
<view v-if="!areaOptions.length" class="dropdown-empty"></view>
</view>
</view>
</view>
</view>
</view>
</view>
<!-- 入库数量 -->
<view class="section-title-bar" style="padding-top: 24rpx;">
<view class="section-bar-line"></view>
<text class="section-title">入库数量</text>
</view>
<view class="qty-input-card">
<view class="form-field">
<text class="form-label">入库数量</text>
<input
v-model="inboundQty"
class="form-input"
placeholder="请输入"
confirm-type="done"
/>
<text class="form-suffix-text">单位{{ textValue(material.purchaseUnitName) }}</text>
</view>
<view class="convert-row">
<text class="convert-label-inline">折算后库存数量</text>
<text class="convert-value-inline">{{ calculatedStock }}</text>
<text class="convert-unit-inline">{{ stockUnitLabel(material) }}</text>
</view>
<view class="convert-formula-inline">
{{ inboundQty || 0 }}{{ textValue(material.purchaseUnitName) }} × {{ textValue(material.purchaseUnitConvertQuantity) }}{{ stockUnitLabel(material) }} = {{ calculatedStock }}{{ stockUnitLabel(material) }}
</view>
</view>
<!-- 供应商 -->
<view class="section-title-bar" style="padding-top: 24rpx;">
<view class="section-bar-line"></view>
<text class="section-title">供应商</text>
</view>
<view class="select-row-card">
<view class="full-dropdown">
<text :class="{ placeholder: !defaultSupplierName }">
{{ defaultSupplierName || '未配置默认供应商' }}
</text>
</view>
</view>
</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, onHide } from '@dcloudio/uni-app'
import NavBar from '@/components/common/NavBar.vue'
import { getWarehouseSimpleList, getWarehouseAreaSimpleList } from '@/api/mes/moldget'
import { getProductDetail, getSparepartStockCount } from '@/api/mes/sparepart'
const material = ref({})
const inboundQty = ref(null)
//
const warehouseOptions = ref([])
const selectedWarehouse = ref(null)
//
const areaOptions = ref([])
const selectedArea = ref(null)
const showAreaDropdown = ref(false)
const loadingAreas = ref(false)
const materialImage = computed(() => {
const images = material.value.images
if (!images) return ''
if (Array.isArray(images)) return String(images[0] || '')
return String(images).split(',')[0]?.trim() || ''
})
const calculatedStock = computed(() => {
const qty = Number(inboundQty.value) || 0
const ratio = Number(material.value.purchaseUnitConvertQuantity) || 0
return qty * ratio
})
const defaultSupplierName = computed(() => {
const suppliers = material.value.suppliers
const defaultId = material.value.defaultSupplierId
if (!suppliers || !suppliers.length) return ''
if (defaultId) {
const found = suppliers.find(s => s.supplierId === defaultId || s.id === defaultId)
if (found) return found.supplierName || ''
}
const firstDefault = suppliers.find(s => s.defaultStatus === 1)
return firstDefault?.supplierName || ''
})
function textValue(v) {
if (v === 0) return '0'
if (v == null) return '-'
const s = String(v).trim()
return s || '-'
}
function textUnit(v) {
if (v === 0) return '0'
if (v == null) return ''
return String(v).trim()
}
function stockUnitLabel(item) {
return item.unitName || item.minStockUnitName || '个'
}
function handleCancel() {
uni.navigateBack()
}
function handleConfirm() {
if (!inboundQty.value || Number(inboundQty.value) <= 0) {
uni.showToast({ title: '请输入入库数量', icon: 'none' })
return
}
if (!selectedArea.value) {
uni.showToast({ title: '请选择库区', icon: 'none' })
return
}
const item = {
productId: material.value.id,
productName: material.value.name || '',
productBarCode: material.value.barCode || '',
productUnitName: material.value.unitName || material.value.minStockUnitName || '',
purchaseUnitName: material.value.purchaseUnitName || '',
purchaseUnitConvertQuantity: Number(material.value.purchaseUnitConvertQuantity) || 1,
inputCount: Number(inboundQty.value),
count: Number(inboundQty.value) * (Number(material.value.purchaseUnitConvertQuantity) || 1),
supplierId: material.value.defaultSupplierId,
supplierName: defaultSupplierName.value,
warehouseId: selectedWarehouse.value.value,
warehouseName: selectedWarehouse.value.label,
areaId: selectedArea.value.value,
areaName: selectedArea.value.label,
_material: { ...material.value }
}
if (!getApp().globalData._materialInboundItems) {
getApp().globalData._materialInboundItems = []
}
getApp().globalData._materialInboundItems.push(item)
uni.showToast({ title: '已添加: ' + (material.value.name || ''), icon: 'success', duration: 1200 })
setTimeout(() => {
const fromScan = getApp().globalData._materialFromScan
getApp().globalData._materialFromScan = false
uni.navigateBack({ delta: fromScan ? 1 : 2 })
}, 800)
}
//
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 || '')
}))
// ""
const rawWarehouse = warehouseOptions.value.find(w => w.label === '原料仓')
if (rawWarehouse) {
selectedWarehouse.value = rawWarehouse
loadAreas(rawWarehouse.value)
}
} catch (e) {
console.error('loadWarehouses error', e)
}
}
//
function toggleAreaDropdown() {
if (!selectedWarehouse.value) {
uni.showToast({ title: '请先选择仓库', icon: 'none' })
return
}
showAreaDropdown.value = !showAreaDropdown.value
}
function handleSelectArea(item) {
selectedArea.value = item
showAreaDropdown.value = false
}
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 : [])
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
}
}
onShow(async () => {
const selectResult = getApp().globalData?._materialBeforeConfirm
if (selectResult) {
material.value = selectResult
inboundQty.value = null
getApp().globalData._materialBeforeConfirm = null
if (selectResult.id) {
try {
const res = await getProductDetail(selectResult.id)
const detail = res?.data || res
if (detail) {
material.value = { ...material.value, ...detail }
loadStockCount()
}
} catch (e) {
console.error('获取物料详情失败:', e)
}
}
}
loadWarehouses()
})
async function loadStockCount() {
const id = material.value.id
if (!id) return
try {
const res = await getSparepartStockCount(id)
material.value.count = (res?.data ?? res) != null ? Number(res?.data ?? res) : 0
} catch (e) {
console.error('获取库存失败:', e)
material.value.count = 0
}
}
onHide(() => {
showAreaDropdown.value = false
})
</script>
<style lang="scss" scoped>
.page-container {
min-height: 100vh;
background: #f5f6f8;
padding-bottom: calc(120rpx + env(safe-area-inset-bottom));
}
.material-section { padding: 0; }
.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; }
.material-card {
background: #fff; border-radius: 16rpx; padding: 24rpx; margin: 0 24rpx 20rpx;
box-shadow: 0 4rpx 16rpx rgba(15, 23, 42, 0.04);
}
.card-top { display: flex; position: relative; }
.card-image-wrap {
width: 160rpx; height: 160rpx; border-radius: 12rpx; overflow: hidden;
background: #f8fafc; border: 1rpx solid #f0f0f0; flex-shrink: 0; margin-right: 20rpx;
}
.card-image { width: 100%; height: 100%; }
.card-image-empty { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; background: #f8fafc; }
.empty-img-icon { font-size: 56rpx; opacity: 0.3; }
.card-info-right { flex: 1; min-width: 0; }
.info-item { display: flex; align-items: center; margin-bottom: 8rpx; }
.info-label { font-size: 26rpx; color: #6b7280; flex-shrink: 0; }
.info-name { font-size: 30rpx; font-weight: 700; color: #0f172a; }
.info-value { font-size: 26rpx; color: #374151; }
.stock-highlight { font-size: 30rpx; font-weight: 700; color: #1f2937; }
.card-bottom { margin-top: 20rpx; padding-top: 20rpx; border-top: 1rpx solid #f0f0f0; }
.detail-row { display: flex; align-items: center; margin-bottom: 14rpx;
&:last-child { margin-bottom: 0; }
&.two-col { justify-content: space-between; }
}
.detail-col { display: flex; align-items: center; flex: 1; }
.detail-label { font-size: 24rpx; color: #9ca3af; flex-shrink: 0; }
.detail-value { font-size: 24rpx; color: #4b5563; }
.qty-input-card {
background: #fff; border-radius: 16rpx; padding: 24rpx; margin: 0 24rpx;
box-shadow: 0 4rpx 16rpx rgba(15, 23, 42, 0.04);
}
.form-field { display: flex; flex-direction: column; gap: 12rpx; }
.form-label { font-size: 26rpx; color: #4b5563; font-weight: 500; }
.form-input { width: 100%; height: 88rpx; padding: 0 24rpx; font-size: 28rpx; color: #374151; background: #f8fafc; border-radius: 14rpx; box-sizing: border-box; }
.form-suffix-text { display: block; margin-top: 10rpx; font-size: 24rpx; color: #9ca3af; }
.convert-row { margin-top: 20rpx; padding-top: 20rpx; border-top: 1rpx solid #f0f0f0; display: flex; align-items: center; }
.convert-label-inline { font-size: 26rpx; color: #6b7280; }
.convert-value-inline { font-size: 36rpx; font-weight: 700; color: #1f2937; margin-left: auto; }
.convert-unit-inline { font-size: 24rpx; color: #64748b; margin-left: 8rpx; }
.convert-formula-inline { margin-top: 10rpx; font-size: 22rpx; color: #9ca3af; }
.select-row-card {
position: relative; display: flex; align-items: center; justify-content: space-between;
background: #fff; border-radius: 16rpx; padding: 24rpx; margin: 0 24rpx 20rpx;
box-shadow: 0 4rpx 16rpx rgba(15, 23, 42, 0.04);
}
.full-dropdown { display: flex; align-items: center; justify-content: space-between; width: 100%; font-size: 28rpx; color: #374151;
.placeholder { color: #9ca3af; }
}
.warehouse-area-card { align-items: flex-start; }
.warehouse-area-rows { width: 100%; display: flex; flex-direction: column; gap: 16rpx; }
.warehouse-area-row { display: flex; align-items: center; }
.warehouse-area-label { width: 80rpx; font-size: 26rpx; color: #6b7280; flex-shrink: 0; }
.warehouse-area-dropdown { flex: 1; min-width: 0; position: relative; }
.dropdown-input { display: flex; align-items: center; height: 64rpx; 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; flex-shrink: 0; }
.dropdown-panel { position: absolute; top: 68rpx; left: 0; right: 0; z-index: 200; 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; 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; }
.dropdown-empty { padding: 32rpx; text-align: center; color: #999; 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: #ffffff; 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: #ffffff; }
</style>

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

@ -63,7 +63,7 @@ const selectedId = ref('')
const searchText = ref('') const searchText = ref('')
const userList = ref([]) const userList = ref([])
const loading = ref(false) const loading = ref(false)
const fromSource = ref('moldRepair') // moldRepair | sparepartInbound | sparepartOutbound | productInbound const fromSource = ref('moldRepair') // moldRepair | sparepartInbound | sparepartOutbound | materialInbound
let searchTimer = null let searchTimer = null
const pageTitle = computed(() => { const pageTitle = computed(() => {
@ -124,11 +124,7 @@ function handleConfirm() {
return return
} }
// 使 globalData key // 使 globalData key
const keyMap = { const keyMap = { sparepartInbound: '_sparepartInboundUserSelectResult', sparepartOutbound: '_sparepartOutboundUserSelectResult', materialInbound: '_materialInboundUserSelectResult' }
sparepartInbound: '_sparepartInboundUserSelectResult',
sparepartOutbound: '_sparepartOutboundUserSelectResult',
productInbound: '_productInboundUserSelectResult'
}
const key = keyMap[fromSource.value] || '_moldRepairUserSelectResult' const key = keyMap[fromSource.value] || '_moldRepairUserSelectResult'
getApp().globalData[key] = { getApp().globalData[key] = {
field: field.value === 'confirmBy' ? 'confirmBy' : 'acceptedBy', field: field.value === 'confirmBy' ? 'confirmBy' : 'acceptedBy',

@ -0,0 +1,480 @@
<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" @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>
</view>
</view>
<!-- 盘点项 -->
<view class="warehouse-area-row" v-if="selectedArea">
<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 v-if="loadingProducts" class="hint">...</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, onHide } 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 { createCheck } from '@/api/mes/sparepartCheck'
//
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(3)
function switchSourceType(type) {
sourceType.value = type
items.value = []
selectedProducts.value = []
selectedArea.value = null
}
//
const warehouseOptions = ref([])
const selectedWarehouse = ref(null)
//
const areaOptions = ref([])
const selectedArea = ref(null)
const showAreaDropdown = ref(false)
const loadingAreas = ref(false)
//
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 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 goSelectItems() {
getApp().globalData._checkItemSelectResult = null
uni.navigateTo({
url: `/pages_function/pages/sparepartCheck/itemSelect?warehouseId=${selectedWarehouse.value.value}&areaId=${selectedArea.value.value}`
})
}
//
function goSelectProduct() {
getApp().globalData._checkProductSelectResult = null
//
getApp().globalData._checkProductSelected = selectedProducts.value.length
? JSON.parse(JSON.stringify(selectedProducts.value))
: null
uni.navigateTo({
url: `/pages_function/pages/sparepartCheck/productSelect`
})
}
// productId
function goSelectItemsByProduct() {
if (!selectedProducts.value.length) return
getApp().globalData._checkItemSelectResult = null
const ids = selectedProducts.value.map(p => p.id).join(',')
uni.navigateTo({
url: `/pages_function/pages/sparepartCheck/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 createCheck({
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?._checkProductSelectResult
if (productResult && Array.isArray(productResult)) {
selectedProducts.value = productResult.map(p => ({
id: p.id,
name: p.name || '备件'
}))
items.value = [] //
getApp().globalData._checkProductSelectResult = 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)))
if (newItems.length) {
items.value = [...items.value, ...newItems]
}
getApp().globalData._checkItemSelectResult = null
}
})
onHide(() => {
showAreaDropdown.value = false
})
</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; }
}
.form-row-arrow { font-size: 20rpx; color: #999; }
.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; }
.hint { padding: 120rpx 0; text-align: center; color: #94a3b8; font-size: 28rpx; }
.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); }
.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; height: 64rpx; 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; 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; }
.dropdown-empty { padding: 32rpx; text-align: center; color: #999; font-size: 26rpx; }
/* 盘点项选择按钮 */
.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,414 @@
<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 { getSparepartCheckDetail, executeSparepartCheck } from '@/api/mes/sparepartCheck'
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 getSparepartCheckDetail(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 executeSparepartCheck(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,917 @@
<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)">
<!-- 审核通过status=10时显示 -->
<view v-if="Number(item.status) === 10" class="action-btn approve-btn" @click.stop="handleApprove(item)"></view>
<!-- 审核驳回status=10时显示 -->
<view v-if="Number(item.status) === 10" class="action-btn reject-btn" @click.stop="handleReject(item)"></view>
<!-- 提交status=0|1 checkStatus=1 -->
<view v-if="showSubmit(item)" class="action-btn submit-btn" @click.stop="openSubmitDialog(item)"></view>
<!-- 盘点checkStatus1 status20 -->
<view v-if="showCheck(item)" class="action-btn execute-btn" @click.stop="goExecute(item)"></view>
<!-- 删除status20 -->
<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 { getSparepartCheckPage, deleteSparepartCheck, submitSparepartCheck, auditSparepartCheck } from '@/api/mes/sparepartCheck'
import { getWarehouseSimpleList } from '@/api/mes/sparepart'
import { getSimpleUserList } from '@/api/mes/moldget'
const selectedStatus = ref('')
const searchKeyword = ref('')
const sparepartWarehouseId = 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 loadSparepartWarehouse() {
try {
const res = await getWarehouseSimpleList()
const data = Array.isArray(res) ? res : (Array.isArray(res?.data) ? res.data : [])
const sparepart = data.find((w) => (w.name || '').includes('备件'))
sparepartWarehouseId.value = sparepart ? String(sparepart.id) : ''
} catch (e) {
console.error('loadSparepartWarehouse 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: sparepartWarehouseId.value || undefined
}
const res = await getSparepartCheckPage(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/sparepartCheck/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 submitSparepartCheck({
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 auditSparepartCheck({ 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 auditSparepartCheck({ 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 handleSubmit(item) {
if (!item?.id) return
uni.showModal({
title: '确认',
content: '确认提交该盘点单?',
confirmColor: '#1d4ed8',
success: async (res) => {
if (res.confirm) {
try {
uni.showLoading({ title: '提交中...' })
await submitSparepartCheck({ id: item.id })
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 deleteSparepartCheck(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/sparepartCheck/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/sparepartCheck/create'
})
}
function clearSearchTimer() {
if (searchTimer) {
clearTimeout(searchTimer)
searchTimer = null
}
}
onShow(() => {
loadSparepartWarehouse()
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,347 @@
<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 { onLoad } from '@dcloudio/uni-app'
import NavBar from '@/components/common/NavBar.vue'
import { generateCheckItemsByLocation } from '@/api/mes/sparepartCheck'
const routeWarehouseId = ref('')
const routeAreaId = ref('')
onLoad((options) => {
routeWarehouseId.value = options?.warehouseId || ''
routeAreaId.value = options?.areaId || ''
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 isSelected(item) {
return selectedItems.value.some(s => String(s.productId || s.id) === String(item.productId || item.id))
}
function toggleSelect(item) {
const idx = selectedItems.value.findIndex(s => String(s.productId || s.id) === String(item.productId || item.id))
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: routeAreaId.value ? [Number(routeAreaId.value)] : undefined,
categoryType: 3,
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._checkItemSelectResult = [...selectedItems.value]
uni.navigateBack()
}
onLoad((options) => {
routeWarehouseId.value = options?.warehouseId || ''
routeAreaId.value = options?.areaId || ''
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 - 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,307 @@
<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 { onLoad } from '@dcloudio/uni-app'
import NavBar from '@/components/common/NavBar.vue'
import { generateCheckItemsByProduct } from '@/api/mes/sparepartCheck'
const routeProductId = ref('')
const list = ref([])
const selectedItems = ref([])
const loading = ref(false)
const keyword = ref('')
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 isSelected(item) {
return selectedItems.value.some(s =>
String(s.productId) === String(item.productId) && String(s.warehouseId) === String(item.warehouseId)
)
}
function toggleSelect(item) {
const idx = selectedItems.value.findIndex(s =>
String(s.productId) === String(item.productId) && String(s.warehouseId) === String(item.warehouseId)
)
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: 3,
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._checkItemSelectResult = [...selectedItems.value]
uni.navigateBack()
}
onLoad((options) => {
routeProductId.value = options?.productIds || options?.productId || ''
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,340 @@
<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 { getSparepartSimpleList } 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 {
// 使 getSparepartSimpleListcategoryType=3
const res = await getSparepartSimpleList(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._checkProductSelectResult = [...selectedItems.value]
uni.navigateBack()
}
onShow(() => {
// create
const prevSelected = getApp().globalData?._checkProductSelected
if (prevSelected && Array.isArray(prevSelected)) {
selectedItems.value = prevSelected
getApp().globalData._checkProductSelected = 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>

@ -67,22 +67,23 @@
<text class="section-title">附件</text> <text class="section-title">附件</text>
</view> </view>
<view class="attachment-area"> <view class="attachment-area">
<view class="attachment-list"> <view v-if="attachmentFileName" class="attachment-file-item">
<view v-for="(file, idx) in attachmentList" :key="idx" class="attachment-file-item"> <view class="file-icon">
<view class="file-icon"> <text class="file-icon-text">{{ getFileIcon(attachmentFileName) }}</text>
<text class="file-icon-text">{{ getFileIcon(file.name) }}</text> </view>
</view> <view class="file-info">
<view class="file-info"> <text class="file-name" :title="attachmentFileName">{{ attachmentFileName }}</text>
<text class="file-name" :title="file.name">{{ file.name }}</text> <text v-if="attachmentFileSize" class="file-size">{{ formatFileSize(attachmentFileSize) }}</text>
<text class="file-size">{{ formatFileSize(file.size) }}</text>
</view>
<view class="file-delete" @click="removeAttachment(idx)">
<text class="delete-icon-sm"></text>
</view>
</view> </view>
<view class="attachment-add-file" @click="handleAddAttachment"> <view v-if="uploadLoading" class="file-uploading">
<text class="add-text">选取文件</text> <text class="uploading-text">上传中...</text>
</view> </view>
<view v-else class="file-delete" @click="removeAttachment">
<text class="delete-icon-sm"></text>
</view>
</view>
<view class="attachment-add-file" @click="handleAddAttachment" v-if="!attachmentFileName">
<text class="add-text">选取文件</text>
</view> </view>
</view> </view>
</view> </view>
@ -143,6 +144,8 @@ import { useI18n } from 'vue-i18n'
import NavBar from '@/components/common/NavBar.vue' import NavBar from '@/components/common/NavBar.vue'
import { createSparepartInbound } from '@/api/mes/sparepartInbound' import { createSparepartInbound } from '@/api/mes/sparepartInbound'
import { getSparepartDetail } from '@/api/mes/sparepart' import { getSparepartDetail } from '@/api/mes/sparepart'
import { getBaseUrl } from '@/utils/request'
import { getToken } from '@/utils/auth'
const { t } = useI18n() const { t } = useI18n()
@ -208,8 +211,11 @@ const selectedOperatorName = ref('')
// //
const remark = ref('') const remark = ref('')
// // web limit=1
const attachmentList = ref([]) const fileUrl = ref('') // JSON: {"fileName":"xxx.pdf","fileUrl":"https://..."}
const attachmentFileName = ref('') //
const attachmentFileSize = ref(0) //
const uploadLoading = ref(false) //
function formatDate(date) { function formatDate(date) {
const y = date.getFullYear() const y = date.getFullYear()
@ -288,42 +294,130 @@ function formatFileSize(bytes) {
return (bytes / (1024 * 1024)).toFixed(1) + ' MB' return (bytes / (1024 * 1024)).toFixed(1) + ' MB'
} }
const ALLOWED_EXTS = ['png', 'jpg', 'jpeg', 'doc', 'xls', 'ppt', 'txt', 'pdf']
const MAX_FILE_SIZE = 100 * 1024 * 1024 // 100MB
function handleAddAttachment() { function handleAddAttachment() {
// #ifdef APP-PLUS // #ifdef APP-PLUS
// APP plus.gallery
plus.gallery.pick( plus.gallery.pick(
(res) => { (res) => {
const files = (res?.files || []).map(f => ({ const file = res?.files?.[0]
name: f.name || 'unknown', if (!file) return
size: f.size || 0, const ext = (file.name || '').split('.').pop()?.toLowerCase()
path: f // file if (!ALLOWED_EXTS.includes(ext)) {
})) uni.showToast({ title: '不支持的文件类型:.' + (ext || '未知'), icon: 'none' })
attachmentList.value.push(...files) return
}, }
(e) => { if (file.size > MAX_FILE_SIZE) {
console.log('选择文件失败:', e) uni.showToast({ title: '文件大小不能超过100MB', icon: 'none' })
return
}
uploadFile(file)
}, },
{ filter: 'all', multiple: true, maximum: 9 - attachmentList.value.length } (e) => { console.log('选择文件失败:', e) },
{ filter: 'all', multiple: false }
) )
// #endif // #endif
// #ifndef APP-PLUS // #ifndef APP-PLUS
// APP chooseImage // APP uni.chooseFile
uni.chooseImage({ uni.chooseFile({
count: 9 - attachmentList.value.length, count: 1,
sizeType: ['compressed'], type: 'all',
sourceType: ['album', 'camera'],
success: (res) => { success: (res) => {
res.tempFilePaths.forEach(path => { const tempFile = res.tempFiles?.[0]
const parts = path.split('/') if (!tempFile) return
const name = parts[parts.length - 1] || 'image.jpg' const ext = (tempFile.name || '').split('.').pop()?.toLowerCase()
attachmentList.value.push({ name, size: 0, path }) if (!ALLOWED_EXTS.includes(ext)) {
uni.showToast({ title: '不支持的文件类型:.' + (ext || '未知'), icon: 'none' })
return
}
if (tempFile.size > MAX_FILE_SIZE) {
uni.showToast({ title: '文件大小不能超过100MB', icon: 'none' })
return
}
uploadFile(tempFile)
},
fail: () => {
// chooseFile chooseImage
uni.chooseImage({
count: 1,
sizeType: ['compressed'],
sourceType: ['album', 'camera'],
success: (imgRes) => {
const path = imgRes.tempFilePaths?.[0]
if (!path) return
const parts = path.split('/')
const name = parts[parts.length - 1] || 'image.jpg'
uploadFile({ path, name, size: 0 })
}
}) })
} }
}) })
// #endif // #endif
} }
function removeAttachment(idx) { async function uploadFile(file) {
attachmentList.value.splice(idx, 1) uploadLoading.value = true
attachmentFileName.value = file.name || 'unknown'
attachmentFileSize.value = file.size || 0
// form-data
const formData = {
file: file.path // uni.uploadFile files
}
try {
const res = await new Promise((resolve, reject) => {
uni.uploadFile({
url: getBaseUrl() + '/admin-api/infra/file/upload',
filePath: file.path,
name: 'file',
header: {
'Authorization': 'Bearer ' + (getToken() || ''),
'tenantId': '1'
},
success: (uploadRes) => {
if (uploadRes.statusCode === 200) {
try {
const data = JSON.parse(uploadRes.data)
resolve(data)
} catch (e) {
reject(new Error('解析上传结果失败'))
}
} else {
reject(new Error('上传失败,状态码:' + uploadRes.statusCode))
}
},
fail: (err) => {
reject(err)
}
})
})
if (res.code === 0 && res.data) {
const { fileName, fileUrl: url } = res.data
fileUrl.value = JSON.stringify({ fileName: fileName || file.name, fileUrl: url })
attachmentFileName.value = fileName || file.name
uni.showToast({ title: '上传成功', icon: 'success' })
} else {
throw new Error(res.msg || '上传失败')
}
} catch (e) {
attachmentFileName.value = ''
attachmentFileSize.value = 0
fileUrl.value = ''
const msg = e?.message || '上传失败'
uni.showToast({ title: String(msg).substring(0, 50), icon: 'none' })
} finally {
uploadLoading.value = false
}
}
function removeAttachment() {
attachmentFileName.value = ''
attachmentFileSize.value = 0
fileUrl.value = ''
} }
async function handleSubmit() { async function handleSubmit() {
@ -373,9 +467,9 @@ async function handleSubmit() {
items: items items: items
} }
// // web JSON
if (attachmentList.value.length) { if (fileUrl.value) {
submitData.attachments = attachmentList.value.map(f => f.path || f) submitData.fileUrl = fileUrl.value
} }
console.log('提交数据:', JSON.stringify(submitData)) console.log('提交数据:', JSON.stringify(submitData))
@ -561,6 +655,10 @@ onHide(() => {})
flex-shrink: 0; flex-shrink: 0;
} }
.delete-icon-sm { font-size: 22rpx; color: #dc2626; } .delete-icon-sm { font-size: 22rpx; color: #dc2626; }
.file-uploading {
flex-shrink: 0;
.uploading-text { font-size: 22rpx; color: #2563eb; }
}
.attachment-add-file { .attachment-add-file {
display: flex; align-items: center; justify-content: center; gap: 10rpx; display: flex; align-items: center; justify-content: center; gap: 10rpx;

@ -14,12 +14,18 @@
@confirm="handleSearch" @confirm="handleSearch"
/> />
</view> </view>
<picker mode="selector" :range="statusLabels" :value="statusIndex" @change="onStatusChange"> <view class="status-box-wrapper">
<view class="status-box"> <view class="status-box" @click="toggleStatusDropdown">
<text class="status-box-text">{{ currentStatusLabel }}</text> <text class="status-box-text">{{ currentStatusLabel }}</text>
<uni-icons type="bottom" size="14" color="#9ca3af"></uni-icons> <uni-icons type="bottom" size="14" color="#9ca3af"></uni-icons>
</view> </view>
</picker> <view v-if="showStatusDropdown" class="status-dropdown-panel">
<view v-for="(item, idx) in statusOptions" :key="idx" class="status-dropdown-item" :class="{ active: selectedStatus === item.value }" @click.stop="selectStatus(item, idx)">
<text class="status-dropdown-item-text">{{ item.label }}</text>
<text v-if="selectedStatus === item.value" class="status-dropdown-check"></text>
</view>
</view>
</view>
<view class="reset-filter-btn" @click="resetFilters">{{ t('functionCommon.reset') }}</view> <view class="reset-filter-btn" @click="resetFilters">{{ t('functionCommon.reset') }}</view>
</view> </view>
@ -140,7 +146,7 @@
<script setup> <script setup>
import { computed, nextTick, ref } from 'vue' import { computed, nextTick, ref } from 'vue'
import { onShow, onUnload } from '@dcloudio/uni-app' import { onShow, onUnload, onHide } from '@dcloudio/uni-app'
import { useI18n } from 'vue-i18n' import { useI18n } from 'vue-i18n'
import NavBar from '@/components/common/NavBar.vue' import NavBar from '@/components/common/NavBar.vue'
import { getSparepartInboundPage, auditSparepartInbound, submitSparepartInbound } from '@/api/mes/sparepartInbound' import { getSparepartInboundPage, auditSparepartInbound, submitSparepartInbound } from '@/api/mes/sparepartInbound'
@ -150,19 +156,16 @@ const { t } = useI18n()
const selectedStatus = ref('') const selectedStatus = ref('')
const searchKeyword = ref('') const searchKeyword = ref('')
const showStatusDropdown = ref(false)
const statusOptions = computed(() => [ const statusOptions = computed(() => [
{ label: t('functionCommon.all'), value: '' }, { label: t('functionCommon.all'), value: '' },
{ label: t('sparepartInbound.tabPending'), value: '0' }, { label: t('sparepartInbound.tabPending'), value: '0' },
{ label: t('sparepartInbound.tabAuditing'), value: '10' }, { label: t('sparepartInbound.tabAuditing'), value: '10' },
{ label: t('sparepartInbound.approve'), value: '20' } { label: t('sparepartInbound.approve'), 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 currentStatusLabel = computed(() => {
const current = statusOptions.value.find((item) => item.value === selectedStatus.value) const current = statusOptions.value.find((item) => item.value === selectedStatus.value)
return current ? current.label : t('functionCommon.all') return current ? current.label : t('functionCommon.all')
@ -237,7 +240,7 @@ async function fetchList(reset) {
pageNo: pageNo.value, pageNo: pageNo.value,
pageSize: pageSize.value, pageSize: pageSize.value,
no: searchKeyword.value.trim() || undefined, no: searchKeyword.value.trim() || undefined,
status: selectedStatus.value || undefined statusList: selectedStatus.value !== '' ? [Number(selectedStatus.value)] : undefined
} }
const res = await getSparepartInboundPage(params) const res = await getSparepartInboundPage(params)
const page = normalizePageData(res) const page = normalizePageData(res)
@ -252,9 +255,13 @@ async function fetchList(reset) {
} }
} }
function onStatusChange(event) { function toggleStatusDropdown() {
const index = Number(event?.detail?.value || 0) showStatusDropdown.value = !showStatusDropdown.value
selectedStatus.value = statusOptions.value[index]?.value ?? '' }
function selectStatus(item, _idx) {
selectedStatus.value = item.value
showStatusDropdown.value = false
fetchList(true) fetchList(true)
} }
@ -431,6 +438,10 @@ onShow(() => {
onUnload(() => { onUnload(() => {
clearSearchTimer() clearSearchTimer()
}) })
onHide(() => {
showStatusDropdown.value = false
})
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
@ -466,8 +477,12 @@ onUnload(() => {
color: #374151; color: #374151;
} }
.status-box { .status-box-wrapper {
position: relative;
flex-shrink: 0; flex-shrink: 0;
}
.status-box {
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: space-between; justify-content: space-between;
@ -479,6 +494,46 @@ onUnload(() => {
border-radius: 12rpx; border-radius: 12rpx;
} }
.status-dropdown-panel {
position: absolute;
top: 74rpx;
left: 0;
right: 0;
z-index: 200;
background: #fff;
border: 1rpx solid #e0e0e0;
border-radius: 12rpx;
box-shadow: 0 8rpx 30rpx rgba(0, 0, 0, 0.12);
overflow: hidden;
}
.status-dropdown-item {
display: flex;
align-items: center;
justify-content: space-between;
padding: 18rpx 24rpx;
border-bottom: 1rpx solid #f0f0f0;
&:last-child {
border-bottom: 0;
}
&.active {
background: #f0f5ff;
}
}
.status-dropdown-item-text {
font-size: 26rpx;
color: #374151;
}
.status-dropdown-check {
font-size: 26rpx;
color: #2563eb;
font-weight: 700;
}
.status-box-text { .status-box-text {
font-size: 24rpx; font-size: 24rpx;
color: #374151; color: #374151;

@ -61,29 +61,12 @@
</view> </view>
<view class="select-row-card warehouse-area-card"> <view class="select-row-card warehouse-area-card">
<view class="warehouse-area-rows"> <view class="warehouse-area-rows">
<!-- 仓库固定为备件仓不可选 -->
<view class="warehouse-area-row"> <view class="warehouse-area-row">
<text class="warehouse-area-label">仓库</text> <text class="warehouse-area-label">仓库</text>
<view class="warehouse-area-dropdown" @click="toggleWarehouseDropdown"> <view class="warehouse-area-dropdown">
<view class="dropdown-input"> <view class="dropdown-input">
<text :class="['dropdown-value', { placeholder: !selectedWarehouse }]"> <text class="dropdown-value">备件仓</text>
{{ selectedWarehouse ? selectedWarehouse.label : '请选择' }}
</text>
<text class="dropdown-arrow"></text>
</view>
<view v-if="showWarehouseDropdown" class="dropdown-panel">
<view class="dropdown-scroll">
<view
v-for="item in warehouseOptions"
:key="item.value"
class="dropdown-item"
:class="{ active: selectedWarehouse?.value === item.value }"
@click.stop="handleSelectWarehouse(item)"
>
<text class="dropdown-item-text">{{ item.label }}</text>
<text v-if="selectedWarehouse?.value === item.value" class="dropdown-check"></text>
</view>
<view v-if="!warehouseOptions.length" class="dropdown-empty"></view>
</view>
</view> </view>
</view> </view>
</view> </view>
@ -176,10 +159,9 @@ const inboundQty = ref(null)
const supplierId = ref(undefined) const supplierId = ref(undefined)
const supplierName = ref('') const supplierName = ref('')
// //
const warehouseOptions = ref([]) const warehouseOptions = ref([])
const selectedWarehouse = ref(null) const selectedWarehouse = ref(null)
const showWarehouseDropdown = ref(false)
// //
const areaOptions = ref([]) const areaOptions = ref([])
@ -287,16 +269,6 @@ function handleConfirm() {
} }
// //
function toggleWarehouseDropdown() {
showWarehouseDropdown.value = !showWarehouseDropdown.value
}
function handleSelectWarehouse(item) {
selectedWarehouse.value = item
showWarehouseDropdown.value = false
selectedArea.value = null
areaOptions.value = []
loadAreas(item.value)
}
async function loadWarehouses() { async function loadWarehouses() {
try { try {
const res = await getWarehouseSimpleList() const res = await getWarehouseSimpleList()
@ -305,6 +277,11 @@ async function loadWarehouses() {
value: w.id, value: w.id,
label: w.name || String(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) { } catch (e) {
console.error('loadWarehouses error', e) console.error('loadWarehouses error', e)
} }
@ -377,7 +354,6 @@ async function loadStockCount() {
} }
onHide(() => { onHide(() => {
showWarehouseDropdown.value = false
showAreaDropdown.value = false showAreaDropdown.value = false
}) })
</script> </script>

@ -15,8 +15,8 @@
@confirm="onScanInputConfirm" @confirm="onScanInputConfirm"
/> />
</view> </view>
<view class="warehouse-box" @click="openWarehousePicker"> <view class="area-box" @click="openAreaPicker">
<text class="warehouse-box-text">{{ selectedWarehouseLabel || t('sparepartInventory.allWarehouse') }}</text> <text class="area-box-text">{{ selectedAreaLabel || t('sparepartInventory.allArea') }}</text>
<uni-icons type="bottom" size="14" color="#9ca3af"></uni-icons> <uni-icons type="bottom" size="14" color="#9ca3af"></uni-icons>
</view> </view>
<view class="reset-filter-btn" @click="resetFilters">{{ t('functionCommon.reset') }}</view> <view class="reset-filter-btn" @click="resetFilters">{{ t('functionCommon.reset') }}</view>
@ -86,23 +86,23 @@
<sv-focus-no-keyboard ref="focusNoKeyboardRef"></sv-focus-no-keyboard> <sv-focus-no-keyboard ref="focusNoKeyboardRef"></sv-focus-no-keyboard>
<uni-popup ref="warehousePickerRef" type="bottom" background-color="#fff"> <uni-popup ref="areaPickerRef" type="bottom" background-color="#fff">
<view class="picker-content"> <view class="picker-content">
<view class="picker-header"> <view class="picker-header">
<text class="picker-title">{{ t('sparepartInventory.warehousePlaceholder') }}</text> <text class="picker-title">{{ t('sparepartInventory.areaPlaceholder') }}</text>
<view class="picker-clear" @click="resetWarehouse"> <view class="picker-clear" @click="resetArea">
<text class="picker-clear-text">{{ t('functionCommon.reset') }}</text> <text class="picker-clear-text">{{ t('functionCommon.reset') }}</text>
</view> </view>
</view> </view>
<scroll-view scroll-y class="picker-list"> <scroll-view scroll-y class="picker-list">
<view <view
v-for="item in warehouseOptions" v-for="item in areaOptions"
:key="String(item.value)" :key="String(item.value)"
class="picker-item" class="picker-item"
@click="selectWarehouse(item)" @click="selectArea(item)"
> >
<text class="picker-text">{{ item.label }}</text> <text class="picker-text">{{ item.label }}</text>
<text v-if="selectedWarehouse === item.value" class="picker-check"></text> <text v-if="selectedArea === item.value" class="picker-check"></text>
</view> </view>
</scroll-view> </scroll-view>
</view> </view>
@ -115,10 +115,11 @@ import { ref, computed, nextTick } from 'vue'
import { onLoad, onReady } from '@dcloudio/uni-app' import { onLoad, onReady } from '@dcloudio/uni-app'
import { useI18n } from 'vue-i18n' import { useI18n } from 'vue-i18n'
import NavBar from '@/components/common/NavBar.vue' import NavBar from '@/components/common/NavBar.vue'
import { getSparepartInventoryPage, getWarehouseSimpleList } from '@/api/mes/sparepart' import { getSparepartInventoryPage } from '@/api/mes/sparepart'
import { getWarehousePage, getWarehouseAreaSimpleList } from '@/api/mes/moldget'
const { t } = useI18n() const { t } = useI18n()
const warehousePickerRef = ref(null) const areaPickerRef = ref(null)
const list = ref([]) const list = ref([])
const loading = ref(false) const loading = ref(false)
@ -128,9 +129,10 @@ const pageNo = ref(1)
const pageSize = ref(10) const pageSize = ref(10)
const total = ref(0) const total = ref(0)
const searchKeyword = ref('') const searchKeyword = ref('')
const selectedWarehouse = ref('') const selectedArea = ref('')
const warehouseOptions = ref([]) const areaOptions = ref([])
const sparepartWarehouseId = ref(null)
// //
const focusNoKeyboardRef = ref(null) const focusNoKeyboardRef = ref(null)
@ -144,13 +146,13 @@ function focusKeywordNoKeyboard() {
}) })
} }
const selectedWarehouseLabel = computed(() => { const selectedAreaLabel = computed(() => {
const current = warehouseOptions.value.find((item) => item.value === selectedWarehouse.value) const current = areaOptions.value.find((item) => item.value === selectedArea.value)
return current ? current.label : '' return current ? current.label : ''
}) })
onLoad(async () => { onLoad(async () => {
await loadWarehouseList() await loadWarehouseThenAreas()
await fetchList(true) await fetchList(true)
}) })
@ -158,23 +160,30 @@ onReady(() => {
focusKeywordNoKeyboard() focusKeywordNoKeyboard()
}) })
async function loadWarehouseList() { async function loadWarehouseThenAreas() {
try { try {
const res = await getWarehouseSimpleList() // categoryType=3
const data = Array.isArray(res) ? res : (Array.isArray(res?.data) ? res.data : []) const whRes = await getWarehousePage({ pageNo: 1, pageSize: 1, categoryType: 3 })
warehouseOptions.value = data.map((w) => ({ const whData = Array.isArray(whRes) ? whRes : (Array.isArray(whRes?.data) ? whRes.data : (Array.isArray(whRes?.data?.list) ? whRes.data.list : []))
value: String(w.id), if (whData.length) {
label: w.name || w.warehouseName || String(w.id) sparepartWarehouseId.value = whData[0].id
})) //
const areaRes = await getWarehouseAreaSimpleList(sparepartWarehouseId.value)
const areaData = Array.isArray(areaRes) ? areaRes : (Array.isArray(areaRes?.data) ? areaRes.data : [])
areaOptions.value = areaData.map((a) => ({
value: String(a.id),
label: a.name || a.areaName || String(a.id)
}))
}
} catch (e) { } catch (e) {
console.error('loadWarehouseList error', e) console.error('loadWarehouseThenAreas error', e)
} }
} }
// //
const allList = ref([]) const allList = ref([])
async function fetchAllForSearch(warehouseId) { async function fetchAllForSearch(areaId) {
const all = [] const all = []
let currentPage = 1 let currentPage = 1
const maxPage = 10 // 10 const maxPage = 10 // 10
@ -183,7 +192,7 @@ async function fetchAllForSearch(warehouseId) {
pageNo: currentPage, pageNo: currentPage,
pageSize: 100, pageSize: 100,
categoryType: 3, categoryType: 3,
warehouseId: warehouseId || undefined areaId: areaId || undefined
}) })
const page = normalizePageData(res) const page = normalizePageData(res)
all.push(...page.list) all.push(...page.list)
@ -208,7 +217,7 @@ async function fetchList(reset) {
if (keyword && reset) { if (keyword && reset) {
// //
const allData = await fetchAllForSearch(selectedWarehouse.value) const allData = await fetchAllForSearch(selectedArea.value)
allList.value = allData allList.value = allData
// ID PRODUCTMATERIAL-330 // ID PRODUCTMATERIAL-330
const scanMatch = keyword.match(/(?:productmaterial|spare|material|product)[-_](\d+)/i) const scanMatch = keyword.match(/(?:productmaterial|spare|material|product)[-_](\d+)/i)
@ -232,7 +241,7 @@ async function fetchList(reset) {
pageNo: pageNo.value, pageNo: pageNo.value,
pageSize: pageSize.value, pageSize: pageSize.value,
categoryType: 3, categoryType: 3,
warehouseId: selectedWarehouse.value || undefined areaId: selectedArea.value || undefined
}) })
const page = normalizePageData(res) const page = normalizePageData(res)
total.value = page.total total.value = page.total
@ -270,7 +279,7 @@ async function onScanInputConfirm() {
async function resetFilters() { async function resetFilters() {
searchKeyword.value = '' searchKeyword.value = ''
selectedWarehouse.value = '' selectedArea.value = ''
allList.value = [] allList.value = []
// //
pageNo.value = 1 pageNo.value = 1
@ -278,22 +287,22 @@ async function resetFilters() {
await fetchList(true) await fetchList(true)
} }
function openWarehousePicker() { function openAreaPicker() {
warehousePickerRef.value?.open() areaPickerRef.value?.open()
} }
async function selectWarehouse(item) { async function selectArea(item) {
selectedWarehouse.value = item.value selectedArea.value = item.value
warehousePickerRef.value?.close() areaPickerRef.value?.close()
allList.value = [] allList.value = []
pageNo.value = 1 pageNo.value = 1
finished.value = false finished.value = false
await fetchList(true) await fetchList(true)
} }
async function resetWarehouse() { async function resetArea() {
selectedWarehouse.value = '' selectedArea.value = ''
warehousePickerRef.value?.close() areaPickerRef.value?.close()
allList.value = [] allList.value = []
pageNo.value = 1 pageNo.value = 1
finished.value = false finished.value = false
@ -385,7 +394,7 @@ function formatDateTime(value) {
color: #9ca3af; color: #9ca3af;
} }
.warehouse-box { .area-box {
flex-shrink: 0; flex-shrink: 0;
display: flex; display: flex;
align-items: center; align-items: center;
@ -399,7 +408,7 @@ function formatDateTime(value) {
box-sizing: border-box; box-sizing: border-box;
} }
.warehouse-box-text { .area-box-text {
color: #374151; color: #374151;
font-size: 26rpx; font-size: 26rpx;
max-width: 110rpx; max-width: 110rpx;

@ -58,19 +58,24 @@
<text class="section-title">附件</text> <text class="section-title">附件</text>
</view> </view>
<view class="attachment-area"> <view class="attachment-area">
<view class="attachment-list"> <view v-if="attachmentFileName" class="attachment-file-item">
<view v-for="(file, idx) in attachmentList" :key="idx" class="attachment-file-item"> <view class="file-icon">
<view class="file-icon"><text class="file-icon-text">{{ getFileIcon(file.name) }}</text></view> <text class="file-icon-text">{{ getFileIcon(attachmentFileName) }}</text>
<view class="file-info"> </view>
<text class="file-name">{{ file.name }}</text> <view class="file-info">
<text class="file-size">{{ formatFileSize(file.size) }}</text> <text class="file-name" :title="attachmentFileName">{{ attachmentFileName }}</text>
</view> <text v-if="attachmentFileSize" class="file-size">{{ formatFileSize(attachmentFileSize) }}</text>
<view class="file-delete" @click="removeAttachment(idx)"><text class="delete-icon-sm"></text></view> </view>
<view v-if="uploadLoading" class="file-uploading">
<text class="uploading-text">上传中...</text>
</view> </view>
<view class="attachment-add-file" @click="handleAddAttachment"> <view v-else class="file-delete" @click="removeAttachment">
<text class="add-text">选取文件</text> <text class="delete-icon-sm"></text>
</view> </view>
</view> </view>
<view class="attachment-add-file" @click="handleAddAttachment" v-if="!attachmentFileName">
<text class="add-text">选取文件</text>
</view>
</view> </view>
</view> </view>
@ -121,6 +126,8 @@ import { useI18n } from 'vue-i18n'
import NavBar from '@/components/common/NavBar.vue' import NavBar from '@/components/common/NavBar.vue'
import { createSparepartOutbound } from '@/api/mes/sparepartOutbound' import { createSparepartOutbound } from '@/api/mes/sparepartOutbound'
import { getSparepartDetail } from '@/api/mes/sparepart' import { getSparepartDetail } from '@/api/mes/sparepart'
import { getBaseUrl } from '@/utils/request'
import { getToken } from '@/utils/auth'
const { t } = useI18n() const { t } = useI18n()
@ -129,7 +136,11 @@ const outboundDate = ref(formatDate(new Date()))
const selectedOperatorId = ref(null) const selectedOperatorId = ref(null)
const selectedOperatorName = ref('') const selectedOperatorName = ref('')
const remark = ref('') const remark = ref('')
const attachmentList = ref([]) //
const fileUrl = ref('')
const attachmentFileName = ref('')
const attachmentFileSize = ref(0)
const uploadLoading = ref(false)
function formatDate(date) { const y = date.getFullYear(); const m = String(date.getMonth() + 1).padStart(2, '0'); const d = String(date.getDate()).padStart(2, '0'); return `${y}-${m}-${d}` } function formatDate(date) { const y = date.getFullYear(); const m = String(date.getMonth() + 1).padStart(2, '0'); const d = String(date.getDate()).padStart(2, '0'); return `${y}-${m}-${d}` }
function handleDateChange(e) { outboundDate.value = e.detail.value } function handleDateChange(e) { outboundDate.value = e.detail.value }
@ -202,17 +213,101 @@ function goSelectOperator() {
} }
// //
function getFileIcon(fileName) { const ext = (fileName || '').split('.').pop()?.toLowerCase(); const m = { pdf: '📄', doc: '📝', docx: '📝', xls: '📊', xlsx: '📊', ppt: '📽', pptx: '📽', txt: '📃', zip: '📦', rar: '📦', jpg: '🖼', jpeg: '🖼', png: '🖼', gif: '🖼' }; return m[ext] || '📎' } function getFileIcon(fileName) {
function formatFileSize(bytes) { if (!bytes) return '0 B'; if (bytes < 1024) return bytes + ' B'; if (bytes < 1048576) return (bytes / 1024).toFixed(1) + ' KB'; return (bytes / 1048576).toFixed(1) + ' MB' } const ext = (fileName || '').split('.').pop()?.toLowerCase()
const iconMap = { pdf: '📄', doc: '📝', docx: '📝', xls: '📊', xlsx: '📊', ppt: '📽', pptx: '📽', txt: '📃', zip: '📦', rar: '📦', jpg: '🖼', jpeg: '🖼', png: '🖼', gif: '🖼', webp: '🖼' }
return iconMap[ext] || '📎'
}
function formatFileSize(bytes) {
if (!bytes) return '0 B'
if (bytes < 1024) return bytes + ' B'
if (bytes < 1048576) return (bytes / 1024).toFixed(1) + ' KB'
return (bytes / 1048576).toFixed(1) + ' MB'
}
const ALLOWED_EXTS = ['png', 'jpg', 'jpeg', 'doc', 'xls', 'ppt', 'txt', 'pdf']
const MAX_FILE_SIZE = 100 * 1024 * 1024
function handleAddAttachment() { function handleAddAttachment() {
// #ifdef APP-PLUS // #ifdef APP-PLUS
plus.gallery.pick((res) => { const files = (res?.files || []).map(f => ({ name: f.name || 'unknown', size: f.size || 0, path: f })); attachmentList.value.push(...files) }, (e) => {}, { filter: 'all', multiple: true, maximum: 9 - attachmentList.value.length }) plus.gallery.pick(
(res) => {
const file = res?.files?.[0]
if (!file) return
const ext = (file.name || '').split('.').pop()?.toLowerCase()
if (!ALLOWED_EXTS.includes(ext)) { uni.showToast({ title: '不支持的文件类型:.' + (ext || '未知'), icon: 'none' }); return }
if (file.size > MAX_FILE_SIZE) { uni.showToast({ title: '文件大小不能超过100MB', icon: 'none' }); return }
uploadFile(file)
},
(e) => { console.log('选择文件失败:', e) },
{ filter: 'all', multiple: false }
)
// #endif // #endif
// #ifndef APP-PLUS // #ifndef APP-PLUS
uni.chooseImage({ count: 9 - attachmentList.value.length, sizeType: ['compressed'], sourceType: ['album', 'camera'], success: (res) => { res.tempFilePaths.forEach(path => { const parts = path.split('/'); const name = parts[parts.length - 1] || 'image.jpg'; attachmentList.value.push({ name, size: 0, path }) }) } }) uni.chooseFile({
count: 1, type: 'all',
success: (res) => {
const tempFile = res.tempFiles?.[0]
if (!tempFile) return
const ext = (tempFile.name || '').split('.').pop()?.toLowerCase()
if (!ALLOWED_EXTS.includes(ext)) { uni.showToast({ title: '不支持的文件类型:.' + (ext || '未知'), icon: 'none' }); return }
if (tempFile.size > MAX_FILE_SIZE) { uni.showToast({ title: '文件大小不能超过100MB', icon: 'none' }); return }
uploadFile(tempFile)
},
fail: () => {
uni.chooseImage({
count: 1, sizeType: ['compressed'], sourceType: ['album', 'camera'],
success: (imgRes) => {
const path = imgRes.tempFilePaths?.[0]
if (!path) return
const parts = path.split('/')
uploadFile({ path, name: parts[parts.length - 1] || 'image.jpg', size: 0 })
}
})
}
})
// #endif // #endif
} }
function removeAttachment(idx) { attachmentList.value.splice(idx, 1) }
async function uploadFile(file) {
uploadLoading.value = true
attachmentFileName.value = file.name || 'unknown'
attachmentFileSize.value = file.size || 0
try {
const res = await new Promise((resolve, reject) => {
uni.uploadFile({
url: getBaseUrl() + '/admin-api/infra/file/upload',
filePath: file.path,
name: 'file',
header: { 'Authorization': 'Bearer ' + (getToken() || ''), 'tenantId': '1' },
success: (uploadRes) => {
if (uploadRes.statusCode === 200) {
try { resolve(JSON.parse(uploadRes.data)) }
catch (e) { reject(new Error('解析上传结果失败')) }
} else { reject(new Error('上传失败,状态码:' + uploadRes.statusCode)) }
},
fail: (err) => { reject(err) }
})
})
if (res.code === 0 && res.data) {
const { fileName, fileUrl: url } = res.data
fileUrl.value = JSON.stringify({ fileName: fileName || file.name, fileUrl: url })
attachmentFileName.value = fileName || file.name
uni.showToast({ title: '上传成功', icon: 'success' })
} else {
throw new Error(res.msg || '上传失败')
}
} catch (e) {
attachmentFileName.value = ''; attachmentFileSize.value = 0; fileUrl.value = ''
uni.showToast({ title: String(e?.message || '上传失败').substring(0, 50), icon: 'none' })
} finally {
uploadLoading.value = false
}
}
function removeAttachment() {
attachmentFileName.value = ''; attachmentFileSize.value = 0; fileUrl.value = ''
}
async function handleSubmit() { async function handleSubmit() {
if (!itemList.value.length) { uni.showToast({ title: '请先添加备件', icon: 'none' }); return } if (!itemList.value.length) { uni.showToast({ title: '请先添加备件', icon: 'none' }); return }
@ -250,7 +345,7 @@ async function handleSubmit() {
items: items items: items
} }
if (attachmentList.value.length) { submitData.fileUrl = String(attachmentList.value[0]?.path || '') } if (fileUrl.value) { submitData.fileUrl = fileUrl.value }
console.log('=== 出库提交 ===') console.log('=== 出库提交 ===')
console.log(JSON.stringify(submitData)) console.log(JSON.stringify(submitData))
@ -312,6 +407,7 @@ onHide(() => {})
.file-size { font-size: 22rpx; color: #9ca3af; margin-top: 4rpx; display: block; } .file-size { font-size: 22rpx; color: #9ca3af; margin-top: 4rpx; display: block; }
.file-delete { width: 48rpx; height: 48rpx; border-radius: 24rpx; background: #fee2e2; display: flex; align-items: center; justify-content: center; flex-shrink: 0; } .file-delete { width: 48rpx; height: 48rpx; border-radius: 24rpx; background: #fee2e2; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.delete-icon-sm { font-size: 22rpx; color: #dc2626; } .delete-icon-sm { font-size: 22rpx; color: #dc2626; }
.file-uploading { flex-shrink: 0; .uploading-text { font-size: 22rpx; color: #2563eb; } }
.attachment-add-file { display: flex; align-items: center; justify-content: center; height: 88rpx; background: #fff; border: 2rpx dashed #cbd5e1; border-radius: 12rpx; } .attachment-add-file { display: flex; align-items: center; justify-content: center; height: 88rpx; background: #fff; border: 2rpx dashed #cbd5e1; border-radius: 12rpx; }
.add-text { font-size: 26rpx; color: #6b7280; } .add-text { font-size: 26rpx; color: #6b7280; }

@ -6,9 +6,15 @@
<view class="keyword-box"> <view class="keyword-box">
<input v-model="searchKeyword" class="keyword-input" :placeholder="t('sparepartOutbound.searchPlaceholder')" confirm-type="search" @input="handleKeywordInput" @confirm="handleSearch" /> <input v-model="searchKeyword" class="keyword-input" :placeholder="t('sparepartOutbound.searchPlaceholder')" confirm-type="search" @input="handleKeywordInput" @confirm="handleSearch" />
</view> </view>
<picker mode="selector" :range="statusLabels" :value="statusIndex" @change="onStatusChange"> <view class="status-box-wrapper">
<view class="status-box"><text class="status-box-text">{{ currentStatusLabel }}</text><uni-icons type="bottom" size="14" color="#9ca3af"></uni-icons></view> <view class="status-box" @click="toggleStatusDropdown"><text class="status-box-text">{{ currentStatusLabel }}</text><uni-icons type="bottom" size="14" color="#9ca3af"></uni-icons></view>
</picker> <view v-if="showStatusDropdown" class="status-dropdown-panel">
<view v-for="(item, idx) in statusOptions" :key="idx" class="status-dropdown-item" :class="{ active: selectedStatus === item.value }" @click.stop="selectStatus(item, idx)">
<text class="status-dropdown-item-text">{{ item.label }}</text>
<text v-if="selectedStatus === item.value" class="status-dropdown-check"></text>
</view>
</view>
</view>
<view class="reset-filter-btn" @click="resetFilters">{{ t('functionCommon.reset') }}</view> <view class="reset-filter-btn" @click="resetFilters">{{ t('functionCommon.reset') }}</view>
</view> </view>
@ -83,7 +89,7 @@
<script setup> <script setup>
import { computed, ref } from 'vue' import { computed, ref } from 'vue'
import { onShow, onUnload } from '@dcloudio/uni-app' import { onShow, onUnload, onHide } from '@dcloudio/uni-app'
import { useI18n } from 'vue-i18n' import { useI18n } from 'vue-i18n'
import NavBar from '@/components/common/NavBar.vue' import NavBar from '@/components/common/NavBar.vue'
import { getSparepartOutboundPage, auditSparepartOutbound, submitSparepartOutbound } from '@/api/mes/sparepartOutbound' import { getSparepartOutboundPage, auditSparepartOutbound, submitSparepartOutbound } from '@/api/mes/sparepartOutbound'
@ -93,14 +99,14 @@ const { t } = useI18n()
const selectedStatus = ref('') const selectedStatus = ref('')
const searchKeyword = ref('') const searchKeyword = ref('')
const showStatusDropdown = ref(false)
const statusOptions = computed(() => [ const statusOptions = computed(() => [
{ label: t('functionCommon.all'), value: '' }, { label: t('functionCommon.all'), value: '' },
{ label: t('sparepartOutbound.tabPending'), value: '0' }, { label: t('sparepartOutbound.tabPending'), value: '0' },
{ label: t('sparepartOutbound.tabAuditing'), value: '10' }, { label: t('sparepartOutbound.tabAuditing'), value: '10' },
{ label: t('sparepartOutbound.approve'), value: '20' } { label: t('sparepartOutbound.approve'), value: '20' },
{ label: '已驳回', value: '1' }
]) ])
const statusLabels = computed(() => statusOptions.value.map(i => i.label))
const statusIndex = computed(() => { const idx = statusOptions.value.findIndex(i => i.value === selectedStatus.value); return idx >= 0 ? idx : 0 })
const currentStatusLabel = computed(() => { const cur = statusOptions.value.find(i => i.value === selectedStatus.value); return cur ? cur.label : t('functionCommon.all') }) const currentStatusLabel = computed(() => { const cur = statusOptions.value.find(i => i.value === selectedStatus.value); return cur ? cur.label : t('functionCommon.all') })
const list = ref([]) const list = ref([])
const loading = ref(false) const loading = ref(false)
@ -142,7 +148,7 @@ async function fetchList(reset) {
if (reset) { pageNo.value = 1; finished.value = false } if (reset) { pageNo.value = 1; finished.value = false }
if (pageNo.value === 1) loading.value = true; else loadingMore.value = true if (pageNo.value === 1) loading.value = true; else loadingMore.value = true
try { try {
const params = { pageNo: pageNo.value, pageSize: pageSize.value, no: searchKeyword.value.trim() || undefined, status: selectedStatus.value || undefined } const params = { pageNo: pageNo.value, pageSize: pageSize.value, no: searchKeyword.value.trim() || undefined, statusList: selectedStatus.value !== '' ? [Number(selectedStatus.value)] : undefined }
const res = await getSparepartOutboundPage(params) const res = await getSparepartOutboundPage(params)
const page = normalizePageData(res) const page = normalizePageData(res)
list.value = reset ? page.list : [...list.value, ...page.list] list.value = reset ? page.list : [...list.value, ...page.list]
@ -151,7 +157,8 @@ async function fetchList(reset) {
finally { loading.value = false; loadingMore.value = false } finally { loading.value = false; loadingMore.value = false }
} }
function onStatusChange(e) { const idx = Number(e?.detail?.value || 0); selectedStatus.value = statusOptions.value[idx]?.value ?? ''; fetchList(true) } function toggleStatusDropdown() { showStatusDropdown.value = !showStatusDropdown.value }
function selectStatus(item, _idx) { selectedStatus.value = item.value; showStatusDropdown.value = false; fetchList(true) }
function handleSearch() { clearSearchTimer(); uni.hideKeyboard(); fetchList(true) } function handleSearch() { clearSearchTimer(); uni.hideKeyboard(); fetchList(true) }
function handleKeywordInput() { clearSearchTimer(); searchTimer = setTimeout(() => fetchList(true), 300) } function handleKeywordInput() { clearSearchTimer(); searchTimer = setTimeout(() => fetchList(true), 300) }
function resetFilters() { clearSearchTimer(); searchKeyword.value = ''; selectedStatus.value = ''; fetchList(true) } function resetFilters() { clearSearchTimer(); searchKeyword.value = ''; selectedStatus.value = ''; fetchList(true) }
@ -198,6 +205,7 @@ function clearSearchTimer() { if (searchTimer) { clearTimeout(searchTimer); sear
onShow(() => { fetchList(true) }) onShow(() => { fetchList(true) })
onUnload(() => { clearSearchTimer() }) onUnload(() => { clearSearchTimer() })
onHide(() => { showStatusDropdown.value = false })
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
@ -205,7 +213,12 @@ onUnload(() => { clearSearchTimer() })
.filter-bar { display: flex; align-items: center; gap: 12rpx; padding: 18rpx 24rpx; background: #fff; } .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-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; } .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-wrapper { position: relative; flex-shrink: 0; }
.status-box { 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-dropdown-panel { position: absolute; top: 74rpx; left: 0; right: 0; z-index: 200; background: #fff; border: 1rpx solid #e0e0e0; border-radius: 12rpx; box-shadow: 0 8rpx 30rpx rgba(0,0,0,0.12); overflow: hidden; }
.status-dropdown-item { display: flex; align-items: center; justify-content: space-between; padding: 18rpx 24rpx; border-bottom: 1rpx solid #f0f0f0; &:last-child { border-bottom: 0; } &.active { background: #f0f5ff; } }
.status-dropdown-item-text { font-size: 26rpx; color: #374151; }
.status-dropdown-check { font-size: 26rpx; color: #2563eb; font-weight: 700; }
.status-box-text { font-size: 24rpx; color: #374151; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .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; } .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; }

@ -100,20 +100,12 @@
</view> </view>
<view class="select-row-card warehouse-area-card"> <view class="select-row-card warehouse-area-card">
<view class="warehouse-area-rows"> <view class="warehouse-area-rows">
<!-- 仓库固定为备件仓不可选 -->
<view class="warehouse-area-row"> <view class="warehouse-area-row">
<text class="warehouse-area-label">仓库</text> <text class="warehouse-area-label">仓库</text>
<view class="warehouse-area-dropdown" @click="toggleWarehouseDropdown"> <view class="warehouse-area-dropdown">
<view class="dropdown-input"> <view class="dropdown-input">
<text :class="['dropdown-value', { placeholder: !selectedWarehouse }]">{{ selectedWarehouse ? selectedWarehouse.label : '请选择' }}</text> <text class="dropdown-value">备件仓</text>
<text class="dropdown-arrow"></text>
</view>
<view v-if="showWarehouseDropdown" class="dropdown-panel">
<view class="dropdown-scroll">
<view v-for="item in warehouseOptions" :key="item.value" class="dropdown-item" :class="{ active: selectedWarehouse?.value === item.value }" @click.stop="handleSelectWarehouse(item)">
<text class="dropdown-item-text">{{ item.label }}</text>
<text v-if="selectedWarehouse?.value === item.value" class="dropdown-check"></text>
</view>
</view>
</view> </view>
</view> </view>
</view> </view>
@ -228,7 +220,6 @@ const currentOrderOptions = computed(() => selectedPurpose.value === 'repair' ?
const warehouseOptions = ref([]) const warehouseOptions = ref([])
const selectedWarehouse = ref(null) const selectedWarehouse = ref(null)
const showWarehouseDropdown = ref(false)
const areaOptions = ref([]) const areaOptions = ref([])
const selectedArea = ref(null) const selectedArea = ref(null)
const showAreaDropdown = ref(false) const showAreaDropdown = ref(false)
@ -458,13 +449,16 @@ async function loadRepairOrdersById(deviceId) {
} catch (e) { console.error('loadRepairOrdersById error', e) } } catch (e) { console.error('loadRepairOrdersById error', e) }
} }
function toggleWarehouseDropdown() { showWarehouseDropdown.value = !showWarehouseDropdown.value }
function handleSelectWarehouse(item) { selectedWarehouse.value = item; showWarehouseDropdown.value = false; selectedArea.value = null; areaOptions.value = []; warehouseAreaStockCount.value = 0; loadAreas(item.value) }
async function loadWarehouses() { async function loadWarehouses() {
try { try {
const res = await getWarehouseSimpleList() const res = await getWarehouseSimpleList()
const data = Array.isArray(res) ? res : (Array.isArray(res?.data) ? res.data : []) 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 || '') })) 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) {} } catch (e) {}
} }

@ -98,6 +98,12 @@ const MENU_ROUTE_MAP = {
sparepartinbound: '/pages_function/pages/sparepartInbound/index', sparepartinbound: '/pages_function/pages/sparepartInbound/index',
sparepartIn: '/pages_function/pages/sparepartInbound/index', sparepartIn: '/pages_function/pages/sparepartInbound/index',
'备件入库': '/pages_function/pages/sparepartInbound/index', '备件入库': '/pages_function/pages/sparepartInbound/index',
sparepartCheck: '/pages_function/pages/sparepartCheck/index',
sparepartcheck: '/pages_function/pages/sparepartCheck/index',
'备件盘点': '/pages_function/pages/sparepartCheck/index',
materialInbound: '/pages_function/pages/materialInbound/index',
materialinbound: '/pages_function/pages/materialInbound/index',
'物料入库': '/pages_function/pages/materialInbound/index',
sparepartinventory: '/pages_function/pages/sparepartInventory/index', sparepartinventory: '/pages_function/pages/sparepartInventory/index',
'备件库存查询': '/pages_function/pages/sparepartInventory/index', '备件库存查询': '/pages_function/pages/sparepartInventory/index',
keypart: '/pages_function/pages/keypart/index', keypart: '/pages_function/pages/keypart/index',

Loading…
Cancel
Save