javascript_bootstrap

数据格式化

前端界面接受到的数据都是string类型的,当以date传输到前端的时候,是以millionsecond为单位,可以进行如下操作对数据进行格式化

{title: "开始时间", field: "beginTime",align: 'center',formatter:TimeFormat},
                    {title: "结束时间", field: "endTime",align: 'center',formatter:TimeFormat},


        function TimeFormat(value){
            var date = new Date(value);
//          var format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            return date.toLocaleString();
        }

        Date.prototype.toLocaleString = function() {
              return this.getFullYear() + "-" + (this.getMonth() + 1) + "-" + this.getDate() + "  " + this.getHours() + ":" + this.getMinutes() + ":" + this.getSeconds();
        };

通过重写toLocaleString来对日期进行格式化

数据的判断显示

{title: "任务状态", field: "state",align: 'center',formatter:status},


  function status(value){
            if(value==1){
            return '<font color="red">有异常</font>';
            }else if(value == 0){
            return '<font color="black">进行中</font>';
            }else if(value == 2)
            return '<font color="green">已完成</font>';
        };

对于thymleaf的get拼接请求

使用框架的前端界面,会出现转义的问题,为了 避免这种不必要的转移,可以添加 标签date,如下

        function operateFormatter(value, row, index) {
           if(row.state == "1"){
                return [
                    '<a class="exception" href="javascript:void(0);">',
                    '<i class="glyphicon glyphicon-signal"></i>查看异常信息',
                    '</a>'
                ].join('');
                }
           else{
                return [

                ].join('');
                }

        }


        window.operateEvents = {
             'click .like': function (e, value, row, index) {
                connectTest(row.gisNodeUrl, index, true);
            },
            'click .exception':function (e, value, row, index){
                var _iframe = window.parent;
                /* <![CDATA[ */
                _iframe.showInfoLayer("/job/pathException?id="+row.taskId+"&nodeIp="+row.ip,"异常信息", "1100px", "600px");
                /* ]]> */
            },  
        };
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值