Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

AppIndex.js 7.4 KiB

4 anos atrás
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. jQuery.extend({
  2. handleError: function (s, xhr, status, e) {
  3. // If a local callback was specified, fire it
  4. if (s.error) {
  5. s.error.call(s.context || s, xhr, status, e);
  6. }
  7. // Fire the global callback
  8. if (s.global) {
  9. (s.context ? jQuery(s.context) : jQuery.event).trigger(
  10. "ajaxError", [xhr, s, e]);
  11. }
  12. },
  13. createUploadIframe: function (b, d) {
  14. var a = "jUploadFrame" + b;
  15. var c = '<iframe id="' + a + '" name="' + a + '" style="position:absolute; top:-9999px; left:-9999px"';
  16. if (window.ActiveXObject) {
  17. if (typeof d == "boolean") {
  18. c += ' src="javascript:false"'
  19. } else {
  20. if (typeof d == "string") {
  21. c += ' src="' + d + '"'
  22. }
  23. }
  24. }
  25. c += " />";
  26. jQuery(c).appendTo(document.body);
  27. return jQuery("#" + a).get(0)
  28. },
  29. createUploadForm: function (g, b, a) {
  30. var e = "jUploadForm" + g;
  31. var c = "jUploadFile" + g;
  32. var d = jQuery('<form action="" method="POST" name="' + e + '" id="' + e + '" enctype="multipart/form-data"></form>');
  33. if (a) {
  34. for (var f in a) {
  35. jQuery('<input type="hidden" name="' + f + '" value="' + a[f] + '" />').appendTo(d)
  36. }
  37. }
  38. var j = jQuery("#" + b);
  39. var h = jQuery(j).clone();
  40. jQuery(j).attr("id", c);
  41. jQuery(j).before(h);
  42. jQuery(j).appendTo(d);
  43. jQuery(d).css("position", "absolute");
  44. jQuery(d).css("top", "-1200px");
  45. jQuery(d).css("left", "-1200px");
  46. jQuery(d).appendTo("body");
  47. return d
  48. },
  49. ajaxFileUpload: function (i) {
  50. i = jQuery.extend({},
  51. jQuery.ajaxSettings, i);
  52. var f = new Date().getTime();
  53. var b = jQuery.createUploadForm(f, i.fileElementId, (typeof (i.data) == "undefined" ? false : i.data));
  54. var g = jQuery.createUploadIframe(f, i.secureuri);
  55. var d = "jUploadFrame" + f;
  56. var c = "jUploadForm" + f;
  57. if (i.global && !jQuery.active++) {
  58. jQuery.event.trigger("ajaxStart")
  59. }
  60. var h = false;
  61. var k = {};
  62. if (i.global) {
  63. jQuery.event.trigger("ajaxSend", [k, i])
  64. }
  65. var j = function (o) {
  66. var n = document.getElementById(d);
  67. try {
  68. if (n.contentWindow) {
  69. k.responseText = n.contentWindow.document.body ? n.contentWindow.document.body.innerHTML : null;
  70. k.responseXML = n.contentWindow.document.XMLDocument ? n.contentWindow.document.XMLDocument : n.contentWindow.document
  71. } else {
  72. if (n.contentDocument) {
  73. k.responseText = n.contentDocument.document.body ? n.contentDocument.document.body.innerHTML : null;
  74. k.responseXML = n.contentDocument.document.XMLDocument ? n.contentDocument.document.XMLDocument : n.contentDocument.document
  75. }
  76. }
  77. } catch (m) {
  78. jQuery.handleError(i, k, null, m)
  79. }
  80. if (k || o == "timeout") {
  81. h = true;
  82. var p;
  83. try {
  84. p = o != "timeout" ? "success" : "error";
  85. if (p != "error") {
  86. var l = jQuery.uploadHttpData(k, i.dataType);
  87. if (i.success) {
  88. i.success(l, p)
  89. }
  90. if (i.global) {
  91. jQuery.event.trigger("ajaxSuccess", [k, i])
  92. }
  93. } else {
  94. jQuery.handleError(i, k, p)
  95. }
  96. } catch (m) {
  97. p = "error";
  98. jQuery.handleError(i, k, p, m)
  99. }
  100. if (i.global) {
  101. jQuery.event.trigger("ajaxComplete", [k, i])
  102. }
  103. if (i.global && !--jQuery.active) {
  104. jQuery.event.trigger("ajaxStop")
  105. }
  106. if (i.complete) {
  107. i.complete(k, p)
  108. }
  109. jQuery(n).unbind();
  110. setTimeout(function () {
  111. try {
  112. jQuery(n).remove();
  113. jQuery(b).remove()
  114. } catch (q) {
  115. jQuery.handleError(i, k, null, q)
  116. }
  117. },
  118. 100);
  119. k = null
  120. }
  121. };
  122. if (i.timeout > 0) {
  123. setTimeout(function () {
  124. if (!h) {
  125. j("timeout")
  126. }
  127. },
  128. i.timeout)
  129. }
  130. try {
  131. var b = jQuery("#" + c);
  132. jQuery(b).attr("action", i.url);
  133. jQuery(b).attr("method", "POST");
  134. jQuery(b).attr("target", d);
  135. if (b.encoding) {
  136. jQuery(b).attr("encoding", "multipart/form-data")
  137. } else {
  138. jQuery(b).attr("enctype", "multipart/form-data")
  139. }
  140. jQuery(b).submit()
  141. } catch (a) {
  142. jQuery.handleError(i, k, null, a)
  143. }
  144. jQuery("#" + d).load(j);
  145. return {
  146. abort: function () { }
  147. }
  148. },
  149. uploadHttpData: function (r, type) {
  150. var data = !type;
  151. data = type == "xml" || data ? r.responseXML : r.responseText;
  152. if (type == "script") {
  153. jQuery.globalEval(data)
  154. }
  155. if (type == "json") {
  156. eval("data = " + data)
  157. }
  158. if (type == "html") {
  159. jQuery("<div>").html(data).evalScripts()
  160. }
  161. return data
  162. }
  163. });
  164. var loaddfimg;
  165. var baseinfo;
  166. var bootstrap = function (a, b) {
  167. var c = {
  168. init: function () {
  169. c.initData();
  170. c.bind()
  171. },
  172. bind: function () {
  173. function d() {
  174. var e = document.getElementById("uploadFile").files[0];
  175. var g = window.URL.createObjectURL(e);
  176. document.getElementById("uploadPreview").src = g
  177. }
  178. a("#uploadFile").on("change", d);
  179. a("#lr_save_btn").on("click",
  180. function () {
  181. var e = document.getElementById("uploadFile").files[0];
  182. if (!!e) {
  183. b.loading(true, "正在保存...");
  184. a.ajaxFileUpload({
  185. url: top.$.rootUrl + "/LR_SystemModule/LogoImg/UploadFile?code=applogo",
  186. secureuri: false,
  187. fileElementId: "uploadFile",
  188. dataType: "json",
  189. success: function (f) {
  190. b.loading(false);
  191. a("#uploadFile").on("change", d);
  192. if (f.code == 200) {
  193. b.alert.success("保存成功")
  194. }
  195. }
  196. })
  197. }
  198. })
  199. },
  200. initData: function () {
  201. a(".file").prepend('<img id="uploadPreview" src="' + top.$.rootUrl + '/LR_SystemModule/LogoImg/GetImg?code=applogo" >')
  202. }
  203. };
  204. c.init()
  205. };