Commit ddf3222a by qinjianhui

fix: 缺货统计添加导出功能

parent ce4120d9
...@@ -53,6 +53,7 @@ declare module 'vue' { ...@@ -53,6 +53,7 @@ declare module 'vue' {
ElTag: typeof import('element-plus/es')['ElTag'] ElTag: typeof import('element-plus/es')['ElTag']
ElTimeline: typeof import('element-plus/es')['ElTimeline'] ElTimeline: typeof import('element-plus/es')['ElTimeline']
ElTimelineItem: typeof import('element-plus/es')['ElTimelineItem'] ElTimelineItem: typeof import('element-plus/es')['ElTimelineItem']
ElTimePicker: typeof import('element-plus/es')['ElTimePicker']
ElTooltip: typeof import('element-plus/es')['ElTooltip'] ElTooltip: typeof import('element-plus/es')['ElTooltip']
ElTree: typeof import('element-plus/es')['ElTree'] ElTree: typeof import('element-plus/es')['ElTree']
ElUpload: typeof import('element-plus/es')['ElUpload'] ElUpload: typeof import('element-plus/es')['ElUpload']
......
import axios from './axios' import axios from './axios'
import { BasePaginationData } from '@/types/api' import { BasePaginationData, BaseRespData } from '@/types/api'
import { SearchForm, OutOfStockItem } from '@/types/api/outOfStockStatistics' import { SearchForm, OutOfStockItem } from '@/types/api/outOfStockStatistics'
export function getOutOfStockStatisticsListApi( export function getOutOfStockStatisticsListApi(
data: SearchForm, data: SearchForm,
...@@ -11,3 +11,13 @@ export function getOutOfStockStatisticsListApi( ...@@ -11,3 +11,13 @@ export function getOutOfStockStatisticsListApi(
{ ...data, currentPage, pageSize }, { ...data, currentPage, pageSize },
) )
} }
export function exportOutOfStockStatisticsListApi(data: {
exportAll: boolean
indexes?: number[]
}) {
return axios.post<never, BaseRespData<never>>(
'stockOutStatistics/exportStockOutStatistics',
data,
)
}
...@@ -16,6 +16,7 @@ export interface OutOfStockItem { ...@@ -16,6 +16,7 @@ export interface OutOfStockItem {
freezeInventory?: number freezeInventory?: number
purchaseNotInQuantity?: number purchaseNotInQuantity?: number
longestDelayDays?: number longestDelayDays?: number
sort?: number
} }
export interface SearchForm { export interface SearchForm {
......
...@@ -74,6 +74,33 @@ ...@@ -74,6 +74,33 @@
></ElPagination> ></ElPagination>
</div> </div>
</div> </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="currentPage">导出本页</el-radio>
<el-radio label="selectedRows">导出选中</el-radio>
<el-radio label="all">全部</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
:loading="exportLoading"
type="primary"
@click="submitExportForm"
>确认</el-button
>
</span>
</template>
</ElDialog>
</template> </template>
<script setup lang="tsx"> <script setup lang="tsx">
...@@ -83,8 +110,12 @@ import usePageList from '@/utils/hooks/usePageList' ...@@ -83,8 +110,12 @@ import usePageList from '@/utils/hooks/usePageList'
import { loadWarehouseListApi } from '@/api/podCnOrder' import { loadWarehouseListApi } from '@/api/podCnOrder'
import type { WarehouseListData } from '@/types/api/podCnOrder' import type { WarehouseListData } from '@/types/api/podCnOrder'
import { SearchForm, OutOfStockItem } from '@/types/api/outOfStockStatistics' import { SearchForm, OutOfStockItem } from '@/types/api/outOfStockStatistics'
import { getOutOfStockStatisticsListApi } from '@/api/outOfStockStis' import {
getOutOfStockStatisticsListApi,
exportOutOfStockStatisticsListApi,
} from '@/api/outOfStockStis'
import ImageView from '@/components/ImageView.vue' import ImageView from '@/components/ImageView.vue'
import { filePath } from '@/api/axios'
const searchForm = ref<SearchForm>({ const searchForm = ref<SearchForm>({
warehouseId: '', warehouseId: '',
...@@ -94,7 +125,11 @@ const searchForm = ref<SearchForm>({ ...@@ -94,7 +125,11 @@ const searchForm = ref<SearchForm>({
}) })
const warehouseList = ref<WarehouseListData[]>([]) const warehouseList = ref<WarehouseListData[]>([])
const exportVisible = ref(false)
const exportForm = ref({
resource: null,
})
const exportLoading = ref(false)
// 表格列配置 // 表格列配置
const tableColumns = computed(() => { const tableColumns = computed(() => {
return [ return [
...@@ -213,7 +248,7 @@ const { ...@@ -213,7 +248,7 @@ const {
refresh: search, refresh: search,
onCurrentPageChange: handleCurrentChange, onCurrentPageChange: handleCurrentChange,
onPageSizeChange: handleSizeChange, onPageSizeChange: handleSizeChange,
} = usePageList({ } = usePageList<OutOfStockItem>({
query: (page, pageSize) => query: (page, pageSize) =>
getOutOfStockStatisticsListApi( getOutOfStockStatisticsListApi(
{ {
...@@ -236,9 +271,45 @@ const loadWarehouseList = async () => { ...@@ -236,9 +271,45 @@ const loadWarehouseList = async () => {
console.error(e) console.error(e)
} }
} }
// 导出数据 // 导出数据
const exportData = async () => {} const exportData = async () => {
exportForm.value.resource = null
exportVisible.value = true
}
const submitExportForm = async () => {
if (!exportForm.value.resource) {
return ElMessage.error('请选择导出类型')
}
const params: { exportAll: boolean; indexes?: number[] } = {
exportAll: false,
indexes: [],
}
if (exportForm.value.resource === 'currentPage') {
params.exportAll = false
params.indexes = undefined
} else if (exportForm.value.resource === 'selectedRows') {
if (!selectedRows.value.length) {
return ElMessage.error('请选择要导出的数据')
}
params.exportAll = false
params.indexes = selectedRows.value.map((el: OutOfStockItem) =>
Number(el.sort),
)
} else if (exportForm.value.resource === 'all') {
params.exportAll = true
params.indexes = undefined
}
try {
const res = await exportOutOfStockStatisticsListApi({
...searchForm.value,
...params,
})
window.open(filePath + res.message, '_blank')
exportVisible.value = false
} catch (e) {
console.error(e)
}
}
// 处理表格选择变化 // 处理表格选择变化
const selectedRows = ref<OutOfStockItem[]>([]) const selectedRows = ref<OutOfStockItem[]>([])
......
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