Archive.js 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403
  1. Ext.QuickTips.init();
  2. Ext.define('erp.controller.hr.emplmana.Archive', {
  3. extend: 'Ext.app.Controller',
  4. FormUtil: Ext.create('erp.util.FormUtil'),
  5. BaseUtil: Ext.create('erp.util.BaseUtil'),
  6. GridUtil: Ext.create('erp.util.GridUtil'),
  7. views:[
  8. 'hr.emplmana.Archive','core.form.Panel','core.grid.Panel2','core.toolbar.Toolbar','hr.emplmana.RelationGrid',
  9. 'hr.emplmana.EducationGrid','hr.emplmana.PositionGrid','hr.emplmana.WorkGrid',
  10. 'core.button.Add','core.button.Save','core.button.Close','hr.emplmana.ReandpunishGrid',
  11. 'core.button.Update','core.button.Delete','core.form.YnField','core.button.DeleteDetail',
  12. 'core.trigger.DbfindTrigger','core.grid.YnColumn','core.form.YnField','core.button.ResAudit',
  13. 'core.button.Audit','core.button.Submit','core.button.ResSubmit','core.form.FileField','hr.emplmana.ContractGrid'
  14. ],
  15. init:function(){
  16. var me = this;
  17. this.control({
  18. 'erpGridPanel2': {
  19. itemclick: function(selModel, record){
  20. this.GridUtil.onGridItemClick(selModel, record);
  21. }
  22. },
  23. 'reandpunishgrid':{
  24. itemclick: function(selModel, record){
  25. this.GridUtil.onGridItemClick(selModel, record, 'reandpunishgrid');
  26. }
  27. },
  28. 'positiongrid':{
  29. itemclick: function(selModel, record){
  30. this.GridUtil.onGridItemClick(selModel, record, 'positiongrid');
  31. }
  32. },
  33. 'workgrid':{
  34. itemclick: function(selModel, record){
  35. this.GridUtil.onGridItemClick(selModel, record, 'workgrid');
  36. }
  37. },
  38. 'educationgrid':{
  39. itemclick: function(selModel, record){
  40. this.GridUtil.onGridItemClick(selModel, record, 'educationgrid');
  41. }
  42. },
  43. 'relationgrid':{
  44. itemclick: function(selModel, record){
  45. this.GridUtil.onGridItemClick(selModel, record, 'relationgrid');
  46. }
  47. },
  48. 'erpSaveButton': {
  49. click: function(btn){
  50. this.beforeSave();
  51. }
  52. },
  53. 'erpSubmitButton': {
  54. afterrender: function(btn){
  55. var status = Ext.getCmp('em_statuscode');
  56. if(status && status.value != 'ENTERING'){
  57. btn.hide();
  58. }
  59. },
  60. click: function(btn){
  61. me.FormUtil.onSubmit(Ext.getCmp('em_id').value);
  62. }
  63. },
  64. 'erpResSubmitButton': {
  65. afterrender: function(btn){
  66. var status = Ext.getCmp('em_statuscode');
  67. if(status && status.value != 'COMMITED'){
  68. btn.hide();
  69. }
  70. },
  71. click: function(btn){
  72. me.FormUtil.onResSubmit(Ext.getCmp('em_id').value);
  73. }
  74. },
  75. 'erpAuditButton': {
  76. afterrender: function(btn){
  77. var status = Ext.getCmp('em_statuscode');
  78. if(status && status.value != 'COMMITED'){
  79. btn.hide();
  80. }
  81. },
  82. click: function(btn){
  83. me.FormUtil.onAudit(Ext.getCmp('em_id').value);
  84. }
  85. },
  86. 'erpResAuditButton': {
  87. afterrender: function(btn){
  88. var status = Ext.getCmp('em_statuscode');
  89. if(status && status.value != 'AUDITED'){
  90. btn.hide();
  91. }
  92. },
  93. click: function(btn){
  94. me.FormUtil.onResAudit(Ext.getCmp('em_id').value);
  95. }
  96. },
  97. 'field[name=em_id]': {
  98. afterrender: function(f){
  99. if(f.value != null && f.value != ''){
  100. var emid = Ext.getCmp('em_id').value;
  101. var positiongrid = Ext.getCmp('positiongrid');
  102. positiongrid.getMyData(emid);
  103. var workgrid = Ext.getCmp('workgrid');
  104. workgrid.getMyData(emid);
  105. var reandpunishgrid = Ext.getCmp('reandpunishgrid');
  106. reandpunishgrid.getMyData(emid);
  107. var educationgrid = Ext.getCmp('educationgrid');
  108. educationgrid.getMyData(emid);
  109. var relationgrid = Ext.getCmp('relationgrid');
  110. relationgrid.getMyData(emid);
  111. var contractgrid = Ext.getCmp('contractgrid');
  112. contractgrid.getMyData(emid);
  113. }
  114. },
  115. change: function(f){
  116. if(f.value != null && f.value != ''){
  117. var emid = Ext.getCmp('em_id').value;
  118. Ext.getCmp('positiongrid').getMyData(emid);
  119. Ext.getCmp('workgrid').getMyData(emid);
  120. Ext.getCmp('reandpunishgrid').getMyData(emid);
  121. Ext.getCmp('educationgrid').getMyData(emid);
  122. Ext.getCmp('contractgrid').getMyData(emid);
  123. //Ext.getCmp('relationgrid').getMyData(emid);
  124. }
  125. }
  126. },
  127. 'field[name=em_iccode]':{
  128. blur:function(f){
  129. if(f.value != null && f.value != ''){
  130. if(f.value.length!=18){
  131. showError('身份证填写不正确!');
  132. return;
  133. }
  134. var year=f.value.slice(6,10);
  135. var month=f.value.slice(10,12);
  136. var day=f.value.slice(12,14);
  137. var year_int=year-0;
  138. var month_int=month-0;
  139. var day_int=day-0;
  140. if(isNaN(year_int)||isNaN(month_int)||isNaN(day_int)){
  141. showError('身份证填写不正确!');
  142. return;
  143. }
  144. if(month_int>12||day_int>31){
  145. showError('身份证填写不正确!');
  146. return;
  147. }
  148. Ext.getCmp('em_birthday').setValue(year+'-'+month+'-'+day);
  149. }
  150. }
  151. },
  152. 'erpCloseButton': {
  153. click: function(btn){
  154. this.FormUtil.beforeClose(this);
  155. }
  156. },
  157. 'erpUpdateButton': {
  158. click: function(btn){
  159. this.beforeUpdate();
  160. }
  161. },
  162. 'erpDeleteButton': {
  163. click: function(btn){
  164. me.FormUtil.onDelete(Ext.getCmp('em_id').value);
  165. }
  166. },
  167. 'erpAddButton': {
  168. click: function(){
  169. me.FormUtil.onAdd('addArchive', '新增人员档案', 'jsps/hr/emplmana/archive.jsp');
  170. }
  171. }
  172. });
  173. },
  174. getForm: function(btn){
  175. return btn.ownerCt.ownerCt;
  176. },
  177. beforeSave: function(){
  178. var me = this;
  179. var form = Ext.getCmp('form');
  180. if(! me.FormUtil.checkForm()){
  181. return;
  182. }
  183. if(Ext.getCmp(form.keyField).value == null || Ext.getCmp(form.keyField).value == ''){
  184. me.FormUtil.getSeqId(form);
  185. }
  186. var detail = Ext.getCmp('grid');
  187. var education = Ext.getCmp('educationgrid');
  188. var position = Ext.getCmp('positiongrid');
  189. var work = Ext.getCmp('workgrid');
  190. var reandpunish = Ext.getCmp('reandpunishgrid');
  191. var relation = Ext.getCmp('relationgrid');
  192. var param1 = me.GridUtil.getGridStore(detail);
  193. var param2 = me.GridUtil.getGridStore(education);
  194. var param3 = me.GridUtil.getGridStore(position);
  195. var param4 = me.GridUtil.getGridStore(work);
  196. var param5 = me.GridUtil.getGridStore(reandpunish);
  197. var param6 = me.GridUtil.getGridStore(relation);
  198. if(param6.length==0&&Ext.getCmp('em_havefriend').value=='有'){
  199. showError('请填写亲友信息!');
  200. return;
  201. }
  202. if(detail.necessaryField.length > 0 && (param1.length == 0)){//
  203. showError($I18N.common.grid.emptyDetail);
  204. return;
  205. } else {
  206. param1 = param1 == null ? [] : "[" + param1.toString().replace(/\\/g,"%") + "]";
  207. param2 = param2 == null ? [] : "[" + param2.toString().replace(/\\/g,"%") + "]";
  208. param3 = param3 == null ? [] : "[" + param3.toString().replace(/\\/g,"%") + "]";
  209. param4 = param4 == null ? [] : "[" + param4.toString().replace(/\\/g,"%") + "]";
  210. param5 = param5 == null ? [] : "[" + param5.toString().replace(/\\/g,"%") + "]";
  211. param6 = param6 == null ? [] : "[" + param6.toString().replace(/\\/g,"%") + "]";
  212. if(form.getForm().isValid()){
  213. Ext.each(form.items.items, function(item){
  214. if(item.xtype == 'numberfield'){
  215. if(item.value == null || item.value == ''){
  216. item.setValue(0);
  217. }
  218. }
  219. });
  220. var r = form.getValues();
  221. me.FormUtil.save(r, param1, param2, param3,param4,param5,param6);
  222. }else{
  223. me.FormUtil.checkForm();
  224. }
  225. }
  226. },
  227. beforeUpdate: function(){
  228. var me = this;
  229. var form = Ext.getCmp('form');
  230. if(! me.FormUtil.checkForm()){
  231. return;
  232. }
  233. if(Ext.getCmp(form.keyField).value == null || Ext.getCmp(form.keyField).value == ''){
  234. me.FormUtil.getSeqId(form);
  235. }
  236. var detail = Ext.getCmp('grid');
  237. var education = Ext.getCmp('educationgrid');
  238. var position = Ext.getCmp('positiongrid');
  239. var work = Ext.getCmp('workgrid');
  240. var reandpunish = Ext.getCmp('reandpunishgrid');
  241. var relation = Ext.getCmp('relationgrid');
  242. var param1 = me.GridUtil.getGridStore(detail);
  243. var param2 = me.GridUtil.getGridStore(education);
  244. var param3 = me.GridUtil.getGridStore(position);
  245. var param4 = me.GridUtil.getGridStore(work);
  246. var param5 = me.GridUtil.getGridStore(reandpunish);
  247. var param6 = me.GridUtil.getGridStore(relation);
  248. if(detail.necessaryField.length > 0 && (param1.length == 0)){
  249. showError($I18N.common.grid.emptyDetail);
  250. return;
  251. } else {
  252. param1 = param1 == null ? [] : "[" + param1.toString().replace(/\\/g,"%") + "]";
  253. param2 = param2 == null ? [] : "[" + param2.toString().replace(/\\/g,"%") + "]";
  254. param3 = param3 == null ? [] : "[" + param3.toString().replace(/\\/g,"%") + "]";
  255. param4 = param4 == null ? [] : "[" + param4.toString().replace(/\\/g,"%") + "]";
  256. param5 = param5 == null ? [] : "[" + param5.toString().replace(/\\/g,"%") + "]";
  257. param6 = param6 == null ? [] : "[" + param6.toString().replace(/\\/g,"%") + "]";
  258. if(form.getForm().isValid()){
  259. Ext.each(form.items.items, function(item){
  260. if(item.xtype == 'numberfield'){
  261. if(item.value == null || item.value == ''){
  262. item.setValue(0);
  263. }
  264. }
  265. });
  266. var r = form.getValues();
  267. me.FormUtil.update(r, param1, param2, param3,param4,param5,param6);
  268. }else{
  269. me.FormUtil.checkForm();
  270. }
  271. }
  272. },
  273. add10EmptyItems: function(grid){
  274. var items = grid.store.data.items;
  275. var detno = grid.detno;
  276. if(detno){
  277. var index = items.length == 0 ? 0 : Number(items[items.length-1].data[detno]);
  278. for(var i=0;i<10;i++){
  279. var o = new Object();
  280. o[detno] = index + i + 1;
  281. grid.store.insert(items.length, o);
  282. items[items.length-1]['index'] = items.length-1;
  283. }
  284. } else {
  285. for(var i=0;i<10;i++){
  286. var o = new Object();
  287. grid.store.insert(items.length, o);
  288. items[items.length-1]['index'] = items.length-1;
  289. }
  290. }
  291. },
  292. onGridItemClick2: function(selModel, record){
  293. var grid = Ext.getCmp('positiongrid');
  294. var index = null;
  295. if(grid.detno){
  296. index = record.data[grid.detno];
  297. index = index == null ? (record.index + 1) : index;
  298. if(index.toString() == 'NaN'){
  299. index = '';
  300. }
  301. if(index == grid.store.data.items[grid.store.data.items.length-1].data[grid.detno]){//如果选择了最后一行
  302. this.add10EmptyItems(grid);//就再加10行
  303. }
  304. } else {
  305. index = record.index + 1;
  306. if(index.toString() == 'NaN'){
  307. index = '';
  308. }
  309. if(index == grid.store.data.items[grid.store.data.items.length-1].index + 1){//如果选择了最后一行
  310. this.add10EmptyItems(grid);//就再加10行
  311. }
  312. }
  313. var btn = Ext.ComponentQuery.query('erpDeleteDetailButton')[0];
  314. btn.setDisabled(false);
  315. btn.setText(btn.text.split(':')[0] + ":" + index);
  316. btn = Ext.ComponentQuery.query('copydetail')[0];
  317. btn.setDisabled(false);
  318. btn.setText(btn.text.split(':')[0] + ":" + index);
  319. btn = Ext.ComponentQuery.query('pastedetail')[0];
  320. btn.setDisabled(false);
  321. btn.setText(btn.text.split(':')[0] + ":" + index);
  322. btn = Ext.ComponentQuery.query('updetail')[0];
  323. btn.setDisabled(false);
  324. btn.setText(btn.text.split(':')[0] + ":" + index);
  325. btn = Ext.ComponentQuery.query('downdetail')[0];
  326. btn.setDisabled(false);
  327. btn.setText(btn.text.split(':')[0] + ":" + index);
  328. },
  329. onGridItemClick3: function(selModel, record){
  330. var grid = Ext.getCmp('workgrid');
  331. var index = null;
  332. if(grid.detno){
  333. index = record.data[grid.detno];
  334. index = index == null ? (record.index + 1) : index;
  335. if(index.toString() == 'NaN'){
  336. index = '';
  337. }
  338. if(index == grid.store.data.items[grid.store.data.items.length-1].data[grid.detno]){//如果选择了最后一行
  339. this.add10EmptyItems(grid);//就再加10行
  340. }
  341. } else {
  342. index = record.index + 1;
  343. if(index.toString() == 'NaN'){
  344. index = '';
  345. }
  346. if(index == grid.store.data.items[grid.store.data.items.length-1].index + 1){//如果选择了最后一行
  347. this.add10EmptyItems(grid);//就再加10行
  348. }
  349. }
  350. var btn = Ext.ComponentQuery.query('erpDeleteDetailButton')[0];
  351. btn.setDisabled(false);
  352. btn.setText(btn.text.split(':')[0] + ":" + index);
  353. btn = Ext.ComponentQuery.query('copydetail')[0];
  354. btn.setDisabled(false);
  355. btn.setText(btn.text.split(':')[0] + ":" + index);
  356. btn = Ext.ComponentQuery.query('pastedetail')[0];
  357. btn.setDisabled(false);
  358. btn.setText(btn.text.split(':')[0] + ":" + index);
  359. btn = Ext.ComponentQuery.query('updetail')[0];
  360. btn.setDisabled(false);
  361. btn.setText(btn.text.split(':')[0] + ":" + index);
  362. btn = Ext.ComponentQuery.query('downdetail')[0];
  363. btn.setDisabled(false);
  364. btn.setText(btn.text.split(':')[0] + ":" + index);
  365. },
  366. onGridItemClick4: function(selModel, record){
  367. var grid = Ext.getCmp('educationgrid');
  368. var index = null;
  369. if(grid.detno){
  370. index = record.data[grid.detno];
  371. index = index == null ? (record.index + 1) : index;
  372. if(index.toString() == 'NaN'){
  373. index = '';
  374. }
  375. if(index == grid.store.data.items[grid.store.data.items.length-1].data[grid.detno]){//如果选择了最后一行
  376. this.add10EmptyItems(grid);//就再加10行
  377. }
  378. } else {
  379. index = record.index + 1;
  380. if(index.toString() == 'NaN'){
  381. index = '';
  382. }
  383. if(index == grid.store.data.items[grid.store.data.items.length-1].index + 1){//如果选择了最后一行
  384. this.add10EmptyItems(grid);//就再加10行
  385. }
  386. }
  387. var btn = Ext.ComponentQuery.query('erpDeleteDetailButton')[0];
  388. btn.setDisabled(false);
  389. btn.setText(btn.text.split(':')[0] + ":" + index);
  390. btn = Ext.ComponentQuery.query('copydetail')[0];
  391. btn.setDisabled(false);
  392. btn.setText(btn.text.split(':')[0] + ":" + index);
  393. btn = Ext.ComponentQuery.query('pastedetail')[0];
  394. btn.setDisabled(false);
  395. btn.setText(btn.text.split(':')[0] + ":" + index);
  396. btn = Ext.ComponentQuery.query('updetail')[0];
  397. btn.setDisabled(false);
  398. btn.setText(btn.text.split(':')[0] + ":" + index);
  399. btn = Ext.ComponentQuery.query('downdetail')[0];
  400. btn.setDisabled(false);
  401. btn.setText(btn.text.split(':')[0] + ":" + index);
  402. }
  403. });