shmily1213 1 месяц назад
Родитель
Сommit
50fe603f3c

+ 53 - 21
src/pagesSystem/pages/bind-profile/bind-profile.vue

@@ -20,7 +20,7 @@
         <uv-form-item label="考生类别" prop="examType" borderBottom required>
           <ie-picker ref="pickerRef" v-model="examTypeForm.examType" :list="examTypeList" :disabled="isExamTypeDisabled"
             :placeholder="pickerPlaceholder" :custom-style="customStyle" key-label="dictLabel" key-value="dictValue"
-            @click="handlePreCheck('examType')">
+            @click="handlePreCheck('examType')" @change="handleExamTypeChange">
             <template v-if="isExamTypeDisabled" #right>
               <ie-image src="/static/image/icon-lock.png" custom-class="w-24 h-30" mode="aspectFill" />
             </template>
@@ -47,27 +47,27 @@
       </content-card>
 
       <content-card v-if="showCulture" title="文化素质">
-        <uv-form-item label="语文" prop="form.scores.chinese" borderBottom :required="isBindMode">
+        <uv-form-item label="语文" prop="form.scores.chinese" borderBottom :required="isScoreRequired">
           <uv-input v-model.number="scoresForm.chinese" border="none" type="number" :placeholder="inputPlaceholder"
             font-size="30rpx" :custom-style="customStyle">
           </uv-input>
         </uv-form-item>
-        <uv-form-item label="数学" prop="form.score.mathematics" borderBottom :required="isBindMode">
+        <uv-form-item label="数学" prop="form.score.mathematics" borderBottom :required="isScoreRequired">
           <uv-input v-model.number="scoresForm.mathematics" border="none" type="number" :placeholder="inputPlaceholder"
             font-size="30rpx" :custom-style="customStyle">
           </uv-input>
         </uv-form-item>
-        <uv-form-item label="外语" prop="form.scores.foreign" borderBottom :required="isBindMode">
+        <uv-form-item label="外语" prop="form.scores.foreign" borderBottom :required="isScoreRequired">
           <uv-input v-model.number="scoresForm.foreign" border="none" type="number" :placeholder="inputPlaceholder"
             font-size="30rpx" :custom-style="customStyle">
           </uv-input>
         </uv-form-item>
-        <uv-form-item label="物理" prop="form.scores.physics" borderBottom :required="isBindMode">
+        <uv-form-item label="物理" prop="form.scores.physics" borderBottom :required="isScoreRequired">
           <uv-input v-model.number="scoresForm.physics" border="none" type="number" :placeholder="inputPlaceholder"
             font-size="30rpx" :custom-style="customStyle">
           </uv-input>
         </uv-form-item>
-        <uv-form-item label="政治" prop="form.scores.political" :required="isBindMode">
+        <uv-form-item label="政治" prop="form.scores.political" :required="isScoreRequired">
           <uv-input v-model.number="scoresForm.political" border="none" type="number" :placeholder="inputPlaceholder"
             font-size="30rpx" :custom-style="customStyle">
           </uv-input>
@@ -135,6 +135,9 @@ const customStyle = {
   paddingLeft: '26px'
 };
 
+// 普高-文化成绩必填,保存后锁定不可修改
+// 中职务-文化成绩不填,保存后可修改
+const isScoreRequired = computed(() => examTypeForm.value.examType === EnumExamType.OHS);
 const isBindMode = computed(() => [EnumBindScene.LOGIN_BIND, EnumBindScene.REGISTER_BIND].includes(prevData.value.scene));
 const isSchoolDisabled = computed(() => isBindMode.value && !!prevData.value.cardInfo.assignSchoolId);
 const isClassDisabled = computed(() => isBindMode.value && !!prevData.value.cardInfo.classId);
