project.js
4.6 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
var Controller = {
index: function () {
var roterUrl = $('#lv2Url').val();
// 初始化表格参数配置
Table.api.init({
extend: {
index_url: 'project/getContainer',
del_url: 'project/del'
}
});
var routerMap = {
// 项目首页
main: '/teacher/project/index?ref=addtabs&container_id=',
// 项目编辑页
edit: '/teacher/setting/basicinfo/edit?ref=addtabs&container_id=',
// 项目统计页
statistical: '/teacher/double_detail/index?ref=addtabs&container_id=',
}
var table = $("#table");
// Template.helper("Moment", Moment);
// 初始化表格
table.bootstrapTable({
url: $.fn.bootstrapTable.defaults.extend.index_url,
templateView: true,
columns: [
[
{field: 'state', checkbox: true, },
{field: 'id', title: 'ID', operate: false},
{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
],
],
// 数据加载成功,绑定按钮事件
onLoadSuccess: function () {
// 跳转页面按钮
$('.tpl-wrap').on('click', '.btn-router', function () {
var url = routerMap[$(this).data('target')] + $(this).parents('.tpl-wrap').data('id')+'&type='+ $(this).data('id');
// console.log(url);return false;
top.location.href = url;
})
// 删除项目
$('.tpl-wrap').on('click', '.btn-del', function () {
var that = this;
var containerId = $(this).parents('.tpl-wrap').data('id')
var top = $(that).offset().top - $(window).scrollTop();
var left = $(that).offset().left - $(window).scrollLeft() - 260;
if (top + 154 > $(window).height()) {
top = top - 154;
}
if ($(window).width() < 480) {
top = left = undefined;
}
Layer.confirm(
__('Are you sure you want to delete this item?'),
{icon: 3, title: __('Warning'), offset: [top, left], shadeClose: true},
function (index) {
var table = $(that).closest('table');
var options = table.bootstrapTable('getOptions');
Table.api.multi("del", containerId, table, that);
Layer.close(index);
}
);
})
// 切换项目类型,查看项目报名情况
$('.tpl-wrap').on('click', '.tab-item', function () {
var index = $(this).index()
$(this).addClass('active').siblings().removeClass('active')
$('.detail-wrap > div').eq(index).show().siblings().hide()
})
// 点击各项目容器的第一个项目类型tab(用于显示该类型的报名情况)
$('.tpl-wrap').each(function (i, tpl) {
$(tpl).find('.tab-item').eq(0).click()
})
},
// 是否显示快速搜索(搜索框)
search: false,
// 是否显示切换视图按钮
showToggle: false,
// 是否显示隐藏列按钮
showColumns: false,
// 是否显示导出按钮
showExport: false,
// 是否开启通用搜索功能(表格右上角的放大镜)
commonSearch: true,
// 是否隐藏通用搜索按钮
showSearch: false,
//分页大小
pageSize: 3
});
// 为表格绑定事件
Table.api.bindevent(table);
},
};
return Controller;
});