oaCheck.js 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695
  1. layui.define(['tool','oaPicker','uploadPlus'], function (exports) {
  2. const layer = layui.layer;
  3. const form = layui.form;
  4. const tool = layui.tool;
  5. const uploadPlus = layui.uploadPlus;
  6. const opts={
  7. "checkBox":"checkBox",//审核容器id
  8. "checking_btn":"",//待审核状态下自定义添加的按钮
  9. "checked_btn":"",//审核通过自定义添加的按钮
  10. "check_name": "",//审核类型标识
  11. "check_btn":1,//是否显示提交审核按钮
  12. "check_ok":function(){
  13. //审核通过的执行函数
  14. },
  15. "check_no":function(){
  16. //审核拒绝的执行函数
  17. },
  18. "check_back":function(){
  19. //撤回的执行函数
  20. },
  21. "check_reversed":function(){
  22. //反确认的执行函数
  23. }
  24. };
  25. const obj = {
  26. loading:false,
  27. checkStatus: function (status) {
  28. statusArray = ['待提交审批','审批中','审批通过','审批不通过','已撤回'];
  29. return '<span class="check-status-color-'+status+'">'+statusArray[status]+'</span>';
  30. },
  31. statusTemplate: function (status) {
  32. let me = this;
  33. let tem =`
  34. <tr>
  35. <td class="layui-td-gray-2">审批状态</td>
  36. <td>${me.checkStatus(status)}</td>
  37. </tr>
  38. `;
  39. return tem;
  40. },
  41. uidsTemplate: function () {
  42. let tem =`
  43. <td class="layui-td-gray-2">审批人<font>*</font></td>
  44. <td>
  45. <input type="text" name="check_uames" value="" autocomplete="off" placeholder="请选择审批人" lay-verify="required" lay-reqText="请选择审批人" class="layui-input picker-admin" readonly><input type="text" name="check_uids" value="" readonly style="display:none;">
  46. </td>
  47. `;
  48. return tem;
  49. },
  50. flowTemplate: function (data) {
  51. let flowtype='<option value="" title="">--请选择--</option>';
  52. if(data && data.length>0){
  53. for(let i=0;i<data.length;i++){
  54. flowtype+='<option value="'+data[i].id+'" title="'+data[i].check_type+'">'+data[i].title+'</option>';
  55. }
  56. }
  57. let tem =`
  58. <tr>
  59. <td class="layui-td-gray-2">审批流程<font>*</font></td>
  60. <td>
  61. <select name="flow_id" lay-verify="required" lay-filter="flowtype" lay-reqText="请选择审批流程">
  62. ${flowtype}
  63. </select>
  64. </td>
  65. </tr>
  66. `;
  67. return tem;
  68. },
  69. copyTemplate: function (detail) {
  70. let me = this;
  71. let tem =`
  72. <tr style="${detail.is_copy==0?'display:none':''}">
  73. <td class="layui-td-gray-2">抄送人</td>
  74. <td>
  75. <input type="text" name="check_copy_unames" value="" readonly autocomplete="off" placeholder="请选择审批通过后的抄送人" class="layui-input picker-admin" data-type="2"><input type="text" name="check_copy_uids" value="" readonly style="display:none;">
  76. </td>
  77. </tr>
  78. `;
  79. return tem;
  80. },
  81. btnTemplate: function () {
  82. let me = this;
  83. let tem =`
  84. <div class="pt-3">
  85. <button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="checkform">提交审批</button>
  86. <button type="reset" class="layui-btn layui-btn-primary">重置</button>
  87. ${me.sets.checking_btn}
  88. </div>
  89. `;
  90. if(me.sets.check_btn == 1){
  91. return tem;
  92. }else{
  93. return '';
  94. }
  95. },
  96. recordTemplate: function (record) {
  97. let me = this;
  98. let tem ='';
  99. if(record.length>0){
  100. tem+='<tr><td class="layui-td-gray-2">审批记录</td><td colspan="5"><ul class="layui-timeline flow-record pt-2">';
  101. for(let l=0;l<record.length;l++){
  102. let check_content='';
  103. if(record[l].content!=''){
  104. check_content='审批意见:<span class="green">'+record[l].content+'</span>。';
  105. }
  106. tem+='<li class="layui-timeline-item delete-'+record[l].delete_time+'">\
  107. <i class="layui-icon layui-timeline-axis">&#xe63f;</i>\
  108. <p style="padding-left:24px">'+record[l].check_time_str+'<span class="black ml-2">'+record[l].name+'</span><span class="check-status-color-'+(record[l].check_status+1)+'">『'+record[l].status_str+'』</span>了此申请。'+check_content+'</p>';
  109. let file_array= record[l].file_array;
  110. if(file_array.length>0){
  111. tem+='<p style="padding:4px 24px 0;">审批附件:</p><div class="layui-row" style="padding:2px 16px;">';
  112. for(let f=0;f<file_array.length;f++){
  113. tem+='<div class="layui-col-md4">'+tool.fileCard(file_array[f],1)+'</div>';
  114. }
  115. tem+='</div>';
  116. }
  117. tem+='</li>';
  118. }
  119. tem+='</ul></td></tr>';
  120. }
  121. return tem;
  122. },
  123. createTemplate: function (flow) {
  124. let me = this;
  125. let checkHtml = `
  126. <form class="layui-form">
  127. <h3 class="pb-2">审批操作</h3>
  128. <table class="layui-table layui-table-form">
  129. ${me.flowTemplate(flow)}
  130. <tr id="checkTR">${me.uidsTemplate()}</tr>
  131. ${me.copyTemplate(flow[0])}
  132. </table>
  133. </form>
  134. `;
  135. return checkHtml;
  136. },
  137. //审批待提交模版
  138. initTemplate: function (detail) {
  139. let me = this;
  140. let checkHtml = `
  141. <form class="layui-form">
  142. <h3 class="pb-2">审批操作</h3>
  143. <table class="layui-table layui-table-form">
  144. ${me.statusTemplate(detail.check_status)}
  145. ${me.recordTemplate(detail.check_record)}
  146. ${me.flowTemplate(detail.flow)}
  147. <tr id="checkTR">${me.uidsTemplate()}</tr>
  148. ${me.copyTemplate(detail)}
  149. </table>
  150. ${me.btnTemplate()}
  151. </form>
  152. `;
  153. let viewHtml = `
  154. <form class="layui-form">
  155. <h3 class="pb-2">审批操作</h3>
  156. <table class="layui-table layui-table-form">
  157. ${me.statusTemplate(detail.check_status)}
  158. ${me.recordTemplate(detail.check_record)}
  159. </table>
  160. </form>
  161. `;
  162. if(detail.is_creater==1){
  163. return checkHtml;
  164. }
  165. else{
  166. return viewHtml;
  167. }
  168. },
  169. //审批中模版
  170. checkTemplate: function (detail) {
  171. let me = this,flowHtml='',list = detail.nodes;
  172. for(var f=0;f<list.length;f++){
  173. //审批流程
  174. let checkUser = '',
  175. iconRight ='<span class="layui-icon layui-icon-right"></span>',
  176. iconStatus ='<i class="layui-icon layui-icon-time"></i>',
  177. strStatus ='<div class="check-item-status">待审批</div>',
  178. check_types= '',
  179. sortClass ='';
  180. if(f == list.length-1){
  181. iconRight ='';
  182. }
  183. if(detail.check_step_sort == list[f].sort){
  184. sortClass ='flow-this';
  185. iconStatus ='<i class="layui-icon layui-icon-time"></i>';
  186. strStatus ='<div class="check-item-status">当前审批</div>';
  187. if(list[f].check_uids_info.length>1){
  188. check_types= ' <span class="layui-badge layui-bg-blue">会签</span>';
  189. if(list[f].check_types==2){
  190. check_types= ' <span class="layui-badge layui-bg-orange">或签</span>';
  191. }
  192. }
  193. }
  194. if(list[f].check_role == 0 || list[f].check_role == 5){
  195. checkUser=list[f].check_uids_info[0].name;
  196. }
  197. if(list[f].check_role == 1 || list[f].check_role == 2 || list[f].check_role == 3 || list[f].check_role == 4){
  198. checkUser=list[f].flow_name;
  199. }
  200. if(list[f].check_list.length>0){
  201. let one=0,two=0,three=0;
  202. for(var m=0;m<list[f].check_uids_info.length;m++){
  203. if(list[f].check_uids_info[m].check_status == 2){
  204. three++
  205. }
  206. if(list[f].check_uids_info[m].check_status == 1){
  207. two++
  208. }
  209. if(list[f].check_uids_info[m].check_status == 0){
  210. one++
  211. }
  212. }
  213. //会签
  214. if(list[f].check_types==1){
  215. if(three > 0){
  216. iconStatus ='<i class="layui-icon layui-icon-close" data-no=""></i>';
  217. strStatus ='<div class="check-item-status">拒绝</div>';
  218. }
  219. else{
  220. if(one > 0){
  221. iconStatus ='<i class="layui-icon layui-icon-time"></i>';
  222. strStatus ='<div class="check-item-status">待审批</div>';
  223. }
  224. else{
  225. iconStatus ='<i class="layui-icon layui-icon-ok-circle" data-ok=""></i>';
  226. strStatus ='<div class="check-item-status">通过</div>';
  227. }
  228. }
  229. }
  230. //或签
  231. if(list[f].check_types==2){
  232. if(two > 0){
  233. iconStatus ='<i class="layui-icon layui-icon-ok-circle" data-ok=""></i>';
  234. strStatus ='<div class="check-item-status">通过</div>';
  235. }
  236. else{
  237. iconStatus ='<i class="layui-icon layui-icon-close" data-no=""></i>';
  238. strStatus ='<div class="check-item-status">拒绝</div>';
  239. }
  240. }
  241. }
  242. flowHtml+= '<div class="flow-flexbox check-item flow-flex-row '+sortClass+'" id="flow'+f+'">'+iconStatus+'<div class="check-item-name">'+check_types+checkUser+'</div>'+strStatus+iconRight+'</div>';
  243. }
  244. let checkCopy=`<tr style="${detail.is_copy==0?'display:none':''}"><td class="layui-td-gray-2">抄送人</td><td colspan="3">${detail.copy_unames}</td></tr>`;
  245. let checkNode = `<tr>
  246. <td class="layui-td-gray-2">审批节点 <font>*</font></td>
  247. <td colspan="3">
  248. <input type="radio" name="check_node" lay-filter="check_node" value="1" title="审批结束">
  249. <input type="radio" name="check_node" lay-filter="check_node" value="2" title="下一审批人">
  250. <div class="layui-inline">
  251. <input type="text" name="check_uname" value="" readonly autocomplete="off" placeholder="请选择下一审批人" lay-verify="required" lay-reqText="请选择下一审批人" class="layui-input picker-admin"><input type="hidden" name="check_uids" value="">
  252. </div>
  253. </td>
  254. </tr>
  255. `;
  256. let checkContent = `<tr style="${detail.is_file==0?'display:none':''}">
  257. <td class="layui-td-gray-2">审批附件 <button type="button" class="layui-btn layui-btn-xs" id="uploadBtnCheck"><i class="layui-icon"></i></button></td>
  258. <td colspan="3">
  259. <div class="layui-row" id="uploadBoxCheck"><input data-type="file" type="hidden" name="check_files" value=""></div>
  260. </td>
  261. </tr>
  262. <tr>
  263. <td class="layui-td-gray-2">审批意见</td>
  264. <td colspan="3">
  265. <textarea name="content" placeholder="请输入审批意见" class="layui-textarea"></textarea>
  266. </td>
  267. </tr>`;
  268. let btnCheck='<span class="layui-btn layui-btn-normal btn-check" data-status="1"><i class="layui-icon layui-icon-ok"></i> 通过</span><span class="layui-btn layui-btn-danger btn-check" data-status="2"><i class="layui-icon layui-icon-close"></i> 拒绝</span>';
  269. if(detail.step.check_role==5){
  270. btnCheck='<span class="layui-btn layui-btn-normal btn-check" data-status="1"><i class="layui-icon layui-icon-ok"></i> 通过</span><span class="layui-btn layui-btn-danger btn-check" data-status="2"><i class="layui-icon layui-icon-close"></i> 退回</span>';
  271. }
  272. let btnBack='<span class="layui-btn layui-btn-primary btn-check" data-status="3"><i class="layui-icon layui-icon-reduce-circle"></i> 撤回</span>';
  273. let btnCheckBack='<span class="layui-btn layui-btn-danger btn-check" data-event="check" data-status="4">反确认审核</span>';
  274. let btnExport='<a href="/api/export/pdf?types='+me.sets.check_name+'&id='+detail.id+'" class="layui-btn" target="_blank"><i class="layui-icon layui-icon-print"></i>审批单导出打印</a>';
  275. let checkHtml = `
  276. <form class="layui-form">
  277. <h3 class="pb-2">审批操作</h3>
  278. <table class="layui-table layui-table-form">
  279. <tr>
  280. <td class="layui-td-gray-2">审批状态</td>
  281. <td>${me.checkStatus(detail.check_status)}</td>
  282. <td class="layui-td-gray-2">当前审批人</td>
  283. <td>${detail.check_unames}</td>
  284. </tr>
  285. ${checkCopy}
  286. <tr>
  287. <td class="layui-td-gray-2">审批流</td>
  288. <td colspan="3">
  289. <div class="flow-flexbox check-items flow-flex-row" id="flowList">
  290. <div class="flow-flexbox check-item flow-flex-row">
  291. <i class="layui-icon layui-icon-add-circle" data-ok=""></i>
  292. <div class="check-item-name">${detail.admin_name}</div>
  293. <div class="check-item-status">创建</div>
  294. <span class="layui-icon layui-icon-right"></span>
  295. </div>
  296. ${flowHtml}
  297. </div>
  298. </td>
  299. </tr>
  300. ${me.recordTemplate(detail.check_record)}
  301. ${detail.is_checker==1 && detail.step.check_role==0?checkNode:''}
  302. ${detail.is_checker==1?checkContent:''}
  303. </table>
  304. <div class="pt-3">
  305. <input type="hidden" name="check_role" value="${detail.step.check_role}">
  306. ${detail.is_checker==1?btnCheck:''}
  307. ${detail.is_creater==1 && detail.is_back==1 && (detail.check_status==1 || detail.check_status==3)?btnBack:''}
  308. ${detail.is_reversed == 1 && detail.is_creater==1 && typeof me.sets.check_reversed ==='function' && detail.check_status==2?btnCheckBack:''}
  309. ${detail.is_export == 1 && detail.check_status==2?btnExport:''}
  310. ${detail.check_status==2?me.sets.checked_btn:''}
  311. </div>
  312. </form>
  313. `;
  314. return checkHtml;
  315. },
  316. //审批撤回模版
  317. backTemplate: function (detail) {
  318. let me = this;
  319. let btnHtml ='';
  320. if(me.sets.check_btn == 1){
  321. btnHtml ='<div class="pt-3"><button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="checkform">提交审批</button><button type="reset" class="layui-btn layui-btn-primary">重置</button></div>';
  322. }
  323. let checkHtml = `
  324. <form class="layui-form">
  325. <h3 class="pb-2">审批操作</h3>
  326. <table class="layui-table layui-table-form">
  327. ${me.statusTemplate(detail.check_status)}
  328. ${me.recordTemplate(detail.check_record)}
  329. ${me.flowTemplate(detail.flow)}
  330. <tr id="checkTR">${me.uidsTemplate()}</tr>
  331. ${me.copyTemplate(detail)}
  332. </table>
  333. ${me.btnTemplate()}
  334. </form>
  335. `;
  336. let viewHtml = `
  337. <form class="layui-form">
  338. <h3 class="pb-2">审批操作</h3>
  339. <table class="layui-table layui-table-form">
  340. ${me.statusTemplate(detail.check_status)}
  341. ${me.recordTemplate(detail.check_record)}
  342. </table>
  343. </form>
  344. `;
  345. if(detail.is_creater==1 && detail.is_back==1){
  346. return checkHtml;
  347. }
  348. else{
  349. return viewHtml;
  350. }
  351. },
  352. submit:function(data,callback){
  353. tool.post("/api/check/submit_check", data, callback);
  354. },
  355. init: function (options) {
  356. this.sets = $.extend({}, opts, options);
  357. let me = this;
  358. let checkBox = $('#'+me.sets.checkBox);
  359. let action_id = checkBox.data('id');
  360. let check_status = checkBox.data('status');
  361. let check_flow_id = checkBox.data('checkflowid');
  362. if(action_id === undefined || check_status === undefined || check_flow_id === undefined){
  363. return false;
  364. }
  365. //获取审批信息
  366. $.ajax({
  367. url: "/api/check/get_flow_nodes",
  368. type:'get',
  369. data:{check_name:me.sets.check_name,action_id:action_id,flow_id:check_flow_id},
  370. success: function (e) {
  371. if (e.code == 0) {
  372. if(check_status==0){
  373. if(action_id==0){
  374. if(e.data.length>0){
  375. checkBox.append(me.createTemplate(e.data));
  376. }
  377. else{
  378. let none = '<h3 class="pb-2">审批操作</h3>\
  379. <table class="layui-table layui-table-form">\
  380. <tr>\
  381. <td class="layui-td-gray-2">审批流程<font>*</font></td>\
  382. <td><input type="text" name="flow_id" value="" autocomplete="off" placeholder="未设置审批流程,请联系管理员设置" lay-verify="required" lay-reqtext="未设置审批流程,请联系管理员设置" class="layui-input" readonly></td>\
  383. </tr>\
  384. </table>';
  385. checkBox.append(none);
  386. }
  387. }
  388. else{
  389. checkBox.append(me.initTemplate(e.data));
  390. }
  391. }
  392. else if(check_status==4){
  393. checkBox.append(me.backTemplate(e.data));
  394. }
  395. else{
  396. checkBox.append(me.checkTemplate(e.data));
  397. var fileUp = new uploadPlus({
  398. "target":'uploadBtnCheck',
  399. "targetBox":'uploadBoxCheck',
  400. });
  401. }
  402. form.render();
  403. }
  404. }
  405. })
  406. //选择审批流
  407. form.on('select(flowtype)', function(data){
  408. var check_type = data.elem[data.elem.selectedIndex].title;
  409. if(data.value==''){
  410. $('#checkTR').html(me.uidsTemplate());
  411. checkBox.find('[name="check_copy_unames"]').val('');
  412. checkBox.find('[name="check_copy_uids"]').val('');
  413. form.render();
  414. return false;
  415. }
  416. if(check_type == 1){
  417. $('#checkTR').html(me.uidsTemplate());
  418. form.render();
  419. }
  420. $.ajax({
  421. url: "/api/check/get_flow_users",
  422. type:'get',
  423. data:{id:data.value},
  424. success: function (e) {
  425. if (e.code == 0) {
  426. var flow_li='',flow_idx=0;
  427. var flow_data = e.data.flow_data;
  428. if(e.data.copy_uids && e.data.copy_uids !=''){
  429. checkBox.find('[name="check_copy_unames"]').val(e.data.copy_unames);
  430. checkBox.find('[name="check_copy_uids"]').val(e.data.copy_uids.split(','));
  431. }
  432. if(check_type == 2 || check_type == 3){
  433. for(var a=0;a<flow_data.length;a++){
  434. var check_types = '',check_role = '',user_li='';
  435. if(flow_data[a].check_types==1){
  436. check_types= ' <span class="layui-badge layui-bg-blue">会签</span>';
  437. }
  438. if(flow_data[a].check_types==2){
  439. check_types= ' <span class="layui-badge layui-bg-orange">或签</span>';
  440. }
  441. if(flow_data[a].check_role==1){
  442. check_role = '当前部门负责人';
  443. }
  444. if(flow_data[a].check_role==2){
  445. check_role = '上级部门负责人';
  446. }
  447. if(flow_data[a].check_role==3){
  448. check_role = '岗位职称:'+flow_data[a].check_position;
  449. }
  450. if(flow_data[a].check_role==4){
  451. check_role = '指定人员';
  452. }
  453. if(flow_data[a].check_role==5){
  454. check_role = flow_data[a].flow_name;
  455. check_types= ' <span class="layui-badge layui-bg-green">可回退</span>';
  456. }
  457. let check_uids_info=flow_data[a].check_uids_info;
  458. if(check_uids_info.length>0){
  459. flow_idx++;
  460. for(var b=0;b<check_uids_info.length;b++){
  461. user_li+= '<li style="padding:3px 0;line-height:22px"><img src="'+check_uids_info[b].thumb+'" style="width:22px; height:22px; border-radius:50%; vertical-align: bottom; margin-right:8px;" />'+check_uids_info[b].name+'</li>';
  462. }
  463. flow_li+='<li class="layui-timeline-item" style="padding-bottom:5px;">\
  464. <i class="layui-icon layui-timeline-axis">&#xe63f;</i>\
  465. <div class="layui-timeline-content">\
  466. <p class="layui-timeline-title" style="margin-bottom:3px">第'+flow_idx+'级审批『'+check_role+'』'+check_types+'</p>\
  467. <ul>'+user_li+'</ul>\
  468. </div>\
  469. </li>';
  470. }
  471. }
  472. if(flow_li==''){
  473. flow_li='<span style="color:#999;">审批流程错误,请联系管理员设置</span>';
  474. }
  475. formHtml = '<td class="layui-td-gray-2">审批流</td>\
  476. <td>\
  477. <ul id="flowList" class="layui-timeline">'+flow_li+'</ul>\
  478. </td>';
  479. $('#checkTR').html(formHtml);
  480. }
  481. }
  482. }
  483. })
  484. });
  485. //提交审批
  486. form.on('submit(checkform)', function(data){
  487. data.field.action_id = action_id;
  488. data.field.check_name = me.sets.check_name;
  489. let callback = function (e) {
  490. layer.msg(e.msg);
  491. if (e.code == 0) {
  492. tool.sideClose(1000);
  493. }
  494. }
  495. if(typeof me.sets.post_form ==='string' && typeof me.sets.post_url ==='string'){
  496. let postData = form.val(me.sets.post_form);
  497. tool.post(me.sets.post_url, postData, function(res){
  498. if (res.code == 0) {
  499. tool.post("/api/check/submit_check", data.field, callback);
  500. }
  501. else{
  502. layer.msg(res.msg);
  503. }
  504. });
  505. }
  506. else{
  507. tool.post("/api/check/submit_check", data.field, callback);
  508. }
  509. return false;
  510. });
  511. //审批操作按钮
  512. checkBox.on('click','.btn-check', function(data){
  513. let content=checkBox.find('[name="content"]').val();
  514. let check_status=$(this).data('status');
  515. let check_role = checkBox.find('input[name="check_role"]').val();
  516. let check_node=0,check_uids='',check_files='';
  517. if(check_role == 0 && check_status==1){
  518. check_node = checkBox.find('input[name="check_node"]:checked').val();
  519. check_uids = checkBox.find('input[name="check_uids"]').val();
  520. if(!check_node){
  521. layer.msg('请选择下一审批节点');
  522. return false;
  523. }
  524. if(check_node == 2 && check_uids==''){
  525. layer.msg('请选择下一审批人');
  526. return false;
  527. }
  528. }
  529. if(check_status ==1 || check_status==2){
  530. let check_files = checkBox.find('input[name="check_files"]').val();
  531. let confirmTips='确定通过该审批?';
  532. if(check_status==2){
  533. confirmTips='确定拒绝该审批?';
  534. if(content==''){
  535. layer.msg('请输入审批意见');
  536. return false;
  537. }
  538. }
  539. tool.ask(confirmTips, function(index){
  540. if(typeof me.sets.post_form ==='string' && typeof me.sets.post_url ==='string'){
  541. let postData = form.val(me.sets.post_form);
  542. tool.post(me.sets.post_url, postData, function(res){
  543. if (res.code == 0) {
  544. $.ajax({
  545. url: "/api/check/flow_check",
  546. type:'post',
  547. data:{
  548. action_id:action_id,
  549. check_name:me.sets.check_name,
  550. check_flow_id:check_flow_id,
  551. check_node:check_node,
  552. check_uids:check_uids,
  553. check:check_status,
  554. check_files:check_files,
  555. content:content
  556. },
  557. success: function (e) {
  558. layer.msg(e.msg);
  559. if (e.code == 0) {
  560. if(e.data.check_status==2 && typeof me.sets.check_ok ==='function'){
  561. me.sets.check_ok(e);
  562. }
  563. if(e.data.check_status==3 && typeof me.sets.check_no ==='function'){
  564. me.sets.check_no(e);
  565. }
  566. tool.sideClose(1000);
  567. }
  568. }
  569. })
  570. }
  571. else{
  572. layer.msg(res.msg);
  573. }
  574. });
  575. }
  576. else{
  577. $.ajax({
  578. url: "/api/check/flow_check",
  579. type:'post',
  580. data:{
  581. action_id:action_id,
  582. check_name:me.sets.check_name,
  583. check_flow_id:check_flow_id,
  584. check_node:check_node,
  585. check_uids:check_uids,
  586. check:check_status,
  587. check_files:check_files,
  588. content:content
  589. },
  590. success: function (e) {
  591. layer.msg(e.msg);
  592. if (e.code == 0) {
  593. if(e.data.check_status==2 && typeof me.sets.check_ok ==='function'){
  594. me.sets.check_ok(e);
  595. }
  596. if(e.data.check_status==3 && typeof me.sets.check_no ==='function'){
  597. me.sets.check_no(e);
  598. }
  599. tool.sideClose(1000);
  600. }
  601. }
  602. })
  603. }
  604. layer.close(index);
  605. });
  606. }
  607. else if(check_status ==3){
  608. $(parent.$('.express-close')).addClass('parent-colse');
  609. layer.prompt({
  610. formType: 2,
  611. title: '请输入撤回理由',
  612. area: ['480px', '120px'] //自定义文本域宽高
  613. }, function(value, index, elem){
  614. if(value==''){
  615. layer.msg('请输入撤回理由');
  616. return false;
  617. }
  618. $.ajax({
  619. url: "/api/check/flow_check",
  620. type:'post',
  621. data:{
  622. action_id:action_id,
  623. check_name:me.sets.check_name,
  624. check_flow_id:check_flow_id,
  625. check:check_status,
  626. content:value
  627. },
  628. success: function (e) {
  629. layer.msg(e.msg);
  630. if (e.code == 0) {
  631. if(e.data.check_status==4 && typeof me.sets.check_back ==='function'){
  632. me.sets.check_back(e);
  633. }
  634. tool.sideClose(1000);
  635. }
  636. }
  637. })
  638. $(parent.$('.express-close')).removeClass('parent-colse');
  639. layer.close(index);
  640. });
  641. }
  642. else if(check_status ==4){
  643. $(parent.$('.express-close')).addClass('parent-colse');
  644. layer.prompt({
  645. formType: 2,
  646. title: '请输入反确认理由',
  647. area: ['480px', '120px'] //自定义文本域宽高
  648. }, function(value, index, elem){
  649. if(value==''){
  650. layer.msg('请输入反确认理由');
  651. return false;
  652. }
  653. $.ajax({
  654. url: "/api/check/flow_check",
  655. type:'post',
  656. data:{
  657. action_id:action_id,
  658. check_name:me.sets.check_name,
  659. check_flow_id:check_flow_id,
  660. check:check_status,
  661. content:value
  662. },
  663. success: function (e) {
  664. layer.msg(e.msg);
  665. if (e.code == 0) {
  666. if(e.data.check_status==0 && typeof me.sets.check_reversed ==='function'){
  667. me.sets.check_reversed(e);
  668. }
  669. tool.sideClose(1000);
  670. }
  671. }
  672. })
  673. $(parent.$('.express-close')).removeClass('parent-colse');
  674. layer.close(index);
  675. });
  676. }
  677. return false;
  678. });
  679. }
  680. };
  681. exports('oaCheck', obj);
  682. });