faultset.php
9.59 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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
<?php
use yii\helpers\Url;
use app\ht\widgets\LinkPager;
$this->title = '故障设置';
$this->params['breadcrumbs'][] = '设备管理';
$this->params['breadcrumbs'][] = ['label' => '设备列表', 'url' => ['/device/device/index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="panel panel-default">
<div class="panel-heading bg-success">
<?php echo $gets['info']; ?>
</div>
<div class="panel-heading">
<?php if ($gets['type'] == 1): ?>
<a class="btn btn-danger pull-left" id="batch_del">批量删除</a>
<?php else: ?>
<a class="btn btn-success pull-left" id="batch_add">批量添加</a>
<a href="<?=Url::toRoute(['/device/fault/index', 'deviceParentCat' =>0,'deviceCat'=>0])?>" class="btn btn-primary pull-right">故障管理</a>
<?php endif; ?>
<input type="hidden" value="<?=$gets['model_id'] ?>" id="model_id">
<div class="clearfix"></div>
</div>
<div class="panel-body">
<ul id="countryTab" class="nav nav-tabs" style="margin-bottom: 20px">
<li <?php if ($gets['type'] == 1){ echo "class=\"active\"" ;} ?> ><a href="<?=Url::toRoute(['/device/fault/faultset', 'type' =>0,'mid'=>$gets['model_id'],'title'=>$gets['info']])?>" >已添加故障</a></li>
<li <?php if ($gets['type'] == 2){ echo "class=\"active\"" ;} ?> ><a href="<?=Url::toRoute(['/device/fault/faultset', 'type'=>2,'mid'=>$gets['model_id'],'title'=>$gets['info']])?>" >未添加故障</a></li>
</ul>
<?php if (!empty($deviceFaultlList)) : ?>
<table class="table table-striped table-bordered" id="brand-table">
<thead>
<tr>
<th style="width:5%;" class="text-center align-middle hqy-all-select"><input type="checkbox" class="select-on-check-all" name="selection_all" value="1"></th>
<th style="width:50%;">故障名称</th>
<th style="width:20%;">更新时间</th>
<th style="width:25%;">操作</th>
</tr>
</thead>
<tbody>
<?php if ($gets['type'] == 1): ?>
<?php foreach ($deviceFaultlList as $models_device_faults) : ?>
<tr>
<td class="text-center align-middle hqy-row-select"><input type="checkbox" name="selection[]" value="<?=$models_device_faults['id'] ?>"></td>
<td ><?= $models_device_faults['name'] ?></td>
<td >
<?=Yii::$app->formatter->asTime($models_device_faults['updated_at'],"yyyy-MM-dd HH:mm:ss"); ?>
</td>
<td >
<button class="btn btn-danger btn_fault_del" device_fault="<?=$models_device_faults['id'] ?>" >删除</button>
<button class="btn btn-primary btn_repair_plan_setting" device_fault="<?=$models_device_faults['id'] ?>">维修方案设置</button>
</td>
</tr>
<?php endforeach; ?>
<?php else: ?>
<?php foreach ($deviceFaultlList as $device_fault) : ?>
<tr >
<td class="text-center align-middle hqy-row-select"><input type="checkbox" name="selection[]" value="<?=$device_fault['id'] ?>"></td>
<td ><?= $device_fault['name'] ?></td>
<td >
<?=Yii::$app->formatter->asTime($device_fault['updated_at'],"yyyy-MM-dd HH:mm:ss"); ?>
</td>
<td >
<button class="btn btn-success btn_fault_add" device_fault="<?=$device_fault['id'] ?>" mid="<?=$gets['model_id'] ?>" >添加</button>
</td>
</tr>
<?php endforeach; ?>
<?php endif; ?>
</tbody>
</table>
<?php else : ?>
<p class="text-center">
没有找到数据
</p>
<?php endif; ?>
</div>
<div class="panel-footer">
<div class="hqy-panel-pager">
<?= LinkPager::widget([
'pagination' => $pages,
]); ?>
<div class="clearfix"></div>
</div>
</div>
</div>
<script>
// 全部选中
seajs.use("base/1.0.0/unit/utils/utils-1.0.0",function (a) {
a.hqySelectRow('brand-table', 'warning');
})
//删除
$("#batch_del").click(function() {
var ids = "";
$("input[name='selection[]']").each(function() {
if ($(this).prop("checked") == true) {
var id = $(this).attr("value");
ids = ids + id + ",";
}
});
if (ids == "") {
alert('请选择要删除的故障')
return false;
}
var url = "<?php echo Url::toRoute('/device/fault/batch-model-device-fault-del'); ?>";
$('#url4').val(url);//给会话中的隐藏属性URL赋值
$('#ids').val(ids);
$('#modal_content').text("确定要删除吗?");
$('#myModal4').modal();
});
//添加
$("#batch_add").click(function() {
var ids = "";
$("input[name='selection[]']").each(function() {
if ($(this).prop("checked") == true) {
var id = $(this).attr("value");
ids = ids + id + ",";
}
});
if (ids == "") {
alert('请选择要添加的故障')
return false;
}
var url = "<?php echo Url::toRoute('/device/fault/batch-model-device-fault-add'); ?>";
$('#url4').val(url);//给会话中的隐藏属性URL赋值
$('#ids').val(ids);
$('#modal_content').text("确定要添加吗?");
$('#myModal4').modal();
});
function batchDisableSubmit(){
var url=$.trim($("#url4").val());//获取会话中的隐藏属性URL
var model_id = $("#model_id").val();
var ids = $.trim($("#ids").val());
ids = ids.length > 0 ? ids.substring(0,(ids.length-1)):ids;
$.ajax({
type: "post",
url: url,
dataType:"json",
data: $.csrf({"ids":ids,"model_id":model_id}),
success:function(msg){
alert(msg['msg']);
if (msg['status'] == 1){
location.reload();
}else{
}
},
error:function(msg){
}
});
}
$(document).ready(function () {
$(".btn_fault_add").bind("click",function(){
var fault_id = $(this).attr("device_fault");
var mid = $(this).attr("mid");
var thiz = $(this);
$.ajax({
type: "post",
url: "model-fault-add",
dataType:"json",
data: $.csrf({"mid":mid,"fault_id":fault_id}),
success:function(msg){
alert(msg['msg']);
if (msg['status'] == 1){
thiz.parents('tr').remove();
}else{
}
},
error:function(msg){
}
});
});
$(".btn_fault_del").bind("click",function(){
var fault_id = $(this).attr("device_fault");
//var model_id = $(this).attr("model_id");
if (fault_id == null || fault_id == ""){
alert("删除失败,请刷新后再试");
return false;
}
var thiz = $(this);
$.ajax({
type: "post",
url: "model-fault-del",
dataType:"json",
data: $.csrf({"id":fault_id}),
success:function(msg){
alert(msg['msg']);
if (msg['status'] == 1){
thiz.parents('tr').remove();
}else{
}
},
error:function(msg){
}
});
});
$(".btn_repair_plan_setting").bind("click",function () {
var modelDeviceFaultId = $(this).attr("device_fault");
if (modelDeviceFaultId == null || modelDeviceFaultId == "" ){
alert("缺少必要参数,无法进行维修方案设置");
return false;
}else{
location.href = "./repair-plan-set?type=1&modelDeviceFaultId="+modelDeviceFaultId;
}
});
});
</script>
<!-- 模态框(Modal) -->
<div class="modal fade" id="myModal4" tabindex="-1" role="dialog" aria-labelledby="myModalLabel4" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">关闭</button>
<h4 class="modal-title" id="myModalLabel4">
提示
</h4>
</div>
<div class="modal-body" id="modal_content">
</div>
<div class="modal-footer">
<input type="hidden" id="url4"/>
<input type="hidden" id="ids"/>
<a onclick="batchDisableSubmit()" class="btn btn-primary" data-dismiss="modal">确定</a>
<button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal -->
</div>