define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) { var Controller = { index: function () { // 初始化表格参数配置 Table.api.init({ extend: { index_url: 'app/app_contract/index' + location.search, add_url: 'app/app_contract/add', edit_url: 'app/app_contract/edit', del_url: 'app/app_contract/del', // multi_url: 'app/app_contract/multi', // import_url: 'app/app_contract/import', table: 'app_contract', } }); var table = $("#table"); // 初始化表格 table.bootstrapTable({ url: $.fn.bootstrapTable.defaults.extend.index_url, pk: 'id', sortName: 'id', columns: [ [ {checkbox: true}, {field: 'id', title: __('Id')}, {field: 'daili_name', title: __('所属代理'), operate: 'LIKE'}, {field: 'user_id', title: __('用户ID')}, {field: 'user_name', title: __('用户')}, {field: 'coin_id', title: __('Coin_id')}, {field: 'symbol', title: __('Symbol'), operate: 'LIKE'}, {field: 'type', title: __('Type'), searchList: {"more":__('Type more'),"free":__('Type free')}, formatter: Table.api.formatter.normal}, {field: 'status', title: __('Status'), searchList: {"0":__('Status 0'),"1":__('Status 1'),"2":__('Status 2'),"3":__('Status 3')}, formatter: Table.api.formatter.status}, {field: 'price', title: __('Price'), operate:'BETWEEN'}, {field: 'pc_price', title: __('Pc_price'), operate:'BETWEEN'}, {field: 'num', title: __('Num')}, {field: 'multiple', title: __('Multiple')}, {field: 'promise_fee', title: __('Promise_fee'), operate:'BETWEEN'}, {field: 'fee', title: __('Fee'), operate:'BETWEEN'}, {field: 'zy_price', title: __('Zy_price'), operate:'BETWEEN'}, {field: 'zs_price', title: __('Zs_price'), operate:'BETWEEN'}, {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime}, {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime}, {field: 'pctime', title: __('Pctime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime}, {field: 'income', title: __('Income'), operate:'BETWEEN'}, {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate} ] ] }); // 为表格绑定事件 Table.api.bindevent(table); // 一键平仓按钮事件 $(document).on('click', '.btn-closeall', function () { Layer.confirm('确定要一键平仓所有持仓中的合约订单吗?此操作不可撤销!', { icon: 0, title: '一键平仓确认' }, function (index) { Layer.close(index); $.ajax({ url: 'app/app_contract/closeall', type: 'POST', dataType: 'json', success: function (ret) { if (ret.code === 1) { Layer.alert(ret.msg, {icon: 1}); table.bootstrapTable('refresh'); } else { Layer.alert(ret.msg, {icon: 2}); } }, error: function () { Layer.alert('请求失败', {icon: 2}); } }); }); }); }, add: function () { Controller.api.bindevent(); }, edit: function () { Controller.api.bindevent(); }, api: { bindevent: function () { Form.api.bindevent($("form[role=form]")); } } }; return Controller; });