123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422 |
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="UTF-8">
- <meta content="yes" name="apple-mobile-web-app-capable">
- <!-- <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0,minimum-scale=1.0,user-scalable=0" /> -->
- <title>薪水</title>
- <link rel="stylesheet" type="text/css" href="public/public_css.css" />
- <script type="text/javascript" src="public/jquery-2.1.0.js"></script>
- <style type="text/css">
- .alert-info {
- position: absolute;
- top: 150px;
- right: 0;
- left: 0;
- bottom: 0;
- text-align: center;
- }
- .alert-info p {
- display: inline-block;
- color: #fff;
- font-size: 14px;
- line-height: 40px;
- padding: 0 10px;
- background-color: rgba(0, 0, 0, 0.7);
- border-radius: 40px;
- }
- .loading {
- position: fixed;
- top: 0;
- left: 0;
- display: none;
- width: 100%;
- height: 100vh;
- background: rgba(255, 255, 255, 0.4)
- }
- .loading img {
- position: absolute;
- top: 0;
- bottom: 0;
- left: 0;
- right: 0;
- margin: auto;
- width: 60px;
- height: 60px;
- }
- </style>
- <style type="text/css">
- .contaniner_box {
- background: #F7F7F7;
- width: 100%;
- height: 100vh;
- display: flex;
- }
- .con_left{
- width: 400px;
- height: 100%;
- background-color: #fff;
- display: flex;
- flex-direction: column;
- align-items: center;
- justify-content: center;
- }
- .inputDiv {
- width: 200px;
- }
- .inputDiv input {
- display: block;
- width: 100%;
- height: 50px;
- font-size: 20px;
- background: transparent;
- border: none;
- border-radius: 50px;
- outline: none;
- border: 1px solid #3173FF;
- cursor: pointer;
- color: #3173FF;
- }
- /* .inputDiv input:hover {
- border-color: #3173FF;
- color: #3173FF;
- } */
- .submission {
- width: 300px;
- height: 60px;
- border-radius: 60px;
- background: #3173FF;
- border: none;
- font-size: 18px;
- color: #fff;
- display: block;
- margin-top: 40px;
- cursor: pointer;
- }
- .fileDiv {
- font-size: 20px;
- line-height: 50px;
- }
-
- .upload_success {
- flex: 1;
- background: #fff;
- height: 100vh;
- padding: 40px 20px;
- padding-bottom: 0;
- box-sizing: border-box;
- overflow-y: auto;
- margin-left: 15px;
- }
- .upload_success h3 {
- color: #3173FF;
- font-size: 14px;
- font-weight: bold;
- margin-bottom: 10px;
- background: rgba(49, 115, 255, 0.15);
- padding: 10px 20px;
- box-sizing: border-box;
- }
- .upload_success li {
- font-size: 14px;
- line-height: 30px;
- color: #fff;
- }
- .upload_success li span:nth-of-type(1) {
- padding-right: 20px;
- width: 40%;
- display: inline-block;
- }
- .table{
- width: 100%;
- font-size: 14px;
- border-collapse: collapse;
- border: 1px solid #ebeef5;
- margin-top: 10px;
- }
- .table .thead{
- background-color: #fafafa;
- }
- .table .thead .th{
- font-weight: bold;
- }
- .table .tr .th:nth-child(1), .table .tr .td:nth-child(1){
- width: 20%;
- }
- .table .tr .th:nth-child(2), .table .tr .td:nth-child(2){
- width: 30%;
- }
- .table .tr .th:nth-child(3), .table .tr .td:nth-child(3){
- width: 30%;
- }
- .table .tr .th:nth-child(4), .table .tr .td:nth-child(4){
- width: 20%;
- }
-
- .table .tr{
- color: rgb(22, 30, 70);
- height: 44px;
- display: flex;
- }
- .table .th, .table .td{
- border-right: 1px solid #ebeef5;
- border-bottom: 1px solid #ebeef5;
- text-align: center;
- display: flex;
- align-items: center;
- justify-content: center;
- flex-wrap: wrap;
- }
- .tbody{
- height: calc(100vh - 190px);
- box-sizing: border-box;
- overflow-y: auto;
- }
- .table .td{
- color: #333;
- }
- .fail_c{
- color: red !important;
- }
- .select_box{
- width: 160px;
- height: 32px;
- border: 1px solid #ddd;
- padding: 0 10px;
- border-radius: 4px;
- color: #333;
- }
- .noDataBox{
- display: flex;
- flex-direction: column;
- justify-content: center;
- align-items: center;
- padding-top: 16vh;
- }
- .noDataBox img{
- width: 300px;
- }
- .noDataBox p{
- color: #aaa;
- }
- .refresh{
- color: #3173FF;
- cursor: pointer;
- font-size: 14px;
- margin-left: 20px;
- }
- .hint{
- color: #999;
- font-size: 12px;
- }
- .flex{
- display: flex;
- align-items: center;
- }
- .allComplete{
- display: none;
- }
- </style>
- </head>
- <body>
- <div class="contaniner_box">
- <div class="con_left">
- <ul class="fileDiv"></ul>
- <div class="inputDiv">
- <input type="file" id="files" style="display: none" onchange="fileImport();">
- <input type="button" id="fileImport" value="导入文件">
- </div>
- <button class="submission" onclick="submissionEvent()">提交</button>
- </div>
- <div class="upload_success">
- <h3><span style="color:#23c23f" class="allComplete">✅ 全部发送完成。</span>已发送酷炫成员(<span class="total">-</span>)人,发送成功(<span class="succ_n">-</span>)人,失败(<span class="fail_n">-</span>)人。</h3>
- <div class="flex">
- <select class="select_box" id="status_select">
- <option value="all">全部</option>
- <option value="success">发送成功</option>
- <option value="fail">发送失败</option>
- </select>
- <div class="refresh" onclick="salaryEmailDetail()">刷新</div>
- <div class="hint">(点击刷新邮件发送详情)</div>
- </div>
- <div class="table">
- <div class="thead">
- <div class="tr">
- <div class="th">姓名</div>
- <div class="th">邮箱</div>
- <div class="th">发送时间</div>
- <div class="th">发送状态</div>
- </div>
- </div>
- <div class="tbody">
- <!-- 员工列表 -->
- <div class="noDataBox">
- <img src="./common/nodata.png" alt="" srcset="">
- <p>暂无数据</p>
- </div>
- </div>
- </div>
- </div>
- </div>
- <div class="alert-info" style="display: none;">
- <!-- tip提示,3s后消失 -->
- <p></p>
- </div>
- <div class="loading">
- <img src="common/loading.gif" />
- </div>
- </body>
- </html>
- <script type="text/javascript">
- $().ready(function() {
- salaryEmailDetail();
- })
- let staffList = [];//员工列表
- var salary = '';
- //点击导入按钮,使files触发点击事件,然后完成读取文件的操作
- $("#fileImport").click(function () {
- $("#files").click();
- })
- function fileImport () {
- //获取读取我文件的File对象
- var selectedFile = document.getElementById('files').files[0];
- var name = selectedFile.name;//读取选中文件的文件名
- var size = selectedFile.size;//读取选中文件的大小
- // console.log("文件名:"+name+"大小:"+size);
- $(".fileDiv").html("<li>文件名:" + name + "</li>")
- var reader = new FileReader();//这是核心,读取操作就是由它完成.
- reader.readAsDataURL(selectedFile);//读取文件的内容,也可以读取文件的URL
- reader.onload = function () {
- //当读取完成后回调这个函数,然后此时文件的内容存储到了result中,直接操作即可
- console.log(this)
- // console.log('onload')
- // console.log(this.result);
- salary = this.result;
- }
- }
- //提交
- function submissionEvent () {
- if ($('.fileDiv li').length == 0) {
- alert('请选择要上传的文件')
- return;
- }
- $('.loading').show();
- $.ajax({
- type: 'post',
- url: '/api/v2/sendSalary',
- data: {
- salary: salary,
- },
- dataType: 'json',
- success: function (res) {
- console.log(res)
- $('.loading').hide();
- salaryEmailDetail()
- showMsg(res.rst.msg)
- },
- error: function (err) {
- $('.loading').hide();
- alert('服务器错误,请稍后再试!')
- }
- })
- }
- //发送状态接口
- function salaryEmailDetail () {
- $('.loading').show();
- $.ajax({
- type: 'post',
- url: '/api/v2/salaryEmailDetail',
- data: {},
- dataType: 'json',
- success: function (res) {
- console.log(res)
- $('.loading').hide();
- if(!res) return;
- if(res.rst && res.rst.detail && Array.isArray(res.rst.detail)){
- staffList = res.rst.detail;
- statusSelectChange('all')
- }
- $(".total").html(res.rst.total)
- $(".succ_n").html(res.rst.succ_n)
- $(".fail_n").html(res.rst.fail_n)
- if(res.rst.is_end == 1) {
- $(".allComplete").show()
- }else{
- $(".allComplete").hide()
- }
- },
- error: function (err) {
- $('.loading').hide();
- alert('服务器错误,请稍后再试!')
- }
- })
- }
- // 发送状态变化
- $('#status_select').change(function(){
- let selectedValue = $(this).val()
- statusSelectChange(selectedValue)
- console.log(selectedValue)
- })
- function statusSelectChange (type) {
- let list = []
- if(type == 'all'){
- list = staffList
- }
- if(type == 'success') {
- staffList.forEach((item)=>{
- if(item.code == 0) {
- list.push(item)
- }
- })
- }
- if(type == 'fail') {
- staffList.forEach((item)=>{
- if(item.code == 500) {
- list.push(item)
- }
- })
- }
- let tbody_html = '';
- if(list.length == 0) {
- tbody_html = `<div class="noDataBox">
- <img src="./common/nodata.png" alt="" srcset="">
- <p>暂无数据</p>
- </div>`
- }else{
- list.forEach((item)=>{
- tbody_html += `<div class="tr">
- <div class="td">${item.name}</div>
- <div class="td">${item.email}</div>
- <div class="td">${item.time}</div>
- <div class="td ${item.code == 500 ? 'fail_c' : ''}">${item.code == 500 ? '失败' : '成功'}</div>
- </div>`
- })
- }
- $(".tbody").html(tbody_html)
- }
- // toast
- function showMsg (msg) {
- var msgBox = $('.alert-info');
- msgBox.children('p').html(msg);
- msgBox.show();
- setTimeout(function () {
- msgBox.hide();
- }, 2500);
- }
- </script>
|