thebus_apply.js 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395
  1. define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
  2. var Controller = {
  3. index: function () {
  4. // 初始化表格参数配置
  5. $(".btn-add").data("area",["1000px","400px"]);
  6. Table.api.init({
  7. extend: {
  8. index_url: 'thebus_apply/index' + location.search,
  9. add_url: 'thebus_apply/add',
  10. edit_url: 'thebus_apply/edit',
  11. del_url: 'thebus_apply/del',
  12. multi_url: 'thebus_apply/multi',
  13. import_url: 'thebus_apply/import',
  14. table: 'thebus_apply',
  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. columns: [
  24. [
  25. {checkbox: true},
  26. {field: 'order_number', title: __('Id')},
  27. {field: 'people_count', title: __('人数'), operate: false},
  28. {field: 'unit_id_text', title: __('Unit_id')},
  29. {field: 'people_id_text', title: __('People_id')},
  30. {field: 'contact', title: __('Contact'), operate: 'LIKE'},
  31. {field: 'cause', title: __('Cause'), operate: 'LIKE'},
  32. // {field: 'auth_stime', title: __('Auth_stime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  33. // {field: 'auth_etime', title: __('Auth_etime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  34. {field: 'unit_people_id_text', title: __('营级审批人')},
  35. {field: 'unit_people_id_state', title: __('营级审批状态'),formatter:function(index,row){
  36. if(row.unit_people_state == 1){
  37. if(!row.unit_people_remark)return '<span class="text-success">已审批</span>'
  38. return '<span class="text-warning">特殊审核</span> <i class="fa fa-commenting-o" data-toggle="tooltip" data-original-title="'+row.unit_people_remark+'"></i>'
  39. }else if(row.unit_people_state == 2){
  40. return '<span class="text-danger">已驳回</span> <i class="fa fa-commenting-o" data-toggle="tooltip" data-original-title="'+row.unit_people_remark+'"></i>'
  41. }else{
  42. return '未处理'
  43. }
  44. }},
  45. {field: 'unit_people_id_state', title: __('初审状态'),formatter:function(index,row){
  46. if(row.chushen_state == 1){
  47. if(!row.chushen_remark)return '<span class="text-success">已审批</span>'
  48. return '<span class="text-warning">特殊审核</span> <i class="fa fa-commenting-o" data-toggle="tooltip" data-original-title="'+row.chushen_remark+'"></i>'
  49. }else if(row.chushen_state == 2){
  50. return '<span class="text-danger">已驳回</span> <i class="fa fa-commenting-o" data-toggle="tooltip" data-original-title="'+row.chushen_remark+'"></i>'
  51. }else{
  52. return '未处理'
  53. }
  54. }},
  55. {field: 'people1_id_text', title: __('People1_id')},
  56. {field: 'people1_state', title: __('一级审批状态'),formatter:function(index,row){
  57. if(row.people1_state == 1){
  58. if(!row.people1_remark)return '<span class="text-success">已审批</span>'
  59. return '<span class="text-warning">特殊审核</span> <i class="fa fa-commenting-o" data-toggle="tooltip" data-original-title="'+row.people1_remark+'"></i>'
  60. }else if(row.people1_state == 2){
  61. return '<span class="text-danger">已驳回</span> <i class="fa fa-commenting-o" data-toggle="tooltip" data-original-title="'+row.people1_remark+'"></i>'
  62. }else{
  63. return '未处理'
  64. }
  65. }},
  66. {field: 'people2_id_text', title: __('People2_id')},
  67. {field: 'people2_state', title: __('二级审批状态'),formatter:function(index,row){
  68. if(row.people2_state == 1){
  69. if(!row.people2_remark)return '<span class="text-success">已审批</span>'
  70. return '<span class="text-warning">特殊审核</span> <i class="fa fa-commenting-o" data-toggle="tooltip" data-original-title="'+row.people2_remark+'"></i>'
  71. }else if(row.people2_state == 2){
  72. return '<span class="text-danger">已驳回</span> <i class="fa fa-commenting-o" data-toggle="tooltip" data-original-title="'+row.people2_remark+'"></i>'
  73. }else{
  74. return '未处理'
  75. }
  76. }},
  77. {field: 'people3_id_text', title: __('People3_id')},
  78. {field: 'people3_state', title: __('三级审批状态'),formatter:function(index,row){
  79. if(row.people3_state == 1){
  80. if(!row.people3_remark)return '<span class="text-success">已审批</span>'
  81. return '<span class="text-warning">特殊审核</span> <i class="fa fa-commenting-o" data-toggle="tooltip" data-original-title="'+row.people3_remark+'"></i>'
  82. }else if(row.people3_state == 2){
  83. return '<span class="text-danger">已驳回</span> <i class="fa fa-commenting-o" data-toggle="tooltip" data-original-title="'+row.people3_remark+'"></i>'
  84. }else{
  85. return '未处理'
  86. }
  87. }},
  88. // {field: 'admin_id_text', title: __('Admin_id')},
  89. // {field: 'createtime', title: __('Createtime'), formatter: Table.api.formatter.datetime},
  90. {field: 'updatetime', title: __('Updatetime'), formatter: Table.api.formatter.datetime},
  91. {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate,buttons: [
  92. {
  93. name: '审核',
  94. text: '审核',
  95. title: '审核',
  96. classname: 'btn btn-xs btn-info btn-view btn-dialog ',
  97. icon: 'fa fa-search',
  98. url: function(row){
  99. var url = 'thebus_apply/auth?ids='+row.id;
  100. if(row.people1_id_state==0){
  101. url+='&step=1';
  102. }else if(row.people2_id_state==0){
  103. url+='&step=2';
  104. }else if(row.people3_id_state==0){
  105. url+='&step=3';
  106. }
  107. return url;
  108. },
  109. extend: 'data-area=\'["450px","80%"]\'',
  110. refresh: true,
  111. visible:function(row){
  112. if(row.unit_people_state==1 && row.chushen_state == 1){
  113. if(row.people1_state==0 && Config.admin.id == row.people1_id){
  114. return true;
  115. }else if(row.people2_state==0 && Config.admin.id == row.people2_id && row.people1_state==1){
  116. return true;
  117. }else if(row.people3_state==0 && Config.admin.id == row.people3_id && row.people1_state==1 && row.people2_state==1){
  118. return true;
  119. }
  120. }
  121. return false;
  122. }
  123. },
  124. {
  125. name: '审核',
  126. text: '特殊审核',
  127. title: '特殊审核',
  128. classname: 'btn btn-xs btn-warning btn-view btn-click ',
  129. icon: 'fa fa-search',
  130. refresh: true,
  131. visible:function(row){
  132. if(row.unit_people_state==1 && row.chushen_state == 1){
  133. if((row.people1_state==0 || row.people2_state==0 || row.people3_state==0) && (row.people1_state!=2 && row.people2_state!=2 && row.people3_state!=2) && Config.admin.id == row.default_people_id){
  134. return true;
  135. }
  136. }
  137. return false;
  138. },
  139. click:function(e,row){
  140. var id = row.id;
  141. Layer.prompt({
  142. title:'特殊授权情况'
  143. },function(val,index){
  144. if(val){
  145. $.get('thebus_apply/auth_status',{ids:id,state:1,remark:val},function(res){
  146. Layer.closeAll();
  147. $("a.btn-refresh").trigger("click");
  148. Layer.msg(res.msg);
  149. });
  150. }else{
  151. Layer.msg('请输入特殊授权情况');
  152. }
  153. })
  154. }
  155. },
  156. {
  157. name: '审核',
  158. text: '营级审核',
  159. title: '营级审核',
  160. classname: 'btn btn-xs btn-warning btn-view btn-click ',
  161. icon: 'fa fa-search',
  162. refresh: true,
  163. visible:function(row){
  164. if(row.unit_people_state==0 && row.unit_people_id==Config.admin.id){
  165. return true;
  166. }
  167. return false;
  168. },
  169. click:function(e,row){
  170. var id = row.id;
  171. Layer.confirm('请选择审核状态', {
  172. btn: ['通过', '不通过', '关闭'] //可以无限个按钮
  173. ,btn3: function(index, layero){
  174. }
  175. }, function(index, layero){
  176. $.get('thebus_apply/tongyong_auth',{ids:id,unit_people_state:1},function(res){
  177. Layer.closeAll();
  178. $("a.btn-refresh").trigger("click");
  179. Layer.msg(res.msg);
  180. });
  181. }, function(index){
  182. Layer.prompt({
  183. title:'请输入不通过原因'
  184. },function(val,index){
  185. if(val){
  186. $.get('thebus_apply/tongyong_auth',{ids:id,unit_people_state:2,unit_people_remark:val},function(res){
  187. Layer.closeAll();
  188. $("a.btn-refresh").trigger("click");
  189. Layer.msg(res.msg);
  190. });
  191. }else{
  192. Layer.msg('请输入不通过原因');
  193. }
  194. })
  195. });
  196. }
  197. },
  198. {
  199. name: '审核',
  200. text: '初审',
  201. title: '初审',
  202. classname: 'btn btn-xs btn-warning btn-view btn-click ',
  203. icon: 'fa fa-search',
  204. refresh: true,
  205. visible:function(row){
  206. if(row.default_people_id==Config.admin.id && row.chushen_state==0 && row.unit_people_state==1){
  207. return true;
  208. }
  209. return false;
  210. },
  211. click:function(e,row){
  212. var id = row.id;
  213. Layer.confirm('请选择审核状态', {
  214. btn: ['通过', '不通过', '关闭'] //可以无限个按钮
  215. ,btn3: function(index, layero){
  216. }
  217. }, function(index, layero){
  218. $.get('thebus_apply/tongyong_auth',{ids:id,chushen_state:1},function(res){
  219. Layer.closeAll();
  220. $("a.btn-refresh").trigger("click");
  221. Layer.msg(res.msg);
  222. });
  223. }, function(index){
  224. Layer.prompt({
  225. title:'请输入不通过原因'
  226. },function(val,index){
  227. if(val){
  228. $.get('thebus_apply/tongyong_auth',{ids:id,chushen_state:2,chushen_remark:val},function(res){
  229. Layer.closeAll();
  230. $("a.btn-refresh").trigger("click");
  231. Layer.msg(res.msg);
  232. });
  233. }else{
  234. Layer.msg('请输入不通过原因');
  235. }
  236. })
  237. });
  238. }
  239. }
  240. ]}
  241. ]
  242. ]
  243. });
  244. // 为表格绑定事件
  245. Table.api.bindevent(table);
  246. table.on('post-body.bs.table',function(){
  247. $(".btn-editone").data("area",["1000px","400px"]);
  248. })
  249. $('#mu-auth').click(function(){
  250. var list = table.bootstrapTable('getSelections');
  251. if(list.length == 0){
  252. Layer.msg('请选择要审核的数据');
  253. return false;
  254. }
  255. Layer.confirm('是否批量通过初审?',{icon:3},function(index){
  256. var list = table.bootstrapTable('getSelections');
  257. var id = [];
  258. for(var i in list){
  259. id.push(list[i].id);
  260. }
  261. $.get('thebus_apply/mu_auth',{ids:id},function(res){
  262. Layer.msg(res.msg);
  263. if(res.code == 1){
  264. table.bootstrapTable('refresh');
  265. }
  266. });
  267. });
  268. });
  269. },
  270. add: function () {
  271. $(document).on("change", "#c-thebus_themplate_id", function(){
  272. $.get('thebus_themplate/getone',{id:$(this).val()},function(res){
  273. $('#c-people1_id').val(res.data.people1_id);
  274. $('#c-people1_id_text').val(res.data.people1_id_text);
  275. $('#c-people2_id').val(res.data.people2_id);
  276. $('#c-people2_id_text').val(res.data.people2_id_text);
  277. $('#c-people3_id').val(res.data.people3_id);
  278. $('#c-people3_id_text').val(res.data.people3_id_text);
  279. });
  280. });
  281. $("#c-people_id").data("params", function (obj) {
  282. var unit_id = $('#J_unitselect').val();
  283. return {
  284. "custom[unit_id][0]": "in",
  285. "custom[unit_id][1]": unit_id
  286. };
  287. });
  288. $("#c-people1_id,#c-people2_id,#c-people3_id").data("params", function (obj) {
  289. var custom = {};
  290. custom['custom'] = {};
  291. custom['custom']['id'] = [];
  292. custom['custom']['id'][0] = 'not in';
  293. custom['custom']['id'][1] = '1';
  294. return custom;
  295. });
  296. Controller.api.bindevent();
  297. },
  298. edit: function () {
  299. $(document).on("change", "#c-thebus_themplate_id", function(){
  300. $.get('thebus_themplate/getone',{id:$(this).val()},function(res){
  301. $('#c-people1_id').val(res.data.people1_id);
  302. $('#c-people2_id').val(res.data.people2_id);
  303. $('#c-people3_id').val(res.data.people3_id);
  304. $('#c-people1_id').selectPageRefresh();
  305. $('#c-people2_id').selectPageRefresh();
  306. $('#c-people3_id').selectPageRefresh();
  307. });
  308. });
  309. $("#c-people_id").data("params", function (obj) {
  310. var unit_id = $('#J_unitselect').val();
  311. return {
  312. "custom[unit_id][0]": "in",
  313. "custom[unit_id][1]": unit_id
  314. };
  315. });
  316. $("#c-people1_id,#c-people2_id,#c-people3_id").data("params", function (obj) {
  317. var custom = {};
  318. custom['custom'] = {};
  319. custom['custom']['id'] = [];
  320. custom['custom']['id'][0] = 'not in';
  321. custom['custom']['id'][1] = '1';
  322. return custom;
  323. });
  324. Controller.api.bindevent();
  325. },
  326. auth: function () {
  327. Controller.api.bindevent();
  328. $('#J_ok').click(function(){
  329. var id = $(this).data('id');
  330. Layer.confirm('确定要通过吗?',{shade:false},function(index){
  331. $.get('thebus_apply/auth_status',{ids:id,state:1},function(res){
  332. parent.Layer.closeAll();
  333. parent.$("a.btn-refresh").trigger("click");
  334. parent.Layer.msg(res.msg);
  335. });
  336. });
  337. });
  338. $('#J_no').click(function(){
  339. var id = $(this).data('id');
  340. Layer.prompt({
  341. title:'驳回原因'
  342. },function(val,index){
  343. if(val){
  344. $.get('thebus_apply/auth_status',{ids:id,state:1,remark:val},function(res){
  345. parent.Layer.closeAll();
  346. parent.$("a.btn-refresh").trigger("click");
  347. parent.Layer.msg(res.msg);
  348. });
  349. }else{
  350. Layer.msg('请输入原因');
  351. }
  352. })
  353. });
  354. },
  355. outbus: function(){
  356. Controller.api.bindevent();
  357. $("#c-busnumber").data("params", function (obj) {
  358. return {custom: {vehiclemodel: $("#c-model").val(),status:1}};
  359. });
  360. $(document).on("fa.event.appendfieldlist", ".btn-append", function (e, obj) {
  361. Form.events.selectpage(obj);
  362. Form.events.datetimepicker(obj);
  363. });
  364. },
  365. api: {
  366. bindevent: function () {
  367. Form.api.bindevent($("form[role=form]"));
  368. }
  369. }
  370. };
  371. return Controller;
  372. });