regionFee.php
9.11 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
<?php
use yii\helpers\Url;
use app\ht\widgets\LinkPager;
use common\helpers\ImageManager;
$this->title = '地区及费用';
$this->params['breadcrumbs'][] = '系统管理';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="panel panel-default">
<div class="panel-heading form-inline">
<a href="javascript:void(0)" data-href="<?php echo Url::toRoute('/setting/system-setting/add-region-fee'); ?>" class="btn btn-success pull-left addRegionBtn">添加地区费用</a>
<div style="clear:both;width:100%;"></div>
</div>
<div class="panel-body">
<?php if (!empty($rList)) : ?>
<table class="table table-striped table-bordered" id="brand-table">
<thead>
<tr>
<th style="width:5%;" class="text-center align-middle hqy-all-select">ID</th>
<th>地区</th>
<th style="width:10%;">上门费(元)</th>
<th style="width:10%;">工时费(元)</th>
<th style="width:10%;">派单半径(米)</th>
<th style="width:10%;">接单半径(米)</th>
<th style="width:14%;">操作</th>
</tr>
</thead>
<tbody>
<?php foreach ($rList as $item) : ?>
<tr>
<td class="text-center align-middle hqy-row-select"><?= $item['id'] ?></td>
<td>
<span class="city"><?= $item['city'] ?></span>
</td>
<td>
<span class="door_fee"><?= $item['door_fee'] ?></span>
</td>
<td >
<span class="man_hour_fee"><?= $item['man_hour_fee'] ?></span>
</td>
<td >
<span class="dispatch_order_radius"><?= $item['dispatch_order_radius'] ?></span>
</td>
<td >
<span class="pick_order_radius"><?= $item['pick_order_radius'] ?></span>
</td>
<td >
<a href="javascript:void(0)" data-id="<?= $item['id'] ?>" class="editBtns">编辑</a> |
<a href = "javascript:void(0)" data-id="<?= $item['id'] ?>" class="del-item">删除</a>
</td>
</tr>
<?php endforeach; ?>
</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>
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" 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="myModalLabel">添加地区及费用</h4>
</div>
<div class="modal-body">
<form>
<div class="form-group">
<label for="regionName">地区名称</label>
<input type="text" class="form-control" id="regionName" placeholder="地区名称">
</div>
<div class="form-group">
<label for="door_fee">上门费(元)</label>
<input type="number" class="form-control" id="door_fee" placeholder="上门费">
</div>
<div class="form-group">
<label for="man_hour_fee">工时费(元)</label>
<input type="number" class="form-control" id="man_hour_fee" placeholder="工时费">
</div>
<div class="form-group">
<label for="dispatch_order_radius">派单半径(米)</label>
<input type="number" min="1" class="form-control" id="dispatch_order_radius" placeholder="单位是米">
</div>
<div class="form-group">
<label for="pick_order_radius">接单半径(米)</label>
<input type="number" min="1" class="form-control" id="pick_order_radius" placeholder="单位是米">
</div>
<input type="hidden" class="form-control" id="region_fee_id" />
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
<button type="button" class="btn btn-primary" id="submitBtn">提交</button>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal -->
</div>
<script>
var regionFeeSaveUrl = '<?= Url::toRoute(['/setting/system-setting/add-region-fee']); ?>';
var regionFeeUpdateUrl = '<?= Url::toRoute(['/setting/system-setting/update-region-fee']); ?>';
var regionFeeDelUrl = '<?= Url::toRoute(['/setting/system-setting/del-region-fee']); ?>';
var maxRadius = 40076000;
$(function(){
$('.addRegionBtn').click(function(){
$('#region_fee_id').val(0);
$('#myModal').modal('show');
})
$('#submitBtn').click(function(){
var regionName = $('#regionName').val().replace(/\s+/g, "");
var door_fee = $.trim($('#door_fee').val());
var man_hour_fee = $.trim($('#man_hour_fee').val());
var region_fee_id = $('#region_fee_id').val();
var pick_order_radius = $('#pick_order_radius').val();
var dispatch_order_radius = $('#dispatch_order_radius').val();
if ('' == regionName ){
alert('地区名不能为空');
return false;
}
door_fee = door_fee * 1.00
man_hour_fee = man_hour_fee * 1.00
if ( 0 == door_fee ){
alert('上门费不能空也不能为0');
return false;
}
if ( 0 == man_hour_fee ){
alert('工时费不能空也不能为0');
return false;
}
if ( 0 == dispatch_order_radius ){
alert('派单半径不能为空');
return false;
}
if (dispatch_order_radius > maxRadius) {
alert('派单半径不能为超过'+maxRadius);
return false;
}
if ( 0 == pick_order_radius ){
alert('接单半径不能为空');
return false;
}
if (pick_order_radius > maxRadius) {
alert('接单半径不能为超过'+maxRadius);
return false;
}
if (region_fee_id > 0){
regionFeeSaveUrl = regionFeeUpdateUrl
}
$.post(regionFeeSaveUrl,{
id: region_fee_id,
region: regionName,
door_fee: door_fee,
man_hour_fee: man_hour_fee,
dispatch_order_radius: dispatch_order_radius,
pick_order_radius: pick_order_radius
},function(res){
if (res.success){
$('#myModal').modal('hide')
window.location.reload();
}else{
alert(res.error);
}
},'json')
})
$('.editBtns').click(function(){
var trParents = $(this).parents('tr');
var city = trParents.find('.city').html();
var door_fee = trParents.find('.door_fee').html();
var man_hour_fee = trParents.find('.man_hour_fee').html();
var dispatch_order_radius = trParents.find('.dispatch_order_radius').html();
var pick_order_radius = trParents.find('.pick_order_radius').html();
var rf_id = $(this).attr('data-id');
$('#region_fee_id').val(rf_id);
$('#regionName').val(city);
$('#door_fee').val(door_fee);
$('#man_hour_fee').val(man_hour_fee);
$('#dispatch_order_radius').val(dispatch_order_radius);
$('#pick_order_radius').val(pick_order_radius);
$('#myModal').modal('show')
})
$('.del-item').click(function(){
if (!confirm('确认删除该记录?')){
return false;
}
var id = $(this).attr('data-id');
$.post(regionFeeDelUrl,{id:id},function(res){
if (res.success){
window.location.reload();
}else{
alert(res.error);
}
},'json')
})
});
</script>