From a1d7e81859f554f3a53680cc35f0f49bf1f77098 Mon Sep 17 00:00:00 2001
From: wwf <1971391498@qq.com>
Date: 星期四, 14 五月 2026 14:37:02 +0800
Subject: [PATCH] 导入项目
---
src/views/mall/promotion/coupon/components/CouponSendForm.vue | 162 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 162 insertions(+), 0 deletions(-)
diff --git a/src/views/mall/promotion/coupon/components/CouponSendForm.vue b/src/views/mall/promotion/coupon/components/CouponSendForm.vue
new file mode 100644
index 0000000..4b9edb7
--- /dev/null
+++ b/src/views/mall/promotion/coupon/components/CouponSendForm.vue
@@ -0,0 +1,162 @@
+<template>
+ <Dialog v-model="dialogVisible" :appendToBody="true" title="鍙戦�佷紭鎯犲埜" width="70%">
+ <!-- 鎼滅储宸ヤ綔鏍� -->
+ <el-form
+ ref="queryFormRef"
+ :inline="true"
+ :model="queryParams"
+ class="-mb-15px"
+ label-width="82px"
+ >
+ <el-form-item label="浼樻儬鍒稿悕绉�" prop="name">
+ <el-input
+ v-model="queryParams.name"
+ class="!w-240px"
+ placeholder="璇疯緭鍏ヤ紭鎯犲姷鍚�"
+ clearable
+ @keyup="handleQuery"
+ />
+ </el-form-item>
+ <el-form-item>
+ <el-button @click="handleQuery">
+ <Icon class="mr-5px" icon="ep:search" />
+ 鎼滅储
+ </el-button>
+ <el-button @click="resetQuery">
+ <Icon class="mr-5px" icon="ep:refresh" />
+ 閲嶇疆
+ </el-button>
+ </el-form-item>
+ </el-form>
+
+ <!-- 鍒楄〃 -->
+ <el-table v-loading="loading" :data="list" show-overflow-tooltip>
+ <el-table-column align="center" label="浼樻儬鍒稿悕绉�" prop="name" min-width="60" />
+ <el-table-column
+ label="浼樻儬閲戦 / 鎶樻墸"
+ align="center"
+ prop="discount"
+ :formatter="discountFormat"
+ min-width="60"
+ />
+ <el-table-column
+ align="center"
+ label="鏈�浣庢秷璐�"
+ prop="usePrice"
+ min-width="60"
+ :formatter="usePriceFormat"
+ />
+ <el-table-column
+ align="center"
+ label="鏈夋晥鏈熼檺"
+ prop="validityType"
+ min-width="140"
+ :formatter="validityTypeFormat"
+ />
+ <el-table-column
+ align="center"
+ label="鍓╀綑鏁伴噺"
+ min-width="60"
+ :formatter="remainedCountFormat"
+ />
+ <el-table-column label="鎿嶄綔" align="center" min-width="60px" fixed="right">
+ <template #default="scope">
+ <el-button
+ link
+ type="primary"
+ :disabled="sendLoading"
+ :loading="sendLoading"
+ @click="handleSendCoupon(scope.row.id)"
+ v-hasPermi="['promotion:coupon:send']"
+ >
+ 鍙戦��
+ </el-button>
+ </template>
+ </el-table-column>
+ </el-table>
+ <!-- 鍒嗛〉 -->
+ <Pagination
+ v-model:limit="queryParams.pageSize"
+ v-model:page="queryParams.pageNo"
+ :total="total"
+ @pagination="getList"
+ />
+ <div class="clear-both"></div>
+ </Dialog>
+</template>
+<script lang="ts" setup>
+import * as CouponTemplateApi from '@/api/mall/promotion/coupon/couponTemplate'
+import * as CouponApi from '@/api/mall/promotion/coupon/coupon'
+import {
+ discountFormat,
+ remainedCountFormat,
+ usePriceFormat,
+ validityTypeFormat
+} from '@/views/mall/promotion/coupon/formatter'
+import { CouponTemplateTakeTypeEnum } from '@/utils/constants'
+
+defineOptions({ name: 'PromotionCouponSendForm' })
+
+const message = useMessage() // 娑堟伅寮圭獥
+const total = ref(0) // 鍒楄〃鐨勬�婚〉鏁�
+const list = ref<any[]>([]) // 鍒楄〃鐨勬暟鎹�
+const loading = ref(false) // 鍒楄〃鐨勫姞杞戒腑
+const sendLoading = ref(false) // 鍙戦�佹寜閽殑鍔犺浇涓�
+const dialogVisible = ref(false) // 寮圭獥鐨勬槸鍚﹀睍绀�
+const queryParams = ref({
+ pageNo: 1,
+ pageSize: 10,
+ name: null,
+ canTakeTypes: [CouponTemplateTakeTypeEnum.ADMIN.type]
+}) // 鏌ヨ鍙傛暟
+const queryFormRef = ref() // 鎼滅储鐨勮〃鍗�
+// 棰嗗彇浜虹殑缂栧彿鍒楄〃
+let userIds: number[] = []
+
+/** 鎵撳紑寮圭獥 */
+const open = (ids: number[]) => {
+ userIds = ids
+ // 鎵撳紑鏃堕噸缃煡璇紝闃叉鍙戦�佸垪琛ㄥ墿浣欐暟閲忔湭鏇存柊鐨勯棶棰�
+ resetQuery()
+
+ dialogVisible.value = true
+}
+defineExpose({ open }) // 鎻愪緵 open 鏂规硶锛岀敤浜庢墦寮�寮圭獥
+
+/** 鏌ヨ鍒楄〃 */
+const getList = async () => {
+ loading.value = true
+ try {
+ const data = await CouponTemplateApi.getCouponTemplatePage(queryParams.value)
+ list.value = data.list
+ total.value = data.total
+ } finally {
+ loading.value = false
+ }
+}
+
+/** 鎼滅储鎸夐挳鎿嶄綔 */
+const handleQuery = () => {
+ queryParams.value.pageNo = 1
+ getList()
+}
+
+/** 閲嶇疆鎸夐挳鎿嶄綔 */
+const resetQuery = () => {
+ queryFormRef?.value?.resetFields()
+ handleQuery()
+}
+
+/** 鍙戦�佹搷浣� **/
+const handleSendCoupon = async (templateId: number) => {
+ try {
+ sendLoading.value = true
+ await CouponApi.sendCoupon({ templateId, userIds })
+ // 鎻愮ず
+ message.success('鍙戦�佹垚鍔�')
+ dialogVisible.value = false
+ } finally {
+ sendLoading.value = false
+ }
+}
+</script>
--
Gitblit v1.8.0