/** * 管理初始化 */ var TCoupon = { id: "TCouponTable", //表格id seItem: null, //选中的条目 table: null, layerIndex: -1 }; // console.log("父级页面"+window.parent.getElementById("counpons"+$("#index").val())); console.log("父级页面" + window.parent.document.getElementById("counpons" + $("#index").val()).value); console.log( $("#index").val()); var ids = window.parent.document.getElementById("counpons" + $("#index").val()).value; // 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: 'id', field: 'id', visible: false, align: 'center', valign: 'middle'}, {title: '优惠券名称', field: 'name', visible: true, align: 'center', valign: 'middle'}, {title: '优惠券类型', field: 'type', visible: true, align: 'center', valign: 'middle', formatter: function (value, row, index) { return {1: "满减券", 2: "代金券", 3: "体验券"}[value] }}, {title: '优惠券详情', field: 'illustrate', visible: true, align: 'center', valign: 'middle'}, ]; }; /** * 检查是否选中 */ 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) var selected = $('#' + this.id).bootstrapTable('getSelections'); // if(selected.length == 0){ // Feng.info("请先选中表格中的某一记录!"); // return false; // }else{ // return true; // } if (selected.length != 0) { TCoupon.seItem = selected[0]; TCoupon.seItem1 = selected; var ids = TCoupon.seItem1.map(function(item) { return item.id; }).join(","); // console.log("aaaaaa"+TCoupon.seItem1.map(function(item) { // return item.id; // }).join(",")) // if (window.parent.document.getElementById("counpons"+i).value==null||window.parent.document.getElementById("counpons"+i).value==""){ window.parent.document.getElementById("counpons"+i).value = ids; // }else { // window.parent.document.getElementById("counpons"+i).value = window.parent.document.getElementById("counpons"+i).value + ','+TCoupon.seItem.id; // // } window.parent.layer.closeAll(); }else { window.parent.document.getElementById("counpons"+i).value = ""; 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: '