489 lines
12 KiB
Vue
489 lines
12 KiB
Vue
<template>
|
||
<view class="scatter-wave-page">
|
||
<view class="normar_container">
|
||
<page-nav :title="title">
|
||
<template #right>
|
||
<view class="nav-right-pending">待处理{{ pendingCount }}</view>
|
||
</template>
|
||
</page-nav>
|
||
|
||
<view class="content-layout">
|
||
<view v-if="loading" class="empty-wrap">
|
||
<text class="empty-text">加载中...</text>
|
||
</view>
|
||
<view v-else-if="strategyList.length === 0" class="empty-wrap">
|
||
<text class="empty-text">暂无策略</text>
|
||
</view>
|
||
<template v-else>
|
||
<view class="top-module">
|
||
<view class="content-card content-card--detail">
|
||
<view class="card-title">{{ currentStrategy.strategyName }}</view>
|
||
<view class="card-row"><text class="value shentong-e-value">申通E</text></view>
|
||
<view class="card-row"><text class="label">货主:</text><text class="value">{{ currentStrategy.ownerText }}</text></view>
|
||
<view class="card-row"><text class="label">订单小于SKU数:</text><text class="value">{{ currentStrategy.orderMaxSku }}个</text></view>
|
||
<view class="card-row"><text class="label">订单最小SKU数:</text><text class="value">{{ currentStrategy.orderMinSku }}个</text></view>
|
||
<view class="card-row"><text class="label">订单最大商品数:</text><text class="value">{{ currentStrategy.orderMaxQty }}个</text></view>
|
||
<view class="card-row"><text class="label">订单最小商品数:</text><text class="value">{{ currentStrategy.orderMinQty }}个</text></view>
|
||
<view class="card-row"><text class="label">拣货类型:</text><text class="value">{{ currentStrategy.pickTypeText }}</text></view>
|
||
<view class="card-row card-row--inline-group">
|
||
<view class="group-item"><text class="label">订单快递限制:</text><text class="value">{{ currentStrategy.expressLimitText }}</text></view>
|
||
<view class="group-item"><text class="label">订单平台限制:</text><text class="value">{{ currentStrategy.platformLimitText }}</text></view>
|
||
</view>
|
||
<view class="card-row card-row--inline-group">
|
||
<view class="group-item"><text class="label">按货主分组:</text><text class="value">{{ currentStrategy.groupByOwnerText }}</text></view>
|
||
<view class="group-item"><text class="label">按快递分组:</text><text class="value">{{ currentStrategy.groupByExpressText }}</text></view>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
|
||
<view class="bottom-module">
|
||
<scroll-view class="grid-scroll" scroll-y>
|
||
<view class="grid-wrap">
|
||
<view
|
||
v-for="item in strategyList"
|
||
:key="item.id"
|
||
class="pick-card"
|
||
:class="{ 'pick-card--active': currentStrategyId === item.id }"
|
||
@click="selectStrategy(item)"
|
||
>
|
||
<view class="pick-card__top">
|
||
<text class="pick-card__tag-left">申通E</text>
|
||
<text class="pick-card__tag-right">{{ item.ownerText }}</text>
|
||
</view>
|
||
<view class="pick-card__main">
|
||
<text class="pick-card__num">{{ item.orderMaxQty }}</text>
|
||
</view>
|
||
<view class="pick-card__bottom">{{ item.pickTypeText }}</view>
|
||
</view>
|
||
</view>
|
||
<view class="safe-area-bottom"></view>
|
||
</scroll-view>
|
||
</view>
|
||
</template>
|
||
</view>
|
||
|
||
<view class="bottom-action-bar">
|
||
<u-button @click="handleRefresh">刷新</u-button>
|
||
<u-button type="primary" :customStyle="{ backgroundColor: '#2979ff', borderColor: '#2979ff' }" @click="handleGrabScatter">抓取散单({{ grabCount }})个</u-button>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
</template>
|
||
|
||
<script>
|
||
export default {
|
||
data() {
|
||
return {
|
||
title: '散单待拣货列表',
|
||
pendingCount: 50,
|
||
grabCount: 5,
|
||
loading: false,
|
||
currentStrategyId: '',
|
||
strategyList: []
|
||
};
|
||
},
|
||
computed: {
|
||
currentStrategy() {
|
||
return this.strategyList.find(item => String(item.id) === String(this.currentStrategyId)) || this.strategyList[0] || {};
|
||
}
|
||
},
|
||
onLoad() {
|
||
this.loadStrategyList();
|
||
},
|
||
methods: {
|
||
getApiErrorMessage(error, fallback = '请求失败') {
|
||
const message = error?.message || error?.msg || error?.errMsg || error?.data?.message;
|
||
return String(message || fallback);
|
||
},
|
||
buildWaveStrategyListParams() {
|
||
return {};
|
||
},
|
||
extractWaveStrategyPayload(response) {
|
||
const candidates = [
|
||
response?.data?.data,
|
||
response?.data,
|
||
response?.result,
|
||
response
|
||
];
|
||
for (let i = 0; i < candidates.length; i += 1) {
|
||
const current = candidates[i];
|
||
if (current && typeof current === 'object' && !Array.isArray(current)) {
|
||
return current;
|
||
}
|
||
}
|
||
return {};
|
||
},
|
||
extractWaveStrategyList(payload, response) {
|
||
const candidates = [
|
||
payload?.list,
|
||
payload?.rows,
|
||
payload?.items,
|
||
payload?.data?.list,
|
||
response?.data?.list,
|
||
response?.data?.data?.list,
|
||
response?.list
|
||
];
|
||
for (let i = 0; i < candidates.length; i += 1) {
|
||
if (Array.isArray(candidates[i])) {
|
||
return candidates[i];
|
||
}
|
||
}
|
||
return [];
|
||
},
|
||
normalizeBooleanText(value) {
|
||
const normalized = Number(value) === 1 || value === true;
|
||
return normalized ? '是' : '否';
|
||
},
|
||
normalizeLimitText(value) {
|
||
if (Array.isArray(value)) {
|
||
return value.length ? value.join('、') : '不限';
|
||
}
|
||
if (value == null || value === '') {
|
||
return '不限';
|
||
}
|
||
if (typeof value === 'string') {
|
||
return value.trim() ? value : '不限';
|
||
}
|
||
return String(value);
|
||
},
|
||
normalizePickTypeText(item) {
|
||
const type = Number(item?.strategy_type || 0);
|
||
const mode = Number(item?.batch_mode || 0);
|
||
if (mode === 1) {
|
||
return 'E型';
|
||
}
|
||
if (type === 1) {
|
||
return 'F型';
|
||
}
|
||
return '未知';
|
||
},
|
||
normalizeWaveStrategyItem(item) {
|
||
const source = item && typeof item === 'object' ? item : {};
|
||
const ownerText = this.normalizeLimitText(source.allowed_owners);
|
||
return {
|
||
id: source.id || Math.random().toString(36).slice(2),
|
||
strategyName: source.strategy_name || '--',
|
||
ownerText,
|
||
orderMaxSku: Number(source.order_max_sku || 0),
|
||
orderMinSku: Number(source.order_min_sku || 0),
|
||
orderMaxQty: Number(source.order_max_qty || 0),
|
||
orderMinQty: Number(source.order_min_qty || 0),
|
||
expressLimitText: this.normalizeLimitText(source.allowed_expresses),
|
||
platformLimitText: this.normalizeLimitText(source.allowed_platforms),
|
||
groupByOwnerText: this.normalizeBooleanText(source.allow_cross_owner),
|
||
groupByExpressText: this.normalizeBooleanText(source.require_same_express),
|
||
pickTypeText: this.normalizePickTypeText(source)
|
||
};
|
||
},
|
||
parseWaveStrategyResponse(response) {
|
||
const payload = this.extractWaveStrategyPayload(response);
|
||
const list = this.extractWaveStrategyList(payload, response);
|
||
return list.map(item => this.normalizeWaveStrategyItem(item));
|
||
},
|
||
selectStrategy(item) {
|
||
if (!item || typeof item !== 'object') {
|
||
return;
|
||
}
|
||
this.currentStrategyId = item.id;
|
||
},
|
||
handleRefresh() {
|
||
this.loadStrategyList();
|
||
},
|
||
handleGrabScatter() {
|
||
if (!this.currentStrategy || !this.currentStrategy.id) {
|
||
uni.showToast({
|
||
title: '请先选择策略',
|
||
icon: 'none'
|
||
});
|
||
return;
|
||
}
|
||
|
||
const params = [
|
||
`strategyId=${encodeURIComponent(String(this.currentStrategy.id || ''))}`,
|
||
`strategyName=${encodeURIComponent(String(this.currentStrategy.strategyName || '--'))}`,
|
||
`ownerText=${encodeURIComponent(String(this.currentStrategy.ownerText || '--'))}`,
|
||
`pickTypeText=${encodeURIComponent(String(this.currentStrategy.pickTypeText || '--'))}`,
|
||
`grabCount=${encodeURIComponent(String(this.grabCount || 0))}`
|
||
];
|
||
this.$tools.routerTo(`/pages/work/order/scatter-picking-detail?${params.join('&')}`);
|
||
},
|
||
async loadStrategyList() {
|
||
this.loading = true;
|
||
try {
|
||
const params = this.buildWaveStrategyListParams();
|
||
const response = await this.$http('order.wave.waveStrategyList', params);
|
||
const payload = this.extractWaveStrategyPayload(response);
|
||
this.pendingCount = Number(payload?.pending_count ?? payload?.pendingCount ?? 50);
|
||
this.strategyList = this.parseWaveStrategyResponse(response);
|
||
this.currentStrategyId = this.strategyList[0]?.id || '';
|
||
} catch (error) {
|
||
this.pendingCount = 50;
|
||
this.currentStrategyId = '';
|
||
this.strategyList = [];
|
||
uni.showToast({
|
||
title: this.getApiErrorMessage(error, '策略加载失败'),
|
||
icon: 'none'
|
||
});
|
||
} finally {
|
||
this.loading = false;
|
||
}
|
||
}
|
||
}
|
||
};
|
||
</script>
|
||
|
||
<style lang="scss" scoped>
|
||
.scatter-wave-page {
|
||
min-height: 100vh;
|
||
background: #f8f9fa;
|
||
position: relative;
|
||
}
|
||
|
||
.normar_container {
|
||
position: relative;
|
||
}
|
||
|
||
::v-deep .nav-title .right {
|
||
width: auto;
|
||
min-width: 170rpx;
|
||
display: flex;
|
||
justify-content: flex-end;
|
||
}
|
||
|
||
.nav-right-pending {
|
||
font-size: 32rpx;
|
||
line-height: 36rpx;
|
||
color: #ffffff;
|
||
padding: 8rpx 18rpx;
|
||
border-radius: 6rpx;
|
||
background: #2979ff;
|
||
}
|
||
|
||
.list-content {
|
||
height: 100%;
|
||
}
|
||
|
||
.content-layout {
|
||
height: calc(100vh - 170rpx - env(safe-area-inset-bottom));
|
||
display: flex;
|
||
flex-direction: column;
|
||
padding: 20rpx 24rpx 120rpx;
|
||
background: #f3f4f6;
|
||
box-sizing: border-box;
|
||
}
|
||
|
||
.top-module,
|
||
.bottom-module {
|
||
flex: 1;
|
||
min-height: 0;
|
||
}
|
||
|
||
.top-module {
|
||
padding-bottom: 10rpx;
|
||
}
|
||
|
||
.bottom-module {
|
||
padding-top: 10rpx;
|
||
}
|
||
|
||
.grid-scroll {
|
||
height: 100%;
|
||
}
|
||
|
||
.grid-wrap {
|
||
display: flex;
|
||
flex-wrap: wrap;
|
||
row-gap: 8rpx;
|
||
column-gap: 16rpx;
|
||
align-content: flex-start;
|
||
padding-bottom: 20rpx;
|
||
}
|
||
|
||
.content-card {
|
||
margin: 0;
|
||
padding: 16rpx;
|
||
background: #fff;
|
||
border-radius: 14rpx;
|
||
box-sizing: border-box;
|
||
height: 100%;
|
||
overflow: hidden;
|
||
}
|
||
|
||
.content-card--detail {
|
||
overflow-y: auto;
|
||
}
|
||
|
||
.card-title {
|
||
font-size: 34rpx;
|
||
font-weight: 600;
|
||
color: #303133;
|
||
margin-bottom: 14rpx;
|
||
}
|
||
|
||
.card-row {
|
||
display: flex;
|
||
align-items: flex-start;
|
||
font-size: 32rpx;
|
||
line-height: 48rpx;
|
||
}
|
||
|
||
.card-row--inline-group {
|
||
justify-content: space-between;
|
||
}
|
||
|
||
.group-item {
|
||
flex: 1;
|
||
display: flex;
|
||
align-items: flex-start;
|
||
}
|
||
|
||
.group-item + .group-item {
|
||
margin-left: 6rpx;
|
||
}
|
||
|
||
.group-item .label {
|
||
width: auto;
|
||
white-space: nowrap;
|
||
margin-right: 6rpx;
|
||
}
|
||
|
||
.label {
|
||
width: auto;
|
||
white-space: nowrap;
|
||
margin-right: 6rpx;
|
||
color: #909399;
|
||
}
|
||
|
||
.value {
|
||
flex: 1;
|
||
min-width: 0;
|
||
color: #303133;
|
||
}
|
||
|
||
.shentong-e-value {
|
||
font-size: 32rpx;
|
||
line-height: 46rpx;
|
||
}
|
||
|
||
.pick-card {
|
||
width: calc(25% - 12rpx);
|
||
height: 180rpx;
|
||
background: #fff;
|
||
border-radius: 14rpx;
|
||
padding: 10rpx;
|
||
box-sizing: border-box;
|
||
display: flex;
|
||
flex-direction: column;
|
||
justify-content: space-between;
|
||
border: 2rpx solid transparent;
|
||
position: relative;
|
||
overflow: hidden;
|
||
}
|
||
|
||
.pick-card--active {
|
||
border-color: transparent;
|
||
box-shadow: inset 0 0 0 6rpx #2979ff, 0 10rpx 24rpx rgba(41, 121, 255, 0.2);
|
||
}
|
||
|
||
.pick-card__top {
|
||
display: flex;
|
||
justify-content: space-between;
|
||
align-items: center;
|
||
min-height: 34rpx;
|
||
}
|
||
|
||
.pick-card__tag-left,
|
||
.pick-card__tag-right {
|
||
position: absolute;
|
||
top: 0;
|
||
font-size: 22rpx;
|
||
line-height: 30rpx;
|
||
padding: 4rpx 14rpx 6rpx;
|
||
background: #19be6b;
|
||
color: #fff;
|
||
max-width: 48%;
|
||
overflow: hidden;
|
||
text-overflow: ellipsis;
|
||
white-space: nowrap;
|
||
}
|
||
|
||
.pick-card__tag-left {
|
||
left: 0;
|
||
clip-path: polygon(0 0, 100% 0, 86% 100%, 0 100%);
|
||
}
|
||
|
||
.pick-card__tag-right {
|
||
right: 0;
|
||
clip-path: polygon(14% 0, 100% 0, 100% 100%, 0 100%);
|
||
}
|
||
|
||
.pick-card__main {
|
||
display: flex;
|
||
align-items: flex-end;
|
||
justify-content: center;
|
||
margin-top: 6rpx;
|
||
}
|
||
|
||
.pick-card__num {
|
||
font-size: 40rpx;
|
||
line-height: 1;
|
||
font-weight: 700;
|
||
color: #303133;
|
||
}
|
||
|
||
.pick-card__unit {
|
||
margin-left: 4rpx;
|
||
font-size: 18rpx;
|
||
line-height: 24rpx;
|
||
color: #606266;
|
||
}
|
||
|
||
.pick-card__sub {
|
||
text-align: center;
|
||
font-size: 18rpx;
|
||
line-height: 24rpx;
|
||
color: #909399;
|
||
}
|
||
|
||
.pick-card__bottom {
|
||
margin-top: 6rpx;
|
||
background: #2979ff;
|
||
color: #fff;
|
||
text-align: center;
|
||
border-radius: 10rpx;
|
||
font-size: 32rpx;
|
||
line-height: 44rpx;
|
||
padding: 2rpx 6rpx;
|
||
}
|
||
|
||
.empty-wrap {
|
||
min-height: 400rpx;
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
}
|
||
|
||
.empty-text {
|
||
font-size: 26rpx;
|
||
color: #909399;
|
||
}
|
||
|
||
.safe-area-bottom {
|
||
height: calc(20rpx + env(safe-area-inset-bottom));
|
||
}
|
||
|
||
.bottom-action-bar {
|
||
position: fixed;
|
||
left: 0;
|
||
right: 0;
|
||
bottom: 0;
|
||
display: grid;
|
||
grid-template-columns: 1fr 1fr;
|
||
column-gap: 12rpx;
|
||
padding: 12rpx 24rpx calc(12rpx + env(safe-area-inset-bottom));
|
||
background: #fff;
|
||
border-top: 1rpx solid #f0f0f0;
|
||
box-sizing: border-box;
|
||
}
|
||
</style>
|