car4s/public/assets/js/backend/user4s/log.js

144 lines
6.1 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'editable'], function ($, undefined, Backend, Table, Form, undefined) {
var Controller = {
index: function () {
// 初始化表格参数配置
Table.api.init({
extend: {
index_url: 'user4s/log/index' + location.search,
//add_url: 'user4s/log/add',
//edit_url: 'user4s/log/edit',
//del_url: 'user4s/log/del',
multi_url: 'user4s/log/multi',
//import_url: 'user4s/log/import',
table: 'user4s_log',
}
});
var table = $("#table");
// 初始化表格
table.bootstrapTable({
url: $.fn.bootstrapTable.defaults.extend.index_url,
pk: 'id',
sortName: 'id',
fixedColumns: true,
fixedRightNumber: 1,
showToggle: false,
maintainSelected: true,
columns: [
[
{checkbox: true},
{field: 'id', title: __('Id'),operate:false},
// { field: 'user4s_id', title: __('User4s_id') },
{field: 'user.name', title: __('会员姓名'), operate: 'LIKE'},
//{field: 'admin_id', title: __('Admin_id')},
//{field: 'title', title: __('Title'), operate: 'LIKE'},
{field: 'description', title: __('Description'), operate: 'LIKE',editable:true},
{field: 'start', title: __('原数额'), operate: false},
{field: 'end', title: __('更改后数额'), operate: false},
{field: 'state', title: __('State'), searchList: {"0":__('State 0'),"1":__('State 1')}, formatter: Table.api.formatter.normal},
//{field: 'user.name', title: __('User.name'), operate: 'LIKE'},
{ field: 'admin.nickname', title: __('操作人员'), operate: 'LIKE' },
{field: 'createtime', title: __('操作时间'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
//{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
]
],
queryParams: function (params) {
//这里可以追加搜索条件
var filter = JSON.parse(params.filter);
var op = JSON.parse(params.op);
//这里可以动态赋值比如从URL中获取admin_id的值filter.admin_id=Fast.api.query('admin_id');
filter.user4s_id = Fast.api.query('user4s_id');
op.user4s_id = "=";
if (filter.user4s_id == null || filter.user4s_id == "") {
delete filter.user4s_id;
delete op.user4s_id;
}
params.filter = JSON.stringify(filter);
params.op = JSON.stringify(op);
console.log(params);
return params;
},
});
// 为表格绑定事件
Table.api.bindevent(table);
},
recyclebin: function () {
// 初始化表格参数配置
Table.api.init({
extend: {
'dragsort_url': ''
}
});
var table = $("#table");
// 初始化表格
table.bootstrapTable({
url: 'user4s/log/recyclebin' + location.search,
pk: 'id',
sortName: 'id',
columns: [
[
{checkbox: true},
{field: 'id', title: __('Id')},
{field: 'title', title: __('Title'), align: 'left'},
{
field: 'deletetime',
title: __('Deletetime'),
operate: 'RANGE',
addclass: 'datetimerange',
formatter: Table.api.formatter.datetime
},
{
field: 'operate',
width: '130px',
title: __('Operate'),
table: table,
events: Table.api.events.operate,
buttons: [
{
name: 'Restore',
text: __('Restore'),
classname: 'btn btn-xs btn-info btn-ajax btn-restoreit',
icon: 'fa fa-rotate-left',
url: 'user4s/log/restore',
refresh: true
},
{
name: 'Destroy',
text: __('Destroy'),
classname: 'btn btn-xs btn-danger btn-ajax btn-destroyit',
icon: 'fa fa-times',
url: 'user4s/log/destroy',
refresh: true
}
],
formatter: Table.api.formatter.operate
}
]
]
});
// 为表格绑定事件
Table.api.bindevent(table);
},
add: function () {
Controller.api.bindevent();
},
edit: function () {
Controller.api.bindevent();
},
api: {
bindevent: function () {
Form.api.bindevent($("form[role=form]"));
}
}
};
return Controller;
});