|
@@ -13,6 +13,7 @@ import { ElMessage, ElMessageBox, ElTag } from 'element-plus';
|
|
|
|
|
|
|
|
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
|
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
|
|
import {
|
|
import {
|
|
|
|
|
+ auditCoupon2Api,
|
|
|
getCoupon2AuditListApi,
|
|
getCoupon2AuditListApi,
|
|
|
getCoupon2EditListApi,
|
|
getCoupon2EditListApi,
|
|
|
} from '#/api/coupon/coupon2';
|
|
} from '#/api/coupon/coupon2';
|
|
@@ -168,6 +169,7 @@ const gridOptions: VxeGridProps<any> = {
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
columns: [
|
|
columns: [
|
|
|
|
|
+ { type: 'checkbox', width: 60 },
|
|
|
{ title: '序号', type: 'seq', width: 50 },
|
|
{ title: '序号', type: 'seq', width: 50 },
|
|
|
// { title: '优惠券ID', field: 'coupon2sid', sortable: true },
|
|
// { title: '优惠券ID', field: 'coupon2sid', sortable: true },
|
|
|
{ title: '优惠券代码', field: 'coupon2code', sortable: true },
|
|
{ title: '优惠券代码', field: 'coupon2code', sortable: true },
|
|
@@ -247,6 +249,66 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
|
|
const auditFormRef = ref<any>(null);
|
|
const auditFormRef = ref<any>(null);
|
|
|
const detailFormRef = ref<any>(null);
|
|
const detailFormRef = ref<any>(null);
|
|
|
|
|
|
|
|
|
|
+/* 批量审核 */
|
|
|
|
|
+const batchAuditVisible = ref(false);
|
|
|
|
|
+const batchAuditLoading = ref(false);
|
|
|
|
|
+const batchAuditForm = ref({ coupon2sype: 1, coupon2shbz: '' });
|
|
|
|
|
+
|
|
|
|
|
+/** 打开批量审核弹窗,校验选中行必须为"申请中"状态 */
|
|
|
|
|
+function handleBatchAudit() {
|
|
|
|
|
+ const records = gridApi.grid.getCheckboxRecords();
|
|
|
|
|
+ if (!records || records.length === 0) {
|
|
|
|
|
+ ElMessage.warning('请先选择需要审核的优惠券');
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ // 检查是否有非"申请中"状态的行
|
|
|
|
|
+ const invalidRows = records.filter((row: any) => row.coupon2sype !== 0);
|
|
|
|
|
+ if (invalidRows.length > 0) {
|
|
|
|
|
+ ElMessage.warning('所选优惠券中包含非"申请中"状态的记录,请重新选择');
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ batchAuditForm.value = { coupon2sype: 1, coupon2shbz: '' };
|
|
|
|
|
+ batchAuditVisible.value = true;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+/** 批量提交审核,并发调用 /api/up?pagevalue=104 接口 */
|
|
|
|
|
+async function handleBatchAuditSubmit() {
|
|
|
|
|
+ const records = gridApi.grid.getCheckboxRecords();
|
|
|
|
|
+ if (!records || records.length === 0) return;
|
|
|
|
|
+
|
|
|
|
|
+ const { coupon2sype, coupon2shbz } = batchAuditForm.value;
|
|
|
|
|
+ if (coupon2sype === 2 && !coupon2shbz) {
|
|
|
|
|
+ ElMessage.warning('审核不通过时,审核备注不能为空');
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ batchAuditLoading.value = true;
|
|
|
|
|
+ try {
|
|
|
|
|
+ const promises = records.map((row: any) =>
|
|
|
|
|
+ // console.log('批量审核参数', {
|
|
|
|
|
+ // coupon2sid: row.coupon2sid,
|
|
|
|
|
+ // coupon2sype,
|
|
|
|
|
+ // coupon2shbz,
|
|
|
|
|
+ // }),
|
|
|
|
|
+ auditCoupon2Api({
|
|
|
|
|
+ 'coupon2sid.value': row.coupon2sid,
|
|
|
|
|
+ coupon2sype,
|
|
|
|
|
+ coupon2shbz,
|
|
|
|
|
+ } as any),
|
|
|
|
|
+ );
|
|
|
|
|
+ await Promise.all(promises);
|
|
|
|
|
+ ElMessage.success(`批量审核成功,共处理 ${records.length} 条记录`);
|
|
|
|
|
+ batchAuditVisible.value = false;
|
|
|
|
|
+ gridApi.grid.clearCheckboxRow();
|
|
|
|
|
+ gridApi.reload();
|
|
|
|
|
+ } catch (error) {
|
|
|
|
|
+ console.error('批量审核失败', error);
|
|
|
|
|
+ ElMessage.error('批量审核失败,请重试');
|
|
|
|
|
+ } finally {
|
|
|
|
|
+ batchAuditLoading.value = false;
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
/* 详情 */
|
|
/* 详情 */
|
|
|
function handleDetail(row: any) {
|
|
function handleDetail(row: any) {
|
|
|
detailFormRef.value?.openDetailModal(row);
|
|
detailFormRef.value?.openDetailModal(row);
|
|
@@ -315,6 +377,13 @@ function handleOrderSuccess({ orderId }: { orderId: string }) {
|
|
|
<Grid table-title="优惠券列表">
|
|
<Grid table-title="优惠券列表">
|
|
|
<template #toolbar-tools>
|
|
<template #toolbar-tools>
|
|
|
<el-button type="primary" @click="handleCreate"> 领取优惠劵 </el-button>
|
|
<el-button type="primary" @click="handleCreate"> 领取优惠劵 </el-button>
|
|
|
|
|
+ <el-button
|
|
|
|
|
+ type="warning"
|
|
|
|
|
+ @click="handleBatchAudit"
|
|
|
|
|
+ v-if="userStore.isSuperAdmin"
|
|
|
|
|
+ >
|
|
|
|
|
+ 批量审核
|
|
|
|
|
+ </el-button>
|
|
|
</template>
|
|
</template>
|
|
|
<template #action="{ row }">
|
|
<template #action="{ row }">
|
|
|
<el-tooltip
|
|
<el-tooltip
|
|
@@ -381,5 +450,40 @@ function handleOrderSuccess({ orderId }: { orderId: string }) {
|
|
|
@finish="handleReceiveSuccess"
|
|
@finish="handleReceiveSuccess"
|
|
|
/>
|
|
/>
|
|
|
<OrderCouponForm ref="orderCouponFormRef" @finish="handleOrderSuccess" />
|
|
<OrderCouponForm ref="orderCouponFormRef" @finish="handleOrderSuccess" />
|
|
|
|
|
+
|
|
|
|
|
+ <!-- 批量审核弹窗 -->
|
|
|
|
|
+ <el-dialog
|
|
|
|
|
+ v-model="batchAuditVisible"
|
|
|
|
|
+ title="批量审核"
|
|
|
|
|
+ width="500px"
|
|
|
|
|
+ :close-on-click-modal="false"
|
|
|
|
|
+ >
|
|
|
|
|
+ <el-form label-width="100px">
|
|
|
|
|
+ <el-form-item label="审核状态">
|
|
|
|
|
+ <el-radio-group v-model="batchAuditForm.coupon2sype">
|
|
|
|
|
+ <el-radio :value="1">审核通过</el-radio>
|
|
|
|
|
+ <el-radio :value="2">审核不通过</el-radio>
|
|
|
|
|
+ </el-radio-group>
|
|
|
|
|
+ </el-form-item>
|
|
|
|
|
+ <el-form-item label="审核备注" v-if="batchAuditForm.coupon2sype === 2">
|
|
|
|
|
+ <el-input
|
|
|
|
|
+ v-model="batchAuditForm.coupon2shbz"
|
|
|
|
|
+ type="textarea"
|
|
|
|
|
+ :rows="3"
|
|
|
|
|
+ placeholder="请输入审核备注"
|
|
|
|
|
+ />
|
|
|
|
|
+ </el-form-item>
|
|
|
|
|
+ </el-form>
|
|
|
|
|
+ <template #footer>
|
|
|
|
|
+ <el-button @click="batchAuditVisible = false">取消</el-button>
|
|
|
|
|
+ <el-button
|
|
|
|
|
+ type="primary"
|
|
|
|
|
+ :loading="batchAuditLoading"
|
|
|
|
|
+ @click="handleBatchAuditSubmit"
|
|
|
|
|
+ >
|
|
|
|
|
+ 确定
|
|
|
|
|
+ </el-button>
|
|
|
|
|
+ </template>
|
|
|
|
|
+ </el-dialog>
|
|
|
</Page>
|
|
</Page>
|
|
|
</template>
|
|
</template>
|