|
|
@@ -1,3 +1,8 @@
|
|
|
+<!--
|
|
|
+ 花店移动端订单列表
|
|
|
+ 用途:管理员查看/筛选订单,并做取货、配送、打印、跑腿、通知制作等操作
|
|
|
+ 团购单:groupBuyId != '0' 时不能只看订单 status,还须结合 groupBuyStatus 控制按钮
|
|
|
+-->
|
|
|
<template>
|
|
|
<view class="order-page app-content">
|
|
|
<view class="page-header">
|
|
|
@@ -88,7 +93,7 @@
|
|
|
<view class="header-tags">
|
|
|
<text class="tag debt-tag" v-if="item.debt == 1">挂账</text>
|
|
|
<text class="tag refund-tag" v-if="item.refund == 1">有售后</text>
|
|
|
- <view class="status-label" :class="{ 'status-label--cancel': item.status == 5 }">
|
|
|
+ <view class="status-label" :class="{ 'status-label--cancel': item._statusLabelCancel }">
|
|
|
<image v-if="item._statusIcon" class="card-icon-sm" :src="iconSrc(item._statusIcon)" mode="aspectFit" />
|
|
|
<text>{{ item._statusText }}</text>
|
|
|
</view>
|
|
|
@@ -138,7 +143,10 @@
|
|
|
<text> ¥{{ item._actPriceText }}</text>
|
|
|
</view>
|
|
|
</view>
|
|
|
- <text v-if="item.sendType == 1" class="pickup-tag">到店自取</text>
|
|
|
+ <view v-if="item.sendType == 1 || item.groupBuyId != '0'" class="order-tags">
|
|
|
+ <text v-if="item.sendType == 1" class="pickup-tag">到店自取</text>
|
|
|
+ <text v-if="item.groupBuyId != '0'" class="group-buy-tag">团购单</text>
|
|
|
+ </view>
|
|
|
</view>
|
|
|
</view>
|
|
|
</view>
|
|
|
@@ -165,8 +173,8 @@
|
|
|
|
|
|
<view
|
|
|
class="outline-action"
|
|
|
- :class="{ disabled: !item._isPaid }"
|
|
|
- @click.stop="item._isPaid ? printOrder(index) : ''"
|
|
|
+ :class="{ disabled: !item._canFulfill }"
|
|
|
+ @click.stop="item._canFulfill ? printOrder(index) : ''"
|
|
|
>打印</view>
|
|
|
|
|
|
<view
|
|
|
@@ -178,11 +186,11 @@
|
|
|
</view>
|
|
|
|
|
|
<view class="action-more-wrap">
|
|
|
- <!-- 已取消订单:「更多」灰色且不可点开菜单 -->
|
|
|
+ <!-- 已取消 / 团购未成团或失败:「更多」灰色且不可点开菜单 -->
|
|
|
<view
|
|
|
class="outline-action"
|
|
|
- :class="{ disabled: item.status == 5 }"
|
|
|
- @click.stop="item.status == 5 ? '' : toggleActionMore(index)"
|
|
|
+ :class="{ disabled: item._moreDisabled }"
|
|
|
+ @click.stop="item._moreDisabled ? '' : toggleActionMore(index)"
|
|
|
>更多</view>
|
|
|
</view>
|
|
|
</view>
|
|
|
@@ -312,6 +320,19 @@ const ORDER_STATUS_TEXT_MAP = {
|
|
|
5: "已取消"
|
|
|
};
|
|
|
|
|
|
+// 拼团状态:与后端 GroupBuyClass / xhGroupBuy.status 对齐
|
|
|
+const GROUP_BUY_STATUS_ONGOING = 1;
|
|
|
+const GROUP_BUY_STATUS_SUCCESS = 2;
|
|
|
+const GROUP_BUY_STATUS_FAIL = 3;
|
|
|
+const GROUP_BUY_STATUS_CANCEL = 4;
|
|
|
+
|
|
|
+const GROUP_BUY_STATUS_TEXT_MAP = {
|
|
|
+ 1: "拼团中",
|
|
|
+ 2: "拼团成功",
|
|
|
+ 3: "拼团失败",
|
|
|
+ 4: "已取消"
|
|
|
+};
|
|
|
+
|
|
|
const RETRY_EXPRESS_STATUS_MAP = {
|
|
|
"-1": true,
|
|
|
"-2": true
|
|
|
@@ -449,6 +470,10 @@ export default {
|
|
|
* @param {number} index - 订单列表索引
|
|
|
*/
|
|
|
toggleActionMore (index) {
|
|
|
+ const current = this.list.data[index];
|
|
|
+ if (!current || current._moreDisabled) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
this.closeBatchMenu();
|
|
|
const targetIndex = Number(index);
|
|
|
if (this.activeMoreIndex === targetIndex) {
|
|
|
@@ -648,7 +673,7 @@ export default {
|
|
|
*/
|
|
|
handleDeliveryAction (index) {
|
|
|
const item = this.list.data[index];
|
|
|
- if (!item || Number(item.status) !== 2) {
|
|
|
+ if (!item || !item._showDeliveryAction) {
|
|
|
return;
|
|
|
}
|
|
|
if (Number(item.sendType) === 1) {
|
|
|
@@ -768,7 +793,7 @@ export default {
|
|
|
*/
|
|
|
printOrder (index) {
|
|
|
const item = this.list.data[index];
|
|
|
- if (!item) return;
|
|
|
+ if (!item || !item._canFulfill) return;
|
|
|
onlinePrintOrder({ id: item.id }).then(res => {
|
|
|
if (res.code == 1) {
|
|
|
this.$msg("操作成功");
|
|
|
@@ -858,6 +883,44 @@ export default {
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
+ /**
|
|
|
+ * 是否团购单:接口 groupBuyId 非 0 即视为团购(与模板 item.groupBuyId != '0' 一致)
|
|
|
+ * @param {Object} item - 订单行
|
|
|
+ * @returns {boolean}
|
|
|
+ */
|
|
|
+ isGroupBuyOrder (item) {
|
|
|
+ return !!(item && item.groupBuyId != '0' && Number(item.groupBuyId) > 0);
|
|
|
+ },
|
|
|
+ /**
|
|
|
+ * 团购单是否已成团成功,可按普通已支付订单履约
|
|
|
+ * 非团购单直接视为可履约(再由 status / payStatus 决定)
|
|
|
+ * @param {Object} item - 订单行
|
|
|
+ * @returns {boolean}
|
|
|
+ */
|
|
|
+ isGroupBuyFulfillable (item) {
|
|
|
+ if (!this.isGroupBuyOrder(item)) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ return Number(item.groupBuyStatus) === GROUP_BUY_STATUS_SUCCESS;
|
|
|
+ },
|
|
|
+ /**
|
|
|
+ * 团购失败或团已取消:履约按钮全部禁用,样式按已取消
|
|
|
+ * @param {Object} item - 订单行
|
|
|
+ * @returns {boolean}
|
|
|
+ */
|
|
|
+ isGroupBuyClosed (item) {
|
|
|
+ if (!this.isGroupBuyOrder(item)) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ const groupBuyStatus = Number(item.groupBuyStatus);
|
|
|
+ return groupBuyStatus === GROUP_BUY_STATUS_FAIL || groupBuyStatus === GROUP_BUY_STATUS_CANCEL;
|
|
|
+ },
|
|
|
+ /**
|
|
|
+ * 规范化列表行:金额/文案 + 操作按钮可用性
|
|
|
+ * 团购单须成团成功才开放打印/取货/跑腿/通知制作;拼团中、失败、已取消一律不可履约
|
|
|
+ * @param {Object} item - 接口订单行
|
|
|
+ * @returns {Object} 带 _ 前缀展示字段的同一对象
|
|
|
+ */
|
|
|
prepareOrderItem (item) {
|
|
|
if (!item) {
|
|
|
return item;
|
|
|
@@ -866,22 +929,28 @@ export default {
|
|
|
const sendType = Number(item.sendType);
|
|
|
const sendStatus = Number(item.sendStatus);
|
|
|
const isPaid = Number(item.payStatus) === 1;
|
|
|
- const express = this.getExpressMeta(status, sendStatus, isPaid);
|
|
|
+ // 团购未成团成功时,即使已付款也不能当普通待发货单操作
|
|
|
+ const canFulfill = isPaid && this.isGroupBuyFulfillable(item);
|
|
|
+ const groupBuyClosed = this.isGroupBuyClosed(item);
|
|
|
+ const express = this.getExpressMeta(status, sendStatus, canFulfill);
|
|
|
|
|
|
Object.assign(item, {
|
|
|
_statusText: this.orderStatusText(item),
|
|
|
_statusIcon: this.orderStatusIcon(item),
|
|
|
+ _statusLabelCancel: status === 5 || groupBuyClosed,
|
|
|
_reachText: this.orderReachText(item),
|
|
|
_addTimeText: this.shortDateTime(item.addTime),
|
|
|
_sendCostText: this.formatMoney(item.sendCost),
|
|
|
_orderPriceText: this.formatMoney(item.orderPrice),
|
|
|
_actPriceText: this.formatMoney(item.actPrice),
|
|
|
_isPaid: isPaid,
|
|
|
- _canSendWork: isPaid && (Number(item.hasWork) === 0 || Number(item.hasWork) === 2),
|
|
|
- // 待发货时展示取货/配送操作:到店自取显示「已取货」,配送单显示「自配送」,二者互斥
|
|
|
- _showDeliveryAction: status === 2,
|
|
|
+ _canFulfill: canFulfill,
|
|
|
+ _canSendWork: canFulfill && (Number(item.hasWork) === 0 || Number(item.hasWork) === 2),
|
|
|
+ // 待发货且(非团购或已成团)才开放取货/自配送
|
|
|
+ _showDeliveryAction: canFulfill && status === 2,
|
|
|
_deliveryActionText: sendType === 1 ? "已取货" : "自配送",
|
|
|
- _showConfirmReachAction: status === 3,
|
|
|
+ _showConfirmReachAction: canFulfill && status === 3,
|
|
|
+ _moreDisabled: status === 5 || groupBuyClosed || (this.isGroupBuyOrder(item) && !canFulfill),
|
|
|
_expressText: express.text,
|
|
|
_expressDisabled: express.disabled,
|
|
|
_expressIconColor: express.iconColor
|
|
|
@@ -906,13 +975,40 @@ export default {
|
|
|
}
|
|
|
return { text: "呼叫跑腿", disabled: true, iconColor: "#09C567" };
|
|
|
},
|
|
|
+ /**
|
|
|
+ * 列表状态文案:团购未成团/失败时优先展示拼团状态,避免误显示「待发货」
|
|
|
+ * @param {Object} item - 订单行
|
|
|
+ * @returns {string}
|
|
|
+ */
|
|
|
orderStatusText (item) {
|
|
|
+ if (this.isGroupBuyOrder(item)) {
|
|
|
+ const groupBuyStatus = Number(item.groupBuyStatus);
|
|
|
+ const status = Number(item.status);
|
|
|
+ // 已付款但团未成:展示拼团中,避免误当成待发货
|
|
|
+ if (groupBuyStatus === GROUP_BUY_STATUS_ONGOING && status !== 1 && status !== 5) {
|
|
|
+ return GROUP_BUY_STATUS_TEXT_MAP[GROUP_BUY_STATUS_ONGOING];
|
|
|
+ }
|
|
|
+ if (groupBuyStatus === GROUP_BUY_STATUS_FAIL) {
|
|
|
+ return GROUP_BUY_STATUS_TEXT_MAP[GROUP_BUY_STATUS_FAIL];
|
|
|
+ }
|
|
|
+ if (groupBuyStatus === GROUP_BUY_STATUS_CANCEL) {
|
|
|
+ return GROUP_BUY_STATUS_TEXT_MAP[GROUP_BUY_STATUS_CANCEL];
|
|
|
+ }
|
|
|
+ }
|
|
|
if (item.status == 2 && item.sendType == 1) {
|
|
|
return "待取货";
|
|
|
}
|
|
|
return ORDER_STATUS_TEXT_MAP[Number(item.status)] || "";
|
|
|
},
|
|
|
+ /**
|
|
|
+ * 状态图标:团购拼团中/失败/取消不展示配送图标
|
|
|
+ * @param {Object} item - 订单行
|
|
|
+ * @returns {string}
|
|
|
+ */
|
|
|
orderStatusIcon (item) {
|
|
|
+ if (this.isGroupBuyOrder(item) && !this.isGroupBuyFulfillable(item)) {
|
|
|
+ return "";
|
|
|
+ }
|
|
|
if (Number(item.status) == 4) {
|
|
|
return "order-htscit-complete";
|
|
|
}
|
|
|
@@ -1477,9 +1573,19 @@ export default {
|
|
|
max-width: 360upx;
|
|
|
}
|
|
|
|
|
|
+/* 订单标签行:自取/团购从左到右并排,右对齐贴合价格区 */
|
|
|
+.order-tags {
|
|
|
+ display: flex;
|
|
|
+ flex-direction: row;
|
|
|
+ flex-wrap: nowrap;
|
|
|
+ align-items: center;
|
|
|
+ justify-content: flex-end;
|
|
|
+ margin-top: 20upx;
|
|
|
+}
|
|
|
+
|
|
|
+.group-buy-tag,
|
|
|
.pickup-tag {
|
|
|
display: inline-block;
|
|
|
- margin-top: 20upx;
|
|
|
padding: 3upx 10upx;
|
|
|
border: 1upx solid #45b880;
|
|
|
border-radius: 8upx;
|
|
|
@@ -1489,6 +1595,10 @@ export default {
|
|
|
flex-shrink: 0;
|
|
|
}
|
|
|
|
|
|
+.pickup-tag + .group-buy-tag {
|
|
|
+ margin-left: 8upx;
|
|
|
+}
|
|
|
+
|
|
|
.cover-price {
|
|
|
width: 206upx;
|
|
|
flex-shrink: 0;
|