/** * 管理初始化 */ var TCoupon = { id: "TCouponTable", //表格id seItem: null, //选中的条目 table: null, layerIndex: -1 }; var ids = $("#conpund").val(); console.log("==========radio=="+ids) /** * 初始化表格的列 */ TCoupon.initColumn = function () { return [ {field: 'selectItem', checkbox: true, formatter: function (value,row) { if(ids.indexOf(row.id)!= -1){ return {checked:true}; }}}, {title: '序号', field: 'id', visible: true, align: 'center', valign: 'middle'}, {title: '优惠券名称', field: 'name', 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: 'type', visible: true, align: 'center', valign: 'middle', formatter: function (value, row, index) { return {1: "满减券", 2: "代金券", 3: "体验券"}[value] }}, {title: '发放方式', field: 'distributionMethod', visible: true, align: 'center', valign: 'middle', formatter: function (value, row, index) { return {1: "积分购买", 2: "注册赠送", 3: "自动发券"}[value] }}, {title: '有效期', field: 'timeValue', visible: true, align: 'center', valign: 'middle'}, {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: 'hasPickQty', visible: true, align: 'center', valign: 'middle'}, {title: '活动状态', field: 'status', visible: true, align: 'center', valign: 'middle', formatter: function (value, row, index) { return {1: "未开始", 2: "已开始", 3: "已结束"}[value] }}, {title: '可售状态', field: 'state', visible: true, align: 'center', valign: 'middle', formatter: function (value, row, index) { return {1: "上架", 2: "下架"}[value] }}, ]; }; /** * 检查是否选中 */ TCoupon.check = function () { var selected = $('#' + this.id).bootstrapTable('getSelections'); if(selected.length == 0){ Feng.info("请先选中表格中的某一记录!"); return false; }else{ TCoupon.seItem = selected[0]; TCoupon.seItem1 = selected; return true; } }; /** * 点击添加 */ TCoupon.openAdd = function () { var index = layer.open({ type: 2, title: '添加', area: ['100%', '100%'], //宽高 fix: false, //不固定 maxmin: true, content: Feng.ctxPath + '/tCouponManage/coupon_add' }); this.layerIndex = index; }; TCoupon.backids = function (i) { console.log("aaaaaa"+i) if (this.check()) { var ids = TCoupon.seItem1.map(function(item) { return item.id; }).join(","); window.parent.document.getElementById("counpons"+i).value = ids; window.parent.layer.closeAll(); } }; /** * 点击编辑 */ TCoupon.openChange = function () { if (this.check()){ let id = TCoupon.seItem.id let name = TCoupon.seItem.name let quantityIssued = TCoupon.seItem.quantityIssued let pickUpQuantity = TCoupon.seItem.pickUpQuantity let illustrate = TCoupon.seItem.illustrate let hasPickQty = TCoupon.seItem.hasPickQty var index = layer.load(1,{ type: 1 , title: '编辑优惠券' , area: ['50%', '50%'] , offset: 'auto' //具体配置参考:http://www.layui.com/doc/modules/layer.html#offset , id: 'layerDemo' //防止重复弹出cge , content: '
' + '
' + '
' + '
\n' + ' \n' + '
\n' + ' '+ '
\n' + '
\n'+ '
\n' + ' \n' + '
\n' + ' '+ '
\n' + '
\n' + '
\n' + ' \n' + '
\n' + ' '+ '
\n' + '
\n' + '
\n' + ' \n' + '
\n' + ' '+ '
\n' + '
\n' + '
' + '
' + '
' , btn: ['关闭', '保存'] , btnAlign: 'c' //按钮居中 , shade: 0.5 //不显示遮罩 ,load:1 , yes: function () { layer.closeAll(); }, btn2:function () { let num = $("#num").val() if(num==''){ Feng.info("请输入发放数量") return false; } let num1 = $("#num1").val() if(num1==''){ Feng.info("请输入限领数量") return false; } let text = $("#text").val() if(text==''){ Feng.info("请输入优惠券说明") return false; } if(num