763 lines
21 KiB
Vue
763 lines
21 KiB
Vue
<template>
|
||
<uni-popup ref="popupRef" :type="popupType" background-color="#fff">
|
||
<view class="shipment-popup" :class="`shipment-popup--${popupType}`" @tap.stop>
|
||
<view class="shipment-popup__header">
|
||
<view>
|
||
<view class="shipment-popup__title">{{ titleText }}</view>
|
||
<view class="shipment-popup__order-no">订单号:{{ orderNo || '-' }}</view>
|
||
<view class="shipment-popup__order-time">下单时间:{{ orderTime || '-' }}</view>
|
||
</view>
|
||
<view class="shipment-popup__close" @tap.stop="handleClose">×</view>
|
||
</view>
|
||
<view class="shipment-popup__desc">{{ descText }}</view>
|
||
<scroll-view scroll-y class="shipment-popup__content">
|
||
<view v-if="renderItems.length === 0" class="shipment-popup__empty">
|
||
{{ emptyText }}
|
||
</view>
|
||
<view
|
||
v-else
|
||
class="shipment-popup__item"
|
||
v-for="(item, index) in renderItems"
|
||
:key="item.itemKey || index"
|
||
>
|
||
<image class="shipment-popup__item-image" :src="item.picUrl" mode="aspectFill" />
|
||
<view class="shipment-popup__item-main">
|
||
<view class="shipment-popup__item-name lineTwo">{{ item.spuName }}</view>
|
||
<view class="shipment-popup__item-sku">{{ item.skuText || '-' }}</view>
|
||
<view class="shipment-popup__item-footer flex-center ju-between">
|
||
<view class="shipment-popup__item-count">
|
||
<text v-if="props.mode === 'delay' && Number(item.alreadyDelayed) > 0" class="shipment-popup__item-delayed">
|
||
已延迟 x{{ item.alreadyDelayed }}
|
||
</text>
|
||
<text class="shipment-popup__item-remain">最多可选 x{{ item.maxCount }}</text>
|
||
</view>
|
||
<su-number-box
|
||
v-model="item.selectedCount"
|
||
:min="0"
|
||
:max="item.maxCount"
|
||
:step="1"
|
||
background="#F6F7FB"
|
||
color="#333333"
|
||
@change="onCountChange(index, $event)"
|
||
/>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
</scroll-view>
|
||
<view class="shipment-popup__actions">
|
||
<view class="shipment-popup__btn shipment-popup__btn--ghost" @tap.stop="handleClose">
|
||
取消
|
||
</view>
|
||
<view class="shipment-popup__btn shipment-popup__btn--primary" @tap.stop="handleSubmit">
|
||
{{ submitText }}
|
||
</view>
|
||
</view>
|
||
</view>
|
||
</uni-popup>
|
||
</template>
|
||
|
||
<script setup>
|
||
import { computed, ref } from 'vue';
|
||
|
||
const props = defineProps({
|
||
mode: {
|
||
type: String,
|
||
default: 'delay',
|
||
},
|
||
popupType: {
|
||
type: String,
|
||
default: 'bottom',
|
||
},
|
||
orderNo: {
|
||
type: String,
|
||
default: '',
|
||
},
|
||
orderTime: {
|
||
type: String,
|
||
default: '',
|
||
},
|
||
orderData: {
|
||
type: Object,
|
||
default: () => ({}),
|
||
},
|
||
delayRecords: {
|
||
type: Array,
|
||
default: () => [],
|
||
},
|
||
});
|
||
|
||
const emit = defineEmits(['close', 'submit']);
|
||
const popupRef = ref();
|
||
const innerItems = ref([]);
|
||
|
||
const titleText = computed(() => (props.mode === 'now' ? '立即发货' : '延迟发货'));
|
||
const submitText = computed(() => (props.mode === 'now' ? '确认立即发货' : '确认延迟发货'));
|
||
const descText = computed(() =>
|
||
props.mode === 'now' ? '请选择当前延迟商品及立即发货数量' : '请选择当前商品及延迟发货数量',
|
||
);
|
||
const emptyText = computed(() =>
|
||
props.mode === 'now' ? '暂无可立即发货的商品' : '暂无可延迟发货的商品',
|
||
);
|
||
|
||
const getFirstValidValue = (...values) =>
|
||
values.find((value) => value !== undefined && value !== null && String(value).trim() !== '') ?? '';
|
||
|
||
const hasValue = (value) => value !== undefined && value !== null && String(value).trim() !== '';
|
||
|
||
const formatSkuPropertyItem = (property) => {
|
||
const value = getFirstValidValue(
|
||
property?.valueName,
|
||
property?.value,
|
||
property?.specValue,
|
||
property?.attrValue,
|
||
property?.optionValue,
|
||
property?.propertyValue,
|
||
typeof property === 'string' ? property : '',
|
||
);
|
||
const name = getFirstValidValue(
|
||
property?.name,
|
||
property?.propertyName,
|
||
property?.specName,
|
||
property?.attrName,
|
||
property?.key,
|
||
property?.label,
|
||
);
|
||
if (name && value) {
|
||
return `${name} ${value}`;
|
||
}
|
||
return value || name || '';
|
||
};
|
||
|
||
const formatSkuProperties = (properties) => {
|
||
if (typeof properties === 'string' && properties.trim()) {
|
||
return properties.trim();
|
||
}
|
||
const list = Array.isArray(properties) ? properties : [];
|
||
if (!list.length) {
|
||
return '';
|
||
}
|
||
return list
|
||
.map((property) => formatSkuPropertyItem(property))
|
||
.filter(Boolean)
|
||
.join(' ');
|
||
};
|
||
|
||
const resolveOrderItemId = (item = {}) =>
|
||
getFirstValidValue(item?.orderItemId, item?.itemId, item?.orderGoodsId, item?.id);
|
||
|
||
const resolveRecordItemId = (record = {}) =>
|
||
getFirstValidValue(record?.orderItemId, record?.itemId, record?.orderGoodsId);
|
||
|
||
const resolveRecordUniqueId = (record = {}) =>
|
||
getFirstValidValue(record?.id, record?.delayRecordId, record?.recordId);
|
||
|
||
const resolveRecordCount = (record = {}) => {
|
||
const candidates = [
|
||
record?.count,
|
||
record?.delayCount,
|
||
record?.recordCount,
|
||
record?.remainingCount,
|
||
record?.availableCount,
|
||
record?.canCount,
|
||
record?.maxCount,
|
||
];
|
||
const matched = candidates
|
||
.map((value) => Number(value))
|
||
.find((value) => Number.isFinite(value) && value > 0);
|
||
return matched || 0;
|
||
};
|
||
|
||
const isSameSku = (skuItem = {}, record = {}) => {
|
||
const skuProps = Array.isArray(skuItem?.properties)
|
||
? skuItem.properties
|
||
: Array.isArray(skuItem?.skuProperties)
|
||
? skuItem.skuProperties
|
||
: Array.isArray(skuItem?.attrs)
|
||
? skuItem.attrs
|
||
: Array.isArray(skuItem?.specs)
|
||
? skuItem.specs
|
||
: Array.isArray(skuItem?.specifications)
|
||
? skuItem.specifications
|
||
: [];
|
||
const recordProps = Array.isArray(record?.properties)
|
||
? record.properties
|
||
: Array.isArray(record?.skuProperties)
|
||
? record.skuProperties
|
||
: Array.isArray(record?.attrs)
|
||
? record.attrs
|
||
: Array.isArray(record?.specs)
|
||
? record.specs
|
||
: Array.isArray(record?.specifications)
|
||
? record.specifications
|
||
: [];
|
||
if (skuProps.length && recordProps.length && skuProps.length === recordProps.length) {
|
||
const skuKey = skuProps
|
||
.map((p) => `${getFirstValidValue(p?.valueName, p?.value, p?.specValue, p?.attrValue, p?.optionValue, p?.propertyValue)}`)
|
||
.filter(Boolean)
|
||
.join('|');
|
||
const recKey = recordProps
|
||
.map((p) => `${getFirstValidValue(p?.valueName, p?.value, p?.specValue, p?.attrValue, p?.optionValue, p?.propertyValue)}`)
|
||
.filter(Boolean)
|
||
.join('|');
|
||
if (skuKey && recKey) return skuKey === recKey;
|
||
if (skuKey || recKey) return false;
|
||
} else if (skuProps.length || recordProps.length) {
|
||
return false;
|
||
}
|
||
const skuText = getFirstValidValue(
|
||
skuItem?.skuText,
|
||
skuItem?.specText,
|
||
skuItem?.propertiesText,
|
||
skuItem?.skuDesc,
|
||
skuItem?.specDesc,
|
||
skuItem?.specification,
|
||
formatSkuProperties(skuItem?.properties),
|
||
formatSkuProperties(skuItem?.skuProperties),
|
||
formatSkuProperties(skuItem?.attrs),
|
||
);
|
||
const recText = getFirstValidValue(
|
||
record?.skuText,
|
||
record?.specText,
|
||
record?.propertiesText,
|
||
formatSkuProperties(record?.properties),
|
||
formatSkuProperties(record?.skuProperties),
|
||
formatSkuProperties(record?.attrs),
|
||
formatSkuProperties(record?.specs),
|
||
formatSkuProperties(record?.specifications),
|
||
record?.skuDesc,
|
||
record?.specDesc,
|
||
record?.specification,
|
||
record?.propertiesValue,
|
||
record?.skuValue,
|
||
record?.sku,
|
||
record?.specInfo,
|
||
record?.attrText,
|
||
);
|
||
if (skuText && recText) return skuText === recText;
|
||
if (skuText || recText) return false;
|
||
return false;
|
||
};
|
||
|
||
const resolveDelayItemCount = (item = {}) => {
|
||
const candidates = [
|
||
item?.count,
|
||
item?.remainingCount,
|
||
item?.availableCount,
|
||
item?.canCount,
|
||
item?.maxCount,
|
||
item?.goodsCount,
|
||
item?.productCount,
|
||
item?.num,
|
||
item?.number,
|
||
item?.quantity,
|
||
];
|
||
const matched = candidates
|
||
.map((value) => Number(value))
|
||
.find((value) => Number.isFinite(value) && value > 0);
|
||
return matched || 0;
|
||
};
|
||
|
||
const buildAlreadyDelayedCountForSpu = (spuItem = {}, parentSpu = {}, delayRecordsInput) => {
|
||
const skuItems = Array.isArray(spuItem?.items) && spuItem.items.length > 0 ? spuItem.items : [spuItem];
|
||
const targetSpuId = getFirstValidValue(
|
||
spuItem?.spuId,
|
||
spuItem?.productId,
|
||
spuItem?.goodsId,
|
||
parentSpu?.spuId,
|
||
parentSpu?.productId,
|
||
parentSpu?.goodsId,
|
||
);
|
||
const targetSpuName = getFirstValidValue(
|
||
spuItem?.spuName,
|
||
spuItem?.name,
|
||
spuItem?.goodsName,
|
||
spuItem?.productName,
|
||
parentSpu?.spuName,
|
||
parentSpu?.name,
|
||
parentSpu?.goodsName,
|
||
parentSpu?.productName,
|
||
);
|
||
const matchSpuIdentity = (record) => {
|
||
const recordSpuId = getFirstValidValue(record?.spuId, record?.productId, record?.goodsId);
|
||
if (targetSpuId && recordSpuId) return String(targetSpuId) === String(recordSpuId);
|
||
const recordSpuName = getFirstValidValue(record?.spuName, record?.name, record?.goodsName, record?.productName);
|
||
if (targetSpuName && recordSpuName) return String(targetSpuName).trim() === String(recordSpuName).trim();
|
||
return false;
|
||
};
|
||
const records = (Array.isArray(delayRecordsInput) && delayRecordsInput.length > 0 ? delayRecordsInput : []).filter((r) => {
|
||
if (!r) return false;
|
||
const status = Number(r?.status);
|
||
if (status !== 1) return false;
|
||
if (!matchSpuIdentity(r)) return false;
|
||
const c = resolveRecordCount(r);
|
||
return c > 0;
|
||
});
|
||
if (!records.length || !skuItems.length) {
|
||
const empty = new Map();
|
||
skuItems.forEach((_, i) => empty.set(resolveOrderItemId(skuItems[i]) || `sku-${i}`, 0));
|
||
return empty;
|
||
}
|
||
const skuCountMap = new Map();
|
||
skuItems.forEach((skuItem, idx) => {
|
||
const key = resolveOrderItemId(skuItem) || `sku-${idx}`;
|
||
skuCountMap.set(key, 0);
|
||
});
|
||
const usedRecordKeys = new Set();
|
||
const addRecordCountToSku = (record, skuItem, skuIdx) => {
|
||
const rKey = resolveRecordUniqueId(record) || JSON.stringify(record);
|
||
if (usedRecordKeys.has(rKey)) return false;
|
||
const skuKey = resolveOrderItemId(skuItem) || `sku-${skuIdx}`;
|
||
if (!skuCountMap.has(skuKey)) skuCountMap.set(skuKey, 0);
|
||
const c = resolveRecordCount(record);
|
||
skuCountMap.set(skuKey, (Number(skuCountMap.get(skuKey)) || 0) + c);
|
||
usedRecordKeys.add(rKey);
|
||
return true;
|
||
};
|
||
records.forEach((record) => {
|
||
const recordItemId = resolveRecordItemId(record);
|
||
if (!recordItemId) return;
|
||
const matchedIdx = skuItems.findIndex((skuItem) => {
|
||
const skuItemId = resolveOrderItemId(skuItem);
|
||
return skuItemId && String(skuItemId) === String(recordItemId);
|
||
});
|
||
if (matchedIdx >= 0) addRecordCountToSku(record, skuItems[matchedIdx], matchedIdx);
|
||
});
|
||
records.forEach((record) => {
|
||
const rKey = resolveRecordUniqueId(record) || JSON.stringify(record);
|
||
if (usedRecordKeys.has(rKey)) return;
|
||
const matchedIdx = skuItems.findIndex((skuItem) => isSameSku(skuItem, record));
|
||
if (matchedIdx >= 0) addRecordCountToSku(record, skuItems[matchedIdx], matchedIdx);
|
||
});
|
||
records.forEach((record) => {
|
||
const rKey = resolveRecordUniqueId(record) || JSON.stringify(record);
|
||
if (usedRecordKeys.has(rKey)) return;
|
||
if (skuItems.length === 1 && matchSpuIdentity(record)) {
|
||
addRecordCountToSku(record, skuItems[0], 0);
|
||
}
|
||
});
|
||
return skuCountMap;
|
||
};
|
||
|
||
const getSkuAlreadyDelayedCount = (skuCountMap, skuItem, skuIdx) => {
|
||
if (!skuCountMap || skuCountMap.size === 0) return 0;
|
||
const key = resolveOrderItemId(skuItem) || `sku-${skuIdx}`;
|
||
return Number(skuCountMap.get(key)) || 0;
|
||
};
|
||
|
||
const resolveDelayRecordId = (item = {}) =>
|
||
getFirstValidValue(item?.delayRecordId, item?.recordId, item?.id);
|
||
|
||
const resolveDelayRecordCount = (item = {}) => {
|
||
const candidates = [
|
||
item?.count,
|
||
item?.delayCount,
|
||
item?.recordCount,
|
||
item?.remainingCount,
|
||
item?.availableCount,
|
||
item?.canCount,
|
||
item?.maxCount,
|
||
];
|
||
const matched = candidates
|
||
.map((value) => Number(value))
|
||
.find((value) => Number.isFinite(value) && value > 0);
|
||
return matched || 0;
|
||
};
|
||
|
||
const createDelayShipmentItems = (data) => {
|
||
const sourceItems = Array.isArray(data?.items) ? data.items : [];
|
||
const delayRecordsInput = Array.isArray(props.delayRecords) ? props.delayRecords : [];
|
||
const results = [];
|
||
sourceItems.forEach((spuItem) => {
|
||
const hasNested = Array.isArray(spuItem?.items) && spuItem.items.length > 0;
|
||
const skuCountMap = buildAlreadyDelayedCountForSpu(spuItem, spuItem, delayRecordsInput);
|
||
if (hasNested) {
|
||
spuItem.items.forEach((skuItem, idx) => {
|
||
if (!skuItem) return;
|
||
const totalCount = resolveDelayItemCount(skuItem);
|
||
const alreadyDelayed = getSkuAlreadyDelayedCount(skuCountMap, skuItem, idx);
|
||
const remaining = Math.max(0, Number(totalCount) - Number(alreadyDelayed));
|
||
const maxCount = remaining;
|
||
if (maxCount <= 0) return;
|
||
const orderItemId = resolveOrderItemId(skuItem);
|
||
const parentOrderItemId = resolveOrderItemId(spuItem);
|
||
const submitOrderItemId = getFirstValidValue(orderItemId, parentOrderItemId);
|
||
const skuText = getFirstValidValue(
|
||
formatSkuProperties(skuItem?.properties || spuItem?.properties),
|
||
formatSkuProperties(skuItem?.skuProperties || spuItem?.skuProperties),
|
||
formatSkuProperties(skuItem?.attrs || spuItem?.attrs),
|
||
formatSkuProperties(skuItem?.specs || spuItem?.specs),
|
||
formatSkuProperties(skuItem?.specifications || spuItem?.specifications),
|
||
getFirstValidValue(skuItem?.skuText, spuItem?.skuText),
|
||
getFirstValidValue(skuItem?.specText, spuItem?.specText),
|
||
getFirstValidValue(skuItem?.propertiesText, spuItem?.propertiesText),
|
||
getFirstValidValue(skuItem?.skuDesc, spuItem?.skuDesc),
|
||
getFirstValidValue(skuItem?.specDesc, spuItem?.specDesc),
|
||
);
|
||
results.push({
|
||
itemKey: getFirstValidValue(
|
||
submitOrderItemId,
|
||
`${skuItem?.spuName || skuItem?.name || spuItem?.spuName || spuItem?.name || ''}_${skuText}_${totalCount}_${alreadyDelayed}`,
|
||
),
|
||
orderItemId,
|
||
parentOrderItemId,
|
||
submitOrderItemId,
|
||
picUrl: skuItem?.picUrl || spuItem?.picUrl || '',
|
||
spuName: skuItem?.spuName || skuItem?.name || spuItem?.spuName || spuItem?.name || '',
|
||
skuText,
|
||
totalCount,
|
||
alreadyDelayed,
|
||
maxCount,
|
||
selectedCount: maxCount,
|
||
});
|
||
});
|
||
} else {
|
||
const totalCount = resolveDelayItemCount(spuItem);
|
||
const alreadyDelayed = getSkuAlreadyDelayedCount(skuCountMap, spuItem, 0);
|
||
const remaining = Math.max(0, Number(totalCount) - Number(alreadyDelayed));
|
||
const maxCount = remaining;
|
||
if (maxCount <= 0) return;
|
||
const orderItemId = resolveOrderItemId(spuItem);
|
||
const submitOrderItemId = orderItemId;
|
||
const skuText = getFirstValidValue(
|
||
formatSkuProperties(spuItem?.properties),
|
||
formatSkuProperties(spuItem?.skuProperties),
|
||
formatSkuProperties(spuItem?.attrs),
|
||
formatSkuProperties(spuItem?.specs),
|
||
formatSkuProperties(spuItem?.specifications),
|
||
getFirstValidValue(spuItem?.skuText, spuItem?.specText, spuItem?.propertiesText),
|
||
getFirstValidValue(spuItem?.skuDesc, spuItem?.specDesc),
|
||
);
|
||
results.push({
|
||
itemKey: getFirstValidValue(
|
||
submitOrderItemId,
|
||
`${spuItem?.spuName || spuItem?.name || ''}_${skuText}_${totalCount}_${alreadyDelayed}`,
|
||
),
|
||
orderItemId,
|
||
parentOrderItemId: orderItemId,
|
||
submitOrderItemId,
|
||
picUrl: spuItem?.picUrl || '',
|
||
spuName: spuItem?.spuName || spuItem?.name || '',
|
||
skuText,
|
||
totalCount,
|
||
alreadyDelayed,
|
||
maxCount,
|
||
selectedCount: maxCount,
|
||
});
|
||
}
|
||
});
|
||
return results;
|
||
};
|
||
|
||
const createNowShipmentItem = (item) => {
|
||
const maxCount = resolveDelayRecordCount(item);
|
||
const delayRecordId = resolveDelayRecordId(item);
|
||
const skuText = getFirstValidValue(
|
||
formatSkuProperties(item?.properties),
|
||
formatSkuProperties(item?.skuProperties),
|
||
formatSkuProperties(item?.attrs),
|
||
formatSkuProperties(item?.specs),
|
||
formatSkuProperties(item?.specifications),
|
||
getFirstValidValue(item?.skuText, item?.specText, item?.propertiesText),
|
||
getFirstValidValue(item?.propertiesValue, item?.skuValue),
|
||
getFirstValidValue(item?.skuDesc, item?.specDesc, item?.specification),
|
||
getFirstValidValue(item?.sku, item?.specInfo, item?.attrText),
|
||
);
|
||
return {
|
||
itemKey: getFirstValidValue(
|
||
delayRecordId,
|
||
`${item?.spuName || item?.name || item?.title || ''}_${skuText}_${maxCount}`,
|
||
),
|
||
delayRecordId,
|
||
picUrl: getFirstValidValue(
|
||
item?.picUrl,
|
||
item?.image,
|
||
item?.imgUrl,
|
||
item?.thumbnail,
|
||
item?.pic,
|
||
item?.cover,
|
||
item?.spuImage,
|
||
item?.skuImage,
|
||
),
|
||
spuName: getFirstValidValue(
|
||
item?.spuName,
|
||
item?.name,
|
||
item?.title,
|
||
item?.goodsName,
|
||
item?.productName,
|
||
item?.spuTitle,
|
||
),
|
||
skuText,
|
||
maxCount,
|
||
selectedCount: maxCount,
|
||
};
|
||
};
|
||
|
||
const createNowShipmentItems = (data) => {
|
||
const rawExternal = Array.isArray(props.delayRecords) && props.delayRecords.length > 0
|
||
? props.delayRecords
|
||
: [];
|
||
const rawFromData = Array.isArray(data?.delayRecords)
|
||
? data.delayRecords
|
||
: Array.isArray(data?.delayRecordList)
|
||
? data.delayRecordList
|
||
: [];
|
||
const raw = rawExternal.length > 0 ? rawExternal : rawFromData;
|
||
return raw
|
||
.filter(Boolean)
|
||
.filter((item) => {
|
||
const status = Number(item?.status);
|
||
if (!status) return true;
|
||
return status === 1;
|
||
})
|
||
.map((item) => createNowShipmentItem(item))
|
||
.filter((item) => item.maxCount > 0);
|
||
};
|
||
|
||
const renderItems = computed(() => innerItems.value || []);
|
||
|
||
const open = () => {
|
||
const nextItems = props.mode === 'now' ? createNowShipmentItems(props.orderData) : createDelayShipmentItems(props.orderData);
|
||
innerItems.value = nextItems;
|
||
if (!popupRef.value || typeof popupRef.value.open !== 'function') {
|
||
uni.showToast({
|
||
title: '弹窗组件初始化失败,请重试',
|
||
icon: 'none',
|
||
});
|
||
return;
|
||
}
|
||
popupRef.value.open();
|
||
};
|
||
|
||
const close = () => {
|
||
if (popupRef.value && typeof popupRef.value.close === 'function') {
|
||
popupRef.value.close();
|
||
}
|
||
};
|
||
|
||
const handleClose = () => {
|
||
emit('close');
|
||
close();
|
||
};
|
||
|
||
const onCountChange = (index, value) => {
|
||
const current = innerItems.value[index];
|
||
if (!current) return;
|
||
const next = Number(value);
|
||
if (!Number.isFinite(next)) {
|
||
current.selectedCount = 0;
|
||
return;
|
||
}
|
||
current.selectedCount = Math.min(current.maxCount, Math.max(0, next));
|
||
};
|
||
|
||
const buildSubmitPayload = () => {
|
||
if (props.mode === 'now') {
|
||
const hasSelectedCount = innerItems.value.some((item) => Number(item.selectedCount) > 0);
|
||
const items = innerItems.value
|
||
.filter((item) => Number(item.selectedCount) > 0 && hasValue(item.delayRecordId))
|
||
.map((item) => ({
|
||
delayRecordId: item.delayRecordId,
|
||
count: Number(item.selectedCount),
|
||
}));
|
||
return {
|
||
hasSelectedCount,
|
||
items,
|
||
emptyTitle: hasSelectedCount ? '订单商品信息异常' : '请选择立即发货数量',
|
||
};
|
||
}
|
||
const hasSelectedCount = innerItems.value.some((item) => Number(item.selectedCount) > 0);
|
||
const items = innerItems.value
|
||
.filter((item) => Number(item.selectedCount) > 0 && hasValue(item.submitOrderItemId))
|
||
.map((item) => ({
|
||
orderItemId: item.submitOrderItemId,
|
||
count: Number(item.selectedCount),
|
||
}));
|
||
return {
|
||
hasSelectedCount,
|
||
items,
|
||
emptyTitle: hasSelectedCount ? '订单商品信息异常' : '请选择延迟发货数量',
|
||
};
|
||
};
|
||
|
||
const handleSubmit = () => {
|
||
const payload = buildSubmitPayload();
|
||
if (!payload.items.length) {
|
||
uni.showToast({
|
||
title: payload.emptyTitle,
|
||
icon: 'none',
|
||
});
|
||
return;
|
||
}
|
||
emit('submit', {
|
||
mode: props.mode,
|
||
items: payload.items,
|
||
close,
|
||
});
|
||
};
|
||
|
||
defineExpose({
|
||
open,
|
||
close,
|
||
});
|
||
</script>
|
||
|
||
<style lang="scss" scoped>
|
||
.shipment-popup {
|
||
background: #ffffff;
|
||
box-sizing: border-box;
|
||
}
|
||
|
||
.shipment-popup--bottom {
|
||
border-radius: 24rpx 24rpx 0 0;
|
||
padding: 32rpx 24rpx calc(24rpx + env(safe-area-inset-bottom));
|
||
}
|
||
|
||
.shipment-popup--center {
|
||
width: 680rpx;
|
||
max-height: 78vh;
|
||
border-radius: 24rpx;
|
||
padding: 32rpx 24rpx;
|
||
overflow: hidden;
|
||
}
|
||
|
||
.shipment-popup__header {
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: space-between;
|
||
margin-bottom: 12rpx;
|
||
}
|
||
|
||
.shipment-popup__title {
|
||
font-size: 34rpx;
|
||
font-weight: 600;
|
||
color: #333333;
|
||
}
|
||
|
||
.shipment-popup__order-no {
|
||
margin-top: 8rpx;
|
||
font-size: 22rpx;
|
||
line-height: 32rpx;
|
||
color: #999999;
|
||
word-break: break-all;
|
||
}
|
||
|
||
.shipment-popup__order-time {
|
||
margin-top: 4rpx;
|
||
font-size: 22rpx;
|
||
line-height: 32rpx;
|
||
color: #999999;
|
||
}
|
||
|
||
.shipment-popup__close {
|
||
width: 56rpx;
|
||
height: 56rpx;
|
||
border-radius: 50%;
|
||
background: #f3f4f6;
|
||
line-height: 56rpx;
|
||
text-align: center;
|
||
font-size: 36rpx;
|
||
color: #666666;
|
||
}
|
||
|
||
.shipment-popup__desc {
|
||
font-size: 24rpx;
|
||
color: #999999;
|
||
margin-bottom: 24rpx;
|
||
}
|
||
|
||
.shipment-popup__content {
|
||
max-height: 720rpx;
|
||
}
|
||
|
||
.shipment-popup__item {
|
||
display: flex;
|
||
padding: 20rpx 0;
|
||
border-bottom: 1rpx solid #f2f2f2;
|
||
}
|
||
|
||
.shipment-popup__item-image {
|
||
width: 144rpx;
|
||
height: 144rpx;
|
||
border-radius: 12rpx;
|
||
flex-shrink: 0;
|
||
margin-right: 20rpx;
|
||
background: #f5f5f5;
|
||
}
|
||
|
||
.shipment-popup__item-main {
|
||
flex: 1;
|
||
min-width: 0;
|
||
}
|
||
|
||
.shipment-popup__item-name {
|
||
font-size: 28rpx;
|
||
line-height: 40rpx;
|
||
color: #333333;
|
||
}
|
||
|
||
.shipment-popup__item-sku {
|
||
margin-top: 10rpx;
|
||
font-size: 24rpx;
|
||
line-height: 34rpx;
|
||
color: #999999;
|
||
}
|
||
|
||
.shipment-popup__item-footer {
|
||
margin-top: 20rpx;
|
||
}
|
||
|
||
.shipment-popup__item-count {
|
||
font-size: 24rpx;
|
||
color: #666666;
|
||
display: flex;
|
||
align-items: center;
|
||
flex-wrap: wrap;
|
||
gap: 8rpx;
|
||
}
|
||
|
||
.shipment-popup__item-delayed {
|
||
color: #FA7E31;
|
||
background: #FFF4EC;
|
||
padding: 4rpx 12rpx;
|
||
border-radius: 8rpx;
|
||
}
|
||
|
||
.shipment-popup__item-remain {
|
||
color: #666666;
|
||
}
|
||
|
||
.shipment-popup__actions {
|
||
display: flex;
|
||
align-items: center;
|
||
gap: 20rpx;
|
||
margin-top: 32rpx;
|
||
}
|
||
|
||
.shipment-popup__btn {
|
||
flex: 1;
|
||
height: 84rpx;
|
||
line-height: 84rpx;
|
||
text-align: center;
|
||
border-radius: 42rpx;
|
||
font-size: 28rpx;
|
||
font-weight: 500;
|
||
}
|
||
|
||
.shipment-popup__btn--ghost {
|
||
background: #f2f3f5;
|
||
color: #333333;
|
||
}
|
||
|
||
.shipment-popup__btn--primary {
|
||
background: linear-gradient(135deg, #fa8735 0%, #fe3b48 100%);
|
||
color: #ffffff;
|
||
}
|
||
|
||
.shipment-popup__empty {
|
||
padding: 40rpx 24rpx;
|
||
text-align: center;
|
||
font-size: 26rpx;
|
||
color: #999999;
|
||
}
|
||
</style>
|