profile.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'upload'], function ($, undefined, Backend, Table, Form, Upload) {
  2. var Controller = {
  3. index: function () {
  4. // 初始化表格参数配置
  5. Table.api.init({
  6. search: true,
  7. advancedSearch: true,
  8. pagination: true,
  9. extend: {
  10. "index_url": "general/profile/index",
  11. "add_url": "",
  12. "edit_url": "",
  13. "del_url": "",
  14. "multi_url": "",
  15. }
  16. });
  17. var table = $("#table");
  18. // 初始化表格
  19. table.bootstrapTable({
  20. url: $.fn.bootstrapTable.defaults.extend.index_url,
  21. columns: [
  22. [
  23. {field: 'id', title: 'ID'},
  24. {field: 'title', title: __('Title')},
  25. {field: 'url', title: __('Url'), align: 'left', formatter: Controller.api.formatter.url},
  26. {field: 'ip', title: __('ip')},
  27. {field: 'createtime', title: __('Createtime'), formatter: Table.api.formatter.datetime},
  28. ]
  29. ],
  30. commonSearch: false
  31. });
  32. // 为表格绑定事件
  33. Table.api.bindevent(table);//当内容渲染完成后
  34. Form.api.bindevent($("#update-form"), null, function () {
  35. $("input[name='row[password]']").val('');
  36. var url = Backend.api.cdnurl($("#c-avatar").val());
  37. top.window.$(".user-panel .image img,.user-menu > a > img,.user-header > img").prop("src", url);
  38. return true;
  39. });
  40. Upload.api.custom.changeavatar = function (response) {
  41. var url = Backend.api.cdnurl(response.url);
  42. $(".profile-user-img").prop("src", url);
  43. };
  44. },
  45. api: {
  46. formatter: {
  47. url: function (value, row, index) {
  48. return '<div class="input-group input-group-sm" style="width:250px;"><input type="text" class="form-control input-sm" value="' + value + '"><span class="input-group-btn input-group-sm"><a href="' + value + '" target="_blank" class="btn btn-default btn-sm"><i class="fa fa-link"></i></a></span></div>';
  49. },
  50. },
  51. }
  52. };
  53. return Controller;
  54. });