董国庆
2026-03-14 36affb4161b9edf7aa3a5e2a0f5b64381ca69aa8
修改
2个文件已修改
28 ■■■■■ 已修改文件
src/views/userContent/active/coupon/BatchSendModal.vue 20 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/userContent/active/coupon/index.vue 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/userContent/active/coupon/BatchSendModal.vue
@@ -1,7 +1,7 @@
<script setup lang="tsx">
import { ref, computed, watch } from 'vue'
import type { DataTableColumns } from 'naive-ui'
import { NTag } from 'naive-ui'
import { NTag, useMessage } from 'naive-ui'
import { fetchWhitelistPageList } from '@/service/api/whitelist'
interface Props {
@@ -10,12 +10,13 @@
interface Emits {
  (e: 'update:show', value: boolean): void
  (e: 'send-all'): void
  (e: 'send-all', payload: { userCount: number }): void
  (e: 'send-selected', rows: any[]): void
}
const props = defineProps<Props>()
const emits = defineEmits<Emits>()
const message = useMessage()
const showModal = computed({
  get: () => props.show,
@@ -62,6 +63,8 @@
const pageSize = ref(10)
const total = ref(0)
const isNormalStatus = (status: unknown) => status === 1 || status === true
const columns: DataTableColumns<any> = [
  { type: 'selection' },
  { title: '序号', key: 'id', width: 80, align: 'center', render: (_, index) => (currentPage.value - 1) * pageSize.value + index + 1 },
@@ -72,7 +75,7 @@
    key: 'status',
    width: 100,
    render(row) {
      const isNormal = row.status === 1 || row.status === true
      const isNormal = isNormalStatus(row.status)
      return (
        <NTag type={isNormal ? 'info' : 'warning'} size="small" bordered={false} style={{ color: isNormal ? '#1890FF' : '#FAAD14', backgroundColor: isNormal ? '#E6F7FF' : '#FFFBE6' }}>
          {isNormal ? '正常' : '冻结'}
@@ -129,12 +132,21 @@
}
const handleSendAll = () => {
  emits('send-all')
  if (!isNormalStatus(searchModel.value.status)) {
    message.warning('一键发放所有用户仅支持“冻结状态”筛选为“正常”')
    return
  }
  emits('send-all', { userCount: total.value })
  showModal.value = false
}
const handleSendSelected = () => {
  const selectedRows = list.value.filter((item) => checkedRowKeys.value.includes(item.id))
  const hasFrozen = selectedRows.some(row => !isNormalStatus(row.status))
  if (hasFrozen) {
    message.warning('选中用户包含冻结状态,请仅选择“正常”用户')
    return
  }
  emits('send-selected', selectedRows)
  showModal.value = false
}
src/views/userContent/active/coupon/index.vue
@@ -75,12 +75,12 @@
  })
}
const handleBatchSendAll = () => {
const handleBatchSendAll = (payload: { userCount: number }) => {
  if (currentCouponId.value === null || currentCouponId.value === undefined || currentCouponId.value === '') return
  
  dialog.warning({
    title: '确认发放',
    content: '确定要给所有用户发放该优惠券吗?',
    content: `确定向当前筛选条件下所有用户发放优惠券么?共${payload.userCount}个用户。`,
    positiveText: '确定',
    negativeText: '取消',
    onPositiveClick: async () => {
@@ -90,7 +90,7 @@
          phone: []
        })
        if (code === 200) {
          message.success('发放成功')
          message.success(`成功向${payload.userCount}个用户发放优惠券`)
          showBatchSendModal.value = false
        }
      } catch (e) {
@@ -116,7 +116,7 @@
          phone: rows.map(r => r.account) // Assuming 'account' is the phone number field
        })
        if (code === 200) {
          message.success('发放成功')
          message.success(`成功向${rows.length}个用户发放优惠券`)
          showBatchSendModal.value = false
        }
      } catch (e) {