html
html复制代码<div class="panel-body">
<div id="myTabContent" class="tab-content">
<div class="tab-pane fade active in" id="one">
<div class="widget-body no-padding">
<div id="toolbar" class="toolbar">
<a href="javascript:;" class="btn btn-primary btn-refresh" title="{:__('Refresh')}" ><i class="fa fa-refresh"></i> </a>
<a href="javascript:;" class="btn btn-success" id="setPriceBtn">设置平台售价</a>
</div>
<table id="table" class="table table-striped table-bordered table-hover table-nowrap"
data-operate-edit="{:$auth->check('goods/edit')}"
data-operate-del="{:$auth->check('goods/del')}"
width="100%">
</table>
</div>
</div>
</div>
</div>
js复制代码define(['jquery', 'bootstrap', 'backend', 'table', 'form','fast'], function ($, undefined, Backend, Table, Form, Fast) {
var Controller = {
index: function () {
// 初始化表格参数配置
Table.api.init({
extend: {
index_url: 'goods/index' + location.search,
set_price_url: 'goods/set_price',
table: 'goods',
}
});
var table = $("#table");
// 初始化表格
table.bootstrapTable({
url: $.fn.bootstrapTable.defaults.extend.index_url,
pk: 'id',
sortName: 'id',
columns: [
[
{field: 'id', title: __('Id')},
{field: 'goods_url', title: __('页面路径'), operate: 'LIKE'},
{field: 'goods_name', title: __('Goods_name'), operate: 'LIKE'},
]
]
});
// 设置平台价格
$('#setPriceBtn').on('click', function (){
Fast.api.open($.fn.bootstrapTable.defaults.extend.set_price_url+'?sign=1','设置平台售价');
});
// 为表格绑定事件
Table.api.bindevent(table);
},
add: function () {
Controller.api.bindevent();
},
edit: function () {
Controller.api.bindevent();
},
api: {
bindevent: function () {
Form.api.bindevent($("form[role=form]"));
}
},
price: function (){
Controller.api.bindevent();
}
};
return Controller;
});
php复制代码public function set_price()
if ($this->request->isPost()){
$params = $this->request->post('row/a');
$dataArr = $params;
// caozuo
if(){
$this->success('操作成功');
}else{
$this->error('操作失败');
}
}else{
$sign = $_GET['sign'];
$this->view->assign('sign',$sign);
return $this->view->fetch('set_price');
}
}
html文件
html复制代码<form id="edit-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
<input type="hidden" name="row[sign]" value="{$sign}" id="sign"/>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">涨价金额:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-goods_name" class="form-control" name="row[increase_money]" type="text" placeholder="请输入涨价金额" data-rule="required;number" value="">
</div>
</div>
<div class="form-group layer-footer">
<label class="control-label col-xs-12"></label>
<div class="col-xs-12 col-sm-8">
<button type="submit" class="btn btn-success btn-embossed disabled">{:__('OK')}</button>
<button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
</div>
</div>
</form>