standards.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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: 'manage/standards/index' + location.search,
  8. add_url: 'manage/standards/add',
  9. edit_url: 'manage/standards/edit',
  10. del_url: 'manage/standards/del',
  11. multi_url: 'manage/standards/multi',
  12. table: 'qc_standards',
  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_id', title: __('机构名称'), visible: false},
  24. {field: 'institution_name', title: __('机构名称'), align: 'left', searchable: false},
  25. // {field: 'depart_id', title: __('Depart_id')},
  26. {field: 'title', title: __('Title')},
  27. {field: 'desc', title: __('Desc')},
  28. {field: 'status', title: __('Status'),formatter: function (value){
  29. if(value == 0){return '禁用'}else if(value == 1){return '启用'}else{return ''}
  30. }},
  31. {field: 'createdAt', title: __('Createdat'), operate:'RANGE', addclass:'datetimerange'},
  32. {field: 'updatedAt', title: __('修改时间'), operate:'RANGE', addclass:'datetimerange'},
  33. {field: 'type', title: __('Type'),formatter: function (value){
  34. if(value == 1){return '技术质控'}else if(value == 2){return '诊断质控'}else{return ''}
  35. },searchList:{"1":"技术质控","2":"诊断质控"}},
  36. {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
  37. ]
  38. ]
  39. });
  40. // 为表格绑定事件
  41. Table.api.bindevent(table);
  42. initInstitutionSearchList('institution_id');
  43. },
  44. add: function () {
  45. initInstitutionSearchList('institution_id');
  46. Controller.api.bindevent();
  47. },
  48. edit: function () {
  49. initInstitutionSearchList('institution_id');
  50. Controller.api.bindevent();
  51. },
  52. api: {
  53. bindevent: function () {
  54. Form.api.bindevent($("form[role=form]"));
  55. }
  56. }
  57. };
  58. // 选择机构下拉列表
  59. let initInstitutionSearchList = function (id) {
  60. $.ajax({
  61. url: 'institution/institution/institutionSelectList',
  62. type: 'post',
  63. dataType: 'json',
  64. success: function success(res) {
  65. let data = res.rows;
  66. $('#'+id).selectPage({
  67. data : data,
  68. orderBy: 'index'
  69. });
  70. }
  71. });
  72. };
  73. return Controller;
  74. });