92 lines
4.2 KiB
JavaScript
92 lines
4.2 KiB
JavaScript
|
|
define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'template'], function ($, undefined, Backend, Table, Form) {
|
||
|
|
|
||
|
|
var Controller = {
|
||
|
|
index: function () {
|
||
|
|
// 初始化表格参数配置
|
||
|
|
Table.api.init({
|
||
|
|
extend: {
|
||
|
|
index_url: 'yq/perimeter/enterprise/index' + location.search,
|
||
|
|
add_url: 'yq/perimeter/enterprise/add',
|
||
|
|
edit_url: 'yq/perimeter/enterprise/edit',
|
||
|
|
del_url: 'yq/perimeter/enterprise/del',
|
||
|
|
multi_url: 'yq/perimeter/enterprise/multi',
|
||
|
|
import_url: 'yq/perimeter/enterprise/import',
|
||
|
|
table: 'perimeter',
|
||
|
|
}
|
||
|
|
});
|
||
|
|
|
||
|
|
var table = $("#table");
|
||
|
|
Template.helper("Moment", Moment);
|
||
|
|
// 初始化表格
|
||
|
|
table.bootstrapTable({
|
||
|
|
url: $.fn.bootstrapTable.defaults.extend.index_url,
|
||
|
|
templateView: true,
|
||
|
|
pk: 'id',
|
||
|
|
sortName: 'id',
|
||
|
|
fixedColumns: true,
|
||
|
|
fixedRightNumber: 1,
|
||
|
|
columns: [
|
||
|
|
[
|
||
|
|
{checkbox: true},
|
||
|
|
{field: 'id', title: __('Id')},
|
||
|
|
{field: 'pid', title: __('Pid')},
|
||
|
|
{field: 'name', title: __('Name'), operate: 'LIKE'},
|
||
|
|
{field: 'region_lv', title: __('Region_lv')},
|
||
|
|
{field: 'region_type', title: __('Region_type')},
|
||
|
|
{field: 'is_stop', title: __('Is_stop')},
|
||
|
|
{field: 'is_ban', title: __('Is_ban')},
|
||
|
|
{field: 'is_hazard', title: __('Is_hazard')},
|
||
|
|
{field: 'stop_vehicle', title: __('Stop_vehicle')},
|
||
|
|
{field: 'feasible_vehicle', title: __('Feasible_vehicle')},
|
||
|
|
{field: 'max_speed', title: __('Max_speed')},
|
||
|
|
{field: 'update_time', title: __('Update_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
|
||
|
|
{field: 'is_del', title: __('Is_del')},
|
||
|
|
{field: 'account', title: __('Account'), operate: 'LIKE'},
|
||
|
|
{field: 'password', title: __('Password'), operate: 'LIKE'},
|
||
|
|
{field: 'vehicle_count', title: __('Vehicle_count')},
|
||
|
|
{field: 'enter_vehicle', title: __('Enter_vehicle')},
|
||
|
|
{field: 'out_vehicle', title: __('Out_vehicle')},
|
||
|
|
{field: 'driverid', title: __('Driverid'), operate: 'LIKE'},
|
||
|
|
{field: 'enterprise_product', title: __('Enterprise_product'), operate: 'LIKE'},
|
||
|
|
{field: 'enterprise_lv', title: __('Enterprise_lv')},
|
||
|
|
{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
|
||
|
|
]
|
||
|
|
]
|
||
|
|
});
|
||
|
|
|
||
|
|
// 为表格绑定事件
|
||
|
|
Table.api.bindevent(table);
|
||
|
|
|
||
|
|
|
||
|
|
//指定搜索条件
|
||
|
|
$(document).on("click", ".btn-toggle-view", function () {
|
||
|
|
var options = table.bootstrapTable('getOptions');
|
||
|
|
table.bootstrapTable('refreshOptions', {templateView: !options.templateView});
|
||
|
|
});
|
||
|
|
|
||
|
|
//点击详情
|
||
|
|
$(document).on("click", ".btn-detail[data-id]", function () {
|
||
|
|
Backend.api.open($.fn.bootstrapTable.defaults.extend.edit_url+'/ids/' + $(this).data('id'), __('Detail'));
|
||
|
|
});
|
||
|
|
|
||
|
|
//获取选中项
|
||
|
|
$(document).on("click", ".btn-selected", function () {
|
||
|
|
//在templateView的模式下不能调用table.bootstrapTable('getSelections')来获取选中的ID,只能通过下面的Table.api.selectedids来获取
|
||
|
|
Layer.alert(JSON.stringify(Table.api.selectedids(table)));
|
||
|
|
});
|
||
|
|
},
|
||
|
|
add: function () {
|
||
|
|
Controller.api.bindevent();
|
||
|
|
},
|
||
|
|
edit: function () {
|
||
|
|
Controller.api.bindevent();
|
||
|
|
},
|
||
|
|
api: {
|
||
|
|
bindevent: function () {
|
||
|
|
Form.api.bindevent($("form[role=form]"));
|
||
|
|
}
|
||
|
|
}
|
||
|
|
};
|
||
|
|
return Controller;
|
||
|
|
});
|