From 4d8db47ca6e8ad9986fa80f7b5819646ea494d98 Mon Sep 17 00:00:00 2001 From: Admin <978517621@qq.com> Date: 星期五, 30 九月 2022 09:58:21 +0800 Subject: [PATCH] Default Changelist --- src/views/specialWorkSystem/workTicket/workApply/components/broken.vue | 32 +++++++++++++++++++++++++++++--- 1 files changed, 29 insertions(+), 3 deletions(-) diff --git a/src/views/specialWorkSystem/workTicket/workApply/components/broken.vue b/src/views/specialWorkSystem/workTicket/workApply/components/broken.vue index 1c32a26..7c7e821 100644 --- a/src/views/specialWorkSystem/workTicket/workApply/components/broken.vue +++ b/src/views/specialWorkSystem/workTicket/workApply/components/broken.vue @@ -133,13 +133,13 @@ <el-form label-width="150px" label-position="top"> <div v-if="item.mustList.length>0" style="width: 100%;border-bottom: 1px solid #ccc;padding-bottom: 6px;margin-bottom: 10px;font-weight: bolder">必选</div> <el-form-item v-if="item.mustList.length>0" class="tab-i" v-for="(i,x) in item.mustList" :key="x" :label="item.mustList[x].materialName + ':'" prop="defaultVal" :rules="[{ type: 'defaultVal', required: true, message: '该内容不能为空', trigger: 'blur'}]"> - <el-input size="default" type="number" v-model="item.mustList[x].value" placeholder="请输入配置数量,空值默认为0"> + <el-input size="default" type="number" v-model="item.mustList[x].value" @change="(val)=>toZero(val,index,'mustList',x)" placeholder="请输入配置数量,空值默认为0"> <template #append>{{'库存:' + item.mustList[x].stock}}</template> </el-input> </el-form-item> <div v-if="item.unList.length>0" style="width: 100%;border-bottom: 1px solid #ccc;padding-bottom: 6px;margin-bottom: 10px;font-weight: bolder">其他</div> <el-form-item v-if="item.unList.length>0" class="tab-i" v-for="(i,x) in item.unList" :key="x" :label="item.unList[x].materialName + ':'"> - <el-input size="default" type="number" v-model="item.unList[x].value" placeholder="请输入配置数量,空值默认为0"> + <el-input size="default" type="number" v-model="item.unList[x].value" @change="(val)=>toZero(val,index,'unList',x)" placeholder="请输入配置数量,空值默认为0"> <template #append>{{'库存:' + item.unList[x].stock}}</template> </el-input> </el-form-item> @@ -283,11 +283,36 @@ "workDetail.bcPath": [{ required: true, message: '该内容不能为空', trigger: 'blur' }], "workDetail.involvedDepIds": [{ required: true, message: '该内容不能为空', trigger: 'blur' }] }); + + const toZero = (value: string | number,index: number,name: string,x:number) =>{ + if(!value){ + state.materialList[index][name][x].value = 0 + } + } + const submitForm = async (formEl: FormInstance | undefined) => { if (!formEl) return await formEl.validate(async (valid, fields) => { if (valid) { for(let i in state.materialList){ + for(let j in state.materialList[i].mustList){ + if(state.materialList[i].mustList[j].value>state.materialList[i].mustList[j].stock){ + ElMessage({ + type: 'warning', + message: '部分物资库存不足,请重新配置数量。' + }); + return + } + } + for(let j in state.materialList[i].unList){ + if(state.materialList[i].unList[j].value>state.materialList[i].unList[j].stock){ + ElMessage({ + type: 'warning', + message: '部分物资库存不足,请重新配置数量。' + }); + return + } + } state.materialList[i].mustList = state.materialList[i].mustList.map((item:any)=>{ const obj = { defaultVal: item.value, @@ -319,13 +344,13 @@ formEl.resetFields() state.form.workDetail.bcPath = [] state.fileList = [] - state.materialList = [] } else { ElMessage({ type: 'warning', message: res.data.msg }); } + state.materialList = [] } else { console.log('error submit!', fields) } @@ -538,6 +563,7 @@ Search, ruleFormRef, applyRules, + toZero, getMaList, conFirmDevices, closeMaterial, -- Gitblit v1.9.2