fields.js
3.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
var Controller = {
index: function () {
var params = Config.model_id ? '/model_id/' + Config.model_id : '/diyform_id/' + Config.diyform_id;
// 初始化表格参数配置
Table.api.init({
extend: {
index_url: 'cms/fields/index' + params,
add_url: 'cms/fields/add' + params,
edit_url: 'cms/fields/edit' + params,
del_url: 'cms/fields/del' + params,
multi_url: 'cms/fields/multi' + params,
table: 'cms_fields',
}
});
var table = $("#table");
// 初始化表格
table.bootstrapTable({
url: $.fn.bootstrapTable.defaults.extend.index_url,
pk: 'id',
sortName: 'weigh',
columns: [
[
{checkbox: true},
{field: 'id', sortable: true, title: __('Id')},
{field: 'model_id', visible: false, operate: false, title: __('Model_id')},
{field: 'diyform_id', visible: false, operate: false, title: __('Diyform_id')},
{field: 'name', title: __('Name')},
{field: 'type', title: __('Type')},
{field: 'title', title: __('Title')},
{field: 'isfilter', title: __('Isfilter'), searchList: {"1": __('Yes'), "0": __('No')}, formatter: Table.api.formatter.toggle},
{field: 'iscontribute', title: __('Iscontribute'), searchList: {"1": __('Yes'), "0": __('No')}, formatter: Table.api.formatter.toggle},
{field: 'weigh', title: __('Weigh'), visible: false},
{field: 'createtime', title: __('Createtime'), visible: false, operate: 'RANGE', addclass: 'datetimerange', formatter: Table.api.formatter.datetime},
{field: 'updatetime', title: __('Updatetime'), visible: false, operate: 'RANGE', addclass: 'datetimerange', formatter: Table.api.formatter.datetime},
{field: 'status', title: __('Status'), formatter: Table.api.formatter.status},
{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#add-form").data("validator-options", {ignore: ':hidden'});
$(document).on("change", "#c-type", function () {
$(".tf").addClass("hidden");
$(".tf.tf-" + $(this).val()).removeClass("hidden");
});
Form.api.bindevent($("form[role=form]"));
$("#c-type").trigger("change");
}
}
};
return Controller;
});