@@ -271,36 +274,60 @@ const loginValidate = () => {
     return false;
   }
   if (showCulture.value) {
-    if (isBindMode.value) {
-      if (!scoresForm.value.chinese || scoresForm.value.chinese < 0 || scoresForm.value.chinese > 100) {
-        uni.$ie.showToast('请输入正确的语文成绩');
+    if (isScoreRequired.value) {
+      if (!scoresForm.value.chinese) {
+        uni.$ie.showToast('请输入语文成绩');
         return false;
       }
     }
-    if (isBindMode.value) {
-      if (!scoresForm.value.mathematics || scoresForm.value.mathematics < 0 || scoresForm.value.mathematics > 100) {
-        uni.$ie.showToast('请输入正确的数学成绩');
+    if (scoresForm.value?.chinese && (scoresForm.value.chinese < 0 || scoresForm.value.chinese > 100)) {
+      uni.$ie.showToast('请输入正确的语文成绩');
+      return false;
+    }
+    // 
+    if (isScoreRequired.value) {
+      if (!scoresForm.value.mathematics) {
+        uni.$ie.showToast('请输入数学成绩');
         return false;
       }
     }
-    if (isBindMode.value) {
-      if (!scoresForm.value.foreign || scoresForm.value.foreign < 0 || scoresForm.value.foreign > 100) {
-        uni.$ie.showToast('请输入正确的外语成绩');
+    if (scoresForm.value?.mathematics && (scoresForm.value.mathematics < 0 || scoresForm.value.mathematics > 100)) {
+      uni.$ie.showToast('请输入正确的数学成绩');
+      return false;
+    }
+    //
+    if (isScoreRequired.value) {
+      if (!scoresForm.value.foreign) {
+        uni.$ie.showToast('请输入外语成绩');
         return false;
       }
     }
-    if (isBindMode.value) {
-      if (!scoresForm.value.physics || scoresForm.value.physics < 0 || scoresForm.value.physics > 100) {
-        uni.$ie.showToast('请输入正确的物理成绩');
+    if (scoresForm.value?.foreign && (scoresForm.value.foreign < 0 || scoresForm.value.foreign > 100)) {
+      uni.$ie.showToast('请输入正确的外语成绩');
+      return false;
+    }
+    // 
+    if (isScoreRequired.value) {
+      if (!scoresForm.value.physics) {
+        uni.$ie.showToast('请输入物理成绩');
         return false;
       }
     }
-    if (isBindMode.value) {
-      if (!scoresForm.value.political || scoresForm.value.political < 0 || scoresForm.value.political > 100) {
-        uni.$ie.showToast('请输入正确的政治成绩');
+    if (scoresForm.value?.physics && (scoresForm.value.physics < 0 || scoresForm.value.physics > 100)) {
+      uni.$ie.showToast('请输入正确的物理成绩');
+      return false;
+    }
+    //
+    if (isScoreRequired.value) {
+      if (!scoresForm.value.political) {
+        uni.$ie.showToast('请输入政治成绩');
         return false;
       }
     }
+    if (scoresForm.value?.political && (scoresForm.value.political < 0 || scoresForm.value.political > 100)) {
+      uni.$ie.showToast('请输入正确的政治成绩');
+      return false;
+    }
   }
   if (isBindMode.value) {
     if (!form.value.schoolId) {
@@ -316,6 +343,11 @@ const loginValidate = () => {
   }
   return true;
 }
+
+const handleExamTypeChange = () => {
+  scoresForm.value = {};
+}
+
 const handleSubmit = async () => {
   const valid = loginValidate();
   if (valid) {

+ 53 - 11
src/pagesSystem/pages/bind-teacher-profile/bind-teacher-profile.vue

@@ -19,7 +19,7 @@
         <uv-form-item label="考生类别" prop="examType" borderBottom required>
           <ie-picker ref="pickerRef" v-model="examTypeForm.examType" :list="examTypeList"
             :disabled="!examTypeForm.location || disabledEdit" :placeholder="pickerPlaceholder"
-            :custom-style="customStyle" key-label="dictLabel" key-value="dictValue">
+            :custom-style="customStyle" key-label="dictLabel" key-value="dictValue" @change="handleExamTypeChange">
             <template v-if="disabledEdit" #right>
               <ie-image src="/static/image/icon-lock.png" custom-class="w-24 h-30" mode="aspectFill" />
             </template>
@@ -44,33 +44,33 @@
       </content-card>
 
       <content-card v-if="showCulture" title="文化素质">
-        <uv-form-item label="语文" prop="form.scores.chinese" borderBottom :required="true">
+        <uv-form-item label="语文" prop="form.scores.chinese" borderBottom :required="isScoreRequired">
           <uv-input v-model.number="scoresForm.chinese" border="none" type="number" :placeholder="inputPlaceholder"
             font-size="30rpx" :custom-style="customStyle" :readonly="disabledEdit">
           </uv-input>
         </uv-form-item>
-        <uv-form-item label="数学" prop="form.score.mathematics" borderBottom :required="true">
+        <uv-form-item label="数学" prop="form.score.mathematics" borderBottom :required="isScoreRequired">
           <uv-input v-model.number="scoresForm.mathematics" border="none" type="number" :placeholder="inputPlaceholder"
             font-size="30rpx" :custom-style="customStyle" :readonly="disabledEdit">
           </uv-input>
           <ie-image v-if="disabledEdit" slot="right" src="/static/image/icon-lock.png" custom-class="w-24 h-30"
             mode="aspectFill" />
         </uv-form-item>
-        <uv-form-item label="外语" prop="form.scores.foreign" borderBottom :required="true">
+        <uv-form-item label="外语" prop="form.scores.foreign" borderBottom :required="isScoreRequired">
           <uv-input v-model.number="scoresForm.foreign" border="none" type="number" :placeholder="inputPlaceholder"
             font-size="30rpx" :custom-style="customStyle" :readonly="disabledEdit">
           </uv-input>
           <ie-image v-if="disabledEdit" slot="right" src="/static/image/icon-lock.png" custom-class="w-24 h-30"
             mode="aspectFill" />
         </uv-form-item>
-        <uv-form-item label="物理" prop="form.scores.physics" borderBottom :required="true">
+        <uv-form-item label="物理" prop="form.scores.physics" borderBottom :required="isScoreRequired">
           <uv-input v-model.number="scoresForm.physics" border="none" type="number" :placeholder="inputPlaceholder"
             font-size="30rpx" :custom-style="customStyle" :readonly="disabledEdit">
           </uv-input>
           <ie-image v-if="disabledEdit" slot="right" src="/static/image/icon-lock.png" custom-class="w-24 h-30"
             mode="aspectFill" />
         </uv-form-item>
-        <uv-form-item label="政治" prop="form.scores.political" :required="true">
+        <uv-form-item label="政治" prop="form.scores.political" :required="isScoreRequired">
           <uv-input v-model.number="scoresForm.political" border="none" type="number" :placeholder="inputPlaceholder"
             font-size="30rpx" :custom-style="customStyle" :readonly="disabledEdit">
           </uv-input>
@@ -144,6 +144,9 @@ scoresForm.value = form.value.scores || {}
 const disabledEdit = computed(() => {
   return !!userInfo.value.location;
 })
+// 普高-文化成绩必填,保存后锁定不可修改
+// 中职务-文化成绩不填,保存后可修改
+const isScoreRequired = computed(() => examTypeForm.value.examType === EnumExamType.OHS);
 const showCulture = computed(() => {
   return examTypeForm.value.examType === EnumExamType.OHS;
 });
@@ -186,29 +189,68 @@ const loginValidate = () => {
     return false;
   }
   if (showCulture.value) {
-    if (!scoresForm.value.chinese || scoresForm.value.chinese < 0 || scoresForm.value.chinese > 100) {
+    if (isScoreRequired.value) {
+      if (!scoresForm.value.chinese) {
+        uni.$ie.showToast('请输入语文成绩');
+        return false;
+      }
+    }
+    if (scoresForm.value?.chinese && (scoresForm.value.chinese < 0 || scoresForm.value.chinese > 100)) {
       uni.$ie.showToast('请输入正确的语文成绩');
       return false;
     }
-    if (!scoresForm.value.mathematics || scoresForm.value.mathematics < 0 || scoresForm.value.mathematics > 100) {
+    // 
+    if (isScoreRequired.value) {
+      if (!scoresForm.value.mathematics) {
+        uni.$ie.showToast('请输入数学成绩');
+        return false;
+      }
+    }
+    if (scoresForm.value?.mathematics && (scoresForm.value.mathematics < 0 || scoresForm.value.mathematics > 100)) {
       uni.$ie.showToast('请输入正确的数学成绩');
       return false;
     }
-    if (!scoresForm.value.foreign || scoresForm.value.foreign < 0 || scoresForm.value.foreign > 100) {
+    //
+    if (isScoreRequired.value) {
+      if (!scoresForm.value.foreign) {
+        uni.$ie.showToast('请输入外语成绩');
+        return false;
+      }
+    }
+    if (scoresForm.value?.foreign && (scoresForm.value.foreign < 0 || scoresForm.value.foreign > 100)) {
       uni.$ie.showToast('请输入正确的外语成绩');
       return false;
     }
-    if (!scoresForm.value.physics || scoresForm.value.physics < 0 || scoresForm.value.physics > 100) {
+    // 
+    if (isScoreRequired.value) {
+      if (!scoresForm.value.physics) {
+        uni.$ie.showToast('请输入物理成绩');
+        return false;
+      }
+    }
+    if (scoresForm.value?.physics && (scoresForm.value.physics < 0 || scoresForm.value.physics > 100)) {
       uni.$ie.showToast('请输入正确的物理成绩');
       return false;
     }
-    if (!scoresForm.value.political || scoresForm.value.political < 0 || scoresForm.value.political > 100) {
+    //
+    if (isScoreRequired.value) {
+      if (!scoresForm.value.political) {
+        uni.$ie.showToast('请输入政治成绩');
+        return false;
+      }
+    }
+    if (scoresForm.value?.political && (scoresForm.value.political < 0 || scoresForm.value.political > 100)) {
       uni.$ie.showToast('请输入正确的政治成绩');
       return false;
     }
   }
   return true;
 }
+
+const handleExamTypeChange = () => {
+  scoresForm.value = {};
+}
+
 const handleSubmit = async () => {
   console.log('handleSubmit', examTypeForm.value)
   if (!loginValidate()) {