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/discountActivity/index.vue | 239 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 239 insertions(+), 0 deletions(-)
diff --git a/src/views/mall/promotion/discountActivity/index.vue b/src/views/mall/promotion/discountActivity/index.vue
new file mode 100644
index 0000000..1841603
--- /dev/null
+++ b/src/views/mall/promotion/discountActivity/index.vue
@@ -0,0 +1,239 @@
+<template>
+ <doc-alert title="銆愯惀閿�銆戦檺鏃舵姌鎵�" url="https://doc.iocoder.cn/mall/promotion-discount/" />
+
+ <ContentWrap>
+ <!-- 鎼滅储宸ヤ綔鏍� -->
+ <el-form
+ class="-mb-15px"
+ :model="queryParams"
+ ref="queryFormRef"
+ :inline="true"
+ label-width="68px"
+ >
+ <el-form-item label="娲诲姩鍚嶇О" prop="name">
+ <el-input
+ v-model="queryParams.name"
+ placeholder="璇疯緭鍏ユ椿鍔ㄥ悕绉�"
+ clearable
+ @keyup.enter="handleQuery"
+ class="!w-240px"
+ />
+ </el-form-item>
+ <el-form-item label="娲诲姩鐘舵��" prop="status">
+ <el-select
+ v-model="queryParams.status"
+ placeholder="璇烽�夋嫨娲诲姩鐘舵��"
+ clearable
+ class="!w-240px"
+ >
+ <el-option
+ v-for="dict in getIntDictOptions(DICT_TYPE.COMMON_STATUS)"
+ :key="dict.value"
+ :label="dict.label"
+ :value="dict.value"
+ />
+ </el-select>
+ </el-form-item>
+ <el-form-item label="娲诲姩鏃堕棿" prop="activeTime">
+ <el-date-picker
+ v-model="queryParams.activeTime"
+ value-format="YYYY-MM-DD HH:mm:ss"
+ type="daterange"
+ start-placeholder="寮�濮嬫棩鏈�"
+ end-placeholder="缁撴潫鏃ユ湡"
+ :default-time="[new Date('1 00:00:00'), new Date('1 23:59:59')]"
+ class="!w-240px"
+ />
+ </el-form-item>
+ <el-form-item>
+ <el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" /> 鎼滅储</el-button>
+ <el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 閲嶇疆</el-button>
+ <el-button
+ type="primary"
+ plain
+ @click="openForm('create')"
+ v-hasPermi="['promotion:discount-activity:create']"
+ >
+ <Icon icon="ep:plus" class="mr-5px" /> 鏂板娲诲姩
+ </el-button>
+ </el-form-item>
+ </el-form>
+ </ContentWrap>
+ <!-- 鍒楄〃 -->
+ <ContentWrap>
+ <el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true">
+ <el-table-column label="娲诲姩缂栧彿" prop="id" min-width="80" />
+ <el-table-column label="娲诲姩鍚嶇О" prop="name" min-width="140" />
+ <el-table-column label="娲诲姩鏃堕棿" min-width="210">
+ <template #default="scope">
+ {{ formatDate(scope.row.startTime, 'YYYY-MM-DD') }}
+ ~ {{ formatDate(scope.row.endTime, 'YYYY-MM-DD') }}
+ </template>
+ </el-table-column>
+<!-- <el-table-column label="鍟嗗搧鍥剧墖" prop="spuName" min-width="80">-->
+<!-- <template #default="scope">-->
+<!-- <el-image-->
+<!-- :src="scope.row.picUrl"-->
+<!-- class="h-40px w-40px"-->
+<!-- :preview-src-list="[scope.row.picUrl]"-->
+<!-- preview-teleported-->
+<!-- />-->
+<!-- </template>-->
+<!-- </el-table-column>-->
+<!-- <el-table-column label="鍟嗗搧鏍囬" prop="spuName" min-width="300" />-->
+ <el-table-column label="娲诲姩鐘舵��" align="center" prop="status" min-width="100">
+ <template #default="scope">
+ <dict-tag :type="DICT_TYPE.COMMON_STATUS" :value="scope.row.status" />
+ </template>
+ </el-table-column>
+ <el-table-column
+ label="鍒涘缓鏃堕棿"
+ align="center"
+ prop="createTime"
+ :formatter="dateFormatter"
+ width="180px"
+ />
+ <el-table-column label="鎿嶄綔" align="center" width="150px" fixed="right">
+ <template #default="scope">
+ <el-button
+ link
+ type="primary"
+ @click="openForm('update', scope.row.id)"
+ v-hasPermi="['promotion:discount-activity:update']"
+ >
+ 缂栬緫
+ </el-button>
+ <el-button
+ link
+ type="danger"
+ @click="handleClose(scope.row.id)"
+ v-if="scope.row.status === 0"
+ v-hasPermi="['promotion:discount-activity:close']"
+ >
+ 鍏抽棴
+ </el-button>
+ <el-button
+ link
+ type="danger"
+ @click="handleDelete(scope.row.id)"
+ v-else
+ v-hasPermi="['promotion:discount-activity:delete']"
+ >
+ 鍒犻櫎
+ </el-button>
+ </template>
+ </el-table-column>
+ </el-table>
+ <!-- 鍒嗛〉 -->
+ <Pagination
+ :total="total"
+ v-model:page="queryParams.pageNo"
+ v-model:limit="queryParams.pageSize"
+ @pagination="getList"
+ />
+ </ContentWrap>
+ <!-- 琛ㄥ崟寮圭獥锛氭坊鍔�/淇敼 -->
+ <DiscountActivityForm ref="formRef" @success="getList" />
+</template>
+
+<script setup lang="ts">
+import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
+import { dateFormatter } from '@/utils/formatTime'
+import * as DiscountActivity from '@/api/mall/promotion/discount/discountActivity'
+import DiscountActivityForm from './DiscountActivityForm.vue'
+import { formatDate } from '@/utils/formatTime'
+import { fenToYuanFormat } from '@/utils/formatter'
+import { fenToYuan } from '@/utils'
+
+defineOptions({ name: 'DiscountActivity' })
+
+const message = useMessage() // 娑堟伅寮圭獥
+const { t } = useI18n() // 鍥介檯鍖�
+
+const loading = ref(true) // 鍒楄〃鐨勫姞杞戒腑
+const total = ref(0) // 鍒楄〃鐨勬�婚〉鏁�
+const list = ref([]) // 鍒楄〃鐨勬暟鎹�
+const queryParams = reactive({
+ pageNo: 1,
+ pageSize: 10,
+ activeTime: null,
+ name: null,
+ status: null
+})
+const queryFormRef = ref() // 鎼滅储鐨勮〃鍗�
+const exportLoading = ref(false) // 瀵煎嚭鐨勫姞杞戒腑
+
+/** 鏌ヨ鍒楄〃 */
+const getList = async () => {
+ loading.value = true
+ try {
+ const data = await DiscountActivity.getDiscountActivityPage(queryParams)
+ list.value = data.list
+ total.value = data.total
+ } finally {
+ loading.value = false
+ }
+}
+
+/** 鎼滅储鎸夐挳鎿嶄綔 */
+const handleQuery = () => {
+ queryParams.pageNo = 1
+ getList()
+}
+
+/** 閲嶇疆鎸夐挳鎿嶄綔 */
+const resetQuery = () => {
+ queryFormRef.value.resetFields()
+ handleQuery()
+}
+
+/** 娣诲姞/淇敼鎿嶄綔 */
+const formRef = ref()
+const openForm = (type: string, id?: number) => {
+ formRef.value.open(type, id)
+}
+
+/** 鍏抽棴鎸夐挳鎿嶄綔 */
+const handleClose = async (id: number) => {
+ try {
+ // 鍏抽棴鐨勪簩娆$‘璁�
+ await message.confirm('纭鍏抽棴璇ラ檺鏃舵姌鎵f椿鍔ㄥ悧锛�')
+ // 鍙戣捣鍏抽棴
+ await DiscountActivity.closeDiscountActivity(id)
+ message.success('鍏抽棴鎴愬姛')
+ // 鍒锋柊鍒楄〃
+ await getList()
+ } catch {}
+}
+
+/** 鍒犻櫎鎸夐挳鎿嶄綔 */
+const handleDelete = async (id: number) => {
+ try {
+ // 鍒犻櫎鐨勪簩娆$‘璁�
+ await message.delConfirm()
+ // 鍙戣捣鍒犻櫎
+ await DiscountActivity.deleteDiscountActivity(id)
+ message.success(t('common.delSuccess'))
+ // 鍒锋柊鍒楄〃
+ await getList()
+ } catch {}
+}
+
+const configList = ref([]) // 鏃舵閰嶇疆绮剧畝鍒楄〃
+// const formatConfigNames = (configId) => {
+// const config = configList.value.find((item) => item.id === configId)
+// return config != null ? `${config.name}[${config.startTime} ~ ${config.endTime}]` : ''
+// }
+
+const formatSeckillPrice = (products) => {
+ // const seckillPrice = Math.min(...products.map((item) => item.seckillPrice))
+ console.log(products)
+ const seckillPrice = 200
+ return `锟�${fenToYuan(seckillPrice)}`
+}
+
+/** 鍒濆鍖� **/
+onMounted(async () => {
+ await getList()
+})
+</script>
--
Gitblit v1.8.0