|
51 | 51 | <Icon class="mr-5px" icon="ep:refresh" />
|
52 | 52 | 重置
|
53 | 53 | </el-button>
|
54 |
| - <el-button v-hasPermi="['product:brand:create']" plain type="primary" @click="openForm"> |
| 54 | + <el-button v-hasPermi="['product:spu:create']" plain type="primary" @click="openForm"> |
55 | 55 | <Icon class="mr-5px" icon="ep:plus" />
|
56 | 56 | 新增
|
57 | 57 | </el-button>
|
58 | 58 | <!-- TODO @puhui999:增加一个【导出】操作 -->
|
| 59 | + <el-button |
| 60 | + v-hasPermi="['product:spu:export']" |
| 61 | + :loading="exportLoading" |
| 62 | + plain |
| 63 | + type="success" |
| 64 | + @click="handleExport" |
| 65 | + > |
| 66 | + <Icon class="mr-5px" icon="ep:download" /> |
| 67 | + 导出 |
| 68 | + </el-button> |
59 | 69 | </el-form-item>
|
60 | 70 | </el-form>
|
61 | 71 | </ContentWrap>
|
@@ -195,15 +205,17 @@ import { createImageViewer } from '@/components/ImageViewer'
|
195 | 205 | import { dateFormatter } from '@/utils/formatTime'
|
196 | 206 | import { defaultProps, handleTree } from '@/utils/tree'
|
197 | 207 | import { ProductSpuStatusEnum } from '@/utils/constants'
|
| 208 | +import { formatToFraction } from '@/utils' |
| 209 | +import download from '@/utils/download' |
198 | 210 | import * as ProductSpuApi from '@/api/mall/product/spu'
|
199 | 211 | import * as ProductCategoryApi from '@/api/mall/product/category'
|
200 |
| -import { formatToFraction } from '@/utils' |
201 | 212 |
|
202 | 213 | const message = useMessage() // 消息弹窗
|
203 | 214 | const { t } = useI18n() // 国际化
|
204 | 215 | const { currentRoute, push } = useRouter() // 路由跳转
|
205 | 216 |
|
206 | 217 | const loading = ref(false) // 列表的加载中
|
| 218 | +const exportLoading = ref(false) // 导出的加载中 |
207 | 219 | const total = ref(0) // 列表的总页数
|
208 | 220 | const list = ref<any[]>([]) // 列表的数据
|
209 | 221 | // tabs 数据
|
@@ -365,7 +377,22 @@ const openDetail = () => {
|
365 | 377 | message.alert('查看详情未完善!!!')
|
366 | 378 | }
|
367 | 379 |
|
368 |
| -// 监听路由变化更新列表,解决商品保存后,列表不刷新的问题。 |
| 380 | +/** 导出按钮操作 */ |
| 381 | +const handleExport = async () => { |
| 382 | + try { |
| 383 | + // 导出的二次确认 |
| 384 | + await message.exportConfirm() |
| 385 | + // 发起导出 |
| 386 | + exportLoading.value = true |
| 387 | + const data = await ProductSpuApi.exportSpu(queryParams) |
| 388 | + download.excel(data, '商品spu.xls') |
| 389 | + } catch { |
| 390 | + } finally { |
| 391 | + exportLoading.value = false |
| 392 | + } |
| 393 | +} |
| 394 | +
|
| 395 | +// 监听路由变化更新列表 TODO @puhui999:这个是必须加的么?fix: 因为编辑表单是以路由的方式打开,保存表单后列表不会刷新 |
369 | 396 | watch(
|
370 | 397 | () => currentRoute.value,
|
371 | 398 | () => {
|
|
0 commit comments