113 行
5.7 KiB
JavaScript
113 行
5.7 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'),
|
|
formatter: function (value) {
|
|
return (value || 0) + ' 天';
|
|
}
|
|
},
|
|
{
|
|
field: 'post_quota', title: __('Post_quota'), operate: 'BETWEEN',
|
|
formatter: function (value) {
|
|
var n = parseInt(value || 0, 10);
|
|
return n > 0 ? '<span class="text-success">' + n + ' 条</span>' : '<span class="text-muted">不赠送</span>';
|
|
}
|
|
},
|
|
{
|
|
field: 'view_quota', title: __('View_quota'), operate: 'BETWEEN',
|
|
formatter: function (value) {
|
|
var n = parseInt(value !== undefined && value !== null ? value : 20, 10);
|
|
return n === 0 ? '<span class="label label-success">不限次浏览</span>' : (n + ' 条/日');
|
|
}
|
|
},
|
|
{
|
|
field: 'call_quota', title: __('Call_quota'), operate: 'BETWEEN',
|
|
formatter: function (value) {
|
|
var n = parseInt(value !== undefined && value !== null ? value : 30, 10);
|
|
return n === 0 ? '<span class="label label-success">不限次拨打</span>' : (n + ' 次/日');
|
|
}
|
|
},
|
|
{
|
|
field: 'post_discount', title: __('Post_discount'), operate: 'BETWEEN',
|
|
formatter: function (value) {
|
|
var d = parseFloat(value !== undefined && value !== null ? value : 8.0);
|
|
if (isNaN(d) || d >= 10 || d <= 0) {
|
|
return '<span class="text-muted">原价</span>';
|
|
}
|
|
return '<span class="text-warning"><strong>' + parseFloat(d.toFixed(1)) + ' 折</strong></span>';
|
|
}
|
|
},
|
|
{field: 'tag', title: __('Tag'), operate: 'LIKE', formatter: Table.api.formatter.flag},
|
|
{
|
|
field: 'enabled', title: __('Enabled'),
|
|
searchList: {0: '否', 1: '是'},
|
|
formatter: Table.api.formatter.toggle
|
|
},
|
|
{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;
|
|
});
|