/** * 管理初始化 */ var TDriverPromotionActivity = { id: "TDriverPromotionActivityTable", //表格id seItem: null, //选中的条目 table: null, layerIndex: -1 }; /** * 初始化表格的列 */ TDriverPromotionActivity.initColumn = function () { return [ {field: 'selectItem', radio: true}, {title: '推广排名', field: 'sort', visible: true, align: 'center', valign: 'middle', formatter: function (value, row, index) { // 使用序号作为排名,index从0开始,所以需要+1 return index + 1; } }, {title: '司机Id', field: 'driverId', visible: false, align: 'center', valign: 'middle'}, {title: '司机姓名', field: 'driverName', visible: true, align: 'center', valign: 'middle'}, {title: '推广用户数量', field: 'userNum', visible: true, align: 'center', valign: 'middle'}, {title: '推广收益合计', field: 'money', visible: true, align: 'center', valign: 'middle', }, { title: '操作', field: 'opt', visible: true, align: 'left', valign: 'middle', width: "10%", formatter: function (value, row) { var btn = []; btn += '查看下级用户  '; btn += '查看收益明细  '; return btn; } } ]; }; /** * 检查是否选中 */ TDriverPromotionActivity.check = function () { var selected = $('#' + this.id).bootstrapTable('getSelections'); if (selected.length == 0) { Feng.info("请先选中表格中的某一记录!"); return false; } else { TDriverPromotionActivity.seItem = selected[0]; return true; } }; /** * 点击添加 */ TDriverPromotionActivity.openAddTDriverPromotionActivity = function () { var index = layer.open({ type: 2, title: '添加', area: ['100%', '100%'], //宽高 fix: false, //不固定 maxmin: true, content: Feng.ctxPath + '/tDriverPromotionActivity/tDriverPromotionActivity_add' }); this.layerIndex = index; }; /** * 打开查看详情 */ TDriverPromotionActivity.viewUser = function (e) { var index = layer.open({ type: 2, title: '司机推广下级用户', area: ['100%', '100%'], //宽高 fix: false, //不固定 maxmin: true, content: Feng.ctxPath + '/tDriverPromotionActivity/tDriverPromotionActivity_viewUser/' + e }); this.layerIndex = index; }; /** * 打开查看详情 */ TDriverPromotionActivity.viewMoney = function (e,e1) { var index = layer.open({ type: 2, title: '推广收益明细', area: ['100%', '100%'], //宽高 fix: false, //不固定 maxmin: true, content: Feng.ctxPath + '/tDriverPromotionActivity/tDriverPromotionActivity_viewMoney/' + e+"/"+e1 }); this.layerIndex = index; }; /** * 打开查看详情 */ TDriverPromotionActivity.update = function (e) { var index = layer.open({ type: 2, title: '编辑', area: ['100%', '100%'], //宽高 fix: false, //不固定 maxmin: true, content: Feng.ctxPath + '/tDriverPromotionActivity/tDriverPromotionActivity_update/' + e }); this.layerIndex = index; }; TDriverPromotionActivity.info = function (e) { var index = layer.open({ type: 2, title: '编辑', area: ['100%', '100%'], //宽高 fix: false, //不固定 maxmin: true, content: Feng.ctxPath + '/tDriverPromotionActivity/tDriverPromotionActivity_info/' + e }); this.layerIndex = index; }; /** * 删除 */ TDriverPromotionActivity.delete = function (e) { var ajax = new $ax(Feng.ctxPath + "/tDriverPromotionActivity/delete", function (data) { Feng.success("删除成功!"); TDriverPromotionActivity.table.refresh(); }, function (data) { Feng.error("删除失败!" + data.responseJSON.message + "!"); }); ajax.set("tDriverPromotionActivityId", e); ajax.start(); }; TDriverPromotionActivity.stop = function (e) { var ajax = new $ax(Feng.ctxPath + "/tDriverPromotionActivity/stop", function (data) { Feng.success("暂停成功!"); TDriverPromotionActivity.table.refresh(); }, function (data) { Feng.error("暂停失败!" + data.responseJSON.message + "!"); }); ajax.set("id", e); ajax.start(); }; TDriverPromotionActivity.start = function (e) { var ajax = new $ax(Feng.ctxPath + "/tDriverPromotionActivity/start", function (data) { Feng.success("暂停成功!"); TDriverPromotionActivity.table.refresh(); }, function (data) { Feng.error("暂停失败!" + data.responseJSON.message + "!"); }); ajax.set("id", e); ajax.start(); }; TDriverPromotionActivity.startOrStop = function () { if (this.check()) { if (TDriverPromotionActivity.seItem.status == 1) { TDriverPromotionActivity.stop(TDriverPromotionActivity.seItem.id); } else { TDriverPromotionActivity.start(TDriverPromotionActivity.seItem.id); } } }; /** * 查询列表 */ TDriverPromotionActivity.search = function () { var queryData = {}; queryData['driverName'] = $("#driverName").val(); queryData['id'] = $("#id").val(); TDriverPromotionActivity.table.refresh({query: queryData}); }; TDriverPromotionActivity.resetSearch = function () { $("#driverName").val(''); TDriverPromotionActivity.search() }; TDriverPromotionActivity.exportExcel = function () { let p = ""; let id = $('#id').val(); let driverName = $('#driverName').val(); if(null != id && '' != id){ p += "id=" + id + "&"; } if(null != driverName && '' != driverName){ p += "driverName=" + driverName + "&"; } if('' != p){ p = "?" + p.substring(0, p.length - 1); } console.log('p['+p+']') window.location.href = Feng.ctxPath + '/tDriverPromotionActivity/export' + p; }; $(function () { var defaultColunms = TDriverPromotionActivity.initColumn(); var table = new BSTable(TDriverPromotionActivity.id, "/tDriverPromotionActivity/list1", defaultColunms); table.setPaginationType("client"); TDriverPromotionActivity.table = table.init(); TDriverPromotionActivity.search() });