feat: 仓储管理-物料盘点执行模块
parent
fc9730dfdc
commit
7c55b009e6
@ -0,0 +1,190 @@
|
||||
<template>
|
||||
<view class="page-container">
|
||||
<NavBar :title="'选择库区'" />
|
||||
|
||||
<view class="search-bar">
|
||||
<input
|
||||
v-model="keyword"
|
||||
class="search-input"
|
||||
placeholder="搜索库区编码/名称"
|
||||
confirm-type="search"
|
||||
@confirm="handleSearch"
|
||||
/>
|
||||
<text class="search-btn" @click="handleSearch">搜索</text>
|
||||
</view>
|
||||
|
||||
<view class="select-all-bar">
|
||||
<view class="checkbox-wrap" @click="toggleSelectAll">
|
||||
<text :class="['checkbox', isAllSelected ? 'checkbox-checked' : '']">{{ isAllSelected ? '✓' : '' }}</text>
|
||||
<text class="select-all-text">全选</text>
|
||||
</view>
|
||||
<text class="select-count">已选 {{ selectedItems.length }} 项</text>
|
||||
</view>
|
||||
|
||||
<scroll-view scroll-y class="list-scroll">
|
||||
<view v-for="item in filteredList" :key="item.id" class="item-row" @click="toggleSelect(item)">
|
||||
<view class="checkbox-wrap">
|
||||
<text :class="['checkbox', isSelected(item) ? 'checkbox-checked' : '']">{{ isSelected(item) ? '✓' : '' }}</text>
|
||||
</view>
|
||||
<view class="item-info">
|
||||
<view class="info-row">
|
||||
<text class="info-label">库区编码</text>
|
||||
<text class="info-val code">{{ textValue(item.areaCode) }}</text>
|
||||
</view>
|
||||
<view class="info-row">
|
||||
<text class="info-label">库区名称</text>
|
||||
<text class="info-val name">{{ textValue(item.areaName) }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view v-if="loading" class="loading-text">加载中...</view>
|
||||
<view v-if="!loading && !list.length" class="empty-text">暂无数据</view>
|
||||
</scroll-view>
|
||||
|
||||
<view class="bottom-actions">
|
||||
<view class="bottom-btn cancel-btn" @click="handleCancel">取消</view>
|
||||
<view class="bottom-btn confirm-btn" @click="handleConfirm">确定</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, computed } from 'vue'
|
||||
import { onShow } from '@dcloudio/uni-app'
|
||||
import NavBar from '@/components/common/NavBar.vue'
|
||||
import { getWarehouseAreaSimpleList } from '@/api/mes/moldget'
|
||||
|
||||
const list = ref([])
|
||||
const selectedItems = ref([])
|
||||
const loading = ref(false)
|
||||
const keyword = ref('')
|
||||
const warehouseId = ref('')
|
||||
|
||||
const filteredList = computed(() => {
|
||||
if (!keyword.value) return list.value
|
||||
return list.value.filter(item =>
|
||||
(item.areaCode || '').includes(keyword.value) ||
|
||||
(item.areaName || '').includes(keyword.value)
|
||||
)
|
||||
})
|
||||
|
||||
const isAllSelected = computed(() => {
|
||||
return filteredList.value.length > 0 && filteredList.value.every(item => isSelected(item))
|
||||
})
|
||||
|
||||
function textValue(v) {
|
||||
if (v === 0) return '0'
|
||||
if (v == null) return '-'
|
||||
return String(v).trim() || '-'
|
||||
}
|
||||
|
||||
function isSelected(item) {
|
||||
return selectedItems.value.some(s => String(s.id) === String(item.id))
|
||||
}
|
||||
|
||||
function toggleSelect(item) {
|
||||
const idx = selectedItems.value.findIndex(s => String(s.id) === String(item.id))
|
||||
if (idx >= 0) {
|
||||
selectedItems.value.splice(idx, 1)
|
||||
} else {
|
||||
selectedItems.value.push({
|
||||
id: item.id,
|
||||
code: item.areaCode || '',
|
||||
name: item.areaName || ''
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
function toggleSelectAll() {
|
||||
if (isAllSelected.value) {
|
||||
selectedItems.value = []
|
||||
} else {
|
||||
selectedItems.value = filteredList.value.map(item => ({
|
||||
id: item.id,
|
||||
code: item.areaCode || '',
|
||||
name: item.areaName || ''
|
||||
}))
|
||||
}
|
||||
}
|
||||
|
||||
async function loadData() {
|
||||
loading.value = true
|
||||
try {
|
||||
const res = await getWarehouseAreaSimpleList(warehouseId.value)
|
||||
const data = Array.isArray(res) ? res : (Array.isArray(res?.data) ? res.data : [])
|
||||
list.value = data
|
||||
} catch (e) {
|
||||
console.error('loadAreaData error', e)
|
||||
uni.showToast({ title: '加载失败', icon: 'none' })
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function handleSearch() {}
|
||||
|
||||
function handleCancel() {
|
||||
uni.navigateBack()
|
||||
}
|
||||
|
||||
function handleConfirm() {
|
||||
if (!selectedItems.value.length) {
|
||||
uni.showToast({ title: '请至少选择一项', icon: 'none' })
|
||||
return
|
||||
}
|
||||
getApp().globalData._materialCheckAreaSelectResult = [...selectedItems.value]
|
||||
uni.navigateBack()
|
||||
}
|
||||
|
||||
onShow(() => {
|
||||
const prevSelected = getApp().globalData?._materialCheckAreaSelected
|
||||
if (prevSelected && Array.isArray(prevSelected)) {
|
||||
selectedItems.value = prevSelected.map(a => ({
|
||||
id: a.value,
|
||||
code: a.code || '',
|
||||
name: a.label || ''
|
||||
}))
|
||||
getApp().globalData._materialCheckAreaSelected = null
|
||||
}
|
||||
warehouseId.value = getApp().globalData?._materialCheckAreaWarehouseId || ''
|
||||
loadData()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.page-container { min-height: 100vh; background: #f5f6f8; padding-bottom: calc(120rpx + env(safe-area-inset-bottom)); }
|
||||
|
||||
.search-bar { display: flex; gap: 16rpx; padding: 20rpx 24rpx; background: #fff; }
|
||||
.search-input { flex: 1; height: 72rpx; padding: 0 24rpx; background: #f3f4f6; border-radius: 12rpx; font-size: 28rpx; }
|
||||
.search-btn { display: flex; align-items: center; justify-content: center; width: 120rpx; height: 72rpx; background: #1f4b79; color: #fff; border-radius: 12rpx; font-size: 28rpx; }
|
||||
|
||||
.select-all-bar { display: flex; align-items: center; justify-content: space-between; padding: 20rpx 24rpx; background: #fff; border-bottom: 1rpx solid #f0f0f0; }
|
||||
.checkbox-wrap { display: flex; align-items: center; gap: 12rpx; }
|
||||
.checkbox { width: 40rpx; height: 40rpx; border: 2rpx solid #d1d5db; border-radius: 8rpx; display: flex; align-items: center; justify-content: center; font-size: 24rpx; color: #fff; background: #fff;
|
||||
&.checkbox-checked { background: #1f4b79; border-color: #1f4b79; }
|
||||
}
|
||||
.select-all-text { font-size: 28rpx; color: #374151; }
|
||||
.select-count { font-size: 26rpx; color: #1f4b79; font-weight: 600; }
|
||||
|
||||
.list-scroll { height: calc(100vh - 330rpx - env(safe-area-inset-bottom)); }
|
||||
.item-row { display: flex; align-items: flex-start; gap: 16rpx; padding: 20rpx 24rpx; background: #fff; border-bottom: 1rpx solid #f0f0f0;
|
||||
&:active { background: #f9fafb; }
|
||||
}
|
||||
.item-info { flex: 1; display: flex; flex-direction: column; gap: 8rpx; }
|
||||
.info-row { display: flex; align-items: center; gap: 16rpx; }
|
||||
.info-label { width: 120rpx; font-size: 24rpx; color: #9ca3af; flex-shrink: 0; }
|
||||
.info-val { flex: 1; font-size: 26rpx; color: #374151;
|
||||
&.code { font-family: monospace; color: #6b7280; }
|
||||
&.name { font-weight: 500; color: #1a1a1a; }
|
||||
}
|
||||
|
||||
.loading-text, .empty-text { padding: 40rpx; text-align: center; color: #9ca3af; font-size: 26rpx; }
|
||||
|
||||
.bottom-actions { position: fixed; left: 0; right: 0; bottom: 0; display: flex; gap: 18rpx; padding: 18rpx 24rpx calc(18rpx + env(safe-area-inset-bottom)); background: #fff; box-shadow: 0 -8rpx 24rpx rgba(15,23,42,0.06); z-index: 99; }
|
||||
.bottom-btn { flex: 1; height: 84rpx; line-height: 84rpx; text-align: center; border-radius: 16rpx; font-size: 30rpx; font-weight: 600;
|
||||
&:active { opacity: 0.85; }
|
||||
}
|
||||
.cancel-btn { background: #eef2f7; color: #475569; }
|
||||
.confirm-btn { background: #1f4b79; color: #fff; }
|
||||
</style>
|
||||
@ -0,0 +1,392 @@
|
||||
<template>
|
||||
<view class="page-container">
|
||||
<NavBar :title="'盘点执行'" />
|
||||
|
||||
<view class="header-card" v-if="detail">
|
||||
<view class="header-top">
|
||||
<text class="header-no">{{ textValue(detail.no) }}</text>
|
||||
</view>
|
||||
<view class="header-info">
|
||||
<view class="info-row">
|
||||
<text class="info-label">盘点仓库</text>
|
||||
<text class="info-value">{{ textValue(detail.warehouseName || getWarehouseName()) }}</text>
|
||||
</view>
|
||||
<view class="info-row">
|
||||
<text class="info-label">盘点库位</text>
|
||||
<text class="info-value">{{ textValue(getAreaName()) }}</text>
|
||||
</view>
|
||||
<view class="info-row">
|
||||
<text class="info-label">盘点时间</text>
|
||||
<text class="info-value">{{ formatDateTime(detail.checkTime) }}</text>
|
||||
</view>
|
||||
<view class="info-row">
|
||||
<text class="info-label">盘点人</text>
|
||||
<text class="info-value">{{ textValue(detail.creatorName || detail.creator) }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view v-if="loading" class="hint">加载中...</view>
|
||||
|
||||
<view v-else-if="items.length" class="check-list">
|
||||
<view v-for="(item, idx) in items" :key="idx" class="check-card">
|
||||
<view class="check-card-header">
|
||||
<text class="check-card-index">{{ idx + 1 }}</text>
|
||||
<view class="check-card-header-info">
|
||||
<text class="check-card-name">{{ textValue(item.productName) }}</text>
|
||||
<text class="check-card-code">{{ textValue(item.productBarCode) }}</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="sparepart-info">
|
||||
<view class="sp-row">
|
||||
<text class="sp-label">规格型号</text>
|
||||
<text class="sp-value">{{ textValue(item.standard || item.productStandard || item.deviceSpec) }}</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="stock-info">
|
||||
<view class="st-row">
|
||||
<text class="st-label">账面库存</text>
|
||||
<text class="st-value">{{ formatNumber(item.stockCount) }} {{ textValue(item.productUnitName || item.unitName || '个') }}</text>
|
||||
</view>
|
||||
<view class="st-row">
|
||||
<text class="st-label">最小单位</text>
|
||||
<text class="st-value">{{ textValue(item.productUnitName || item.unitName || '个') }}</text>
|
||||
</view>
|
||||
<view class="st-row">
|
||||
<text class="st-label">换算关系</text>
|
||||
<text class="st-value">{{ getConvertText(item) }}</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="input-row">
|
||||
<text class="input-label">实盘数量</text>
|
||||
<view class="input-control">
|
||||
<view class="input-btn minus" @click="handleMinus(idx)">-</view>
|
||||
<input v-model="item._checkCount" class="input-field" type="digit" placeholder="0" />
|
||||
<view class="input-btn plus" @click="handlePlus(idx)">+</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="diff-row">
|
||||
<text class="diff-label">差异</text>
|
||||
<text :class="['diff-value', diffClass(item)]">{{ getDiffText(item) }}</text>
|
||||
</view>
|
||||
|
||||
<view class="remark-row">
|
||||
<text class="remark-label">备注</text>
|
||||
<input v-model="item._remark" class="remark-input" placeholder="请输入备注" />
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view v-else class="hint">暂无盘点数据</view>
|
||||
|
||||
<view v-if="items.length" class="bottom-actions">
|
||||
<view class="submit-btn" @click="handleSubmit">提交盘点结果</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref } from 'vue'
|
||||
import { onLoad } from '@dcloudio/uni-app'
|
||||
import NavBar from '@/components/common/NavBar.vue'
|
||||
import { getMaterialCheckDetail, executeMaterialCheck } from '@/api/mes/materialCheck'
|
||||
import { getProductDetail } from '@/api/mes/sparepart'
|
||||
|
||||
const detail = ref(null)
|
||||
const items = ref([])
|
||||
const loading = ref(false)
|
||||
|
||||
function textValue(v) {
|
||||
if (v === 0) return '0'
|
||||
if (v == null) return '-'
|
||||
const s = String(v).trim()
|
||||
return s || '-'
|
||||
}
|
||||
|
||||
function formatNumber(v) {
|
||||
if (v == null) return '0'
|
||||
return String(v)
|
||||
}
|
||||
|
||||
function formatDateTime(value) {
|
||||
if (!value) return '-'
|
||||
if (Array.isArray(value) && value.length >= 5) {
|
||||
const [y, m, d, h = 0, min = 0, s = 0] = value
|
||||
const pad = (n) => String(n).padStart(2, '0')
|
||||
return `${y}-${pad(m)}-${pad(d)} ${pad(h)}:${pad(min)}:${pad(s)}`
|
||||
}
|
||||
const date = new Date(Number(value))
|
||||
if (Number.isNaN(date.getTime())) return String(value)
|
||||
const pad = (n) => String(n).padStart(2, '0')
|
||||
return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())} ${pad(date.getHours())}:${pad(date.getMinutes())}:${pad(date.getSeconds())}`
|
||||
}
|
||||
|
||||
function getWarehouseName() {
|
||||
const item = items.value[0]
|
||||
return item?.warehouseName || ''
|
||||
}
|
||||
|
||||
function getAreaName() {
|
||||
const item = items.value[0]
|
||||
return item?.areaName || ''
|
||||
}
|
||||
|
||||
function getConvertText(item) {
|
||||
const purchaseUnit = item?.purchaseUnitName
|
||||
const ratio = item?.purchaseUnitConvertQuantity
|
||||
const unit = item?.productUnitName || item?.unitName || '个'
|
||||
if (purchaseUnit && ratio) {
|
||||
return `1${purchaseUnit}=${ratio}${unit}`
|
||||
}
|
||||
return '-'
|
||||
}
|
||||
|
||||
function getDiff(item) {
|
||||
const count = Number(item._checkCount) || 0
|
||||
const stock = Number(item.stockCount) || 0
|
||||
return count - stock
|
||||
}
|
||||
|
||||
function getDiffText(item) {
|
||||
const d = getDiff(item)
|
||||
const unit = item?.productUnitName || item?.unitName || '个'
|
||||
if (d === 0) return `0 ${unit}`
|
||||
return `${d > 0 ? '+' : ''}${d} ${unit}`
|
||||
}
|
||||
|
||||
function diffClass(item) {
|
||||
const d = getDiff(item)
|
||||
if (d > 0) return 'positive'
|
||||
if (d < 0) return 'negative'
|
||||
return ''
|
||||
}
|
||||
|
||||
function handleMinus(idx) {
|
||||
const val = Number(items.value[idx]._checkCount) || 0
|
||||
if (val > 0) {
|
||||
items.value[idx]._checkCount = String(val - 1)
|
||||
}
|
||||
}
|
||||
|
||||
function handlePlus(idx) {
|
||||
const val = Number(items.value[idx]._checkCount) || 0
|
||||
items.value[idx]._checkCount = String(val + 1)
|
||||
}
|
||||
|
||||
onLoad(async (options) => {
|
||||
const id = options?.id
|
||||
if (!id) {
|
||||
uni.showToast({ title: '参数错误', icon: 'none' })
|
||||
return
|
||||
}
|
||||
loading.value = true
|
||||
try {
|
||||
const res = await getMaterialCheckDetail(id)
|
||||
const data = res?.data || res
|
||||
detail.value = data
|
||||
const rawItems = data?.items || []
|
||||
|
||||
const enrichedItems = await Promise.all(
|
||||
rawItems.map(async (item) => {
|
||||
if (!item.productId) return item
|
||||
try {
|
||||
const productRes = await getProductDetail(item.productId)
|
||||
const product = productRes?.data || productRes
|
||||
if (product && product.id) {
|
||||
return {
|
||||
...item,
|
||||
standard: item.standard || product.standard || product.deviceSpec,
|
||||
productUnitName: item.productUnitName || product.unitName || product.minStockUnitName,
|
||||
minStockUnitName: item.minStockUnitName || product.minStockUnitName,
|
||||
purchaseUnitName: item.purchaseUnitName || product.purchaseUnitName,
|
||||
purchaseUnitConvertQuantity: item.purchaseUnitConvertQuantity || product.purchaseUnitConvertQuantity,
|
||||
_checkCount: item.checkCount != null ? String(item.checkCount) : '',
|
||||
_remark: item.remark || ''
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('补全物料信息失败:', item.productId, e)
|
||||
}
|
||||
return {
|
||||
...item,
|
||||
_checkCount: '',
|
||||
_remark: ''
|
||||
}
|
||||
})
|
||||
)
|
||||
|
||||
items.value = enrichedItems
|
||||
} catch (e) {
|
||||
const msg = e?.message || e?.data?.msg || '加载失败'
|
||||
console.error('加载盘点单失败:', e)
|
||||
uni.showToast({ title: String(msg).substring(0, 50), icon: 'none' })
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
})
|
||||
|
||||
async function handleSubmit() {
|
||||
const submitItems = items.value.map((item) => {
|
||||
const actual = Number(item._checkCount) || 0
|
||||
const stock = item.stockCount != null ? Number(item.stockCount) : 0
|
||||
return {
|
||||
id: Number(item.id),
|
||||
warehouseId: Number(item.warehouseId),
|
||||
areaId: item.areaId ? Number(item.areaId) : undefined,
|
||||
productId: Number(item.productId),
|
||||
productPrice: item.productPrice != null ? Number(item.productPrice) : 0,
|
||||
stockCount: stock,
|
||||
actualCount: actual,
|
||||
count: actual - stock,
|
||||
remark: item._remark || ''
|
||||
}
|
||||
})
|
||||
|
||||
try {
|
||||
const now = new Date()
|
||||
const pad = (n) => String(n).padStart(2, '0')
|
||||
const checkTimeStr = `${now.getFullYear()}-${pad(now.getMonth() + 1)}-${pad(now.getDate())} ${pad(now.getHours())}:${pad(now.getMinutes())}:${pad(now.getSeconds())}`
|
||||
const payload = {
|
||||
id: Number(detail.value.id),
|
||||
checkTime: checkTimeStr,
|
||||
sourceType: detail.value.sourceType,
|
||||
categoryType: detail.value.categoryType,
|
||||
checkStatus: 1,
|
||||
remark: '',
|
||||
fileUrl: '',
|
||||
items: submitItems
|
||||
}
|
||||
console.log('[物料盘点提交]', JSON.stringify(payload))
|
||||
uni.showLoading({ title: '提交中...', mask: true })
|
||||
await executeMaterialCheck(payload)
|
||||
uni.hideLoading()
|
||||
uni.showToast({ title: '盘点完成', icon: 'success' })
|
||||
setTimeout(() => uni.navigateBack(), 1500)
|
||||
} catch (e) {
|
||||
uni.hideLoading()
|
||||
const msg = e?.message || e?.data?.msg || e?.response?.data?.msg || '盘点失败'
|
||||
console.error('盘点提交失败:', e)
|
||||
uni.showToast({ title: String(msg).substring(0, 50), icon: 'none' })
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.page-container {
|
||||
min-height: 100vh;
|
||||
background: #f5f6f8;
|
||||
padding-bottom: calc(120rpx + env(safe-area-inset-bottom));
|
||||
}
|
||||
|
||||
.header-card {
|
||||
background: #fff;
|
||||
margin: 20rpx 24rpx;
|
||||
padding: 24rpx;
|
||||
border-radius: 16rpx;
|
||||
}
|
||||
.header-top { margin-bottom: 20rpx; }
|
||||
.header-no { font-size: 32rpx; font-weight: 700; color: #1a1a1a; }
|
||||
.header-info { border-top: 1rpx solid #f0f0f0; padding-top: 20rpx; }
|
||||
.info-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16rpx;
|
||||
&:last-child { margin-bottom: 0; }
|
||||
}
|
||||
.info-label { font-size: 26rpx; color: #6b7280; }
|
||||
.info-value { font-size: 26rpx; color: #1a1a1a; font-weight: 500; }
|
||||
|
||||
.check-list { padding: 0 24rpx; }
|
||||
.check-card {
|
||||
background: #fff;
|
||||
border-radius: 16rpx;
|
||||
padding: 24rpx;
|
||||
margin-bottom: 20rpx;
|
||||
}
|
||||
|
||||
.check-card-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 16rpx;
|
||||
margin-bottom: 20rpx;
|
||||
padding-bottom: 20rpx;
|
||||
border-bottom: 1rpx solid #f0f0f0;
|
||||
}
|
||||
.check-card-index {
|
||||
width: 48rpx;
|
||||
height: 48rpx;
|
||||
border-radius: 24rpx;
|
||||
background: #1f4b79;
|
||||
color: #fff;
|
||||
font-size: 26rpx;
|
||||
font-weight: 700;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
.check-card-header-info { flex: 1; }
|
||||
.check-card-name { font-size: 30rpx; font-weight: 700; color: #1a1a1a; display: block; }
|
||||
.check-card-code { font-size: 24rpx; color: #9ca3af; margin-top: 4rpx; display: block; }
|
||||
|
||||
.sparepart-info { margin-bottom: 20rpx; }
|
||||
.sp-row { display: flex; align-items: center; justify-content: space-between; }
|
||||
.sp-label { font-size: 26rpx; color: #6b7280; }
|
||||
.sp-value { font-size: 26rpx; color: #1a1a1a; font-weight: 500; }
|
||||
|
||||
.stock-info {
|
||||
background: #f8fafc;
|
||||
border-radius: 12rpx;
|
||||
padding: 20rpx;
|
||||
margin-bottom: 20rpx;
|
||||
}
|
||||
.st-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12rpx;
|
||||
&:last-child { margin-bottom: 0; }
|
||||
}
|
||||
.st-label { font-size: 24rpx; color: #6b7280; }
|
||||
.st-value { font-size: 26rpx; color: #16a34a; font-weight: 600; }
|
||||
|
||||
.input-row { margin-bottom: 20rpx; }
|
||||
.input-label { font-size: 26rpx; color: #1a1a1a; font-weight: 500; margin-bottom: 12rpx; display: block; }
|
||||
.input-control { display: flex; align-items: center; gap: 12rpx; }
|
||||
.input-btn {
|
||||
width: 64rpx; height: 64rpx; border-radius: 12rpx;
|
||||
background: #f3f4f6; display: flex; align-items: center; justify-content: center;
|
||||
font-size: 36rpx; color: #374151; font-weight: 600;
|
||||
&:active { background: #e5e7eb; }
|
||||
}
|
||||
.input-field {
|
||||
flex: 1; height: 64rpx; text-align: center;
|
||||
background: #f8fafc; border: 1rpx solid #e0e0e0; border-radius: 10rpx;
|
||||
font-size: 30rpx; color: #1a1a1a; font-weight: 600;
|
||||
}
|
||||
|
||||
.diff-row { display: flex; align-items: center; justify-content: space-between; padding: 16rpx 0; border-top: 1rpx solid #f0f0f0; margin-bottom: 16rpx; }
|
||||
.diff-label { font-size: 26rpx; color: #6b7280; }
|
||||
.diff-value { font-size: 28rpx; font-weight: 700;
|
||||
&.positive { color: #16a34a; }
|
||||
&.negative { color: #dc2626; }
|
||||
}
|
||||
|
||||
.remark-row { display: flex; align-items: center; gap: 16rpx; }
|
||||
.remark-label { font-size: 26rpx; color: #6b7280; flex-shrink: 0; }
|
||||
.remark-input {
|
||||
flex: 1; height: 64rpx;
|
||||
background: #f8fafc; border: 1rpx solid #e0e0e0; border-radius: 10rpx;
|
||||
padding: 0 16rpx; font-size: 26rpx; color: #374151;
|
||||
}
|
||||
|
||||
.hint { padding: 120rpx 0; text-align: center; color: #94a3b8; font-size: 28rpx; }
|
||||
.bottom-actions {
|
||||
position: fixed; left: 0; right: 0; bottom: 0;
|
||||
padding: 20rpx 24rpx calc(20rpx + env(safe-area-inset-bottom));
|
||||
background: #fff; box-shadow: 0 -4rpx 20rpx rgba(0,0,0,0.06);
|
||||
}
|
||||
.submit-btn {
|
||||
height: 88rpx; line-height: 88rpx; text-align: center;
|
||||
background: #1a3a5c; color: #fff; font-size: 30rpx; font-weight: 600;
|
||||
border-radius: 12rpx;
|
||||
&:active { opacity: 0.9; }
|
||||
}
|
||||
</style>
|
||||
@ -0,0 +1,872 @@
|
||||
<template>
|
||||
<view class="page-container">
|
||||
<NavBar :title="'物料盘点'" />
|
||||
|
||||
<view class="filter-bar">
|
||||
<view class="keyword-box">
|
||||
<input
|
||||
v-model="searchKeyword"
|
||||
class="keyword-input"
|
||||
placeholder="搜索单号"
|
||||
confirm-type="search"
|
||||
@input="handleKeywordInput"
|
||||
@confirm="handleSearch"
|
||||
/>
|
||||
</view>
|
||||
<picker mode="selector" :range="statusLabels" :value="statusIndex" @change="onStatusChange">
|
||||
<view class="status-box">
|
||||
<text class="status-box-text">{{ currentStatusLabel }}</text>
|
||||
<uni-icons type="bottom" size="14" color="#9ca3af"></uni-icons>
|
||||
</view>
|
||||
</picker>
|
||||
<view class="reset-filter-btn" @click="resetFilters">重置</view>
|
||||
</view>
|
||||
|
||||
<scroll-view
|
||||
scroll-y
|
||||
class="list-scroll"
|
||||
:scroll-top="scrollTop"
|
||||
@scroll="onScroll"
|
||||
@scrolltolower="loadMore"
|
||||
:lower-threshold="80"
|
||||
>
|
||||
<view class="list-wrap">
|
||||
<view
|
||||
v-for="item in list"
|
||||
:key="item.id"
|
||||
class="task-card"
|
||||
@click="openDetail(item)"
|
||||
>
|
||||
<view class="card-header">
|
||||
<view class="header-main">
|
||||
<view class="header-left">
|
||||
<text class="task-no">{{ textValue(item.no) }}</text>
|
||||
</view>
|
||||
<view class="header-tags">
|
||||
<text :class="['record-tag', statusClass(item.status)]">{{ statusText(item.status) }}</text>
|
||||
<text :class="['record-tag', checkStatusClass(item.checkStatus)]">{{ checkStatusText(item.checkStatus) }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="card-body">
|
||||
<view class="row">
|
||||
<text class="label">产品物料名称</text>
|
||||
<text class="value">{{ textValue(item.productNames) }}</text>
|
||||
</view>
|
||||
<view class="row">
|
||||
<text class="label">仓库</text>
|
||||
<text class="value">{{ textValue(item.warehouseName || getItemsWarehouseName(item.items)) }}</text>
|
||||
</view>
|
||||
<view class="row">
|
||||
<text class="label">盘点时间</text>
|
||||
<text class="value">{{ formatDateTime(item.checkTime) }}</text>
|
||||
</view>
|
||||
<view class="row">
|
||||
<text class="label">创建人</text>
|
||||
<text class="value">{{ textValue(item.creatorName || item.creator) }}</text>
|
||||
</view>
|
||||
<view class="row">
|
||||
<text class="label">创建时间</text>
|
||||
<text class="value">{{ formatDateTime(item.createTime) }}</text>
|
||||
</view>
|
||||
<view class="row">
|
||||
<text class="label">审核人</text>
|
||||
<text class="value">{{ textValue(item.auditUserName) }}</text>
|
||||
</view>
|
||||
<view class="row">
|
||||
<text class="label">备注</text>
|
||||
<text class="value">{{ textValue(item.remark) }}</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="card-actions" v-if="showActions(item)">
|
||||
<view v-if="Number(item.status) === 10" class="action-btn approve-btn" @click.stop="handleApprove(item)">通过</view>
|
||||
<view v-if="Number(item.status) === 10" class="action-btn reject-btn" @click.stop="handleReject(item)">驳回</view>
|
||||
<view v-if="showSubmit(item)" class="action-btn submit-btn" @click.stop="openSubmitDialog(item)">提交</view>
|
||||
<view v-if="showCheck(item)" class="action-btn execute-btn" @click.stop="goExecute(item)">盘点</view>
|
||||
<view v-if="Number(item.status) !== 20" class="action-btn delete-btn" @click.stop="handleDelete(item)">删除</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view v-if="loading && pageNo === 1" class="hint">加载中...</view>
|
||||
<view v-else-if="!list.length" class="hint">暂无盘点数据</view>
|
||||
<view v-else-if="loadingMore" class="hint">加载更多...</view>
|
||||
<view v-else-if="finished" class="hint">没有更多了</view>
|
||||
</view>
|
||||
</scroll-view>
|
||||
|
||||
<view v-if="showGoTop" class="go-top-btn" @click="goTop">
|
||||
<uni-icons type="arrow-up" size="20" color="#1f4b79"></uni-icons>
|
||||
</view>
|
||||
|
||||
<view class="add-btn" @click="goAdd">
|
||||
<text class="add-icon">+</text>
|
||||
</view>
|
||||
|
||||
<!-- 提交弹框 -->
|
||||
<view v-if="showSubmitModal" class="modal-overlay" @click="closeSubmitDialog">
|
||||
<view class="modal-card" @click.stop>
|
||||
<view class="modal-header">
|
||||
<text class="modal-title">提交审核</text>
|
||||
<text class="modal-close" @click="closeSubmitDialog">✕</text>
|
||||
</view>
|
||||
<view class="modal-body">
|
||||
<view class="modal-field">
|
||||
<text class="modal-label"><text class="required">*</text>审核人</text>
|
||||
<view class="modal-dropdown" @click="toggleSubmitAuditorDropdown">
|
||||
<text :class="{ placeholder: !selectedSubmitAuditor }">{{ selectedSubmitAuditor ? selectedSubmitAuditor.label : '请选择' }}</text>
|
||||
<text class="dropdown-arrow">▼</text>
|
||||
<view v-if="showSubmitAuditorDropdown" class="dropdown-panel">
|
||||
<scroll-view scroll-y class="dropdown-scroll">
|
||||
<view v-for="u in submitAuditorOptions" :key="u.value" class="dropdown-item" :class="{ active: selectedSubmitAuditor?.value === u.value }" @click.stop="selectSubmitAuditor(u)">
|
||||
<text class="dropdown-item-text">{{ u.label }}</text>
|
||||
<text v-if="selectedSubmitAuditor?.value === u.value" class="dropdown-check">✓</text>
|
||||
</view>
|
||||
</scroll-view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="modal-field">
|
||||
<text class="modal-label">备注</text>
|
||||
<textarea v-model="submitRemark" class="modal-textarea" placeholder="请输入备注" placeholder-class="textarea-placeholder" :maxlength="200" />
|
||||
</view>
|
||||
</view>
|
||||
<view class="modal-footer">
|
||||
<view class="modal-btn cancel-btn" @click="closeSubmitDialog">取消</view>
|
||||
<view class="modal-btn confirm-btn" @click="confirmSubmitAudit">确定</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { computed, ref } from 'vue'
|
||||
import { onShow, onUnload } from '@dcloudio/uni-app'
|
||||
import NavBar from '@/components/common/NavBar.vue'
|
||||
import { getMaterialCheckPage, deleteMaterialCheck, submitMaterialCheck, auditMaterialCheck } from '@/api/mes/materialCheck'
|
||||
import { getWarehouseSimpleList } from '@/api/mes/sparepart'
|
||||
import { getSimpleUserList } from '@/api/mes/moldget'
|
||||
|
||||
const selectedStatus = ref('')
|
||||
const searchKeyword = ref('')
|
||||
const materialWarehouseId = ref('')
|
||||
|
||||
const statusOptions = computed(() => [
|
||||
{ label: '全部', value: '' },
|
||||
{ label: '待提交', value: '0' },
|
||||
{ label: '审核中', value: '10' },
|
||||
{ label: '已通过', value: '20' },
|
||||
{ label: '已驳回', value: '1' }
|
||||
])
|
||||
|
||||
const statusLabels = computed(() => statusOptions.value.map((item) => item.label))
|
||||
const statusIndex = computed(() => {
|
||||
const index = statusOptions.value.findIndex((item) => item.value === selectedStatus.value)
|
||||
return index >= 0 ? index : 0
|
||||
})
|
||||
const currentStatusLabel = computed(() => {
|
||||
const current = statusOptions.value.find((item) => item.value === selectedStatus.value)
|
||||
return current ? current.label : '全部'
|
||||
})
|
||||
const list = ref([])
|
||||
const loading = ref(false)
|
||||
const loadingMore = ref(false)
|
||||
const finished = ref(false)
|
||||
const pageNo = ref(1)
|
||||
const pageSize = ref(10)
|
||||
const scrollTop = ref(0)
|
||||
const showGoTop = ref(false)
|
||||
|
||||
let searchTimer = null
|
||||
|
||||
async function loadMaterialWarehouse() {
|
||||
try {
|
||||
const res = await getWarehouseSimpleList()
|
||||
const data = Array.isArray(res) ? res : (Array.isArray(res?.data) ? res.data : [])
|
||||
const material = data.find((w) => (w.name || '').includes('原料'))
|
||||
materialWarehouseId.value = material ? String(material.id) : ''
|
||||
} catch (e) {
|
||||
console.error('loadMaterialWarehouse error', e)
|
||||
}
|
||||
}
|
||||
|
||||
function textValue(v) {
|
||||
if (v === 0) return '0'
|
||||
if (v == null) return '-'
|
||||
const s = String(v).trim()
|
||||
return s || '-'
|
||||
}
|
||||
|
||||
function getItemsWarehouseName(items) {
|
||||
if (!Array.isArray(items) || !items.length) return ''
|
||||
const names = [...new Set(items.map(i => i.warehouseName || i.areaName).filter(Boolean))]
|
||||
return names.join('、') || ''
|
||||
}
|
||||
|
||||
function formatDateTime(value) {
|
||||
if (!value) return '-'
|
||||
if (Array.isArray(value) && value.length >= 3) {
|
||||
const [year, month, day, hour = 0, minute = 0, second = 0] = value
|
||||
const pad = (n) => String(n).padStart(2, '0')
|
||||
return `${year}-${pad(month)}-${pad(day)} ${pad(hour)}:${pad(minute)}:${pad(second)}`
|
||||
}
|
||||
const date = new Date(Number(value))
|
||||
if (Number.isNaN(date.getTime())) return String(value)
|
||||
const pad = (n) => String(n).padStart(2, '0')
|
||||
return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())} ${pad(date.getHours())}:${pad(date.getMinutes())}:${pad(date.getSeconds())}`
|
||||
}
|
||||
|
||||
const STATUS_MAP = { 0: '待提交', 10: '审核中', 20: '已通过', 1: '已驳回' }
|
||||
function statusText(s) {
|
||||
const num = Number(s)
|
||||
return STATUS_MAP[num] || textValue(num)
|
||||
}
|
||||
function statusClass(s) {
|
||||
const num = Number(s)
|
||||
if (num === 0) return 'text-primary'
|
||||
if (num === 10) return 'text-muted'
|
||||
if (num === 20) return 'text-success'
|
||||
if (num === 1) return 'text-danger'
|
||||
return ''
|
||||
}
|
||||
|
||||
const CHECK_STATUS_MAP = { 0: '未盘点', 1: '已盘点' }
|
||||
function checkStatusText(s) {
|
||||
const num = Number(s)
|
||||
return CHECK_STATUS_MAP[num] || textValue(num)
|
||||
}
|
||||
function checkStatusClass(s) {
|
||||
const num = Number(s)
|
||||
if (num === 0) return 'text-muted'
|
||||
if (num === 1) return 'text-success'
|
||||
return ''
|
||||
}
|
||||
|
||||
function normalizePageData(res) {
|
||||
const root = res && res.data !== undefined ? res.data : res
|
||||
const candidateList = root?.list || root?.rows || root?.records || root?.data?.list || root?.data?.rows || []
|
||||
const candidateTotal = root?.total ?? root?.data?.total ?? (Array.isArray(candidateList) ? candidateList.length : 0)
|
||||
return {
|
||||
list: Array.isArray(candidateList) ? candidateList : [],
|
||||
total: Number(candidateTotal || 0)
|
||||
}
|
||||
}
|
||||
|
||||
async function fetchList(reset) {
|
||||
if (reset) {
|
||||
pageNo.value = 1
|
||||
finished.value = false
|
||||
}
|
||||
if (pageNo.value === 1) {
|
||||
loading.value = true
|
||||
} else {
|
||||
loadingMore.value = true
|
||||
}
|
||||
try {
|
||||
const params = {
|
||||
pageNo: pageNo.value,
|
||||
pageSize: pageSize.value,
|
||||
no: searchKeyword.value.trim() || undefined,
|
||||
status: selectedStatus.value || undefined,
|
||||
warehouseId: materialWarehouseId.value || undefined,
|
||||
categoryType: 2
|
||||
}
|
||||
const res = await getMaterialCheckPage(params)
|
||||
const page = normalizePageData(res)
|
||||
list.value = reset ? page.list : [...list.value, ...page.list]
|
||||
finished.value = list.value.length >= page.total || page.list.length < pageSize.value
|
||||
} catch (e) {
|
||||
if (!reset) pageNo.value = Math.max(1, pageNo.value - 1)
|
||||
uni.showToast({ title: '加载失败', icon: 'none' })
|
||||
} finally {
|
||||
loading.value = false
|
||||
loadingMore.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function onStatusChange(event) {
|
||||
const index = Number(event?.detail?.value || 0)
|
||||
selectedStatus.value = statusOptions.value[index]?.value ?? ''
|
||||
fetchList(true)
|
||||
}
|
||||
|
||||
function handleSearch() {
|
||||
clearSearchTimer()
|
||||
uni.hideKeyboard()
|
||||
fetchList(true)
|
||||
}
|
||||
|
||||
function handleKeywordInput() {
|
||||
clearSearchTimer()
|
||||
searchTimer = setTimeout(() => {
|
||||
fetchList(true)
|
||||
}, 300)
|
||||
}
|
||||
|
||||
function resetFilters() {
|
||||
clearSearchTimer()
|
||||
searchKeyword.value = ''
|
||||
selectedStatus.value = ''
|
||||
fetchList(true)
|
||||
}
|
||||
|
||||
async function loadMore() {
|
||||
if (loading.value || loadingMore.value || finished.value) return
|
||||
pageNo.value += 1
|
||||
await fetchList(false)
|
||||
}
|
||||
|
||||
function openDetail(item) {
|
||||
if (!item?.id) {
|
||||
uni.showToast({ title: '无法查看详情', icon: 'none' })
|
||||
return
|
||||
}
|
||||
uni.navigateTo({
|
||||
url: `/pages_function/pages/materialCheck/detail?id=${encodeURIComponent(String(item.id))}`
|
||||
})
|
||||
}
|
||||
|
||||
function showActions(item) {
|
||||
if (!item) return false
|
||||
const status = Number(item.status)
|
||||
const checkStatus = Number(item.checkStatus)
|
||||
if (status === 10) return true
|
||||
if ((status === 0 || status === 1) && checkStatus === 1) return true
|
||||
if (checkStatus !== 1 && status !== 20) return true
|
||||
if (status !== 20) return true
|
||||
return false
|
||||
}
|
||||
|
||||
function showSubmit(item) {
|
||||
if (!item) return false
|
||||
const status = Number(item.status)
|
||||
const checkStatus = Number(item.checkStatus)
|
||||
return (status === 0 || status === 1) && checkStatus === 1
|
||||
}
|
||||
|
||||
function showCheck(item) {
|
||||
if (!item) return false
|
||||
const checkStatus = Number(item.checkStatus)
|
||||
const status = Number(item.status)
|
||||
return checkStatus !== 1 && status !== 20
|
||||
}
|
||||
|
||||
const showSubmitModal = ref(false)
|
||||
const currentSubmitItem = ref(null)
|
||||
const submitAuditorOptions = ref([])
|
||||
const selectedSubmitAuditor = ref(null)
|
||||
const showSubmitAuditorDropdown = ref(false)
|
||||
const submitRemark = ref('')
|
||||
|
||||
function openSubmitDialog(item) {
|
||||
currentSubmitItem.value = item
|
||||
selectedSubmitAuditor.value = null
|
||||
submitRemark.value = ''
|
||||
showSubmitModal.value = true
|
||||
loadSubmitAuditorOptions()
|
||||
}
|
||||
|
||||
function closeSubmitDialog() {
|
||||
showSubmitModal.value = false
|
||||
currentSubmitItem.value = null
|
||||
showSubmitAuditorDropdown.value = false
|
||||
}
|
||||
|
||||
function toggleSubmitAuditorDropdown() {
|
||||
showSubmitAuditorDropdown.value = !showSubmitAuditorDropdown.value
|
||||
}
|
||||
|
||||
function selectSubmitAuditor(u) {
|
||||
selectedSubmitAuditor.value = u
|
||||
showSubmitAuditorDropdown.value = false
|
||||
}
|
||||
|
||||
async function loadSubmitAuditorOptions() {
|
||||
if (submitAuditorOptions.value.length) return
|
||||
try {
|
||||
const res = await getSimpleUserList()
|
||||
const data = Array.isArray(res) ? res : (Array.isArray(res?.data) ? res.data : [])
|
||||
submitAuditorOptions.value = data.map((u) => ({
|
||||
value: u.id || u.userId,
|
||||
label: u.nickname || u.userName || u.name || String(u.id || '')
|
||||
}))
|
||||
} catch (e) {
|
||||
console.error('loadSubmitAuditorOptions error', e)
|
||||
}
|
||||
}
|
||||
|
||||
async function confirmSubmitAudit() {
|
||||
if (!selectedSubmitAuditor.value) {
|
||||
uni.showToast({ title: '请选择审核人', icon: 'none' })
|
||||
return
|
||||
}
|
||||
if (!currentSubmitItem.value?.id) return
|
||||
try {
|
||||
uni.showLoading({ title: '提交中...', mask: true })
|
||||
await submitMaterialCheck({
|
||||
id: currentSubmitItem.value.id,
|
||||
auditUserId: selectedSubmitAuditor.value.value,
|
||||
remark: submitRemark.value || undefined
|
||||
})
|
||||
uni.hideLoading()
|
||||
uni.showToast({ title: '提交成功', icon: 'success' })
|
||||
closeSubmitDialog()
|
||||
fetchList(true)
|
||||
} catch (e) {
|
||||
uni.hideLoading()
|
||||
uni.showToast({ title: '提交失败', icon: 'none' })
|
||||
}
|
||||
}
|
||||
|
||||
async function handleApprove(item) {
|
||||
if (!item?.id) return
|
||||
uni.showModal({
|
||||
title: '确认',
|
||||
content: '确认审核通过该盘点单?',
|
||||
confirmColor: '#16a34a',
|
||||
success: async (res) => {
|
||||
if (res.confirm) {
|
||||
try {
|
||||
uni.showLoading({ title: '审核中...' })
|
||||
await auditMaterialCheck({ id: item.id, status: 20 })
|
||||
uni.hideLoading()
|
||||
uni.showToast({ title: '审核通过', icon: 'success' })
|
||||
fetchList(true)
|
||||
} catch (e) {
|
||||
uni.hideLoading()
|
||||
uni.showToast({ title: '操作失败', icon: 'none' })
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
async function handleReject(item) {
|
||||
if (!item?.id) return
|
||||
uni.showModal({
|
||||
title: '确认',
|
||||
content: '确认驳回该盘点单?',
|
||||
confirmColor: '#dc2626',
|
||||
success: async (res) => {
|
||||
if (res.confirm) {
|
||||
try {
|
||||
uni.showLoading({ title: '审核中...' })
|
||||
await auditMaterialCheck({ id: item.id, status: 1 })
|
||||
uni.hideLoading()
|
||||
uni.showToast({ title: '已驳回', icon: 'success' })
|
||||
fetchList(true)
|
||||
} catch (e) {
|
||||
uni.hideLoading()
|
||||
uni.showToast({ title: '操作失败', icon: 'none' })
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
async function handleDelete(item) {
|
||||
if (!item?.id) return
|
||||
uni.showModal({
|
||||
title: '确认删除',
|
||||
content: '确认删除该盘点单?',
|
||||
confirmColor: '#dc2626',
|
||||
success: async (res) => {
|
||||
if (res.confirm) {
|
||||
try {
|
||||
uni.showLoading({ title: '删除中...' })
|
||||
await deleteMaterialCheck(item.id)
|
||||
uni.hideLoading()
|
||||
uni.showToast({ title: '删除成功', icon: 'success' })
|
||||
fetchList(true)
|
||||
} catch (e) {
|
||||
uni.hideLoading()
|
||||
uni.showToast({ title: '删除失败', icon: 'none' })
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function goExecute(item) {
|
||||
if (!item?.id) {
|
||||
uni.showToast({ title: '数据异常', icon: 'none' })
|
||||
return
|
||||
}
|
||||
uni.navigateTo({
|
||||
url: `/pages_function/pages/materialCheck/execute?id=${encodeURIComponent(String(item.id))}`
|
||||
})
|
||||
}
|
||||
|
||||
function onScroll(event) {
|
||||
showGoTop.value = (event?.detail?.scrollTop || 0) > 600
|
||||
}
|
||||
|
||||
function goTop() {
|
||||
scrollTop.value = 0
|
||||
}
|
||||
|
||||
function goAdd() {
|
||||
uni.navigateTo({
|
||||
url: '/pages_function/pages/materialCheck/create'
|
||||
})
|
||||
}
|
||||
|
||||
function clearSearchTimer() {
|
||||
if (searchTimer) {
|
||||
clearTimeout(searchTimer)
|
||||
searchTimer = null
|
||||
}
|
||||
}
|
||||
|
||||
onShow(() => {
|
||||
loadMaterialWarehouse()
|
||||
fetchList(true)
|
||||
})
|
||||
|
||||
onUnload(() => {
|
||||
clearSearchTimer()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.page-container {
|
||||
min-height: 100vh;
|
||||
background: #f4f5f7;
|
||||
}
|
||||
|
||||
.filter-bar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12rpx;
|
||||
padding: 18rpx 24rpx;
|
||||
background: #fff;
|
||||
}
|
||||
|
||||
.keyword-box {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
height: 66rpx;
|
||||
padding: 0 28rpx;
|
||||
background: #f4f5f7;
|
||||
border: 1rpx solid #e5e7eb;
|
||||
border-radius: 12rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.keyword-input {
|
||||
width: 100%;
|
||||
font-size: 24rpx;
|
||||
color: #374151;
|
||||
}
|
||||
|
||||
.status-box {
|
||||
flex-shrink: 0;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
height: 66rpx;
|
||||
padding: 0 28rpx;
|
||||
min-width: 160rpx;
|
||||
background: #fff;
|
||||
border: 1rpx solid #e5e7eb;
|
||||
border-radius: 12rpx;
|
||||
}
|
||||
|
||||
.status-box-text {
|
||||
font-size: 24rpx;
|
||||
color: #374151;
|
||||
min-width: 0;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.reset-filter-btn {
|
||||
height: 66rpx;
|
||||
line-height: 66rpx;
|
||||
padding: 0 28rpx;
|
||||
font-size: 24rpx;
|
||||
color: #4b5563;
|
||||
background: #fff;
|
||||
border: 1rpx solid #e5e7eb;
|
||||
border-radius: 12rpx;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.list-scroll {
|
||||
height: calc(100vh - 194rpx);
|
||||
}
|
||||
|
||||
.list-wrap {
|
||||
padding: 0 24rpx 60rpx;
|
||||
}
|
||||
|
||||
.task-card {
|
||||
position: relative;
|
||||
margin-top: 20rpx;
|
||||
padding: 28rpx;
|
||||
background: #fff;
|
||||
border-radius: 22rpx;
|
||||
box-shadow: 0 8rpx 28rpx rgba(15, 23, 42, 0.06);
|
||||
}
|
||||
|
||||
.card-header {
|
||||
margin-bottom: 18rpx;
|
||||
}
|
||||
|
||||
.header-main {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 16rpx;
|
||||
}
|
||||
|
||||
.header-left {
|
||||
min-width: 0;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.task-no {
|
||||
font-size: 32rpx;
|
||||
font-weight: 700;
|
||||
color: #0f172a;
|
||||
}
|
||||
|
||||
.header-tags {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12rpx;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.record-tag {
|
||||
padding: 8rpx 18rpx;
|
||||
border-radius: 999rpx;
|
||||
font-size: 22rpx;
|
||||
line-height: 1;
|
||||
background: #e2e8f0;
|
||||
color: #64748b;
|
||||
}
|
||||
|
||||
.card-body .row {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: flex-start;
|
||||
gap: 20rpx;
|
||||
margin-top: 12rpx;
|
||||
|
||||
&:first-child {
|
||||
margin-top: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.label {
|
||||
width: 140rpx;
|
||||
font-size: 25rpx;
|
||||
color: #94a3b8;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.value {
|
||||
flex: 1;
|
||||
text-align: right;
|
||||
font-size: 27rpx;
|
||||
color: #334155;
|
||||
line-height: 1.5;
|
||||
|
||||
&.highlight {
|
||||
color: #1f4b79;
|
||||
font-weight: 600;
|
||||
}
|
||||
}
|
||||
|
||||
.card-actions {
|
||||
display: flex;
|
||||
gap: 16rpx;
|
||||
margin-top: 20rpx;
|
||||
padding-top: 20rpx;
|
||||
border-top: 1rpx solid #f0f0f0;
|
||||
}
|
||||
|
||||
.action-btn {
|
||||
flex: 1;
|
||||
height: 64rpx;
|
||||
line-height: 64rpx;
|
||||
text-align: center;
|
||||
border-radius: 10rpx;
|
||||
font-size: 26rpx;
|
||||
font-weight: 500;
|
||||
|
||||
&.execute-btn {
|
||||
background: #dbeafe;
|
||||
color: #1d4ed8;
|
||||
}
|
||||
|
||||
&.submit-btn {
|
||||
background: #dbeafe;
|
||||
color: #1d4ed8;
|
||||
}
|
||||
|
||||
&.delete-btn {
|
||||
background: #fee2e2;
|
||||
color: #dc2626;
|
||||
}
|
||||
|
||||
&.approve-btn {
|
||||
background: #dcfce7;
|
||||
color: #16a34a;
|
||||
}
|
||||
|
||||
&.reject-btn {
|
||||
background: #fee2e2;
|
||||
color: #dc2626;
|
||||
}
|
||||
|
||||
&:active {
|
||||
opacity: 0.8;
|
||||
}
|
||||
}
|
||||
|
||||
.text-success {
|
||||
color: #16a34a;
|
||||
}
|
||||
|
||||
.text-danger {
|
||||
color: #dc2626;
|
||||
}
|
||||
|
||||
.text-warning {
|
||||
color: #d97706;
|
||||
}
|
||||
|
||||
.text-primary {
|
||||
color: #2563eb;
|
||||
}
|
||||
|
||||
.text-muted {
|
||||
color: #64748b;
|
||||
}
|
||||
|
||||
.record-tag.text-success {
|
||||
color: #15803d;
|
||||
background: #dcfce7;
|
||||
}
|
||||
|
||||
.record-tag.text-danger {
|
||||
color: #dc2626;
|
||||
background: #fee2e2;
|
||||
}
|
||||
|
||||
.record-tag.text-warning {
|
||||
color: #d97706;
|
||||
background: #fef3c7;
|
||||
}
|
||||
|
||||
.record-tag.text-primary {
|
||||
color: #1d4ed8;
|
||||
background: #dbeafe;
|
||||
}
|
||||
|
||||
.record-tag.text-muted {
|
||||
color: #64748b;
|
||||
background: #e2e8f0;
|
||||
}
|
||||
|
||||
.hint {
|
||||
padding: 36rpx 0;
|
||||
text-align: center;
|
||||
color: #94a3b8;
|
||||
font-size: 26rpx;
|
||||
}
|
||||
|
||||
.add-btn {
|
||||
position: fixed;
|
||||
right: 28rpx;
|
||||
bottom: calc(56rpx + env(safe-area-inset-bottom));
|
||||
width: 92rpx;
|
||||
height: 92rpx;
|
||||
border-radius: 46rpx;
|
||||
background: #1f4b79;
|
||||
box-shadow: 0 14rpx 30rpx rgba(24, 63, 108, 0.24);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.add-icon {
|
||||
color: #ffffff;
|
||||
font-size: 64rpx;
|
||||
line-height: 1;
|
||||
margin-top: -4rpx;
|
||||
}
|
||||
|
||||
.go-top-btn {
|
||||
position: fixed;
|
||||
right: 28rpx;
|
||||
bottom: calc(140rpx + env(safe-area-inset-bottom));
|
||||
width: 92rpx;
|
||||
height: 92rpx;
|
||||
border-radius: 46rpx;
|
||||
background: rgba(255, 255, 255, 0.96);
|
||||
box-shadow: 0 8rpx 24rpx rgba(15, 23, 42, 0.12);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.modal-overlay {
|
||||
position: fixed; top: 0; left: 0; right: 0; bottom: 0;
|
||||
background: rgba(0, 0, 0, 0.45); z-index: 999;
|
||||
display: flex; align-items: center; justify-content: center;
|
||||
}
|
||||
.modal-card {
|
||||
width: 640rpx; background: #fff; border-radius: 20rpx;
|
||||
box-shadow: 0 16rpx 48rpx rgba(0,0,0,0.15);
|
||||
}
|
||||
.modal-header {
|
||||
display: flex; align-items: center; justify-content: space-between;
|
||||
padding: 32rpx 32rpx 20rpx; border-bottom: 1rpx solid #f0f0f0;
|
||||
}
|
||||
.modal-title { font-size: 32rpx; font-weight: 700; color: #1a1a1a; }
|
||||
.modal-close { font-size: 32rpx; color: #999; padding: 8rpx; }
|
||||
.modal-body { padding: 28rpx 32rpx; }
|
||||
.modal-field { margin-bottom: 28rpx;
|
||||
&:last-child { margin-bottom: 0; }
|
||||
}
|
||||
.modal-label { font-size: 28rpx; color: #374151; font-weight: 500; margin-bottom: 14rpx; display: block; }
|
||||
.modal-label .required { color: #ef4444; }
|
||||
.modal-dropdown {
|
||||
position: relative; display: flex; align-items: center; justify-content: space-between;
|
||||
height: 80rpx; padding: 0 24rpx;
|
||||
background: #f8fafc; border: 1rpx solid #e0e0e0; border-radius: 12rpx;
|
||||
font-size: 28rpx; color: #374151;
|
||||
.placeholder { color: #bbb; }
|
||||
.dropdown-arrow { font-size: 20rpx; color: #999; }
|
||||
}
|
||||
.modal-textarea {
|
||||
width: 100%; min-height: 140rpx; padding: 20rpx;
|
||||
background: #f8fafc; border: 1rpx solid #e0e0e0;
|
||||
border-radius: 12rpx; font-size: 27rpx; color: #374151;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
.textarea-placeholder { color: #bbb; }
|
||||
.dropdown-panel {
|
||||
position: absolute; top: 100%; left: 0; right: 0; z-index: 200; margin-top: 4rpx;
|
||||
background: #fff; border: 1rpx solid #e0e0e0; border-radius: 12rpx;
|
||||
box-shadow: 0 8rpx 30rpx rgba(0,0,0,0.1); overflow: hidden;
|
||||
}
|
||||
.dropdown-scroll { height: 300rpx; }
|
||||
.dropdown-item { display: flex; align-items: center; justify-content: space-between; padding: 20rpx 24rpx; border-bottom: 1rpx solid #f0f0f0;
|
||||
&:last-child { border-bottom: 0; }
|
||||
&.active { background: #f0f5ff; }
|
||||
}
|
||||
.dropdown-item-text { font-size: 27rpx; color: #333; }
|
||||
.dropdown-check { font-size: 28rpx; color: #2563eb; font-weight: 700; }
|
||||
.modal-footer { display: flex; gap: 18rpx; padding: 24rpx 32rpx; border-top: 1rpx solid #f0f0f0; }
|
||||
.modal-btn { flex: 1; height: 80rpx; line-height: 80rpx; text-align: center; border-radius: 14rpx; font-size: 30rpx; font-weight: 600;
|
||||
&:active { opacity: 0.85; }
|
||||
&.cancel-btn { background: #f0f0f0; color: #6b7280; }
|
||||
&.confirm-btn { background: #1f4b79; color: #fff; }
|
||||
}
|
||||
</style>
|
||||
@ -0,0 +1,269 @@
|
||||
<template>
|
||||
<view class="page-container">
|
||||
<NavBar :title="'选择盘点项'" />
|
||||
|
||||
<view class="search-bar">
|
||||
<input
|
||||
v-model="keyword"
|
||||
class="search-input"
|
||||
placeholder="搜索编码/名称"
|
||||
confirm-type="search"
|
||||
@confirm="handleSearch"
|
||||
/>
|
||||
<text class="search-btn" @click="handleSearch">搜索</text>
|
||||
</view>
|
||||
|
||||
<view class="select-all-bar">
|
||||
<view class="checkbox-wrap" @click="toggleSelectAll">
|
||||
<text :class="['checkbox', isAllSelected ? 'checkbox-checked' : '']">{{ isAllSelected ? '✓' : '' }}</text>
|
||||
<text class="select-all-text">全选</text>
|
||||
</view>
|
||||
<text class="select-count">已选 {{ selectedItems.length }} 项</text>
|
||||
</view>
|
||||
|
||||
<scroll-view scroll-y class="list-scroll" @scrolltolower="loadMore">
|
||||
<view v-for="item in list" :key="item.id || item.productId" class="item-row" @click="toggleSelect(item)">
|
||||
<view class="checkbox-wrap">
|
||||
<text :class="['checkbox', isSelected(item) ? 'checkbox-checked' : '']">{{ isSelected(item) ? '✓' : '' }}</text>
|
||||
</view>
|
||||
<view class="item-info">
|
||||
<view class="info-row">
|
||||
<text class="info-label">仓库</text>
|
||||
<text class="info-val">{{ textValue(item.warehouseName) }}</text>
|
||||
</view>
|
||||
<view class="info-row">
|
||||
<text class="info-label">库区</text>
|
||||
<text class="info-val">{{ textValue(item.areaName) }}</text>
|
||||
</view>
|
||||
<view class="info-row">
|
||||
<text class="info-label">编码</text>
|
||||
<text class="info-val code">{{ textValue(item.productBarCode) }}</text>
|
||||
</view>
|
||||
<view class="info-row">
|
||||
<text class="info-label">名称</text>
|
||||
<text class="info-val name">{{ textValue(item.productName) }}</text>
|
||||
</view>
|
||||
<view class="info-row">
|
||||
<text class="info-label">库存数量</text>
|
||||
<text class="info-val stock">{{ textValue(item.stockCount) }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view v-if="loading" class="loading-text">加载中...</view>
|
||||
<view v-if="!loading && !list.length" class="empty-text">暂无数据</view>
|
||||
<view v-if="!loading && list.length && noMore" class="no-more-text">没有更多了</view>
|
||||
</scroll-view>
|
||||
|
||||
<view class="bottom-actions">
|
||||
<view class="bottom-btn cancel-btn" @click="handleCancel">取消</view>
|
||||
<view class="bottom-btn confirm-btn" @click="handleConfirm">确定</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, computed } from 'vue'
|
||||
import { onShow, onLoad } from '@dcloudio/uni-app'
|
||||
import NavBar from '@/components/common/NavBar.vue'
|
||||
import { generateCheckItemsByLocation } from '@/api/mes/materialCheck'
|
||||
|
||||
const routeWarehouseId = ref('')
|
||||
const routeAreaIds = ref('')
|
||||
let isFirstLoad = true
|
||||
|
||||
onLoad((options) => {
|
||||
routeWarehouseId.value = options?.warehouseId || ''
|
||||
routeAreaIds.value = options?.areaIds || ''
|
||||
})
|
||||
|
||||
onShow(() => {
|
||||
const prevSelected = getApp().globalData?._materialCheckItemSelected
|
||||
if (prevSelected && Array.isArray(prevSelected)) {
|
||||
selectedItems.value = prevSelected.map(item => ({
|
||||
id: item.id || item.productId,
|
||||
productId: item.productId || item.id,
|
||||
warehouseId: item.warehouseId,
|
||||
areaId: item.areaId,
|
||||
warehouseName: item.warehouseName,
|
||||
areaName: item.areaName,
|
||||
productBarCode: item.productBarCode,
|
||||
productName: item.productName,
|
||||
stockCount: item.stockCount,
|
||||
productPrice: item.productPrice
|
||||
}))
|
||||
getApp().globalData._materialCheckItemSelected = null
|
||||
}
|
||||
if (isFirstLoad) {
|
||||
isFirstLoad = false
|
||||
loadData(true)
|
||||
}
|
||||
})
|
||||
|
||||
const list = ref([])
|
||||
const selectedItems = ref([])
|
||||
const loading = ref(false)
|
||||
const noMore = ref(false)
|
||||
const pageNo = ref(1)
|
||||
const pageSize = 20
|
||||
const keyword = ref('')
|
||||
|
||||
const isAllSelected = computed(() => {
|
||||
return list.value.length > 0 && list.value.every(item => isSelected(item))
|
||||
})
|
||||
|
||||
function textValue(v) {
|
||||
if (v === 0) return '0'
|
||||
if (v == null) return '-'
|
||||
return String(v).trim() || '-'
|
||||
}
|
||||
|
||||
function getItemKey(item) {
|
||||
return `${item.productId || item.id}_${item.warehouseId || ''}_${item.areaId || ''}`
|
||||
}
|
||||
|
||||
function isSelected(item) {
|
||||
const key = getItemKey(item)
|
||||
return selectedItems.value.some(s => getItemKey(s) === key)
|
||||
}
|
||||
|
||||
function toggleSelect(item) {
|
||||
const key = getItemKey(item)
|
||||
const idx = selectedItems.value.findIndex(s => getItemKey(s) === key)
|
||||
if (idx >= 0) {
|
||||
selectedItems.value.splice(idx, 1)
|
||||
} else {
|
||||
selectedItems.value.push({ ...item })
|
||||
}
|
||||
}
|
||||
|
||||
function toggleSelectAll() {
|
||||
if (isAllSelected.value) {
|
||||
selectedItems.value = []
|
||||
} else {
|
||||
selectedItems.value = [...list.value]
|
||||
}
|
||||
}
|
||||
|
||||
async function loadData(reset = false) {
|
||||
if (loading.value) return
|
||||
if (reset) {
|
||||
pageNo.value = 1
|
||||
list.value = []
|
||||
noMore.value = false
|
||||
}
|
||||
loading.value = true
|
||||
try {
|
||||
const res = await generateCheckItemsByLocation({
|
||||
warehouseIds: routeWarehouseId.value ? [Number(routeWarehouseId.value)] : undefined,
|
||||
areaIds: routeAreaIds.value ? routeAreaIds.value.split(',').map(id => Number(id.trim())).filter(Boolean) : undefined,
|
||||
categoryType: 2,
|
||||
allowEmpty: true
|
||||
})
|
||||
const data = Array.isArray(res) ? res : (Array.isArray(res?.data) ? res.data : [])
|
||||
const filtered = keyword.value
|
||||
? data.filter(item =>
|
||||
(item.productBarCode || '').includes(keyword.value) ||
|
||||
(item.productName || '').includes(keyword.value)
|
||||
)
|
||||
: data
|
||||
list.value = reset ? filtered : [...list.value, ...filtered]
|
||||
noMore.value = true
|
||||
} catch (e) {
|
||||
console.error('loadData error', e)
|
||||
uni.showToast({ title: '加载失败', icon: 'none' })
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function loadMore() {
|
||||
if (!noMore.value && !loading.value) {
|
||||
pageNo.value++
|
||||
loadData()
|
||||
}
|
||||
}
|
||||
|
||||
function handleSearch() {
|
||||
loadData(true)
|
||||
}
|
||||
|
||||
function handleCancel() {
|
||||
uni.navigateBack()
|
||||
}
|
||||
|
||||
function handleConfirm() {
|
||||
if (!selectedItems.value.length) {
|
||||
uni.showToast({ title: '请至少选择一项', icon: 'none' })
|
||||
return
|
||||
}
|
||||
getApp().globalData._materialCheckItemSelectResult = [...selectedItems.value]
|
||||
uni.navigateBack()
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.page-container {
|
||||
min-height: 100vh;
|
||||
background: #f5f6f8;
|
||||
padding-bottom: calc(120rpx + env(safe-area-inset-bottom));
|
||||
}
|
||||
|
||||
.search-bar {
|
||||
display: flex; gap: 16rpx; padding: 20rpx 24rpx; background: #fff;
|
||||
}
|
||||
.search-input {
|
||||
flex: 1; height: 72rpx; padding: 0 24rpx;
|
||||
background: #f3f4f6; border-radius: 12rpx; font-size: 28rpx;
|
||||
}
|
||||
.search-btn {
|
||||
display: flex; align-items: center; justify-content: center;
|
||||
width: 120rpx; height: 72rpx; background: #1f4b79;
|
||||
color: #fff; border-radius: 12rpx; font-size: 28rpx;
|
||||
}
|
||||
|
||||
.select-all-bar {
|
||||
display: flex; align-items: center; justify-content: space-between;
|
||||
padding: 20rpx 24rpx; background: #fff; border-bottom: 1rpx solid #f0f0f0;
|
||||
}
|
||||
.checkbox-wrap {
|
||||
display: flex; align-items: center; gap: 12rpx;
|
||||
}
|
||||
.checkbox {
|
||||
width: 40rpx; height: 40rpx; border: 2rpx solid #d1d5db; border-radius: 8rpx;
|
||||
display: flex; align-items: center; justify-content: center;
|
||||
font-size: 24rpx; color: #fff; background: #fff;
|
||||
&.checkbox-checked { background: #1f4b79; border-color: #1f4b79; }
|
||||
}
|
||||
.select-all-text { font-size: 28rpx; color: #374151; }
|
||||
.select-count { font-size: 26rpx; color: #1f4b79; font-weight: 600; }
|
||||
|
||||
.list-scroll { height: calc(100vh - 200rpx - env(safe-area-inset-bottom)); }
|
||||
.item-row {
|
||||
display: flex; align-items: flex-start; gap: 16rpx;
|
||||
padding: 20rpx 24rpx; background: #fff; border-bottom: 1rpx solid #f0f0f0;
|
||||
&:active { background: #f9fafb; }
|
||||
}
|
||||
.item-info { flex: 1; display: flex; flex-direction: column; gap: 8rpx; }
|
||||
.info-row { display: flex; align-items: center; gap: 16rpx; }
|
||||
.info-label { width: 120rpx; font-size: 24rpx; color: #9ca3af; flex-shrink: 0; }
|
||||
.info-val {
|
||||
flex: 1; font-size: 26rpx; color: #374151;
|
||||
&.code { font-family: monospace; color: #6b7280; }
|
||||
&.name { font-weight: 500; color: #1a1a1a; }
|
||||
&.stock { font-weight: 600; color: #1f4b79; }
|
||||
}
|
||||
|
||||
.loading-text, .empty-text, .no-more-text { padding: 40rpx; text-align: center; color: #9ca3af; font-size: 26rpx; }
|
||||
|
||||
.bottom-actions {
|
||||
position: fixed; left: 0; right: 0; bottom: 0; display: flex; gap: 18rpx;
|
||||
padding: 18rpx 24rpx calc(18rpx + env(safe-area-inset-bottom));
|
||||
background: #fff; box-shadow: 0 -8rpx 24rpx rgba(15,23,42,0.06); z-index: 99;
|
||||
}
|
||||
.bottom-btn { flex: 1; height: 84rpx; line-height: 84rpx; text-align: center; border-radius: 16rpx; font-size: 30rpx; font-weight: 600;
|
||||
&:active { opacity: 0.85; }
|
||||
}
|
||||
.cancel-btn { background: #eef2f7; color: #475569; }
|
||||
.confirm-btn { background: #1f4b79; color: #fff; }
|
||||
</style>
|
||||
@ -0,0 +1,225 @@
|
||||
<template>
|
||||
<view class="page-container">
|
||||
<NavBar :title="'选择盘点项'" />
|
||||
|
||||
<view class="search-bar">
|
||||
<input
|
||||
v-model="keyword"
|
||||
class="search-input"
|
||||
placeholder="搜索编码/名称"
|
||||
confirm-type="search"
|
||||
@confirm="handleSearch"
|
||||
/>
|
||||
<text class="search-btn" @click="handleSearch">搜索</text>
|
||||
</view>
|
||||
|
||||
<view class="select-all-bar">
|
||||
<view class="checkbox-wrap" @click="toggleSelectAll">
|
||||
<text :class="['checkbox', isAllSelected ? 'checkbox-checked' : '']">{{ isAllSelected ? '✓' : '' }}</text>
|
||||
<text class="select-all-text">全选</text>
|
||||
</view>
|
||||
<text class="select-count">已选 {{ selectedItems.length }} 项</text>
|
||||
</view>
|
||||
|
||||
<scroll-view scroll-y class="list-scroll">
|
||||
<view v-for="item in filteredList" :key="item.productId + '_' + (item.warehouseId || '')" class="item-row" @click="toggleSelect(item)">
|
||||
<view class="checkbox-wrap">
|
||||
<text :class="['checkbox', isSelected(item) ? 'checkbox-checked' : '']">{{ isSelected(item) ? '✓' : '' }}</text>
|
||||
</view>
|
||||
<view class="item-info">
|
||||
<view class="info-row">
|
||||
<text class="info-label">仓库</text>
|
||||
<text class="info-val">{{ textValue(item.warehouseName) }}</text>
|
||||
</view>
|
||||
<view class="info-row">
|
||||
<text class="info-label">库区</text>
|
||||
<text class="info-val">{{ textValue(item.areaName) }}</text>
|
||||
</view>
|
||||
<view class="info-row">
|
||||
<text class="info-label">编码</text>
|
||||
<text class="info-val code">{{ textValue(item.productBarCode) }}</text>
|
||||
</view>
|
||||
<view class="info-row">
|
||||
<text class="info-label">名称</text>
|
||||
<text class="info-val name">{{ textValue(item.productName) }}</text>
|
||||
</view>
|
||||
<view class="info-row">
|
||||
<text class="info-label">库存数量</text>
|
||||
<text class="info-val stock">{{ textValue(item.stockCount) }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view v-if="loading" class="loading-text">加载中...</view>
|
||||
<view v-if="!loading && !list.length" class="empty-text">暂无数据</view>
|
||||
</scroll-view>
|
||||
|
||||
<view class="bottom-actions">
|
||||
<view class="bottom-btn cancel-btn" @click="handleCancel">取消</view>
|
||||
<view class="bottom-btn confirm-btn" @click="handleConfirm">确定</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, computed } from 'vue'
|
||||
import { onShow, onLoad } from '@dcloudio/uni-app'
|
||||
import NavBar from '@/components/common/NavBar.vue'
|
||||
import { generateCheckItemsByProduct } from '@/api/mes/materialCheck'
|
||||
|
||||
const routeProductId = ref('')
|
||||
const list = ref([])
|
||||
const selectedItems = ref([])
|
||||
const loading = ref(false)
|
||||
const keyword = ref('')
|
||||
let isFirstLoad = true
|
||||
|
||||
const filteredList = computed(() => {
|
||||
if (!keyword.value) return list.value
|
||||
return list.value.filter(item =>
|
||||
(item.productBarCode || '').includes(keyword.value) ||
|
||||
(item.productName || '').includes(keyword.value) ||
|
||||
(item.warehouseName || '').includes(keyword.value)
|
||||
)
|
||||
})
|
||||
|
||||
const isAllSelected = computed(() => {
|
||||
return filteredList.value.length > 0 && filteredList.value.every(item => isSelected(item))
|
||||
})
|
||||
|
||||
function textValue(v) {
|
||||
if (v === 0) return '0'
|
||||
if (v == null) return '-'
|
||||
return String(v).trim() || '-'
|
||||
}
|
||||
|
||||
function getItemKey(item) {
|
||||
return `${item.productId || item.id}_${item.warehouseId || ''}_${item.areaId || ''}`
|
||||
}
|
||||
|
||||
function isSelected(item) {
|
||||
const key = getItemKey(item)
|
||||
return selectedItems.value.some(s => getItemKey(s) === key)
|
||||
}
|
||||
|
||||
function toggleSelect(item) {
|
||||
const key = getItemKey(item)
|
||||
const idx = selectedItems.value.findIndex(s => getItemKey(s) === key)
|
||||
if (idx >= 0) {
|
||||
selectedItems.value.splice(idx, 1)
|
||||
} else {
|
||||
selectedItems.value.push({ ...item })
|
||||
}
|
||||
}
|
||||
|
||||
function toggleSelectAll() {
|
||||
if (isAllSelected.value) {
|
||||
selectedItems.value = []
|
||||
} else {
|
||||
selectedItems.value = [...filteredList.value]
|
||||
}
|
||||
}
|
||||
|
||||
async function loadData() {
|
||||
loading.value = true
|
||||
try {
|
||||
const ids = routeProductId.value.split(',').map(id => Number(id.trim())).filter(Boolean)
|
||||
const res = await generateCheckItemsByProduct({
|
||||
productIds: ids,
|
||||
categoryType: 2,
|
||||
allowEmpty: true
|
||||
})
|
||||
const data = Array.isArray(res) ? res : (Array.isArray(res?.data) ? res.data : [])
|
||||
list.value = data
|
||||
} catch (e) {
|
||||
console.error('loadData error', e)
|
||||
uni.showToast({ title: '加载失败', icon: 'none' })
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function handleSearch() {}
|
||||
|
||||
function handleCancel() {
|
||||
uni.navigateBack()
|
||||
}
|
||||
|
||||
function handleConfirm() {
|
||||
if (!selectedItems.value.length) {
|
||||
uni.showToast({ title: '请至少选择一项', icon: 'none' })
|
||||
return
|
||||
}
|
||||
getApp().globalData._materialCheckItemSelectResult = [...selectedItems.value]
|
||||
uni.navigateBack()
|
||||
}
|
||||
|
||||
onLoad((options) => {
|
||||
routeProductId.value = options?.productIds || options?.productId || ''
|
||||
})
|
||||
|
||||
onShow(() => {
|
||||
const prevSelected = getApp().globalData?._materialCheckItemSelected
|
||||
if (prevSelected && Array.isArray(prevSelected)) {
|
||||
selectedItems.value = prevSelected.map(item => ({
|
||||
id: item.id || item.productId,
|
||||
productId: item.productId || item.id,
|
||||
warehouseId: item.warehouseId,
|
||||
areaId: item.areaId,
|
||||
warehouseName: item.warehouseName,
|
||||
areaName: item.areaName,
|
||||
productBarCode: item.productBarCode,
|
||||
productName: item.productName,
|
||||
stockCount: item.stockCount,
|
||||
productPrice: item.productPrice
|
||||
}))
|
||||
getApp().globalData._materialCheckItemSelected = null
|
||||
}
|
||||
if (isFirstLoad) {
|
||||
isFirstLoad = false
|
||||
loadData()
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.page-container {
|
||||
min-height: 100vh;
|
||||
background: #f5f6f8;
|
||||
padding-bottom: calc(120rpx + env(safe-area-inset-bottom));
|
||||
}
|
||||
|
||||
.search-bar { display: flex; gap: 16rpx; padding: 20rpx 24rpx; background: #fff; }
|
||||
.search-input { flex: 1; height: 72rpx; padding: 0 24rpx; background: #f3f4f6; border-radius: 12rpx; font-size: 28rpx; }
|
||||
.search-btn { display: flex; align-items: center; justify-content: center; width: 120rpx; height: 72rpx; background: #1f4b79; color: #fff; border-radius: 12rpx; font-size: 28rpx; }
|
||||
|
||||
.select-all-bar { display: flex; align-items: center; justify-content: space-between; padding: 20rpx 24rpx; background: #fff; border-bottom: 1rpx solid #f0f0f0; }
|
||||
.checkbox-wrap { display: flex; align-items: center; gap: 12rpx; }
|
||||
.checkbox { width: 40rpx; height: 40rpx; border: 2rpx solid #d1d5db; border-radius: 8rpx; display: flex; align-items: center; justify-content: center; font-size: 24rpx; color: #fff; background: #fff;
|
||||
&.checkbox-checked { background: #1f4b79; border-color: #1f4b79; }
|
||||
}
|
||||
.select-all-text { font-size: 28rpx; color: #374151; }
|
||||
.select-count { font-size: 26rpx; color: #1f4b79; font-weight: 600; }
|
||||
|
||||
.list-scroll { height: calc(100vh - 330rpx - env(safe-area-inset-bottom)); }
|
||||
.item-row { display: flex; align-items: flex-start; gap: 16rpx; padding: 20rpx 24rpx; background: #fff; border-bottom: 1rpx solid #f0f0f0;
|
||||
&:active { background: #f9fafb; }
|
||||
}
|
||||
.item-info { flex: 1; display: flex; flex-direction: column; gap: 8rpx; }
|
||||
.info-row { display: flex; align-items: center; gap: 16rpx; }
|
||||
.info-label { width: 120rpx; font-size: 24rpx; color: #9ca3af; flex-shrink: 0; }
|
||||
.info-val { flex: 1; font-size: 26rpx; color: #374151;
|
||||
&.code { font-family: monospace; color: #6b7280; }
|
||||
&.name { font-weight: 500; color: #1a1a1a; }
|
||||
&.stock { font-weight: 600; color: #1f4b79; }
|
||||
}
|
||||
|
||||
.loading-text, .empty-text { padding: 40rpx; text-align: center; color: #9ca3af; font-size: 26rpx; }
|
||||
|
||||
.bottom-actions { position: fixed; left: 0; right: 0; bottom: 0; display: flex; gap: 18rpx; padding: 18rpx 24rpx calc(18rpx + env(safe-area-inset-bottom)); background: #fff; box-shadow: 0 -8rpx 24rpx rgba(15,23,42,0.06); z-index: 99; }
|
||||
.bottom-btn { flex: 1; height: 84rpx; line-height: 84rpx; text-align: center; border-radius: 16rpx; font-size: 30rpx; font-weight: 600;
|
||||
&:active { opacity: 0.85; }
|
||||
}
|
||||
.cancel-btn { background: #eef2f7; color: #475569; }
|
||||
.confirm-btn { background: #1f4b79; color: #fff; }
|
||||
</style>
|
||||
@ -0,0 +1,228 @@
|
||||
<template>
|
||||
<view class="page-container">
|
||||
<NavBar :title="'选择产品'" />
|
||||
|
||||
<view class="search-bar">
|
||||
<input
|
||||
v-model="keyword"
|
||||
class="search-input"
|
||||
placeholder="搜索编码/名称"
|
||||
confirm-type="search"
|
||||
@confirm="handleSearch"
|
||||
/>
|
||||
<text class="search-btn" @click="handleSearch">搜索</text>
|
||||
</view>
|
||||
|
||||
<view class="select-all-bar">
|
||||
<view class="checkbox-wrap" @click="toggleSelectAll">
|
||||
<text :class="['checkbox', isAllSelected ? 'checkbox-checked' : '']">{{ isAllSelected ? '✓' : '' }}</text>
|
||||
<text class="select-all-text">全选</text>
|
||||
</view>
|
||||
<text class="select-count">已选 {{ selectedItems.length }} 项</text>
|
||||
</view>
|
||||
|
||||
<scroll-view scroll-y class="list-scroll" @scrolltolower="loadMore">
|
||||
<view v-for="item in list" :key="item.id" class="item-row" @click="toggleSelect(item)">
|
||||
<view class="checkbox-wrap">
|
||||
<text :class="['checkbox', isSelected(item) ? 'checkbox-checked' : '']">{{ isSelected(item) ? '✓' : '' }}</text>
|
||||
</view>
|
||||
<view class="item-info">
|
||||
<view class="info-row">
|
||||
<text class="info-label">编码</text>
|
||||
<text class="info-val code">{{ textValue(item.barCode || item.productBarCode) }}</text>
|
||||
</view>
|
||||
<view class="info-row">
|
||||
<text class="info-label">名称</text>
|
||||
<text class="info-val name">{{ textValue(item.name || item.productName) }}</text>
|
||||
</view>
|
||||
<view class="info-row">
|
||||
<text class="info-label">单位</text>
|
||||
<text class="info-val">{{ textValue(item.unitName || item.productUnitName) }}</text>
|
||||
</view>
|
||||
<view class="info-row">
|
||||
<text class="info-label">规格型号</text>
|
||||
<text class="info-val">{{ textValue(item.standard || item.productStandard) }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view v-if="loading" class="loading-text">加载中...</view>
|
||||
<view v-if="!loading && !list.length" class="empty-text">暂无数据</view>
|
||||
<view v-if="!loading && list.length && noMore" class="no-more-text">没有更多了</view>
|
||||
</scroll-view>
|
||||
|
||||
<view class="bottom-actions">
|
||||
<view class="bottom-btn cancel-btn" @click="handleCancel">取消</view>
|
||||
<view class="bottom-btn confirm-btn" @click="handleConfirm">确定</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, computed } from 'vue'
|
||||
import { onShow } from '@dcloudio/uni-app'
|
||||
import NavBar from '@/components/common/NavBar.vue'
|
||||
import { getMaterialSimpleList } from '@/api/mes/sparepart'
|
||||
|
||||
const list = ref([])
|
||||
const selectedItems = ref([])
|
||||
const loading = ref(false)
|
||||
const noMore = ref(false)
|
||||
const pageNo = ref(1)
|
||||
const pageSize = 20
|
||||
const keyword = ref('')
|
||||
|
||||
const isAllSelected = computed(() => {
|
||||
return list.value.length > 0 && list.value.every(item => isSelected(item))
|
||||
})
|
||||
|
||||
function textValue(v) {
|
||||
if (v === 0) return '0'
|
||||
if (v == null) return '-'
|
||||
return String(v).trim() || '-'
|
||||
}
|
||||
|
||||
function isSelected(item) {
|
||||
return selectedItems.value.some(s => String(s.id) === String(item.id))
|
||||
}
|
||||
|
||||
function toggleSelect(item) {
|
||||
const idx = selectedItems.value.findIndex(s => String(s.id) === String(item.id))
|
||||
if (idx >= 0) {
|
||||
selectedItems.value.splice(idx, 1)
|
||||
} else {
|
||||
selectedItems.value.push({
|
||||
id: item.id,
|
||||
name: item.name || item.productName,
|
||||
barCode: item.barCode || item.productBarCode,
|
||||
unitName: item.unitName || item.productUnitName,
|
||||
standard: item.standard || item.productStandard
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
function toggleSelectAll() {
|
||||
if (isAllSelected.value) {
|
||||
selectedItems.value = []
|
||||
} else {
|
||||
selectedItems.value = list.value.map(item => ({
|
||||
id: item.id,
|
||||
name: item.name || item.productName,
|
||||
barCode: item.barCode || item.productBarCode,
|
||||
unitName: item.unitName || item.productUnitName,
|
||||
standard: item.standard || item.productStandard
|
||||
}))
|
||||
}
|
||||
}
|
||||
|
||||
async function loadData(reset = false) {
|
||||
if (loading.value) return
|
||||
if (reset) {
|
||||
pageNo.value = 1
|
||||
list.value = []
|
||||
noMore.value = false
|
||||
}
|
||||
loading.value = true
|
||||
try {
|
||||
const res = await getMaterialSimpleList(pageNo.value)
|
||||
let root = res && res.data !== undefined ? res.data : res
|
||||
let pageList = Array.isArray(root)
|
||||
? root
|
||||
: Array.isArray(root?.list) ? root.list
|
||||
: Array.isArray(root?.rows) ? root.rows
|
||||
: []
|
||||
|
||||
if (keyword.value) {
|
||||
pageList = pageList.filter(item =>
|
||||
(item.barCode || item.productBarCode || '').includes(keyword.value) ||
|
||||
(item.name || item.productName || '').includes(keyword.value)
|
||||
)
|
||||
}
|
||||
|
||||
if (reset) {
|
||||
list.value = pageList
|
||||
} else {
|
||||
list.value.push(...pageList)
|
||||
}
|
||||
|
||||
if (pageList.length < pageSize) {
|
||||
noMore.value = true
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('loadData error', e)
|
||||
uni.showToast({ title: '加载失败', icon: 'none' })
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function loadMore() {
|
||||
if (!noMore.value && !loading.value) {
|
||||
pageNo.value++
|
||||
loadData()
|
||||
}
|
||||
}
|
||||
|
||||
function handleSearch() {
|
||||
loadData(true)
|
||||
}
|
||||
|
||||
function handleCancel() {
|
||||
uni.navigateBack()
|
||||
}
|
||||
|
||||
function handleConfirm() {
|
||||
if (!selectedItems.value.length) {
|
||||
uni.showToast({ title: '请至少选择一项', icon: 'none' })
|
||||
return
|
||||
}
|
||||
getApp().globalData._materialCheckProductSelectResult = [...selectedItems.value]
|
||||
uni.navigateBack()
|
||||
}
|
||||
|
||||
onShow(() => {
|
||||
const prevSelected = getApp().globalData?._materialCheckProductSelected
|
||||
if (prevSelected && Array.isArray(prevSelected)) {
|
||||
selectedItems.value = prevSelected
|
||||
getApp().globalData._materialCheckProductSelected = null
|
||||
}
|
||||
loadData(true)
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.page-container { min-height: 100vh; background: #f5f6f8; padding-bottom: calc(120rpx + env(safe-area-inset-bottom)); }
|
||||
|
||||
.search-bar { display: flex; gap: 16rpx; padding: 20rpx 24rpx; background: #fff; }
|
||||
.search-input { flex: 1; height: 72rpx; padding: 0 24rpx; background: #f3f4f6; border-radius: 12rpx; font-size: 28rpx; }
|
||||
.search-btn { display: flex; align-items: center; justify-content: center; width: 120rpx; height: 72rpx; background: #1f4b79; color: #fff; border-radius: 12rpx; font-size: 28rpx; }
|
||||
|
||||
.select-all-bar { display: flex; align-items: center; justify-content: space-between; padding: 20rpx 24rpx; background: #fff; border-bottom: 1rpx solid #f0f0f0; }
|
||||
.checkbox-wrap { display: flex; align-items: center; gap: 12rpx; }
|
||||
.checkbox { width: 40rpx; height: 40rpx; border: 2rpx solid #d1d5db; border-radius: 8rpx; display: flex; align-items: center; justify-content: center; font-size: 24rpx; color: #fff; background: #fff;
|
||||
&.checkbox-checked { background: #1f4b79; border-color: #1f4b79; }
|
||||
}
|
||||
.select-all-text { font-size: 28rpx; color: #374151; }
|
||||
.select-count { font-size: 26rpx; color: #1f4b79; font-weight: 600; }
|
||||
|
||||
.list-scroll { height: calc(100vh - 330rpx - env(safe-area-inset-bottom)); }
|
||||
.item-row { display: flex; align-items: flex-start; gap: 16rpx; padding: 20rpx 24rpx; background: #fff; border-bottom: 1rpx solid #f0f0f0;
|
||||
&:active { background: #f9fafb; }
|
||||
}
|
||||
.item-info { flex: 1; display: flex; flex-direction: column; gap: 8rpx; }
|
||||
.info-row { display: flex; align-items: center; gap: 16rpx; }
|
||||
.info-label { width: 120rpx; font-size: 24rpx; color: #9ca3af; flex-shrink: 0; }
|
||||
.info-val { flex: 1; font-size: 26rpx; color: #374151;
|
||||
&.code { font-family: monospace; color: #6b7280; }
|
||||
&.name { font-weight: 500; color: #1a1a1a; }
|
||||
}
|
||||
|
||||
.loading-text, .empty-text, .no-more-text { padding: 40rpx; text-align: center; color: #9ca3af; font-size: 26rpx; }
|
||||
|
||||
.bottom-actions { position: fixed; left: 0; right: 0; bottom: 0; display: flex; gap: 18rpx; padding: 18rpx 24rpx calc(18rpx + env(safe-area-inset-bottom)); background: #fff; box-shadow: 0 -8rpx 24rpx rgba(15,23,42,0.06); z-index: 99; }
|
||||
.bottom-btn { flex: 1; height: 84rpx; line-height: 84rpx; text-align: center; border-radius: 16rpx; font-size: 30rpx; font-weight: 600;
|
||||
&:active { opacity: 0.85; }
|
||||
}
|
||||
.cancel-btn { background: #eef2f7; color: #475569; }
|
||||
.confirm-btn { background: #1f4b79; color: #fff; }
|
||||
</style>
|
||||
@ -0,0 +1,190 @@
|
||||
<template>
|
||||
<view class="page-container">
|
||||
<NavBar :title="'选择库区'" />
|
||||
|
||||
<view class="search-bar">
|
||||
<input
|
||||
v-model="keyword"
|
||||
class="search-input"
|
||||
placeholder="搜索库区编码/名称"
|
||||
confirm-type="search"
|
||||
@confirm="handleSearch"
|
||||
/>
|
||||
<text class="search-btn" @click="handleSearch">搜索</text>
|
||||
</view>
|
||||
|
||||
<view class="select-all-bar">
|
||||
<view class="checkbox-wrap" @click="toggleSelectAll">
|
||||
<text :class="['checkbox', isAllSelected ? 'checkbox-checked' : '']">{{ isAllSelected ? '✓' : '' }}</text>
|
||||
<text class="select-all-text">全选</text>
|
||||
</view>
|
||||
<text class="select-count">已选 {{ selectedItems.length }} 项</text>
|
||||
</view>
|
||||
|
||||
<scroll-view scroll-y class="list-scroll">
|
||||
<view v-for="item in filteredList" :key="item.id" class="item-row" @click="toggleSelect(item)">
|
||||
<view class="checkbox-wrap">
|
||||
<text :class="['checkbox', isSelected(item) ? 'checkbox-checked' : '']">{{ isSelected(item) ? '✓' : '' }}</text>
|
||||
</view>
|
||||
<view class="item-info">
|
||||
<view class="info-row">
|
||||
<text class="info-label">库区编码</text>
|
||||
<text class="info-val code">{{ textValue(item.areaCode) }}</text>
|
||||
</view>
|
||||
<view class="info-row">
|
||||
<text class="info-label">库区名称</text>
|
||||
<text class="info-val name">{{ textValue(item.areaName) }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view v-if="loading" class="loading-text">加载中...</view>
|
||||
<view v-if="!loading && !list.length" class="empty-text">暂无数据</view>
|
||||
</scroll-view>
|
||||
|
||||
<view class="bottom-actions">
|
||||
<view class="bottom-btn cancel-btn" @click="handleCancel">取消</view>
|
||||
<view class="bottom-btn confirm-btn" @click="handleConfirm">确定</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, computed } from 'vue'
|
||||
import { onShow } from '@dcloudio/uni-app'
|
||||
import NavBar from '@/components/common/NavBar.vue'
|
||||
import { getWarehouseAreaSimpleList } from '@/api/mes/moldget'
|
||||
|
||||
const list = ref([])
|
||||
const selectedItems = ref([])
|
||||
const loading = ref(false)
|
||||
const keyword = ref('')
|
||||
const warehouseId = ref('')
|
||||
|
||||
const filteredList = computed(() => {
|
||||
if (!keyword.value) return list.value
|
||||
return list.value.filter(item =>
|
||||
(item.areaCode || '').includes(keyword.value) ||
|
||||
(item.areaName || '').includes(keyword.value)
|
||||
)
|
||||
})
|
||||
|
||||
const isAllSelected = computed(() => {
|
||||
return filteredList.value.length > 0 && filteredList.value.every(item => isSelected(item))
|
||||
})
|
||||
|
||||
function textValue(v) {
|
||||
if (v === 0) return '0'
|
||||
if (v == null) return '-'
|
||||
return String(v).trim() || '-'
|
||||
}
|
||||
|
||||
function isSelected(item) {
|
||||
return selectedItems.value.some(s => String(s.id) === String(item.id))
|
||||
}
|
||||
|
||||
function toggleSelect(item) {
|
||||
const idx = selectedItems.value.findIndex(s => String(s.id) === String(item.id))
|
||||
if (idx >= 0) {
|
||||
selectedItems.value.splice(idx, 1)
|
||||
} else {
|
||||
selectedItems.value.push({
|
||||
id: item.id,
|
||||
code: item.areaCode || '',
|
||||
name: item.areaName || ''
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
function toggleSelectAll() {
|
||||
if (isAllSelected.value) {
|
||||
selectedItems.value = []
|
||||
} else {
|
||||
selectedItems.value = filteredList.value.map(item => ({
|
||||
id: item.id,
|
||||
code: item.areaCode || '',
|
||||
name: item.areaName || ''
|
||||
}))
|
||||
}
|
||||
}
|
||||
|
||||
async function loadData() {
|
||||
loading.value = true
|
||||
try {
|
||||
const res = await getWarehouseAreaSimpleList(warehouseId.value)
|
||||
const data = Array.isArray(res) ? res : (Array.isArray(res?.data) ? res.data : [])
|
||||
list.value = data
|
||||
} catch (e) {
|
||||
console.error('loadAreaData error', e)
|
||||
uni.showToast({ title: '加载失败', icon: 'none' })
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function handleSearch() {}
|
||||
|
||||
function handleCancel() {
|
||||
uni.navigateBack()
|
||||
}
|
||||
|
||||
function handleConfirm() {
|
||||
if (!selectedItems.value.length) {
|
||||
uni.showToast({ title: '请至少选择一项', icon: 'none' })
|
||||
return
|
||||
}
|
||||
getApp().globalData._checkAreaSelectResult = [...selectedItems.value]
|
||||
uni.navigateBack()
|
||||
}
|
||||
|
||||
onShow(() => {
|
||||
const prevSelected = getApp().globalData?._checkAreaSelected
|
||||
if (prevSelected && Array.isArray(prevSelected)) {
|
||||
selectedItems.value = prevSelected.map(a => ({
|
||||
id: a.value,
|
||||
code: a.code || '',
|
||||
name: a.label || ''
|
||||
}))
|
||||
getApp().globalData._checkAreaSelected = null
|
||||
}
|
||||
warehouseId.value = getApp().globalData?._checkAreaWarehouseId || ''
|
||||
loadData()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.page-container { min-height: 100vh; background: #f5f6f8; padding-bottom: calc(120rpx + env(safe-area-inset-bottom)); }
|
||||
|
||||
.search-bar { display: flex; gap: 16rpx; padding: 20rpx 24rpx; background: #fff; }
|
||||
.search-input { flex: 1; height: 72rpx; padding: 0 24rpx; background: #f3f4f6; border-radius: 12rpx; font-size: 28rpx; }
|
||||
.search-btn { display: flex; align-items: center; justify-content: center; width: 120rpx; height: 72rpx; background: #1f4b79; color: #fff; border-radius: 12rpx; font-size: 28rpx; }
|
||||
|
||||
.select-all-bar { display: flex; align-items: center; justify-content: space-between; padding: 20rpx 24rpx; background: #fff; border-bottom: 1rpx solid #f0f0f0; }
|
||||
.checkbox-wrap { display: flex; align-items: center; gap: 12rpx; }
|
||||
.checkbox { width: 40rpx; height: 40rpx; border: 2rpx solid #d1d5db; border-radius: 8rpx; display: flex; align-items: center; justify-content: center; font-size: 24rpx; color: #fff; background: #fff;
|
||||
&.checkbox-checked { background: #1f4b79; border-color: #1f4b79; }
|
||||
}
|
||||
.select-all-text { font-size: 28rpx; color: #374151; }
|
||||
.select-count { font-size: 26rpx; color: #1f4b79; font-weight: 600; }
|
||||
|
||||
.list-scroll { height: calc(100vh - 330rpx - env(safe-area-inset-bottom)); }
|
||||
.item-row { display: flex; align-items: flex-start; gap: 16rpx; padding: 20rpx 24rpx; background: #fff; border-bottom: 1rpx solid #f0f0f0;
|
||||
&:active { background: #f9fafb; }
|
||||
}
|
||||
.item-info { flex: 1; display: flex; flex-direction: column; gap: 8rpx; }
|
||||
.info-row { display: flex; align-items: center; gap: 16rpx; }
|
||||
.info-label { width: 120rpx; font-size: 24rpx; color: #9ca3af; flex-shrink: 0; }
|
||||
.info-val { flex: 1; font-size: 26rpx; color: #374151;
|
||||
&.code { font-family: monospace; color: #6b7280; }
|
||||
&.name { font-weight: 500; color: #1a1a1a; }
|
||||
}
|
||||
|
||||
.loading-text, .empty-text { padding: 40rpx; text-align: center; color: #9ca3af; font-size: 26rpx; }
|
||||
|
||||
.bottom-actions { position: fixed; left: 0; right: 0; bottom: 0; display: flex; gap: 18rpx; padding: 18rpx 24rpx calc(18rpx + env(safe-area-inset-bottom)); background: #fff; box-shadow: 0 -8rpx 24rpx rgba(15,23,42,0.06); z-index: 99; }
|
||||
.bottom-btn { flex: 1; height: 84rpx; line-height: 84rpx; text-align: center; border-radius: 16rpx; font-size: 30rpx; font-weight: 600;
|
||||
&:active { opacity: 0.85; }
|
||||
}
|
||||
.cancel-btn { background: #eef2f7; color: #475569; }
|
||||
.confirm-btn { background: #1f4b79; color: #fff; }
|
||||
</style>
|
||||
Loading…
Reference in New Issue