Commit e8ccbd0f by wuqian

导出

parent e7c03813
...@@ -6,6 +6,7 @@ export interface Tab { ...@@ -6,6 +6,7 @@ export interface Tab {
export interface ExportParams extends SearchForm { export interface ExportParams extends SearchForm {
idList?: number[] idList?: number[]
exportAll: boolean exportAll: boolean
status?:string
} }
export interface SearchForm { export interface SearchForm {
timeType?: number | null timeType?: number | null
......
...@@ -14,6 +14,7 @@ import { ...@@ -14,6 +14,7 @@ import {
getOperationLogApi, getOperationLogApi,
getOrderTabData, getOrderTabData,
getfaceSimplexFileApi, getfaceSimplexFileApi,
exportPodUSInfo,
} from '@/api/podUsOrder' } from '@/api/podUsOrder'
import { import {
SearchForm, SearchForm,
...@@ -23,6 +24,7 @@ import { ...@@ -23,6 +24,7 @@ import {
PodUsOrderListData, PodUsOrderListData,
LogListData, LogListData,
Tab, Tab,
ExportParams,
} from '@/types/api/podUsOrder' } from '@/types/api/podUsOrder'
import platformJson from '../../../json/platform.json' import platformJson from '../../../json/platform.json'
import dayjs from 'dayjs' import dayjs from 'dayjs'
...@@ -284,7 +286,7 @@ const goodsColumns = computed(() => { ...@@ -284,7 +286,7 @@ const goodsColumns = computed(() => {
}, },
] ]
}) })
const tableData = ref<PodUsOrderListData[][]>([]) const tableData = ref<PodUsOrderListData[]>([])
const goodsData = ref<ProductList[]>([]) const goodsData = ref<ProductList[]>([])
const searchVisible = ref(false) const searchVisible = ref(false)
const goodsLoading = ref(false) const goodsLoading = ref(false)
...@@ -371,7 +373,62 @@ const getWeekRange = (weeks = 0, type: 'past' | 'future' = 'past') => { ...@@ -371,7 +373,62 @@ const getWeekRange = (weeks = 0, type: 'past' | 'future' = 'past') => {
type === 'past' ? now.subtract(weeks, 'week') : now.add(weeks, 'week') type === 'past' ? now.subtract(weeks, 'week') : now.add(weeks, 'week')
return [start.startOf('week').toDate(), start.endOf('week').toDate()] return [start.startOf('week').toDate(), start.endOf('week').toDate()]
} }
const exportLoading = ref(false)
const exportVisible = ref(false)
const exportForm = ref({
resource: '',
})
const exportData = () => {
exportVisible.value = true
}
const submitExportForm = async () => {
if (exportForm.value.resource === '') {
return ElMessage.error('请选择导出类型')
}
exportLoading.value = true
const resourceType = Number(exportForm.value.resource)
const params: ExportParams = {
exportAll: false,
idList: [],
}
// 使用函数封装映射逻辑
const mapIds = (items: PodUsOrderListData[]) =>
items
.filter(
(el): el is PodUsOrderListData & { id: string | number } =>
el.id !== undefined && el.id !== null,
)
.map((el) => Number(el.id))
switch (resourceType) {
case 0:
params.idList = mapIds(tableData.value as PodUsOrderListData[])
break
case 1:
params.idList = mapIds(selection.value)
break
case 2:
params.exportAll = true
params.idList = undefined
break
default:
console.error('未知的资源类型:', resourceType)
}
try {
const res = await exportPodUSInfo({
...params,
...(resourceType === 2 ? searchForm.value : {}),
})
window.open(filePath + res.message, '_blank')
exportVisible.value = false
// exportLoading.value = false
} catch (e) {
exportVisible.value = false
// exportLoading.value = false
} finally {
exportLoading.value = false
}
}
const handleSizeChange = (pageSize: number) => { const handleSizeChange = (pageSize: number) => {
pagination.value.pageSize = pageSize pagination.value.pageSize = pageSize
getOrderListFn() getOrderListFn()
...@@ -886,6 +943,14 @@ onMounted(() => { ...@@ -886,6 +943,14 @@ onMounted(() => {
> >
</span> </span>
</ElFormItem> </ElFormItem>
<ElFormItem>
<ElButton
:loading="exportLoading"
type="success"
@click="exportData"
>导出</ElButton
>
</ElFormItem>
</ElForm> </ElForm>
</el-card> </el-card>
</template> </template>
...@@ -957,6 +1022,28 @@ onMounted(() => { ...@@ -957,6 +1022,28 @@ onMounted(() => {
</div> </div>
</template> </template>
</split-div> </split-div>
<ElDialog
v-model="exportVisible"
title="导出选项"
width="500px"
:close-on-click-modal="false"
>
<el-form :model="exportForm" label-width="80px">
<el-form-item label="" prop="resource">
<el-radio-group v-model="exportForm.resource">
<el-radio :label="0">导出本页</el-radio>
<el-radio :label="1">导出选中</el-radio>
<el-radio :label="2">全部</el-radio>
</el-radio-group>
</el-form-item>
</el-form>
<template #footer>
<span class="dialog-footer">
<el-button @click="exportVisible = false">取消</el-button>
<el-button type="primary" @click="submitExportForm">确认</el-button>
</span>
</template>
</ElDialog>
<ResultInfo <ResultInfo
ref="resultRefs" ref="resultRefs"
:list="resultInfo" :list="resultInfo"
......
...@@ -2124,6 +2124,7 @@ const submitExportForm = async () => { ...@@ -2124,6 +2124,7 @@ const submitExportForm = async () => {
const params: ExportParams = { const params: ExportParams = {
exportAll: false, exportAll: false,
idList: [], idList: [],
status: status.value,
} }
// 使用函数封装映射逻辑 // 使用函数封装映射逻辑
const mapIds = (items: PodUsOrderListData[]) => const mapIds = (items: PodUsOrderListData[]) =>
...@@ -2149,9 +2150,11 @@ const submitExportForm = async () => { ...@@ -2149,9 +2150,11 @@ const submitExportForm = async () => {
}) })
window.open(filePath + res.message, '_blank') window.open(filePath + res.message, '_blank')
exportVisible.value = false exportVisible.value = false
exportLoading.value = false // exportLoading.value = false
} catch (e) { } catch (e) {
exportVisible.value = false exportVisible.value = false
// exportLoading.value = false
} finally {
exportLoading.value = false exportLoading.value = false
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment