123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139 |
- define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
- var Controller = {
- index: function () {
- // 初始化表格参数配置
- Table.api.init({
- extend: {
- index_url: 'guidemanage/index',
- add_url: 'guidemanage/add',
- edit_url: 'guidemanage/edit',
- del_url: 'guidemanage/del',
- multi_url: 'guidemanage/multi',
- table: 'guidemanage',
- }
- });
- var table = $("#table");
- // 初始化表格
- table.bootstrapTable({
- url: $.fn.bootstrapTable.defaults.extend.index_url,
- pk: 'id',
- sortName: 'state desc, updatetime desc,id',
- sortOrder:'',
- search: false,
- searchFormVisible: true,
- columns: [
- [
- {checkbox: true},
- {field: 'id', title: __('Id'), operate: 'LIKE %...%'},
- {field: 'channel_id', title: __('channel_id'), operate: 'LIKE %...%'},
- {
- field: 'state',
- title: __('state'),
- visible: false,
- searchList: {"0": __('关闭'), "1": __('启用')}
- },
- {
- field: 'state_text',
- title: __('state'),
- operate: false,
- formatter: function (value, row, index) {
- if (row.state == "0") {
- return '<span style="color:red">关闭</span>';
- } else {
- return '<span style="color:green">启用</span>';
- }
- }
- },
- {
- field: 'createtime',
- title: __('Createtime'),
- formatter: Table.api.formatter.datetime,
- type: 'datetime',
- operate:false,
- addclass: 'datetimerange'
- },
- {
- field: 'updatetime',
- title: __('Updatetime'),
- formatter: Table.api.formatter.datetime,
- type: 'datetime',
- operate:false,
- addclass: 'datetimerange'
- },
- {
- field: 'operate',
- title: __('Operate'),
- table: table,
- events: Table.api.events.operate,
- formatter: Table.api.formatter.operate
- }
- ]
- ]
- });
- // 为表格绑定事件
- Table.api.bindevent(table);
- Controller.api.bindevent();
- },
- add: function () {
- $("#c-host").on("blur", function () {
- var len = $(this).val().split("\n").length;
- $("#host_length").find("span").text(len);
- $("#host_length").css("color", len > 50 ? "red" : "");
- });
- Controller.api.bindevent();
- },
- edit: function () {
- Controller.api.bindevent();
- },
- open: function () {
- var that = this;
- var table = $("#table");
- var ids = Table.api.selectedids(table);
- Layer.confirm(
- "确定启用选中的"+ ids.length +"项?",
- {icon: 3, title: __('Warning'), offset: 0, shadeClose: true},
- function (index) {
- Fast.api.ajax({
- url: 'guidedomain/open',
- dataType: 'json',
- data: {ids: ids}
- }, function (data, ret) {
- table.bootstrapTable('refresh');
- });
- Layer.close(index);
- }
- );
- },
- close: function () {
- var that = this;
- var table = $("#table");
- var ids = Table.api.selectedids(table);
- Layer.confirm(
- "确定关闭选中的"+ ids.length +"项?<small class='text-info help-block'>关闭后将解除对应的渠道商/代理商关联关系</small>",
- {icon: 3, title: __('Warning'), offset: 0, shadeClose: true},
- function (index) {
- Fast.api.ajax({
- url: 'guidedomain/close',
- dataType: 'json',
- data: {ids: ids}
- }, function (data, ret) {
- table.bootstrapTable('refresh');
- });
- Layer.close(index);
- }
- );
- },
- api: {
- bindevent: function () {
- $("#toolbar>a.btn-open").on("click", Controller.open);
- $("#toolbar>a.btn-close").on("click", Controller.close);
- Form.api.bindevent($("form[role=form]"));
- }
- }
- };
- return Controller;
- });
|