|
|
@@ -527,7 +527,8 @@
|
|
|
placeholder="选择优惠券"
|
|
|
style="flex: 1; min-width: 0"
|
|
|
clearable
|
|
|
- @focus="loadGiftCouponList(giftCouponFormData.giftType)"
|
|
|
+ :loading="giftCouponListLoading"
|
|
|
+ @visible-change="(visible: boolean) => visible && loadGiftCouponList(giftCouponFormData.giftType)"
|
|
|
@change="onGiftRowCouponChange(row)"
|
|
|
>
|
|
|
<el-option
|
|
|
@@ -541,7 +542,7 @@
|
|
|
<div class="quantity-cell">
|
|
|
<el-input
|
|
|
type="number"
|
|
|
- :model-value="row.quantity"
|
|
|
+ :model-value="row.quantity === 0 ? '' : row.quantity"
|
|
|
placeholder="请输入赠券数量"
|
|
|
class="quantity-input"
|
|
|
:min="1"
|
|
|
@@ -607,7 +608,6 @@ import {
|
|
|
import { uploadImg } from "@/api/modules/upload";
|
|
|
import { useUserStore } from "@/stores/modules/user";
|
|
|
import { localGet } from "@/utils";
|
|
|
-import { s } from "node_modules/vite/dist/node/types.d-aGj9QkWt";
|
|
|
|
|
|
const route = useRoute();
|
|
|
const router = useRouter();
|
|
|
@@ -1182,6 +1182,7 @@ const giftFriendList = ref<{ id: number | string; name: string; phoneId?: string
|
|
|
const giftFriendListLoading = ref(false);
|
|
|
const giftCouponList = ref<{ id: number | string; name: string; singleQty?: number }[]>([]);
|
|
|
const giftCouponListLoaded = ref(false);
|
|
|
+const giftCouponListLoading = ref(false);
|
|
|
let giftCouponRowKey = 0;
|
|
|
const giftCouponFormData = reactive<{
|
|
|
friendId: string | number;
|
|
|
@@ -1221,6 +1222,7 @@ const loadGiftFriendList = async () => {
|
|
|
};
|
|
|
|
|
|
const loadGiftCouponList = async (giftType: "coupon" | "voucher" = giftCouponFormData.giftType) => {
|
|
|
+ giftCouponListLoading.value = true;
|
|
|
try {
|
|
|
const storeId = localGet("createdId") || userStore.userInfo?.storeId || userStore.userInfo?.createdId;
|
|
|
let params: any = {};
|
|
|
@@ -1255,6 +1257,7 @@ const loadGiftCouponList = async (giftType: "coupon" | "voucher" = giftCouponFor
|
|
|
} catch {
|
|
|
giftCouponList.value = [];
|
|
|
} finally {
|
|
|
+ giftCouponListLoading.value = false;
|
|
|
}
|
|
|
};
|
|
|
|
|
|
@@ -1291,10 +1294,14 @@ const onGiftRowCouponChange = (row: { couponId: string | number; quantity: numbe
|
|
|
if (row.quantity > max) row.quantity = max;
|
|
|
};
|
|
|
|
|
|
-// 输入时即时限制:不允许超出最大数量,输入即截断,输入框从不显示超出的数
|
|
|
+// 输入时即时限制:不允许超出最大数量;允许先清空再输入其他数字(空时暂存为 0,展示为空)
|
|
|
const setGiftRowQuantity = (row: { couponId: string | number; quantity: number }, val: string | number | undefined) => {
|
|
|
const max = getGiftRowMaxQuantity(row);
|
|
|
- const num = val === "" || val == null || Number.isNaN(Number(val)) ? 1 : Number(val);
|
|
|
+ if (val === "" || val == null || Number.isNaN(Number(val))) {
|
|
|
+ row.quantity = 0; // 允许清空,便于用户删除后输入新数量
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ const num = Number(val);
|
|
|
row.quantity = Math.min(Math.max(1, num), max);
|
|
|
};
|
|
|
|