118 lines
3.1 KiB
Vue
118 lines
3.1 KiB
Vue
<template>
|
||
<div class="manual-form">
|
||
<el-input-number
|
||
v-model="manualForm.warehouseId"
|
||
:min="1"
|
||
:step="1"
|
||
size="small"
|
||
controls-position="right"
|
||
placeholder="单仓库ID"
|
||
/>
|
||
<el-input
|
||
v-model="manualWarehouseIdsText"
|
||
size="small"
|
||
placeholder="仓库ID数组,逗号分隔(例:100000,1000028)"
|
||
clearable
|
||
/>
|
||
<el-input-number
|
||
v-model="manualForm.queryTimeoutMs"
|
||
:min="1"
|
||
:step="500"
|
||
size="small"
|
||
controls-position="right"
|
||
placeholder="查询超时(ms)"
|
||
/>
|
||
<el-input-number
|
||
v-model="manualForm.executionTimeoutMs"
|
||
:min="1"
|
||
:step="500"
|
||
size="small"
|
||
controls-position="right"
|
||
placeholder="执行超时(ms)"
|
||
/>
|
||
<div class="action-wrap">
|
||
<el-button size="small" type="warning" :loading="manualLoading" @click="submitManualOutbound">
|
||
手动出库
|
||
</el-button>
|
||
</div>
|
||
</div>
|
||
</template>
|
||
|
||
<script setup lang="ts">
|
||
import { reactive, ref } from 'vue'
|
||
import { ElMessage } from 'element-plus'
|
||
import { orderOutboundOrder } from '@/api/order.outboundOrder/orderoutboundOrder'
|
||
|
||
const emit = defineEmits<{
|
||
(e: 'success', data: any): void
|
||
(e: 'loading-change', value: boolean): void
|
||
}>()
|
||
|
||
const manualLoading = ref(false)
|
||
const manualWarehouseIdsText = ref('')
|
||
const manualForm = reactive({
|
||
warehouseId: undefined as number | undefined,
|
||
queryTimeoutMs: undefined as number | undefined,
|
||
executionTimeoutMs: undefined as number | undefined
|
||
})
|
||
|
||
function parseWarehouseIds(value: string): number[] {
|
||
return value
|
||
.split(',')
|
||
.map((item) => item.trim())
|
||
.filter((item) => !!item)
|
||
.map((item) => Number(item))
|
||
.filter((item) => Number.isFinite(item))
|
||
}
|
||
|
||
function buildPayload() {
|
||
const warehouseIds = parseWarehouseIds(manualWarehouseIdsText.value)
|
||
const payload: Record<string, any> = {}
|
||
if (manualForm.warehouseId) payload.warehouseId = manualForm.warehouseId
|
||
if (warehouseIds.length) payload.warehouseIds = warehouseIds
|
||
if (manualForm.queryTimeoutMs) payload.queryTimeoutMs = manualForm.queryTimeoutMs
|
||
if (manualForm.executionTimeoutMs) payload.executionTimeoutMs = manualForm.executionTimeoutMs
|
||
return payload
|
||
}
|
||
|
||
async function submitManualOutbound() {
|
||
if (manualLoading.value) return null
|
||
manualLoading.value = true
|
||
emit('loading-change', true)
|
||
try {
|
||
const res: any = await orderOutboundOrder.manualOutboundOrder(buildPayload())
|
||
if (!res || ![1, 200].includes(res.code)) {
|
||
throw new Error(res?.message || '手动出库迁移失败')
|
||
}
|
||
const data = res.data || null
|
||
ElMessage.success('手动出库迁移已执行')
|
||
emit('success', data)
|
||
return data
|
||
} catch (error: any) {
|
||
ElMessage.error(error?.message || '手动出库迁移失败')
|
||
throw error
|
||
} finally {
|
||
manualLoading.value = false
|
||
emit('loading-change', false)
|
||
}
|
||
}
|
||
|
||
defineExpose({
|
||
submitManualOutbound
|
||
})
|
||
</script>
|
||
|
||
<style scoped lang="scss">
|
||
.manual-form {
|
||
display: grid;
|
||
grid-template-columns: 180px minmax(280px, 1fr) 160px 160px auto;
|
||
gap: 10px;
|
||
margin-bottom: 12px;
|
||
}
|
||
|
||
.action-wrap {
|
||
display: flex;
|
||
justify-content: flex-end;
|
||
}
|
||
</style>
|