user.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'selectpage'], function ($, undefined, Backend, Table, Form, SelectPage) {
  2. var Controller = {
  3. index: function () {
  4. // 初始化表格参数配置
  5. Table.api.init({
  6. extend: {
  7. index_url: 'bi/user/index' + location.search,
  8. add_url: 'bi/user/add',
  9. edit_url: 'bi/user/edit',
  10. del_url: 'bi/user/del',
  11. multi_url: 'bi/user/multi',
  12. table: 'bi_user',
  13. }
  14. });
  15. var table = $("#table");
  16. // 初始化表格
  17. table.bootstrapTable({
  18. url: $.fn.bootstrapTable.defaults.extend.index_url,
  19. pk: 'id',
  20. sortName: 'id',
  21. columns: [
  22. [
  23. {field: 'institution_name', title: __('Institution_name')},
  24. {field: 'username', title: __('Username')},
  25. {field: 'password', title: __('Password')},
  26. {field: 'createdAt', title: __('Createdat'), operate:'RANGE', addclass:'datetimerange'},
  27. {field: 'realname', title: __('Realname')},
  28. {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
  29. ]
  30. ]
  31. });
  32. // 为表格绑定事件
  33. Table.api.bindevent(table);
  34. },
  35. add: function () {
  36. biInstitutionSearchList();
  37. Controller.api.bindevent();
  38. },
  39. edit: function () {
  40. biInstitutionSearchList();
  41. Controller.api.bindevent();
  42. },
  43. api: {
  44. bindevent: function () {
  45. Form.api.bindevent($("form[role=form]"));
  46. }
  47. }
  48. };
  49. // 选择机构下拉列表
  50. let biInstitutionSearchList = function (id) {
  51. $.ajax({
  52. url: 'bi/institution/institutionSelectList',
  53. type: 'post',
  54. dataType: 'json',
  55. success: function success(res) {
  56. let data = res.rows;
  57. $('#c-institution_id').selectPage({
  58. data : data,
  59. orderBy: 'id'
  60. });
  61. }
  62. });
  63. };
  64. return Controller;
  65. });