f
This commit is contained in:
@@ -322,6 +322,12 @@ export const productAdminApi = {
|
||||
updateProduct: (id, data) => request.put(`/admin/products/${id}`, data),
|
||||
deleteProduct: (id) => request.delete(`/admin/products/${id}`),
|
||||
|
||||
// 产品字典导出
|
||||
exportProductDictionary: (params) => request.get('/admin/products/export-dictionary', {
|
||||
params,
|
||||
responseType: 'blob'
|
||||
}),
|
||||
|
||||
// 组合包管理
|
||||
getAvailableProducts: (params) => request.get('/admin/products/available', { params }),
|
||||
addPackageItem: (packageId, data) => request.post(`/admin/products/${packageId}/package-items`, data),
|
||||
|
||||
@@ -12,6 +12,15 @@
|
||||
<span :class="isMobile ? 'hidden sm:inline' : ''">新增产品</span>
|
||||
<span :class="isMobile ? 'sm:hidden' : 'hidden'">新增</span>
|
||||
</el-button>
|
||||
<el-button
|
||||
type="success"
|
||||
:size="isMobile ? 'small' : 'default'"
|
||||
@click="exportProductDictionary"
|
||||
>
|
||||
<Download class="w-4 h-4 mr-1" />
|
||||
<span :class="isMobile ? 'hidden sm:inline' : ''">导出产品字典</span>
|
||||
<span :class="isMobile ? 'sm:hidden' : 'hidden'">导出</span>
|
||||
</el-button>
|
||||
</template>
|
||||
|
||||
<template #filters>
|
||||
@@ -327,8 +336,8 @@ import FilterItem from '@/components/common/FilterItem.vue'
|
||||
import FilterSection from '@/components/common/FilterSection.vue'
|
||||
import ListPageLayout from '@/components/common/ListPageLayout.vue'
|
||||
import { useMobileTable } from '@/composables/useMobileTable'
|
||||
import { ArrowDown } from '@element-plus/icons-vue'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import { ArrowDown, Download } from '@element-plus/icons-vue'
|
||||
import { ElMessage, ElMessageBox, ElLoading } from 'element-plus'
|
||||
|
||||
const router = useRouter()
|
||||
|
||||
@@ -571,6 +580,40 @@ const handleFormSuccess = () => {
|
||||
loadProducts()
|
||||
}
|
||||
|
||||
// 导出产品字典
|
||||
const exportProductDictionary = async () => {
|
||||
const loading = ElLoading.service({
|
||||
lock: true,
|
||||
text: '正在生成产品字典...',
|
||||
background: 'rgba(0, 0, 0, 0.7)'
|
||||
})
|
||||
try {
|
||||
// 调用导出API,默认使用Excel格式
|
||||
const response = await productAdminApi.exportProductDictionary({ format: 'excel' })
|
||||
|
||||
// 创建下载链接
|
||||
const blob = new Blob([response.data], {
|
||||
type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
|
||||
})
|
||||
|
||||
const url = URL.createObjectURL(blob)
|
||||
const link = document.createElement('a')
|
||||
link.href = url
|
||||
link.download = `产品字典_${new Date().toLocaleDateString('zh-CN').replace(/\//g, '-')}.xlsx`
|
||||
document.body.appendChild(link)
|
||||
link.click()
|
||||
document.body.removeChild(link)
|
||||
URL.revokeObjectURL(url)
|
||||
|
||||
ElMessage.success('产品字典导出成功')
|
||||
} catch (error) {
|
||||
console.error('导出产品字典失败:', error)
|
||||
ElMessage.error('导出产品字典失败,请稍后重试')
|
||||
} finally {
|
||||
loading.close()
|
||||
}
|
||||
}
|
||||
|
||||
// 移动端操作处理
|
||||
const handleMobileAction = (command, product) => {
|
||||
switch (command) {
|
||||
|
||||
Reference in New Issue
Block a user