|
@@ -476,41 +476,26 @@ const loadCouponOptionsByType = async (distributeType: number) => {
|
|
|
const key = distributeType === 2 ? "2-couponList" : "1-couponList";
|
|
const key = distributeType === 2 ? "2-couponList" : "1-couponList";
|
|
|
if (couponOptionsMap.value[key]?.length) return;
|
|
if (couponOptionsMap.value[key]?.length) return;
|
|
|
const storeId = localGet("createdId") || "";
|
|
const storeId = localGet("createdId") || "";
|
|
|
- if (distributeType === 1) {
|
|
|
|
|
- try {
|
|
|
|
|
- const res: any = await getIssueCouponList({
|
|
|
|
|
- storeId,
|
|
|
|
|
- tab: 1,
|
|
|
|
|
- size: 100,
|
|
|
|
|
- page: 1,
|
|
|
|
|
- couponName: "",
|
|
|
|
|
- couponsFromType: 1
|
|
|
|
|
- });
|
|
|
|
|
- const records = res?.data?.records ?? res?.data ?? [];
|
|
|
|
|
- const list = Array.isArray(records) ? records : [];
|
|
|
|
|
- couponDataMap.value[key] = list;
|
|
|
|
|
- couponOptionsMap.value[key] = list.map((item: any) => ({
|
|
|
|
|
- value: String(item.id ?? item.couponId ?? ""),
|
|
|
|
|
- label: item.couponName ?? item.name ?? ""
|
|
|
|
|
- }));
|
|
|
|
|
- } catch (e) {
|
|
|
|
|
- couponDataMap.value[key] = [];
|
|
|
|
|
- couponOptionsMap.value[key] = [];
|
|
|
|
|
- }
|
|
|
|
|
- } else {
|
|
|
|
|
- try {
|
|
|
|
|
- const res: any = await getVoucherList({ storeId, status: 5, size: 100, page: 1 });
|
|
|
|
|
- const records = res?.data?.records ?? res?.data ?? [];
|
|
|
|
|
- const list = Array.isArray(records) ? records : [];
|
|
|
|
|
- couponDataMap.value[key] = list;
|
|
|
|
|
- couponOptionsMap.value[key] = list.map((item: any) => ({
|
|
|
|
|
- value: String(item.id ?? item.voucherId ?? item.couponId ?? ""),
|
|
|
|
|
- label: item.name ?? item.couponName ?? ""
|
|
|
|
|
- }));
|
|
|
|
|
- } catch (e) {
|
|
|
|
|
- couponDataMap.value[key] = [];
|
|
|
|
|
- couponOptionsMap.value[key] = [];
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ try {
|
|
|
|
|
+ const res: any = await getIssueCouponList({
|
|
|
|
|
+ storeId,
|
|
|
|
|
+ tab: 1,
|
|
|
|
|
+ size: 100,
|
|
|
|
|
+ page: 1,
|
|
|
|
|
+ couponName: "",
|
|
|
|
|
+ couponsFromType: 1,
|
|
|
|
|
+ couponType: formData.distributeType
|
|
|
|
|
+ });
|
|
|
|
|
+ const records = res?.data?.records ?? res?.data ?? [];
|
|
|
|
|
+ const list = Array.isArray(records) ? records : [];
|
|
|
|
|
+ couponDataMap.value[key] = list;
|
|
|
|
|
+ couponOptionsMap.value[key] = list.map((item: any) => ({
|
|
|
|
|
+ value: String(item.id ?? item.couponId ?? ""),
|
|
|
|
|
+ label: item.couponName ?? item.name ?? ""
|
|
|
|
|
+ }));
|
|
|
|
|
+ } catch (e) {
|
|
|
|
|
+ couponDataMap.value[key] = [];
|
|
|
|
|
+ couponOptionsMap.value[key] = [];
|
|
|
}
|
|
}
|
|
|
};
|
|
};
|
|
|
|
|
|