index.php
9.73 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
241
242
243
244
245
246
247
248
249
250
251
<?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/private-number/add-number'); ?>" class="btn btn-success pull-left addNumberBtn">添加号码</a> -->
<a href="<?php echo Url::toRoute('/setting/private-number/order-number'); ?>" class="btn btn-success">订单使用虚拟号</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>号码</th>
<th style="width:10%;">供应商</th>
<th>号码池</th>
<th>地区</th>
<th>小号平台绑定数</th>
<th>本平台绑定数</th>
<th style="width:10%;">区号</th>
</tr>
</thead>
<tbody>
<?php foreach ($rList as $item) : ?>
<tr id="row_<?= $item['code'] ?>">
<td >
<span class="pnumber"><?= $item['code'] ?></span>
</td>
<td >
<span class="supplier" data-id="<?=$item['supplier']?>"><?= $suppliers[$item['supplier']] ?></span>
</td>
<td >
<span class="poolkey" data-id="<?=$item['poolKey']?>"><?= $item['poolKey']?$item['poolKey']:'暂无' ?></span>
</td>
<td>
<span class="city"><?= $item['city'] ?></span>
</td>
<td class="queryCount">
0
</td>
<td class="platformCount">
0
</td>
<td>
<span class="city_code"><?= $item['cityCode'] ?></span>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php else : ?>
<p class="text-center">
没有找到数据
</p>
<?php endif; ?>
</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="city">地区名称</label>
<input type="text" class="form-control" id="city" placeholder="例如:深圳市">
</div>
<div class="form-group">
<label for="city_code">区号</label>
<input type="number" class="form-control" id="city_code" placeholder="例如:0755">
</div>
<div class="form-group">
<label for="pnumber">虚拟号(华为号码前加86)</label>
<input type="number" class="form-control" id="pnumber" placeholder="例如:13800138000">
</div>
<div class="form-group">
<label for="supplier">供应商</label>
<select id="supplier">
<?php
foreach($suppliers as $k=> $supplier){
?>
<option value="<?=$k?>"><?=$supplier?></option>
<?php
}
?>
</select>
</div>
<input type="hidden" class="form-control" id="number_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 pNumberSaveUrl = '<?= Url::toRoute(['/setting/private-number/add-number']); ?>';
var pNumberUpdateUrl = '<?= Url::toRoute(['/setting/private-number/update-number']); ?>';
var pNumberDelUrl = '<?= Url::toRoute(['/setting/private-number/del-number']); ?>';
var queryPhoneUrl = '<?= Url::toRoute(['/setting/private-number/querycheck-phone']); ?>';
var platformPhoneUrl = '<?= Url::toRoute(['/setting/private-number/platform-phone']); ?>';
var orderNumberUrl = '<?= Url::toRoute(['/setting/private-number/order-number']); ?>';
$(function(){
function appendNumberNum(supplier,numberJson) {
// 获取小号平台绑定数
if ( undefined !== numberJson.supplier_1 && numberJson.supplier_1.length >0 ){
$.post(queryPhoneUrl,{supplier:supplier, numbers:numberJson.supplier_1.join(',') },function(res){
if ( true == res.success ) {
$.each(res.numberList,function(i,n){
$('#row_'+ this.number).find('.queryCount').html(this.count)
})
}
},'json')
$.post(platformPhoneUrl,{supplier:supplier, numbers:numberJson.supplier_1.join(',') },function(res){
if ( true == res.success ) {
$.each(res.numberList,function(i,n){
$('#row_'+ this.number).find('.platformCount').html('<a href="'+orderNumberUrl+'/?number='+ this.number +'">'+this.count+'</a>')
})
}
},'json')
}
}
function getPhones(){
var numberCell = $('.pnumber');
var numberJson = {};
$.each(numberCell,function(i,n){
var supplier = $(this).parents('tr').find('.supplier').attr('data-id');
var number = $(this).html();
console.log('supplier:'+Object.prototype.toString.call(numberJson['supplier_'+ supplier]))
if (Object.prototype.toString.call(numberJson['supplier_'+ supplier]) === '[object Array]') {
numberJson['supplier_'+ supplier].push(number)
} else {
//[object Undefined]
numberJson['supplier_'+ supplier] = [];
numberJson['supplier_'+ supplier].push(number)
}
})
//只是查询华为
appendNumberNum(1,numberJson);
}
getPhones();
$('.addNumberBtn').click(function(){
$('#number_id').val(0);
$('#myModal').modal('show');
})
$('#submitBtn').click(function(){
var city = $('#city').val().replace(/\s+/g, "");
var pnumber = $.trim($('#pnumber').val());
var city_code = $.trim($('#city_code').val());
var supplier = $('#supplier').val();
var number_id = $('#number_id').val();
if ('' == city ){
alert('地区名不能为空');
return false;
}
if ( '' == pnumber ){
alert('虚拟号码不能空');
return false;
}
if ( '' == city_code ){
alert('区号不能空');
return false;
}
if (number_id > 0){
pNumberSaveUrl = pNumberUpdateUrl
}
$.post( pNumberSaveUrl,{
id: number_id,
city: city,
number: pnumber,
city_code: city_code,
supplier: supplier
},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 city_code = trParents.find('.city_code').html();
var pnumber = trParents.find('.pnumber').html();
var supplier = trParents.find('.supplier').attr('data-id');
var rf_id = $(this).attr('data-id');
$('#number_id').val(rf_id);
$('#city').val(city);
$('#city_code').val(city_code);
$('#pnumber').val(pnumber);
$('#supplier').val(supplier);
$('#myModal').modal('show')
})
$('.del-item').click(function(){
if (!confirm('确认删除该记录?')){
return false;
}
var id = $(this).attr('data-id');
$.post(pNumberDelUrl,{id:id},function(res){
if (res.success){
window.location.reload();
}else{
alert(res.error);
}
},'json')
})
});
</script>