文件
fenleixinxi/public/assets/js/backend/fc/plan.js

77 行
3.5 KiB
JavaScript

define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'backend/format'], function ($, undefined, Backend, Table, Form, Format) {
var Controller = {
index: function () {
// 初始化表格参数配置
Table.api.init({
extend: {
index_url: 'fc/plan/index' + location.search,
add_url: 'fc/plan/add',
edit_url: 'fc/plan/edit',
del_url: 'fc/plan/del',
multi_url: 'fc/plan/multi',
import_url: 'fc/plan/import',
table: 'fc_plan',
}
});
var table = $("#table");
// 初始化表格
table.bootstrapTable({
url: $.fn.bootstrapTable.defaults.extend.index_url,
pk: 'id',
sortName: 'sort',
fixedColumns: true,
fixedRightNumber: 1,
columns: [
[
{checkbox: true},
{field: 'id', title: __('SerialNo'), operate: false, sortable: false, align: 'center', width: '70px', class: 'fc-serial', table: table, formatter: Format.serial},
{field: 'plan_code', title: __('Plan_code'), operate: 'LIKE'},
{field: 'name', title: __('Name'), operate: 'LIKE'},
{
field: 'price', title: __('Price'), operate: 'BETWEEN',
formatter: function (value) {
return value === '' || value === null ? '-' : '¥' + parseFloat(value).toFixed(2);
}
},
{
field: 'origin_price', title: __('Origin_price'), operate: 'BETWEEN',
formatter: function (value) {
return value === '' || value === null ? '-' : '¥' + parseFloat(value).toFixed(2);
}
},
{field: 'days', title: __('Days')},
{field: 'tag', title: __('Tag'), operate: 'LIKE', formatter: Table.api.formatter.flag},
{
field: 'enabled', title: __('Enabled'),
searchList: {0: '否', 1: '是'},
formatter: Format.statusFormatter({0: '否', 1: '是'}, {0: 'default', 1: 'success'})
},
{field: 'sort', title: __('Sort')},
{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, visible: false},
{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, 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;
});