25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.
 
 
 
 
 
 

279 satır
11 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 formAllData;
  10. var formreq;
  11. // 流程信息
  12. var info;
  13. var schemeObj;
  14. var currentNode;
  15. var nodeMap = {};
  16. var getFormData = function ($page) {
  17. console.log('开始获取表单数据');
  18. formDataes = $page.find('#auditcontainer').custmerformGet();
  19. if (formDataes == null) {
  20. return false;
  21. }
  22. formreq = [];
  23. formAllData = {};
  24. for (var id in formDataes) {
  25. // if (!fieldMap[id]) {
  26. // learun.layer.warning('未设置流程表单关联字段!', function () { }, '数字化智慧校园', '关闭');
  27. // return false;
  28. // }
  29. $.extend(formAllData, formDataes[id]);
  30. if (!formMap[id]) {
  31. formDataes[id][fieldMap[id]] = processId;
  32. }
  33. var point = {
  34. schemeInfoId: id,
  35. processIdName: fieldMap[id],
  36. formData: JSON.stringify(formDataes[id])
  37. }
  38. if (formMap[id]) {
  39. point.keyValue = processId;
  40. }
  41. formreq.push(point);
  42. console.log('显示表单信息');
  43. console.log(point);
  44. }
  45. return true;
  46. };
  47. var page = {
  48. init: function ($page, param) {
  49. var _html = '<div class="lr-form-header-submit" style="display:block;" >审核</div>';
  50. $header = $page.parents('.f-page').find('.f-page-header');
  51. $header.append(_html);
  52. headText = $header.find('.f-page-title').text();
  53. $page.find('.lr-naudit-page').toptab(['表单信息', '流程信息']).each(function (index) {
  54. var $this = $(this);
  55. switch (index) {
  56. case 0:
  57. $this.html('<div class="container" id="nauditcontainer"></div>');
  58. break;
  59. case 1:
  60. $this.html('<div class="container" id="nauditcontainer2"></div>');
  61. break;
  62. }
  63. $this = null;
  64. });
  65. processId = param.processId;
  66. taskId = param.taskId;
  67. taskinfo(param);
  68. // 审核
  69. $header.find('.lr-form-header-submit').on('tap', function () {
  70. var actionsheetData = [];
  71. $.each(currentNode.btnList, function (_index, _item) {
  72. if (_item.isHide != '1') {
  73. var point = {
  74. text: _item.name,
  75. group: '1',
  76. event: function () {
  77. // 获取表单数据
  78. if (!getFormData($page)) {
  79. return false;
  80. }
  81. learun.nav.go({ path: 'nworkflow/audit/verify', title: headText + '【' + _item.name + '】', type: 'right', param: {btn:_item,schemeCode:info.SchemeCode, processId: processId, taskId: taskId, verify: _item.code, name: _item.name, node: currentNode } });
  82. }
  83. }
  84. if (_item.code == 'disagree') {
  85. point.mark = true;
  86. }
  87. actionsheetData.push(point);
  88. }
  89. });
  90. if (currentNode.isSign == "1") {
  91. actionsheetData.push({
  92. text: '加签',
  93. group: '2',
  94. event: function () {// 删除当前条信息
  95. // 获取表单数据
  96. if (!getFormData($page)) {
  97. return false;
  98. }
  99. learun.nav.go({ path: 'nworkflow/audit/sign', title: headText + "【加签】", type: 'right' });
  100. }
  101. });
  102. }
  103. if (actionsheetData.length == 0) {
  104. learun.layer.toast('没有审核按钮');
  105. return;
  106. }
  107. learun.actionsheet({
  108. id: 'audit',
  109. data: actionsheetData,
  110. cancel: function () {
  111. }
  112. });
  113. });
  114. },
  115. sign: function (info, auditers) {// info加签信息
  116. var flowreq = {
  117. processId: processId,
  118. taskId: taskId,
  119. userId: info.auditorId,
  120. des: info.description,
  121. formreq: JSON.stringify(formreq)
  122. };
  123. learun.layer.loading(true, "加签流程,请等待!");
  124. learun.httppost(config.webapi + "learun/adms/newwf/sign", flowreq, function (data) {
  125. learun.layer.loading(false);
  126. var prepage = learun.nav.getpage('nworkflow/myflow');
  127. prepage.grid[1].reload();
  128. learun.nav.closeCurrent();
  129. });
  130. },
  131. verify: function (info, auditers) {// info审核信息
  132. var flowreq = {
  133. operationCode: info.verify,
  134. operationName: info.name,
  135. processId: processId,
  136. taskId: taskId,
  137. des: info.description,
  138. auditors: JSON.stringify(auditers),
  139. formreq: JSON.stringify(formreq)
  140. };
  141. learun.layer.loading(true, "审核流程,请等待!");
  142. learun.httppost(config.webapi + "learun/adms/newwf/audit", flowreq, function (data) {
  143. learun.layer.loading(false);
  144. var prepage = learun.nav.getpage('nworkflow/myflow');
  145. prepage.grid[1].reload();
  146. learun.nav.closeCurrent();
  147. });
  148. },
  149. destroy: function (pageinfo) {
  150. $header = null;
  151. }
  152. };
  153. // 流程发起初始化
  154. function taskinfo(_param) {
  155. fieldMap = {};
  156. var req = {
  157. processId: _param.processId,
  158. taskId: _param.taskId
  159. };
  160. learun.layer.loading(true, "获取流程信息");
  161. learun.httpget(config.webapi + "learun/adms/newwf/processinfo", req, function (data) {
  162. learun.layer.loading(false);
  163. if (data) {
  164. var schemeIds = [];
  165. var authorizeFields = [];
  166. var formreq = [];
  167. info = data.info;
  168. schemeObj = JSON.parse(info.Scheme);
  169. // 获取当前节点
  170. $.each(schemeObj.nodes, function (_index, _item) {
  171. if (_item.id == info.CurrentNodeId) {
  172. currentNode = _item;
  173. }
  174. nodeMap[_item.id] = _item;
  175. });
  176. $.each(currentNode.wfForms, function (_index, _item) {
  177. if (_item.formId) {
  178. schemeIds.push(_item.formId);
  179. var point = {
  180. schemeInfoId: _item.formId,
  181. processIdName: _item.field,
  182. keyValue: _param.processId,
  183. }
  184. formreq.push(point);
  185. $.each(_item.authorize, function (_jindex, _jitem) {
  186. _jitem.fieldId = _jindex;
  187. authorizeFields.push(_jitem);
  188. });
  189. }
  190. });
  191. learun.custmerform.loadScheme(schemeIds, function (scheme) {
  192. $('#nauditcontainer').custmerform(scheme);
  193. // 设置表单的可查看权限
  194. $.each(authorizeFields, function (_index, _item) {
  195. if (_item.isLook === 0) {
  196. $('#nauditcontainer').find('#' + _item.fieldId).parents('.lr-form-row').remove();
  197. }
  198. else if (_item.isEdit === 0) {
  199. $('#nauditcontainer').find('#' + _item.fieldId).parents('.lr-form-row').attr('readonly', 'readonly');
  200. }
  201. });
  202. });
  203. formMap = {};
  204. // 获取下自定义表单数据
  205. learun.httpget(config.webapi + "learun/adms/form/data", formreq, function (data) {
  206. if (data) {
  207. // 设置自定义表单数据
  208. $.each(data, function (_id, _item) {
  209. $.each(_item, function (_j, _jitem) {
  210. if (_jitem.length > 0) {
  211. formMap[_id] = true;
  212. }
  213. });
  214. });
  215. $('#nauditcontainer').custmerformSet(data);
  216. }
  217. });
  218. // 加载流程信息
  219. initTimeLine(info.TaskLogList);
  220. }
  221. console.log(data);
  222. });
  223. }
  224. function initTimeLine(flowHistory) {
  225. var nodelist = [];
  226. learun.clientdata.getAll('department', {
  227. callback: function (departmentMap) {
  228. learun.clientdata.getAll('user', {
  229. callback: function (userMap) {
  230. for (var i = 0, l = flowHistory.length; i < l; i++) {
  231. var item = flowHistory[i];
  232. var name = (item.F_CreateUserName || '系统处理') + ':';
  233. if (item.F_CreateUserId && userMap[item.F_CreateUserId]) {
  234. var _department = departmentMap[userMap[item.F_CreateUserId].departmentId];
  235. if (_department) {
  236. name = '【' + _department.name + '】' + name;
  237. }
  238. }
  239. var content = item.F_OperationName;
  240. if (item.F_Des) {
  241. content += '【审批意见】' + item.F_Des;
  242. }
  243. var nodeName = '';
  244. if (item.F_NodeId && nodeMap[item.F_NodeId]) {
  245. nodeName = nodeMap[item.F_NodeId].name;
  246. }
  247. var point = {
  248. title: item.F_NodeName || nodeName,
  249. people: name,
  250. content: content,
  251. time: item.F_CreateDate
  252. };
  253. nodelist.push(point);
  254. }
  255. $('#nauditcontainer2').ftimeline(nodelist);
  256. }
  257. });
  258. }
  259. });
  260. }
  261. return page;
  262. })();