Blame view

public/assets/js/backend/general/profile.js 2.21 KB
2db47680   hexiaodong   chore: 初始提交 php 遗...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
  define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'upload'], function ($, undefined, Backend, Table, Form, Upload) {
  
      var Controller = {
          index: function () {
  
              // 初始化表格参数配置
              Table.api.init({
                  search: true,
                  advancedSearch: true,
                  pagination: true,
                  extend: {
                      "index_url": "general/profile/index",
                      "add_url": "",
                      "edit_url": "",
                      "del_url": "",
                      "multi_url": "",
                  }
              });
  
              var table = $("#table");
  
              // 初始化表格
              table.bootstrapTable({
                  url: $.fn.bootstrapTable.defaults.extend.index_url,
                  columns: [
                      [
                          {field: 'id', title: 'ID'},
                          {field: 'title', title: __('Title')},
                          {field: 'url', title: __('Url'), align: 'left', formatter: Table.api.formatter.url},
                          {field: 'ip', title: __('ip'), formatter:Table.api.formatter.search},
                          {field: 'createtime', title: __('Createtime'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange', sortable: true},
                      ]
                  ],
                  commonSearch: false
              });
  
              // 为表格绑定事件
              Table.api.bindevent(table);//当内容渲染完成后
  
              // 给上传按钮添加上传成功事件
              $("#faupload-avatar").data("upload-success", function (data) {
                  var url = Backend.api.cdnurl(data.url);
                  $(".profile-user-img").prop("src", url);
                  Toastr.success("上传成功!");
              });
  
              // 给表单绑定事件
              Form.api.bindevent($("#update-form"), function () {
                  $("input[name='row[password]']").val('');
                  var url = Backend.api.cdnurl($("#c-avatar").val());
                  top.window.$(".user-panel .image img,.user-menu > a > img,.user-header > img").prop("src", url);
                  return true;
              });
          },
      };
      return Controller;
  });