管理系统表达式配置页面及js

本文介绍了在开发管理系统时如何配置和处理表达式。详细讲述了生成表达式的过程,通过回调函数实现多层table的拼接。接着阐述了解析表达式的方法,一层层解析直至无括号,并使用特定数据结构存储解析结果。最后讨论了回显表达式,特别是处理"()"时,通过getDivHtml和createTableHtml方法实现表达式的正确显示。
摘要由CSDN通过智能技术生成

 开发管理系统,碰到了需要配置表达式的地方。花了半天的时间把自己写的整理了一下。页面的效果是下图。

1.生成表达式

       页面是有多个table块嵌套而成的。在拼接表达式的时候可以使用回调,具体的方法实现如下:

function doaddCondition(tableId){
    var expression = '';
    var spanId =  $("#"+tableId+" td:first-child").attr("id");
    var word = $("#"+spanId+" span[class=\'show-cond-word\']").attr("name");
    var symbol = "and";
    if(word=='word1'){
        symbol = 'and';
    }else if(word='word2'){
        symbol = "or";
    }
    var condition_id = $("#"+spanId).next().attr("id");
    var condition_lenght = $("#"+condition_id).children().length;
    var cond_before_child = $("#"+condition_id+" :first-child").attr("id");
    console.log("处理该div下的第一个代码块");
    if(checkTable(cond_before_child)){
        console.log("这个块是table块");
        expression ="("+doaddCondition(cond_before_child)+")";
    }else{
        console.log("这是个div块");
        var select1 = $("#"+cond_before_child+" select[name=\'select1\']").val();
        var select2 = $("#"+cond_before_child+" select[name=\'select2\']").val();
        var text =  $("#"+cond_before_child+" input[name=\'text1\']").val();
        if(checkInfo(select1)&&checkInfo(select2)&&checkInfo(text)){
            expression =select1+select2+"'"+text+"'";
        }else{
            return false;
        }
    }
    var cond_next_child = cond_before_child;
    for(var i=0;i<condition_lenght-1;i++){
        
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值