Foxtable(狐表)用户栏目专家坐堂 → js代码求助:五个不同的table,怎么实现对应条件判断进行逐一进行


  共有3841人关注过本帖树形打印复制链接

主题:js代码求助:五个不同的table,怎么实现对应条件判断进行逐一进行

帅哥哟,离线,有人找我吗?
cnsjroom
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:七尾狐 帖子:1571 积分:11238 威望:0 精华:0 注册:2021/1/17 17:06:00
js代码求助:五个不同的table,怎么实现对应条件判断进行逐一进行  发帖心情 Post By:2023/1/31 17:58:00 [只看该作者]

js代码求助:四个不同的table,怎么实现对应条件判断进行逐一进行

红色部分是条件判断代码,对应的变量数值都是正确的,但是不管怎么样判断,都会执行蓝色部分代码

想修正四个不同的table,只要有一个不满足条件都不保存数据,要全部满足后再保存数据

 

({
 button13: {
  text: '{{text}}', //系统自动匹配标题
  visible: true,
  click: function() { //按钮单击事件
   e.form.button13.save(function() {
    })

  },
  save: function(fun) {
   var data1 = {};
   var youdengci1
   var youdengci2
   var youdengci3
   var youdengci5
   var data = e.form.getdata();
   var rows = e.form.edittable1.rows;
   if (rows.length != 0) {
    let sum = 0;
    let ary = ["好", "较好", "一般", "较差"];
    for (var i in rows) {
     let row = rows[i];
     if (row.好 == "" && row.较好 == "" && row.一般 == "" && row.较差 == "" && row.弃权 == "") {
      e.form.alert("【" + row.测评对象 + "】---好、较好、一般、较差、弃权至少选择一个!", "温馨提示")
      e.form.tabs1.active = "TabPage1";
      return;
     }
    }
    for (var i in rows) {
     let row = rows[i];
     if (row.好 == "√") {
      sum = sum + 1;
     }
    }
    data1.tablename = "SYS_Dictionary";
    data1.colname = "字典值";
    data1.filter = "备注='公务' and 分类='考核优等次数量'";
    e.form.getitems(data1, function(res1) {
     youdengci1 = res1[0].value;
     if (sum > youdengci1) {
      e.form.alert("公务【好】等次只能<或=" + youdengci1 + ",当前大于" + sum + ",请核实!", "温馨提示")
      e.form.tabs1.active = "TabPage1";
      return ture;
     }

    })
   }
   var rows2 = e.form.edittable2.rows;
   if (rows2.length != 0) {
    let sum2 = 0;
    let ary2 = ["好", "较好", "一般", "较差"];
    for (var i2 in rows2) {
     let row2 = rows2[i2];
     if (row2.好 == "" && row2.较好 == "" && row2.一般 == "" && row2.较差 == "" && row2.弃权 == "") {
      e.form.alert("【" + row2.测评对象 + "】---好、较好、一般、较差、弃权至少选择一个!", "温馨提示")
      e.form.tabs1.active = "TabPage2";
      return;
     }
    }
    for (var i2 in rows2) {
     let row2 = rows2[i2];
     if (row2.好 == "√") {
      sum2 = sum2 + 1;
     }
    }
    data1.tablename = "SYS_Dictionary";
    data1.colname = "字典值";
    data1.filter = "备注='综合保障中心' and 分类='考核优等次数量'";
    e.form.getitems(data1, function(res1) {
     youdengci2 = res1[0].value;
     if (sum2 > youdengci2) {
      e.form.alert("综合保障中心【好】等次只能<或=" + youdengci2 + ",当前大于" + sum2 + ",请核实!", "温馨提示")
      e.form.tabs1.active = "TabPage2";
      return ture;
     }

    })
   }
   var rows3 = e.form.edittable3.rows;
   if (rows3.length != 0) {
    let sum3 = 0;
    let ary3 = ["好", "较好", "一般", "较差"];
    for (var i3 in rows3) {
     let row3 = rows3[i3];
     if (row3.好 == "" && row3.较好 == "" && row3.一般 == "" && row3.较差 == "" && row3.弃权 == "") {
      // if(row.好=="×"&&row.较好=="×"&&row.一般=="×"&&row.较差=="×"){
      // row.弃权= "√"
      e.form.alert("【" + row3.测评对象 + "】---好、较好、一般、较差、弃权至少选择一个!", "温馨提示")
      e.form.tabs1.active = "TabPage3";
      return;
     }
    }
    for (var i3 in rows3) {
     let row3 = rows3[i3];
     if (row3.好 == "√") {
      sum3 = sum3 + 1;
     }
    }
    data1.tablename = "SYS_Dictionary";
    data1.colname = "字典值";
    data1.filter = "备注='工勤人员' and 分类='考核优等次数量'";
    e.form.getitems(data1, function(res1) {
     youdengci3 = res1[0].value;
     if (sum3 > youdengci3) {
      e.form.alert("工勤人员【好】等次只能<或=" + youdengci3 + ",当前大于" + sum3 + ",请核实!", "温馨提示")
      e.form.tabs1.active = "TabPage3";
      return ture;
     }

    })
   }
   var rows5 = e.form.edittable5.rows;
   if (rows5.length != 0) {
    let sum5 = 0;
    let ary5 = ["好", "较好", "一般", "较差"];
    for (var i5 in rows5) {
     let row5 = rows5[i5];
     if (row5.好 == "" && row5.较好 == "" && row5.一般 == "" && row5.较差 == "" && row5.弃权 == "") {
      // if(row.好=="×"&&row.较好=="×"&&row.一般=="×"&&row.较差=="×"){
      // row.弃权= "√"
      e.form.alert("【" + row5.测评对象 + "】---好、较好、一般、较差、弃权至少选择一个!", "温馨提示")
      e.form.tabs1.active = "TabPage5";
      return;
     }
    }
    for (var i5 in rows5) {
     let row5 = rows5[i5];
     if (row5.好 == "√") {
      sum5 = sum5 + 1;
     }
    }
    data1.tablename = "SYS_Dictionary";
    data1.colname = "字典值";
    data1.filter = "备注='服务中心' and 分类='考核优等次数量'";
    e.form.getitems(data1, function(res1) {
     youdengci5 = res1[0].value;
     if (sum5 > youdengci5) {
      e.form.alert("服务中心【好】等次只能<或=" + youdengci5 + ",当前大于" + sum5 + ",请核实!", "温馨提示")
      e.form.tabs1.active = "TabPage5";
      return ture;
     }

    })
   }
   var tables = [e.form.edittable1.getdata(), e.form.edittable2.getdata(), e.form.edittable3.getdata(), e.form.edittable5.getdata()];
   data.tables = JSON.stringify(tables);
   data.onlytable = true;
   e.form.save(data, function() {
    fun()
   })

  }
 }
})


 回到顶部
