Add.html
添加一个选择按钮
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Goods_name')}:</label>
<div class="col-xs-12 col-sm-8">
<div class="input-group">
<input id="c-goods_name" data-rule="required" class="form-control" name="row[goods_name]" type="text" value="" readonly="readonly">
<div class="input-group-addon no-border no-padding">
<span><button type="button" id="fachoose-goods" class="btn btn-primary fachoose-goods" data-input-id="c-goods" data-multiple="false"><i class="fa fa-list"></i> {:__('Choose')}</button></span>
</div>
<span class="msg-box n-right" for="c-image"></span>
</div>
<input id="c-goods_id" data-rule="" class="form-control" name="row[goods_id]" type="hidden" value="">
<!-- <ul class="row list-inline plupload-preview" id="p-image"></ul>-->
</div>
</div>
Add js
$(".fachoose-goods").click(function () {
Fast.api.open('groupbuy/group_buy/search_goods', __('Goods'), {
callback:function(data){
console.log(data.goods_id);
console.log(data.goods_name);
//在这里可以接收弹出层中使用`Fast.api.close(data)`进行回传数据
$("#c-goods_id").val(data.goods_id);
$("#c-goods_name").val(data.goods_name);
}
});
})
search_goods html
<button type="reset" class="btn btn-primary btn-embossed btn-close">{:__('OK')}</button>
search_goods JS
$(".btn-close").click(function (e) {
var rows = table.bootstrapTable('getSelections');
if(rows.length == 0){
Toastr.info("至少选择一项商品");
return;
}
var goods_ids = Table.api.selectedids(table);
var goods_name =rows[0].goods_name;
console.log(goods_ids[0]);
console.log(goods_name);
Fast.api.close({goods_id:goods_ids[0],goods_name:goods_name});
})