batch.php
10.4 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
252
253
254
255
256
257
258
259
<?php
use yii\helpers\Url;
use app\ht\widgets\LinkPager;
$this->title = '批次管理';
$this->params['breadcrumbs'][] = '二维码管理';
$this->params['breadcrumbs'][] = $this->title;
?>
<script src="<?= Yii::$app->request->baseUrl . "/exts/combo-select/js/jquery.combo.select.js"?>"></script>
<link rel="stylesheet" type="text/css" href="<?= Yii::$app->request->baseUrl . "/exts/combo-select/css/combo.select.css"?>" />
<style>
.combo-select{
margin-bottom: 0;
width: width: 252px;;
float: left;
height: 34px;
}
.combo-select .combo-input{
padding: 7px!important;
}
</style>
<div class="panel panel-default">
<div class="panel-body">
<form action="" method="get" class="filter-form">
<table width="100%">
<tbody>
<tr >
<td width="10%" class="text-right">选择批次:</td>
<td width="40%" class="text-left form-inline">
<select class="form-control combo-select-item" id="batch" name="batch">
<option value="0">--请选择批次--</option>
<?php foreach ($batchList as $batch) : ?>
<option value="<?=$batch['id'] ?>" <?php if ($batch['id'] == $gets['batch_id']){ echo "selected"; } ?> ><?=$batch['name'] ?></option>
<?php endforeach; ?>
</select>
</td>
<td width="10%" class="text-right"></td>
<td width="40%" class="text-left"></td>
</tr>
<tr >
<td width="10%" class="text-right">选择城市:</td>
<td width="40%" class="text-left form-inline">
<select class="form-control combo-select-item" id="city" name="city">
<option value="0">--请选择城市--</option>
<?php foreach ($region as $regionItem) : ?>
<option value="<?=$regionItem['city'] ?>" <?php if ($regionItem['city'] == $gets['city']){ echo "selected"; } ?> ><?=$regionItem['city'] ?></option>
<?php endforeach; ?>
</select>
</td>
<td width="10%" class="text-right"></td>
<td width="40%" class="text-left"></td>
</tr>
<tr class="search">
<td colspan="6" class="text-center">
<button type="submit" class="btn btn-primary" id="search"><i class="glyphicon glyphicon-search"></i> 查 询 </button>
<a class="btn btn-default" href="<?=Url::toRoute("/device/qrcode/batch")?>">重 置</a>
</td>
</tr>
</tbody>
</table>
</form>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading">
<a href="<?php echo Url::toRoute('/device/qrcode/batch-create'); ?>" class="btn btn-success pull-left">新增批次</a>
<div class="clearfix"></div>
</div>
<div class="panel-body">
<?php if (!empty($batchList)) : ?>
<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 style="width:20%;">批次名称</th>
<th style="width:10%;">城市</th>
<th style="width:5%;">生成数量</th>
<th style="width:15%;">生成时间</th>
<th style="width:15%;">修改时间</th>
<th style="width:25%;">操作</th>
</tr>
</thead>
<tbody>
<?php foreach ($batchList as $batch) : ?>
<tr>
<td class="text-center align-middle hqy-row-select"><?= $batch['id'] ?></td>
<td >
<?= $batch['name'] ?>
</td>
<td >
<?= $batch['city'] ?>
</td>
<td >
<?= $batch['count'] ?>
</td>
<td >
<?=Yii::$app->formatter->asTime($batch['created_at'],"yyyy-MM-dd HH:mm:ss"); ?>
</td>
<td >
<?=Yii::$app->formatter->asTime($batch['updated_at'],"yyyy-MM-dd HH:mm:ss"); ?>
</td>
<td >
<a class="btn btn-primary" href="<?php echo Url::toRoute(['/device/qrcode/batch-update', 'batch_id' => $batch['id']]) ?>">编辑</a>
<?php if ($batch['status'] == 1): ?>
<a class="btn btn-primary" href="<?php echo Url::toRoute(['/device/qrcode/index', 'batch' => $batch['id']]) ?>">查看</a>
<a class="btn btn-success" href="<?php echo Url::toRoute(['/device/qrcode/zip', 'batch_id' => $batch['id']]) ?>">二维码批量导出</a>
<?php else: ?>
<button class="btn btn-primary btn_generate" batchid="<?=$batch['id'] ?>">生成</button>
<?php endif;?>
</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>
<script>
$(document).ready(function(){
$(".btn_generate").bind("click",function(){
var batch_id = $.trim($(this).attr("batchid"));
if (batch_id == null || batch_id == ""){
alert("参数错误,请刷新后再试");
return false;
}
//$(this).attr("disabled","true");
var loading = $.ladda(this);
$.ajax({
type: "post",
url: "do-generate-qrcode",
dataType:"json",
data: $.csrf({"batch_id":batch_id}),
beforeSend : function(){
// 开始加载...
loading.start();
},
success:function(msg){
loading.stop();
alert(msg['msg']);
if (msg['status'] == 1){
location.reload();
}else{
//提示确认失败
//$(this).removeAttr("disabled");
}
},
error:function(msg){
//提示确认失败
$(this).removeAttr("disabled");
}
});
});
});
var count = 1; // 正在执行页码
var pageCount = 0; // 总页码
function exportData(params) {
$.ajax({
url: "<?=Url::toRoute("/device/qrcode/export-zip-batch")?>",
dataType: "json",
data: params,
type: "GET",
cache: false,
success: function (r) {
if (!r.success) {
alert('系统出错,请联系管理员')
} else {
$("#dialogContent2").html(r.html);
pageCount = r.pageCount;
gen(params, 1);
seajs.use("base/1.0.0/ui/block-ui/block-ui-1.0.0", function () {
$.blockUI({
message: $("#dialog2"),
css: {
width: "990px",
height: "220px",
top: "200px",
left:"20%",
cursor: null
}
})
})
}
},
error: function (r) {
if (r.status == 403) {
alert('您没有此操作权限,请联系管理员')
}
}
})
}
function gen(params, pageNo) {
var param = params;
param += "&pageNo=" + pageNo + '&pageCount=' + pageCount;
$.ajax({
url: "<?=Url::toRoute("/device/qrcode/export-qrcode-batch")?>",
dataType: "json",
data: param,
type: "POST",
cache: false,
beforeSend: function (XMLHttpRequest) {
},
success: function (dataResult) {
if (dataResult.success) {
count++;
if (count <= pageCount) {
$('#count').html(count);
gen(params, count);
}
if (count > pageCount) {
seajs.use("base/1.0.0/ui/block-ui/block-ui-1.0.0", function () {
$.unblockUI();
});
location.reload();
}
} else {
alert("生成二维码意外中断,请重试.");
seajs.use("base/1.0.0/ui/block-ui/block-ui-1.0.0", function () {
$.unblockUI();
});
}
},
error: function (dateResult) {
seajs.use("base/1.0.0/ui/block-ui/block-ui-1.0.0", function () {
$.unblockUI();
});
}
})
}
</script>
<div id="dialog2" style="display: none">
<div style="position:absolute;right: 10px; top: 10px "><a href="javascript:void(0)" id="closeDialog2" >关闭</a></div>
<div id="dialogContent2" style="margin-top:5px;text-align:left"></div>
</div>
<script type="text/javascript">
$(document).ready(function() {
$('.combo-select-item').comboSelect();
});
</script>