帅哥哟,离线,有人找我吗?
有点蓝
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:110750 积分:563676 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2023/1/31 20:38:00 [只看该作者]

自己加调试代码

    e.form.getitems(data1, function(res1) {
     youdengci1 = res1[0].value;
alert("1");//这里能不能弹出
     if (sum > youdengci1) {
alert("2");//这里能不能弹出
      e.form.alert("公务【好】等次只能<或=" + youdengci1 + ",当前大于" + sum + ",请核实!", "温馨提示")
      e.form.tabs1.active = "TabPage1";
      return ture;

最好是自己学会使用浏览器开发者工具逐行调试js代码

 回到顶部
帅哥哟,离线,有人找我吗?
cnsjroom
  3楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:七尾狐 帖子:1571 积分:11238 威望:0 精华:0 注册:2021/1/17 17:06:00
回复:(有点蓝)自己加调试代码    e.form...  发帖心情 Post By:2023/1/31 23:19:00 [只看该作者]

老师   全部都能够弹出 

主要是蓝色的保存部分代码   我想实现的是前面四个红色判断   都不会弹出值的情况下  才能执行蓝色代码

只要有一个出现弹出值  都不能执行蓝色代码

 


 回到顶部
帅哥哟,离线,有人找我吗?
cnsjroom
  4楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:七尾狐 帖子:1571 积分:11238 威望:0 精华:0 注册:2021/1/17 17:06:00
回复:(有点蓝)自己加调试代码    e.form...  发帖心情 Post By:2023/1/31 23:32:00 [只看该作者]

红色代码部分  还是和一楼的代码实现的效果一样    会保存数据

 想让这fun1()  fun2()  fun3() fun4()  四个函数  都不弹出任何信息的情况下再执行
 var tables = [e.form.edittable1.getdata(), e.form.edittable2.getdata(), e.form.edittable3.getdata(), e.form.edittable5.getdata()];
    data.tables = JSON.stringify(tables);
    data.onlytable = true;
    e.form.save(data, function() {
     fun()
    })

 

有没有办法操作呢?

 

 

({
 button13: {
  text: '{{text}}', //系统自动匹配标题
  visible: true,
  click: function() { //按钮单击事件
   e.form.button13.save(function() {
    var rows1 = e.form.edittable1.rows;
    for (var i in rows1) {
     let row1 = rows1[i];
     $.post("form700_gengxinwancheng.Ajax", {
       guid: row1.guid
      },
      function(res) {})
    }
    e.form.edittable1.load();

    var rows2 = e.form.edittable2.rows;
    for (var i in rows2) {
     let row2 = rows2[i];
     $.post("form700_gengxinwancheng.Ajax", {
       guid: row2.guid,
      },
      function(res) {})
    }
    e.form.edittable2.load();

    var rows3 = e.form.edittable3.rows;
    for (var i in rows3) {
     let row3 = rows3[i];
     $.post("form700_gengxinwancheng.Ajax", {
       guid: row3.guid
      },
      function(res) {})
    }
    e.form.edittable3.load();

    var rows5 = e.form.edittable5.rows;
    for (var i in rows5) {
     let row5 = rows5[i];
     $.post("form700_gengxinwancheng.Ajax", {
       guid: row5.guid
      },
      function(res) {})
    }
    e.form.edittable5.load();
    e.form.showloading("正在提交测评数据,谢谢合作!");
    form694.form.table1.load();
    e.form.closeloading();
    // e.form.close();
   })
  },
  save: function(fun) {
   var data1 = {};
   var youdengci1
   var youdengci2
   var youdengci3
   var youdengci5
   var data = e.form.getdata();

   function fun1() {
    var rows = e.form.edittable1.rows;
    if (rows.length != 0) {
     let sum = 0;
     let ary = ["好", "较好", "一般", "较差"];
     for (var i in rows) {
      let row = rows[i];
      if (row.好 == "" && row.较好 == "" && row.一般 == "" && row.较差 == "" && row.弃权 == "") {
       // if(row.好=="×"&&row.较好=="×"&&row.一般=="×"&&row.较差=="×"){
       // row.弃权= "√"
       e.form.alert("【" + row.测评对象 + "】---好、较好、一般、较差、弃权至少选择一个!", "温馨提示")
       e.form.tabs1.active = "TabPage1";
       return;
      }
     }
     for (var i in rows) {
      let row = rows[i];
      if (row.好 == "√") {
       sum = sum + 1;
      }
     }
     data1.tablename = "SYS_Dictionary";
     data1.colname = "字典值";
     data1.filter = "备注='参公' and 分类='考核优等次数量'";
     e.form.getitems(data1, function(res1) {
      youdengci1 = res1[0].value;
      if (sum > youdengci1) {
       e.form.alert("参公【好】等次只能<或=" + youdengci1 + ",当前大于" + sum + ",请核实!", "温馨提示")
       e.form.tabs1.active = "TabPage1";
       return ;
      }

     })

    }
   }

   function fun2() {
    var rows2 = e.form.edittable2.rows;
    if (rows2.length != 0) {
     let sum2 = 0;
     let ary2 = ["好", "较好", "一般", "较差"];
     for (var i2 in rows2) {
      let row2 = rows2[i2];
      if (row2.好 == "" && row2.较好 == "" && row2.一般 == "" && row2.较差 == "" && row2.弃权 == "") {
       e.form.alert("【" + row2.测评对象 + "】---好、较好、一般、较差、弃权至少选择一个!", "温馨提示")
       e.form.tabs1.active = "TabPage2";
       return;
      }
     }
     for (var i2 in rows2) {
      let row2 = rows2[i2];
      if (row2.好 == "√") {
       sum2 = sum2 + 1;
      }
     }
     data1.tablename = "SYS_Dictionary";
     data1.colname = "字典值";
     data1.filter = "备注='综合保障中心' and 分类='考核优等次数量'";
     e.form.getitems(data1, function(res1) {
      youdengci2 = res1[0].value;
      if (sum2 > youdengci2) {
       e.form.alert("综合保障中心【好】等次只能<或=" + youdengci2 + ",当前大于" + sum2 + ",请核实!", "温馨提示")
       e.form.tabs1.active = "TabPage2";
       return ;
      }

     })
    }
   }

   function fun3() {
    var rows3 = e.form.edittable3.rows;
    if (rows3.length != 0) {
     let sum3 = 0;
     let ary3 = ["好", "较好", "一般", "较差"];
     for (var i3 in rows3) {
      let row3 = rows3[i3];
      if (row3.好 == "" && row3.较好 == "" && row3.一般 == "" && row3.较差 == "" && row3.弃权 == "") {
       // if(row.好=="×"&&row.较好=="×"&&row.一般=="×"&&row.较差=="×"){
       // row.弃权= "√"
       e.form.alert("【" + row3.测评对象 + "】---好、较好、一般、较差、弃权至少选择一个!", "温馨提示")
       e.form.tabs1.active = "TabPage3";
       return;
      }
     }
     for (var i3 in rows3) {
      let row3 = rows3[i3];
      if (row3.好 == "√") {
       sum3 = sum3 + 1;
      }
     }
     data1.tablename = "SYS_Dictionary";
     data1.colname = "字典值";
     data1.filter = "备注='工勤人员' and 分类='考核优等次数量'";
     e.form.getitems(data1, function(res1) {
      youdengci3 = res1[0].value;
      if (sum3 > youdengci3) {
       e.form.alert("工勤人员【好】等次只能<或=" + youdengci3 + ",当前大于" + sum3 + ",请核实!", "温馨提示")
       e.form.tabs1.active = "TabPage3";
       return ;
      }

     })

    }

   }

   function fun4() {
    var rows5 = e.form.edittable5.rows;
    if (rows5.length != 0) {
     let sum5 = 0;
     let ary5 = ["好", "较好", "一般", "较差"];
     for (var i5 in rows5) {
      let row5 = rows5[i5];
      if (row5.好 == "" && row5.较好 == "" && row5.一般 == "" && row5.较差 == "" && row5.弃权 == "") {
       // if(row.好=="×"&&row.较好=="×"&&row.一般=="×"&&row.较差=="×"){
       // row.弃权= "√"
       e.form.alert("【" + row5.测评对象 + "】---好、较好、一般、较差、弃权至少选择一个!", "温馨提示")
       e.form.tabs1.active = "TabPage5";
       return;
      }
     }
     for (var i5 in rows5) {
      let row5 = rows5[i5];
      if (row5.好 == "√") {
       sum5 = sum5 + 1;
      }
     }
     data1.tablename = "SYS_Dictionary";
     data1.colname = "字典值";
     data1.filter = "备注='服务中心' and 分类='考核优等次数量'";
     e.form.getitems(data1, function(res1) {
      youdengci5 = res1[0].value;
      if (sum5 > youdengci5) {
       e.form.alert("服务中心【好】等次只能<或=" + youdengci5 + ",当前大于" + sum5 + ",请核实!", "温馨提示")
       e.form.tabs1.active = "TabPage5";
       return ;
      }
     })
    }
   }

 fun1()
  {
   fun2()
    {
     fun3()
      {
       fun4() 
        {
        
        }
       
       }
      }
                var tables = [e.form.edittable1.getdata(), e.form.edittable2.getdata(), e.form.edittable3.getdata(), e.form.edittable5.getdata()];
    data.tables = JSON.stringify(tables);
    data.onlytable = true;
    e.form.save(data, function() {
     fun()
    })
     }

 

  }
 }
})

 

 

红色代码部分  还是和一楼的代码实现的效果一样    会保存数据

 想让这fun1()  fun2()  fun3() fun4()  四个函数  都不弹出任何信息的情况下再执行
 var tables = [e.form.edittable1.getdata(), e.form.edittable2.getdata(), e.form.edittable3.getdata(), e.form.edittable5.getdata()];
    data.tables = JSON.stringify(tables);
    data.onlytable = true;
    e.form.save(data, function() {
     fun()
    })

 

有没有办法操作呢?

 

 


 回到顶部
帅哥哟,离线,有人找我吗?
有点蓝
  5楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:110750 积分:563676 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2023/2/1 8:38:00 [只看该作者]

这是一个回调函数:e.form.getitems(data1, function(res1) {

至于和这个回调函数的返回值怎么获取,建议咨询框架的开发人员,或者看他们的开发文档。

或者试试使用变量记录
var data = e.form.getdata();
   var rows = e.form.edittable1.rows;
var table1是否有值 = true;
   if (rows.length != 0) {
    let sum = 0;
    let ary = ["好", "较好", "一般", "较差"];
    for (var i in rows) {
     let row = rows[i];
     if (row.好 == "" && row.较好 == "" && row.一般 == "" && row.较差 == "" && row.弃权 == "") {
      e.form.alert("【" + row.测评对象 + "】---好、较好、一般、较差、弃权至少选择一个!", "温馨提示")
      e.form.tabs1.active = "TabPage1";
      return;
     }
    }
    for (var i in rows) {
     let row = rows[i];
     if (row.好 == "√") {
      sum = sum + 1;
     }
    }
    data1.tablename = "SYS_Dictionary";
    data1.colname = "字典值";
    data1.filter = "备注='公务' and 分类='考核优等次数量'";
    e.form.getitems(data1, function(res1) {
     youdengci1 = res1[0].value;
     if (sum > youdengci1) {
      e.form.alert("公务【好】等次只能<或=" + youdengci1 + ",当前大于" + sum + ",请核实!", "温馨提示")
      e.form.tabs1.active = "TabPage1";
table1是否有值 = false;
      return ture;
     }

    })
   }
   var rows2 = e.form.edittable2.rows;
……
if(table1是否有值 && table2是否有值 && .................
   var tables = [e.form.edittable1.getdata(), e.form.edittable2.getdata(), e.form.edittable3.getdata(), e.form.edittable5.getdata()];
   data.tables = JSON.stringify(tables);
   data.onlytable = true;
   e.form.save(data, function() {
    fun()
   })

 回到顶部