project.js备份20231205
6.8 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
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,
columns: [
[
{checkbox: true},
{field: 'id', title: __('Id')},
{field: 'plan_name', title: __('巡检计划'),operate: false},
{field: 'plan_id', title: __('巡检计划'),visible:false, operate: '=',searchList: $.getJSON("inspection/plan/dynamicselect")},
{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: '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: '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;
});