Skip to content

Commit ae49aaf

Browse files
committed
Merge branch 'dev-to-dev' of https://gitee.com/puhui999/yudao-ui-admin-vue3 into dev
� Conflicts: � src/views/mall/product/spu/index.vue
2 parents 0fba3fd + d877bfd commit ae49aaf

File tree

2 files changed

+33
-6
lines changed

2 files changed

+33
-6
lines changed

src/api/mall/product/spu.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ export const deleteSpu = (id: number) => {
8686
return request.delete({ url: `/product/spu/delete?id=${id}` })
8787
}
8888

89-
// 导出商品 Spu
90-
export const exportUser = (params) => {
91-
return request.download({ url: '/product/spu/export', params })
89+
// 导出商品 Spu Excel
90+
export const exportSpu = async (params) => {
91+
return await request.download({ url: '/product/spu/export', params })
9292
}

src/views/mall/product/spu/index.vue

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,21 @@
5151
<Icon class="mr-5px" icon="ep:refresh" />
5252
重置
5353
</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">
5555
<Icon class="mr-5px" icon="ep:plus" />
5656
新增
5757
</el-button>
5858
<!-- 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>
5969
</el-form-item>
6070
</el-form>
6171
</ContentWrap>
@@ -195,15 +205,17 @@ import { createImageViewer } from '@/components/ImageViewer'
195205
import { dateFormatter } from '@/utils/formatTime'
196206
import { defaultProps, handleTree } from '@/utils/tree'
197207
import { ProductSpuStatusEnum } from '@/utils/constants'
208+
import { formatToFraction } from '@/utils'
209+
import download from '@/utils/download'
198210
import * as ProductSpuApi from '@/api/mall/product/spu'
199211
import * as ProductCategoryApi from '@/api/mall/product/category'
200-
import { formatToFraction } from '@/utils'
201212
202213
const message = useMessage() // 消息弹窗
203214
const { t } = useI18n() // 国际化
204215
const { currentRoute, push } = useRouter() // 路由跳转
205216
206217
const loading = ref(false) // 列表的加载中
218+
const exportLoading = ref(false) // 导出的加载中
207219
const total = ref(0) // 列表的总页数
208220
const list = ref<any[]>([]) // 列表的数据
209221
// tabs 数据
@@ -365,7 +377,22 @@ const openDetail = () => {
365377
message.alert('查看详情未完善!!!')
366378
}
367379
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: 因为编辑表单是以路由的方式打开,保存表单后列表不会刷新
369396
watch(
370397
() => currentRoute.value,
371398
() => {

0 commit comments

Comments
 (0)