소스 검색

多选框互斥判断

wyq 4 년 전
부모
커밋
3e49fabe0c
1개의 변경된 파일8개의 추가작업 그리고 13개의 파일을 삭제
  1. 8 13
      src/js/staticInfo.js

+ 8 - 13
src/js/staticInfo.js

@@ -157,7 +157,7 @@ function renderContentscale(list, contentWrapClassName, name) {
             if (it.selectType == 21 && item.resultType == 1) {
               str += '<label><input class="radio_type" type="radio" name="scale' + its.parentId + '" value="' + its.score + '"/>'
             } else if (it.selectType == 22 && item.resultType == 1) {
-              str += '<label><input class="radio_type" name="scale' + its.parentId + '" type="checkbox" value="' + its.score + '" />'
+              str += '<label><input class="radio_type" name="scale' + its.parentId + '" type="checkbox" value="' + its.score + '"/>'
             } else if (it.selectType == 21 && item.resultType == 2) {
               str += '<label><input class="radio_type" name="scale' + its.parentId + '" type="radio" value="' + its.result + '" data_obj="' + it.content + '问题' + its.result + '"/>'
             } else if (it.selectType == 22 && item.resultType == 2) {
@@ -234,6 +234,7 @@ function getcheck() {
     const domName = $(this).attr('name');
     const $radio = $(this);
     const id = $(this).parents('.contentList').data("id");
+    console.log($radio.data('waschecked'))
     if ($radio.data('waschecked') == true) {
       $radio.prop('checked', false);
       $("input:radio[name='" + domName + "']").data('waschecked', false);
@@ -255,19 +256,13 @@ function getcheck() {
     const domName = $(this).attr('name');
     const $radio = $(this);
     const id = $(this).parents('.contentList').data("id");
-    console.log($radio.data('waschecked'))
-    if ($radio.data('waschecked') == true) {
-      // $radio.parents('.contentList').siblings(".contentList[data-id='" + id + "']").find('.radio_type').attr("disabled", false);
-      if (isclick) {
-        getchecks()
+    $radio.parents('.contentList').each(function (i) {
+      if ($(this).find('input[type="checkbox"]:checked').val() == undefined){
+        $radio.parents('.contentList').siblings(".contentList[data-id='" + id + "']").find('.radio_type').attr("disabled", false);
+      }else{
+        $radio.parents('.contentList').siblings(".contentList[data-id='" + id + "']").find('.radio_type').attr("disabled", true);
       }
-    } else {
-      $radio.data('waschecked', true);
-      $radio.parents('.contentList').siblings(".contentList[data-id='" + id + "']").find('.radio_type').attr("disabled", true);
-      if (isclick) {
-        getchecks()
-      }
-    }
+    })
   });
 }