/** * 车辆管理管理初始化 */ var TPointProducts = { id: "TPointProductsTable", //表格id seItem: null, //选中的条目 table: null, layerIndex: -1 }; var language =1 /** * 初始化表格的列 */ TPointProducts.initColumn = function () { return [ {field: 'selectItem', checkbox: true}, {title: '序号', field: 'id', visible: true, align: 'center', valign: 'middle'}, {title: '商品名称', field: 'name', visible: true, align: 'center', valign: 'middle', // formatter: function (value, row, index) { // return {1: "日卡票", 2: "月卡票", 3: "季卡票", 4: "年卡票"}[value] // } }, {title: '商品封面', field: 'cover', visible: true, align: 'center', valign: 'middle', formatter: function (value, row, index) { value = typeof value == "undefined" || value == '' ? '/static/img/NoPIC.png' : value; return '' } }, {title: '有效期', field: 'timeValue', visible: true, align: 'center', valign: 'middle' }, {title: '兑换地点', field: 'useScope', visible: true, align: 'center', valign: 'middle', formatter: function (value, row, index) { return {1: "全国", 2: "指定城市", 3: "指定门店"}[value] } }, {title: '用户人群', field: 'userPopulation', visible: true, align: 'center', valign: 'middle', formatter: function (value, row, index) { return {1: "全部用户", 2: "年度会员", 3: "已有学员用户"}[value] } }, {title: '发放数量', field: 'quantityIssued', visible: true, align: 'center', valign: 'middle' }, {title: '限领数量', field: 'pickUpQuantity', visible: true, align: 'center', valign: 'middle' }, {title: '已领数量', field: 'hasExchangeQty', visible: true, align: 'center', valign: 'middle' }, {title: '已兑换数量', field: 'hasPickQty', visible: true, align: 'center', valign: 'middle' }, {title: '排序', field: 'sort', visible: true, align: 'center', valign: 'middle'}, {title: '活动状态', field: 'activeStatus', visible: true, align: 'center', valign: 'middle', formatter: function (value, row, index) { return {1: "未开始", 2: "已开始", 3: "已结束"}[value] } }, {title: '可售状态', field: 'shelves', visible: true, align: 'center', valign: 'middle', formatter: function (value, row, index) { return {1: "上架", 2: "下架"}[value] } }, {title: '审核状态', field: 'auditStatus', visible: true, align: 'center', valign: 'middle', formatter: function (value, row, index) { return {2: "待审核", 1: "已通过",3: "已拒绝"}[value] }}, ]; }; function currentTime(timestamp){ var time = timestamp + ''; if(time.length != 13){ timestamp = timestamp * 1000; } var date = new Date(timestamp);; var Y = date.getFullYear() + '-'; var M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-'; var D = (date.getDate() < 10 ? '0' + (date.getDate()) : date.getDate()) + ' '; var h = (date.getHours() < 10 ? '0' + (date.getHours()) : date.getHours()) + ':'; var m = (date.getMinutes() < 10 ? '0' + (date.getMinutes()) : date.getMinutes()) + ':'; var s = (date.getSeconds() < 10 ? '0' + (date.getSeconds()) : date.getSeconds()); var strDate = Y + M + D + h + m + s; return strDate } function currentTime1(timestamp){ var time = timestamp + ''; if(time.length != 13){ timestamp = timestamp * 1000; } var date = new Date(timestamp);; var Y = date.getFullYear() + '-'; var M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-'; var D = (date.getDate() < 10 ? '0' + (date.getDate()) : date.getDate()) + ' '; var h = (date.getHours() < 10 ? '0' + (date.getHours()) : date.getHours()) + ':'; var m = (date.getMinutes() < 10 ? '0' + (date.getMinutes()) : date.getMinutes()) + ':'; var s = (date.getSeconds() < 10 ? '0' + (date.getSeconds()) : date.getSeconds()); var strDate = Y + M + D ; return strDate } /** * 检查是否选中 */ TPointProducts.check = function () { var selected = $('#' + this.id).bootstrapTable('getSelections'); if(selected.length == 0){ Feng.info("请先选中表格中的某一记录!"); return false; }else{ TPointProducts.seItem = selected[0]; return true; } }; /** * 添加 */ TPointProducts.openAddTPointProducts = function () { var index = layer.open({ type: 2, title: '添加', area: ['100%', '100%'], //宽高 fix: false, //不固定 maxmin: true, content: Feng.ctxPath + '/ticket/add' }); this.layerIndex = index; }; /** * 查看详情 */ TPointProducts.detail = function () { if (this.check()) { var index = layer.open({ type: 2, title:'编辑', area: ['100%', '100%'], //宽高 fix: false, //不固定 maxmin: true, content: Feng.ctxPath + '/tGoods/goods_info/' + TPointProducts.seItem.id }); this.layerIndex = index; } }; /** * 购买详情 */ TPointProducts.payDetail = function () { if (this.check()) { var index = layer.open({ type: 2, title:'购买详情', area: ['70%', '70%'], //宽高 fix: false, //不固定 maxmin: true, content: Feng.ctxPath + '/tGoods/tPay_detail1/' + TPointProducts.seItem.id }); this.layerIndex = index; } }; /** * 编辑页面 */ TPointProducts.openEditPage = function () { if (this.check()) { let size = TPointProducts.seItem.size if(size>0){ Feng.info("没有操作权限"); return; } var index = layer.open({ type: 2, title:'编辑', area: ['100%', '100%'], //宽高 fix: false, //不固定 maxmin: true, content: Feng.ctxPath + '/tGoods/tGoods_update/' + TPointProducts.seItem.id }); this.layerIndex = index; } } /** * 上架处理 * @param m */ TPointProducts.onShelf = function () { if (this.check()){ let size = TPointProducts.seItem.size if(size>0){ Feng.info("没有操作权限"); return; } var selected = $('#' + this.id).bootstrapTable('getSelections'); const data1 = { ids:[], state:null }; selected.forEach(function(obj) { var id = obj.id; data1.ids.push(id); }); data1.state = 1; $.ajax({ url: Feng.ctxPath + "/ticket/changeState", type: "POST", contentType: "application/json", // 设置请求头的 Content-Type data: JSON.stringify(data1), // 将数据转换为 JSON 字符串 success: function(response) { Feng.success("上架成功!"); TPointProducts.search(); }, error: function(xhr, status, error) { var errorMessage = xhr.responseText ? xhr.responseText : "修改失败!"; Feng.error("您的网络异常!"); } }); } }; /** * 下架处理 * @param m */ TPointProducts.offShelf = function () { if (this.check()){ let size = TPointProducts.seItem.size if(size>0){ Feng.info("没有操作权限"); return; } var selected = $('#' + this.id).bootstrapTable('getSelections'); const data1 = { ids:[], state:null }; selected.forEach(function(obj) { var id = obj.id; data1.ids.push(id); }); data1.state = 2; $.ajax({ url: Feng.ctxPath + "/ticket/changeState", type: "POST", contentType: "application/json", // 设置请求头的 Content-Type data: JSON.stringify(data1), // 将数据转换为 JSON 字符串 success: function(response) { Feng.success("下架成功!"); TPointProducts.search(); }, error: function(xhr, status, error) { } }); } }; /** * 查询车辆管理列表 */ TPointProducts.search = function () { var queryData = {}; queryData['name'] = $("#name").val(); queryData['type'] = $("#type").val(); queryData['redemptionMethod'] = $("#redemptionMethod").val(); queryData['userPopulation'] = $("#userPopulation").val(); queryData['activeStatus'] = $("#activeStatus").val(); queryData['state'] = $("#state").val(); TPointProducts.table.refresh({query: queryData}); }; TPointProducts.resetSearch = function () { $("#name").val(""); $("#type").val(""); $("#redemptionMethod").val(""); $("#userPopulation").val(""); $("#activeStatus").val(""); $("#state").val(""); TPointProducts.search(); }; $(function () { var defaultColunms = TPointProducts.initColumn(); var table = new BSTable(TPointProducts.id, "/ticket/listAll", defaultColunms); table.setPaginationType("client"); TPointProducts.table = table.init(); });