layui 数据表格 根据值(1=业务,2=机构)显示中文名称

数据是用ThinkPHP5操作

类型是固定4个,

 

用layui templet - 自定义模板 方法一:

 {field:'type', title: '类型', width: 200, templet: '#titleTpl'}

 

 <script type="text/html" id="titleTpl">
  if({{d.type}}=='2'){机构}else if({{d.type}}=='3'){财务}
</script> 
 
 
 
其它方法二:(ThinkPHP5读数据)
            //分类显示中文名称
            $("[data-field='type']").children().each(function(){
                    if($(this).text()=='1'){
                       $(this).text("教务")
                    }else if($(this).text()=='2'){
                       $(this).text("机构")
                    }else if($(this).text()=='3'){
                       $(this).text("财务")
                    }else if($(this).text()=='4'){
                       $(this).text("业务")
                    }
            })

 

 

转:https://blog.csdn.net/haibo0668/article/details/78193575

 

参考 :http://www.layui.com/demo/table/style.html

 

posted @ 2018-08-13 09:15  与f  阅读(1864)  评论(0编辑  收藏  举报