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.

audit.js 11 KiB

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