warning.js
5.4 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
102
103
104
105
106
107
108
109
110
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
var Controller = {
index: function () {
// 初始化表格参数配置
Table.api.init({
extend: {
index_url: 'inspection/warning/index' + location.search,
add_url: 'inspection/warning/add',
edit_url: 'inspection/warning/edit',
del_url: 'inspection/warning/del',
multi_url: 'inspection/warning/multi',
import_url: 'inspection/warning/import',
table: 'inspection_warning',
}
});
var table = $("#table");
// 初始化表格
table.bootstrapTable({
url: $.fn.bootstrapTable.defaults.extend.index_url,
pk: 'id',
sortName: 'id',
columns: [
[
{checkbox: true},
{field: 'id', title: __('Id')},
{field: 'inspectionarea.area_name', title: __('Inspectionarea.area_name'), operate: 'LIKE'},
{field: 'areasite.site_name', title: __('巡检点'), operate: 'LIKE'},
{field: 'areaitem.item_name', title: __('检查项'), operate: 'LIKE'},
{field: 'categoryp.name', title: __('父级类型'), operate: 'LIKE'},
{field: 'category.name', title: __('隐患类型'), operate: 'LIKE'},
{field: 'title', title: __('Title'), operate: 'LIKE'},
{field: 'message', title: __('Message'), operate: 'LIKE',events:{
// click事件 绑定到test1类上,e 事件对象, value 当前这个表格格子的值,row 当前行数据,index当前行索引值
'click .open-message':function (e,value,row,index) {
layer.open({
title:'预警信息',
type:1,
content:`<div style="padding: 10px 15px;">${value}</div>`,
area:['30%', '50%'],
});
}
},formatter: function (value, row, index) {
return `<div class="open-message" style="width:160px;overflow: hidden;white-space: nowrap;text-overflow: ellipsis;">
<a href="javascript:void(0);">${value}</a>
</div>`
}
},
{field: 'cover_images', title: __('图片'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.images},
{field: 'inspectionstaff.staff_name', title: __('Inspectionstaff.staff_name'), operate: 'LIKE'},
{field: 'status', title: __('Status'), searchList: {"0":__('Status 0'),"-1":__('Status -1'),"1":__('Status 1'),"2":__('Status 2')}, formatter: Table.api.formatter.status},
{field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
{
field: 'operate',
title: __('Operate'),
table: table,
events: Table.api.events.operate,
buttons:[
{
name: 'reply',
text:"隐患回复",
title: __('隐患回复'),
classname: 'btn btn-xs btn-primary btn-dialog',
icon: 'fa fa-list',
url: 'inspection/warning/reply?pid={id}',
callback: function (data) {
Layer.alert("接收到回传数据:" + JSON.stringify(data), {title: "回传数据"});
}
},
],
formatter: Table.api.formatter.operate
} ]
]
});
// 为表格绑定事件
Table.api.bindevent(table);
},
add: function () {
Controller.api.bindevent();
},
edit: function () {
Controller.api.bindevent();
},
reply: function () {
Controller.api.bindevent();
},
api: {
bindevent: function () {
$("#c-category_pid").on('change',function () {
let categoryId = $("#c-category_id");
//动态修改SelectPage选中项
categoryId.selectPageClear();
categoryId.selectPageRefresh();
});
$("#c-category_id").data("params", function (obj) {
//obj为SelectPage对象
return {custom: {pid: $("#c-category_pid").val()}};
});
Form.api.bindevent($("form[role=form]"));
}
}
};
return Controller;
});