feat: 优化商品查询页布局与详情跳转
This commit is contained in:
parent
5305f77560
commit
6d7a1bd28d
@ -135,6 +135,12 @@ export default {
|
|||||||
isSystemApi: true
|
isSystemApi: true
|
||||||
},
|
},
|
||||||
warehouse: {
|
warehouse: {
|
||||||
|
list: {
|
||||||
|
path: "stock.warehouse.list",
|
||||||
|
auth: true,
|
||||||
|
method: "POST",
|
||||||
|
isSystemApi: true
|
||||||
|
},
|
||||||
search: {
|
search: {
|
||||||
path: "stock.warehouse.search",
|
path: "stock.warehouse.search",
|
||||||
auth: true,
|
auth: true,
|
||||||
|
|||||||
@ -127,6 +127,13 @@
|
|||||||
{
|
{
|
||||||
"titleNView": false
|
"titleNView": false
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path" : "pages/work/product/detail",
|
||||||
|
"style" :
|
||||||
|
{
|
||||||
|
"titleNView": false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
],
|
],
|
||||||
|
|||||||
@ -2,76 +2,59 @@
|
|||||||
<view class="login-container" :style="bgStyle">
|
<view class="login-container" :style="bgStyle">
|
||||||
<view class="form_box">
|
<view class="form_box">
|
||||||
<view class="header-section">
|
<view class="header-section">
|
||||||
<u--image
|
<text class="system-title">PDA仓库管理系统</text>
|
||||||
shape="circle"
|
|
||||||
:src="logo"
|
|
||||||
width="120rpx"
|
|
||||||
height="120rpx"
|
|
||||||
mode="aspectFit"
|
|
||||||
></u--image>
|
|
||||||
<text class="app-name">设备登录</text>
|
|
||||||
<text class="welcome-text">请选择登录方式</text>
|
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view class="login-methods">
|
<view class="login-methods">
|
||||||
<!-- 二维码登录 -->
|
<!-- 账号密码登录 -->
|
||||||
<view class="method-card" @click="showQrCode = true">
|
<view class="method-card direct-login-card">
|
||||||
<view class="method-icon">
|
<view class="direct-login-form">
|
||||||
<u-icon name="chat" size="60rpx" color="#2979ff"></u-icon>
|
<u--input
|
||||||
|
v-model="loginForm.username"
|
||||||
|
placeholder="请输入账号"
|
||||||
|
inputAlign="center"
|
||||||
|
clearable
|
||||||
|
border="bottom"
|
||||||
|
:customStyle="{ marginBottom: '24rpx' }"
|
||||||
|
></u--input>
|
||||||
|
<view class="password-input-wrap">
|
||||||
|
<u--input
|
||||||
|
v-model="loginForm.password"
|
||||||
|
placeholder="请输入密码"
|
||||||
|
inputAlign="center"
|
||||||
|
:type="showPassword ? 'text' : 'password'"
|
||||||
|
@confirm="Login"
|
||||||
|
clearable
|
||||||
|
border="bottom"
|
||||||
|
:customStyle="{ marginBottom: '24rpx' }"
|
||||||
|
></u--input>
|
||||||
|
<u-icon
|
||||||
|
class="password-toggle-icon"
|
||||||
|
:name="showPassword ? 'eye' : 'eye-off-outline'"
|
||||||
|
size="32rpx"
|
||||||
|
color="#666"
|
||||||
|
@click="togglePasswordVisibility"
|
||||||
|
></u-icon>
|
||||||
|
</view>
|
||||||
|
<u-button
|
||||||
|
type="primary"
|
||||||
|
text="登录"
|
||||||
|
@click="Login"
|
||||||
|
></u-button>
|
||||||
</view>
|
</view>
|
||||||
<text class="method-title">账号登录</text>
|
|
||||||
<text class="method-desc">使用账号密码登录</text>
|
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 广播扫描登录 -->
|
<!-- 广播扫描登录 -->
|
||||||
<view class="method-card" @click="startBroadcastScan">
|
<view class="method-card scan-login-card">
|
||||||
<view class="method-icon">
|
<view class="method-icon">
|
||||||
<u-icon name="scan" size="60rpx" color="#19be6b"></u-icon>
|
<u-icon name="scan" size="36rpx" color="#19be6b"></u-icon>
|
||||||
</view>
|
</view>
|
||||||
<text class="method-title">扫描工牌登录</text>
|
<text class="method-desc">PDA扫描工牌登录</text>
|
||||||
<text class="method-desc">PDA直接扫描工牌登录</text>
|
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 二维码登录弹窗 -->
|
|
||||||
<u-popup
|
|
||||||
:show="showQrCode"
|
|
||||||
mode="center"
|
|
||||||
round="10"
|
|
||||||
@close="showQrCode = false"
|
|
||||||
>
|
|
||||||
<view class="qr-popup">
|
|
||||||
<view class="popup-header">
|
|
||||||
<text class="popup-title">账号密码登录</text>
|
|
||||||
<u-icon name="close" size="24" @click="showQrCode = false"></u-icon>
|
|
||||||
</view>
|
|
||||||
<view class="qr-container">
|
|
||||||
<u--input
|
|
||||||
v-model="loginForm.username"
|
|
||||||
placeholder="请输入用户名"
|
|
||||||
border="bottom"
|
|
||||||
clearable
|
|
||||||
:customStyle="{ marginBottom: '40rpx' }"
|
|
||||||
></u--input>
|
|
||||||
<u--input
|
|
||||||
v-model="loginForm.password"
|
|
||||||
placeholder="请输入密码"
|
|
||||||
border="bottom"
|
|
||||||
clearable
|
|
||||||
:customStyle="{ marginBottom: '40rpx' }"
|
|
||||||
></u--input>
|
|
||||||
|
|
||||||
<u-button
|
|
||||||
type="primary"
|
|
||||||
text="登录"
|
|
||||||
@click="Login"
|
|
||||||
></u-button>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
</u-popup>
|
|
||||||
|
|
||||||
<!-- 消息提示 -->
|
<!-- 消息提示 -->
|
||||||
<u-toast ref="uToast"></u-toast>
|
<u-toast ref="uToast"></u-toast>
|
||||||
<u-notify ref="uNotify"></u-notify>
|
<u-notify ref="uNotify"></u-notify>
|
||||||
@ -88,9 +71,8 @@ export default {
|
|||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
bgStyle: '',
|
bgStyle: '',
|
||||||
logo: '/static/logo.png',
|
|
||||||
showQrCode: false,
|
|
||||||
showLoginConfirm: false,
|
showLoginConfirm: false,
|
||||||
|
showPassword: false,
|
||||||
scanning: false,
|
scanning: false,
|
||||||
deviceCode: '',
|
deviceCode: '',
|
||||||
scanUuid: '',
|
scanUuid: '',
|
||||||
@ -130,6 +112,9 @@ export default {
|
|||||||
this.$store.dispatch('broadcast/stop');
|
this.$store.dispatch('broadcast/stop');
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
togglePasswordVisibility() {
|
||||||
|
this.showPassword = !this.showPassword;
|
||||||
|
},
|
||||||
decodeBase64Text(value) {
|
decodeBase64Text(value) {
|
||||||
if (!value) return '';
|
if (!value) return '';
|
||||||
if (typeof atob !== 'function') return '';
|
if (typeof atob !== 'function') return '';
|
||||||
@ -301,17 +286,6 @@ export default {
|
|||||||
uni.showToast({ title: e?.message || '扫码数据不合法', icon: 'none' });
|
uni.showToast({ title: e?.message || '扫码数据不合法', icon: 'none' });
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
startBroadcastScan(){
|
|
||||||
this.scanning = true;
|
|
||||||
this.currentDevice = null;
|
|
||||||
this.deviceCode = '';
|
|
||||||
this.scanUuid = '';
|
|
||||||
this.$store.dispatch('broadcast/resume');
|
|
||||||
uni.showToast({
|
|
||||||
title: '请扫描工牌',
|
|
||||||
icon: 'none'
|
|
||||||
});
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
@ -320,6 +294,7 @@ export default {
|
|||||||
.login-container {
|
.login-container {
|
||||||
width: 100vw;
|
width: 100vw;
|
||||||
height: 100vh;
|
height: 100vh;
|
||||||
|
margin: 0 auto;
|
||||||
background-image: var(--bg-url, url('@/static/loginbg.jpg'));
|
background-image: var(--bg-url, url('@/static/loginbg.jpg'));
|
||||||
background-size: cover;
|
background-size: cover;
|
||||||
background-position: center;
|
background-position: center;
|
||||||
@ -334,8 +309,8 @@ export default {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.form_box {
|
.form_box {
|
||||||
width: 90%;
|
width: 80%;
|
||||||
margin-left:5%;
|
margin: 0 auto;
|
||||||
background: rgba(255, 255, 255, 0.95);
|
background: rgba(255, 255, 255, 0.95);
|
||||||
border-radius: 20rpx;
|
border-radius: 20rpx;
|
||||||
padding: 60rpx 40rpx;
|
padding: 60rpx 40rpx;
|
||||||
@ -344,22 +319,17 @@ export default {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.header-section {
|
.header-section {
|
||||||
text-align: center;
|
text-align: left;
|
||||||
margin-bottom: 60rpx;
|
margin-bottom: 60rpx;
|
||||||
|
|
||||||
.app-name {
|
.system-title {
|
||||||
display: block;
|
display: block;
|
||||||
font-size: 48rpx;
|
text-align: center;
|
||||||
font-weight: bold;
|
width: 100%;
|
||||||
|
font-size: 40rpx;
|
||||||
|
font-weight: 600;
|
||||||
color: #333;
|
color: #333;
|
||||||
margin-top: 20rpx;
|
margin-bottom: 20rpx;
|
||||||
}
|
|
||||||
|
|
||||||
.welcome-text {
|
|
||||||
display: block;
|
|
||||||
font-size: 28rpx;
|
|
||||||
color: #666;
|
|
||||||
margin-top: 10rpx;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -403,6 +373,48 @@ export default {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.direct-login-card {
|
||||||
|
text-align: left;
|
||||||
|
|
||||||
|
.direct-login-form {
|
||||||
|
margin-top: 20rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.password-input-wrap {
|
||||||
|
position: relative;
|
||||||
|
|
||||||
|
.password-toggle-icon {
|
||||||
|
position: absolute;
|
||||||
|
left: 0;
|
||||||
|
top: 18rpx;
|
||||||
|
z-index: 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.scan-login-card {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
pointer-events: none;
|
||||||
|
background: transparent;
|
||||||
|
|
||||||
|
&:active {
|
||||||
|
background: transparent;
|
||||||
|
}
|
||||||
|
|
||||||
|
.method-icon {
|
||||||
|
margin-bottom: 0;
|
||||||
|
margin-right: 16rpx;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.method-desc {
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.device-status {
|
.device-status {
|
||||||
margin-top: 40rpx;
|
margin-top: 40rpx;
|
||||||
|
|
||||||
|
|||||||
284
pages/work/product/detail.vue
Normal file
284
pages/work/product/detail.vue
Normal file
@ -0,0 +1,284 @@
|
|||||||
|
<template>
|
||||||
|
<view class="goods-detail-page">
|
||||||
|
<view class="normar_container">
|
||||||
|
<page-nav :title="title"></page-nav>
|
||||||
|
|
||||||
|
<scroll-view class="detail-content" scroll-y>
|
||||||
|
<view class="detail-card" v-if="item">
|
||||||
|
<view class="image-section">
|
||||||
|
<u-image
|
||||||
|
class="main-image"
|
||||||
|
:src="getImageUrl(item)"
|
||||||
|
mode="aspectFit"
|
||||||
|
width="100%"
|
||||||
|
height="360rpx"
|
||||||
|
@click="previewProductImage(item)"
|
||||||
|
>
|
||||||
|
<template #error>
|
||||||
|
<view class="image-placeholder">
|
||||||
|
<u-icon name="photo" size="42" color="#c0c4cc"></u-icon>
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
|
</u-image>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<view class="info-section">
|
||||||
|
<view class="name-row">
|
||||||
|
<text class="goods-name">{{ item.item_name || item.product_name || item.name || '未命名商品' }}</text>
|
||||||
|
</view>
|
||||||
|
<view class="info-row">
|
||||||
|
<text class="label">货主:</text>
|
||||||
|
<text class="value">{{ getStoreOwnerText(item) }}</text>
|
||||||
|
</view>
|
||||||
|
<view class="info-row">
|
||||||
|
<text class="label">商品编码:</text>
|
||||||
|
<text class="value">{{ item.goods_code || item.item_code || '--' }}</text>
|
||||||
|
</view>
|
||||||
|
<view class="info-row">
|
||||||
|
<text class="label">条码:</text>
|
||||||
|
<text class="value">{{ getBarcodeText(item) }}</text>
|
||||||
|
</view>
|
||||||
|
<view class="info-row">
|
||||||
|
<text class="label">SKU规格:</text>
|
||||||
|
<text class="value">{{ item.sku_property || '--' }}</text>
|
||||||
|
</view>
|
||||||
|
<view class="info-row">
|
||||||
|
<text class="label">库存单位:</text>
|
||||||
|
<text class="value">{{ item.stock_unit || '--' }}</text>
|
||||||
|
</view>
|
||||||
|
<view class="info-row">
|
||||||
|
<text class="label">库存数量:</text>
|
||||||
|
<text class="value">{{ getValueOrDash(item.quantity) }}</text>
|
||||||
|
</view>
|
||||||
|
<view class="info-row">
|
||||||
|
<text class="label">锁定量:</text>
|
||||||
|
<text class="value">{{ getValueOrDash(item.locked_quantity) }}</text>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<view v-else class="empty-state">
|
||||||
|
<text class="empty-text">暂无商品详情</text>
|
||||||
|
</view>
|
||||||
|
<view class="safe-area-bottom"></view>
|
||||||
|
</scroll-view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
title: '商品详情',
|
||||||
|
item: null,
|
||||||
|
cacheKey: ''
|
||||||
|
};
|
||||||
|
},
|
||||||
|
onLoad(options) {
|
||||||
|
this.cacheKey = (options && options.cacheKey) || '';
|
||||||
|
if (!this.cacheKey) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const cached = uni.getStorageSync(this.cacheKey);
|
||||||
|
if (cached && typeof cached === 'object') {
|
||||||
|
this.item = cached;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onUnload() {
|
||||||
|
if (this.cacheKey) {
|
||||||
|
uni.removeStorageSync(this.cacheKey);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
getValueOrDash(value) {
|
||||||
|
return value === null || value === undefined || value === '' ? '--' : value;
|
||||||
|
},
|
||||||
|
getBarcodeText(item) {
|
||||||
|
if (!item || typeof item !== 'object') {
|
||||||
|
return '--';
|
||||||
|
}
|
||||||
|
|
||||||
|
const barcodes = item.barcodes;
|
||||||
|
if (Array.isArray(barcodes) && barcodes.length > 0) {
|
||||||
|
return barcodes.filter(code => code !== null && code !== undefined && code !== '').join(';');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof barcodes === 'string' && barcodes.trim()) {
|
||||||
|
return barcodes;
|
||||||
|
}
|
||||||
|
|
||||||
|
return item.barcode || item.code || '--';
|
||||||
|
},
|
||||||
|
getImageUrl(item) {
|
||||||
|
if (!item || typeof item !== 'object') {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
const candidate = item.image || item.image_url || item.img || item.pic || item.photo || item.cover || item.cover_url;
|
||||||
|
if (candidate) {
|
||||||
|
return String(candidate);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Array.isArray(item.images) && item.images.length > 0) {
|
||||||
|
return String(item.images[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Array.isArray(item.pics) && item.pics.length > 0) {
|
||||||
|
return String(item.pics[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return '';
|
||||||
|
},
|
||||||
|
getImageList(item) {
|
||||||
|
if (!item || typeof item !== 'object') {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Array.isArray(item.images) && item.images.length > 0) {
|
||||||
|
return item.images.map(url => String(url)).filter(Boolean);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Array.isArray(item.pics) && item.pics.length > 0) {
|
||||||
|
return item.pics.map(url => String(url)).filter(Boolean);
|
||||||
|
}
|
||||||
|
|
||||||
|
const single = this.getImageUrl(item);
|
||||||
|
return single ? [single] : [];
|
||||||
|
},
|
||||||
|
previewProductImage(item) {
|
||||||
|
const urls = this.getImageList(item);
|
||||||
|
if (!urls.length) {
|
||||||
|
uni.showToast({
|
||||||
|
title: '暂无可预览图片',
|
||||||
|
icon: 'none'
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
uni.previewImage({
|
||||||
|
current: urls[0],
|
||||||
|
urls
|
||||||
|
});
|
||||||
|
},
|
||||||
|
getStoreOwnerText(item) {
|
||||||
|
if (!item || typeof item !== 'object') {
|
||||||
|
return '--';
|
||||||
|
}
|
||||||
|
|
||||||
|
const directValue = item['store.store_remask'] || item['store_stock.store_remask'] || item.store_remask;
|
||||||
|
if (directValue !== null && directValue !== undefined && directValue !== '') {
|
||||||
|
return directValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (item.store_stock && typeof item.store_stock === 'object' && item.store_stock.store_remask) {
|
||||||
|
return item.store_stock.store_remask;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (item.store && typeof item.store === 'object' && item.store.store_remask) {
|
||||||
|
return item.store.store_remask;
|
||||||
|
}
|
||||||
|
|
||||||
|
return '--';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
.goods-detail-page {
|
||||||
|
background: #f7f8fa;
|
||||||
|
height: 100vh;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.normar_container {
|
||||||
|
flex: 1;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
min-height: 0;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.detail-content {
|
||||||
|
flex: 1;
|
||||||
|
min-height: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.detail-card {
|
||||||
|
background: #fff;
|
||||||
|
margin: 20rpx;
|
||||||
|
border-radius: 12rpx;
|
||||||
|
padding: 20rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.image-section {
|
||||||
|
margin-bottom: 16rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.main-image {
|
||||||
|
border-radius: 10rpx;
|
||||||
|
overflow: hidden;
|
||||||
|
background: #f5f7fa;
|
||||||
|
}
|
||||||
|
|
||||||
|
.image-placeholder {
|
||||||
|
width: 100%;
|
||||||
|
height: 360rpx;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
background: #f5f7fa;
|
||||||
|
}
|
||||||
|
|
||||||
|
.name-row {
|
||||||
|
margin-bottom: 10rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.goods-name {
|
||||||
|
font-size: 30rpx;
|
||||||
|
font-weight: 600;
|
||||||
|
color: #303133;
|
||||||
|
}
|
||||||
|
|
||||||
|
.info-row {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
line-height: 1.6;
|
||||||
|
margin-bottom: 6rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.info-row:last-child {
|
||||||
|
margin-bottom: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.label {
|
||||||
|
width: 120rpx;
|
||||||
|
font-size: 24rpx;
|
||||||
|
color: #909399;
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.value {
|
||||||
|
flex: 1;
|
||||||
|
font-size: 24rpx;
|
||||||
|
color: #606266;
|
||||||
|
white-space: nowrap;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
}
|
||||||
|
|
||||||
|
.empty-state {
|
||||||
|
padding: 160rpx 0 100rpx;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.empty-text {
|
||||||
|
font-size: 28rpx;
|
||||||
|
color: #909399;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@ -15,7 +15,7 @@
|
|||||||
></u-search>
|
></u-search>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<scroll-view class="list-content" scroll-y>
|
<scroll-view class="list-content" scroll-y :scroll-top="listScrollTop" @scroll="handleListScroll">
|
||||||
<view v-if="!loading && list.length === 0" class="empty-state">
|
<view v-if="!loading && list.length === 0" class="empty-state">
|
||||||
<u-icon name="search" size="88" color="#c0c4cc"></u-icon>
|
<u-icon name="search" size="88" color="#c0c4cc"></u-icon>
|
||||||
<text class="empty-text">暂无商品数据</text>
|
<text class="empty-text">暂无商品数据</text>
|
||||||
@ -23,33 +23,86 @@
|
|||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view v-else class="list-wrap">
|
<view v-else class="list-wrap">
|
||||||
<view class="goods-item" v-for="(item, index) in list" :key="item.id || index">
|
<view class="goods-item" v-for="(item, index) in list" :key="item.id || index" @click="goProductDetail(item)">
|
||||||
<view class="item-title-row">
|
<view class="item-main-row">
|
||||||
<text class="goods-name">{{ item.item_name || item.product_name || item.name || '未命名商品' }}</text>
|
<view class="item-thumb">
|
||||||
</view>
|
<u-image
|
||||||
<view class="item-row">
|
v-if="getImageList(item).length <= 1"
|
||||||
<text class="label">商品编码:</text>
|
class="goods-image"
|
||||||
<text class="value">{{ item.goods_code || item.item_code || '--' }}</text>
|
:src="getImageUrl(item)"
|
||||||
</view>
|
mode="aspectFill"
|
||||||
<view class="item-row">
|
width="180rpx"
|
||||||
<text class="label">条码:</text>
|
height="180rpx"
|
||||||
<text class="value">{{ getBarcodeText(item) }}</text>
|
@click.stop="previewProductImage(item)"
|
||||||
</view>
|
>
|
||||||
<view class="item-row">
|
<template #error>
|
||||||
<text class="label">SKU规格:</text>
|
<view class="image-placeholder">
|
||||||
<text class="value">{{ item.sku_property || '--' }}</text>
|
<u-icon name="photo" size="32" color="#c0c4cc"></u-icon>
|
||||||
</view>
|
</view>
|
||||||
<view class="item-row">
|
</template>
|
||||||
<text class="label">库存单位:</text>
|
</u-image>
|
||||||
<text class="value">{{ item.stock_unit || '--' }}</text>
|
<view
|
||||||
</view>
|
v-else
|
||||||
<view class="item-row">
|
class="goods-image-grid"
|
||||||
<text class="label">库存数量:</text>
|
@click.stop="previewProductImage(item)"
|
||||||
<text class="value">{{ getValueOrDash(item.quantity) }}</text>
|
>
|
||||||
</view>
|
<view
|
||||||
<view class="item-row">
|
class="grid-cell"
|
||||||
<text class="label">锁定量:</text>
|
v-for="(img, imgIndex) in getImageThumbList(item)"
|
||||||
<text class="value">{{ getValueOrDash(item.locked_quantity) }}</text>
|
:key="img + '-' + imgIndex"
|
||||||
|
>
|
||||||
|
<u-image
|
||||||
|
class="grid-image"
|
||||||
|
:src="img"
|
||||||
|
mode="aspectFill"
|
||||||
|
width="88rpx"
|
||||||
|
height="88rpx"
|
||||||
|
>
|
||||||
|
<template #error>
|
||||||
|
<view class="image-placeholder image-placeholder-small">
|
||||||
|
<u-icon name="photo" size="24" color="#c0c4cc"></u-icon>
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
|
</u-image>
|
||||||
|
<view v-if="imgIndex === 3 && getExtraImageCount(item) > 0" class="more-mask">
|
||||||
|
<text class="more-text">+{{ getExtraImageCount(item) }}</text>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<view class="item-info">
|
||||||
|
<view class="item-title-row">
|
||||||
|
<text class="goods-name">{{ item.item_name || item.product_name || item.name || '未命名商品' }}</text>
|
||||||
|
</view>
|
||||||
|
<view class="item-row">
|
||||||
|
<text class="label">货主:</text>
|
||||||
|
<text class="value">{{ getStoreOwnerText(item) }}</text>
|
||||||
|
</view>
|
||||||
|
<view class="item-row">
|
||||||
|
<text class="label">商品编码:</text>
|
||||||
|
<text class="value">{{ item.goods_code || item.item_code || '--' }}</text>
|
||||||
|
</view>
|
||||||
|
<view class="item-row">
|
||||||
|
<text class="label">条码:</text>
|
||||||
|
<text class="value">{{ getBarcodeText(item) }}</text>
|
||||||
|
</view>
|
||||||
|
<view class="item-row">
|
||||||
|
<text class="label">SKU规格:</text>
|
||||||
|
<text class="value">{{ item.sku_property || '--' }}</text>
|
||||||
|
</view>
|
||||||
|
<view class="item-row">
|
||||||
|
<text class="label">库存单位:</text>
|
||||||
|
<text class="value">{{ item.stock_unit || '--' }}</text>
|
||||||
|
</view>
|
||||||
|
<view class="item-row">
|
||||||
|
<text class="label">库存数量:</text>
|
||||||
|
<text class="value">{{ getValueOrDash(item.quantity) }}</text>
|
||||||
|
</view>
|
||||||
|
<view class="item-row">
|
||||||
|
<text class="label">锁定量:</text>
|
||||||
|
<text class="value">{{ getValueOrDash(item.locked_quantity) }}</text>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
@ -69,7 +122,8 @@
|
|||||||
title: '商品查询',
|
title: '商品查询',
|
||||||
keyword: '',
|
keyword: '',
|
||||||
loading: false,
|
loading: false,
|
||||||
list: []
|
list: [],
|
||||||
|
listScrollTop: 0
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onLoad() {
|
onLoad() {
|
||||||
@ -84,14 +138,23 @@
|
|||||||
onResult: this.handleBroadcastResult
|
onResult: this.handleBroadcastResult
|
||||||
});
|
});
|
||||||
this.$store.dispatch('broadcast/resume');
|
this.$store.dispatch('broadcast/resume');
|
||||||
|
const cachedTop = Number(uni.getStorageSync('product_query_scroll_top') || 0);
|
||||||
|
this.$nextTick(() => {
|
||||||
|
this.listScrollTop = cachedTop > 0 ? cachedTop : 0;
|
||||||
|
});
|
||||||
},
|
},
|
||||||
onHide() {
|
onHide() {
|
||||||
|
uni.setStorageSync('product_query_scroll_top', this.listScrollTop || 0);
|
||||||
this.$store.dispatch('broadcast/pause');
|
this.$store.dispatch('broadcast/pause');
|
||||||
},
|
},
|
||||||
onUnload() {
|
onUnload() {
|
||||||
this.$store.dispatch('broadcast/stop');
|
this.$store.dispatch('broadcast/stop');
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
handleListScroll(event) {
|
||||||
|
const top = event && event.detail ? Number(event.detail.scrollTop || 0) : 0;
|
||||||
|
this.listScrollTop = top;
|
||||||
|
},
|
||||||
normalizeKeyword(value) {
|
normalizeKeyword(value) {
|
||||||
return String(value || '').replace(/\s+/g, '');
|
return String(value || '').replace(/\s+/g, '');
|
||||||
},
|
},
|
||||||
@ -109,8 +172,13 @@
|
|||||||
return '--';
|
return '--';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Array.isArray(item.barcodes) && item.barcodes.length > 0) {
|
const barcodes = item.barcodes;
|
||||||
return item.barcodes.join(';');
|
if (Array.isArray(barcodes) && barcodes.length > 0) {
|
||||||
|
return barcodes.filter(code => code !== null && code !== undefined && code !== '').join(';');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof barcodes === 'string' && barcodes.trim()) {
|
||||||
|
return barcodes;
|
||||||
}
|
}
|
||||||
|
|
||||||
return item.barcode || item.code || '--';
|
return item.barcode || item.code || '--';
|
||||||
@ -118,6 +186,169 @@
|
|||||||
getValueOrDash(value) {
|
getValueOrDash(value) {
|
||||||
return value === null || value === undefined || value === '' ? '--' : value;
|
return value === null || value === undefined || value === '' ? '--' : value;
|
||||||
},
|
},
|
||||||
|
getStoreOwnerText(item) {
|
||||||
|
if (!item || typeof item !== 'object') {
|
||||||
|
return '--';
|
||||||
|
}
|
||||||
|
|
||||||
|
const directValue = item['store.store_remask'] || item['store_stock.store_remask'] || item.store_remask;
|
||||||
|
if (directValue !== null && directValue !== undefined && directValue !== '') {
|
||||||
|
return directValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (item.store_stock && typeof item.store_stock === 'object' && item.store_stock.store_remask) {
|
||||||
|
return item.store_stock.store_remask;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (item.store && typeof item.store === 'object' && item.store.store_remask) {
|
||||||
|
return item.store.store_remask;
|
||||||
|
}
|
||||||
|
|
||||||
|
const nestedValue = this.findStoreRemaskValue(item);
|
||||||
|
if (nestedValue) {
|
||||||
|
return nestedValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
return '--';
|
||||||
|
},
|
||||||
|
findStoreRemaskValue(source, visited = new Set()) {
|
||||||
|
if (!source || typeof source !== 'object') {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (visited.has(source)) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
visited.add(source);
|
||||||
|
|
||||||
|
if (typeof source.store_remask === 'string' && source.store_remask.trim()) {
|
||||||
|
return source.store_remask.trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
const keys = Object.keys(source);
|
||||||
|
for (let i = 0; i < keys.length; i++) {
|
||||||
|
const key = keys[i];
|
||||||
|
const value = source[key];
|
||||||
|
|
||||||
|
if (key === 'store_remask' && value) {
|
||||||
|
return String(value).trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (value && typeof value === 'object') {
|
||||||
|
const nested = this.findStoreRemaskValue(value, visited);
|
||||||
|
if (nested) {
|
||||||
|
return nested;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return '';
|
||||||
|
},
|
||||||
|
isBarcodeLike(value) {
|
||||||
|
const text = this.normalizeKeyword(value);
|
||||||
|
return text.length >= 6 && /^[A-Za-z0-9._-]+$/.test(text);
|
||||||
|
},
|
||||||
|
extractBarcodeList(item) {
|
||||||
|
if (!item || typeof item !== 'object') {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
let values = [];
|
||||||
|
if (Array.isArray(item.barcodes)) {
|
||||||
|
values = values.concat(item.barcodes);
|
||||||
|
} else if (typeof item.barcodes === 'string' && item.barcodes.trim()) {
|
||||||
|
values = values.concat(item.barcodes.split(/[;,,\s]+/));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (item.barcode) {
|
||||||
|
values.push(item.barcode);
|
||||||
|
}
|
||||||
|
if (item.code) {
|
||||||
|
values.push(item.code);
|
||||||
|
}
|
||||||
|
|
||||||
|
return [...new Set(values
|
||||||
|
.map(code => this.normalizeKeyword(code))
|
||||||
|
.filter(Boolean)
|
||||||
|
)];
|
||||||
|
},
|
||||||
|
filterByBarcodeExact(list, keyword) {
|
||||||
|
const target = this.normalizeKeyword(keyword);
|
||||||
|
if (!target) {
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (list || []).filter(item => this.extractBarcodeList(item).includes(target));
|
||||||
|
},
|
||||||
|
getImageUrl(item) {
|
||||||
|
if (!item || typeof item !== 'object') {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
const candidate = item.image || item.image_url || item.img || item.pic || item.photo || item.cover || item.cover_url;
|
||||||
|
if (candidate) {
|
||||||
|
return String(candidate);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Array.isArray(item.images) && item.images.length > 0) {
|
||||||
|
return String(item.images[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Array.isArray(item.pics) && item.pics.length > 0) {
|
||||||
|
return String(item.pics[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return '';
|
||||||
|
},
|
||||||
|
getImageList(item) {
|
||||||
|
if (!item || typeof item !== 'object') {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Array.isArray(item.images) && item.images.length > 0) {
|
||||||
|
return item.images.map(url => String(url)).filter(Boolean);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Array.isArray(item.pics) && item.pics.length > 0) {
|
||||||
|
return item.pics.map(url => String(url)).filter(Boolean);
|
||||||
|
}
|
||||||
|
|
||||||
|
const single = this.getImageUrl(item);
|
||||||
|
return single ? [single] : [];
|
||||||
|
},
|
||||||
|
getImageThumbList(item) {
|
||||||
|
return this.getImageList(item).slice(0, 4);
|
||||||
|
},
|
||||||
|
getExtraImageCount(item) {
|
||||||
|
const total = this.getImageList(item).length;
|
||||||
|
return total > 4 ? total - 4 : 0;
|
||||||
|
},
|
||||||
|
previewProductImage(item) {
|
||||||
|
const urls = this.getImageList(item);
|
||||||
|
if (!urls.length) {
|
||||||
|
uni.showToast({
|
||||||
|
title: '暂无可预览图片',
|
||||||
|
icon: 'none'
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
uni.previewImage({
|
||||||
|
current: urls[0],
|
||||||
|
urls
|
||||||
|
});
|
||||||
|
},
|
||||||
|
goProductDetail(item) {
|
||||||
|
if (!item || typeof item !== 'object') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const cacheKey = `product_detail_${Date.now()}_${Math.random().toString(36).slice(2, 8)}`;
|
||||||
|
uni.setStorageSync(cacheKey, item);
|
||||||
|
uni.navigateTo({
|
||||||
|
url: `/pages/work/product/detail?cacheKey=${cacheKey}`
|
||||||
|
});
|
||||||
|
},
|
||||||
async handleSearch() {
|
async handleSearch() {
|
||||||
const keyword = this.normalizeKeyword(this.keyword);
|
const keyword = this.normalizeKeyword(this.keyword);
|
||||||
this.keyword = keyword;
|
this.keyword = keyword;
|
||||||
@ -128,12 +359,30 @@
|
|||||||
|
|
||||||
this.loading = true;
|
this.loading = true;
|
||||||
try {
|
try {
|
||||||
const res = await this.$http('stock.warehouse.search', {
|
const res = await this.$http('stock.warehouse.list', {
|
||||||
keyword
|
pagination: {
|
||||||
|
page: 1,
|
||||||
|
pageSize: 100
|
||||||
|
},
|
||||||
|
keyword,
|
||||||
|
barcode: keyword,
|
||||||
|
barcodes: [keyword]
|
||||||
});
|
});
|
||||||
|
|
||||||
if (res && res.code === 200) {
|
if (res && res.code === 200) {
|
||||||
this.list = Array.isArray(res.data) ? res.data : [];
|
const responseData = res.data;
|
||||||
|
let nextList = [];
|
||||||
|
if (Array.isArray(responseData)) {
|
||||||
|
nextList = responseData;
|
||||||
|
} else if (responseData && Array.isArray(responseData.list)) {
|
||||||
|
nextList = responseData.list;
|
||||||
|
} else if (responseData && Array.isArray(responseData.rows)) {
|
||||||
|
nextList = responseData.rows;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.list = this.isBarcodeLike(keyword)
|
||||||
|
? this.filterByBarcodeExact(nextList, keyword)
|
||||||
|
: nextList;
|
||||||
} else {
|
} else {
|
||||||
this.list = [];
|
this.list = [];
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
@ -194,16 +443,105 @@
|
|||||||
.goods-item {
|
.goods-item {
|
||||||
background: #fff;
|
background: #fff;
|
||||||
border-radius: 12rpx;
|
border-radius: 12rpx;
|
||||||
padding: 24rpx;
|
padding: 10rpx 20rpx;
|
||||||
margin-bottom: 20rpx;
|
margin-bottom: 20rpx;
|
||||||
box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.04);
|
border: 1rpx solid #e9edf3;
|
||||||
|
box-shadow: 0 8rpx 24rpx rgba(0, 0, 0, 0.08);
|
||||||
|
position: relative;
|
||||||
|
|
||||||
|
&::before {
|
||||||
|
content: '';
|
||||||
|
position: absolute;
|
||||||
|
left: 0;
|
||||||
|
top: 18rpx;
|
||||||
|
bottom: 18rpx;
|
||||||
|
width: 6rpx;
|
||||||
|
background: #2979ff;
|
||||||
|
border-radius: 0 6rpx 6rpx 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.item-main-row {
|
||||||
|
display: flex;
|
||||||
|
align-items: flex-start;
|
||||||
|
}
|
||||||
|
|
||||||
|
.item-thumb {
|
||||||
|
width: 180rpx;
|
||||||
|
margin-right: 20rpx;
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.goods-image {
|
||||||
|
border-radius: 10rpx;
|
||||||
|
overflow: hidden;
|
||||||
|
background: #f5f7fa;
|
||||||
|
}
|
||||||
|
|
||||||
|
.goods-image-grid {
|
||||||
|
width: 180rpx;
|
||||||
|
height: 180rpx;
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-content: space-between;
|
||||||
|
}
|
||||||
|
|
||||||
|
.grid-cell {
|
||||||
|
position: relative;
|
||||||
|
width: 88rpx;
|
||||||
|
height: 88rpx;
|
||||||
|
border-radius: 8rpx;
|
||||||
|
overflow: hidden;
|
||||||
|
background: #f5f7fa;
|
||||||
|
}
|
||||||
|
|
||||||
|
.grid-image {
|
||||||
|
border-radius: 8rpx;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.image-placeholder {
|
||||||
|
width: 100%;
|
||||||
|
height: 180rpx;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
background: #f5f7fa;
|
||||||
|
}
|
||||||
|
|
||||||
|
.image-placeholder-small {
|
||||||
|
height: 88rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.more-mask {
|
||||||
|
position: absolute;
|
||||||
|
left: 0;
|
||||||
|
top: 0;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
background: rgba(0, 0, 0, 0.45);
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.more-text {
|
||||||
|
font-size: 22rpx;
|
||||||
|
color: #fff;
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
|
||||||
|
.item-info {
|
||||||
|
flex: 1;
|
||||||
|
min-width: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.item-title-row {
|
.item-title-row {
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
margin-bottom: 18rpx;
|
margin-bottom: 6rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
.goods-name {
|
.goods-name {
|
||||||
@ -218,11 +556,16 @@
|
|||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
flex-wrap: nowrap;
|
flex-wrap: nowrap;
|
||||||
line-height: 1.8;
|
line-height: 1.4;
|
||||||
|
margin-bottom: 2rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.item-row:last-child {
|
||||||
|
margin-bottom: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.label {
|
.label {
|
||||||
width: 140rpx;
|
width: 116rpx;
|
||||||
font-size: 24rpx;
|
font-size: 24rpx;
|
||||||
color: #909399;
|
color: #909399;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user