Commit 34c97635 by qinjianhui

feat: 批次管理操作列修改

parent 43f9f19b
......@@ -43,7 +43,10 @@ export function getFactoryOrderNewListApi(
status?: string,
subStatus?: number,
) {
const body = normalizePodOrderQueryPayload({ ...data } as Record<string, unknown>)
const body = normalizePodOrderQueryPayload({ ...data } as Record<
string,
unknown
>)
return axios.post<never, BasePaginationData<FactoryOrderNewListData>>(
'factory/podOrder/list_page',
{
......@@ -173,7 +176,7 @@ export function cancelSuspendApi(ids: (number | string)[]) {
})
}
export function archiveOrderApi(ids: (number | string)) {
export function archiveOrderApi(ids: number | string) {
return axios.get<never, BaseRespData<void>>('factory/podOrder/archiving', {
params: { ids },
})
......@@ -194,10 +197,10 @@ export function applyReplenishApi(ids: (number | string)[]) {
}
export function batchDeleteApi(ids: (number | string)[]) {
return axios.post<never, BaseRespData<void>>(
return axios.get<never, BaseRespData<never>>(
'factory/podOrderBatchDownload/delete',
{
ids: ids.join(','),
params: { ids: ids.join(',') },
},
)
}
......@@ -276,7 +279,10 @@ export function getSuspendListApi(
pageSize: number,
pauseReason?: number,
) {
const body = normalizePodOrderQueryPayload({ ...data } as Record<string, unknown>)
const body = normalizePodOrderQueryPayload({ ...data } as Record<
string,
unknown
>)
return axios.post<never, BasePaginationData<FactoryOrderNewListData>>(
'factory/podOrderPauseControl/list_page',
{ ...body, currentPage, pageSize, pauseReason },
......@@ -289,7 +295,10 @@ export function getSuspendStatisticsApi(
pageSize: number,
pauseReason?: number,
) {
const body = normalizePodOrderQueryPayload({ ...data } as Record<string, unknown>)
const body = normalizePodOrderQueryPayload({ ...data } as Record<
string,
unknown
>)
return axios.post<never, BaseRespData<Record<string, number>>>(
'factory/podOrderPauseControl/suspendStatistics',
{ ...body, currentPage, pageSize, pauseReason },
......@@ -352,19 +361,53 @@ export function cancelLogisticsOrderApi(orderIds: (string | number)[]) {
orderIds,
)
}
export function arrangeFinishApi(
url: string,
params: {
export function arrangeFinishApi(params: {
productIdList: number[]
templateWidth?: number
type?: string
},
) {
return axios.post<never, BaseRespData<never>>(url, {
}) {
return axios.post<never, BaseRespData<never>>(
'factory/podOrderOperation/arrangeFinish',
{
operationIdList: params.productIdList,
templateWidth: params.templateWidth,
type: params.type,
})
},
)
}
export function batchDownloadDesignImagesApi(params: {
id: number
templateWidth?: number
type?: string
}) {
return axios.get<never, BaseRespData<never>>(
'factory/podOrderBatchDownload/reComposingDesignImages',
{
params,
},
)
}
export function printPickPdfByBatchNumberApi(params: {
batchArrangeNumber: string
}) {
return axios.get<never, BaseRespData<never>>(
`factory/podOrderOperation/printPickPdfByBatchNumber`,
{
params,
},
)
}
// 打印生产单item
export function printProductionPdfByBatchNumberApi(params: {
batchArrangeNumber: string
}) {
return axios.get<never, BaseRespData<never>>(
`factory/podOrderOperation/printProductionPdfByBatchNumber`,
{
params,
},
)
}
export function downloadMaterialApi(id: number[]) {
......@@ -381,10 +424,10 @@ export function downloadOperationMaterialApi(id: number[]) {
)
}
export function downloadBatchMaterialApi(id: number | string) {
return axios.post<never, BaseRespData<never>>(
export function downloadBatchMaterialApi(id: number | string, type?: string) {
return axios.get<never, BaseRespData<never>>(
'factory/podOrderBatchDownload/download',
id,
{ params: { id, type } },
)
}
......
......@@ -189,6 +189,7 @@ export interface BatchManageData {
prnDownloadStatus?: string
enableArrange?: boolean
standardDesignImage?: number
type?: string
}
export interface RestockData {
......
......@@ -33,9 +33,7 @@
<template #footer>
<div style="text-align: center">
<ElButton @click="visible = false">取消</ElButton>
<ElButton type="primary" :loading="submitting" @click="handleSubmit">
确定
</ElButton>
<ElButton type="primary" @click="handleSubmit"> 确定 </ElButton>
</div>
</template>
</ElDialog>
......@@ -44,21 +42,26 @@
<script setup lang="ts">
import { ref } from 'vue'
import { ElMessage } from 'element-plus'
import { arrangeFinishApi } from '@/api/factoryOrderNew'
import { BaseRespData } from '@/types/api'
type OpenPayload = {
productIdList: number[]
productIdList?: number[]
title?: string
requestUrl: string
showAutoSwitch?: boolean
id?: number
}
const emit = defineEmits<{
success: []
}>()
const props = defineProps<{
submitApi: (params: {
productIdList?: number[]
templateWidth?: number
type?: string
}) => Promise<BaseRespData<never>>
}>()
const visible = ref(false)
const submitting = ref(false)
const payload = ref<OpenPayload | null>(null)
const isAuto = ref(true)
......@@ -89,21 +92,25 @@ const handleSubmit = async () => {
if (mustFill && !templateWidth) {
return ElMessage.warning('请选择排版宽度')
}
submitting.value = true
const loading = ElLoading.service({
fullscreen: true,
text: '操作中...',
background: 'rgba(0, 0, 0, 0.3)',
})
try {
await arrangeFinishApi(payload.value.requestUrl, {
const res = await props.submitApi({
productIdList: payload.value.productIdList,
templateWidth: isAuto.value ? templateWidth : undefined,
type: isAuto.value ? 'png' : undefined,
})
ElMessage.success('操作成功')
if (res.code !== 200) return
ElMessage.success(res.message)
visible.value = false
emit('success')
} catch (e) {
console.error(e)
} finally {
submitting.value = false
loading.close()
}
}
......
......@@ -89,6 +89,9 @@
<div class="batch-manage-actions">
<span class="item">
<ElButton type="primary" @click="refresh">查询</ElButton>
</span>
<span class="item">
<ElButton type="danger" @click="handleBatchDelete">批量删除</ElButton>
</span>
</div>
......@@ -109,7 +112,7 @@
{{ row.downloadStatus || '未下载' }}
</el-tag>
</template>
<template #operation="{ row }">
<template #operate="{ row }">
<ElButton
type="primary"
link
......@@ -118,14 +121,19 @@
>
下载
</ElButton>
<ElButton type="primary" link size="small" @click="handlePrintPick()">
<ElButton
type="primary"
link
size="small"
@click="handlePrintPick(row)"
>
拣货单
</ElButton>
<ElButton
type="primary"
link
size="small"
@click="handlePrintProduction()"
@click="handlePrintProduction(row)"
>
生产单
</ElButton>
......@@ -137,14 +145,23 @@
>
重排
</ElButton>
<ElButton type="danger" link size="small" @click="handleDelete()">
<ElButton
type="danger"
link
size="small"
@click="handleBatchDelete(row)"
>
删除
</ElButton>
</template>
</TableView>
</div>
<ArrangeDialog ref="arrangeDialogRef" @success="refresh" />
<ArrangeDialog
ref="arrangeDialogRef"
:submit-api="submitBatchDownloadDesignImagesApi"
@success="refresh"
/>
<ElPagination
v-model:current-page="currentPage"
......@@ -167,6 +184,8 @@ import {
getBatchManageListApi,
batchDeleteApi,
downloadBatchMaterialApi,
printPickPdfByBatchNumberApi,
printProductionPdfByBatchNumberApi,
} from '@/api/factoryOrderNew'
import type { BatchManageData } from '@/types/api/factoryOrderNew'
import type { PaginationData } from '@/types/api'
......@@ -176,6 +195,7 @@ import { getEmployeeListApi } from '@/api/common'
import type { userData } from '@/types/api/user'
import usePageList from '@/utils/hooks/usePageList'
import { filePath } from '@/api/axios'
import { batchDownloadDesignImagesApi } from '@/api/factoryOrderNew'
const selectedRows = ref<BatchManageData[]>([])
const employeeList = ref<userData[]>([])
......@@ -218,7 +238,7 @@ const columns = [
{
label: '批次号',
prop: 'batchArrangeNum',
width: 120,
width: 180,
align: 'center',
},
{
......@@ -259,7 +279,7 @@ const columns = [
width: 150,
prop: 'craftType',
align: 'center',
render: ({ row }: { row: BatchManageData; index: number }) => {
render: (row: BatchManageData) => {
if (row && !row.craftType) {
return (
<div>
......@@ -290,7 +310,7 @@ const columns = [
minWidth: 180,
prop: 'standardDesignImage',
align: 'center',
render: ({ row }: { row: BatchManageData }) => {
render: (row: BatchManageData) => {
return (
<div>
<span>
......@@ -302,12 +322,12 @@ const columns = [
},
{
label: '失败原因',
minWidth: 250,
minWidth: 300,
prop: 'failReason',
align: 'left',
render: ({ row }: { row: BatchManageData; index: number }) => {
render: (row: BatchManageData) => {
return (
<div>
<div style="white-space: pre-line">
<span v-html={row?.failReason}></span>
</div>
)
......@@ -330,7 +350,7 @@ const columns = [
width: 85,
prop: 'automaticComposing',
align: 'center',
render: ({ row }: { row: BatchManageData; index: number }) => {
render: (row: BatchManageData) => {
return (
<div>
<span>{row?.automaticComposing ? '是' : '否'}</span>
......@@ -342,10 +362,10 @@ const columns = [
label: '排版参数',
width: 140,
prop: 'composingParam',
align: 'center',
render: ({ row }: { row: BatchManageData; index: number }) => {
align: 'left',
render: (row: BatchManageData) => {
return (
<div>
<div style="white-space: pre-line">
<span>{row?.composingParam?.split(';').join('\n')}</span>
</div>
)
......@@ -413,58 +433,119 @@ const handleSelectionChange = (rows: BatchManageData[]) => {
selectedRows.value = rows
}
const handleBatchDelete = async () => {
const handleBatchDelete = async (row?: BatchManageData) => {
let ids
if (!row) {
if (!selectedRows.value.length) {
ElMessage.warning('请先选择数据')
return
}
await ElMessageBox.confirm('确定批量删除选中的批次吗?', '提示', {
ids = selectedRows.value.map((r) => r.id)
} else {
ids = [row.id]
}
try {
await ElMessageBox.confirm('确定删除选中的数据吗?', '提示', {
type: 'warning',
})
} catch {
return
}
const loading = ElLoading.service({
fullscreen: true,
text: '操作中...',
background: 'rgba(0, 0, 0, 0.3)',
})
try {
await batchDeleteApi(selectedRows.value.map((r) => r.id))
ElMessage.success('删除成功')
const res = await batchDeleteApi(ids)
if (res.code !== 200) return
ElMessage.success(res.message)
refresh()
} catch (e) {
const err = e as Error & { message?: string }
ElMessage.error(err?.message || '删除失败')
console.error(e)
} finally {
loading.close()
}
}
const handleDownload = async (row: BatchManageData) => {
try {
await ElMessageBox.confirm('确定下载选中的批次吗?', '提示', {
type: 'warning',
const loading = ElLoading.service({
fullscreen: true,
text: '操作中...',
background: 'rgba(0, 0, 0, 0.3)',
})
} catch {
return
}
const type = row.url && row.tiffUrl ? 'tiff' : row.url ? 'png' : 'tiff'
try {
const res = await downloadBatchMaterialApi(row.id)
const res = await downloadBatchMaterialApi(row.id, type)
if (res.code !== 200) return
window.open(filePath + res.message)
window.open(filePath + res.message, '_blank')
} catch (e) {
console.error(e)
} finally {
loading.close()
}
}
const handlePrintPick = () => {
ElMessage.info('接口待提供')
const submitBatchDownloadDesignImagesApi = (params: {
productIdList?: number[]
templateWidth?: number
type?: string
}) => {
return batchDownloadDesignImagesApi({
id: params.productIdList?.[0] as number,
templateWidth: params.templateWidth,
type: params.type,
})
}
const handlePrintProduction = () => {
ElMessage.info('接口待提供')
const handlePrintPick = async (row: BatchManageData) => {
const loading = ElLoading.service({
fullscreen: true,
text: '操作中...',
background: 'rgba(0, 0, 0, 0.3)',
})
try {
const res = await printPickPdfByBatchNumberApi({
batchArrangeNumber: row.batchArrangeNum as string,
})
if (res?.code !== 200) return
ElMessage.success('操作成功')
window.open(filePath + res?.message)
} catch (e) {
console.error(e)
} finally {
loading.close()
}
}
const handleDelete = () => {
ElMessage.info('接口待提供')
const handlePrintProduction = async (row: BatchManageData) => {
const loading = ElLoading.service({
fullscreen: true,
text: '操作中...',
background: 'rgba(0, 0, 0, 0.3)',
})
try {
const res = await printProductionPdfByBatchNumberApi({
batchArrangeNumber: row.batchArrangeNum as string,
})
if (res?.code !== 200) return
ElMessage.success('操作成功')
window.open(filePath + res?.message)
} catch (e) {
console.error(e)
} finally {
loading.close()
}
}
const handleReArrange = (row: BatchManageData) => {
arrangeDialogRef.value?.open({
productIdList: [row.id],
title: '重排',
requestUrl: 'factory/podOrderBatchDownload/reComposingDesignImages',
showAutoSwitch: false,
})
}
......
......@@ -837,6 +837,7 @@
<ArrangeDialog
ref="arrangeDialogRef"
:submit-api="submitArrangeFinishApi"
@success="() => refreshCurrentView({ isRefreshTree: true })"
/>
......@@ -922,6 +923,7 @@ import {
submitPodPrintOrderCompleteApi,
getFactoryOrderNewOperateDetailApi,
statusPushApi,
arrangeFinishApi,
} from '@/api/factoryOrderNew'
import BigNumber from 'bignumber.js'
import { filePath } from '@/api/axios'
......@@ -1611,10 +1613,21 @@ const handleArrange = async () => {
.filter((n) => Number.isFinite(n)) as number[]
arrangeDialogRef.value?.open({
productIdList,
requestUrl: 'factory/podOrderOperation/arrangeFinish',
showAutoSwitch: true,
})
}
const submitArrangeFinishApi = (params: {
productIdList?: number[]
templateWidth?: number
type?: string
}) =>
arrangeFinishApi({
productIdList: params.productIdList || [],
templateWidth: params.templateWidth,
type: params.type,
})
const handleSingleConfirmOrder = (row: FactoryOrderNewListData) => {
confirmOrderDialogRef.value?.open([row.id])
}
......
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