Açıklama Yok

salary.html 10KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta content="yes" name="apple-mobile-web-app-capable">
  6. <!-- <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0,minimum-scale=1.0,user-scalable=0" /> -->
  7. <title>薪水</title>
  8. <link rel="stylesheet" type="text/css" href="public/public_css.css" />
  9. <script type="text/javascript" src="public/jquery-2.1.0.js"></script>
  10. <style type="text/css">
  11. .alert-info {
  12. position: absolute;
  13. top: 150px;
  14. right: 0;
  15. left: 0;
  16. bottom: 0;
  17. text-align: center;
  18. }
  19. .alert-info p {
  20. display: inline-block;
  21. color: #fff;
  22. font-size: 14px;
  23. line-height: 40px;
  24. padding: 0 10px;
  25. background-color: rgba(0, 0, 0, 0.7);
  26. border-radius: 40px;
  27. }
  28. .loading {
  29. position: fixed;
  30. top: 0;
  31. left: 0;
  32. display: none;
  33. width: 100%;
  34. height: 100vh;
  35. background: rgba(255, 255, 255, 0.4)
  36. }
  37. .loading img {
  38. position: absolute;
  39. top: 0;
  40. bottom: 0;
  41. left: 0;
  42. right: 0;
  43. margin: auto;
  44. width: 60px;
  45. height: 60px;
  46. }
  47. </style>
  48. <style type="text/css">
  49. .contaniner_box {
  50. background: #F7F7F7;
  51. width: 100%;
  52. height: 100vh;
  53. display: flex;
  54. }
  55. .con_left{
  56. width: 400px;
  57. height: 100%;
  58. background-color: #fff;
  59. display: flex;
  60. flex-direction: column;
  61. align-items: center;
  62. justify-content: center;
  63. }
  64. .inputDiv {
  65. width: 200px;
  66. }
  67. .inputDiv input {
  68. display: block;
  69. width: 100%;
  70. height: 50px;
  71. font-size: 20px;
  72. background: transparent;
  73. border: none;
  74. border-radius: 50px;
  75. outline: none;
  76. border: 1px solid #3173FF;
  77. cursor: pointer;
  78. color: #3173FF;
  79. }
  80. /* .inputDiv input:hover {
  81. border-color: #3173FF;
  82. color: #3173FF;
  83. } */
  84. .submission {
  85. width: 300px;
  86. height: 60px;
  87. border-radius: 60px;
  88. background: #3173FF;
  89. border: none;
  90. font-size: 18px;
  91. color: #fff;
  92. display: block;
  93. margin-top: 40px;
  94. cursor: pointer;
  95. }
  96. .fileDiv {
  97. font-size: 20px;
  98. line-height: 50px;
  99. }
  100. .upload_success {
  101. flex: 1;
  102. background: #fff;
  103. height: 100vh;
  104. padding: 40px 20px;
  105. padding-bottom: 0;
  106. box-sizing: border-box;
  107. overflow-y: auto;
  108. margin-left: 15px;
  109. }
  110. .upload_success h3 {
  111. color: #3173FF;
  112. font-size: 14px;
  113. font-weight: bold;
  114. margin-bottom: 10px;
  115. background: rgba(49, 115, 255, 0.15);
  116. padding: 10px 20px;
  117. box-sizing: border-box;
  118. }
  119. .upload_success li {
  120. font-size: 14px;
  121. line-height: 30px;
  122. color: #fff;
  123. }
  124. .upload_success li span:nth-of-type(1) {
  125. padding-right: 20px;
  126. width: 40%;
  127. display: inline-block;
  128. }
  129. .table{
  130. width: 100%;
  131. font-size: 14px;
  132. border-collapse: collapse;
  133. border: 1px solid #ebeef5;
  134. margin-top: 10px;
  135. }
  136. .table .thead{
  137. background-color: #fafafa;
  138. }
  139. .table .thead .th{
  140. font-weight: bold;
  141. }
  142. .table .tr .th:nth-child(1), .table .tr .td:nth-child(1){
  143. width: 20%;
  144. }
  145. .table .tr .th:nth-child(2), .table .tr .td:nth-child(2){
  146. width: 30%;
  147. }
  148. .table .tr .th:nth-child(3), .table .tr .td:nth-child(3){
  149. width: 30%;
  150. }
  151. .table .tr .th:nth-child(4), .table .tr .td:nth-child(4){
  152. width: 20%;
  153. }
  154. .table .tr{
  155. color: rgb(22, 30, 70);
  156. height: 44px;
  157. display: flex;
  158. }
  159. .table .th, .table .td{
  160. border-right: 1px solid #ebeef5;
  161. border-bottom: 1px solid #ebeef5;
  162. text-align: center;
  163. display: flex;
  164. align-items: center;
  165. justify-content: center;
  166. flex-wrap: wrap;
  167. }
  168. .tbody{
  169. height: calc(100vh - 190px);
  170. box-sizing: border-box;
  171. overflow-y: auto;
  172. }
  173. .table .td{
  174. color: #333;
  175. }
  176. .fail_c{
  177. color: red !important;
  178. }
  179. .select_box{
  180. width: 160px;
  181. height: 32px;
  182. border: 1px solid #ddd;
  183. padding: 0 10px;
  184. border-radius: 4px;
  185. color: #333;
  186. }
  187. .noDataBox{
  188. display: flex;
  189. flex-direction: column;
  190. justify-content: center;
  191. align-items: center;
  192. padding-top: 16vh;
  193. }
  194. .noDataBox img{
  195. width: 300px;
  196. }
  197. .noDataBox p{
  198. color: #aaa;
  199. }
  200. .refresh{
  201. color: #3173FF;
  202. cursor: pointer;
  203. font-size: 14px;
  204. margin-left: 20px;
  205. }
  206. .hint{
  207. color: #999;
  208. font-size: 12px;
  209. }
  210. .flex{
  211. display: flex;
  212. align-items: center;
  213. }
  214. .allComplete{
  215. display: none;
  216. }
  217. </style>
  218. </head>
  219. <body>
  220. <div class="contaniner_box">
  221. <div class="con_left">
  222. <ul class="fileDiv"></ul>
  223. <div class="inputDiv">
  224. <input type="file" id="files" style="display: none" onchange="fileImport();">
  225. <input type="button" id="fileImport" value="导入文件">
  226. </div>
  227. <button class="submission" onclick="submissionEvent()">提交</button>
  228. </div>
  229. <div class="upload_success">
  230. <h3><span style="color:#23c23f" class="allComplete">✅ 全部发送完成。</span>已发送酷炫成员(<span class="total">-</span>)人,发送成功(<span class="succ_n">-</span>)人,失败(<span class="fail_n">-</span>)人。</h3>
  231. <div class="flex">
  232. <select class="select_box" id="status_select">
  233. <option value="all">全部</option>
  234. <option value="success">发送成功</option>
  235. <option value="fail">发送失败</option>
  236. </select>
  237. <div class="refresh" onclick="salaryEmailDetail()">刷新</div>
  238. <div class="hint">(点击刷新邮件发送详情)</div>
  239. </div>
  240. <div class="table">
  241. <div class="thead">
  242. <div class="tr">
  243. <div class="th">姓名</div>
  244. <div class="th">邮箱</div>
  245. <div class="th">发送时间</div>
  246. <div class="th">发送状态</div>
  247. </div>
  248. </div>
  249. <div class="tbody">
  250. <!-- 员工列表 -->
  251. <div class="noDataBox">
  252. <img src="./common/nodata.png" alt="" srcset="">
  253. <p>暂无数据</p>
  254. </div>
  255. </div>
  256. </div>
  257. </div>
  258. </div>
  259. <div class="alert-info" style="display: none;">
  260. <!-- tip提示,3s后消失 -->
  261. <p></p>
  262. </div>
  263. <div class="loading">
  264. <img src="common/loading.gif" />
  265. </div>
  266. </body>
  267. </html>
  268. <script type="text/javascript">
  269. $().ready(function() {
  270. salaryEmailDetail();
  271. })
  272. let staffList = [];//员工列表
  273. var salary = '';
  274. //点击导入按钮,使files触发点击事件,然后完成读取文件的操作
  275. $("#fileImport").click(function () {
  276. $("#files").click();
  277. })
  278. function fileImport () {
  279. //获取读取我文件的File对象
  280. var selectedFile = document.getElementById('files').files[0];
  281. var name = selectedFile.name;//读取选中文件的文件名
  282. var size = selectedFile.size;//读取选中文件的大小
  283. // console.log("文件名:"+name+"大小:"+size);
  284. $(".fileDiv").html("<li>文件名:" + name + "</li>")
  285. var reader = new FileReader();//这是核心,读取操作就是由它完成.
  286. reader.readAsDataURL(selectedFile);//读取文件的内容,也可以读取文件的URL
  287. reader.onload = function () {
  288. //当读取完成后回调这个函数,然后此时文件的内容存储到了result中,直接操作即可
  289. console.log(this)
  290. // console.log('onload')
  291. // console.log(this.result);
  292. salary = this.result;
  293. }
  294. }
  295. //提交
  296. function submissionEvent () {
  297. if ($('.fileDiv li').length == 0) {
  298. alert('请选择要上传的文件')
  299. return;
  300. }
  301. $('.loading').show();
  302. $.ajax({
  303. type: 'post',
  304. url: '/api/v2/sendSalary',
  305. data: {
  306. salary: salary,
  307. },
  308. dataType: 'json',
  309. success: function (res) {
  310. console.log(res)
  311. $('.loading').hide();
  312. salaryEmailDetail()
  313. showMsg(res.rst.msg)
  314. },
  315. error: function (err) {
  316. $('.loading').hide();
  317. alert('服务器错误,请稍后再试!')
  318. }
  319. })
  320. }
  321. //发送状态接口
  322. function salaryEmailDetail () {
  323. $('.loading').show();
  324. $.ajax({
  325. type: 'post',
  326. url: '/api/v2/salaryEmailDetail',
  327. data: {},
  328. dataType: 'json',
  329. success: function (res) {
  330. console.log(res)
  331. $('.loading').hide();
  332. if(!res) return;
  333. if(res.rst && res.rst.detail && Array.isArray(res.rst.detail)){
  334. staffList = res.rst.detail;
  335. statusSelectChange('all')
  336. }
  337. $(".total").html(res.rst.total)
  338. $(".succ_n").html(res.rst.succ_n)
  339. $(".fail_n").html(res.rst.fail_n)
  340. if(res.rst.is_end == 1) {
  341. $(".allComplete").show()
  342. }else{
  343. $(".allComplete").hide()
  344. }
  345. },
  346. error: function (err) {
  347. $('.loading').hide();
  348. alert('服务器错误,请稍后再试!')
  349. }
  350. })
  351. }
  352. // 发送状态变化
  353. $('#status_select').change(function(){
  354. let selectedValue = $(this).val()
  355. statusSelectChange(selectedValue)
  356. console.log(selectedValue)
  357. })
  358. function statusSelectChange (type) {
  359. let list = []
  360. if(type == 'all'){
  361. list = staffList
  362. }
  363. if(type == 'success') {
  364. staffList.forEach((item)=>{
  365. if(item.code == 0) {
  366. list.push(item)
  367. }
  368. })
  369. }
  370. if(type == 'fail') {
  371. staffList.forEach((item)=>{
  372. if(item.code == 500) {
  373. list.push(item)
  374. }
  375. })
  376. }
  377. let tbody_html = '';
  378. if(list.length == 0) {
  379. tbody_html = `<div class="noDataBox">
  380. <img src="./common/nodata.png" alt="" srcset="">
  381. <p>暂无数据</p>
  382. </div>`
  383. }else{
  384. list.forEach((item)=>{
  385. tbody_html += `<div class="tr">
  386. <div class="td">${item.name}</div>
  387. <div class="td">${item.email}</div>
  388. <div class="td">${item.time}</div>
  389. <div class="td ${item.code == 500 ? 'fail_c' : ''}">${item.code == 500 ? '失败' : '成功'}</div>
  390. </div>`
  391. })
  392. }
  393. $(".tbody").html(tbody_html)
  394. }
  395. // toast
  396. function showMsg (msg) {
  397. var msgBox = $('.alert-info');
  398. msgBox.children('p').html(msg);
  399. msgBox.show();
  400. setTimeout(function () {
  401. msgBox.hide();
  402. }, 2500);
  403. }
  404. </script>