RoadFlow2.1 临时演示

roadui.file.js 1.6KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. //文件上传
  2. ; RoadUI.File = function ()
  3. {
  4. var instance = this;
  5. this.init = function ($files)
  6. {
  7. $files.each(function ()
  8. {
  9. $file = $(this);
  10. var id = $file.attr("id") || "";
  11. var name = $file.attr("name") || "";
  12. var filetype = $file.attr("filetype") || "";
  13. var value = $file.val();
  14. if (name.length == 0)
  15. {
  16. name = id;
  17. }
  18. var $hide = $('<input type="hidden" id="' + id + '" name="' + name + '" value="" />');
  19. var $but = $('<input type="button" class="mybutton" style="margin:0;" value="附件" />');
  20. $file.attr("id", id + "_text");
  21. $file.attr("name", name + "_text");
  22. $file.attr("readonly", "readonly");
  23. $file.removeClass().addClass("mytext");
  24. $file.css({ "border-top": "1px solid #b7b6b4", "border-left": "1px solid #b7b6b4", "border-bottom": "1px solid #b7b6b4", "border-right": "0" });
  25. $hide.val(value);
  26. if (value.length > 0)
  27. {
  28. $file.val('共' + value.split('|').length + '个文件');
  29. }
  30. $but.bind("click", function ()
  31. {
  32. var val = $(this).prev().prev().val();
  33. new RoadUI.Window().open({ id: "file_" + id, url: (top.rootdir || "") + "/Controls/UploadFiles/Default.aspx?eid=" + id + "&files=" + val + "&filetype=" + filetype, width: 500, height: 400, title: "附件管理", showclose: false });
  34. });
  35. $file.after($but).before($hide);
  36. });
  37. };
  38. }