lxr 1 ヶ月 前
コミット
3ca9ba74dd

+ 66 - 57
src/views/dynamicManagement/friendCoupon.vue

@@ -187,71 +187,83 @@ const giftRules = reactive<FormRules>({
   quantity: [{ required: true, message: "请输入赠送数量", trigger: "blur" }]
 });
 
-// 好友留言表格列配置
+// 好友赠我表格列配置(与截图一致:店铺名称、类型、数量、结束时间、操作)
 const friendMessageColumns = reactive<ColumnProps<any>[]>([
   {
     prop: "storeName",
     label: "店铺名称",
     search: {
-      el: "input"
+      el: "input",
+      props: { placeholder: "请输入" }
     }
   },
   {
-    prop: "couponName",
-    label: "优惠券名称"
-  },
-  {
-    prop: "nominalValue",
-    label: "优惠券额",
+    prop: "couponType",
+    label: "类型",
+    search: {
+      el: "select",
+      props: { placeholder: "请选择" }
+    },
+    enum: [
+      { label: "满减券", value: 1 },
+      { label: "折扣券", value: 2 }
+    ],
     render: (scope: any) => {
-      return `¥${scope.row.nominalValue || 0}`;
+      const typeMap: Record<number, string> = { 1: "满减券", 2: "折扣券" };
+      return typeMap[scope.row.type] ?? scope.row.couponTypeName ?? "--";
     }
   },
   {
+    prop: "couponNum",
+    label: "数量"
+  },
+  {
     prop: "endDate",
-    label: "有效期至",
+    label: "结束时间",
     render: (scope: any) => {
       return scope.row.endDate?.replace(/-/g, "/") || "--";
     }
   },
-  {
-    prop: "couponNum",
-    label: "优惠券数量"
-  },
   { prop: "operation", label: "操作", fixed: "right", width: 200 }
 ]);
 
-// 我赠好友表格列配置
+// 我赠好友表格列配置(与好友赠我保持一致)
 const myGiftColumns = reactive<ColumnProps<any>[]>([
   {
     prop: "storeName",
     label: "店铺名称",
     search: {
-      el: "input"
+      el: "input",
+      props: { placeholder: "请输入" }
     }
   },
   {
-    prop: "couponName",
-    label: "优惠券名称"
-  },
-  {
-    prop: "nominalValue",
-    label: "优惠券额",
+    prop: "couponType",
+    label: "类型",
+    search: {
+      el: "select",
+      props: { placeholder: "请选择" }
+    },
+    enum: [
+      { label: "满减券", value: 1 },
+      { label: "折扣券", value: 2 }
+    ],
     render: (scope: any) => {
-      return `¥${scope.row.nominalValue || 0}`;
+      const typeMap: Record<number, string> = { 1: "满减券", 2: "折扣券" };
+      return typeMap[scope.row.type] ?? scope.row.couponTypeName ?? "--";
     }
   },
   {
+    prop: "couponNum",
+    label: "数量"
+  },
+  {
     prop: "endDate",
-    label: "有效期至",
+    label: "结束时间",
     render: (scope: any) => {
       return scope.row.endDate?.replace(/-/g, "/") || "--";
     }
   },
-  {
-    prop: "couponNum",
-    label: "优惠券数量"
-  },
   { prop: "operation", label: "操作", fixed: "right", width: 200 }
 ]);
 
@@ -259,46 +271,43 @@ const myGiftColumns = reactive<ColumnProps<any>[]>([
 const columns = computed(() => {
   return activeName.value === "friendMessage" ? friendMessageColumns : myGiftColumns;
 });
-// 初始化请求参数 - 好友赠我传 storeUserId
-const initParam = reactive({
-  storeUserId: localGet("createdId"), // 好友赠我:当前店铺ID(接收方)
-  friendStoreUserId: undefined as number | undefined // 我赠好友:当前用户ID(赠送方)
-  // type: activeName.value
+// 初始化请求参数:列表接口格式 storeUserId、storeName、type、queryType(queryType 1=好友赠我 2=我赠好友)
+const initParam = reactive<Record<string, any>>({
+  storeUserId: localGet("createdId") ?? "",
+  queryType: 1
 });
 
-// Tab切换处理
+// Tab 切换处理:queryType 1=好友赠我,2=我赠好友
 const handleTabClick = () => {
-  // initParam.type = activeName.value;
-
-  // 根据当前 tab 设置正确的参数
-  if (activeName.value === "myGift") {
-    // 好友赠我:传 storeUserId
-    initParam.storeUserId = localGet("createdId");
-    initParam.friendStoreUserId = undefined;
-  } else {
-    // 我赠好友:传 friendStoreUserId
-    initParam.storeUserId = undefined;
-    initParam.friendStoreUserId = localGet("geeker-user").userInfo.id;
-  }
-
+  initParam.queryType = activeName.value === "friendMessage" ? 1 : 2;
   proTable.value?.getTableList();
 };
 
-// dataCallback 是对于返回的表格数据做处理
+// dataCallback:兼容后端返回格式——data 直接为数组 或 { records/list, total },统一为 { list, total }
 const dataCallback = (data: any) => {
-  return {
-    list: data || [],
-    total: data?.length || 0
-  };
+  if (!data) return { list: [], total: 0 };
+  if (Array.isArray(data)) {
+    return { list: data, total: data.length };
+  }
+  const list = data.records ?? data.list ?? [];
+  const total = data.total ?? list.length;
+  return { list, total };
 };
 
-// 获取表格列表
+// 获取表格列表:接口参数 storeUserId、storeName、couponType、queryType(1=好友赠我 2=我赠好友)、分页
 const getTableList = (params: any) => {
-  const newParams = {
-    ...params
-    //type: activeName.value === "friendMessage" ? 0 : 1 // 0-好友赠我,1-我赠好友
+  const newParams: any = {
+    storeUserId: "386",
+    storeName: params.storeName ?? "",
+    type: 1,
+    queryType: activeName.value === "friendMessage" ? 1 : 2,
+    page: params.pageNum ?? 1,
+    size: params.pageSize ?? 10
   };
-
+  // 优惠券类型:1=仅满减券,2=仅折扣券,不传=全部优惠券
+  if (params.couponType === 1 || params.couponType === 2) {
+    newParams.couponType = params.couponType;
+  }
   return getFriendCouponList(newParams);
 };
 

+ 35 - 63
src/views/dynamicManagement/friendCouponDetail.vue

@@ -3,31 +3,38 @@
   <div class="table-box" style="width: 100%; min-height: 100%; background-color: white">
     <div class="header">
       <el-button @click="goBack"> 返回 </el-button>
-      <h2 class="title">好友优惠券详情</h2>
+      <h2 class="title">优惠券详情</h2>
     </div>
     <div class="content">
       <!-- 左侧内容区域 -->
       <div class="contentLeft">
-        <!-- 基础信息模块 -->
+        <!-- 基础信息模块(与截图一致:店铺名称、类型、优惠券名称、面值、数量、结束时间、有效期) -->
         <div class="model">
           <h3 style="font-weight: bold">基础信息:</h3>
           <!-- 店铺名称 -->
           <div class="detail-item">
             <div class="detail-label">店铺名称</div>
             <div class="detail-value">
-              {{ couponModel.name || "--" }}
+              {{ couponModel.storeName || "--" }}
+            </div>
+          </div>
+          <!-- 类型 -->
+          <div class="detail-item">
+            <div class="detail-label">类型</div>
+            <div class="detail-value">
+              {{ getCouponTypeText(couponModel.couponType) }}
             </div>
           </div>
           <!-- 优惠券名称 -->
           <div class="detail-item">
             <div class="detail-label">优惠券名称</div>
             <div class="detail-value">
-              {{ couponModel.name || "--" }}
+              {{ couponModel.couponName || couponModel.name || "--" }}
             </div>
           </div>
           <!-- 面值 -->
           <div class="detail-item">
-            <div class="detail-label">面值(元)</div>
+            <div class="detail-label">面值</div>
             <div class="detail-value" v-if="couponId">
               {{ formatCurrency(couponModel.nominalValue, 2, "¥") }}
             </div>
@@ -35,24 +42,31 @@
               {{ formatCurrency(couponModel.nominalValue ?? couponModel.price, 2, "¥") }}
             </div>
           </div>
-          <!-- 有效期至 -->
+          <!-- 数量 -->
+          <div class="detail-item">
+            <div class="detail-label">数量</div>
+            <div class="detail-value">
+              {{ couponModel.couponNum ?? couponModel.singleQty ?? "--" }}
+            </div>
+          </div>
+          <!-- 结束时间 -->
           <div class="detail-item">
-            <div class="detail-label">有效期至</div>
+            <div class="detail-label">结束时间</div>
             <div class="detail-value" v-if="couponId">
-              {{ couponModel.endGetDate }}
+              {{ couponModel.endGetDate || "--" }}
             </div>
             <div class="detail-value" v-else>
-              {{ couponModel.endDate }}
+              {{ couponModel.endDate || "--" }}
             </div>
           </div>
-          <!-- 优惠券数量 -->
+          <!-- 有效期 -->
           <div class="detail-item">
-            <div class="detail-label">优惠券数量</div>
+            <div class="detail-label">有效期</div>
             <div class="detail-value">
-              {{ couponModel.singleQty || "--" }}
+              {{ couponModel.validityPeriod || couponModel.endDate || "--" }}
             </div>
           </div>
-          <!-- 最低消费金额 -->
+          <!-- 最低消费金额(保留原有) -->
           <div class="detail-item">
             <div class="detail-label">最低消费金额</div>
             <div class="detail-value">
@@ -60,56 +74,6 @@
             </div>
           </div>
         </div>
-        <!-- 好友信息模块 -->
-        <div class="model">
-          <h3 style="font-weight: bold">好友信息:</h3>
-          <!-- 好友名称 -->
-          <div class="detail-item">
-            <div class="detail-label">
-              {{ type === "friendMessage" ? "赠送人" : "接收人" }}
-            </div>
-            <div class="detail-value">
-              {{ couponModel.acName || "--" }}
-            </div>
-          </div>
-          <!-- 状态 -->
-          <div class="detail-item" v-if="type === 'myGift' && couponModel.status !== undefined">
-            <div class="detail-label">状态</div>
-            <div class="detail-value">
-              {{ getStatusText() }}
-            </div>
-          </div>
-        </div>
-      </div>
-      <!-- 右侧内容区域 -->
-      <div class="contentRight">
-        <!-- 优惠券详细列表 -->
-        <div
-          class="model"
-          v-if="couponModel.lifeDiscountCouponFriendRuleDetailVos && couponModel.lifeDiscountCouponFriendRuleDetailVos.length > 0"
-        >
-          <h3 style="font-weight: bold">优惠券详细列表:</h3>
-          <div v-for="(detail, index) in couponModel.lifeDiscountCouponFriendRuleDetailVos" :key="index" class="detail-card">
-            <div class="detail-item">
-              <div class="detail-label">店铺名称</div>
-              <div class="detail-value">
-                {{ detail.storeName || "--" }}
-              </div>
-            </div>
-            <div class="detail-item">
-              <div class="detail-label">优惠券名称</div>
-              <div class="detail-value">
-                {{ detail.couponName || "--" }}
-              </div>
-            </div>
-            <div class="detail-item">
-              <div class="detail-label">优惠券数量</div>
-              <div class="detail-value">
-                {{ detail.couponNum || "--" }}
-              </div>
-            </div>
-          </div>
-        </div>
       </div>
     </div>
   </div>
@@ -238,6 +202,14 @@ const loadDetailData = async () => {
 };
 
 /**
+ * 获取优惠券类型文案
+ */
+const getCouponTypeText = (type: number | string | undefined) => {
+  const typeMap: Record<string, string> = { "1": "折扣券", "2": "满减券" };
+  return type != null ? (typeMap[String(type)] ?? String(type)) : "--";
+};
+
+/**
  * 获取状态文本
  */
 const getStatusText = () => {