/** * 短信记录管理初始化 */ var TSmsrecord = { id: "TSmsrecordTable", //表格id seItem: null, //选中的条目 table: null, layerIndex: -1 }; /** * 初始化表格的列 */ TSmsrecord.initColumn = function () { return [ {field: 'selectItem', radio: true}, {title: '序号', field: 'id', visible: true, align: 'center', valign: 'middle'}, {title: '发送时间', field: 'insertTime', visible: true, align: 'center', valign: 'middle',width:'10%', formatter: function (value, row) { var btn = ""; if(row.insertTime != '' && row.insertTime != null) { var time = row.insertTime.replace(" ",'
'); btn = ['

' + time + '

'] } return btn; } }, {title: '接收人手机号', field: 'phone', visible: true, align: 'center', valign: 'middle', formatter: function (value, row) { var btn = ""; if(row.phone != '' && row.phone != null) { btn = ['

' + row.phone + '

'] } return btn; } }, {title: '发送内容', field: 'content', visible: true, align: 'center', valign: 'middle', formatter: function (value, row) { var btn = ""; if(row.content != '' && row.content != null) { var str = row.content; if (str.length > 50){ str = str.substring(0,50)+'...
'; } btn = ['

' + str + '

'] } return btn; } }, {title: '发送结果', field: 'result', visible: true, align: 'center', valign: 'middle', formatter: function (value, row) { var btn = ['

成功

'] return btn; } } ]; }; /** * 查看更多按钮 * @param con */ TSmsrecord.buttonClick = function (id,type) { var index = layer.open({ type: 2, title: language==1?'查看详情':(language==2?'View details':'Melihat rincian'), area: ['800px', '420px'], //宽高 fix: false, //不固定 maxmin: true, content: Feng.ctxPath + '/tSmsrecord/lookDetail/'+id+"/"+type }); this.layerIndex = index; } /** * 检查是否选中 */ TSmsrecord.check = function () { var selected = $('#' + this.id).bootstrapTable('getSelections'); if(selected.length == 0){ Feng.info("请先选中表格中的某一记录!"); return false; }else{ TSmsrecord.seItem = selected[0]; return true; } }; /** * 点击添加短信记录 */ TSmsrecord.openAddTSmsrecord = function () { var index = layer.open({ type: 2, title: language==1?'添加':(language==2?'Add':'Tambahkan'), area: ['800px', '420px'], //宽高 fix: false, //不固定 maxmin: true, content: Feng.ctxPath + '/tSmsrecord/tSmsrecord_add' }); this.layerIndex = index; }; /** * 打开查看短信记录详情 */ TSmsrecord.openTSmsrecordDetail = function () { if (this.check()) { var index = layer.open({ type: 2, title: language==1?'详情':(language==2?'details':'details'), area: ['800px', '420px'], //宽高 fix: false, //不固定 maxmin: true, content: Feng.ctxPath + '/tSmsrecord/tSmsrecord_update/' + TSmsrecord.seItem.id }); this.layerIndex = index; } }; /** * 删除短信记录 */ TSmsrecord.delete = function () { if (this.check()) { var ajax = new $ax(Feng.ctxPath + "/tSmsrecord/delete", function (data) { Feng.success("删除成功!"); TSmsrecord.table.refresh(); }, function (data) { Feng.error("删除失败!" + data.responseJSON.message + "!"); }); ajax.set("tSmsrecordId",this.seItem.id); ajax.start(); } }; /** * 查询短信记录列表 */ TSmsrecord.search = function () { var queryData = {}; queryData['insertTime'] = $("#insertTime").val(); queryData['phone'] = $("#phone").val(); TSmsrecord.table.refresh({query: queryData}); }; TSmsrecord.resetSearch = function () { $("#insertTime").val(""); $("#phone").val(""); TSmsrecord.search(); }; $(function () { var defaultColunms = TSmsrecord.initColumn(); var table = new BSTable(TSmsrecord.id, "/tSmsrecord/list", defaultColunms); table.setPaginationType("server"); TSmsrecord.table = table.init(); });