You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

167 lines
6.2 KiB

  1. (function () {
  2. var processId = '';
  3. var schemeCode = '';
  4. var fieldMap = {};
  5. var formDataes;
  6. var formAllData;
  7. var formreq;
  8. var $header = null;
  9. var headText = '';
  10. var getFormData = function ($page,flag) {
  11. formDataes = $page.find('#createflow').custmerformGet(flag);
  12. if (formDataes == null) {
  13. return false;
  14. }
  15. formreq = [];
  16. for (var id in formDataes) {
  17. if (!fieldMap[id]) {
  18. learun.layer.warning('未设置流程表单关联字段!', function () { }, '数字化智慧校园', '关闭');
  19. return false;
  20. }
  21. formDataes[id][fieldMap[id]] = processId;
  22. var point = {
  23. schemeInfoId: id,
  24. processIdName: fieldMap[id],
  25. formData: JSON.stringify(formDataes[id])
  26. }
  27. formreq.push(point);
  28. }
  29. return true;
  30. };
  31. var currentNode;
  32. var schemeObj;
  33. var page = {
  34. isScroll: false,
  35. init: function ($page, param) {
  36. schemeCode = param.schemeCode;
  37. currentNode = null;
  38. var _html = '<div class="lr-form-header-submit" style="display:block;" >提交</div>';
  39. $header = $page.parents('.f-page').find('.f-page-header');
  40. $header.append(_html);
  41. headText = $header.find('.f-page-title').text();
  42. processId = learun.guid('-');;
  43. bootstraper($page);
  44. // 发起流程
  45. $header.find('.lr-form-header-submit').on('tap', function () {
  46. if (currentNode == null) {
  47. learun.layer.toast('还未加载完流程模板');
  48. return;
  49. }
  50. learun.actionsheet({
  51. id: 'createflow1',
  52. data: [
  53. {
  54. text: '创建流程',
  55. group: '1',
  56. event: function () {
  57. // 获取表单数据
  58. if (!getFormData($page)) {
  59. return false;
  60. }
  61. learun.nav.go({ path: 'nworkflow/createflow/form', title: headText, type: 'right', param: { node: currentNode, nodelist: schemeObj.nodes, schemeCode: schemeCode, processId: processId } });
  62. }
  63. },
  64. {
  65. text: '保存草稿',
  66. mark: true,
  67. group: '2',
  68. event: function () {
  69. // 获取表单数据
  70. if (!getFormData($page, true)) {
  71. return false;
  72. }
  73. // 创建草稿
  74. page.saveDraft();
  75. }
  76. }
  77. ],
  78. cancel: function () {
  79. }
  80. });
  81. });
  82. },
  83. create: function (info, auditers) {// 提交创建流程
  84. var flowreq = {
  85. code: schemeCode,
  86. processId: processId,
  87. title: info.title,
  88. level: info.level,
  89. auditors: JSON.stringify(auditers),
  90. formreq: JSON.stringify(formreq)
  91. };
  92. learun.layer.loading(true, "创建流程,请等待!");
  93. learun.httppost(config.webapi + "learun/adms/newwf/create", flowreq, function (data) {
  94. learun.layer.loading(false);
  95. learun.nav.closeCurrent();
  96. });
  97. },
  98. saveDraft: function () {
  99. var flowreq = {
  100. code: schemeCode,
  101. processId: processId,
  102. formreq: JSON.stringify(formreq)
  103. };
  104. learun.layer.loading(true, "保存草稿!");
  105. learun.httppost(config.webapi + "learun/adms/newwf/draft", flowreq, function (data) {
  106. learun.layer.loading(false);
  107. learun.nav.closeCurrent();
  108. });
  109. }
  110. };
  111. // 流程发起初始化
  112. function bootstraper($page) {
  113. learun.layer.loading(true, "获取流程模板信息");
  114. learun.httpget(config.webapi + "learun/adms/newwf/scheme", schemeCode, function (data) {
  115. learun.layer.loading(false);
  116. if (data) {
  117. schemeObj = JSON.parse(data.F_Content);
  118. // 获取开始节点
  119. $.each(schemeObj.nodes, function (_index, _item) {
  120. if (_item.type == 'startround') {
  121. currentNode = _item;
  122. return false;
  123. }
  124. });
  125. var wfForms = currentNode.wfForms;// 表单数据
  126. var schemeIds = [];
  127. var authorizeFields = [];
  128. // 获取下关联字段
  129. $.each(wfForms, function (_index, _item) {
  130. if (_item.formId) {
  131. fieldMap[_item.formId] = _item.field;
  132. schemeIds.push(_item.formId);
  133. $.each(_item.authorize, function (_jindex, _jitem) {
  134. _jitem.fieldId = _jindex;
  135. authorizeFields.push(_jitem);
  136. });
  137. }
  138. });
  139. learun.custmerform.loadScheme(schemeIds, function (scheme) {
  140. $page.find('#createflow').custmerform(scheme);
  141. // 设置表单的可查看权限
  142. $.each(authorizeFields, function (_index, _item) {
  143. if (_item.isLook === 0) {
  144. $('#createflow').find('#' + _item.fieldId).parents('.lr-form-row').remove();
  145. }
  146. else if (_item.isEdit === 0) {
  147. $('#createflow').find('#' + _item.fieldId).parents('.lr-form-row').attr('readonly', 'readonly');
  148. }
  149. });
  150. });
  151. }
  152. });
  153. }
  154. return page;
  155. })();