Kpitoolbar.js 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965
  1. /**
  2. * 此toolbar用于明细表grid
  3. */
  4. Ext.define('erp.view.hr.kpi.Kpitoolbar', {
  5. extend : 'Ext.Toolbar',
  6. alias : 'widget.Kpitoolbar',
  7. FormUtil: Ext.create('erp.util.FormUtil'),
  8. BaseUtil: Ext.create('erp.util.BaseUtil'),
  9. GridUtil: Ext.create('erp.util.GridUtil'),
  10. dock : 'top',
  11. requires : ['erp.view.core.trigger.DbfindTrigger','erp.view.hr.kpi.KpiPanel'],
  12. initComponent : function() {
  13. var me=this;
  14. var f=this.id;
  15. Ext.apply(this, {
  16. items : [{
  17. xtype : 'tbtext',
  18. text : '基础数据'
  19. },{
  20. xtype:'button',
  21. iconCls: 'x-button-icon-add',
  22. cls: 'x-btn-gray',
  23. id:f+"-KpiAdd",
  24. text: '添加',
  25. width: 60,
  26. style: {
  27. marginLeft: '10px'
  28. },
  29. listeners: {
  30. click:function(btn){
  31. var form=btn.ownerCt.ownerCt.ownerCt.previousSibling();
  32. var k=form.keyField;
  33. var fid=Ext.getCmp(k).value;
  34. if(!fid){
  35. showError("请先保存");
  36. }else{
  37. var grid=btn.ownerCt.ownerCt;
  38. var caller=grid.id;
  39. if(caller=='grid'){
  40. caller='KpidesignItem';
  41. }
  42. var win;
  43. var formCondition='';
  44. if(caller=='KpidesignItem'){
  45. win =new Ext.window.Window({
  46. id: 'kpi-win1',
  47. title: '考核项目维护',
  48. height:350,
  49. width: 1000,
  50. layout:'fit',
  51. resizable:false,
  52. defaults: {
  53. anchor: '100%'
  54. },
  55. items:[{
  56. xtype: 'erpKpiPanel',
  57. id:'kpi-form',
  58. anchor: '100% 50%',
  59. fixedlayout:true,
  60. caller:'KpidesignItem',
  61. formCondition:formCondition,
  62. saveUrl: 'hr/kpi/saveDetail.action?caller=' +caller,
  63. updateUrl:'hr/kpi/updateDetail.action?caller=' +caller,
  64. deleteUrl: 'hr/kpi/deleteDetail.action?caller=' +caller,
  65. getIdUrl: 'common/getCommonId.action?caller=' +caller,
  66. keyField: '',
  67. codeField: '',
  68. buttons: [{
  69. text:'保存',
  70. cls: 'x-btn-gray',
  71. handler: function(btn) {
  72. Ext.getCmp('ki_kdid').setValue(Ext.getCmp('kd_id').value);
  73. var bool=me.checkScore();
  74. if(bool!=false){
  75. me.beforeSave();
  76. }
  77. }
  78. }, {
  79. text: $I18N.common.button.erpCloseButton,
  80. cls: 'x-btn-gray',
  81. handler: function(btn) {
  82. btn.ownerCt.ownerCt.ownerCt.close();
  83. }
  84. }]
  85. }],
  86. listeners:{
  87. 'beforeclose':function(view ,opt){
  88. //grid 刷新一次
  89. var grid=Ext.getCmp('grid');
  90. var fid=Ext.getCmp('kd_id').value;
  91. var gridParam = {caller: 'Kpidesign', condition: 'ki_kdid='+fid};
  92. grid.GridUtil.loadNewStore(grid,gridParam);
  93. }
  94. }
  95. });
  96. }else if(caller=='KpidesigngradeLevel_F'){
  97. win =new Ext.window.Window({
  98. id: 'kpi-win2',
  99. title: '评分等级维护',
  100. height: 200,
  101. width: 400,
  102. layout:'fit',
  103. resizable:false,
  104. defaults: {
  105. anchor: '100%'
  106. },
  107. items:[{
  108. xtype:'form',
  109. id:'kpi-form',
  110. baseCls : "x-plain",
  111. getIdUrl: 'common/getId.action?seq=KpidesigngradeLevel_SEQ',
  112. updateUrl:'hr/kpi/updateDetail.action?caller=' +caller,
  113. saveUrl: 'hr/kpi/saveDetail.action?caller=KpidesigngradeLevel_F',
  114. buttonAlign: 'center',
  115. keyField:'kl_id',
  116. margin:'10 10 10 10',
  117. layout: {
  118. type: 'vbox',
  119. align: 'center'
  120. },
  121. defaults:{
  122. bodyStyle:'padding:10 10 10 10'
  123. },
  124. items: [{
  125. xtype: 'hidden',
  126. fieldLabel: 'ID',
  127. name:'kl_id',
  128. id:'kl_id',
  129. allowBlank: false,
  130. value: ''
  131. },{
  132. xtype: 'hidden',
  133. fieldLabel: '关联主表',
  134. name:'kl_kdid',
  135. id:'kl_kdid',
  136. value: ''
  137. },{
  138. xtype: 'hidden',
  139. fieldLabel: '序号',
  140. name:'kl_detno',
  141. id:'kl_detno',
  142. value: ''
  143. },{
  144. xtype: 'dbfindtrigger',
  145. fieldLabel: '名称',
  146. name:'kl_name',
  147. id:'kl_name',
  148. allowBlank: false,
  149. labelStyle:'color:#FF0000',
  150. fieldStyle: 'background:#E0E0FF;color:#515151',
  151. value: ''
  152. },{
  153. xtype: 'numberfield',
  154. fieldLabel: '最低分',
  155. name:'kl_score_from',
  156. id:'kl_score_from',
  157. labelStyle:'color:#FF0000',
  158. fieldStyle: 'background:#E0E0FF;color:#515151',
  159. allowBlank: false,
  160. maxValue :100,
  161. minValue:0,
  162. value: ''
  163. },{
  164. xtype: 'numberfield',
  165. fieldLabel: '最高分',
  166. labelStyle:'color:#FF0000',
  167. allowBlank: false,
  168. name:'kl_score_to',
  169. fieldStyle: 'background:#E0E0FF;color:#515151',
  170. id:'kl_score_to',
  171. maxValue :100,
  172. minValue:0,
  173. value: ''
  174. }],
  175. buttons: [{
  176. text:'保存',
  177. cls: 'x-btn-gray',
  178. handler: function(btn) {
  179. Ext.getCmp('kl_kdid').setValue(Ext.getCmp('kd_id').value);
  180. me.beforeSave(btn);
  181. }
  182. }, {
  183. text: $I18N.common.button.erpCloseButton,
  184. cls: 'x-btn-gray',
  185. handler: function(btn) {
  186. btn.ownerCt.ownerCt.ownerCt.close();
  187. }
  188. }]
  189. }],
  190. listeners:{
  191. 'beforeclose':function(view ,opt){
  192. //grid 刷新一次
  193. var grid=Ext.getCmp('KpidesigngradeLevel_F');
  194. var fid=Ext.getCmp('kd_id').value;
  195. var gridParam = {caller: 'KpidesigngradeLevel', condition: 'kl_kdid='+fid};
  196. grid.GridUtil.loadNewStore(grid,gridParam);
  197. }
  198. }
  199. });
  200. }else{
  201. win = new Ext.window.Window({
  202. id: 'kpi-win3',
  203. title: '评分设计维护',
  204. height:500,
  205. width: 1000,
  206. layout:'anchor',
  207. resizable:false,
  208. defaults: {
  209. anchor: '100%'
  210. },
  211. items:[{
  212. xtype: 'erpKpiPanel',
  213. id:'kpi-form',
  214. anchor: '100% 50%',
  215. fixedlayout:true,
  216. caller:'Kpidesignpoint_F',
  217. formCondition:'',
  218. saveUrl: 'hr/kpi/saveDetail.action?caller=' +caller,
  219. updateUrl:'hr/kpi/updateDetail.action?caller=' +caller,
  220. deleteUrl: 'hr/kpi/deleteDetail.action?caller=' +caller,
  221. getIdUrl: 'common/getCommonId.action?caller=' +caller,
  222. keyField: '',
  223. codeField: '',
  224. buttons: [{
  225. text:'保存',
  226. cls: 'x-btn-gray',
  227. handler: function(btn) {
  228. Ext.getCmp('kp_kdid').setValue(Ext.getCmp('kd_id').value);
  229. me.beforeSave(btn);
  230. }
  231. }, {
  232. text: $I18N.common.button.erpCloseButton,
  233. cls: 'x-btn-gray',
  234. handler: function(btn) {
  235. btn.ownerCt.ownerCt.ownerCt.close();
  236. }
  237. }]
  238. },{
  239. id:'kpi-grid',
  240. xtype: 'erpGridPanel2',
  241. selModel: {
  242. injectCheckbox: 0,
  243. mode: "MULTI", //"SINGLE"/"SIMPLE"/"MULTI"
  244. checkOnly: true //只能通过checkbox选择
  245. },
  246. condition:'ki_kdid ='+fid,
  247. caller:'Kpidesignpoint_F',
  248. selType: "checkboxmodel",
  249. bbar:[],
  250. anchor: '100% 50%'
  251. }],
  252. listeners:{
  253. 'beforeclose':function(view ,opt){
  254. //grid 刷新一次
  255. var grid=Ext.getCmp('Kpidesignpoint_F');
  256. var fid=Ext.getCmp('kd_id').value;
  257. var gridParam = {caller: 'Kpidesignpoint', condition: 'kp_kdid='+fid};
  258. grid.GridUtil.loadNewStore(grid,gridParam);
  259. }
  260. }
  261. });
  262. }
  263. win.show();
  264. }
  265. }
  266. }
  267. },{
  268. xtype:'button',
  269. iconCls: 'x-button-icon-submit',
  270. cls: 'x-btn-gray',
  271. id:f+"-KpiUpdate",
  272. text: '修改',
  273. disabled:true,
  274. width: 60,
  275. style: {
  276. marginLeft: '10px'
  277. },
  278. handler: function(btn){
  279. var grid=btn.ownerCt.ownerCt;
  280. var records = grid.selModel.getSelection();
  281. if(records.length > 0){
  282. var fid=Ext.getCmp('kd_id').value;
  283. var grid=btn.ownerCt.ownerCt;
  284. var caller=grid.id;
  285. if(caller=='grid'){
  286. caller='KpidesignItem';
  287. }
  288. var win;
  289. var formCondition='';
  290. if(caller=='KpidesignItem'){
  291. formCondition='ki_id='+records[0].data['ki_id'];
  292. win =new Ext.window.Window({
  293. id: 'kpi-win1',
  294. title: '考核项目维护',
  295. height:350,
  296. width: 1000,
  297. layout:'fit',
  298. resizable:false,
  299. defaults: {
  300. anchor: '100%'
  301. },
  302. items:[{
  303. xtype: 'erpKpiPanel',
  304. id:'kpi-form',
  305. anchor: '100% 50%',
  306. fixedlayout:true,
  307. caller:'KpidesignItem',
  308. formCondition:formCondition,
  309. saveUrl: 'hr/kpi/saveDetail.action?caller=' +caller,
  310. updateUrl:'hr/kpi/updateDetail.action?caller=' +caller,
  311. deleteUrl: 'hr/kpi/deleteDetail.action?caller=' +caller,
  312. getIdUrl: 'common/getCommonId.action?caller=' +caller,
  313. keyField: '',
  314. codeField: '',
  315. buttons: [{
  316. text:'更新',
  317. cls: 'x-btn-gray',
  318. handler: function(btn) {
  319. Ext.getCmp('ki_kdid').setValue(Ext.getCmp('kd_id').value);
  320. var bool=me.checkScore();
  321. if(bool!=false){
  322. me.beforeUpdate();
  323. }
  324. }
  325. }, {
  326. text: $I18N.common.button.erpCloseButton,
  327. cls: 'x-btn-gray',
  328. handler: function(btn) {
  329. btn.ownerCt.ownerCt.ownerCt.close();
  330. }
  331. }]
  332. }],
  333. listeners:{
  334. 'beforeclose':function(view ,opt){
  335. //grid 刷新一次
  336. var grid=Ext.getCmp('grid');
  337. var fid=Ext.getCmp('kd_id').value;
  338. var gridParam = {caller: 'Kpidesign', condition: 'ki_kdid='+fid};
  339. grid.GridUtil.loadNewStore(grid,gridParam);
  340. }
  341. }
  342. });
  343. }else if(caller=='KpidesigngradeLevel_F'){
  344. win =new Ext.window.Window({
  345. id: 'kpi-win2',
  346. title: '评分等级维护',
  347. height: 200,
  348. width: 400,
  349. layout:'fit',
  350. resizable:false,
  351. defaults: {
  352. anchor: '100%'
  353. },
  354. items:[{
  355. xtype:'form',
  356. id:'kpi-form',
  357. baseCls : "x-plain",
  358. getIdUrl: 'common/getId.action?seq=KpidesigngradeLevel_SEQ',
  359. updateUrl:'hr/kpi/updateDetail.action?caller=' +caller,
  360. saveUrl: 'hr/kpi/saveDetail.action?caller=KpidesigngradeLevel_F',
  361. buttonAlign: 'center',
  362. keyField:'kl_id',
  363. margin:'10 10 10 10',
  364. layout: {
  365. type: 'vbox',
  366. align: 'center'
  367. },
  368. defaults:{
  369. bodyStyle:'padding:10 10 10 10'
  370. },
  371. items: [{
  372. xtype: 'hidden',
  373. fieldLabel: 'ID',
  374. name:'kl_id',
  375. id:'kl_id',
  376. allowBlank: false,
  377. value: records[0].data['kl_id']
  378. },{
  379. xtype: 'hidden',
  380. fieldLabel: '关联主表',
  381. name:'kl_kdid',
  382. id:'kl_kdid',
  383. value: records[0].data['kl_kdid']
  384. },{
  385. xtype: 'hidden',
  386. fieldLabel: '序号',
  387. name:'kl_detno',
  388. id:'kl_detno',
  389. value: records[0].data['kl_detno']
  390. },{
  391. xtype: 'dbfindtrigger',
  392. fieldLabel: '名称',
  393. name:'kl_name',
  394. id:'kl_name',
  395. allowBlank: false,
  396. labelStyle:'color:#FF0000',
  397. fieldStyle: 'background:#E0E0FF;color:#515151',
  398. value: records[0].data['kl_name']
  399. },{
  400. xtype: 'numberfield',
  401. fieldLabel: '最低分',
  402. name:'kl_score_from',
  403. id:'kl_score_from',
  404. labelStyle:'color:#FF0000',
  405. fieldStyle: 'background:#E0E0FF;color:#515151',
  406. allowBlank: false,
  407. value: records[0].data['kl_score_from']
  408. },{
  409. xtype: 'numberfield',
  410. fieldLabel: '最高分',
  411. labelStyle:'color:#FF0000',
  412. allowBlank: false,
  413. name:'kl_score_to',
  414. fieldStyle: 'background:#E0E0FF;color:#515151',
  415. id:'kl_score_to',
  416. value: records[0].data['kl_score_to']
  417. }],
  418. buttons: [{
  419. text:'更新',
  420. cls: 'x-btn-gray',
  421. handler: function(btn) {
  422. Ext.getCmp('kl_kdid').setValue(Ext.getCmp('kd_id').value);
  423. me.beforeUpdate(btn);
  424. }
  425. }, {
  426. text: $I18N.common.button.erpCloseButton,
  427. cls: 'x-btn-gray',
  428. handler: function(btn) {
  429. btn.ownerCt.ownerCt.ownerCt.close();
  430. }
  431. }]
  432. }],
  433. listeners:{
  434. 'beforeclose':function(view ,opt){
  435. //grid 刷新一次
  436. var grid=Ext.getCmp('KpidesigngradeLevel_F');
  437. var fid=Ext.getCmp('kd_id').value;
  438. var gridParam = {caller: 'KpidesigngradeLevel', condition: 'kl_kdid='+fid};
  439. grid.GridUtil.loadNewStore(grid,gridParam);
  440. }
  441. }
  442. });
  443. }else{
  444. formCondition='kp_id='+records[0].data['kp_id'];
  445. win = new Ext.window.Window({
  446. id: 'kpi-win3',
  447. title: '评分设计维护',
  448. height:500,
  449. width: 1000,
  450. layout:'anchor',
  451. resizable:false,
  452. defaults: {
  453. anchor: '100%'
  454. },
  455. items:[{
  456. xtype: 'erpKpiPanel',
  457. id:'kpi-form',
  458. anchor: '100% 50%',
  459. fixedlayout:true,
  460. caller:'Kpidesignpoint_F',
  461. formCondition:formCondition,
  462. saveUrl: 'hr/kpi/saveDetail.action?caller=' +caller,
  463. updateUrl:'hr/kpi/updateDetail.action?caller=' +caller,
  464. deleteUrl: 'hr/kpi/deleteDetail.action?caller=' +caller,
  465. getIdUrl: 'common/getCommonId.action?caller=' +caller,
  466. keyField: '',
  467. codeField: '',
  468. buttons: [{
  469. text:'更新',
  470. cls: 'x-btn-gray',
  471. handler: function(btn) {
  472. Ext.getCmp('kp_kdid').setValue(Ext.getCmp('kd_id').value);
  473. me.beforeUpdate(btn);
  474. }
  475. }, {
  476. text: $I18N.common.button.erpCloseButton,
  477. cls: 'x-btn-gray',
  478. handler: function(btn) {
  479. btn.ownerCt.ownerCt.ownerCt.close();
  480. }
  481. }]
  482. },{
  483. id:'kpi-grid',
  484. xtype: 'erpGridPanel2',
  485. selModel: {
  486. injectCheckbox: 0,
  487. mode: "MULTI", //"SINGLE"/"SIMPLE"/"MULTI"
  488. checkOnly: true //只能通过checkbox选择
  489. },
  490. condition:'ki_kdid ='+fid,
  491. caller:'Kpidesignpoint_F',
  492. selType: "checkboxmodel",
  493. bbar:[],
  494. anchor: '100% 50%'
  495. }],
  496. listeners:{
  497. 'beforeclose':function(view ,opt){
  498. //grid 刷新一次
  499. var grid=Ext.getCmp('Kpidesignpoint_F');
  500. var fid=Ext.getCmp('kd_id').value;
  501. var gridParam = {caller: 'Kpidesignpoint', condition: 'kp_kdid='+fid};
  502. grid.GridUtil.loadNewStore(grid,gridParam);
  503. }
  504. }
  505. });
  506. }
  507. win.show();
  508. }else{
  509. showError("请选择明细行");
  510. }
  511. }
  512. },{
  513. xtype:'button',
  514. iconCls: 'x-button-icon-close',
  515. cls: 'x-btn-gray',
  516. id:f+"-KpiDel",
  517. text: '删除',
  518. disabled:true,
  519. width: 60,
  520. style: {
  521. marginLeft: '10px'
  522. },
  523. handler: function(btn){
  524. var grid=btn.ownerCt.ownerCt;
  525. var records = grid.selModel.getSelection();
  526. var caller=grid.id;
  527. if(caller=='grid'){
  528. caller='KpidesignItem';
  529. }
  530. var id=0;
  531. var fid=Ext.getCmp('kd_id').value;
  532. var gridParam = {};
  533. if(records.length > 0){
  534. if(caller=='KpidesignItem'){
  535. id=records[0].data['ki_id'];
  536. gridParam = {caller: 'Kpidesign', condition: 'ki_kdid='+fid};
  537. }else if(caller=='KpidesigngradeLevel_F'){
  538. id=records[0].data['kl_id'];
  539. gridParam = {caller: 'KpidesigngradeLevel', condition: 'kl_kdid='+fid};
  540. }else{
  541. id=records[0].data['kp_id'];
  542. gridParam = {caller: 'Kpidesignpoint', condition: 'kp_kdid='+fid};
  543. }
  544. warnMsg($I18N.common.msg.ask_del, function(btn){
  545. if(btn == 'yes'){
  546. Ext.Ajax.request({
  547. url : basePath + 'hr/kpi/deleteDetail.action?caller=' +caller,
  548. params: {
  549. id: id
  550. },
  551. method : 'post',
  552. callback : function(options,success,response){
  553. var localJson = new Ext.decode(response.responseText);
  554. if(localJson.exceptionInfo){
  555. showError(localJson.exceptionInfo);return;
  556. }
  557. if(localJson.success){
  558. Ext.Msg.alert('提示','删除成功',function(){
  559. grid.GridUtil.loadNewStore(grid,gridParam);
  560. });
  561. } else {
  562. delFailure();
  563. }
  564. }
  565. });
  566. }
  567. });
  568. }else{
  569. }
  570. }
  571. },{
  572. xtype:'button',
  573. iconCls: 'x-button-icon-save',
  574. cls: 'x-btn-gray',
  575. id:f+"-KpiLook",
  576. text: '查看',
  577. width: 60,
  578. style: {
  579. marginLeft: '10px'
  580. },
  581. handler: function(btn){
  582. var grid=btn.ownerCt.ownerCt;
  583. var records = grid.selModel.getSelection();
  584. if(records.length > 0){
  585. var fid=Ext.getCmp('kd_id').value;
  586. var grid=btn.ownerCt.ownerCt;
  587. var caller=grid.id;
  588. if(caller=='grid'){
  589. caller='KpidesignItem';
  590. }
  591. var win;
  592. var formCondition='';
  593. if(caller=='KpidesignItem'){
  594. formCondition='ki_id='+records[0].data['ki_id'];
  595. win =new Ext.window.Window({
  596. id: 'kpi-win1',
  597. title: '考核项目',
  598. height:350,
  599. width: 1000,
  600. layout:'fit',
  601. resizable:false,
  602. defaults: {
  603. anchor: '100%'
  604. },
  605. items:[{
  606. xtype: 'erpKpiPanel',
  607. id:'kpi-form',
  608. anchor: '100% 50%',
  609. fixedlayout:true,
  610. caller:'KpidesignItem',
  611. formCondition:formCondition,
  612. keyField: '',
  613. codeField: '',
  614. buttons: [{
  615. text: $I18N.common.button.erpCloseButton,
  616. cls: 'x-btn-gray',
  617. handler: function(btn) {
  618. btn.ownerCt.ownerCt.ownerCt.close();
  619. }
  620. }]
  621. }]
  622. });
  623. }else if(caller=='KpidesigngradeLevel_F'){
  624. win =new Ext.window.Window({
  625. id: 'kpi-win2',
  626. title: '评分等级',
  627. height: 200,
  628. width: 400,
  629. layout:'fit',
  630. resizable:false,
  631. defaults: {
  632. anchor: '100%'
  633. },
  634. items:[{
  635. xtype:'form',
  636. id:'kpi-form',
  637. baseCls : "x-plain",
  638. buttonAlign: 'center',
  639. keyField:'kl_id',
  640. margin:'10 10 10 10',
  641. layout: {
  642. type: 'vbox',
  643. align: 'center'
  644. },
  645. defaults:{
  646. bodyStyle:'padding:10 10 10 10'
  647. },
  648. items: [{
  649. xtype: 'hidden',
  650. fieldLabel: 'ID',
  651. name:'kl_id',
  652. id:'kl_id',
  653. allowBlank: false,
  654. value: records[0].data['kl_id']
  655. },{
  656. xtype: 'hidden',
  657. fieldLabel: '关联主表',
  658. name:'kl_kdid',
  659. id:'kl_kdid',
  660. value: records[0].data['kl_kdid']
  661. },{
  662. xtype: 'hidden',
  663. fieldLabel: '序号',
  664. name:'kl_detno',
  665. id:'kl_detno',
  666. value: records[0].data['kl_detno']
  667. },{
  668. xtype: 'dbfindtrigger',
  669. fieldLabel: '名称',
  670. name:'kl_name',
  671. id:'kl_name',
  672. allowBlank: false,
  673. labelStyle:'color:#FF0000',
  674. fieldStyle: 'background:#E0E0FF;color:#515151',
  675. value: records[0].data['kl_name']
  676. },{
  677. xtype: 'numberfield',
  678. fieldLabel: '最低分',
  679. name:'kl_score_from',
  680. id:'kl_score_from',
  681. labelStyle:'color:#FF0000',
  682. fieldStyle: 'background:#E0E0FF;color:#515151',
  683. allowBlank: false,
  684. value: records[0].data['kl_score_from']
  685. },{
  686. xtype: 'numberfield',
  687. fieldLabel: '最高分',
  688. labelStyle:'color:#FF0000',
  689. allowBlank: false,
  690. name:'kl_score_to',
  691. fieldStyle: 'background:#E0E0FF;color:#515151',
  692. id:'kl_score_to',
  693. value: records[0].data['kl_score_to']
  694. }],
  695. buttons: [{
  696. text: $I18N.common.button.erpCloseButton,
  697. cls: 'x-btn-gray',
  698. handler: function(btn) {
  699. btn.ownerCt.ownerCt.ownerCt.close();
  700. }
  701. }]
  702. }]
  703. });
  704. }else{
  705. formCondition='kp_id='+records[0].data['kp_id'];
  706. win = new Ext.window.Window({
  707. id: 'kpi-win3',
  708. title: '评分设计',
  709. height:500,
  710. width: 1000,
  711. layout:'anchor',
  712. resizable:false,
  713. defaults: {
  714. anchor: '100%'
  715. },
  716. items:[{
  717. xtype: 'erpKpiPanel',
  718. id:'kpi-form',
  719. anchor: '100% 50%',
  720. fixedlayout:true,
  721. caller:'Kpidesignpoint_F',
  722. formCondition:formCondition,
  723. keyField: '',
  724. codeField: '',
  725. buttons: [{
  726. text: $I18N.common.button.erpCloseButton,
  727. cls: 'x-btn-gray',
  728. handler: function(btn) {
  729. btn.ownerCt.ownerCt.ownerCt.close();
  730. }
  731. }]
  732. },{
  733. id:'kpi-grid',
  734. xtype: 'erpGridPanel2',
  735. selModel: {
  736. injectCheckbox: 0,
  737. mode: "MULTI", //"SINGLE"/"SIMPLE"/"MULTI"
  738. checkOnly: true //只能通过checkbox选择
  739. },
  740. condition:'ki_kdid ='+fid,
  741. caller:'Kpidesignpoint_F',
  742. selType: "checkboxmodel",
  743. bbar:[],
  744. anchor: '100% 50%'
  745. }]
  746. });
  747. }
  748. win.show();
  749. }else{
  750. showError("请选择明细行");
  751. }
  752. }
  753. }]
  754. });
  755. this.callParent(arguments);
  756. },
  757. checkForm: function(){
  758. var s = '';
  759. var form = Ext.getCmp('kpi-form');
  760. form.getForm().getFields().each(function (item, index, length){
  761. if(!item.isValid()){
  762. if(s != ''){
  763. s += ',';
  764. }
  765. if(item.fieldLabel || item.ownerCt.fieldLabel){
  766. s += item.fieldLabel || item.ownerCt.fieldLabel;
  767. }
  768. }
  769. });
  770. if(s == ''){
  771. return true;
  772. }
  773. showError($I18N.common.form.necessaryInfo1 + '(<font color=green>' + s.replace(/&nbsp;/g,'') +
  774. '</font>)' + $I18N.common.form.necessaryInfo2);
  775. return false;
  776. },
  777. checkScore:function(){
  778. var a=Ext.getCmp('ki_score_from').value-0;//最低分
  779. var b=Ext.getCmp('ki_score_to').value-0;//最高分
  780. var c=Ext.getCmp('ki_standardscore').value-0;//标准分
  781. if(a>b){
  782. showError('起始分数不能大于截止分数');
  783. return false;
  784. }
  785. if(c<a||c>b){
  786. showError('标准分要在起始分数和截止分数之间');
  787. return false;
  788. }
  789. },
  790. beforeSave: function(){
  791. var me = this;
  792. var form = Ext.getCmp('kpi-form');
  793. if(!me.checkForm()){
  794. return;
  795. }
  796. if(Ext.getCmp(form.keyField).value == null || Ext.getCmp(form.keyField).value == ''){
  797. me.FormUtil.getSeqId(form);
  798. }
  799. var grid = Ext.getCmp('kpi-grid');
  800. var jsonGridData = new Array();
  801. if(grid) {
  802. var s=grid.selModel.getSelection();//获取多行
  803. var dd;
  804. for(var i=0;i<s.length;i++){//将grid里面各行的数据获取并拼成jsonGridData
  805. var data = s[i].data;
  806. dd = new Object();
  807. Ext.each(grid.columns, function(c){
  808. if((!c.isCheckerHd)&&(c.logic != 'ignore') && c.dataIndex){//只需显示,无需后台操作的字段,自动略去
  809. if(c.xtype == 'numbercolumn'){//赋个默认值0吧,不然不好保存
  810. if(data[c.dataIndex] == null || data[c.dataIndex] == '' || String(data[c.dataIndex]) == 'NaN'){
  811. dd[c.dataIndex] = '0';//也可以从data里面去掉这些字段
  812. } else {
  813. dd[c.dataIndex] = "" + s[i].data[c.dataIndex];
  814. }
  815. } else {
  816. dd[c.dataIndex] = s[i].data[c.dataIndex];
  817. }
  818. if (c.defaultValue && (dd[c.dataIndex] == null || dd[c.dataIndex] == '0')) {
  819. dd[c.dataIndex] = c.defaultValue;
  820. }
  821. }
  822. });
  823. if(grid.mainField && form && form.keyField){//例如,将pu_id的值赋给pd_puid
  824. dd[grid.mainField] = Ext.getCmp(form.keyField).value;
  825. }
  826. jsonGridData.push(Ext.JSON.encode(dd));
  827. }
  828. }
  829. param1 = jsonGridData == null ? [] : "[" + jsonGridData.toString().replace(/\\/g,"%") + "]";
  830. if(form.getForm().isValid()){
  831. Ext.each(form.items.items, function(item){
  832. if(item.xtype == 'numberfield'){
  833. if(item.value == null || item.value == ''){
  834. item.setValue(0);
  835. }
  836. }
  837. });
  838. var r = form.getValues();
  839. me.save(r, param1);
  840. }else{
  841. me.FormUtil.checkForm();
  842. }
  843. },
  844. save: function(){
  845. var params = new Object();
  846. var r = arguments[0];
  847. Ext.each(Ext.Object.getKeys(r), function(k){//去掉页面非表单定义字段
  848. if(contains(k, 'ext-', true)){
  849. delete r[k];
  850. }
  851. });
  852. params.formStore = unescape(Ext.JSON.encode(r).replace(/\\/g,"%"));
  853. params.param = unescape(arguments[1].toString().replace(/\\/g,"%"));
  854. var me = this;
  855. var form = Ext.getCmp('kpi-form');
  856. Ext.Ajax.request({
  857. url : basePath + form.saveUrl,
  858. params : params,
  859. method : 'post',
  860. callback : function(options,success,response){
  861. var localJson = new Ext.decode(response.responseText);
  862. if(localJson.success){
  863. Ext.Msg.alert('提示','添加成功',function(){
  864. form.ownerCt.close();
  865. });
  866. } else if(localJson.exceptionInfo){
  867. var str = localJson.exceptionInfo;
  868. showError(str);
  869. return;
  870. } else{
  871. saveFailure();//@i18n/i18n.js
  872. }
  873. }
  874. });
  875. },
  876. beforeUpdate: function(){
  877. var me = this;
  878. var form = Ext.getCmp('kpi-form');
  879. if(!me.checkForm){
  880. return;
  881. }
  882. if(Ext.getCmp(form.keyField).value == null || Ext.getCmp(form.keyField).value == ''){
  883. me.FormUtil.getSeqId(form);
  884. }
  885. var grid = Ext.getCmp('kpi-grid');
  886. var jsonGridData = new Array();
  887. if(grid) {
  888. var s=grid.selModel.getSelection();//获取多行
  889. var dd;
  890. for(var i=0;i<s.length;i++){//将grid里面各行的数据获取并拼成jsonGridData
  891. var data = s[i].data;
  892. dd = new Object();
  893. Ext.each(grid.columns, function(c){
  894. if((!c.isCheckerHd)&&(c.logic != 'ignore') && c.dataIndex){//只需显示,无需后台操作的字段,自动略去
  895. if(c.xtype == 'numbercolumn'){//赋个默认值0吧,不然不好保存
  896. if(data[c.dataIndex] == null || data[c.dataIndex] == '' || String(data[c.dataIndex]) == 'NaN'){
  897. dd[c.dataIndex] = '0';//也可以从data里面去掉这些字段
  898. } else {
  899. dd[c.dataIndex] = "" + s[i].data[c.dataIndex];
  900. }
  901. } else {
  902. dd[c.dataIndex] = s[i].data[c.dataIndex];
  903. }
  904. if (c.defaultValue && (dd[c.dataIndex] == null || dd[c.dataIndex] == '0')) {
  905. dd[c.dataIndex] = c.defaultValue;
  906. }
  907. }
  908. });
  909. if(grid.mainField && form && form.keyField){//例如,将pu_id的值赋给pd_puid
  910. dd[grid.mainField] = Ext.getCmp(form.keyField).value;
  911. }
  912. jsonGridData.push(Ext.JSON.encode(dd));
  913. }
  914. }
  915. param = jsonGridData == null ? [] : "[" + jsonGridData.toString().replace(/\\/g,"%") + "]";
  916. if(form.getForm().isValid()){
  917. Ext.each(form.items.items, function(item){
  918. if(item.xtype == 'numberfield'){
  919. if(item.value == null || item.value == ''){
  920. item.setValue(0);
  921. }
  922. }
  923. });
  924. var r = form.getValues();
  925. me.update(r, param);
  926. }else{
  927. me.FormUtil.checkForm();
  928. }
  929. },
  930. update:function(){
  931. var params = new Object();
  932. var r = arguments[0];
  933. Ext.each(Ext.Object.getKeys(r), function(k){//去掉页面非表单定义字段
  934. if(contains(k, 'ext-', true)){
  935. delete r[k];
  936. }
  937. });
  938. params.formStore = unescape(Ext.JSON.encode(r).replace(/\\/g,"%"));
  939. params.param = unescape(arguments[1].toString().replace(/\\/g,"%"));
  940. var me = this;
  941. var form = Ext.getCmp('kpi-form');
  942. Ext.Ajax.request({
  943. url : basePath + form.updateUrl,
  944. params : params,
  945. method : 'post',
  946. callback : function(options,success,response){
  947. var localJson = new Ext.decode(response.responseText);
  948. if(localJson.success){
  949. Ext.Msg.alert('提示','添加成功',function(){
  950. form.ownerCt.close();
  951. });
  952. } else if(localJson.exceptionInfo){
  953. var str = localJson.exceptionInfo;
  954. showError(str);
  955. return;
  956. } else{
  957. saveFailure();//@i18n/i18n.js
  958. }
  959. }
  960. });
  961. }
  962. });