project.js
8.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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
var Controller = {
index: function () {
// 初始化表格参数配置
Table.api.init({
extend: {
index_url: 'inspection/project/index' + location.search,
del_url: 'inspection/project/del',
multi_url: 'inspection/project/multi',
import_url: 'inspection/project/import',
table: 'inspection_project',
}
});
var table = $("#table");
// 初始化表格
table.bootstrapTable({
url: $.fn.bootstrapTable.defaults.extend.index_url,
pk: 'id',
sortName: 'id',
pageSize:10,
search:false,
fixedColumns:true,//固定列代码
fixedRightNumber:1,//固定右侧第1列
fixedNumber:2,//固定左侧2列
columns: [
[
{checkbox: true},
{field: 'id', title: __('Id')},
{field: 'plan_name', title: __('巡检计划'),operate: false},
// {field: 'plan_id', title: __('巡检计划'),visible:true, operate: '=',searchList: $.getJSON("inspection/plan/dynamicselect")},
{field: 'plan_id', title: __('巡检计划'),visible:false},
{field: 'area_name', title: __('巡检区域'),operate: false},
{field: 'area_id', title: __('巡检区域'),visible:false, operate: '=',searchList: $.getJSON("inspection/area/dynamicselect")},
{field: 'route_name', title: __('巡检路线'),operate: false},
{field: 'route_id', title: __('巡检路线'),visible:false, operate: '=',searchList: $.getJSON("inspection/route/dynamicselect")},
{field: 'site_name', title: __('巡检点'),operate: false},
{
field: 'area_site_id', title: __('巡检点'), searchList: function (column) {
return Template('categorytpl', {});
}, formatter: function (value, row, index) {
return '无';
}, visible: false
},
{field: 'begintime', title: __('Begin_time'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
{field: 'endtime', title: __('End_time'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
{field: 'staff.staff_name', title: __('巡检员'), operate: 'LIKE'},
{field: 'checktime', title: __('Checktime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
// {field: 'jumptime', title: __('Jumptime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
// {field: 'jump_content', title: __('Jump_content'), operate: 'LIKE'},
{field: 'images', title: __('图片'),operate: false,formatter: Controller.api.formatter.images},
{field: 'content', title: __('备注'),operate: false},
// {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
{field: 'status', title: __('巡检进度'),searchList: {"0": __('进行中'), "1": __('正常'), "2": __('异常')}, operate: '=',formatter: Controller.api.formatter.status},
{field: 'state', title: __('巡检结果'),searchList: {"-1": __('漏检'), "0": __('进行中'), "1": __('已巡检'),"2": __('跳捡')},formatter: Controller.api.formatter.state},
{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate,
buttons: [
{
name: 'trajectory_num',
text:function(row){
if(row.trajectory_num>0 && row.status==1){
return "<span style='color:#007AFF;'>轨迹回放</span>";
}else{
return "无轨迹";
}
},
title:function(row){
if(row.trajectory_num>0 && row.status==1){
return "("+row.plan_name+")轨迹回放";
}else{
return "无轨迹,可稍后刷新重试";
}
},
extend:'data-area=["94%","94%"]',
classname: 'btn btn-xs btn-default btn-dialog',
icon: 'fa',
url: 'inspection/project/guiji?ids={id}',
},
{
name: 'ercode',
text: __('巡检详情'),
title: __('巡检详情'),
classname: 'btn btn-xs btn-warning btn-dialog',
url: 'inspection/projectitem/index'
}
],
formatter: Table.api.formatter.operate}
]
],
});
$(".btn-generate").click(function(){
$.ajax({
type:'POST',
url:'inspection/project/generate',
success:function (response) {
if(response.code){
Toastr.success("任务生成成功");
table.bootstrapTable('refresh');
}else{
Toastr.error(response.msg);
table.bootstrapTable('refresh');
}
Layer.closeAll()
}
})
})
// 为表格绑定事件
Table.api.bindevent(table);
},
add: function () {
Controller.api.bindevent();
},
edit: function () {
Controller.api.bindevent();
},
api: {
formatter:{
state: function (value, row, index) {
switch (value) {
case 0:
return "进行中";
case 1:
return "正常";
case 2:
return "异常";
}
},
images: function (value, row, index) {
if(value){
var str = "";
var images_arr = value.split(",");
for(i=0;i<images_arr.length;i++){
if(images_arr[i]){
str += '<a href="'+images_arr[i]+'" style="margin: 0px 5px;" target="_blank"><img class="img-sm img-center" src="'+images_arr[i]+'"></a>';
}
}
return str;
}
},
status: function (value, row, index) {
switch (value) {
case -1:
return "漏检";
case 0:
return "进行中";
case 1:
return "已巡检";
case 2:
return "跳检";
}
},
},
bindevent: function () {
Form.api.bindevent($("form[role=form]"));
}
}
};
return Controller;
});