WMS_PDA/src/components/space-list/space-list.vue
zm2000 dc554f9a9e refactor: 搜索框组件化统一重构,新增拆单页面功能
一、新增共享搜索组件 SearchBar
- 新增 src/components/SearchBar/SearchBar.vue
- 将各页面内联的「搜索输入 + 扫码按钮 + 搜索按钮」统一封装
- 支持 input-font-size / search-text-font-size / show-scan /
  show-search / focus / disabled / scan-icon 等属性
- 统一输入框与搜索文字字号为 34rpx

二、各页面搜索框接入 SearchBar 组件(删除重复样式代码)
- 首页快捷操作、工作台配置
- 商品查询、库位查询、库内转移、随机上架、收货及子组件
- 盘点相关组件(工具栏、搜索面板、明细选择、记录新增、实盘数量)
- 订单复核、复核列表、称重、包材绑定、拦截登记
- 散单/团单拣货详情、退单记录、发货标签、打印补打、缺货补货

三、通用样式调整
- page-nav 页面标题字号 32rpx -> 36rpx

四、拆单页面(src/pages/packing/splitOrder.vue)功能完善
- 未绑定按钮字号与输入框按钮统一为 36rpx
- 未查询时显示空态提示(参考绑定包材页面),并固定定位避免跳动
- 修复空态遮挡导致搜索输入框无法聚焦的问题
- 快递号面板样式参考拦截登记页面,子单号标签白底黑字并对齐
- 面板与操作按钮分隔,左右留白统一 24rpx
- 子单号列表支持滚动查看(最大高度 400rpx)
- 拆单按钮改为蓝色、36rpx、不加粗
- 拆单数量弹窗参考完成盘点弹窗(640rpx、20rpx 圆角、88rpx 按钮),
  新增右上角关闭图标,点击遮罩不关闭
- 拆单失败时从 order.detail 日志提取「子单号分配」失败 message,
  使用自定义 u-popup 弹窗完整展示失败信息
2026-11-10 18:20:38 +08:00

