Skip to content

Commit 815897c

Browse files
committed
商城:优惠劵的前端完善
1 parent 98477ef commit 815897c

File tree

3 files changed

+436
-417
lines changed

3 files changed

+436
-417
lines changed

src/views/mall/promotion/coupon/index.vue

Lines changed: 35 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,19 @@
11
<template>
22
<doc-alert title="功能开启" url="https://doc.iocoder.cn/mall/build/" />
33

4+
<!-- 搜索工作栏 -->
45
<ContentWrap>
5-
<!-- 搜索工作栏 -->
6-
<el-form :model="queryParams" ref="queryFormRef" :inline="true" label-width="68px">
6+
<el-form
7+
ref="queryFormRef"
8+
:inline="true"
9+
:model="queryParams"
10+
class="-mb-15px"
11+
label-width="68px"
12+
>
713
<el-form-item label="会员昵称" prop="nickname">
814
<el-input
915
v-model="queryParams.nickname"
16+
class="!w-240px"
1017
placeholder="请输入会员昵称"
1118
clearable
1219
@keyup="handleQuery"
@@ -15,13 +22,12 @@
1522
<el-form-item label="创建时间" prop="createTime">
1623
<el-date-picker
1724
v-model="queryParams.createTime"
18-
style="width: 240px"
19-
type="datetimerange"
2025
value-format="YYYY-MM-DD HH:mm:ss"
21-
range-separator="-"
26+
type="daterange"
2227
start-placeholder="开始日期"
2328
end-placeholder="结束日期"
24-
:default-time="[new Date(2000, 1, 1, 0, 0, 0), new Date(2000, 2, 1, 23, 59, 59)]"
29+
:default-time="[new Date('1 00:00:00'), new Date('1 23:59:59')]"
30+
class="!w-240px"
2531
/>
2632
</el-form-item>
2733
<el-form-item>
@@ -31,11 +37,6 @@
3137
<el-button @click="resetQuery"> <Icon icon="ep:refresh" class="mr-5px" />重置 </el-button>
3238
</el-form-item>
3339
</el-form>
34-
35-
<!-- 操作工具栏 -->
36-
<!-- <el-row :gutter="10" class="mb8">
37-
<right-toolbar v-model:showSearch="showSearch" @queryTable="getList" />
38-
</el-row> -->
3940
</ContentWrap>
4041

4142
<ContentWrap>
@@ -86,23 +87,21 @@
8687
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
8788
<template #default="scope">
8889
<el-button
89-
size="small"
90-
type="primary"
91-
link
92-
@click="handleDelete(scope.row)"
9390
v-hasPermi="['promotion:coupon:delete']"
94-
><Icon icon="ep:delete" :size="12" class="mr-1px" />回收</el-button
91+
type="danger"
92+
link
93+
@click="handleDelete(scope.row.id)"
9594
>
95+
回收
96+
</el-button>
9697
</template>
9798
</el-table-column>
9899
</el-table>
99-
100-
<!-- 分页组件 -->
101-
<pagination
102-
v-show="total > 0"
103-
:total="total"
104-
v-model:page="queryParams.pageNo"
100+
<!-- 分页 -->
101+
<Pagination
105102
v-model:limit="queryParams.pageSize"
103+
v-model:page="queryParams.pageNo"
104+
:total="total"
106105
@pagination="getList"
107106
/>
108107
</ContentWrap>
@@ -112,36 +111,31 @@
112111
import { deleteCoupon, getCouponPage } from '@/api/mall/promotion/coupon'
113112
import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
114113
import { dateFormatter } from '@/utils/formatTime'
115-
import { FormInstance } from 'element-plus'
116114
117-
// 消息弹窗
118-
const message = useMessage()
115+
defineOptions({ name: 'PromotionCoupon' })
116+
117+
const message = useMessage() // 消息弹窗
119118
120-
// 遮罩层
121-
const loading = ref(true)
122-
// 总条数
123-
const total = ref(0)
124-
// 优惠劵列表
125-
const list = ref([])
119+
const loading = ref(true) // 列表的加载中
120+
const total = ref(0) // 列表的总页数
121+
const list = ref([]) // 字典表格数据
126122
// 查询参数
127123
const queryParams = reactive({
128124
pageNo: 1,
129125
pageSize: 10,
130126
createTime: [],
131127
status: undefined
132128
})
133-
// Tab 筛选
134-
const activeTab = ref('all')
129+
const queryFormRef = ref() // 搜索的表单
135130
131+
const activeTab = ref('all') // Tab 筛选
136132
const statusTabs = reactive([
137133
{
138134
label: '全部',
139135
value: 'all'
140136
}
141137
])
142138
143-
const queryFormRef = ref<FormInstance | null>(null)
144-
145139
/** 查询列表 */
146140
const getList = async () => {
147141
loading.value = true
@@ -168,16 +162,17 @@ const resetQuery = () => {
168162
}
169163
170164
/** 删除按钮操作 */
171-
const handleDelete = async (row) => {
172-
const id = row.id
173-
165+
const handleDelete = async (id: number) => {
174166
try {
167+
// 二次确认
175168
await message.confirm(
176169
'回收将会收回会员领取的待使用的优惠券,已使用的将无法回收,确定要回收所选优惠券吗?'
177170
)
171+
// 发起删除
178172
await deleteCoupon(id)
179-
getList()
180173
message.notifySuccess('回收成功')
174+
// 重新加载列表
175+
await getList()
181176
} catch {}
182177
}
183178
@@ -187,6 +182,7 @@ const onTabChange = (tabName) => {
187182
getList()
188183
}
189184
185+
/** 初始化 **/
190186
onMounted(() => {
191187
getList()
192188
// 设置 statuses 过滤

0 commit comments

Comments
 (0)