feat: 延迟发货api
This commit is contained in:
@@ -69,7 +69,7 @@
|
||||
<view class="flex-center ju-flex-end m-t-12" v-if="props.index != 5 && isAiActionOrder">
|
||||
<AiOrderActionBar
|
||||
:status="currentStatus"
|
||||
:disableDelayShipment="isPickUpOrder"
|
||||
:disableDelayShipment="isPickUpOrder || !isAiStoreOrder"
|
||||
:showView="true"
|
||||
@delay="onDelayShipment"
|
||||
@now="onNowShipment"
|
||||
@@ -82,6 +82,54 @@
|
||||
<card_orderBan :data="props.data" @downData="downData"></card_orderBan>
|
||||
</view>
|
||||
</view>
|
||||
<uni-popup ref="delayPopupRef" type="bottom" background-color="#fff">
|
||||
<view class="delay-popup" @tap.stop>
|
||||
<view class="delay-popup__header">
|
||||
<view>
|
||||
<view class="delay-popup__title">延迟发货</view>
|
||||
<view class="delay-popup__order-no">订单号:{{ props.data.no || '-' }}</view>
|
||||
<view class="delay-popup__order-time">
|
||||
下单时间:{{ formatCreateTime(props.data.createTime) || '-' }}
|
||||
</view>
|
||||
</view>
|
||||
<view class="delay-popup__close" @tap.stop="closeDelayShipmentPopup">×</view>
|
||||
</view>
|
||||
<view class="delay-popup__desc">请选择当前商品及延迟发货数量</view>
|
||||
<scroll-view scroll-y class="delay-popup__content">
|
||||
<view
|
||||
class="delay-popup__item"
|
||||
v-for="(item, index) in delayShipmentItems"
|
||||
:key="item.orderItemId || index"
|
||||
>
|
||||
<image class="delay-popup__item-image" :src="item.picUrl" mode="aspectFill" />
|
||||
<view class="delay-popup__item-main">
|
||||
<view class="delay-popup__item-name lineTwo">{{ item.spuName }}</view>
|
||||
<view class="delay-popup__item-sku">{{ item.skuText || '-' }}</view>
|
||||
<view class="delay-popup__item-footer flex-center ju-between">
|
||||
<view class="delay-popup__item-count">最多可选 x{{ item.maxCount }}</view>
|
||||
<su-number-box
|
||||
v-model="item.selectedCount"
|
||||
:min="0"
|
||||
:max="item.maxCount"
|
||||
:step="1"
|
||||
background="#F6F7FB"
|
||||
color="#333333"
|
||||
@change="onDelayShipmentCountChange(index, $event)"
|
||||
/>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</scroll-view>
|
||||
<view class="delay-popup__actions">
|
||||
<view class="delay-popup__btn delay-popup__btn--ghost" @tap.stop="closeDelayShipmentPopup">
|
||||
取消
|
||||
</view>
|
||||
<view class="delay-popup__btn delay-popup__btn--primary" @tap.stop="submitDelayShipment">
|
||||
确认延迟发货
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</uni-popup>
|
||||
</template>
|
||||
<script setup>
|
||||
import {
|
||||
@@ -130,6 +178,13 @@
|
||||
const onCopy = (no) => {
|
||||
proxy.$sheep.$helper.copyText(no);
|
||||
};
|
||||
const formatSkuProperties = (properties) => {
|
||||
const list = Array.isArray(properties) ? properties : [];
|
||||
return list
|
||||
.map((property) => property?.valueName)
|
||||
.filter(Boolean)
|
||||
.join(' ');
|
||||
};
|
||||
const formatCreateTime = (value) => {
|
||||
if (!value) return '';
|
||||
const s = sheep?.$helper?.timeFormat
|
||||
@@ -159,6 +214,7 @@
|
||||
|
||||
const isAiActionOrder =
|
||||
String(props.data?.__source) === 'aishop' || Number(props.data?.type) === 5;
|
||||
const isAiStoreOrder = computed(() => String(props.data?.__source) === 'aishop');
|
||||
const isPickUpOrder = computed(() => {
|
||||
if (Number(props.data?.deliveryType) === 2) return true;
|
||||
return Boolean(
|
||||
@@ -182,6 +238,88 @@
|
||||
const resolveAiOrderId = (data) => {
|
||||
return data?.id || data?.orderId;
|
||||
};
|
||||
const resolveDelayOrderItemId = (item) => {
|
||||
return Number(item?.id || item?.orderItemId || item?.itemId || 0);
|
||||
};
|
||||
const delayPopupRef = ref();
|
||||
const delayShipmentItems = ref([]);
|
||||
const createDelayShipmentItems = (data) => {
|
||||
const sourceItems = Array.isArray(data?.items) ? data.items : [];
|
||||
return sourceItems
|
||||
.map((item) => {
|
||||
const maxCount = Number(item?.count || 0);
|
||||
return {
|
||||
orderItemId: resolveDelayOrderItemId(item),
|
||||
picUrl: item?.picUrl || '',
|
||||
spuName: item?.spuName || item?.name || '',
|
||||
skuText: formatSkuProperties(item?.properties),
|
||||
maxCount,
|
||||
selectedCount: maxCount,
|
||||
};
|
||||
})
|
||||
.filter((item) => item.orderItemId > 0 && item.maxCount > 0);
|
||||
};
|
||||
const closeDelayShipmentPopup = () => {
|
||||
delayPopupRef.value?.close();
|
||||
};
|
||||
const onDelayShipmentCountChange = (index, value) => {
|
||||
const current = delayShipmentItems.value[index];
|
||||
if (!current) return;
|
||||
const next = Number(value || 0);
|
||||
current.selectedCount = Math.min(current.maxCount, Math.max(0, next));
|
||||
};
|
||||
const openDelayShipmentPopup = (data) => {
|
||||
const id = resolveAiOrderId(data);
|
||||
if (!id) {
|
||||
uni.showToast({
|
||||
title: '订单信息异常',
|
||||
icon: 'none',
|
||||
});
|
||||
return;
|
||||
}
|
||||
const nextItems = createDelayShipmentItems(data);
|
||||
if (!nextItems.length) {
|
||||
uni.showToast({
|
||||
title: '未获取到可延迟商品',
|
||||
icon: 'none',
|
||||
});
|
||||
return;
|
||||
}
|
||||
delayShipmentItems.value = nextItems;
|
||||
delayPopupRef.value?.open();
|
||||
};
|
||||
const submitDelayShipment = async () => {
|
||||
const orderId = resolveAiOrderId(props.data);
|
||||
if (!orderId) {
|
||||
uni.showToast({
|
||||
title: '订单信息异常',
|
||||
icon: 'none',
|
||||
});
|
||||
return;
|
||||
}
|
||||
const items = delayShipmentItems.value
|
||||
.filter((item) => Number(item.selectedCount) > 0)
|
||||
.map((item) => ({
|
||||
orderItemId: item.orderItemId,
|
||||
count: Number(item.selectedCount),
|
||||
}));
|
||||
if (!items.length) {
|
||||
uni.showToast({
|
||||
title: '请选择延迟发货数量',
|
||||
icon: 'none',
|
||||
});
|
||||
return;
|
||||
}
|
||||
const { code } = await aiDelayedShipment({
|
||||
orderId,
|
||||
items,
|
||||
});
|
||||
if (code === 0) {
|
||||
closeDelayShipmentPopup();
|
||||
currentStatus.value = 50;
|
||||
emit('downData');
|
||||
}
|
||||
};
|
||||
|
||||
const onDelayShipment = () => {
|
||||
delayShipment(props.data);
|
||||
@@ -193,30 +331,7 @@
|
||||
|
||||
function delayShipment(data) {
|
||||
if (isPickUpOrder.value) return;
|
||||
const id = resolveAiOrderId(data);
|
||||
if (!id) {
|
||||
uni.showToast({
|
||||
title: '订单信息异常',
|
||||
icon: 'none',
|
||||
});
|
||||
return;
|
||||
}
|
||||
uni.showModal({
|
||||
title: '延迟发货',
|
||||
content: '请您确认是否暂时不需要发货,确认后该产品将为您安排延迟发货',
|
||||
confirmColor: '#FA7E31',
|
||||
success: async function (res) {
|
||||
if (!res.confirm) return;
|
||||
const { code } = await aiDelayedShipment({
|
||||
id,
|
||||
status: 50,
|
||||
});
|
||||
if (code === 0) {
|
||||
currentStatus.value = 50;
|
||||
emit('downData');
|
||||
}
|
||||
},
|
||||
});
|
||||
openDelayShipmentPopup(data);
|
||||
}
|
||||
|
||||
function nowShipment(data) {
|
||||
@@ -331,6 +446,131 @@
|
||||
line-height: 36rpx;
|
||||
}
|
||||
|
||||
.delay-popup {
|
||||
background: #ffffff;
|
||||
border-radius: 24rpx 24rpx 0 0;
|
||||
padding: 32rpx 24rpx calc(24rpx + env(safe-area-inset-bottom));
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.delay-popup__header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
margin-bottom: 12rpx;
|
||||
}
|
||||
|
||||
.delay-popup__title {
|
||||
font-size: 34rpx;
|
||||
font-weight: 600;
|
||||
color: #333333;
|
||||
}
|
||||
|
||||
.delay-popup__order-no {
|
||||
margin-top: 8rpx;
|
||||
font-size: 22rpx;
|
||||
line-height: 32rpx;
|
||||
color: #999999;
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
.delay-popup__order-time {
|
||||
margin-top: 4rpx;
|
||||
font-size: 22rpx;
|
||||
line-height: 32rpx;
|
||||
color: #999999;
|
||||
}
|
||||
|
||||
.delay-popup__close {
|
||||
width: 56rpx;
|
||||
height: 56rpx;
|
||||
border-radius: 50%;
|
||||
background: #f3f4f6;
|
||||
line-height: 56rpx;
|
||||
text-align: center;
|
||||
font-size: 36rpx;
|
||||
color: #666666;
|
||||
}
|
||||
|
||||
.delay-popup__desc {
|
||||
font-size: 24rpx;
|
||||
color: #999999;
|
||||
margin-bottom: 24rpx;
|
||||
}
|
||||
|
||||
.delay-popup__content {
|
||||
max-height: 720rpx;
|
||||
}
|
||||
|
||||
.delay-popup__item {
|
||||
display: flex;
|
||||
padding: 20rpx 0;
|
||||
border-bottom: 1rpx solid #f2f2f2;
|
||||
}
|
||||
|
||||
.delay-popup__item-image {
|
||||
width: 144rpx;
|
||||
height: 144rpx;
|
||||
border-radius: 12rpx;
|
||||
flex-shrink: 0;
|
||||
margin-right: 20rpx;
|
||||
background: #f5f5f5;
|
||||
}
|
||||
|
||||
.delay-popup__item-main {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.delay-popup__item-name {
|
||||
font-size: 28rpx;
|
||||
line-height: 40rpx;
|
||||
color: #333333;
|
||||
}
|
||||
|
||||
.delay-popup__item-sku {
|
||||
margin-top: 10rpx;
|
||||
font-size: 24rpx;
|
||||
line-height: 34rpx;
|
||||
color: #999999;
|
||||
}
|
||||
|
||||
.delay-popup__item-footer {
|
||||
margin-top: 20rpx;
|
||||
}
|
||||
|
||||
.delay-popup__item-count {
|
||||
font-size: 24rpx;
|
||||
color: #666666;
|
||||
}
|
||||
|
||||
.delay-popup__actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 20rpx;
|
||||
margin-top: 32rpx;
|
||||
}
|
||||
|
||||
.delay-popup__btn {
|
||||
flex: 1;
|
||||
height: 84rpx;
|
||||
line-height: 84rpx;
|
||||
text-align: center;
|
||||
border-radius: 42rpx;
|
||||
font-size: 28rpx;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.delay-popup__btn--ghost {
|
||||
background: #f2f3f5;
|
||||
color: #333333;
|
||||
}
|
||||
|
||||
.delay-popup__btn--primary {
|
||||
background: linear-gradient(135deg, #fa8735 0%, #fe3b48 100%);
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.price {
|
||||
color: #ee0a24;
|
||||
font-size: 24rpx;
|
||||
|
||||
Reference in New Issue
Block a user