294 lines
6.1 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<!-- 货位列表弹窗 -->
<u-popup :show="show" mode="bottom" round="20" :closeable="true" :safeAreaInsetBottom="true" @close="handleClose">
<view class="space-list-container">
<!-- 标题 -->
<view class="popup-header">
<text class="popup-title">选择货位</text>
<text class="popup-subtitle">共{{ spaceList.length }}个货位</text>
</view>
<!-- 搜索框 -->
<view class="search-box" v-if="showSearch">
<SearchBar
v-model="searchKeyword"
placeholder="搜索货位编码、自定义名称"
:show-scan="false"
:show-search="false"
:input-font-size="'34rpx'"
:search-text-font-size="'34rpx'"
@search="handleSearch"
@clear="handleSearch"
></SearchBar>
</view>
<!-- 货位列表 -->
<scroll-view class="space-list-scroll" scroll-y :style="{ height: scrollHeight }">
<!-- 空状态 -->
<u-empty v-if="filteredList.length === 0" mode="data" icon="http://cdn.uviewui.com/uview/empty/data.png"
:text="searchKeyword ? '未找到相关货位' : '暂无货位数据'"></u-empty>
<!-- 货位列表项 -->
<view v-for="(item, index) in filteredList" :key="item.id || index" class="space-item"
:class="{ 'space-item-selected': selectedId === item.id }" @click="handleSelect(item)">
<view class="space-item-left">
<!-- 货位信息 -->
<view class="space-info">
<!-- 货位编码 -->
<view class="space-code">
<text class="code-text">{{ item.space_code }}</text>
</view>
<!-- 自定义名称 -->
<view v-if="item.custom_name" class="custom-name">
<text class="name-text">{{ item.custom_name }}</text>
</view>
<!-- 自定义条码 -->
<view v-if="item.custom_barcode" class="custom-barcode">
<text class="barcode-text">条码:{{ item.custom_barcode }}</text>
</view>
</view>
</view>
<view class="space-item-right">
<!-- 选中标记 -->
<u-icon v-if="selectedId === item.id" name="checkmark-circle-fill" color="#2979ff" size="20"
class="check-icon" />
</view>
</view>
</scroll-view>
<!-- 底部按钮 -->
<view class="popup-footer" v-if="showConfirm">
<u-button type="primary" :disabled="!selectedItem" @click="handleConfirm">
确认选择
</u-button>
</view>
</view>
</u-popup>
</template>
<script>
export default {
name: 'space-list',
props: {
// 货位列表数据
spaceList: {
type: Array,
default: () => []
},
// 是否显示弹窗
show: {
type: Boolean,
default: false
},
// 是否显示搜索框
showSearch: {
type: Boolean,
default: true
},
// 是否显示确认按钮
showConfirm: {
type: Boolean,
default: true
},
// 滚动区域高度(默认500rpx)
scrollHeight: {
type: String,
default: '500rpx'
}
},
data() {
return {
searchKeyword: '',
selectedItem: null,
filteredList: [],
selectedId: null,
};
},
watch: {
spaceList: {
immediate: true,
handler(newVal) {
this.filteredList = [...newVal];
}
},
selectedId: {
immediate: true,
handler(newVal) {
if (newVal) {
this.selectedItem = this.spaceList.find(item => item.id === newVal);
}
}
}
},
methods: {
// 搜索处理
handleSearch() {
const keyword = this.searchKeyword.trim().toLowerCase();
if (!keyword) {
this.filteredList = [...this.spaceList];
return;
}
this.filteredList = this.spaceList.filter(item => {
return (
(item.space_code && item.space_code.toLowerCase().includes(keyword)) ||
(item.custom_name && item.custom_name.toLowerCase().includes(keyword)) ||
(item.custom_barcode && item.custom_barcode.toLowerCase().includes(keyword))
);
});
// 触发搜索事件
this.$emit('searchSpace', this.searchKeyword);
},
// 选择货位项
handleSelect(item) {
this.selectedItem = item;
this.selectedId = item.id;
// 如果不显示确认按钮,直接触发选择事件
if (!this.showConfirm) {
this.$emit('select', item);
this.$emit('close');
}
},
// 确认选择
handleConfirm() {
if (this.selectedItem) {
this.$emit('select', this.selectedItem);
this.handleClose();
}
},
// 关闭弹窗
handleClose() {
this.searchKeyword = '';
this.selectedItem = null;
this.selectedId = null;
this.$emit('close');
}
}
};
</script>
<style lang="scss" scoped>
.space-list-container {
padding: 30rpx;
background-color: #f5f5f5;
.popup-header {
text-align: center;
margin-bottom: 30rpx;
.popup-title {
display: block;
font-size: 32rpx;
font-weight: bold;
color: #333;
margin-bottom: 10rpx;
}
.popup-subtitle {
font-size: 24rpx;
color: #909399;
}
}
.search-box {
background-color: #fff;
border-radius: 12rpx;
padding: 20rpx 24rpx;
margin-bottom: 24rpx;
box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.05);
}
.space-list-scroll {
background-color: #fff;
border-radius: 12rpx;
overflow: hidden;
}
.space-item {
display: flex;
align-items: center;
padding: 24rpx;
border-bottom: 1rpx solid #f0f0f0;
position: relative;
&:last-child {
border-bottom: none;
}
&-selected {
background-color: #f0f7ff;
}
&-left {
flex: 1;
margin-right: 20rpx;
}
&-right {
display: flex;
align-items: center;
}
.space-info {
.space-code {
margin-bottom: 8rpx;
.code-text {
font-size: 28rpx;
font-weight: 500;
color: #333;
line-height: 1.4;
}
}
.custom-name {
margin-bottom: 8rpx;
.name-text {
font-size: 26rpx;
color: #666;
line-height: 1.4;
}
}
.custom-barcode {
.barcode-text {
font-size: 24rpx;
color: #909399;
line-height: 1.4;
}
}
}
.check-icon {
margin-left: 10rpx;
}
}
.popup-footer {
margin-top: 30rpx;
::v-deep .u-button {
height: 80rpx;
border-radius: 12rpx;
font-size: 30rpx;
}
}
}
</style>