people.js 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
  2. var Controller = {
  3. index: function () {
  4. $(".btn-add").data("area", ["1020px", "775px"]);
  5. // 初始化表格参数配置
  6. Table.api.init();
  7. this.table.first();
  8. this.table.second();
  9. },
  10. table: {
  11. first: function () {
  12. // 表格1
  13. var table1 = $("#table1");
  14. table1.bootstrapTable({
  15. url: 'unit/get_unit',
  16. toolbar: '#toolbar1',
  17. sortName: 'id',
  18. search: false,
  19. pagination: false,
  20. columns: [
  21. [
  22. {
  23. field: 'operate', title: __('单位'), table: table1, events: Table.api.events.operate, buttons: [
  24. {
  25. name: 'log',
  26. title: '',
  27. text: function(row){return row.name},
  28. classname: 'btn btn-success btn-xs btn-click btn-custom',
  29. click: function (e, data) {
  30. console.log(data)
  31. $("#myTabContent2 .form-commonsearch select[name='unit_id']").val(data.id);
  32. $("#myTabContent2 .btn-refresh").trigger("click");
  33. }
  34. }
  35. ], formatter: Table.api.formatter.operate
  36. }
  37. ]
  38. ]
  39. });
  40. // 为表格1绑定事件
  41. Table.api.bindevent(table1);
  42. },
  43. second: function () {
  44. // 表格2
  45. var table = $("#table2");
  46. $(".btn-add").data("area",["1000px","90%"]);
  47. // $(".btn-edit").data("area",["860px","90%"]);
  48. // 初始化表格参数配置
  49. Table.api.init({
  50. extend: {
  51. index_url: 'people/index' + location.search,
  52. add_url: 'people/add',
  53. edit_url: 'people/edit',
  54. del_url: 'people/del',
  55. multi_url: 'people/multi',
  56. import_url: 'people/import',
  57. table: 'people',
  58. }
  59. });
  60. Controller.api.bindevent();
  61. // var table = $("#table");
  62. // 初始化表格
  63. table.bootstrapTable({
  64. url: $.fn.bootstrapTable.defaults.extend.index_url,
  65. pk: 'id',
  66. sortName: 'id',
  67. columns: [
  68. [
  69. {checkbox: true},
  70. {field: 'order_number', title: __('序号'),operate:false},
  71. {field: 'name', title: __('Name'), operate: 'LIKE'},
  72. {field: 'sex_list', title: __('Sex_list'), searchList: {"男":__('男'),"女":__('女')}, formatter: Table.api.formatter.normal},
  73. {field: 'age', title: __('Age'),operate:false},
  74. {field: 'duty', title: __('Duty_id'),operate:false},
  75. {field: 'unit_id', title: __('unit_id'),visible:false, searchList: $.getJSON("unit/index?lists=1")},
  76. {field: 'unit_id_text', title: __('unit_id'),operate:false},
  77. {field: 'post_id', title: __('Post_id'),visible:false, searchList: $.getJSON("people/post")},
  78. {field: 'grade_id_text', title: __('Grade_id'),operate:false},
  79. {field: 'post_date', title: __('Post_date'), operate:'RANGE', addclass:'datetimerange', autocomplete:false,operate:false},
  80. {field: 'job', title: __('Job'),operate:false},
  81. {field: 'skill_id', title: __('Skill_id'),operate:'LIKE',visible:false, searchList: $.getJSON("people/skill")},
  82. {field: 'rank_id', title: __('Skill_id'),operate:'LIKE',visible:false, searchList: $.getJSON("people/rank")},
  83. {field: 'skill_date', title: __('Skill_date'),operate:false, addclass:'datetimerange', autocomplete:false},
  84. {field: 'level_id_text', title: __('Level_id'),operate:false},
  85. {field: 'level_date', title: __('Level_date'),operate:false, addclass:'datetimerange', autocomplete:false},
  86. {field: 'origin', title: __('Origin'),operate:false},
  87. {field: 'education_id_text', title: __('Education_id'),operate:false},
  88. {field: 'school', title: __('School'),operate:false},
  89. {field: 'reign', title: __('人员状态'), searchList: {'0':__('在位'),'1':__('休假'), '2':__('出差'), '6':__('外诊'), '4':__('学习'), '3': __('借调'), '5' : __('执行任务'), '7':__('其他')}, formatter: Table.api.formatter.normal},
  90. {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
  91. ]
  92. ]
  93. });
  94. // 为表格绑定事件
  95. Table.api.bindevent(table);
  96. table.on('post-body.bs.table',function(){
  97. $(".btn-editone").data("area",["1000px","90%"]);
  98. })
  99. }
  100. },
  101. // index: function () {
  102. // $(".btn-add").data("area",["1000px","90%"]);
  103. // // $(".btn-edit").data("area",["860px","90%"]);
  104. // // 初始化表格参数配置
  105. // Table.api.init({
  106. // extend: {
  107. // index_url: 'people/index' + location.search,
  108. // add_url: 'people/add',
  109. // edit_url: 'people/edit',
  110. // del_url: 'people/del',
  111. // multi_url: 'people/multi',
  112. // import_url: 'people/import',
  113. // table: 'people',
  114. // }
  115. // });
  116. // Controller.api.bindevent();
  117. // var table = $("#table");
  118. // // 初始化表格
  119. // table.bootstrapTable({
  120. // url: $.fn.bootstrapTable.defaults.extend.index_url,
  121. // pk: 'id',
  122. // sortName: 'id',
  123. // columns: [
  124. // [
  125. // {checkbox: true},
  126. // {field: 'order_number', title: __('序号'),operate:false},
  127. // {field: 'name', title: __('Name'), operate: 'LIKE'},
  128. // {field: 'sex_list', title: __('Sex_list'), searchList: {"男":__('男'),"女":__('女')}, formatter: Table.api.formatter.normal},
  129. // {field: 'age', title: __('Age'),operate:false},
  130. // {field: 'duty', title: __('Duty_id'),operate:false},
  131. // {field: 'unit_id', title: __('unit_id'),visible:false, searchList: $.getJSON("unit/index?lists=1")},
  132. // {field: 'unit_id_text', title: __('unit_id'),operate:false},
  133. // {field: 'post_id', title: __('Post_id'),visible:false, searchList: $.getJSON("people/post")},
  134. // {field: 'grade_id_text', title: __('Grade_id'),operate:false},
  135. // {field: 'post_date', title: __('Post_date'), operate:'RANGE', addclass:'datetimerange', autocomplete:false,operate:false},
  136. // {field: 'job', title: __('Job'),operate:false},
  137. // {field: 'skill_id', title: __('Skill_id'),operate:'LIKE',visible:false, searchList: $.getJSON("people/skill")},
  138. // {field: 'rank_id', title: __('Skill_id'),operate:'LIKE',visible:false, searchList: $.getJSON("people/rank")},
  139. // {field: 'skill_date', title: __('Skill_date'),operate:false, addclass:'datetimerange', autocomplete:false},
  140. // {field: 'level_id_text', title: __('Level_id'),operate:false},
  141. // {field: 'level_date', title: __('Level_date'),operate:false, addclass:'datetimerange', autocomplete:false},
  142. // {field: 'origin', title: __('Origin'),operate:false},
  143. // {field: 'education_id_text', title: __('Education_id'),operate:false},
  144. // {field: 'school', title: __('School'),operate:false},
  145. // {field: 'reign', title: __('人员状态'), searchList: {'0':__('在位'),'1':__('休假'), '2':__('出差'), '6':__('外诊'), '4':__('学习'), '3': __('借调'), '5' : __('执行任务'), '7':__('其他')}, formatter: Table.api.formatter.normal},
  146. // {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
  147. // ]
  148. // ]
  149. // });
  150. // // 为表格绑定事件
  151. // Table.api.bindevent(table);
  152. // table.on('post-body.bs.table',function(){
  153. // $(".btn-editone").data("area",["1000px","90%"]);
  154. // })
  155. // },
  156. add: function () {
  157. Controller.api.bindevent();
  158. $("#faupload-readme_file").data("upload-success", function(data, ret){
  159. //这里进行后续操作
  160. $('#c-readme_file_name').val(data.name);
  161. });
  162. },
  163. edit: function () {
  164. Controller.api.bindevent();
  165. $("#faupload-readme_file").data("upload-success", function(data, ret){
  166. //这里进行后续操作
  167. $('#c-readme_file_name').val(data.name);
  168. });
  169. },
  170. api: {
  171. bindevent: function () {
  172. Form.api.bindevent($("form[role=form]"));
  173. }
  174. }
  175. };
  176. return Controller;
  177. });