Admin
2022-09-30 4d8db47ca6e8ad9986fa80f7b5819646ea494d98
src/views/specialWorkSystem/workTicket/workApply/components/fire.vue
@@ -115,13 +115,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>
@@ -253,7 +253,11 @@
         onMounted(() => {
         });
         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) => {
@@ -266,6 +270,24 @@
                     return
                  }
                  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,
@@ -294,13 +316,13 @@
                           message: '提交成功!'
                        });
                        formEl.resetFields()
                        state.materialList = []
                  } else {
                     ElMessage({
                        type: 'warning',
                        message: res.data.msg
                     });
                  }
                  state.materialList = []
               } else {
                  console.log('error submit!', fields)
               }
@@ -359,6 +381,7 @@
               state.equipmentDialog = true
            }
         }
         const conFirmDevices = ()=>{
            for(let i in state.materialList){
               for(let j in state.materialList[i].mustList){
@@ -379,7 +402,6 @@
                     return
                  }
               }
            }
            ElMessageBox.confirm('是否确认物资及数量配置?')
               .then(() => {
@@ -404,6 +426,7 @@
            Search,
            ruleFormRef,
            applyRules,
            toZero,
            getMaList,
            conFirmDevices,
            closeMaterial,