Browse Source

修改出生年月禁用选项--及重复点击提交问卷

plg 4 months ago
parent
commit
b644b24db4
1 changed files with 16 additions and 1 deletions
  1. 16 1
      src/components/CpmdQuestionnaire.vue

+ 16 - 1
src/components/CpmdQuestionnaire.vue

@@ -11,6 +11,9 @@ const router = useRouter()
 const userInfo = userInfoStore()
 const dialogVisible = ref<boolean>(false)
 
+//设置防止重复点击的事件
+const isLock = ref<boolean>(false)
+
 const ruleForm = reactive<any>({
     //是否是少数民族
     isMinority: false,
@@ -73,6 +76,11 @@ const queryQuestion = async (planId: string) => {
 
 //提交答案时校验
 const submitQuestion = () => {
+    //如果已经上锁---则直接退出
+    if (isLock.value) {
+        return
+    }
+    isLock.value = true;
     for (let i = 0; i < questionList.value.length; i++) {
         if (questionList.value[i].topicType == '3' && questionList.value[i].optionValue != '') {
             //格式化时间格式
@@ -84,6 +92,7 @@ const submitQuestion = () => {
                     message: `请完成必选项:${questionList.value[i].quesName}`,
                     type: 'error'
                 })
+                isLock.value = false;
                 return
             }
         }
@@ -108,6 +117,8 @@ const comT = () => {
 
 }
 //保存问卷接口
+//设置一个防止重复调用的接口
+
 const saveQuesQuestion = async () => {
     let res: any = await sqveQuesQuestionApi(questionList.value)
     if (res.code == 200) {
@@ -137,7 +148,11 @@ const saveQuesQuestion = async () => {
     //是否弹出测试计划页面
 
     //是否弹出开始测试弹出框
+    isLock.value = false;
+}
 
+const disbledData = (time: any) => {
+    return time.getTime() >= Date.now()
 }
 
 const transmitType = ref('')
@@ -172,7 +187,7 @@ defineExpose({ open })
                         <!-- <el-radio label="线下场地免费"></el-radio> -->
                     </el-radio-group>
                     <el-date-picker v-model="item.optionValue" type="date" placeholder="选择出生年月" class="question_radio"
-                        v-if="item.topicType == '3'" />
+                        v-if="item.topicType == '3'" :disabled-date="disbledData" />
                 </div>
             </div>
         </span>