ProcessProperty.js 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480
  1. /**
  2. * 设置流程属性
  3. */
  4. setPropertyNames = function() {
  5. var type = processNode.type;
  6. if (type == "MyCanvas") {
  7. pn.id = "ID";
  8. pn.name = myDesktopApp.i18n.processName;
  9. pn.category = myDesktopApp.i18n.nameSpace;
  10. pn.documentation = myDesktopApp.i18n.processDescription;
  11. ce.id = Ext.create('Ext.form.field.Text', {
  12. readOnly : true
  13. });
  14. ce.name = Ext.create('Ext.form.field.Text', {
  15. readOnly : true
  16. });
  17. ce.category = Ext.create('Ext.form.field.Text', {
  18. readOnly : true
  19. });
  20. ce.documentation = Ext.create('Ext.form.field.Text', {
  21. readOnly : true
  22. });
  23. }
  24. if (type == "draw2d.Start" || type == "draw2d.End"
  25. || type == "draw2d.CancelEnd" || type == "draw2d.ErrorEnd") {
  26. pn.eventId = "ID";
  27. pn.eventName = myDesktopApp.i18n.Name;
  28. pn.expression = myDesktopApp.i18n.startPersion;
  29. ce.eventId = Ext.create('Ext.form.field.Text', {
  30. readOnly : true
  31. });
  32. ce.eventName = Ext.create('Ext.form.field.Text', {});
  33. ce.expression = Ext.create('Ext.form.field.Text', {
  34. readOnly : true
  35. });
  36. }
  37. if (type == "draw2d.UserTask" || type == "draw2d.SignTask") {
  38. pn.taskId = "ID";
  39. pn.taskName = myDesktopApp.i18n.Name;
  40. pn.documentation = myDesktopApp.i18n.description;
  41. pn.performerType = myDesktopApp.i18n.persionType;
  42. pn.expression = myDesktopApp.i18n.joinPersion;
  43. pn.formId = myDesktopApp.i18n.Form;
  44. pn.signNum = myDesktopApp.i18n.signNum;
  45. if (processNode.taskId.indexOf('signTask') != -1) {
  46. pn.signType = myDesktopApp.i18n.signType;
  47. pn.isSequential = myDesktopApp.i18n.runStatus;
  48. ce.signType = Ext.create('Ext.form.ComboBox', {
  49. valueField : 'value',
  50. displayField : 'name',
  51. store : this.getSignTypeStore(),
  52. listeners : {
  53. change : function(obj, newVal, oldVal) {
  54. if (newVal == 'passByProportion') {
  55. workflowpg.setProperty("signNum",
  56. processNode.signNum, true);
  57. } else {
  58. workflowpg.removeProperty("signNum");
  59. }
  60. }
  61. }
  62. });
  63. ce.isSequential = Ext.create('Ext.form.ComboBox', {
  64. valueField : 'value',
  65. displayField : 'name',
  66. store : this.getStateStore()
  67. });
  68. }
  69. ce.formId = Ext.create('Ext.form.field.Text', {});
  70. ce.taskId = Ext.create('Ext.form.field.Text', {
  71. readOnly : true
  72. });
  73. ce.taskName = Ext.create('Ext.form.field.Text', {});
  74. ce.documentation = Ext.create('Ext.form.field.Text', {});
  75. ce.performerType = Ext.create('Ext.form.ComboBox', {
  76. valueField : 'value',
  77. displayField : 'name',
  78. store : this.getPerformerStore()
  79. });
  80. if (type == "draw2d.SignTask") {
  81. ce.performerType.setReadOnly(true);
  82. }
  83. ce.expression = Ext.create('Ext.form.field.Text', {
  84. listeners : {
  85. focus : function(obj, e, eOpts) {
  86. var performerType = processNode.performerType;
  87. var sw;
  88. if (performerType == "assignee") {
  89. sw = Ext.create('baseUx.selector.UserSelectorFront', {
  90. issingle : true,
  91. myvalue : processNode.expression,
  92. // data返回的是json类型的数据
  93. uswcallback : function(data) {
  94. data = Ext.decode(data);
  95. if (data) {
  96. obj.setValue(data[0].accountName);
  97. workflowpg.setProperty(
  98. "expression",
  99. data[0].accountName);
  100. }
  101. }
  102. });
  103. }
  104. if (performerType == "candidateGroups") {
  105. sw = Ext.create('baseUx.selector.RoleSelector', {
  106. issingle : true,
  107. uswcallback : function(data) {
  108. source.expression = data.roles[0].name;
  109. processNode.expression = data.roles[0].name;
  110. workflowpg.setSource(source);
  111. }
  112. });
  113. }
  114. if (performerType == "candidateUsers") {
  115. sw = Ext.create('baseUx.selector.UserSelectorFront', {
  116. myvalue : processNode.expression,
  117. // data返回的是json类型的数据
  118. uswcallback : function(data) {
  119. var result = '';
  120. data = Ext.decode(data);
  121. if (data) {
  122. for (var i = 0; i < data.length; i++) {
  123. result += data[i].accountName
  124. + ',';
  125. }
  126. result = result.substring(0,
  127. result.length - 1);
  128. obj.setValue(result);
  129. workflowpg.setProperty(
  130. "expression", result);
  131. }
  132. }
  133. });
  134. }
  135. sw.show();
  136. }
  137. }
  138. });
  139. if (type == "draw2d.SignTask") {
  140. ce.expression.suspendEvents(true);
  141. ce.expression.setReadOnly(true);
  142. }
  143. }
  144. if (type == "draw2d.DecoratedConnection") {
  145. pn.lineId = "ID";
  146. pn.lineName = myDesktopApp.i18n.note;
  147. pn.condition = myDesktopApp.i18n.condition;
  148. ce.lineId = Ext.create('Ext.form.field.Text', {
  149. readOnly : true
  150. });
  151. ce.lineName = Ext.create('Ext.form.field.Text', {});
  152. ce.condition = Ext.create('Ext.form.ComboBox', {
  153. store : this.getHandleStore(),
  154. valueField : 'shortClassName',
  155. displayField : 'handleName',
  156. multiSelect : true
  157. });
  158. }
  159. if (type == "draw2d.ExclusiveGateway" || type == "draw2d.ParallelGateway") {
  160. pn.gatewayId = "ID";
  161. pn.gatewayName = myDesktopApp.i18n.Name;
  162. ce.gatewayId = Ext.create('Ext.form.field.Text', {
  163. readOnly : true
  164. });
  165. ce.gatewayName = Ext.create('Ext.form.field.Text', {});
  166. }
  167. };
  168. /* 设置属性数据 */
  169. setSource = function() {
  170. Ext.getCmp('assignmentlistenertxt').setValue('');
  171. Ext.getCmp('createlistenertxt').setValue('');
  172. Ext.getCmp('completelistenertxt').setValue('');
  173. Ext.getCmp('actioncombo').setValue('');
  174. Ext.getCmp('formtxt').setValue('');
  175. Ext.getCmp('formpg').setSource({});
  176. Ext.getCmp('delegatestr').setValue('');
  177. var type = processNode.type;
  178. source = {};
  179. if (type == "MyCanvas") {
  180. source.id = workflow.process.id;
  181. source.name = workflow.process.name;
  182. source.category = workflow.process.category;
  183. source.documentation = workflow.process.documentation;
  184. }
  185. nodeId = processNode.id;
  186. if (type == "draw2d.Start" || type == "draw2d.End"
  187. || type == "draw2d.CancelEnd" || type == "draw2d.ErrorEnd") {
  188. source.eventId = processNode.eventId;
  189. source.eventName = processNode.eventName;
  190. source.expression = processNode.expression;
  191. workflowpg.customRenderers = {
  192. expression : function(v) {
  193. if (v = "applyUserId") {
  194. return "系统内置参数";
  195. }
  196. }
  197. };
  198. }
  199. if (type == "draw2d.UserTask" || type == "draw2d.SignTask") {
  200. source.taskId = processNode.taskId;
  201. source.taskName = processNode.taskName;
  202. source.documentation = processNode.documentation;
  203. source.performerType = processNode.performerType;
  204. source.expression = processNode.expression;
  205. source.formId = processNode.formId;
  206. if (processNode.taskId.indexOf('signTask') != -1) {
  207. source.isSequential = processNode.isSequential;
  208. source.signType = processNode.signType;
  209. }
  210. workflowpg.customRenderers = {
  211. performerType : function(v) {
  212. if (v == "assignee")
  213. return "办理人";
  214. if (v == "candidateUsers")
  215. return "备选人员";
  216. if (v == "candidateGroups")
  217. return "备选角色";
  218. },
  219. isSequential : function(v) {
  220. if (v == "true") {
  221. return '串行';
  222. }
  223. if (v == "false") {
  224. return '并行';
  225. }
  226. },
  227. signType : function(v) {
  228. if (v == 'oneVoteVeto') {
  229. return '一票否决';
  230. } else if (v == 'oneVotePass') {
  231. return '一票通过';
  232. } else if (v == 'passByProportion') {
  233. return '按比例通过';
  234. }
  235. },
  236. expression : function(v) {
  237. if(v=='${currentuser}'){
  238. return '发起人';
  239. }
  240. var result = "";
  241. if (source.performerType == "assignee") {
  242. Ext.Ajax.request({
  243. async : false,
  244. url : '/user/getusernamebyassignee',
  245. params : {
  246. accountName : v
  247. },
  248. success : function(response) {
  249. result = response.responseText;
  250. }
  251. });
  252. } else if (source.performerType == "candidateUsers") {
  253. Ext.Ajax.request({
  254. async : false,
  255. url : '/user/getusernamebycandidateusers',
  256. params : {
  257. accountName : v
  258. },
  259. success : function(response) {
  260. result = response.responseText;
  261. }
  262. });
  263. } else if (source.performerType == "candidateGroups") {
  264. Ext.Ajax.request({
  265. async : false,
  266. url : '/user/getusernamebycandidategroups',
  267. params : {
  268. roleName : v
  269. },
  270. success : function(response) {
  271. result = response.responseText;
  272. }
  273. });
  274. }
  275. return result;
  276. }
  277. };
  278. if (processNode.myforms.getSize() > 0) {
  279. var form = processNode.myforms.get(0);
  280. formtxt.setValue(form.name);
  281. formpg.setFormProperties(JSON.parse(form.config
  282. .replace(/\'/g, '\"')));
  283. }
  284. if (processNode.users.getSize() > 0) {
  285. var user = processNode.users.get(0);
  286. var arr = Ext.decode(user.value, true), names = '';
  287. if (arr) {
  288. for (var i = 0; i < arr.length; ++i) {
  289. names = names + arr[i].userName + ',';
  290. }
  291. delegatestr.setValue(names.substring(0, names.length - 1));
  292. }
  293. }
  294. if (processNode.mylisteners.getSize() > 0) {
  295. var listener = processNode.mylisteners;
  296. for(var i=0;i<listener.size;i++){
  297. var nameArray = listener.get(i).name.split(',');
  298. for(var j=0;j<nameArray.length;j++){
  299. if(j==0){
  300. Ext.getCmp('assignmentlistenertxt').setValue(nameArray[j].replace(/\'/g,""));
  301. }else if(j==1){
  302. Ext.getCmp('createlistenertxt').setValue(nameArray[j].replace(/\'/g,""));
  303. }else if(j==2){
  304. Ext.getCmp('completelistenertxt').setValue(nameArray[j].replace(/\'/g,""));
  305. }
  306. }
  307. }
  308. }
  309. if (processNode.actions.getSize() > 0) {
  310. var action = processNode.actions.get(0);
  311. Ext.getCmp('actioncombo').setValue(action.id);
  312. }
  313. }
  314. if (type == "draw2d.DecoratedConnection") {
  315. source.lineId = processNode.lineId;
  316. source.lineName = processNode.lineName;
  317. if (typeof processNode.condition == 'string') {
  318. source.condition = processNode.condition;
  319. } else {
  320. source.condition = '';
  321. if (processNode.condition && processNode.condition.length > 0) {
  322. for (var i = 0; i < processNode.condition.length; i++) {
  323. var con = processNode.condition[i];
  324. source.condition += con + ',';
  325. }
  326. }
  327. source.condition = source.condition.substring(0,
  328. source.condition.length - 1);
  329. processNode.condition = source.condition;
  330. }
  331. workflowpg.customRenderers = {
  332. condition : function(v) {
  333. var newhandlers = '';
  334. Ext.Ajax.request({
  335. url : '/handler/manage',
  336. async : false,// 同步请求数据
  337. success : function(response) {
  338. var myhandlers = Ext.decode(response.responseText);
  339. if (typeof v == 'string') {
  340. v = (v.trim()).split(',');
  341. }
  342. for (var i = 0; i < v.length; i++) {
  343. for (var j = 0; j < myhandlers.handlers.length; j++) {
  344. if (myhandlers.handlers[j].shortClassName
  345. .trim() == v[i].trim()) {
  346. newhandlers += myhandlers.handlers[j].handleName
  347. + ',';
  348. }
  349. }
  350. }
  351. }
  352. });
  353. return newhandlers.substring(0, newhandlers.length - 1);
  354. }
  355. };
  356. }
  357. if (type == "draw2d.ExclusiveGateway" || type == "draw2d.ParallelGateway") {
  358. source.gatewayId = processNode.gatewayId;
  359. source.gatewayName = processNode.gatewayName;
  360. }
  361. workflowpg.setSource(source);
  362. };
  363. /* 属性表格数据改变事件 */
  364. startPnChange = function(source, recordId, value, oldValue, eOpts) {
  365. var type = processNode.type;
  366. processNode[recordId] = value;
  367. if (type == "draw2d.UserTask") {
  368. processNode.setId(processNode['taskId']);
  369. processNode.setContent(processNode['taskName']);
  370. processNode.isUseExpression = true;
  371. processNode.performerType = processNode['performerType'];
  372. processNode.expression = processNode['expression'];
  373. processNode.formId = processNode['formId'];
  374. }
  375. if (type == 'draw2d.SignTask') {
  376. processNode.setId(processNode['taskId']);
  377. processNode.setContent(processNode['taskName']);
  378. processNode.isUseExpression = true;
  379. processNode.performerType = processNode['performerType'];
  380. processNode.expression = processNode['expression'];
  381. processNode.formId = processNode['formId'];
  382. processNode.signNum = processNode['signNum'];
  383. }
  384. if (type == "draw2d.DecoratedConnection") {
  385. processNode.setLabel(processNode['lineName']);
  386. processNode.condition = processNode['condition'];
  387. }
  388. };
  389. getPerformerStore = function() {
  390. var performerStore = Ext.create('Ext.data.Store', {
  391. fields : [{
  392. name : 'name',
  393. type : 'string'
  394. }, {
  395. name : 'value',
  396. type : 'string'
  397. }],
  398. data : [{
  399. name : myDesktopApp.i18n.assignee,
  400. value : 'assignee'
  401. }, {
  402. name : myDesktopApp.i18n.candidateUsers,
  403. value : 'candidateUsers'
  404. }, {
  405. name : myDesktopApp.i18n.candidateGroups,
  406. value : 'candidateGroups'
  407. }]
  408. });
  409. return performerStore;
  410. };
  411. getSignTypeStore = function() {
  412. var signTypeStore = Ext.create('Ext.data.Store', {
  413. fields : [{
  414. name : 'name',
  415. type : 'string'
  416. }, {
  417. name : 'value',
  418. type : 'string'
  419. }],
  420. data : [{
  421. name : myDesktopApp.i18n.oneVoteVeto,
  422. value : 'oneVoteVeto'
  423. }, {
  424. name : myDesktopApp.i18n.oneVotePass,
  425. value : 'oneVotePass'
  426. }, {
  427. name : myDesktopApp.i18n.passByProportion,
  428. value : 'passByProportion'
  429. }]
  430. });
  431. return signTypeStore;
  432. };
  433. getStateStore = function() {
  434. var stateStore = Ext.create('Ext.data.Store', {
  435. fields : [{
  436. name : 'name',
  437. type : 'string'
  438. }, {
  439. name : 'value',
  440. type : 'string'
  441. }],
  442. data : [{
  443. name : myDesktopApp.i18n.serial,
  444. value : 'true'
  445. }, {
  446. name : myDesktopApp.i18n.parallel,
  447. value : 'false'
  448. }]
  449. });
  450. return stateStore;
  451. };
  452. getHandleStore = function() {
  453. var handleStore = Ext.create('Ext.data.Store', {
  454. fields : [{
  455. name : 'handleName',
  456. type : 'string'
  457. }, {
  458. name : 'shortClassName',
  459. type : 'string'
  460. }],
  461. proxy : {
  462. type : 'ajax',
  463. url : '/handle/manage',
  464. reader : {
  465. type : 'json',
  466. root : 'handles',
  467. totalProperty : 'totalCount'
  468. },
  469. writer : {
  470. type : 'json'
  471. }
  472. }
  473. });
  474. return handleStore;
  475. };