Brak opisu

samplePool.js 1.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. $(".importFile").click(function () {
  2. $("#upFile").trigger("click");
  3. });
  4. $("#upFile").change(function () {
  5. upload();
  6. });
  7. function upload() {
  8. if (document.getElementById("upFile").files.length > 0) {
  9. var formData = new FormData();
  10. formData.append("upFile", document.getElementById("upFile").files[0]);
  11. formData.append("specialid", selectThemeId);
  12. formData.append("token", $.cookie("token"));
  13. $.ajax({
  14. url: huayi.config.callcenter_url + "SamplePool/ImportExcel",
  15. type: "POST",
  16. data: formData,
  17. contentType: false,
  18. processData: false,
  19. success: function (result) {
  20. $("#upFile").change(function () {
  21. upload();
  22. });
  23. var r = $.parseJSON(result);
  24. if (r.state.toLowerCase() == "success") {
  25. layer.msg("导入成功");
  26. initOrderTable(selectThemeId)
  27. }
  28. },
  29. });
  30. } else {
  31. layer.confirm("请上传文件!", {
  32. btn: ["确定"],
  33. });
  34. }
  35. }
  36. $(".exportTemplate").click(function () {
  37. var a = document.createElement("a");
  38. a.style.display = "none";
  39. a.download = "样本池模版.xlsx";
  40. a.href = "../static/xls/样本池模版.xlsx";
  41. document.body.appendChild(a);
  42. a.click();
  43. document.body.removeChild(a);
  44. });