Compare commits
2 Commits
fb1573b2a5
...
5305f77560
| Author | SHA1 | Date | |
|---|---|---|---|
| 5305f77560 | |||
| 34adbce776 |
@ -133,6 +133,14 @@ export default {
|
||||
auth: true,
|
||||
method: "POST",
|
||||
isSystemApi: true
|
||||
},
|
||||
warehouse: {
|
||||
search: {
|
||||
path: "stock.warehouse.search",
|
||||
auth: true,
|
||||
method: "POST",
|
||||
isSystemApi: true
|
||||
}
|
||||
}
|
||||
},
|
||||
print: {
|
||||
|
||||
@ -145,14 +145,22 @@ const actions = {
|
||||
commit,
|
||||
state
|
||||
},path) {
|
||||
let has = false;
|
||||
console.log("所有菜单",state.menus);
|
||||
for(let i =0;i<state.menus.length;i++){
|
||||
if(state.menus[i].component==path){
|
||||
has = true;
|
||||
}
|
||||
const normalizePath = (target = '') => String(target)
|
||||
.trim()
|
||||
.replace(/^\/+/, '')
|
||||
.replace(/\.vue$/i, '');
|
||||
|
||||
const targetPath = normalizePath(path);
|
||||
if (!targetPath) {
|
||||
return false;
|
||||
}
|
||||
return has;
|
||||
|
||||
console.log("所有菜单", state.menus);
|
||||
return (state.menus || []).some(menu => {
|
||||
const componentPath = normalizePath(menu?.component || '');
|
||||
const menuPath = normalizePath(menu?.path || '');
|
||||
return componentPath === targetPath || menuPath === targetPath;
|
||||
});
|
||||
},
|
||||
login({
|
||||
commit,
|
||||
|
||||
20
pages.json
20
pages.json
@ -1,14 +1,5 @@
|
||||
{
|
||||
// "condition": { //模式配置,仅开发期间生效
|
||||
// "current": 0, //当前激活的模式(list 的索引项)
|
||||
// "list": [{
|
||||
// "name": "test", //模式名称
|
||||
// "path": "pages/componentsA/test/test", //启动页面,必选
|
||||
// "query": "" //启动参数,在页面的onLoad函数里面得到
|
||||
// }]
|
||||
// },
|
||||
"pages": [ //pages数组中第一项表示应用启动页,参考:https://uniapp.dcloud.io/collocation/pages
|
||||
|
||||
{
|
||||
"pages": [
|
||||
{
|
||||
"path": "pages/login/index",
|
||||
|
||||
@ -129,6 +120,13 @@
|
||||
{
|
||||
"titleNView": false
|
||||
}
|
||||
},
|
||||
{
|
||||
"path" : "pages/work/product/query",
|
||||
"style" :
|
||||
{
|
||||
"titleNView": false
|
||||
}
|
||||
}
|
||||
|
||||
],
|
||||
|
||||
@ -311,7 +311,14 @@
|
||||
this.activeNav = group.initial || '全部';
|
||||
},
|
||||
toPath(item) {
|
||||
if (!item || !item.component) {
|
||||
const menuName = String(item?.name || '').trim();
|
||||
const isGoodsQuery = menuName === '商品查询' || (menuName.includes('商品') && menuName.includes('查询'));
|
||||
const rawPath = item?.component || item?.path || '';
|
||||
const targetPath = isGoodsQuery
|
||||
? '/pages/work/product/query'
|
||||
: (rawPath ? (rawPath.startsWith('/') ? rawPath : `/${rawPath}`) : '');
|
||||
|
||||
if (!targetPath) {
|
||||
uni.showToast({
|
||||
title: '功能暂未开放',
|
||||
icon: 'none'
|
||||
@ -320,7 +327,7 @@
|
||||
}
|
||||
|
||||
uni.navigateTo({
|
||||
url: item.component.startsWith('/') ? item.component : `/${item.component}`,
|
||||
url: targetPath,
|
||||
animationType: 'slide-in-right'
|
||||
});
|
||||
},
|
||||
|
||||
@ -334,7 +334,14 @@
|
||||
},
|
||||
|
||||
toPath(item) {
|
||||
if (!item || !item.component) {
|
||||
const menuName = String(item?.name || '').trim();
|
||||
const isGoodsQuery = menuName === '商品查询' || (menuName.includes('商品') && menuName.includes('查询'));
|
||||
const rawPath = item?.component || item?.path || '';
|
||||
const targetPath = isGoodsQuery
|
||||
? '/pages/work/product/query'
|
||||
: (rawPath ? (rawPath.startsWith('/') ? rawPath : `/${rawPath}`) : '');
|
||||
|
||||
if (!targetPath) {
|
||||
uni.showToast({
|
||||
title: '功能暂未开放',
|
||||
icon: 'none',
|
||||
@ -344,7 +351,7 @@
|
||||
}
|
||||
|
||||
uni.navigateTo({
|
||||
url: item.component.startsWith('/') ? item.component : `/${item.component}`,
|
||||
url: targetPath,
|
||||
animationType: 'slide-in-right'
|
||||
});
|
||||
},
|
||||
|
||||
259
pages/work/product/query.vue
Normal file
259
pages/work/product/query.vue
Normal file
@ -0,0 +1,259 @@
|
||||
<template>
|
||||
<view class="goods-query-page">
|
||||
<view class="normar_container">
|
||||
<page-nav :title="title"></page-nav>
|
||||
|
||||
<view class="search-panel">
|
||||
<u-search
|
||||
v-model="keyword"
|
||||
placeholder="请输入商品条码或名称"
|
||||
:bg-color="'#f5f5f5'"
|
||||
shape="round"
|
||||
:show-action="false"
|
||||
@search="handleSearch"
|
||||
@clear="handleSearch"
|
||||
></u-search>
|
||||
</view>
|
||||
|
||||
<scroll-view class="list-content" scroll-y>
|
||||
<view v-if="!loading && list.length === 0" class="empty-state">
|
||||
<u-icon name="search" size="88" color="#c0c4cc"></u-icon>
|
||||
<text class="empty-text">暂无商品数据</text>
|
||||
<text class="empty-hint">请输入关键字进行查询</text>
|
||||
</view>
|
||||
|
||||
<view v-else class="list-wrap">
|
||||
<view class="goods-item" v-for="(item, index) in list" :key="item.id || index">
|
||||
<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">{{ 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 class="safe-area-bottom"></view>
|
||||
</scroll-view>
|
||||
</view>
|
||||
|
||||
<u-loading-page :loading="loading" bg-color="rgba(255,255,255,0.9)"></u-loading-page>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
title: '商品查询',
|
||||
keyword: '',
|
||||
loading: false,
|
||||
list: []
|
||||
}
|
||||
},
|
||||
onLoad() {
|
||||
this.$store.dispatch('broadcast/setCallbacks', {
|
||||
onResult: this.handleBroadcastResult
|
||||
});
|
||||
this.$store.dispatch('broadcast/start');
|
||||
this.list = [];
|
||||
},
|
||||
onShow() {
|
||||
this.$store.dispatch('broadcast/setCallbacks', {
|
||||
onResult: this.handleBroadcastResult
|
||||
});
|
||||
this.$store.dispatch('broadcast/resume');
|
||||
},
|
||||
onHide() {
|
||||
this.$store.dispatch('broadcast/pause');
|
||||
},
|
||||
onUnload() {
|
||||
this.$store.dispatch('broadcast/stop');
|
||||
},
|
||||
methods: {
|
||||
normalizeKeyword(value) {
|
||||
return String(value || '').replace(/\s+/g, '');
|
||||
},
|
||||
handleBroadcastResult(result) {
|
||||
const scanResult = this.normalizeKeyword((result && result.data) || '');
|
||||
if (!scanResult) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.keyword = scanResult;
|
||||
this.handleSearch();
|
||||
},
|
||||
getBarcodeText(item) {
|
||||
if (!item || typeof item !== 'object') {
|
||||
return '--';
|
||||
}
|
||||
|
||||
if (Array.isArray(item.barcodes) && item.barcodes.length > 0) {
|
||||
return item.barcodes.join(';');
|
||||
}
|
||||
|
||||
return item.barcode || item.code || '--';
|
||||
},
|
||||
getValueOrDash(value) {
|
||||
return value === null || value === undefined || value === '' ? '--' : value;
|
||||
},
|
||||
async handleSearch() {
|
||||
const keyword = this.normalizeKeyword(this.keyword);
|
||||
this.keyword = keyword;
|
||||
if (!keyword) {
|
||||
this.list = [];
|
||||
return;
|
||||
}
|
||||
|
||||
this.loading = true;
|
||||
try {
|
||||
const res = await this.$http('stock.warehouse.search', {
|
||||
keyword
|
||||
});
|
||||
|
||||
if (res && res.code === 200) {
|
||||
this.list = Array.isArray(res.data) ? res.data : [];
|
||||
} else {
|
||||
this.list = [];
|
||||
uni.showToast({
|
||||
title: (res && res.message) || '查询失败',
|
||||
icon: 'none'
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
this.list = [];
|
||||
uni.showToast({
|
||||
title: (error && error.message) || '查询失败',
|
||||
icon: 'none'
|
||||
});
|
||||
} finally {
|
||||
this.loading = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.goods-query-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;
|
||||
}
|
||||
|
||||
.search-panel {
|
||||
padding: 20rpx;
|
||||
background: #fff;
|
||||
border-bottom: 1rpx solid #f2f2f2;
|
||||
flex-shrink: 0;
|
||||
position: relative;
|
||||
z-index: 2;
|
||||
}
|
||||
|
||||
.list-content {
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
height: auto;
|
||||
}
|
||||
|
||||
.list-wrap {
|
||||
padding: 20rpx;
|
||||
}
|
||||
|
||||
.goods-item {
|
||||
background: #fff;
|
||||
border-radius: 12rpx;
|
||||
padding: 24rpx;
|
||||
margin-bottom: 20rpx;
|
||||
box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.04);
|
||||
}
|
||||
|
||||
.item-title-row {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 18rpx;
|
||||
}
|
||||
|
||||
.goods-name {
|
||||
font-size: 30rpx;
|
||||
color: #303133;
|
||||
font-weight: 600;
|
||||
flex: 1;
|
||||
padding-right: 20rpx;
|
||||
}
|
||||
|
||||
.item-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex-wrap: nowrap;
|
||||
line-height: 1.8;
|
||||
}
|
||||
|
||||
.label {
|
||||
width: 140rpx;
|
||||
font-size: 24rpx;
|
||||
color: #909399;
|
||||
white-space: nowrap;
|
||||
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;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.empty-text {
|
||||
font-size: 30rpx;
|
||||
color: #909399;
|
||||
margin-top: 24rpx;
|
||||
}
|
||||
|
||||
.empty-hint {
|
||||
font-size: 24rpx;
|
||||
color: #c0c4cc;
|
||||
margin-top: 10rpx;
|
||||
}
|
||||
</style>
|
||||
@ -597,7 +597,7 @@
|
||||
if(!this.selectedDetail){
|
||||
return false;
|
||||
}
|
||||
const stocks = await this.$http("stock.search", {
|
||||
const stocks = await this.$http("stock.warehouse.search", {
|
||||
keyword: data,
|
||||
store_id: this.receivingInfo.store_id
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user