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.
 
 
 
 
 
 

192 lines
7.7 KiB

  1. (function () {
  2. var processId = '';
  3. var taskId = '';
  4. var $header = null;
  5. var headText = '';
  6. var fieldMap = {};
  7. var formMap = {};
  8. var formDataes;
  9. var formreq;
  10. // 流程信息
  11. var info;
  12. var schemeObj;
  13. var currentNode;
  14. var nodeMap = {};
  15. var page = {
  16. init: function ($page, param) {
  17. $page.find('.lr-chlidlook-page').toptab(['表单信息', '父流程信息']).each(function (index) {
  18. var $this = $(this);
  19. switch (index) {
  20. case 0:
  21. $this.html('<div class="container" id="chlidlookcontainer"></div>');
  22. break;
  23. case 1:
  24. $this.html('<div class="container" id="chlidlookcontainer2"></div>');
  25. break;
  26. }
  27. $this = null;
  28. });
  29. processId = param.processId;
  30. taskId = param.taskId;
  31. taskinfo(param);
  32. },
  33. destroy: function (pageinfo) {
  34. $header = null;
  35. }
  36. };
  37. // 流程发起初始化
  38. function taskinfo(_param) {
  39. fieldMap = {};
  40. var req = {
  41. processId: _param.processId,
  42. taskId: _param.taskId
  43. };
  44. learun.layer.loading(true, "获取流程信息");
  45. learun.httpget(config.webapi + "learun/adms/newwf/processinfo", req, function (data) {
  46. if (data) {
  47. info = data.info;
  48. schemeObj = JSON.parse(info.Scheme);
  49. // 获取当前节点
  50. $.each(schemeObj.nodes, function (_index, _item) {
  51. if (_item.id == info.CurrentNodeId) {
  52. currentNode = _item;
  53. }
  54. });
  55. learun.httpget(config.webapi + "learun/adms/newwf/scheme", currentNode.childFlow, function (cdata) {
  56. learun.layer.loading(false);
  57. if (cdata) {
  58. var schemeObj3 = JSON.parse(cdata.F_Content);
  59. var ccurrentNode;
  60. // 获取开始节点
  61. $.each(schemeObj3.nodes, function (_index, _item) {
  62. if (_item.type == 'startround') {
  63. ccurrentNode = _item;
  64. return false;
  65. }
  66. });
  67. var wfForms = ccurrentNode.wfForms;// 表单数据
  68. var schemeIds = [];
  69. var authorizeFields = [];
  70. var formreq = [];
  71. // 获取下关联字段
  72. $.each(wfForms, function (_index, _item) {
  73. if (_item.formId) {
  74. fieldMap[_item.formId] = _item.field;
  75. schemeIds.push(_item.formId);
  76. var point = {
  77. schemeInfoId: _item.formId,
  78. processIdName: _item.field,
  79. keyValue: info.childProcessId,
  80. }
  81. formreq.push(point);
  82. $.each(_item.authorize, function (_jindex, _jitem) {
  83. _jitem.fieldId = _jindex;
  84. authorizeFields.push(_jitem);
  85. });
  86. }
  87. });
  88. learun.custmerform.loadScheme(schemeIds, function (scheme) {
  89. $('#chlidlookcontainer').custmerform(scheme);
  90. // 设置表单的可查看权限
  91. $.each(authorizeFields, function (_index, _item) {
  92. if (_item.isLook === 0) {
  93. $('#chlidlookcontainer').find('#' + _item.fieldId).parents('.lr-form-row').remove();
  94. }
  95. else if (_item.isEdit === 0) {
  96. $('#chlidlookcontainer').find('#' + _item.fieldId).parents('.lr-form-row').attr('readonly', 'readonly');
  97. }
  98. });
  99. $('#chlidlookcontainer').setFormRead();
  100. });
  101. formMap = {};
  102. // 获取下自定义表单数据
  103. learun.httpget(config.webapi + "learun/adms/form/data", formreq, function (data) {
  104. if (data) {
  105. // 设置自定义表单数据
  106. $.each(data, function (_id, _item) {
  107. $.each(_item, function (_j, _jitem) {
  108. if (_jitem.length > 0) {
  109. formMap[_id] = true;
  110. }
  111. });
  112. });
  113. $('#chlidlookcontainer').custmerformSet(data);
  114. }
  115. });
  116. }
  117. });
  118. }
  119. else {
  120. learun.layer.loading(false);
  121. }
  122. });
  123. learun.httpget(config.webapi + "learun/adms/newwf/processinfo", {
  124. processId: _param.processId
  125. }, function (data) {
  126. learun.layer.loading(false);
  127. if (data) {
  128. var schemeObj2 = JSON.parse(data.info.Scheme);
  129. // 获取当前节点
  130. $.each(schemeObj2.nodes, function (_index, _item) {
  131. nodeMap[_item.id] = _item;
  132. });
  133. // 加载流程信息
  134. initTimeLine(data.info.TaskLogList);
  135. }
  136. });
  137. }
  138. function initTimeLine(flowHistory) {
  139. var nodelist = [];
  140. learun.clientdata.getAll('department', {
  141. callback: function (departmentMap) {
  142. learun.clientdata.getAll('user', {
  143. callback: function (userMap) {
  144. for (var i = 0, l = flowHistory.length; i < l; i++) {
  145. var item = flowHistory[i];
  146. var name = (item.F_CreateUserName || '系统处理') + ':';
  147. if (item.F_CreateUserId && userMap[item.F_CreateUserId]) {
  148. var _department = departmentMap[userMap[item.F_CreateUserId].departmentId];
  149. if (_department) {
  150. name = '【' + _department.name + '】' + name;
  151. }
  152. }
  153. var content = item.F_OperationName;
  154. if (item.F_Des) {
  155. content += '【审批意见】' + item.F_Des;
  156. }
  157. var nodeName = '';
  158. if (item.F_NodeId && nodeMap[item.F_NodeId]) {
  159. nodeName = nodeMap[item.F_NodeId].name;
  160. }
  161. var point = {
  162. title: item.F_NodeName || nodeName,
  163. people: name,
  164. content: content,
  165. time: item.F_CreateDate
  166. };
  167. nodelist.push(point);
  168. }
  169. $('#chlidlookcontainer2').ftimeline(nodelist);
  170. }
  171. });
  172. }
  173. });
  174. }
  175. return page;
  176. })();