feat(mes): 更新盘点方案参数类型枚举及相关逻辑

pull/871/MERGE
YunaiV 2026-03-09 22:58:32 +08:00
parent 9a6cd0f6cb
commit 0559f8eccd
3 changed files with 46 additions and 119 deletions

View File

@ -251,13 +251,13 @@ export const MesWmStockTakingTaskLineStatusEnum = {
} }
/** MES 盘点方案参数类型枚举 */ /** MES 盘点方案参数类型枚举 */
// TODO @AI感觉这个枚举不太对看看 biz type
export const MesWmStockTakingParamTypeEnum = { export const MesWmStockTakingParamTypeEnum = {
WAREHOUSE: 1, WAREHOUSE: 102,
LOCATION: 2, LOCATION: 103,
AREA: 3, AREA: 104,
ITEM: 4, ITEM: 600,
BATCH: 5 BATCH: 107,
QUALITY_STATUS: 900
} }
/** MES 外协入库单状态枚举 */ /** MES 外协入库单状态枚举 */

View File

@ -1,4 +1,3 @@
<!-- DONE @AI当前基础信息区已按 1 3 列布局展示时间字段保留 12 栅格以兼容日期时间选择器 -->
<template> <template>
<Dialog :title="dialogTitle" v-model="dialogVisible" width="1100px"> <Dialog :title="dialogTitle" v-model="dialogVisible" width="1100px">
<el-form <el-form

View File

