upload-excel.page.js
2.22 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
require('admin/user.page.css');
require('bootpag/lib/jquery.bootpag.min');
const _ = require('lodash');
function bind_delete_user() {
const deleteFn = function() {
const userId = $(this).data('id');
$.ajax({
method: 'post',
url: '/admin/api/user/deleteInfoUser',
data: {
userId
}
})
.then(() => {
location.reload();
});
};
$(document).on('click', '.btn-delete-user', deleteFn);
}
function bind_table_pagination(list) {
const $ul = $('.user-list');
let html = '';
_.each(list, item => {
html += `
<tr class="even pointer">
<td class="">${item.id}</td>
<td class=""><img src="${item.head_url}" style="width: 50px;height: 50px;border-radius: 50px;"></td>
<td class=""><img src="${item.img_url}" style="width: 50px;height: 50px;"></td>
<td class="">${item.name}</td>
<td class="">${item.tag}</td>
<td class="">${item.style}</td>
<td class="">${item.career}</td>
<td class="">${item.skns_1 || ''} || ${item.skns_2 || ''}</td>
<td class="">${item.interest}</td>
<td class="">${item.desc}</td>
</tr>`;
});
$ul.html(html);
}
function bind_export_user_list() {
let uploadFn = function() {
let $form = $('#uploadForm')[0];
let formData = new FormData($form);
formData.append('actId', $(this).data('id'));
console.log($form);
if ($form) {
$.ajax({
url: '/api/excel/loady100file',
data: formData,
method: 'POST',
cache: false,
processData: false,
contentType: false,
success: function(res) {
console.log(res.data);
bind_table_pagination(res.data);
}
});
}
};
$('.btn-upload-excel').on('click', uploadFn);
}
(function() {
bind_delete_user();
bind_export_user_list();
}());