repair_plan_set.php
9.25 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
<?php
use yii\helpers\Url;
use app\ht\widgets\LinkPager;
$this->title = '维修方案设置';
$this->params['breadcrumbs'][] = '设备管理';
$this->params['breadcrumbs'][] = ['label' => '故障设置', 'url' => ['/device/fault/faultset?type=0&mid='.$gets['model_id']."&title=".$gets['info']]];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="panel panel-default">
<div class="panel-heading bg-success">
<?=$gets['info'] ?> > <?=$fault['name'] ?>
</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>
<?php endif; ?>
<input type="hidden" value="<?=$gets['model_id'] ?>" id="model_id">
<input type="hidden" value="<?=$gets['fault_id'] ?>" id="fault_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/repair-plan-set', 'type' =>1, 'modelDeviceFaultId'=> $gets['modelDeviceFaultId']])?>" >已添加维修方案</a></li>
<li <?php if ($gets['type'] == 2){ echo "class=\"active\"" ;} ?> ><a href="<?=Url::toRoute(['/device/fault/repair-plan-set', 'type'=>2, 'modelDeviceFaultId'=> $gets['modelDeviceFaultId']])?>" >未添加维修方案</a></li>
</ul>
<?php if (!empty($list)) : ?>
<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 ($list as $p) : ?>
<tr>
<td class="text-center align-middle hqy-row-select"><input type="checkbox" name="selection[]" value="<?=$p['model_price_id'] ?>"></td>
<td ><?=$p['name'] ?></td>
<td ><?=$p['reason'] ?></td>
<td >
<button class="btn btn-danger btn_fault_models_replan_del" model_price_id="<?=$p['model_price_id'] ?>" >删除</button>
<button class="btn btn-primary btn_repair_plan_setting" model_price_id="<?=$p['model_price_id'] ?>">设置价格</button>
</td>
</tr>
<?php endforeach; ?>
<?php else: ?>
<?php foreach ($list as $p) : ?>
<tr >
<td class="text-center align-middle hqy-row-select"><input type="checkbox" name="selection[]" value="<?=$p['id'] ?>"></td>
<td ><?=$p['name'] ?></td>
<td ><?=$p['reason'] ?></td>
<td >
<button class="btn btn-success btn_fault_models_replan_add" repair_plan_id="<?=$p['id'] ?>" model_id="<?=$p['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">
<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/fault-repair-plan-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/fault-repair-plan-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_models_replan_add").bind("click",function(){
var repair_plan_id = $(this).attr("repair_plan_id");
var model_id = $(this).attr("model_id");
var thiz = $(this);
$.ajax({
type: "post",
url: "fault-repair-plan-add",
dataType:"json",
data: $.csrf({"ids":repair_plan_id,"model_id":model_id}),
success:function(msg){
alert(msg['msg']);
if (msg['status'] == 1){
thiz.parents('tr').remove();
}else{
}
},
error:function(msg){
}
});
});
//执行删除维修方案报价
$(".btn_fault_models_replan_del").bind("click",function(){
var model_price_id = $(this).attr("model_price_id");
//var model_id = $(this).attr("model_id");
if (model_price_id == null || model_price_id == ""){
alert("删除失败,请刷新后再试");
return false;
}
var thiz = $(this);
if (confirm("你确定要删除此维修方案吗?")){
$.ajax({
type: "post",
url: "fault-repair-plan-del",
dataType:"json",
data: $.csrf({"ids":model_price_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 () {
location.href = "./repair-plan-price-set?modelsRepairPlanPricesId="+$(this).attr("model_price_id");
});
});
</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>