sysnavigationform.js 39 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093
  1. //没找到model从哪里来的***************不知道如何调用form
  2. /**
  3. * 各种活动对应的属性面板
  4. */
  5. Ext.ns('App.form');
  6. /** 面向抽象编程***/
  7. App.form.AbstractForm = Ext.extend(Object, {
  8. eventNames: [
  9. ['start', '开始'],
  10. ['end', '结束']
  11. ],
  12. classNames:[],
  13. clearItem: function(p) {
  14. if (typeof p.items != 'undefined') {
  15. var item = null;
  16. while ((item = p.items.last())) {
  17. p.remove(item, true);
  18. }
  19. }
  20. },
  21. getParticipantData: function(model) {
  22. var data = [];
  23. var elements = model.dom.getElementsByTagName('participant');
  24. Gef.each(elements, function(elem) {
  25. data.push({
  26. name: elem.getAttribute('name'),
  27. type: elem.getAttribute('type'),
  28. id : elem.getAttribute('id')
  29. });
  30. });
  31. return data;
  32. },
  33. resetParticipant: function(tabPanel, model) {
  34. var data = this.getParticipantData(model);
  35. var Record = Ext.data.Record.create(['name', 'type','id']);
  36. var store = new Ext.data.JsonStore({
  37. fields: Record,
  38. data: data,
  39. listeners: {
  40. add: function(store, records, index) {
  41. var record = records[0];
  42. var participantName = record.get('name');
  43. var participantType = record.get('type');
  44. var participantId = record.get('id');
  45. if ((!participantName) || participantName == '' || (!participantType) || participantType == '') {
  46. return;
  47. }
  48. var onDom = new Gef.model.Dom('participant');
  49. onDom.setAttribute('name', participantName);
  50. onDom.setAttribute('type', participantType);
  51. onDom.setAttribute('id',participantId);
  52. model.dom.addElement(onDom);
  53. },
  54. remove: function(store, record, index) {
  55. var candidateElements = model.dom.getElementsByTagName('participant');
  56. var elements = candidateElements;
  57. var element = elements[index];
  58. model.dom.elements.remove(element);
  59. },
  60. update: function(store, record, operation) {
  61. var participantName = record.get('name');
  62. var participantType = record.get('type');
  63. var participantId = record.get('id');
  64. if ((!participantName) || participantName == '' || (!participantType) || participantType == '') {
  65. return;
  66. }
  67. var index = store.indexOf(record);
  68. var candidateElements = model.dom.getElementsByTagName('participant');
  69. var elements = candidateElements;
  70. var element = elements[index];
  71. if (!element) {
  72. var onDom = new Gef.model.Dom('participant');
  73. onDom.setAttribute('name', participantName);
  74. onDom.setAttribute('type', participantType);
  75. onDom.setAttribute('id' , participantId);
  76. model.dom.addElement(onDom);
  77. } else {
  78. element.setAttribute('name', participantName);
  79. element.setAttribute('type', participantType);
  80. element.setAttribute('id' , participantId);
  81. }
  82. this.commitChanges();
  83. }
  84. }
  85. });
  86. var grid = new Ext.grid.EditorGridPanel({
  87. title: '界面配置',
  88. store: store,
  89. viewConfig: {
  90. forceFit: true
  91. },
  92. id:'grid',
  93. listeners:{
  94. 'cellclick':function(grid,rowIndex){
  95. grid.lastSelectedRecord=grid.selModel.selection.record;
  96. }
  97. },
  98. columnLines:true,
  99. dbfinds:[{
  100. field:'name',
  101. dbGridField:'sn_displayname'
  102. },{
  103. field:'type',
  104. dbGridField:'sn_url'
  105. },{
  106. field:'id',
  107. dbGridField:'sn_id'
  108. }],
  109. columns: [{
  110. header: '页面名称',
  111. dataIndex: 'name',
  112. sortable: true,
  113. width:400,
  114. editor: new Ext.grid.GridEditor(new Gef.org.DbfindField({
  115. dbtype:'grid',
  116. name:'name',
  117. dbfind:'Sysnavigation|sn_displayname'
  118. }))
  119. },{
  120. header: '页面路径',
  121. dataIndex: 'type',
  122. sortable: true,
  123. width:400
  124. },{
  125. header:'页面ID',
  126. dataIndex:'id',
  127. sortable:true,
  128. width:0
  129. }],
  130. tbar: [{
  131. text: '添加',
  132. iconCls: 'tb-add',
  133. handler: function() {
  134. var p = new Record({
  135. name: '',
  136. type: ''
  137. });
  138. this.addRecord(grid, p);
  139. },
  140. scope: this
  141. }, {
  142. text: '删除',
  143. iconCls: 'tb-delete',
  144. handler: function() {
  145. this.removeRecord(grid);
  146. },
  147. scope: this
  148. }]
  149. });
  150. tabPanel.add(grid);
  151. },
  152. getEventData: function(model) {
  153. var data = [];
  154. var elements = model.dom.getElementsByTagName('on');
  155. Gef.each(elements, function(elem) {
  156. var timerElem = elem.getElementByTagName('timer');
  157. if (timerElem) {
  158. return true;
  159. }
  160. data.push({
  161. name: elem.getAttribute('event'),
  162. classname: elem.getElementAttribute('event-listener', 'class')
  163. });
  164. });
  165. return data;
  166. },
  167. resetEvent: function(tabPanel, model) {
  168. var data = this.getEventData(model);
  169. var Record = Ext.data.Record.create(['name', 'classname']);
  170. var store = new Ext.data.JsonStore({
  171. fields: Record,
  172. data: data,
  173. listeners: {
  174. add: function(store, records, index) {
  175. var record = records[0];
  176. var eventName = record.get('name');
  177. var eventClassName = record.get('classname');
  178. if ((!eventName) || eventName == '' || (!eventClassName) || eventClassName == '') {
  179. return;
  180. }
  181. var onDom = new Gef.model.Dom('on'); // 这才是 创建一个 新元素的正确方法!
  182. onDom.setAttribute('event', eventName);
  183. onDom.setElementAttribute('event-listener', 'class', eventClassName);
  184. model.dom.addElement(onDom);
  185. },
  186. remove: function(store, record, index) {
  187. var candidateElements = model.dom.getElementsByTagName('on');
  188. var elements = [];
  189. Gef.each(candidateElements, function(elem) {
  190. var timerElem = elem.getElementByTagName('timer');
  191. if (!timerElem) {
  192. elements.push(elem);
  193. }
  194. });
  195. var element = elements[index];
  196. model.dom.elements.remove(element);
  197. },
  198. update: function(store, record, operation) {
  199. var eventName = record.get('name');
  200. var eventClassName = record.get('classname');
  201. if ((!eventName) || eventName == '' || (!eventClassName) || eventClassName == '') {
  202. return;
  203. }
  204. var index = store.indexOf(record);
  205. var candidateElements = model.dom.getElementsByTagName('on');
  206. var elements = [];
  207. Gef.each(candidateElements, function(elem) {
  208. var timerElem = elem.getElementByTagName('timer');
  209. if (!timerElem) {
  210. elements.push(elem);
  211. }
  212. });
  213. var element = elements[index];
  214. if (!element) {
  215. var onDom = new Gef.model.Dom('on');
  216. onDom.setAttribute('event', eventName);
  217. onDom.setElementAttribute('event-listener', 'class', eventClassName);
  218. model.dom.addElement(onDom);
  219. } else {
  220. element.setAttribute('event', eventName);
  221. element.setElementAttribute('event-listener', 'class', eventClassName);
  222. }
  223. this.commitChanges();
  224. }
  225. }
  226. });
  227. var eventNameMap = {};
  228. Gef.each(this.eventNames, function(item) {
  229. eventNameMap[item[0]] = item[1];
  230. });
  231. var classNameMap = {};
  232. Gef.each(this.classNames, function(item) {
  233. classNameMap[item[0]] = item[1];
  234. });
  235. var grid = new Ext.grid.EditorGridPanel({
  236. title: '事件配置',
  237. store: store,
  238. viewConfig: {
  239. forceFit: true
  240. },
  241. columns: [{
  242. header: '事件类型',
  243. dataIndex: 'name',
  244. editor: new Ext.grid.GridEditor(new Ext.ux.TwoCombo({
  245. data: this.eventNames
  246. })),
  247. /* width:'15%',*/
  248. renderer: function(v) {
  249. return eventNameMap[v];
  250. }
  251. }, {
  252. header: '类名',
  253. dataIndex: 'classname',
  254. /* editor: new Ext.grid.GridEditor(new Ext.form.TextField())*/
  255. editor: new Ext.grid.GridEditor(new Ext.ux.TwoCombo({
  256. data: this.classNames
  257. })),
  258. renderer: function(v) {
  259. return classNameMap[v];
  260. }
  261. }],
  262. tbar: [{
  263. text: '添加',
  264. iconCls: 'tb-add',
  265. handler: function() {
  266. var p = new Record({
  267. name: this.eventNames[0][0],
  268. classname: ''
  269. });
  270. this.addRecord(grid, p);
  271. },
  272. scope: this
  273. }, {
  274. text: '删除',
  275. iconCls: 'tb-delete',
  276. handler: function() {
  277. this.removeRecord(grid);
  278. },
  279. scope: this
  280. }]
  281. });
  282. tabPanel.add(grid);
  283. },
  284. getSwimlaneData: function(model) {
  285. var data = [];
  286. var elements = model.dom.getElementsByTagName('swimlane');
  287. Gef.each(elements, function(item) {
  288. data.push({
  289. name: item.getAttribute('name'),
  290. assignee: item.getAttribute('assignee'),
  291. candidateUsers: item.getAttribute('candidate-users'),
  292. candidateGroups: item.getAttribute('candidate-groups'),
  293. description: item.getElementContent('description')
  294. });
  295. });
  296. return data;
  297. },
  298. resetSwimlane: function(tabPanel, model) {
  299. var data = this.getSwimlaneData(model);
  300. var Record = Ext.data.Record.create([
  301. 'name',
  302. 'assignee',
  303. 'candidateUsers',
  304. 'candidateGroups',
  305. 'description'
  306. ]);
  307. var store = new Ext.data.JsonStore({
  308. fields: Record,
  309. data: data,
  310. listeners: {
  311. add: function(store, records, index) {
  312. var record = records[0];
  313. var swimlaneDom = new Gef.model.Dom('swimlane');
  314. swimlaneDom.setAttribute('name', record.get('name'));
  315. swimlaneDom.setAttribute('assignee', record.get('assignee'));
  316. swimlaneDom.setAttribute('candidate-users', record.get('candidateUsers'));
  317. swimlaneDom.setAttribute('candidate-groups', record.get('candidateGroups'));
  318. swimlaneDom.setElementContent('description', record.get('description'));
  319. model.dom.addElement(swimlaneDom);
  320. },
  321. remove: function(store, record, index) {
  322. var elements = model.dom.getElementsByTagName('swimlane');
  323. var element = elements[index];
  324. model.dom.elements.remove(element);
  325. },
  326. update: function(store, record, operation) {
  327. var index = store.indexOf(record);
  328. var elements = model.dom.getElementsByTagName('swimlane');
  329. var element = elements[index];
  330. element.setAttribute('name', record.get('name'));
  331. element.setAttribute('assignee', record.get('assignee'));
  332. element.setAttribute('candidate-users', record.get('candidateUsers'));
  333. element.setAttribute('candidate-groups', record.get('candidateGroups'));
  334. element.setElementContent('description', record.get('description'));
  335. this.commitChanges();
  336. }
  337. }
  338. });
  339. var grid = new Ext.grid.EditorGridPanel({
  340. title: '泳道配置',
  341. store: store,
  342. viewConfig: {
  343. forceFit: true
  344. },
  345. columns: [{
  346. header: '泳道名',
  347. dataIndex: 'name',
  348. editor: new Ext.grid.GridEditor(new Ext.form.TextField())
  349. }, {
  350. header: '分配人',
  351. dataIndex: 'assignee',
  352. editor: new Ext.grid.GridEditor(new Ext.form.TextField())
  353. }, {
  354. header: '候选人',
  355. dataIndex: 'candidateUsers',
  356. editor: new Ext.grid.GridEditor(new Ext.form.TextField())
  357. }, {
  358. header: '候选群组',
  359. dataIndex: 'candidateGroups',
  360. editor: new Ext.grid.GridEditor(new Ext.form.TextField())
  361. }, {
  362. header: '备注',
  363. dataIndex: 'description',
  364. editor: new Ext.grid.GridEditor(new Ext.form.TextField())
  365. }],
  366. tbar: [{
  367. text: '添加',
  368. iconCls: 'tb-add',
  369. handler: function() {
  370. var p = new Record({
  371. name: '',
  372. assignee: '',
  373. candidateUsers: '',
  374. candidateGroups: '',
  375. description: ''
  376. });
  377. this.addRecord(grid, p);
  378. },
  379. scope: this
  380. }, {
  381. text: '删除',
  382. iconCls: 'tb-delete',
  383. handler: function() {
  384. this.removeRecord(grid);
  385. },
  386. scope: this
  387. }]
  388. });
  389. tabPanel.add(grid);
  390. },
  391. getTimerData: function(model) {
  392. var data = [];
  393. var elements = model.dom.getElementsByTagName('on');
  394. Gef.each(elements, function(elem) {
  395. var timerElem = elem.getElementByTagName('timer');
  396. if (!timerElem) {
  397. return true;
  398. }
  399. data.push({
  400. name: elem.getAttribute('event'),
  401. duedate: timerElem.getAttribute('duedate'),
  402. repeat: timerElem.getAttribute('repeat'),
  403. //duedatetime: timerElem.getAttribute('duedatetime'),
  404. classname: elem.getElementAttribute('event-listener', 'class')
  405. });
  406. });
  407. return data;
  408. },
  409. resetTimer: function(tabPanel, model) {
  410. var data = this.getTimerData(model);
  411. var Record = Ext.data.Record.create([
  412. 'name',
  413. 'duedate',
  414. 'repeat',
  415. //'duedatetime',
  416. 'classname'
  417. ]);
  418. var store = new Ext.data.JsonStore({
  419. fields: Record,
  420. data: data,
  421. listeners: {
  422. add: function(store, records, index) {
  423. var record = records[0];
  424. var onDom = new Gef.model.Dom('on');
  425. onDom.setAttribute('event', record.get('name'));
  426. var timerDom = new Gef.model.Dom('timer');
  427. timerDom.setAttribute('duedate', record.get('duedate'));
  428. timerDom.setAttribute('repeat', record.get('repeat'));
  429. //timerDom.setAttribute('duedatetime', record.get('duedatetime'));
  430. onDom.addElement(timerDom);
  431. onDom.setElementAttribute('event-listener', 'class', record.get('classname'));
  432. model.dom.addElement(onDom);
  433. },
  434. remove: function(store, record, index) {
  435. var candidateElements = model.dom.getElementsByTagName('on');
  436. var elements = [];
  437. Gef.each(candidateElements, function(elem) {
  438. var timerElem = elem.getElementByTagName('timer');
  439. if (!timerElem) {
  440. return true;
  441. } else {
  442. elements.push(elem);
  443. }
  444. });
  445. var element = elements[index];
  446. model.dom.elements.remove(element);
  447. },
  448. update: function(store, record, operation) {
  449. var index = store.indexOf(record);
  450. var candidateElements = model.dom.getElementsByTagName('on');
  451. var elements = [];
  452. Gef.each(candidateElements, function(elem) {
  453. var timerElem = elem.getElementByTagName('timer');
  454. if (!timerElem) {
  455. return true;
  456. } else {
  457. elements.push(elem);
  458. }
  459. });
  460. var element = elements[index];
  461. element.setAttribute('event', record.get('name'));
  462. var timerElem = element.getElementByTagName('timer');
  463. timerElem.setAttribute('duedate', record.get('duedate'));
  464. timerElem.setAttribute('repeat', record.get('repeat'));
  465. //element.setAttribute('duedatetime', record.get('duedatetime'));
  466. element.setElementAttribute('event-listener', 'class', record.get('classname'));
  467. element.setElementContent('description', record.get('description'));
  468. this.commitChanges();
  469. }
  470. }
  471. });
  472. var grid = new Ext.grid.EditorGridPanel({
  473. title: '定时器配置',
  474. xtype: 'editorgrid',
  475. store: store,
  476. viewConfig: {
  477. forceFit: true
  478. },
  479. columns: [{
  480. header: '名称',
  481. dataIndex: 'name',
  482. editor: new Ext.grid.GridEditor(new Ext.form.TextField())
  483. }, {
  484. header: '持续日期',
  485. dataIndex: 'duedate',
  486. editor: new Ext.grid.GridEditor(new Ext.form.TextField())
  487. }, {
  488. header: '重复次数',
  489. dataIndex: 'repeat',
  490. editor: new Ext.grid.GridEditor(new Ext.form.TextField())
  491. }, /*{
  492. header: '持续时间',
  493. dataIndex: 'duedatetime',
  494. editor: new Ext.grid.GridEditor(new Ext.form.TextField())
  495. }, */{
  496. header: '监听器类名',
  497. dataIndex: 'classname',
  498. editor: new Ext.grid.GridEditor(new Ext.form.TextField())
  499. }],
  500. tbar: [{
  501. text: '添加',
  502. iconCls: 'tb-add',
  503. handler: function() {
  504. var p = new Record({
  505. name: '',
  506. duedate: '',
  507. repeat: '',
  508. //duedatetime: '',
  509. classname: ''
  510. });
  511. this.addRecord(grid, p);
  512. },
  513. scope: this
  514. }, {
  515. text: '删除',
  516. iconCls: 'tb-delete',
  517. handler: function() {
  518. this.removeRecord(grid);
  519. },
  520. scope: this
  521. }]
  522. });
  523. tabPanel.add(grid);
  524. },
  525. getVariableData: function(model) {
  526. var data = [];
  527. var elements = model.dom.getElementsByTagName('variable');
  528. Gef.each(elements, function(item) {
  529. data.push({
  530. name: item.getAttribute('name'),
  531. type: item.getAttribute('type'),
  532. history: item.getAttribute('history'),
  533. init: item.getAttribute('init')
  534. });
  535. });
  536. return data;
  537. },
  538. resetVariable: function(tabPanel, model) {
  539. var data = this.getVariableData(model);
  540. var Record = Ext.data.Record.create([
  541. 'name',
  542. 'type',
  543. 'history',
  544. 'init'
  545. ]);
  546. var store = new Ext.data.JsonStore({
  547. fields: Record,
  548. data: data,
  549. listeners: {
  550. add: function(store, records, index) {
  551. var record = records[0];
  552. var variableDom = new Gef.model.Dom('variable');
  553. variableDom.setAttribute('name', record.get('duedate'));
  554. variableDom.setAttribute('type', record.get('type'));
  555. variableDom.setAttribute('history', record.get('history'));
  556. variableDom.setAttribute('init', record.get('init'));
  557. model.dom.addElement(variableDom);
  558. },
  559. remove: function(store, record, index) {
  560. var elements = model.dom.getElementsByTagName('variable');
  561. var element = elements[index];
  562. model.dom.elements.remove(element);
  563. },
  564. update: function(store, record, operation) {
  565. var index = store.indexOf(record);
  566. var elements = model.dom.getElementsByTagName('variable');
  567. var element = elements[index];
  568. element.setAttribute('name', record.get('name'));
  569. element.setAttribute('type', record.get('type'));
  570. element.setAttribute('init', record.get('history'));
  571. element.setAttribute('history', record.get('init'));
  572. this.commitChanges();
  573. }
  574. }
  575. });
  576. var grid = new Ext.grid.EditorGridPanel({
  577. title: '变量设置',
  578. store: store,
  579. viewConfig: {
  580. forceFit: true
  581. },
  582. columns: [{
  583. header: '变量名',
  584. dataIndex: 'name',
  585. editor: new Ext.grid.GridEditor(new Ext.form.TextField())
  586. }, {
  587. header: '变量类型',
  588. dataIndex: 'type',
  589. editor: new Ext.grid.GridEditor(new Ext.form.TextField())
  590. }, {
  591. header: '是否保存历史',
  592. dataIndex: 'history',
  593. editor: new Ext.grid.GridEditor(new Ext.ux.OneCombo({
  594. data: ['true', 'false']
  595. }))
  596. }, {
  597. header: '初始值',
  598. dataIndex: 'init',
  599. editor: new Ext.grid.GridEditor(new Ext.form.TextField())
  600. }],
  601. tbar: [{
  602. text: '添加',
  603. iconCls: 'tb-add',
  604. handler: function() {
  605. var p = new Record({
  606. name: '',
  607. type: ''
  608. });
  609. grid.stopEditing();
  610. grid.getStore().insert(0, p);
  611. grid.startEditing(0, 0);
  612. }
  613. }, {
  614. text: '删除',
  615. iconCls: 'tb-delete',
  616. handler: function() {
  617. Ext.Msg.confirm('信息', '确定删除?', function(btn){
  618. if (btn == 'yes') {
  619. var sm = grid.getSelectionModel();
  620. var cell = sm.getSelectedCell();
  621. var record = grid.getStore().getAt(cell[0]);
  622. grid.getStore().remove(record);
  623. }
  624. });
  625. }
  626. }]
  627. });
  628. tabPanel.add(grid);
  629. },
  630. addRecord: function(grid, record) {
  631. grid.stopEditing();
  632. var index = grid.getStore().getCount();
  633. grid.getStore().insert(index, record);
  634. grid.startEditing(index, 0);
  635. },
  636. removeRecord: function(grid) {
  637. Ext.Msg.confirm('信息', '确定删除?', function(btn) {
  638. if (btn != 'yes') {
  639. return;
  640. }
  641. var sm = grid.getSelectionModel();
  642. var cell = sm.getSelectedCell();
  643. var record = grid.getStore().getAt(cell[0]);
  644. grid.getStore().remove(record);
  645. });
  646. }
  647. });
  648. Ext.ns('App.form');
  649. App.form.CustomForm = Ext.extend(App.form.AbstractForm, {
  650. decorate: function(tabPanel, model) {
  651. this.clearItem(tabPanel);
  652. this.resetBasic(tabPanel, model);
  653. this.resetParticipant(tabPanel, model);
  654. //this.resetEvent(tabPanel, model);
  655. },
  656. resetBasic: function(tabPanel, model) {
  657. var p = new Ext.form.FormPanel({
  658. title: '基本配置',
  659. labelWidth: 70,
  660. labelAlign: 'right',
  661. border: false,
  662. defaultType: 'textfield',
  663. defaults: {
  664. anchor: '90%'
  665. },
  666. bodyStyle: {
  667. padding: '6px 0 0'
  668. },
  669. items: [{
  670. name: 'name',
  671. fieldLabel: '名称',
  672. value: model.text ? model.text : '',
  673. listeners: {
  674. 'blur': function(field) {
  675. var newValue = field.getValue();
  676. // FIXME: use command
  677. model.text = newValue;
  678. model.editPart.figure.updateAndShowText(newValue);
  679. }
  680. }
  681. },{
  682. name: 'description',
  683. fieldLabel: '备注',
  684. xtype: 'textarea',
  685. value: model.dom.getElementContent('description'),
  686. listeners: {
  687. 'blur': function(field) {
  688. var newValue = field.getValue();
  689. model.dom.setElementContent('description', newValue);
  690. }
  691. }
  692. }]
  693. });
  694. tabPanel.add(p);
  695. tabPanel.activate(p);
  696. }
  697. });
  698. App.form.ProcessForm = Ext.extend(App.form.AbstractForm, {
  699. decorate: function(tabPanel, model) {
  700. this.clearItem(tabPanel);
  701. this.resetBasic(tabPanel, model);
  702. },
  703. resetBasic: function(tabPanel, model) {
  704. var cstore = new Ext.data.SimpleStore({
  705. fields : ["value"],
  706. data : [["是"],["否"]]
  707. });
  708. var k=model.dom.getAttribute("data");
  709. if(k.length==0){
  710. var combo = new Ext.form.ComboBox({
  711. name:'pr_enabled',
  712. fieldLabel:'启用',
  713. editable:false,
  714. allowBlanmodel: false,
  715. store:cstore,
  716. value:model.pr_enabled?model.pr_enabled:'',
  717. valueField : "value",
  718. displayField : "value",
  719. mode : "local",
  720. triggerAction : "all",
  721. listeners:{
  722. 'blur':function(field){
  723. var newValue=field.getValue();
  724. model.pr_enabled=newValue;
  725. }
  726. }
  727. });
  728. var p = new Ext.form.FormPanel({
  729. id:'FirstForm',
  730. title: '基本配置',
  731. labelWidth: 70,
  732. labelAlign: 'right',
  733. border: false,
  734. defaultType: 'textfield',
  735. defaults: {
  736. anchor: '90%'
  737. },
  738. bodyStyle: {
  739. padding: '6px 0 0'
  740. },
  741. items: [{
  742. name: 'pr_defname',
  743. fieldLabel: '流程名称',
  744. allowBlanmodel: false,
  745. value: model.pr_defname ? model.pr_defname : '',
  746. listeners: {
  747. 'blur': function(field) {
  748. var newValue = field.getValue();
  749. model.pr_defname = newValue;
  750. }}
  751. },{
  752. name: 'pr_caller',
  753. fieldLabel: '流程CALLER',
  754. allowBlanmodel: false,
  755. value: model.pr_caller?model.pr_caller:'',
  756. listeners: {
  757. 'blur': function(field) {
  758. var newValue = field.getValue();
  759. // console.log(model);
  760. model.pr_caller = newValue;
  761. },
  762. 'beforerender':function(field){
  763. var condition=getUrlParam('formCondition');
  764. if(condition){
  765. field.setValue(condition.split("IS")[1]);
  766. }
  767. }
  768. }
  769. },combo, {
  770. name: 'pr_descn',
  771. fieldLabel: '备注',
  772. xtype: 'textarea',
  773. //value: model.dom.getElementContent('description'),//设置。。
  774. value:model.pr_descn ? model.pr_descn:'',
  775. listeners: {
  776. 'blur': function(field) {
  777. var newValue = field.getValue();
  778. model.dom.setElementContent('description', newValue);
  779. var a=model;
  780. model.pr_descn=newValue;
  781. }
  782. }
  783. }]
  784. });
  785. }else{
  786. var combo = new Ext.form.ComboBox({
  787. name:'pr_enabled',
  788. fieldLabel:'启用',
  789. editable:false,
  790. allowBlanmodel: false,
  791. store:cstore,
  792. value:k.pr_enabled?k.pr_enabled:'',
  793. valueField : "value",
  794. displayField : "value",
  795. mode : "local",
  796. triggerAction : "all",
  797. listeners:{
  798. 'blur':function(field){
  799. var newValue=field.getValue();
  800. k.pr_enabled=newValue;
  801. }
  802. }
  803. });
  804. var p = new Ext.form.FormPanel({
  805. id:'FirstForm',
  806. title: '基本配置',
  807. labelWidth: 70,
  808. labelAlign: 'right',
  809. border: false,
  810. defaultType: 'textfield',
  811. defaults: {
  812. anchor: '90%'
  813. },
  814. bodyStyle: {
  815. padding: '6px 0 0'
  816. },
  817. items: [{
  818. name: 'pr_defname',
  819. fieldLabel: '流程名称',
  820. allowBlank: false,
  821. value: k.pr_defname ? k.pr_defname : '',
  822. listeners: {
  823. 'blur': function(field) {
  824. var newValue = field.getValue();
  825. k.pr_defname = newValue;
  826. }
  827. }
  828. },{
  829. name: 'pr_caller',
  830. fieldLabel: '流程对应表单(caller)',
  831. allowBlank: false,
  832. value: k.pr_caller?k.pr_caller:'',
  833. listeners: {
  834. 'blur': function(field) {
  835. var newValue = field.getValue();
  836. k.pr_caller = newValue;
  837. },
  838. 'afterrender':function(field){
  839. alert(getUrlParam('formCondition'));
  840. }
  841. }
  842. },combo,{
  843. name: 'pr_descn',
  844. fieldLabel: '备注',
  845. xtype: 'textarea',
  846. //value: model.dom.getElementContent('description'),//设置。。
  847. value: k.pr_descn ? k.pr_descn : '',
  848. listeners: {
  849. 'blur': function(field) {
  850. var newValue = field.getValue();
  851. model.dom.setElementContent('description', newValue);
  852. var a=model;
  853. k.pr_descn=newValue;
  854. }
  855. }
  856. }]
  857. });
  858. }
  859. tabPanel.add(p);
  860. tabPanel.activate(p);
  861. }
  862. });
  863. Ext.ns('App.form');
  864. App.form.TransitionForm = Ext.extend(App.form.AbstractForm, {
  865. id:'transitionform',
  866. eventNames: [
  867. ['take', '进入']
  868. ],
  869. decorate: function(tabPanel, model) {
  870. this.clearItem(tabPanel);
  871. this.resetBasic(tabPanel, model);
  872. this.resetEvent(tabPanel, model);
  873. this.resetTimer(tabPanel, model);
  874. },
  875. resetBasic: function(tabPanel, model) {
  876. var condition = model.dom.getElementAttribute('condition', 'expr');
  877. if (condition != '') {
  878. condition = condition.replace(/&lt;/g, '<')
  879. .replace(/&amp;/g, '&');
  880. }
  881. var items = [];
  882. items.push({
  883. name: 'name',
  884. fieldLabel: '名称',
  885. value: model.text ? model.text : '',
  886. listeners: {
  887. 'blur': function(field) {
  888. var newValue = field.getValue();
  889. // FIXME: use command
  890. if(model.getSource().type == 'task'){
  891. if(newValue!="同意"&&newValue!="不同意"){
  892. alert("任务节点的流出连线名称必须为“同意”或“不同意!”");
  893. field.focus();
  894. }
  895. }
  896. model.text = newValue;
  897. model.editPart.figure.updateAndShowText(newValue);
  898. }
  899. }
  900. });
  901. if (model.getSource().type == 'decision') {
  902. items.push({
  903. name: 'condition',
  904. fieldLabel: '条件',
  905. // <condition expr="#{ACCOUNT&gt;=10000}"/>
  906. value: condition,
  907. listeners: {
  908. 'blur': function(field) {
  909. var newValue = field.getValue();
  910. if (newValue != '') {
  911. model.dom.setElementAttribute('condition', 'expr', newValue);
  912. } else if (model.dom.elements.length > 0) {
  913. model.dom.removeElement(model.dom.elements[0]);
  914. }
  915. }
  916. }
  917. });
  918. }
  919. var p = new Ext.form.FormPanel({
  920. title: '基本配置',
  921. labelWidth: 70,
  922. labelAlign: 'right',
  923. border: false,
  924. defaultType: 'textfield',
  925. defaults: {
  926. anchor: '90%'
  927. },
  928. bodyStyle: {
  929. padding: '6px 0 0'
  930. },
  931. items: items
  932. });
  933. tabPanel.add(p);
  934. tabPanel.activate(p);
  935. },
  936. getTimerData: function(model) {
  937. var data = [];
  938. var elements = model.dom.getElementsByTagName('timer');
  939. Gef.each(elements, function(elem) {
  940. data.push({
  941. duedate: timerElem.getAttribute('duedate')
  942. });
  943. });
  944. return data;
  945. },
  946. resetTimer: function(tabPanel, model) {
  947. var data = this.getTimerData(model);
  948. var Record = Ext.data.Record.create([
  949. 'duedate'
  950. ]);
  951. var store = new Ext.data.JsonStore({
  952. fields: Record,
  953. data: data,
  954. listeners: {
  955. add: function(store, records, index) {
  956. var record = records[0];
  957. var timerDom = new Gef.model.Dom('timer');
  958. timerDom.setAttribute('duedate', record.get('duedate'));
  959. model.dom.addElement(timerDom);
  960. },
  961. remove: function(store, record, index) {
  962. var element = model.dom.getElementByTagName('timer');
  963. model.dom.elements.remove(element);
  964. },
  965. update: function(store, record, operation) {
  966. var index = store.indexOf(record);
  967. var element = model.dom.getElementByTagName('timer');
  968. element.setAttribute('duedate', record.get('duedate'));
  969. this.commitChanges();
  970. }
  971. }
  972. });
  973. var grid = new Ext.grid.EditorGridPanel({
  974. title: '定时器配置',
  975. xtype: 'editorgrid',
  976. store: store,
  977. viewConfig: {
  978. forceFit: true
  979. },
  980. columns: [{
  981. header: '持续日期',
  982. dataIndex: 'duedate',
  983. editor: new Ext.grid.GridEditor(new Ext.form.TextField())
  984. }/*, {
  985. header: '持续时间',
  986. dataIndex: 'duedatetime',
  987. editor: new Ext.grid.GridEditor(new Ext.form.TextField())
  988. }*/],
  989. tbar: [{
  990. text: '添加',
  991. iconCls: 'tb-add',
  992. handler: function() {
  993. var count = grid.getStore().getCount();
  994. if (count > 0) {
  995. Ext.Msg.alert('info', '连线上只能设置一个定时器');
  996. return;
  997. }
  998. var p = new Record({
  999. name: '',
  1000. duedate: '',
  1001. repeat: '',
  1002. //duedatetime: '',
  1003. classname: ''
  1004. });
  1005. grid.stopEditing();
  1006. var index = grid.getStore().getCount();
  1007. grid.getStore().insert(index, p);
  1008. grid.startEditing(index, 0);
  1009. }
  1010. }, {
  1011. text: '删除',
  1012. iconCls: 'tb-delete',
  1013. handler: function() {
  1014. Ext.Msg.confirm('信息', '确定删除?', function(btn){
  1015. if (btn == 'yes') {
  1016. var sm = grid.getSelectionModel();
  1017. var cell = sm.getSelectedCell();
  1018. var record = grid.getStore().getAt(cell[0]);
  1019. grid.getStore().remove(record);
  1020. }
  1021. });
  1022. }
  1023. }]
  1024. });
  1025. tabPanel.add(grid);
  1026. }
  1027. });