flowInsDataCommon.js 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. /**
  2. *
  3. * @param modelId
  4. * 流程模版id
  5. * @param flowInsId
  6. * 数据流程实例id
  7. * @param modelName
  8. * 流程模版名称
  9. * @param userName
  10. * 当前用户
  11. */
  12. function startFlow(modelId, flowInsId, modelName, userName) {
  13. // var defaultName = '流程:'+ modelName + "(" + getDate() + "
  14. // ${session.name})";
  15. var flag = false;
  16. $.ajax({
  17. url : "bpmDataCenterAction.do?task=preToStart&flowInsId=" + flowInsId
  18. + "&time=" + new Date().getTime(),
  19. async : false,
  20. type : "post",
  21. dataType : 'json',
  22. success : function(data) {
  23. if (data) {
  24. var state = data.state; //数据状态(0:未报销/付款,1:已报销/付款,2:报销/付款中)
  25. var remain_amount =data.remain_amount; //未付款
  26. var dateType = data.dateType; //数据类型(1加班;2:申购;3:出差,4:付款,5:报销)
  27. if (state == "" || state == "0") {
  28. flag = true;
  29. } else if (state == "1") {
  30. if(dateType == "2" || dateType == "1"){ //如果是申购流程,判断是否已经全额付款
  31. if(remain_amount <= 0){
  32. flag = false;
  33. alert("该记录已完成全部报销,不能重复发起");
  34. }else{
  35. flag = true;
  36. }
  37. }else{
  38. flag = false;
  39. alert("该记录已发起过流程,不能重复发起");
  40. }
  41. return;
  42. }
  43. } else {
  44. alert("发起流程失败!");
  45. return;
  46. }
  47. },
  48. error : function() {
  49. alert("数据处理失败,请检查网络重新登录或联系管理员!");
  50. return;
  51. }
  52. });
  53. if (!flag) {
  54. return;
  55. }
  56. var defaultName = userName + getCurentDate() + modelName;
  57. $("input[type='text']:first").focus();
  58. $.ligerDialog.prompt('流程标题', defaultName, function(yes, value) {
  59. if (yes) {
  60. if ($.trim(value) == '') {
  61. addError("流程标题不能为空!");
  62. return;
  63. }
  64. if ($.trim(value).length > 100) {
  65. addError("流程标题不能超过100个字!");
  66. return;
  67. }
  68. value = value.replace("#", "%23");
  69. var dialogId = modelId + new Date().getTime();
  70. openODialog(
  71. '${pageContext.request.contextPath }/FlowAction.do?task=toStart&modelId='
  72. + modelId + '&tabid=' + getCurrentTabId()
  73. + '&modelName=' + value + '&dialogId=' + dialogId
  74. + '&flowInsId=' + flowInsId, '流程发起', dialogId);
  75. }
  76. });
  77. }
  78. function getCurentDate() {
  79. var now = new Date();
  80. var year = now.getFullYear(); // 年
  81. var month = now.getMonth() + 1; // 月
  82. var day = now.getDate(); // 日
  83. // var hh = now.getHours(); //时
  84. // var mm = now.getMinutes(); //分
  85. var clock = year + "-";
  86. if (month < 10)
  87. clock += "0";
  88. clock += month + "-";
  89. if (day < 10)
  90. clock += "0";
  91. clock += day;
  92. // if(hh < 10)
  93. // clock += "0";
  94. // clock += hh + ":";
  95. // if (mm < 10) clock += '0';
  96. // clock += mm;
  97. return (clock);
  98. }