layui使用templet格式化表格数据的方法
网络编程 2021-07-04 15:01www.168986.cn编程入门
今天长沙网络推广就为大家分享一篇layui使用templet格式化表格数据的方法,具有很好的参考价值,希望对大家有所帮助。一起跟随长沙网络推广过来看看吧
增加js
/*---------------------格式化时间开始--------------------------*/
//对Date的扩展,将 Date 转化为指定格式的String //月(M)、日(d)、小时(h)、分(m)、秒(s)、季度(q) 可以用 1-2 个占位符, //年(y)可以用 1-4 个占位符,毫秒(S)只能用 1 个占位符(是 1-3 位的数字) //例子: //(new Date()).Format("yyyy-MM-dd hh:mm:ss.S") ==> 2006-07-02 08:09:04.423 //(new Date()).Format("yyyy-M-d h:m:s.S") ==> 2006-7-2 8:9:4.18 Date.prototype.Format = function (fmt) { //author: meizz var o = { "M+": this.getMonth() + 1, //月份 "d+": this.getDate(), //日 "h+": this.getHours(), //小时 "m+": this.getMinutes(), //分 "s+": this.getSeconds(), //秒 "q+": Math.floor((this.getMonth() + 3) / 3), //季度 "S": this.getMilliseconds() //毫秒 }; if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length)); for (var k in o) if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length))); return fmt; } var date = new Date();
/*---------------------格式化时间结束--------------------------*/
cols: [[ { type: 'numbers', title: '序号', width: 50 }, { type: 'checkbox' }, { field: 'BILL_NO', title: '单据编码', width: 230, }, { field: 'BIZ_STATUS', title: '单据状态', templet: function (d) { return getDictName('COM_BIZ_STATUS', d.BIZ_STATUS); }, width: 100, }, { field: 'RETURN_MSG_CODE', title: '状态', width: 100, }, { field: 'UNIT_NAME', title: '创建组织', width: 100, }, { field: 'BUSIN_TYPE_ITEM_NAME', title: '业务类别', width: 230, }, { field: 'TITLE', title: '申请单标题', width: 280, }, { field: 'CREATE_BY_NAME', title: '创建人姓名', width: 130, }, { field: 'GMT_CREATE', title: '创建时间', sort: false, templet: function (d) { date.setTime(d.GMT_CREATE); return date.Format("yyyy-MM-dd hh:mm:ss"); }, width: 130, }, { field: 'RETURN_MSG', title: '传输云超市返回信息', width: 400, }, ]],
格式化创建时间
格式化单据状态直接调用function的方法返回对应的显示值
以上这篇layui使用templet格式化表格数据的方法就是长沙网络推广分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持狼蚁SEO。
编程语言
- 机械手焊接机器人编程 机械手焊接设备编程
- vb数据库编程实例,vb做数据库
- tiobe世界编程语言排行榜,全球编程语言排行
- 成都java编程培训 成都it编程培训中心
- 编程基础培训,编程基础知识培训
- flash游戏编程基础教程,flash游戏开发教程
- 不会英语能学编程吗 不会英语可以学程序员吗
- 爱心代码编程C语言 爱心代码编程c语言公式
- c语言编程学习入门 c语言编程快速入门
- 西门子plc编程培训 西门子plc编程培训班
- 哪里可以学编程 台州哪里可以学编程
- 少儿编程哪个好 少儿编程哪个品牌好
- 编程是什么意思,图形编程是什么意思
- c语言编程软件下载,c语言编程软件在哪下载
- java编程软件下载,java编程下载手机版
- ug编程培训学校,ug编程培训教程