فهرست منبع

点计算时含有未选择必填项的时候未选择项目红框(2509)

zhangxc 5 سال پیش
والد
کامیت
0e9704bc54
1فایلهای تغییر یافته به همراه10 افزوده شده و 2 حذف شده
  1. 10 2
      src/js/scale.js

+ 10 - 2
src/js/scale.js

@@ -4,7 +4,7 @@ const {
   getUrlArgObject
 } = require('./promise.js');
 const $ = require("jquery");
-
+let hasCalc = false;
 $(function () {
   var scaleInfo;
   // 用GetQueryString方法从地址栏获取参数,暂时写死
@@ -63,9 +63,11 @@ function renderScaleType1(scaleList) {
     for (var x = 0; x < scaleList.group[j].rows.length; x++) {
       for (var y = 0; y < scaleList.group[j].rows[x].row.length; y++) {
         var str2 = ''
+        var hasSelect = false
         for (var z = 0; z < scaleList.group[j].rows[x].row[y].details.length; z++) {
           str2 += '<span class="groupRowRadio"><input  type="radio" data-index="' + j + '_' + x + '_' + y + '_' + z + '"  name="' + j +'_'+ x  +'_'+ y + '" id="' + j +'_' + x +'_' + y  +'_'+ z + '"'
           if (scaleList.group[j].rows[x].row[y].details[z].select == 1) {
+            hasSelect = true
             str2 += ' checked="checked"'
           }
           str2 += ' />' + '<label for="' + j  +'_'+ x +'_' + y +'_' + z + '">' + scaleList.group[j].rows[x].row[y].details[z].detailName + '(' + scaleList.group[j].rows[x].row[y].details[z].score + ')' + '</label>'
@@ -74,7 +76,11 @@ function renderScaleType1(scaleList) {
           }
           str2 += '</span>'
         }
-        str += '<div class="groupRowWrapper ' + j  +'_'+ x + '" data-group="' + j +'_' + x + '" id="' + j  +'_'+ x  +'_'+ y + '">'
+        str += '<div class="groupRowWrapper '
+        if(+scaleList.group[j].rows[x].required === 1&&hasCalc&&!hasSelect) {
+          str += 'noSelect '
+        }
+        str +='' + j  +'_'+ x + '" data-group="' + j +'_' + x + '" id="' + j  +'_'+ x  +'_'+ y + '">'
         
         if(scaleList.group[j].rows[x].row.length > 1 && y=== 0) {
           str += '<div class="tips">本组选项可多选或根据需要选择某一条选项</div>'
@@ -132,6 +138,7 @@ function bindScaleType1(scaleList) {
   })
 
   $('.calcuBtn').on('click', function () {
+    hasCalc = true
     let allSelect = true
     for (let i = 0; i < scaleList.group.length; i++) {
       for (let j = 0; j < scaleList.group[i].rows.length; j++) {
@@ -146,6 +153,7 @@ function bindScaleType1(scaleList) {
           }
           if (!itemSelect) {
             allSelect = false
+            $('.' + i+'_' + j).addClass('noSelect')
           }
         }