Commit 17e3c2c4 by qinjianhui

fix: 调用接口

parent 70fb178e
...@@ -38,7 +38,7 @@ export function getFactoryOrderNewListApi( ...@@ -38,7 +38,7 @@ export function getFactoryOrderNewListApi(
export function getFactoryOrderNewDetailApi(id: number | string) { export function getFactoryOrderNewDetailApi(id: number | string) {
return axios.get<never, BaseRespData<ProductListData[]>>( return axios.get<never, BaseRespData<ProductListData[]>>(
'factory/podOrder/get', 'factory/podOrderProduct/getListByPodOrderId',
{ {
params: { id }, params: { id },
}, },
...@@ -47,7 +47,7 @@ export function getFactoryOrderNewDetailApi(id: number | string) { ...@@ -47,7 +47,7 @@ export function getFactoryOrderNewDetailApi(id: number | string) {
export function getFactoryOrderNewLogApi(id: number | string) { export function getFactoryOrderNewLogApi(id: number | string) {
return axios.get<never, BaseRespData<LogListData[]>>( return axios.get<never, BaseRespData<LogListData[]>>(
'factory/podOrder/getLog', 'factory/podOrderLog/getPodOrderLog',
{ {
params: { id }, params: { id },
}, },
...@@ -275,6 +275,13 @@ export function downloadMaterialApi(id: number[]) { ...@@ -275,6 +275,13 @@ export function downloadMaterialApi(id: number[]) {
) )
} }
export function downloadOperationMaterialApi(id: number[]) {
return axios.post<never, BaseRespData<never>>(
'factory/podOrderOperation/downloadDesignImages',
id,
)
}
export function downloadBatchMaterialApi(id: number | string) { export function downloadBatchMaterialApi(id: number | string) {
return axios.post<never, BaseRespData<never>>( return axios.post<never, BaseRespData<never>>(
'factory/podOrderBatchDownload/download', 'factory/podOrderBatchDownload/download',
......
...@@ -106,6 +106,11 @@ export interface ProductListData { ...@@ -106,6 +106,11 @@ export interface ProductListData {
customsValue?: number customsValue?: number
remark?: string remark?: string
} }
export interface operateOrderListData {
id: number
podOrderProductId: number
[key: string]: unknown
}
export interface LogListData { export interface LogListData {
id: number id: number
......
...@@ -135,11 +135,7 @@ import { ElMessage } from 'element-plus' ...@@ -135,11 +135,7 @@ import { ElMessage } from 'element-plus'
import { getCardLayoutListApi } from '@/api/factoryOrderNew' import { getCardLayoutListApi } from '@/api/factoryOrderNew'
import type { PaginationData } from '@/types/api' import type { PaginationData } from '@/types/api'
import usePageList from '@/utils/hooks/usePageList' import usePageList from '@/utils/hooks/usePageList'
import { operateOrderListData } from '@/types/api/factoryOrderNew'
interface CardItem {
id: number | string
[key: string]: unknown
}
const props = defineProps<{ const props = defineProps<{
status: string status: string
...@@ -148,7 +144,7 @@ const props = defineProps<{ ...@@ -148,7 +144,7 @@ const props = defineProps<{
}>() }>()
const emit = defineEmits<{ const emit = defineEmits<{
'selection-change': [items: CardItem[]] 'selection-change': [items: operateOrderListData[]]
}>() }>()
const { const {
...@@ -160,7 +156,7 @@ const { ...@@ -160,7 +156,7 @@ const {
onCurrentPageChange, onCurrentPageChange,
onPageSizeChange, onPageSizeChange,
refresh, refresh,
} = usePageList<CardItem>({ } = usePageList<operateOrderListData>({
initPageSize: props.initPageSize || 100, initPageSize: props.initPageSize || 100,
query: async (current, size) => { query: async (current, size) => {
const payload = { const payload = {
...@@ -168,16 +164,16 @@ const { ...@@ -168,16 +164,16 @@ const {
statusCode: props.status === 'ALL' ? undefined : props.status, statusCode: props.status === 'ALL' ? undefined : props.status,
} }
const res = await getCardLayoutListApi(payload, current, size) const res = await getCardLayoutListApi(payload, current, size)
return res.data as unknown as PaginationData<CardItem> return res.data as unknown as PaginationData<operateOrderListData>
}, },
}) })
const selectedItems = ref<CardItem[]>([]) const selectedItems = ref<operateOrderListData[]>([])
const isSelected = (item: CardItem) => const isSelected = (item: operateOrderListData) =>
selectedItems.value.some((s) => s.id === item.id) selectedItems.value.some((s) => s.id === item.id)
const handleCardClick = (item: CardItem) => { const handleCardClick = (item: operateOrderListData) => {
const idx = selectedItems.value.findIndex((s) => s.id === item.id) const idx = selectedItems.value.findIndex((s) => s.id === item.id)
if (idx >= 0) { if (idx >= 0) {
selectedItems.value.splice(idx, 1) selectedItems.value.splice(idx, 1)
......
...@@ -868,6 +868,7 @@ import type { BaseRespData } from '@/types/api' ...@@ -868,6 +868,7 @@ import type { BaseRespData } from '@/types/api'
import type { import type {
FactoryOrderNewListData, FactoryOrderNewListData,
LogListData, LogListData,
operateOrderListData,
ProductListData, ProductListData,
SearchForm, SearchForm,
StatusTreeNode, StatusTreeNode,
...@@ -891,6 +892,7 @@ import { ...@@ -891,6 +892,7 @@ import {
getfaceSimplexFileApi, getfaceSimplexFileApi,
cancelLogisticsOrderApi, cancelLogisticsOrderApi,
downloadMaterialApi, downloadMaterialApi,
downloadOperationMaterialApi,
composingNewPodOrderDesignImages, composingNewPodOrderDesignImages,
printNewPodOrderProductionOrderApi, printNewPodOrderProductionOrderApi,
syncReceiverAddress, syncReceiverAddress,
...@@ -1138,7 +1140,7 @@ const productList = ref<ProductListData[]>([]) ...@@ -1138,7 +1140,7 @@ const productList = ref<ProductListData[]>([])
const currentRow = ref<FactoryOrderNewListData | null>(null) const currentRow = ref<FactoryOrderNewListData | null>(null)
const selectedRowIds = ref<(number | string)[]>([]) const selectedRowIds = ref<(number | string)[]>([])
const selectedRows = ref<FactoryOrderNewListData[]>([]) const selectedRows = ref<FactoryOrderNewListData[]>([])
const cardSelectedIds = ref<(number | string)[]>([]) const cardSelectList = ref<operateOrderListData[]>([])
const logList = ref<LogListData[]>([]) const logList = ref<LogListData[]>([])
const tableRef = ref() const tableRef = ref()
const mainColumns = [ const mainColumns = [
...@@ -1444,7 +1446,7 @@ const createLogisticDialogRef = ref() ...@@ -1444,7 +1446,7 @@ const createLogisticDialogRef = ref()
const updateCustomsDialogVisible = ref(false) const updateCustomsDialogVisible = ref(false)
const weightDialogRef = ref() const weightDialogRef = ref()
const getSelectedIds = (): (number | string)[] => { const getSelectedIds = (): (number | string)[] => {
if (isCardLayout.value) return cardSelectedIds.value if (isCardLayout.value) return cardSelectList.value.map((item) => item.id)
return selectedRowIds.value return selectedRowIds.value
} }
const ensureSelection = (msg = '请先选择订单'): boolean => { const ensureSelection = (msg = '请先选择订单'): boolean => {
...@@ -1480,7 +1482,7 @@ const handleStatusNodeClick = (node: StatusTreeNode) => { ...@@ -1480,7 +1482,7 @@ const handleStatusNodeClick = (node: StatusTreeNode) => {
} }
selectedRowIds.value = [] selectedRowIds.value = []
selectedRows.value = [] selectedRows.value = []
cardSelectedIds.value = [] cardSelectList.value = []
productList.value = [] productList.value = []
logList.value = [] logList.value = []
currentRow.value = null currentRow.value = null
...@@ -1515,8 +1517,8 @@ const handleMainSelectionChange = (rows: FactoryOrderNewListData[]) => { ...@@ -1515,8 +1517,8 @@ const handleMainSelectionChange = (rows: FactoryOrderNewListData[]) => {
selectedRowIds.value = rows.map((row) => row.id) selectedRowIds.value = rows.map((row) => row.id)
selectedRows.value = rows selectedRows.value = rows
} }
const handleCardSelectionChange = (items: { id: number | string }[]) => { const handleCardSelectionChange = (items: operateOrderListData[]) => {
cardSelectedIds.value = items.map((i) => i.id) cardSelectList.value = items
} }
const getOrderDetailsById = async (tabName?: 'product' | 'log') => { const getOrderDetailsById = async (tabName?: 'product' | 'log') => {
if (!currentRow.value) { if (!currentRow.value) {
...@@ -1556,7 +1558,7 @@ const handleRowClick = (row: FactoryOrderNewListData) => { ...@@ -1556,7 +1558,7 @@ const handleRowClick = (row: FactoryOrderNewListData) => {
logList.value = [] logList.value = []
selectedRowIds.value = [] selectedRowIds.value = []
selectedRows.value = [] selectedRows.value = []
cardSelectedIds.value = [] cardSelectList.value = []
} }
const handleTabClick = (tab: TabsPaneContext) => { const handleTabClick = (tab: TabsPaneContext) => {
...@@ -1849,14 +1851,24 @@ const downloadPDF = (url: string) => { ...@@ -1849,14 +1851,24 @@ const downloadPDF = (url: string) => {
} }
const handleDownloadMaterial = async () => { const handleDownloadMaterial = async () => {
if (!ensureSelection()) return if (!ensureSelection()) return
const ids = getSelectedIds() const usePodOrderDownloadStatuses = ['PENDING_SCHEDULE', 'PENDING_DELIVERY', 'SUSPEND']
const usePodOrderDownload = usePodOrderDownloadStatuses.includes(status.value)
const ids = usePodOrderDownload
? selectedRows.value.map((row) => row.id)
: cardSelectList.value.map((row) => row.podOrderProductId)
if (!ids.length) {
ElMessage.warning('未获取到可下载的素材ID')
return
}
const loading = ElLoading.service({ const loading = ElLoading.service({
fullscreen: true, fullscreen: true,
text: '操作中...', text: '操作中...',
background: 'rgba(0, 0, 0, 0.3)', background: 'rgba(0, 0, 0, 0.3)',
}) })
try { try {
const res = await downloadMaterialApi(ids as number[]) const res = usePodOrderDownload
? await downloadMaterialApi(ids as number[])
: await downloadOperationMaterialApi(ids as number[])
if (res.message) { if (res.message) {
const a = document.createElement('a') const a = document.createElement('a')
a.href = filePath + res.message a.href = filePath + res.message
......
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