瀏覽代碼

feat: 优化优惠券列表和详情显示

laiqi 11 月之前
父節點
當前提交
e6cda15f11

+ 95 - 18
apps/web-ele/src/api/coupon/coupon2.ts

@@ -1,6 +1,6 @@
 import type { Coupon2Entity, PageConfig } from '@vben/types';
 
-import { parseQueryValues } from '@vben/utils';
+import dayjs from 'dayjs';
 
 import { requestClient } from '#/api/request';
 
@@ -9,7 +9,15 @@ interface Coupon2PartialEntity
   coupon2code?: string;
 }
 
-interface Coupon2QueryParams extends Coupon2PartialEntity, PageConfig {}
+interface Coupon2QueryParams
+  extends Omit<Coupon2PartialEntity, 'coupon2adddatetime'>,
+    PageConfig {
+  couponmc?: string;
+  productsname?: string;
+  productsmodel?: string;
+  productsjjlx?: string;
+  coupon2adddatetime?: string[];
+}
 
 /**
  * 我的优惠券信息_列表
@@ -18,7 +26,6 @@ export async function getCoupon2ListApi(data: Coupon2QueryParams) {
   return requestClient.post<any>('/api/query/list?pagevalue=101', {
     pageindex: data.pageindex,
     rows: data.rows,
-    ...parseQueryValues(data),
   });
 }
 
@@ -29,7 +36,7 @@ export async function getCoupon2DetailApi(data: { coupon2sid: string }) {
   return requestClient.post<any>(
     '/api/query/view?pagevalue=102',
     {
-      ...parseQueryValues(data),
+      'coupon2sid.value': data.coupon2sid,
     },
     { formatData: true }, // 格式化返回数据
   );
@@ -53,34 +60,104 @@ export async function editCoupon2Api(data: Coupon2Entity) {
  * 我的优惠券_审核_列表(用于admin)
  */
 export async function getCoupon2AuditListApi(data: Coupon2QueryParams) {
-  return requestClient.post<any>('/api/query/list?pagevalue=117', {
-    pageindex: data.pageindex,
-    rows: data.rows,
-    ...parseQueryValues(data),
-    'coupon2adddatetime.sort': 1,
-  });
+  const {
+    pageindex,
+    rows,
+    couponmc,
+    coupon2sype,
+    productsname,
+    productsmodel,
+    productsjjlx,
+    coupon2adddatetime,
+  } = data;
+  const queryParams: Record<string, any> = {
+    pageindex,
+    rows,
+  };
+
+  if (couponmc) {
+    queryParams['coupon2mc.like'] = couponmc;
+  }
+  if (coupon2sype !== undefined && coupon2sype !== null) {
+    queryParams['coupon2sype.value'] = coupon2sype;
+  }
+  if (productsname) {
+    queryParams['productsname.like'] = productsname;
+  }
+  if (productsmodel) {
+    queryParams['productsmodel.like'] = productsmodel;
+  }
+  if (productsjjlx) {
+    queryParams['productsjjlx.like'] = productsjjlx;
+  }
+
+  if (coupon2adddatetime && coupon2adddatetime.length > 0) {
+    queryParams['coupon2adddatetime.start'] = dayjs(coupon2adddatetime[0])
+      .startOf('day')
+      .format('YYYY-MM-DD HH:mm:ss');
+    queryParams['coupon2adddatetime.end'] = dayjs(coupon2adddatetime[1])
+      .endOf('day')
+      .format('YYYY-MM-DD HH:mm:ss');
+  }
+  queryParams['coupon2adddatetime.sort'] = 1;
+  return requestClient.post<any>('/api/query/list?pagevalue=117', queryParams);
 }
 
 /**
  * 我的优惠券_编辑_列表(用于经销商查询优惠劵列表)
  */
 export async function getCoupon2EditListApi(data: Coupon2QueryParams) {
-  return requestClient.post<any>('/api/query/list?pagevalue=120', {
-    pageindex: data.pageindex,
-    rows: data.rows,
-    ...parseQueryValues(data),
-    'coupon2adddatetime.sort': 1,
-  });
+  const {
+    pageindex,
+    rows,
+    couponmc,
+    coupon2sype,
+    productsname,
+    productsmodel,
+    productsjjlx,
+    coupon2adddatetime,
+  } = data;
+  const queryParams: Record<string, any> = {
+    pageindex,
+    rows,
+  };
+
+  if (couponmc) {
+    queryParams['coupon2mc.like'] = couponmc;
+  }
+  if (coupon2sype !== undefined && coupon2sype !== null) {
+    queryParams['coupon2sype.value'] = coupon2sype;
+  }
+  if (productsname) {
+    queryParams['productsname.like'] = productsname;
+  }
+  if (productsmodel) {
+    queryParams['productsmodel.like'] = productsmodel;
+  }
+  if (productsjjlx) {
+    queryParams['productsjjlx.like'] = productsjjlx;
+  }
+
+  if (coupon2adddatetime && coupon2adddatetime.length > 0) {
+    queryParams['coupon2adddatetime.start'] = dayjs(coupon2adddatetime[0])
+      .startOf('day')
+      .format('YYYY-MM-DD HH:mm:ss');
+    queryParams['coupon2adddatetime.end'] = dayjs(coupon2adddatetime[1])
+      .endOf('day')
+      .format('YYYY-MM-DD HH:mm:ss');
+  }
+  queryParams['coupon2adddatetime.sort'] = 1;
+  return requestClient.post<any>('/api/query/list?pagevalue=120', queryParams);
 }
 
 /**
  * 我的优惠券_审核_详情
  */
-export async function getCoupon2AuditDetailApi(data: any) {
+export async function getCoupon2AuditDetailApi(data: { coupon2sid: string }) {
   return requestClient.post<any>(
     '/api/query/view?pagevalue=118',
     {
-      ...parseQueryValues(data),
+      'coupon2sid.value': data.coupon2sid,
     },
     { formatData: true },
   );

+ 25 - 2
apps/web-ele/src/views/examine-manage/examine-coupon/detail.vue

@@ -1,5 +1,5 @@
 <script lang="ts" setup>
-import { computed, ref } from 'vue';
+import { computed, ref, watch } from 'vue';
 
 import { useVbenModal } from '@vben/common-ui';
 
@@ -8,11 +8,34 @@ import { ElButton, ElImage, ElTag } from 'element-plus';
 import { getCoupon2AuditDetailApi } from '#/api/coupon/coupon2';
 import { getDictListApi } from '#/api/dict';
 import { getAttachmentListApi } from '#/api/file';
+import { getCustomerDetailApi } from '#/api/user';
 
 import EditBuyerInfoModal from './edit-buyer-info-modal.vue';
 
 const data = ref<any>(null);
 const loading = ref(false);
+const dealerName = ref('');
+
+// 监听data的变化,当data有值且userssuperiorid存在时,获取经销商名称
+watch(
+  () => data.value,
+  async (newData) => {
+    if (newData && newData.userssuperiorid) {
+      try {
+        const res = await getCustomerDetailApi({
+          usersid: newData.userssuperiorid,
+        });
+        dealerName.value = res.usersname || '未知';
+      } catch (error) {
+        console.error('获取经销商名称失败:', error);
+        dealerName.value = '获取失败';
+      }
+    } else {
+      dealerName.value = '';
+    }
+  },
+  { deep: true },
+);
 
 // 身份证附件数据
 const certificateDataList = ref<any[]>([]);
@@ -154,7 +177,7 @@ const couponInfo = computed(() => {
     //     : '',
     // },
     // { label: '下单时间', value: data.value.ordersorderdate },
-    // { label: '经销商名称', value: data.value.jxsname },
+    { label: '经销商名称', value: dealerName.value },
   ];
 
   // 如果优惠券状态为2(审核不通过),显示审核备注

+ 48 - 3
apps/web-ele/src/views/examine-manage/examine-coupon/index.vue

@@ -61,6 +61,44 @@ const formOptions: VbenFormProps = {
       },
       defaultValue: 0,
     },
+    {
+      component: 'DatePicker',
+      fieldName: 'coupon2adddatetime',
+      label: '申请时间',
+      componentProps: {
+        type: 'daterange',
+        valueFormat: 'YYYY-MM-DD HH:mm:ss',
+        // placeholder: ['开始时间', '结束时间'],
+        // style: 'width:100%',
+      },
+    },
+    {
+      component: 'Input',
+      fieldName: 'productsname',
+      label: '产品名称',
+      componentProps: {
+        placeholder: $t('ui.placeholder.input'),
+        allowClear: true,
+      },
+    },
+    {
+      component: 'Input',
+      fieldName: 'productsmodel',
+      label: '产品型号',
+      componentProps: {
+        placeholder: $t('ui.placeholder.input'),
+        allowClear: true,
+      },
+    },
+    {
+      component: 'Input',
+      fieldName: 'productsjjlx',
+      label: '机具类型',
+      componentProps: {
+        placeholder: $t('ui.placeholder.input'),
+        allowClear: true,
+      },
+    },
   ],
   wrapperClass: 'grid-cols-1 md:grid-cols-3 lg:grid-cols-5',
 };
@@ -103,11 +141,16 @@ const gridOptions: VxeGridProps<any> = {
   },
 
   columns: [
-    { title: '优惠券ID', field: 'coupon2sid', sortable: true },
-    { title: '优惠券代码', field: 'coupon2code', sortable: true },
+    { title: '序号', type: 'seq', width: 50 },
+    // { title: '优惠券ID', field: 'coupon2sid', sortable: true },
+    // { title: '优惠券代码', field: 'coupon2code', sortable: true },
+    { title: '产品名称', field: 'productsname', sortable: true },
+    { title: '产品型号', field: 'productsmodel', sortable: true },
+    { title: '机具类型', field: 'productsjjlx', sortable: true },
+    { title: '生产企业', field: 'scqyinfomc', sortable: true },
     { title: '优惠券名称', field: 'coupon2mc', sortable: true },
     { title: '可用产品', field: 'productsname', sortable: true },
-    { title: '购机者', field: 'usersname', sortable: true },
+    { title: '购机者', field: 'usersname', sortable: true, width: 140 },
     {
       title: '优惠券状态',
       field: 'coupon2sype',
@@ -127,6 +170,7 @@ const gridOptions: VxeGridProps<any> = {
           );
         },
       },
+      width: 150,
     },
     {
       title: '使用状态',
@@ -146,6 +190,7 @@ const gridOptions: VxeGridProps<any> = {
           );
         },
       },
+      width: 160,
     },
     { title: '申请时间', field: 'coupon2adddatetime', sortable: true },
     { title: '审核时间', field: 'coupon2reviewdatetime', sortable: true },