product_cache.hbs
4.47 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
<div class="pageheader">
<div class="media">
<div class="pageicon pull-left">
<i class="fa fa-th-list"></i>
</div>
<div class="media-body">
<ul class="breadcrumb">
<li><a href="/"><i class="glyphicon glyphicon-home"></i></a></li>
<li><a href="/servers">缓存管理</a></li>
</ul>
<h4>清理商品缓存</h4>
</div>
</div>
<!-- media -->
</div>
<div class="contentpanel">
<div class="row cache-panel">
<div class="panel panel-default">
<div class="panel-body">
<div class="col-sm-6">
<div class="operations mb20">
<label class="control-label">导入文件:</label>
<div class="file-upload"></div>
<p class="skn-count"></p>
<select id="selectType" class="form-control input-sm selcet-auto pull-left mr20">
<option value="1">批量变价</option>
<option value="2">其它批量</option>
</select>
<button class="btn btn-warning btn-clear ">执行清理</button>
</div>
<div class="download">
<a href="/template/product_cache_template.xlsx" class="block">模板文件下载</a>
<a href="javascript:;" class="block product-url">生成商品url</a>
</div>
</div>
<div class="col-sm-6">
<div class="panel">
<div class="panel-heading">
<h4 class="panel-title">日志</h4>
</div><!-- panel-heading -->
<div class="panel-body yoho-log-dark">
<div class="results-list ">
</div><!-- results-list -->
</div><!-- panel-body -->
</div><!-- panel -->
</div>
</div>
<div class="panel-footer">
<div class="result pull-left ml20"></div>
</div>
</div>
</div>
</div>
<script>
var posing = false;
$(document).on('ready pjax:success', function() {
var fileUpload = $('.file-upload').uploadFile({
url: '/product_cache/import',
method: 'POST',
uploadStr: '浏览',
multiple: false,
maxFileCount: 1,
fileName: 'excelFile',
allowedTypes: 'xlsx,xls',
dynamicFormData: function() {
return {type: $('#selectType').val()}
},
onSuccess: function(files, data, xhr, pd) {
console.log('success')
if(data.code === 200) {
$('.skn-count').text('导入数量:' + data.count).data('count', data.count);
}
fileUpload.reset();
},
onError: function(files, data, xhr, pd) {
console.log('onError')
fileUpload.reset();
}
})
$('.btn-clear').click(function() {
var count = $('.skn-count').data('count');
var selectType = $('#selectType').val();
if(count > 0 && selectType) {
$.post('/product_cache/clear', {
type: selectType,
});
}
})
$('.product-url').click(function() {
var count = $('.skn-count').data('count');
if(count > 0) {
window.location.href = '/product_cache/product_url';
}
})
function layoutResize() {
$('.yoho-log-dark').height($('body').height() - 450);
}
$(window).resize(function() {
layoutResize();
});
layoutResize();
var $logs = $('.yoho-log-dark .results-list');
var $dark = $('.yoho-log-dark');
function appendLog(message) {
var html = '<p><span class="message">- ' + message + '</span></p>';
$logs.append(html);
$dark.scrollTop($logs[0].scrollHeight);
}
var ws = io();
ws.on('connect', function() {
ws.on('/product_cache/log', function(data) {
appendLog(data.message)
});
});
});
</script>