✨ feat(mes): 添加盘点结果的创建、更新和删除功能
parent
567ed338c8
commit
6f97a7b473
|
|
@ -49,6 +49,10 @@ export const StockTakingApi = {
|
||||||
return await request.put({ url: '/mes/wm/stocktaking-task/cancel', params: { id } })
|
return await request.put({ url: '/mes/wm/stocktaking-task/cancel', params: { id } })
|
||||||
},
|
},
|
||||||
|
|
||||||
|
finishStockTaking: async (id: number) => {
|
||||||
|
return await request.put({ url: '/mes/wm/stocktaking-task/finish', data: { id } })
|
||||||
|
},
|
||||||
|
|
||||||
exportStockTaking: async (params: any) => {
|
exportStockTaking: async (params: any) => {
|
||||||
return await request.download({ url: '/mes/wm/stocktaking-task/export-excel', params })
|
return await request.download({ url: '/mes/wm/stocktaking-task/export-excel', params })
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,10 @@ export const StockTakingTaskLineApi = {
|
||||||
return await request.get({ url: '/mes/wm/stocktaking-task-line/page', params })
|
return await request.get({ url: '/mes/wm/stocktaking-task-line/page', params })
|
||||||
},
|
},
|
||||||
|
|
||||||
|
getStockTakingTaskLineSimpleList: async (taskId: number) => {
|
||||||
|
return await request.get({ url: '/mes/wm/stocktaking-task-line/simple-list', params: { taskId } })
|
||||||
|
},
|
||||||
|
|
||||||
getStockTakingTaskLine: async (id: number) => {
|
getStockTakingTaskLine: async (id: number) => {
|
||||||
return await request.get({ url: '/mes/wm/stocktaking-task-line/get', params: { id } })
|
return await request.get({ url: '/mes/wm/stocktaking-task-line/get', params: { id } })
|
||||||
},
|
},
|
||||||
|
|
@ -45,3 +49,20 @@ export const StockTakingTaskLineApi = {
|
||||||
return await request.delete({ url: '/mes/wm/stocktaking-task-line/delete?id=' + id })
|
return await request.delete({ url: '/mes/wm/stocktaking-task-line/delete?id=' + id })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface StockTakingTaskLineSimpleVO {
|
||||||
|
id: number
|
||||||
|
itemId: number
|
||||||
|
itemCode: string
|
||||||
|
itemName: string
|
||||||
|
specification?: string
|
||||||
|
unitMeasureName?: string
|
||||||
|
batchCode?: string
|
||||||
|
warehouseId: number
|
||||||
|
warehouseName: string
|
||||||
|
locationId?: number
|
||||||
|
locationName?: string
|
||||||
|
areaId?: number
|
||||||
|
areaName?: string
|
||||||
|
quantity: number
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -28,11 +28,23 @@ export const StockTakingResultApi = {
|
||||||
return await request.get({ url: '/mes/wm/stocktaking-task-result/page', params })
|
return await request.get({ url: '/mes/wm/stocktaking-task-result/page', params })
|
||||||
},
|
},
|
||||||
|
|
||||||
getStockTakingResultList: async (taskId: number) => {
|
getStockTakingResult: async (id: number) => {
|
||||||
return await request.get({ url: '/mes/wm/stocktaking-task-result/list?taskId=' + taskId })
|
return await request.get({ url: '/mes/wm/stocktaking-task-result/get', params: { id } })
|
||||||
},
|
},
|
||||||
|
|
||||||
exportStockTakingResult: async (params: any) => {
|
getStockTakingResultList: async (params: any) => {
|
||||||
return await request.download({ url: '/mes/wm/stocktaking-task-result/export-excel', params })
|
return await request.get({ url: '/mes/wm/stocktaking-task-result/list', params })
|
||||||
|
},
|
||||||
|
|
||||||
|
createStockTakingResult: async (data: StockTakingResultVO) => {
|
||||||
|
return await request.post({ url: '/mes/wm/stocktaking-task-result/create', data })
|
||||||
|
},
|
||||||
|
|
||||||
|
updateStockTakingResult: async (data: StockTakingResultVO) => {
|
||||||
|
return await request.put({ url: '/mes/wm/stocktaking-task-result/update', data })
|
||||||
|
},
|
||||||
|
|
||||||
|
deleteStockTakingResult: async (id: number) => {
|
||||||
|
return await request.delete({ url: '/mes/wm/stocktaking-task-result/delete?id=' + id })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -112,17 +112,24 @@
|
||||||
</el-row>
|
</el-row>
|
||||||
</el-form>
|
</el-form>
|
||||||
|
|
||||||
<el-tabs v-if="formData.id" type="border-card" class="mt-16px">
|
<el-tabs v-if="formData.id" v-model="activeTab" type="border-card" class="mt-16px">
|
||||||
<el-tab-pane v-if="!formData.blindFlag" label="盘点清单">
|
<el-tab-pane v-if="!formData.blindFlag" label="盘点清单" name="lines">
|
||||||
<StockTakingTaskLineList :task-id="formData.id" :form-type="formType" />
|
<StockTakingTaskLineList :task-id="formData.id" :form-type="formType" />
|
||||||
</el-tab-pane>
|
</el-tab-pane>
|
||||||
<el-tab-pane v-if="resultVisible" label="盘点结果">
|
<el-tab-pane v-if="resultVisible || isExecute" label="盘点结果" name="results">
|
||||||
<StockTakingTaskResultList :task-id="formData.id" />
|
<StockTakingTaskResultList
|
||||||
|
ref="resultListRef"
|
||||||
|
:task-id="formData.id"
|
||||||
|
:form-type="isExecute ? 'execute' : 'detail'"
|
||||||
|
/>
|
||||||
</el-tab-pane>
|
</el-tab-pane>
|
||||||
</el-tabs>
|
</el-tabs>
|
||||||
|
|
||||||
<template #footer>
|
<template #footer>
|
||||||
<el-button v-if="!isDetail" @click="submitForm" type="primary" :disabled="formLoading">
|
<el-button v-if="isExecute" @click="handleExecute" type="primary" :disabled="formLoading">
|
||||||
|
执行盘点
|
||||||
|
</el-button>
|
||||||
|
<el-button v-else-if="!isDetail" @click="submitForm" type="primary" :disabled="formLoading">
|
||||||
确 定
|
确 定
|
||||||
</el-button>
|
</el-button>
|
||||||
<el-button @click="dialogVisible = false">取 消</el-button>
|
<el-button @click="dialogVisible = false">取 消</el-button>
|
||||||
|
|
@ -155,13 +162,15 @@ const dialogTitle = computed(() => {
|
||||||
const titles = {
|
const titles = {
|
||||||
create: '新增盘点任务',
|
create: '新增盘点任务',
|
||||||
update: '编辑盘点任务',
|
update: '编辑盘点任务',
|
||||||
detail: '盘点任务详情'
|
detail: '盘点任务详情',
|
||||||
|
execute: '执行盘点'
|
||||||
}
|
}
|
||||||
return titles[formType.value] || formType.value
|
return titles[formType.value] || formType.value
|
||||||
}) // 弹窗的标题
|
}) // 弹窗的标题
|
||||||
const formLoading = ref(false) // 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用
|
const formLoading = ref(false) // 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用
|
||||||
const formType = ref('create') // 表单的类型:create - 新增;update - 修改;detail - 详情
|
const formType = ref('create') // 表单的类型:create - 新增;update - 修改;detail - 详情;execute - 执行盘点
|
||||||
const isDetail = computed(() => formType.value === 'detail') // 是否只读
|
const isDetail = computed(() => formType.value === 'detail') // 是否只读
|
||||||
|
const isExecute = computed(() => formType.value === 'execute') // 是否执行盘点模式
|
||||||
const resultVisible = computed(
|
const resultVisible = computed(
|
||||||
() => formData.value.status && formData.value.status !== MesWmStockTakingTaskStatusEnum.PREPARE
|
() => formData.value.status && formData.value.status !== MesWmStockTakingTaskStatusEnum.PREPARE
|
||||||
)
|
)
|
||||||
|
|
@ -191,6 +200,8 @@ const formRules = reactive({
|
||||||
userId: [{ required: true, message: '盘点人不能为空', trigger: 'change' }]
|
userId: [{ required: true, message: '盘点人不能为空', trigger: 'change' }]
|
||||||
})
|
})
|
||||||
const formRef = ref() // 表单 Ref
|
const formRef = ref() // 表单 Ref
|
||||||
|
const activeTab = ref('lines') // 当前激活的 tab
|
||||||
|
const resultListRef = ref() // 盘点结果列表 Ref
|
||||||
|
|
||||||
/** 生成任务编码 */
|
/** 生成任务编码 */
|
||||||
const generateCode = () => {
|
const generateCode = () => {
|
||||||
|
|
@ -201,6 +212,7 @@ const generateCode = () => {
|
||||||
const open = async (type: string, id?: number) => {
|
const open = async (type: string, id?: number) => {
|
||||||
dialogVisible.value = true
|
dialogVisible.value = true
|
||||||
formType.value = type
|
formType.value = type
|
||||||
|
activeTab.value = type === 'execute' ? 'results' : 'lines'
|
||||||
resetForm()
|
resetForm()
|
||||||
if (id) {
|
if (id) {
|
||||||
formLoading.value = true
|
formLoading.value = true
|
||||||
|
|
@ -265,4 +277,22 @@ const handlePlanChange = (plan?: StockTakingPlanVO) => {
|
||||||
formData.value.blindFlag = !!plan.blindFlag
|
formData.value.blindFlag = !!plan.blindFlag
|
||||||
formData.value.frozenFlag = !!plan.frozenFlag
|
formData.value.frozenFlag = !!plan.frozenFlag
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 执行盘点 */
|
||||||
|
const handleExecute = async () => {
|
||||||
|
try {
|
||||||
|
await message.confirm('确认执行盘点操作?')
|
||||||
|
formLoading.value = true
|
||||||
|
|
||||||
|
// 完成盘点任务
|
||||||
|
await StockTakingApi.finishStockTaking(formData.value.id!)
|
||||||
|
|
||||||
|
message.success('执行盘点成功')
|
||||||
|
dialogVisible.value = false
|
||||||
|
emit('success')
|
||||||
|
} catch {
|
||||||
|
} finally {
|
||||||
|
formLoading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
|
|
@ -146,7 +146,7 @@ const props = defineProps<{
|
||||||
const { t } = useI18n()
|
const { t } = useI18n()
|
||||||
const message = useMessage()
|
const message = useMessage()
|
||||||
|
|
||||||
const isReadOnly = computed(() => props.formType === 'detail')
|
const isReadOnly = computed(() => props.formType !== 'update')
|
||||||
|
|
||||||
// ==================== 列表 ====================
|
// ==================== 列表 ====================
|
||||||
const loading = ref(false)
|
const loading = ref(false)
|
||||||
|
|
|
||||||
|
|
@ -1,27 +1,144 @@
|
||||||
<!-- MES 盘点任务结果列表子组件 -->
|
<!-- MES 盘点任务结果列表子组件 -->
|
||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
<el-table
|
<el-button
|
||||||
v-loading="loading"
|
v-if="!isReadOnly"
|
||||||
:data="list"
|
v-hasPermi="['mes:wm-stock-taking-task:update']"
|
||||||
:stripe="true"
|
type="primary"
|
||||||
:show-overflow-tooltip="true"
|
plain
|
||||||
border
|
@click="openForm('create')"
|
||||||
|
class="mb-10px"
|
||||||
>
|
>
|
||||||
<el-table-column type="index" label="#" width="60" />
|
<Icon icon="ep:plus" class="mr-5px" /> 新增
|
||||||
<el-table-column label="物料编码" prop="itemCode" min-width="140" />
|
</el-button>
|
||||||
<el-table-column label="物料名称" prop="itemName" min-width="160" />
|
<el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true" border>
|
||||||
<el-table-column label="规格" prop="specification" min-width="120" />
|
<el-table-column label="产品物料编码" align="center" prop="itemCode" min-width="140" />
|
||||||
<el-table-column label="单位" prop="unitMeasureName" width="90" />
|
<el-table-column label="产品物料名称" align="center" prop="itemName" min-width="160" />
|
||||||
<el-table-column label="批次" prop="batchCode" min-width="120" />
|
<el-table-column label="规格型号" align="center" prop="specification" min-width="120" />
|
||||||
<el-table-column label="仓库" prop="warehouseName" min-width="120" />
|
<el-table-column label="单位名称" align="center" prop="unitMeasureName" width="90" />
|
||||||
<el-table-column label="库区" prop="locationName" min-width="120" />
|
<!-- TODO @AI:三个仓库字段 -->
|
||||||
<el-table-column label="库位" prop="areaName" min-width="120" />
|
<el-table-column label="数量" align="center" prop="quantity" min-width="120" />
|
||||||
<el-table-column label="差异数量" prop="quantity" min-width="120" />
|
<el-table-column label="盘点数量" align="center" prop="takingQuantity" min-width="120" />
|
||||||
<el-table-column label="备注" prop="remark" min-width="180" />
|
<el-table-column v-if="!isReadOnly" label="操作" align="center" width="160" fixed="right">
|
||||||
<el-table-column label="生成时间" prop="createTime" min-width="180" />
|
<template #default="scope">
|
||||||
|
<el-button link type="primary" @click="openForm('update', scope.row.id)">编辑</el-button>
|
||||||
|
<el-button link type="danger" @click="handleDelete(scope.row.id)">删除</el-button>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
</el-table>
|
</el-table>
|
||||||
|
<Pagination
|
||||||
|
:total="total"
|
||||||
|
v-model:page="queryParams.pageNo"
|
||||||
|
v-model:limit="queryParams.pageSize"
|
||||||
|
@pagination="getList"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- 添加/编辑弹窗 -->
|
||||||
|
<Dialog :title="dialogTitle" v-model="dialogVisible" width="960px">
|
||||||
|
<el-form
|
||||||
|
ref="formRef"
|
||||||
|
:model="formData"
|
||||||
|
:rules="formRules"
|
||||||
|
label-width="110px"
|
||||||
|
v-loading="formLoading"
|
||||||
|
>
|
||||||
|
<!-- 执行盘点模式:选择盘点清单行 -->
|
||||||
|
<!--
|
||||||
|
TODO @AI:我想是这样的:
|
||||||
|
lineId 是可选的;
|
||||||
|
1)选择了 lineId 的情况下,其他字段(itemId、warehouseId 等)都不可修改,且根据 lineId 自动带出对应的值;
|
||||||
|
2)不选择 lineId 的情况下,其他字段都可以手动选择/
|
||||||
|
-->
|
||||||
|
<el-row v-if="isExecuteMode && dialogFormType === 'create'">
|
||||||
|
<el-col :span="24">
|
||||||
|
<el-form-item label="盘点清单" prop="lineId">
|
||||||
|
<el-select
|
||||||
|
v-model="formData.lineId"
|
||||||
|
placeholder="请选择盘点清单"
|
||||||
|
class="!w-full"
|
||||||
|
@change="handleLineChange"
|
||||||
|
>
|
||||||
|
<el-option
|
||||||
|
v-for="line in taskLineList"
|
||||||
|
:key="line.id"
|
||||||
|
:label="`${line.itemCode} - ${line.itemName} (${line.warehouseName}${line.locationName ? ' / ' + line.locationName : ''}${line.areaName ? ' / ' + line.areaName : ''})`"
|
||||||
|
:value="line.id"
|
||||||
|
/>
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
<!-- 普通模式:手动选择物料和仓库 -->
|
||||||
|
<el-row v-if="!isExecuteMode || dialogFormType === 'update'">
|
||||||
|
<el-col :span="8">
|
||||||
|
<el-form-item label="物料" prop="itemId">
|
||||||
|
<MdItemSelect v-model="formData.itemId" placeholder="请选择物料" />
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="8">
|
||||||
|
<el-form-item label="批次编码" prop="batchCode">
|
||||||
|
<el-input v-model="formData.batchCode" placeholder="请输入批次编码" />
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="8">
|
||||||
|
<el-form-item label="仓库" prop="warehouseId">
|
||||||
|
<WmWarehouseSelect
|
||||||
|
v-model="formData.warehouseId"
|
||||||
|
placeholder="请选择仓库"
|
||||||
|
@change="handleWarehouseChange"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
<el-row v-if="!isExecuteMode || dialogFormType === 'update'">
|
||||||
|
<el-col :span="8" v-if="formData.warehouseId">
|
||||||
|
<el-form-item label="库区" prop="locationId">
|
||||||
|
<WmWarehouseLocationSelect
|
||||||
|
v-model="formData.locationId"
|
||||||
|
:warehouse-id="formData.warehouseId"
|
||||||
|
placeholder="请选择库区"
|
||||||
|
@change="handleLocationChange"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="8" v-if="formData.locationId">
|
||||||
|
<el-form-item label="库位" prop="areaId">
|
||||||
|
<WmWarehouseAreaSelect
|
||||||
|
v-model="formData.areaId"
|
||||||
|
:location-id="formData.locationId"
|
||||||
|
placeholder="请选择库位"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
|
||||||
|
<!-- 差异数量 -->
|
||||||
|
<el-row>
|
||||||
|
<el-col :span="8">
|
||||||
|
<el-form-item label="差异数量" prop="quantity">
|
||||||
|
<el-input-number
|
||||||
|
v-model="formData.quantity"
|
||||||
|
:precision="2"
|
||||||
|
controls-position="right"
|
||||||
|
class="!w-1/1"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
<el-row>
|
||||||
|
<el-col :span="24">
|
||||||
|
<el-form-item label="备注" prop="remark">
|
||||||
|
<el-input v-model="formData.remark" type="textarea" placeholder="请输入备注" />
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
</el-form>
|
||||||
|
<template #footer>
|
||||||
|
<el-button @click="submitForm" type="primary" :disabled="formLoading">确 定</el-button>
|
||||||
|
<el-button @click="dialogVisible = false">取 消</el-button>
|
||||||
|
</template>
|
||||||
|
</Dialog>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
|
@ -29,29 +146,189 @@ import {
|
||||||
StockTakingResultApi,
|
StockTakingResultApi,
|
||||||
type StockTakingResultVO
|
type StockTakingResultVO
|
||||||
} from '@/api/mes/wm/stocktaking/task/result/index'
|
} from '@/api/mes/wm/stocktaking/task/result/index'
|
||||||
|
import {
|
||||||
|
StockTakingTaskLineApi,
|
||||||
|
type StockTakingTaskLineVO
|
||||||
|
} from '@/api/mes/wm/stocktaking/task/line/index'
|
||||||
|
import MdItemSelect from '@/views/mes/md/item/components/MdItemSelect.vue'
|
||||||
|
import WmWarehouseSelect from '@/views/mes/wm/warehouse/components/WmWarehouseSelect.vue'
|
||||||
|
import WmWarehouseLocationSelect from '@/views/mes/wm/warehouse/components/WmWarehouseLocationSelect.vue'
|
||||||
|
import WmWarehouseAreaSelect from '@/views/mes/wm/warehouse/components/WmWarehouseAreaSelect.vue'
|
||||||
|
|
||||||
defineOptions({ name: 'StockTakingTaskResultList' })
|
defineOptions({ name: 'StockTakingTaskResultList' })
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
taskId: number
|
taskId: number
|
||||||
|
formType?: string
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
|
const { t } = useI18n()
|
||||||
|
const message = useMessage()
|
||||||
|
|
||||||
|
const isReadOnly = computed(() => props.formType === 'detail')
|
||||||
|
const isExecuteMode = computed(() => props.formType === 'execute')
|
||||||
|
|
||||||
|
// ==================== 列表 ====================
|
||||||
const loading = ref(false)
|
const loading = ref(false)
|
||||||
const list = ref<StockTakingResultVO[]>([])
|
const list = ref<StockTakingResultVO[]>([])
|
||||||
|
const total = ref(0)
|
||||||
|
const queryParams = reactive({
|
||||||
|
pageNo: 1,
|
||||||
|
pageSize: 10,
|
||||||
|
taskId: undefined as number | undefined
|
||||||
|
})
|
||||||
|
|
||||||
|
/** 查询列表 */
|
||||||
const getList = async () => {
|
const getList = async () => {
|
||||||
if (!props.taskId) return
|
if (!props.taskId) return
|
||||||
loading.value = true
|
loading.value = true
|
||||||
try {
|
try {
|
||||||
list.value = await StockTakingResultApi.getStockTakingResultList(props.taskId)
|
queryParams.taskId = props.taskId
|
||||||
|
const data = await StockTakingResultApi.getStockTakingResultList(queryParams)
|
||||||
|
list.value = data.list
|
||||||
|
total.value = data.total
|
||||||
} finally {
|
} finally {
|
||||||
loading.value = false
|
loading.value = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 删除 */
|
||||||
|
const handleDelete = async (id: number) => {
|
||||||
|
try {
|
||||||
|
await message.delConfirm()
|
||||||
|
await StockTakingResultApi.deleteStockTakingResult(id)
|
||||||
|
message.success(t('common.delSuccess'))
|
||||||
|
await getList()
|
||||||
|
} catch {}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ==================== 添加/编辑表单 ====================
|
||||||
|
const dialogVisible = ref(false)
|
||||||
|
const dialogTitle = ref('')
|
||||||
|
const formLoading = ref(false)
|
||||||
|
const dialogFormType = ref('')
|
||||||
|
const taskLineList = ref<StockTakingTaskLineVO[]>([])
|
||||||
|
const formData = ref({
|
||||||
|
id: undefined,
|
||||||
|
taskId: undefined as number | undefined,
|
||||||
|
lineId: undefined,
|
||||||
|
materialStockId: undefined,
|
||||||
|
itemId: undefined,
|
||||||
|
batchId: undefined,
|
||||||
|
batchCode: undefined,
|
||||||
|
warehouseId: undefined,
|
||||||
|
locationId: undefined,
|
||||||
|
areaId: undefined,
|
||||||
|
quantity: undefined,
|
||||||
|
remark: undefined
|
||||||
|
})
|
||||||
|
const formRules = reactive({
|
||||||
|
lineId: [{ required: true, message: '请选择盘点清单', trigger: 'change' }],
|
||||||
|
quantity: [{ required: true, message: '差异数量不能为空', trigger: 'blur' }]
|
||||||
|
})
|
||||||
|
const formRef = ref()
|
||||||
|
|
||||||
|
/** 打开表单弹窗 */
|
||||||
|
const openForm = async (type: string, id?: number) => {
|
||||||
|
dialogVisible.value = true
|
||||||
|
dialogTitle.value = t('action.' + type)
|
||||||
|
dialogFormType.value = type
|
||||||
|
resetForm()
|
||||||
|
|
||||||
|
// 执行盘点模式下,加载盘点清单列表
|
||||||
|
if (isExecuteMode.value && !id) {
|
||||||
|
formLoading.value = true
|
||||||
|
try {
|
||||||
|
taskLineList.value = await StockTakingTaskLineApi.getStockTakingTaskLineSimpleList(
|
||||||
|
props.taskId
|
||||||
|
)
|
||||||
|
} finally {
|
||||||
|
formLoading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (id) {
|
||||||
|
formLoading.value = true
|
||||||
|
try {
|
||||||
|
formData.value = await StockTakingResultApi.getStockTakingResult(id)
|
||||||
|
} finally {
|
||||||
|
formLoading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 提交表单 */
|
||||||
|
const submitForm = async () => {
|
||||||
|
await formRef.value.validate()
|
||||||
|
formLoading.value = true
|
||||||
|
try {
|
||||||
|
const data = {
|
||||||
|
...formData.value,
|
||||||
|
taskId: props.taskId
|
||||||
|
} as unknown as StockTakingResultVO
|
||||||
|
if (dialogFormType.value === 'create') {
|
||||||
|
await StockTakingResultApi.createStockTakingResult(data)
|
||||||
|
message.success(t('common.createSuccess'))
|
||||||
|
} else {
|
||||||
|
await StockTakingResultApi.updateStockTakingResult(data)
|
||||||
|
message.success(t('common.updateSuccess'))
|
||||||
|
}
|
||||||
|
dialogVisible.value = false
|
||||||
|
await getList()
|
||||||
|
} finally {
|
||||||
|
formLoading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 仓库变化时清空库区和库位 */
|
||||||
|
const handleWarehouseChange = () => {
|
||||||
|
formData.value.locationId = undefined
|
||||||
|
formData.value.areaId = undefined
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 库区变化时清空库位 */
|
||||||
|
const handleLocationChange = () => {
|
||||||
|
formData.value.areaId = undefined
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 盘点清单行变化 */
|
||||||
|
const handleLineChange = (lineId: number) => {
|
||||||
|
const line = taskLineList.value.find((item) => item.id === lineId)
|
||||||
|
if (line) {
|
||||||
|
// TODO @AI:linter 报错;
|
||||||
|
formData.value.materialStockId = line.materialStockId
|
||||||
|
formData.value.itemId = line.itemId
|
||||||
|
formData.value.batchId = line.batchId
|
||||||
|
formData.value.batchCode = line.batchCode
|
||||||
|
formData.value.warehouseId = line.warehouseId
|
||||||
|
formData.value.locationId = line.locationId
|
||||||
|
formData.value.areaId = line.areaId
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 重置表单 */
|
||||||
|
const resetForm = () => {
|
||||||
|
formData.value = {
|
||||||
|
id: undefined,
|
||||||
|
taskId: undefined,
|
||||||
|
lineId: undefined,
|
||||||
|
materialStockId: undefined,
|
||||||
|
itemId: undefined,
|
||||||
|
batchId: undefined,
|
||||||
|
batchCode: undefined,
|
||||||
|
warehouseId: undefined,
|
||||||
|
locationId: undefined,
|
||||||
|
areaId: undefined,
|
||||||
|
quantity: undefined,
|
||||||
|
remark: undefined
|
||||||
|
}
|
||||||
|
formRef.value?.resetFields()
|
||||||
|
}
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
() => props.taskId,
|
() => props.taskId,
|
||||||
() => {
|
() => {
|
||||||
|
queryParams.pageNo = 1
|
||||||
getList()
|
getList()
|
||||||
},
|
},
|
||||||
{ immediate: true }
|
{ immediate: true }
|
||||||
|
|
|
||||||
|
|
@ -105,7 +105,7 @@
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column label="盘点方案" align="center" prop="planName" min-width="180" />
|
<el-table-column label="盘点方案" align="center" prop="planName" min-width="180" />
|
||||||
<el-table-column label="盘点日期" align="center" prop="takingDate" min-width="180" />
|
<el-table-column label="盘点日期" align="center" prop="takingDate" :formatter="dateFormatter2" min-width="180" />
|
||||||
<el-table-column label="盘点人" align="center" prop="userNickname" min-width="120" />
|
<el-table-column label="盘点人" align="center" prop="userNickname" min-width="120" />
|
||||||
<el-table-column label="单据状态" align="center" prop="status" min-width="110">
|
<el-table-column label="单据状态" align="center" prop="status" min-width="110">
|
||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
|
|
@ -132,6 +132,15 @@
|
||||||
>
|
>
|
||||||
提交
|
提交
|
||||||
</el-button>
|
</el-button>
|
||||||
|
<el-button
|
||||||
|
v-if="scope.row.status === MesWmStockTakingTaskStatusEnum.APPROVING"
|
||||||
|
link
|
||||||
|
type="primary"
|
||||||
|
@click="handleExecute(scope.row.id)"
|
||||||
|
v-hasPermi="['mes:wm-stock-taking-task:update']"
|
||||||
|
>
|
||||||
|
执行盘点
|
||||||
|
</el-button>
|
||||||
<el-button
|
<el-button
|
||||||
v-if="scope.row.status === MesWmStockTakingTaskStatusEnum.PREPARE"
|
v-if="scope.row.status === MesWmStockTakingTaskStatusEnum.PREPARE"
|
||||||
link
|
link
|
||||||
|
|
@ -165,6 +174,7 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
import { dateFormatter2 } from '@/utils/formatTime'
|
||||||
import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
|
import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
|
||||||
import download from '@/utils/download'
|
import download from '@/utils/download'
|
||||||
import { StockTakingApi, type StockTakingTaskVO } from '@/api/mes/wm/stocktaking/task/index'
|
import { StockTakingApi, type StockTakingTaskVO } from '@/api/mes/wm/stocktaking/task/index'
|
||||||
|
|
@ -231,6 +241,11 @@ const handleSubmit = async (id: number) => {
|
||||||
} catch {}
|
} catch {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 执行盘点 */
|
||||||
|
const handleExecute = (id: number) => {
|
||||||
|
formRef.value.open('execute', id)
|
||||||
|
}
|
||||||
|
|
||||||
/** 取消任务 */
|
/** 取消任务 */
|
||||||
const handleCancel = async (id: number) => {
|
const handleCancel = async (id: number) => {
|
||||||
try {
|
try {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue