出入库 编辑页面 子表单验证

出入库 编辑页面 子表单验证
pull/1/head
siontion 9 months ago
parent d03b24a66c
commit 6494feaf65

@ -4,6 +4,7 @@
<span v-text="dialogTitle"></span>
</template>
<el-form ref="formRef" :model="formData" :rules="formRules" label-width="100px" v-loading="formLoading">
<!-- 基础信息 -->
<el-card class="hl-card-info">
<template #header>
<div class="hl-card-info-icona"></div><span class="hl-card-info-text">基础信息</span>
@ -78,7 +79,7 @@
</el-col>
</el-row>
</el-card>
<!-- 物料信息 -->
<el-card class="hl-card-info">
<template #header>
<div class="hl-card-info-icona"></div><span class="hl-card-info-text">物料信息</span>
@ -89,15 +90,19 @@
<el-col>
<el-button class="hl-addbutton" type="primary" size="large" @click="onAddItem"></el-button>
</el-col>
<el-table :data="formData.productBomItemDOList" class="hl-table">
<el-form ref="matSubFormRef" :model="formData.matItemDOList" :rules="subFormRules"
v-loading="subFormLoading" label-width="0">
<el-table :data="formData.matItemDOList" class="hl-table">
<el-table-column prop="cid" label="序号" :width="80" />
<el-table-column prop="matId" label="物料编码">
<template #default="scope">
<el-form-item :prop="`${scope.$index}.matId`" :rules="subFormRules.matId" class="mb-0px!">
<el-select v-model="scope.row.matId" placeholder="物料编码" :remote-method="remoteMatCodeSearch"
remote-show-suffix remote clearable reserve-keyword filterable :loading="matSelectLoading"
@change="(val) => handleMatCode(scope, val)" class="!w-180px">
<el-option v-for="item in matList" :key="item.id" :label="item.code" :value="item.id" />
</el-select>
</el-form-item>
</template>
</el-table-column>
<el-table-column prop="matName" label="物料名称">
@ -129,16 +134,21 @@
</el-table-column>
<el-table-column prop="rgId" width="140" label="入库库区" required>
<template #default="scope">
<el-form-item :prop="`${scope.$index}.rgId`" :rules="subFormRules.rgId" class="mb-0px!">
<el-select v-model="scope.row.rgId" placeholder="" style="width: 100%" @change="handleRg(scope)">
<el-option v-for="dict in rgList" :key="dict.id" :label="dict.rgName" :value="dict.id" />
</el-select>
</el-form-item>
</template>
</el-table-column>
<el-table-column prop="pnId" width="140" label="入库库位" required>
<template #default="scope">
<el-form-item :prop="`${scope.$index}.pnId`" :rules="subFormRules.pnId" class="mb-0px!">
<el-select v-model="scope.row.pnId" placeholder="" style="width: 100%">
<el-option v-for="dict in scope.row.pnlist" :key="dict.id" :label="dict.pnName" :value="dict.id" />
<el-option v-for="dict in scope.row.pnlist" :key="dict.id" :label="dict.pnName"
:value="dict.id" />
</el-select>
</el-form-item>
</template>
</el-table-column>
<el-table-column prop="storageOkQty" width="120" label="入库数量" required>
@ -173,11 +183,12 @@
</template>
</el-table-column>
</el-table>
</el-form>
</el-card>
</el-col>
</el-row>
</el-card>
<!-- 附件信息 -->
<el-card class="hl-card-info">
<template #header>
<div class="hl-card-info-icona"></div><span class="hl-card-info-text">附件信息</span>
@ -222,6 +233,7 @@
</el-col>
</el-row>
</el-card>
<!-- 系统信息 -->
<el-card class="hl-card-info">
<template #header>
<div class="hl-card-info-icona"></div><span class="hl-card-info-text">系统信息</span>
@ -299,7 +311,6 @@ const message = useMessage() // 消息弹窗
const router = useRoute();
const isShow = ref(false)
const dialogVisible = ref(false) //
const dialogTitle = ref('') //
const formLoading = ref(false) // 12
const formType = ref('') // create - update -
@ -321,7 +332,7 @@ const formData = ref({
outboundTime: undefined,
cancel: undefined,
cancelTime: undefined,
productBomItemDOList: [],
matItemDOList: [],
attachments: []
})
const formRules = reactive({
@ -331,6 +342,14 @@ const formRules = reactive({
whId: [{ required: true, message: '入库仓库不能为空', trigger: 'blur' }]
})
const formRef = ref() // Ref
const matSubFormRef = ref() // Ref
const subFormLoading = ref(false) //
const subFormRules = reactive({
matId: [{ required: true, message: '物料不能为空', trigger: 'blur' }],
rgId: [{ required: true, message: '库区不能为空', trigger: 'blur' }],
pnId: [{ required: true, message: '库位不能为空', trigger: 'blur' }],
})
const userList = ref<UserApi.UserVO[]>([]) //
@ -388,6 +407,12 @@ const emit = defineEmits(['success']) // 定义 success 事件,用于操作成
const submitForm = async () => {
//
await formRef.value.validate()
//
try {
await matSubFormRef.value.validate()
} catch (e) {
return
}
//
formLoading.value = true
try {
@ -404,11 +429,11 @@ const submitForm = async () => {
commonResult = 'common.updateSuccess'
}
//
formData.value.productBomItemDOList.forEach(item => {
formData.value.matItemDOList.forEach(item => {
item.stockId = storageid.value
item.whId = formData.value.whId
})
const dataMats = formData.value.productBomItemDOList as unknown as StorageMatApi.StorageMatVO[]
const dataMats = formData.value.matItemDOList as unknown as StorageMatApi.StorageMatVO[]
await StorageMatApi.createStorageMatBatch(dataMats)
//
@ -448,13 +473,13 @@ const onAddItem = () => {
productBomItemValueDOList: []
}
matCount = matCount + 1
formData.value.productBomItemDOList.push(newData)
formData.value.matItemDOList.push(newData)
}
//
const handlefuke = (index, item) => {
const data: any = formData.value.productBomItemDOList[index]
const data: any = formData.value.matItemDOList[index]
//
const newData: any = {
@ -478,13 +503,13 @@ const handlefuke = (index, item) => {
}
matCount = matCount + 1
//
formData.value.productBomItemDOList.splice(index + 1, 0, newData)
formData.value.matItemDOList.splice(index + 1, 0, newData)
}
//
const handleDelete2 = (index: number) => {
formData.value.productBomItemDOList.splice(index, 1)
formData.value.matItemDOList.splice(index, 1)
}
//
@ -506,7 +531,7 @@ const handleWh = (async (wid) => {
pnList.value = []
rgList.value = dataRg.list
formData.value.productBomItemDOList.forEach(item => {
formData.value.matItemDOList.forEach(item => {
item.rgId = ''
item.pnId = ''
item.pnlist.value = []
@ -564,6 +589,8 @@ const handleMatCode = async (scope, matid) => {
}
}
const isShowBtnStatus = false
const isShowBtnCancel = false
/** 初始化 **/
onMounted(async () => {
@ -594,8 +621,8 @@ onMounted(async () => {
const queryParamsRg = reactive({
pageNo: 1,
pageSize: 99,
status:1,
whId : formData.value.whId
status: 1,
whId: formData.value.whId
})
const dataRg = await RgApi.getRgPage(queryParamsRg)
@ -618,7 +645,7 @@ onMounted(async () => {
stockId: router.query.id
})
const dataMats = await StorageMatApi.getStorageMatPage(queryParamsMat)
formData.value.productBomItemDOList = dataMats.list
formData.value.matItemDOList = dataMats.list
//
const queryParamsMat2 = reactive({
@ -628,7 +655,7 @@ onMounted(async () => {
})
const matVos = await MaterialApi.getMaterialPage(queryParamsMat2)
formData.value.productBomItemDOList.forEach(item => {
formData.value.matItemDOList.forEach(item => {
item.cid = matCount
item.matId = matVos.list.find((record) => record.id === item.matId)?.id
//item.matCode = matVos.list.find( (record) => record.id === item.matId)?.id
@ -637,11 +664,9 @@ onMounted(async () => {
item.matType = matVos.list.find((record) => record.id === item.matId)?.materialType
item.matUnit = matVos.list.find((record) => record.id === item.matId)?.unit
item.pnlist = pnList.value.filter((pn) => pn.rgId === item.rgId)
matCount= matCount+1
matCount = matCount + 1
})
//
//
let attParams = {
@ -653,6 +678,7 @@ onMounted(async () => {
formData.value.attachments = (await getFilePage(attParams)).list;
}
//
userList.value = await UserApi.getSimpleUserList()
})

Loading…
Cancel
Save