zentaobiz.ui.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. var methods = [];
  2. $(document).ready(function()
  3. {
  4. if(!isVerify)
  5. {
  6. if(isModuleCalcExist)
  7. {
  8. var $html = genVerifyResult(checkModuleFile, false, moduleCalcTip);
  9. $('.verify-result').append($html);
  10. }
  11. else
  12. {
  13. verify();
  14. }
  15. }
  16. var htmlHeight = $('html').height();
  17. $('.verify-content').height(Math.min(htmlHeight - 440, 342));
  18. });
  19. function verify(method)
  20. {
  21. if(!method)
  22. {
  23. methods = Object.keys(verifyCustomMethods);
  24. $('.verify-result').empty();
  25. $('.metric-result').empty();
  26. $('.publish-btn-disabled').show();
  27. $('.publish-btn').addClass('hidden');
  28. method = methods.shift();
  29. }
  30. verifyStep(method, function(status, error){
  31. if(!status) return;
  32. if(methods.length == 0)
  33. {
  34. var url = $.createLink('metric', 'ajaxgetmetricresult', 'metricID=' + metricId + '&from=' + from);
  35. loadTarget(url, '.metric-result')
  36. $('.publish-btn-disabled').hide();
  37. $('.publish-btn').removeClass('hidden');
  38. return;
  39. }
  40. method = methods.shift();
  41. verify(method);
  42. });
  43. }
  44. function verifyStep(step, callback)
  45. {
  46. var url = $.createLink('metric', 'ajaxCheck', 'code=' + code + '&step=' + step);
  47. $.get(url, function(resp){
  48. resp = JSON.parse(resp);
  49. var status = resp[0];
  50. var error = resp[1];
  51. var $html = genVerifyResult(verifyCustomMethods[step].text, status, error);
  52. $('.verify-result').append($html);
  53. if(typeof callback == 'function') callback(status, error);
  54. });
  55. }
  56. function genVerifyResult(tip, status, error)
  57. {
  58. var sentenceClass = status ? 'pass' : 'error';
  59. var iconClass = status ? 'check' : 'close';
  60. var html = '<p class="verify-sentence ' + sentenceClass + '">';
  61. html += tip;
  62. html += '<i class="icon icon-' + iconClass + '"></i>';
  63. if(error && error.length) html += '<input class="bg-danger ml-5 ellipsis w-96" title="' + error + '" value="' + error + '"/>';
  64. html += '</p>';
  65. return $(html);
  66. }
  67. function download(id)
  68. {
  69. var url = $.createLink('metric', 'downloadTemplate', 'metricID=' + id);
  70. var form = document.createElement('form');
  71. form.style.display = 'none';
  72. form.method = 'POST';
  73. form.action = url;
  74. document.body.appendChild(form);
  75. form.submit();
  76. document.body.removeChild(form);
  77. }