res.js 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
  2. var Controller = {
  3. index: function () {
  4. // 初始化表格参数配置
  5. Table.api.init({
  6. extend: {
  7. index_url: 'res/index' + location.search,
  8. add_url: 'res/add',
  9. edit_url: 'res/edit',
  10. // del_url: 'res/del',
  11. multi_url: 'res/multi',
  12. import_url: 'res/import',
  13. reports_url:'res/report',
  14. table: 'res',
  15. }
  16. });
  17. var table = $("#table");
  18. // 初始化表格
  19. table.bootstrapTable({
  20. url: $.fn.bootstrapTable.defaults.extend.index_url,
  21. pk: 'id',
  22. sortName: 'id',
  23. fixedColumns: true,
  24. fixedRightNumber: 1,
  25. columns: [
  26. [
  27. {checkbox: true},
  28. {field: 'id', title: __('Id'),operate: false},
  29. {field: 'entrust_no', title: __('Entrust_no'), operate: 'LIKE'},
  30. // {field: 'entrust_id', title: __('Entrust_id')},
  31. {field: 'machine', title: __('Machine'), operate: 'LIKE'},
  32. {field: 'name', title: __('Name'), operate: 'LIKE'},
  33. {field: 'bach', title: __('Bach'), operate: 'LIKE'},
  34. {field: 'sample_no', title: __('Sample_no'), operate: 'LIKE'},
  35. // {field: 'standard_id', title: __('Standard_id')},
  36. {field: 'standard_name', title: __('Standard_name'), operate: 'LIKE'},
  37. {field: 'dis', title: __('Dis'),operate: false},
  38. {field: 'dis_impurity', title: __('Dis_impurity'),operate: false},
  39. {field: 'ben_total', title: __('Ben_total'),operate: false},
  40. {field: 'ben', title: __('Ben'),operate: false},
  41. {field: 'unit', title: __('Unit'),operate: false},
  42. {field: 'judge', title: __('Judge'),operate: false,formatter: function (value,row,index) {
  43. if (value == 1){
  44. value = '合格';
  45. return '<span style="color: #18bc9c">' +value+ '</span>';
  46. }else{
  47. value = '不合格';
  48. return '<span style="color: #f75444">' +value+ '</span>';
  49. }
  50. }},
  51. {field: 'create', title: __('Create'),operate: false},
  52. {field: 'maker', title: __('Maker'),operate: false},
  53. {field: 'remark', title: __('Remark'),operate: false},
  54. {field: 'params', title: __('Params'),operate: false},
  55. // {field: 'userid', title: __('Userid')},
  56. {field: 'status', title: __('Status'), searchList: {"0":__('Status 0'),"1":__('Status 1'),"2":__('Status 2')}, formatter: Table.api.formatter.status},
  57. // {field: 'delete_time', title: __('Delete_time'), operate: 'LIKE'},
  58. {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate,
  59. buttons: [
  60. {
  61. name: 'data',
  62. text: __('检测数据'),
  63. title: __('检测数据'),
  64. classname: 'btn btn-xs btn-primary btn-dialog',
  65. icon: 'fa fa-list',
  66. extend:'data-area=["100%","100%"]',
  67. url: 'res/data/id/{ids}',
  68. callback: function (data) {
  69. },
  70. visible: function (row) {
  71. //返回true时按钮显示,返回false隐藏
  72. return true;
  73. }
  74. },
  75. {
  76. name: 'data',
  77. text: __('导出数据报告'),
  78. title: __('导出数据报告'),
  79. classname: 'btn btn-xs btn-primary',
  80. // classname: 'btn btn-xs btn-primary btn-dialog',
  81. icon: 'fa fa-list',
  82. extend:'data-area=["100%","100%"]',
  83. url: 'res/report/id/{ids}',
  84. callback: function (data) {
  85. },
  86. visible: function (row) {
  87. //返回true时按钮显示,返回false隐藏
  88. return true;
  89. }
  90. }
  91. ],
  92. formatter: Table.api.formatter.operate}
  93. ]
  94. ]
  95. });
  96. $(".btn-edit").data("area", ["100%","100%"]);
  97. table.on('post-body.bs.table', function (e, settings, json, xhr) {
  98. $(".btn-editone").data("area", ["100%", "100%"]);
  99. });
  100. // 为表格绑定事件
  101. Table.api.bindevent(table);
  102. },
  103. add: function () {
  104. Controller.api.bindevent();
  105. },
  106. edit: function () {
  107. Controller.api.bindevent();
  108. },
  109. api: {
  110. bindevent: function () {
  111. Form.api.bindevent($("form[role=form]"));
  112. }
  113. }
  114. };
  115. return Controller;
  116. });