Browse Source

fix:修改笼位申请,数量与周龄只填一个

LYK 1 week ago
parent
commit
42e91ae58f

+ 52 - 28
src/view/animal/application/components/Application.vue

@@ -31,7 +31,7 @@
                 :rules="rules.variety" />
                 :rules="rules.variety" />
               <van-field v-model="state.form.levelName" label="饲养区域" placeholder="请选择" readonly is-link required :rules="rules.levelName"
               <van-field v-model="state.form.levelName" label="饲养区域" placeholder="请选择" readonly is-link required :rules="rules.levelName"
                 @click="showLevelPicker = true" />
                 @click="showLevelPicker = true" />
-              <van-field label="周龄" required :rules="rules.age">
+              <van-field label="周龄(w)" :rules="rules.age">
                 <template #input>
                 <template #input>
                   <div class="range-input-wrapper">
                   <div class="range-input-wrapper">
                     <van-field v-model="state.form.age.min" placeholder="请输入" type="digit" class="range-input" />
                     <van-field v-model="state.form.age.min" placeholder="请输入" type="digit" class="range-input" />
@@ -40,7 +40,7 @@
                   </div>
                   </div>
                 </template>
                 </template>
               </van-field>
               </van-field>
-              <van-field label="体重" required :rules="rules.weight">
+              <van-field label="体重(g)" :rules="rules.weight">
                 <template #input>
                 <template #input>
                   <div class="range-input-wrapper">
                   <div class="range-input-wrapper">
                     <van-field v-model="state.form.weight.min" placeholder="请输入" type="number" class="range-input" />
                     <van-field v-model="state.form.weight.min" placeholder="请输入" type="number" class="range-input" />
@@ -254,19 +254,31 @@ const rules = {
   age: [
   age: [
     {
     {
       validator: () => {
       validator: () => {
-        const value = state.form.age
-        console.log('周龄范围:', value)
-        const min = Number(value?.min)
-        const max = Number(value?.max)
-        if (
-          !value ||
-          value.min === null ||
-          value.min === '' ||
-          value.max === null ||
-          value.max === '' ||
-          isNaN(min) ||
-          isNaN(max)
-        ) {
+        const age = state.form.age
+        const weight = state.form.weight
+        const ageMin = age?.min
+        const ageMax = age?.max
+        const weightMin = weight?.min
+        const weightMax = weight?.max
+        const hasAgeMin = ageMin !== null && ageMin !== ''
+        const hasAgeMax = ageMax !== null && ageMax !== ''
+        const hasWeightMin = weightMin !== null && weightMin !== ''
+        const hasWeightMax = weightMax !== null && weightMax !== ''
+        const isAgeFilled = hasAgeMin && hasAgeMax
+        const isWeightFilled = hasWeightMin && hasWeightMax
+        const hasAgeAny = hasAgeMin || hasAgeMax
+        if (!hasAgeAny && !isWeightFilled) {
+          return '周龄或体重至少填写一个'
+        }
+        if (hasAgeAny && !isAgeFilled) {
+          return '周龄范围不能为空'
+        }
+        if (!isAgeFilled) {
+          return true
+        }
+        const min = Number(ageMin)
+        const max = Number(ageMax)
+        if (isNaN(min) || isNaN(max)) {
           return '周龄范围不能为空'
           return '周龄范围不能为空'
         }
         }
         if (max === 0) {
         if (max === 0) {
@@ -282,19 +294,31 @@ const rules = {
   weight: [
   weight: [
     {
     {
       validator: () => {
       validator: () => {
-        const value = state.form.weight
-        console.log('体重范围:', value)
-        const min = Number(value?.min)
-        const max = Number(value?.max)
-        if (
-          !value ||
-          value.min === null ||
-          value.min === '' ||
-          value.max === null ||
-          value.max === '' ||
-          isNaN(min) ||
-          isNaN(max)
-        ) {
+        const age = state.form.age
+        const weight = state.form.weight
+        const ageMin = age?.min
+        const ageMax = age?.max
+        const weightMin = weight?.min
+        const weightMax = weight?.max
+        const hasAgeMin = ageMin !== null && ageMin !== ''
+        const hasAgeMax = ageMax !== null && ageMax !== ''
+        const hasWeightMin = weightMin !== null && weightMin !== ''
+        const hasWeightMax = weightMax !== null && weightMax !== ''
+        const isAgeFilled = hasAgeMin && hasAgeMax
+        const isWeightFilled = hasWeightMin && hasWeightMax
+        const hasWeightAny = hasWeightMin || hasWeightMax
+        if (!hasWeightAny && !isAgeFilled) {
+          return '周龄或体重至少填写一个'
+        }
+        if (hasWeightAny && !isWeightFilled) {
+          return '体重范围不能为空'
+        }
+        if (!isWeightFilled) {
+          return true
+        }
+        const min = Number(weightMin)
+        const max = Number(weightMax)
+        if (isNaN(min) || isNaN(max)) {
           return '体重范围不能为空'
           return '体重范围不能为空'
         }
         }
         if (max === 0) {
         if (max === 0) {

+ 3 - 2
src/view/animal/applicationRemoval/components/addEdit.vue

@@ -99,7 +99,7 @@
               <h4 class="mb20 mt20">淘汰上报信息</h4>
               <h4 class="mb20 mt20">淘汰上报信息</h4>
               <div class="simple-table">
               <div class="simple-table">
                 <div class="simple-table__header-taotai">
                 <div class="simple-table__header-taotai">
-                  <div class="simple-table__cell" align="center">淘汰日期</div>
+                  <div class="simple-table__cell" align="center">日期</div>
                   <div class="simple-table__cell" align="center">淘汰数量</div>
                   <div class="simple-table__cell" align="center">淘汰数量</div>
                   <div class="simple-table__cell" align="center">淘汰原因</div>
                   <div class="simple-table__cell" align="center">淘汰原因</div>
                   <div class="simple-table__cell" align="center">尸体存放位置</div>
                   <div class="simple-table__cell" align="center">尸体存放位置</div>
@@ -821,7 +821,7 @@ defineExpose({
   .simple-table__header,
   .simple-table__header,
   .simple-table__row {
   .simple-table__row {
     display: flex;
     display: flex;
-    min-width: 660px;
+    min-width: 550px;
   }
   }
   .simple-table__header-taotai,
   .simple-table__header-taotai,
   .simple-table__row-taotai {
   .simple-table__row-taotai {
@@ -829,6 +829,7 @@ defineExpose({
     min-width: 500px;
     min-width: 500px;
   }
   }
 
 
+  .simple-table__header-taotai,
   .simple-table__header {
   .simple-table__header {
     background-color: #f7f8fa;
     background-color: #f7f8fa;
     font-weight: 600;
     font-weight: 600;