res.js 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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. table: 'res',
  14. }
  15. });
  16. var table = $("#table");
  17. // 初始化表格
  18. table.bootstrapTable({
  19. url: $.fn.bootstrapTable.defaults.extend.index_url,
  20. pk: 'id',
  21. sortName: 'id',
  22. fixedColumns: true,
  23. fixedRightNumber: 1,
  24. columns: [
  25. [
  26. {checkbox: true},
  27. {field: 'id', title: __('Id'),operate: false},
  28. {field: 'entrust_no', title: __('Entrust_no'), operate: 'LIKE'},
  29. // {field: 'entrust_id', title: __('Entrust_id')},
  30. {field: 'machine', title: __('Machine'), operate: 'LIKE'},
  31. {field: 'name', title: __('Name'), operate: 'LIKE'},
  32. {field: 'bach', title: __('Bach'), operate: 'LIKE'},
  33. {field: 'sample_no', title: __('Sample_no'), operate: 'LIKE'},
  34. // {field: 'standard_id', title: __('Standard_id')},
  35. {field: 'standard_name', title: __('Standard_name'), operate: 'LIKE'},
  36. {field: 'dis', title: __('Dis'),operate: false},
  37. {field: 'dis_impurity', title: __('Dis_impurity'),operate: false},
  38. {field: 'ben_total', title: __('Ben_total'),operate: false},
  39. {field: 'ben', title: __('Ben'),operate: false},
  40. {field: 'unit', title: __('Unit'),operate: false},
  41. {field: 'judge', title: __('Judge'),operate: false,formatter: function (value,row,index) {
  42. if (value == 1){
  43. value = '合格';
  44. return '<span style="color: #18bc9c">' +value+ '</span>';
  45. }else{
  46. value = '不合格';
  47. return '<span style="color: #f75444">' +value+ '</span>';
  48. }
  49. }},
  50. {field: 'create', title: __('Create'),operate: false},
  51. {field: 'maker', title: __('Maker'),operate: false},
  52. {field: 'remark', title: __('Remark'),operate: false},
  53. {field: 'params', title: __('Params'),operate: false},
  54. // {field: 'userid', title: __('Userid')},
  55. {field: 'status', title: __('Status'), searchList: {"0":__('Status 0'),"1":__('Status 1'),"2":__('Status 2')}, formatter: Table.api.formatter.status},
  56. // {field: 'delete_time', title: __('Delete_time'), operate: 'LIKE'},
  57. {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
  58. ]
  59. ]
  60. });
  61. $(".btn-edit").data("area", ["100%","100%"]);
  62. table.on('post-body.bs.table', function (e, settings, json, xhr) {
  63. $(".btn-editone").data("area", ["100%", "100%"]);
  64. });
  65. // 为表格绑定事件
  66. Table.api.bindevent(table);
  67. },
  68. add: function () {
  69. Controller.api.bindevent();
  70. },
  71. edit: function () {
  72. Controller.api.bindevent();
  73. },
  74. api: {
  75. bindevent: function () {
  76. Form.api.bindevent($("form[role=form]"));
  77. }
  78. }
  79. };
  80. return Controller;
  81. });