@ -5,14 +5,14 @@
type="primary" type="primary"
plain plain
@click="openForm('create')" @click="openForm('create')"
:disabled="disabled || (isRemoteMode && !planId)" :disabled="disabled"
class="mb-10px" class="mb-10px"
> >
<Icon icon="ep:plus" class="mr-5px" /> 添加条件 <Icon icon="ep:plus" class="mr-5px" /> 添加条件
</el-button> </el-button>
<el-table <el-table
v-loading="loading" v-loading="loading"
:data="displayList" :data="list"
:stripe="true" :stripe="true"
:show-overflow-tooltip="true" :show-overflow-tooltip="true"
border border
@ -32,7 +32,6 @@
</el-table-column> </el-table-column>
</el-table> </el-table>
<Pagination <Pagination
v-if="isRemoteMode"
:total="total" :total="total"
v-model:page="queryParams.pageNo" v-model:page="queryParams.pageNo"
v-model:limit="queryParams.pageSize" v-model:limit="queryParams.pageSize"
@ -67,15 +66,12 @@
</el-select> </el-select>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="24"> <el-col :span="24" v-if="formData.type">
<el-form-item label="条件值" prop="valueId"> <el-form-item label="条件值" prop="valueId">
<template v-if="formData.type === BarcodeBizTypeEnum.WAREHOUSE"> <template v-if="formData.type === MesWmStockTakingParamTypeEnum.WAREHOUSE">
<WmWarehouseSelect <WmWarehouseSelect v-model="formData.valueId" @change="handleSelectorChange" />
v-model="formData.valueId"
@change="(item) => handleSelectorChange(item)"
/>
</template> </template>
<template v-else-if="formData.type === BarcodeBizTypeEnum.LOCATION"> <template v-else-if="formData.type === MesWmStockTakingParamTypeEnum.LOCATION">
<div class="space-y-2"> <div class="space-y-2">
<WmWarehouseSelect <WmWarehouseSelect
v-model="locationWarehouseId" v-model="locationWarehouseId"
@ -84,15 +80,16 @@
placeholder="请选择仓库" placeholder="请选择仓库"
/> />
<WmWarehouseLocationSelect <WmWarehouseLocationSelect
v-if="locationWarehouseId"
v-model="formData.valueId" v-model="formData.valueId"
:warehouse-id="locationWarehouseId" :warehouse-id="locationWarehouseId"
@change="(item) => handleSelectorChange(item)" @change="handleSelectorChange"
class="!w-1/1" class="!w-1/1"
placeholder="请选择库区" placeholder="请选择库区"
/> />
</div> </div>
</template> </template>
<template v-else-if="formData.type === BarcodeBizTypeEnum.AREA"> <template v-else-if="formData.type === MesWmStockTakingParamTypeEnum.AREA">
<div class="space-y-2"> <div class="space-y-2">
<WmWarehouseSelect <WmWarehouseSelect
v-model="areaWarehouseId" v-model="areaWarehouseId"
@ -101,6 +98,7 @@
placeholder="请选择仓库" placeholder="请选择仓库"
/> />
<WmWarehouseLocationSelect <WmWarehouseLocationSelect
v-if="areaWarehouseId"
v-model="areaLocationId" v-model="areaLocationId"
:warehouse-id="areaWarehouseId" :warehouse-id="areaWarehouseId"
@change="handleAreaLocationChange" @change="handleAreaLocationChange"
@ -108,24 +106,27 @@
placeholder="请选择库区" placeholder="请选择库区"
/> />
<WmWarehouseAreaSelect <WmWarehouseAreaSelect
v-if="areaLocationId"
v-model="formData.valueId" v-model="formData.valueId"
:warehouse-id="areaWarehouseId" :warehouse-id="areaWarehouseId"
@change="(item) => handleSelectorChange(item)" @change="handleSelectorChange"
class="!w-1/1" class="!w-1/1"
placeholder="请选择库位" placeholder="请选择库位"
/> />
</div> </div>
</template> </template>
<template v-else-if="formData.type === BarcodeBizTypeEnum.ITEM"> <template v-else-if="formData.type === MesWmStockTakingParamTypeEnum.ITEM">
<MdItemSelect <MdItemSelect v-model="formData.valueId" @change="handleSelectorChange" />
v-model="formData.valueId"
@change="(item) => handleSelectorChange(item)"
/>
</template> </template>
<template v-else> <template v-else-if="formData.type === MesWmStockTakingParamTypeEnum.BATCH || formData.type === MesWmStockTakingParamTypeEnum.QUALITY_STATUS">
<!-- TODO @芋艿后续来跟进 -->
<el-row :gutter="8" class="w-full"> <el-row :gutter="8" class="w-full">
<el-col :span="8"> <el-col :span="8">
<el-input v-model="formData.valueId" placeholder="值ID" @change="handleManualChange" /> <el-input
v-model="formData.valueId"
placeholder="值ID"
@change="handleManualChange"
/>
</el-col> </el-col>
<el-col :span="8"> <el-col :span="8">
<el-input <el-input
@ -165,7 +166,7 @@ import {
StockTakingPlanParamApi, StockTakingPlanParamApi,
type StockTakingPlanParamVO type StockTakingPlanParamVO
} from '@/api/mes/wm/stocktaking/plan/param/index' } from '@/api/mes/wm/stocktaking/plan/param/index'
import { BarcodeBizTypeEnum } from '@/views/mes/utils/constants' import { MesWmStockTakingParamTypeEnum } from '@/views/mes/utils/constants'
import WmWarehouseSelect from '@/views/mes/wm/warehouse/components/WmWarehouseSelect.vue' import WmWarehouseSelect from '@/views/mes/wm/warehouse/components/WmWarehouseSelect.vue'
import WmWarehouseLocationSelect from '@/views/mes/wm/warehouse/components/WmWarehouseLocationSelect.vue' import WmWarehouseLocationSelect from '@/views/mes/wm/warehouse/components/WmWarehouseLocationSelect.vue'
import WmWarehouseAreaSelect from '@/views/mes/wm/warehouse/components/WmWarehouseAreaSelect.vue' import WmWarehouseAreaSelect from '@/views/mes/wm/warehouse/components/WmWarehouseAreaSelect.vue'
@ -175,25 +176,9 @@ import { WmWarehouseAreaApi } from '@/api/mes/wm/warehouse/area'
defineOptions({ name: 'StockTakingPlanParamList' }) defineOptions({ name: 'StockTakingPlanParamList' })
interface ParamRow extends StockTakingPlanParamVO { const props = defineProps<{
valueId?: number | string planId: number
} disabled?: boolean
const props = withDefaults(
defineProps<{
modelValue?: ParamRow[]
planId?: number
disabled?: boolean
}>(),
{
modelValue: () => [],
planId: undefined,
disabled: false
}
)
const emit = defineEmits<{
'update:modelValue': [value: ParamRow[]]
}>() }>()
const { t } = useI18n() const { t } = useI18n()
@ -201,7 +186,7 @@ const message = useMessage()
// ==================== ==================== // ==================== ====================
const loading = ref(false) const loading = ref(false)
const list = ref<ParamRow[]>([]) const list = ref<StockTakingPlanParamVO[]>([])
const total = ref(0) const total = ref(0)
const queryParams = reactive({ const queryParams = reactive({
pageNo: 1, pageNo: 1,
@ -209,21 +194,8 @@ const queryParams = reactive({
planId: undefined as number | undefined planId: undefined as number | undefined
}) })
// TODO @AIisRemoteMode
const isRemoteMode = computed(() => !!props.planId)
const localRows = computed({
get: () => props.modelValue || [],
set: (value) => emit('update:modelValue', value)
})
const displayList = computed(() => (isRemoteMode.value ? list.value : localRows.value))
/** 查询条件列表 */ /** 查询条件列表 */
const getList = async () => { const getList = async () => {
if (!isRemoteMode.value || !props.planId) {
list.value = []
total.value = 0
return
}
loading.value = true loading.value = true
try { try {
queryParams.planId = props.planId queryParams.planId = props.planId
@ -236,23 +208,12 @@ const getList = async () => {
} }
/** 删除 */ /** 删除 */
const handleDelete = async (row: ParamRow) => { const handleDelete = async (row: StockTakingPlanParamVO) => {
try { try {
await message.delConfirm() await message.delConfirm()
if (isRemoteMode.value && row.id) { await StockTakingPlanParamApi.deleteStockTakingPlanParam(row.id!)
await StockTakingPlanParamApi.deleteStockTakingPlanParam(row.id)
message.success(t('common.delSuccess'))
// TODO @AI
// 1
if (list.value.length === 1 && queryParams.pageNo > 1) {
queryParams.pageNo -= 1
}
await getList()
return
}
localRows.value = localRows.value.filter((item) => item !== row)
message.success(t('common.delSuccess')) message.success(t('common.delSuccess'))
await getList()
} catch {} } catch {}
} }
@ -261,10 +222,10 @@ const dialogVisible = ref(false)
const dialogTitle = ref('') const dialogTitle = ref('')
const formLoading = ref(false) const formLoading = ref(false)
const formType = ref('') const formType = ref('')
const formData = ref<ParamRow>({ const formData = ref<StockTakingPlanParamVO>({
id: undefined, id: undefined,
planId: undefined, planId: undefined,
type: BarcodeBizTypeEnum.WAREHOUSE, type: undefined,
valueId: undefined, valueId: undefined,
valueCode: '', valueCode: '',
valueName: '', valueName: '',
@ -275,7 +236,6 @@ const formRules = reactive({
valueId: [{ required: true, message: '条件值不能为空', trigger: 'change' }] valueId: [{ required: true, message: '条件值不能为空', trigger: 'change' }]
}) })
const formRef = ref() const formRef = ref()
const editingIndex = ref<number>(-1)
const locationWarehouseId = ref<number>() // const locationWarehouseId = ref<number>() //
const areaWarehouseId = ref<number>() // const areaWarehouseId = ref<number>() //
@ -292,20 +252,13 @@ const openForm = async (type: string, id?: number) => {
formLoading.value = true formLoading.value = true
isLoadingData.value = true isLoadingData.value = true
try { try {
formData.value = (await StockTakingPlanParamApi.getStockTakingPlanParam(id)) as ParamRow formData.value = await StockTakingPlanParamApi.getStockTakingPlanParam(id)
// //
await loadCascadeData() await loadCascadeData()
} finally { } finally {
formLoading.value = false formLoading.value = false
isLoadingData.value = false isLoadingData.value = false
} }
} else if (type === 'update') {
//
const row = localRows.value.find((item) => item === id)
if (row) {
formData.value = { ...row }
editingIndex.value = localRows.value.findIndex((item) => item === row)
}
} }
} }
@ -319,31 +272,15 @@ const submitForm = async () => {
planId: props.planId, planId: props.planId,
valueId: Number(formData.value.valueId) valueId: Number(formData.value.valueId)
} as StockTakingPlanParamVO } as StockTakingPlanParamVO
if (isRemoteMode.value && props.planId) {
if (formType.value === 'create') {
await StockTakingPlanParamApi.createStockTakingPlanParam(data)
message.success(t('common.createSuccess'))
} else {
await StockTakingPlanParamApi.updateStockTakingPlanParam(data)
message.success(t('common.updateSuccess'))
}
dialogVisible.value = false
await getList()
return
}
//
const nextRows = [...localRows.value]
if (formType.value === 'create') { if (formType.value === 'create') {
nextRows.push({ ...data, planId: undefined }) await StockTakingPlanParamApi.createStockTakingPlanParam(data)
message.success(t('common.createSuccess')) message.success(t('common.createSuccess'))
} else if (editingIndex.value > -1) { } else {
nextRows.splice(editingIndex.value, 1, { ...data, planId: undefined }) await StockTakingPlanParamApi.updateStockTakingPlanParam(data)
message.success(t('common.updateSuccess')) message.success(t('common.updateSuccess'))
} }
localRows.value = nextRows
dialogVisible.value = false dialogVisible.value = false
await getList()
} finally { } finally {
formLoading.value = false formLoading.value = false
} }
@ -354,13 +291,12 @@ const resetForm = () => {
formData.value = { formData.value = {
id: undefined, id: undefined,
planId: props.planId, planId: props.planId,
type: BarcodeBizTypeEnum.WAREHOUSE, type: undefined,
valueId: undefined, valueId: undefined,
valueCode: '', valueCode: '',
valueName: '', valueName: '',
remark: '' remark: ''
} }
editingIndex.value = -1
formRef.value?.resetFields() formRef.value?.resetFields()
} }
@ -428,14 +364,14 @@ const loadCascadeData = async () => {
} }
try { try {
// ID // ID
if (formData.value.type === BarcodeBizTypeEnum.LOCATION) { if (formData.value.type === MesWmStockTakingParamTypeEnum.LOCATION) {
const location = await WmWarehouseLocationApi.getWarehouseLocation(formData.value.valueId) const location = await WmWarehouseLocationApi.getWarehouseLocation(formData.value.valueId)
if (location?.warehouseId) { if (location?.warehouseId) {
locationWarehouseId.value = location.warehouseId locationWarehouseId.value = location.warehouseId
} }
} }
// IDID // IDID
else if (formData.value.type === BarcodeBizTypeEnum.AREA) { else if (formData.value.type === MesWmStockTakingParamTypeEnum.AREA) {
const area = await WmWarehouseAreaApi.getWarehouseArea(formData.value.valueId) const area = await WmWarehouseAreaApi.getWarehouseArea(formData.value.valueId)
if (area?.warehouseId) { if (area?.warehouseId) {
areaWarehouseId.value = area.warehouseId areaWarehouseId.value = area.warehouseId
@ -452,15 +388,7 @@ const loadCascadeData = async () => {
/** 监听 planId 变化 */ /** 监听 planId 变化 */
watch( watch(
() => props.planId, () => props.planId,
async (value) => { async () => {
resetForm()
if (!value) {
queryParams.planId = undefined
queryParams.pageNo = 1
list.value = []
total.value = 0
return
}
queryParams.pageNo = 1 queryParams.pageNo = 1
await getList() await getList()
}, },