feat:模具管理-模具列表添加导出按钮

main
黄伟杰 1 week ago
parent 7a1ba32ae3
commit 4292e5cf86

@ -85,6 +85,10 @@ export const MoldBrandApi = {
getMoldPageWithoutPaging: async () => {
return await request.get({ url: `/erp/mold-brand/mold/list` })
},
// 导出模具 Excel
exportMold: async (params) => {
return await request.download({ url: `/erp/mold-brand/mold/export-excel`, params })
},
// 新增模具
createMold: async (data) => {
return await request.post({ url: `/erp/mold-brand/mold/create`, data })

@ -4,6 +4,15 @@
<el-button type="primary" plain @click="openForm('create')" v-hasPermi="['erp:mold-brand:create']">
<Icon icon="ep:plus" class="mr-5px" /> {{ t('action.add') }}
</el-button>
<el-button
type="success"
plain
@click="handleExport"
:loading="exportLoading"
v-hasPermi="['erp:mold-brand:export']"
>
<Icon icon="ep:download" class="mr-5px" /> {{ t('action.export') }}
</el-button>
<el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true">
<el-table-column :label="t('MoldManagement.Mold.code')" align="center" prop="code" />
<el-table-column :label="t('MoldManagement.Mold.name')" align="left" prop="name" />
@ -70,6 +79,7 @@
<script setup lang="ts">
import { DICT_TYPE } from '@/utils/dict'
import { dateFormatter, formatDate } from '@/utils/formatTime'
import download from '@/utils/download'
import { MoldBrandApi, type MoldVO } from '@/api/erp/mold'
import MoldForm from './MoldForm.vue'
import MoldRecordForm from "@/views/erp/mold/components/MoldRecordForm.vue";
@ -83,6 +93,7 @@ const props = defineProps<{
const loading = ref(false) //
const list = ref([]) //
const total = ref(0) //
const exportLoading = ref(false) //
const queryParams = reactive({
pageNo: 1,
pageSize: 10,
@ -143,6 +154,26 @@ const handleDelete = async (id: number) => {
} catch { }
}
/** 导出按钮操作 */
const handleExport = async () => {
if (!props.brandId) {
message.error('请选择一个模具型号')
return
}
try {
await message.exportConfirm()
exportLoading.value = true
const data = await MoldBrandApi.exportMold({
...queryParams,
brandId: props.brandId
})
download.excel(data, '模具.xls')
} catch {
} finally {
exportLoading.value = false
}
}
/** 添加/修改操作 */
const recordFormRef = ref()
const openRecordForm = (type: string, id?: number, brandId?: number) => {

Loading…
Cancel
Save