| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304 |
- Ext.QuickTips.init();
- Ext.define('erp.controller.oa.persontask.workDaily.AddWorkDaily', {
- extend: 'Ext.app.Controller',
- FormUtil: Ext.create('erp.util.FormUtil'),
- BaseUtil: Ext.create('erp.util.BaseUtil'),
- views:[
- 'oa.persontask.workDaily.AddWorkDaily','core.form.Panel',
- 'core.button.Add','core.button.Save','core.button.Close','core.button.Update','core.button.Delete',
- 'core.form.DetailTextField','core.form.FileField','common.datalist.GridPanel','common.datalist.Toolbar'
-
- ],
- init:function(){
- var me = this;
- this.control({
- 'erpDatalistGridPanel': {
- itemclick: this.onGridItemClick
- },
- 'datefield[id=wd_date]':{
- afterrender: function(field){
- if(getUrlParam('flag')!=1){
- field.setVisible(false);
- }
- if(contains(window.location.href,'formCondition',true)){
- field.setVisible(true);
- field.setDisabled(true);
- }
- this.search(Ext.util.Format.date(new Date(field.value),"Y-m-d"));
- },
- change: function(field){
- this.search(Ext.util.Format.date(new Date(field.value),"Y-m-d"));
- }
- },
- 'button[id=save]': {
- click: function(btn){
- var mm = this.FormUtil;
- var form = Ext.getCmp('form');
- if(! mm.checkForm()){
- return;
- }
- if(Ext.getCmp(form.keyField).value == null || Ext.getCmp(form.keyField).value == ''){
- mm.getSeqId(form);
- this.save(form);
- // alert(Ext.getCmp('wd_tip').value);
- if(Ext.getCmp('wd_tip').value != null && Ext.getCmp('wd_tip').value != ''){
- this.release();
- }
- } else {
- this.update(form);
- }
-
- }
- },
- 'button[id=addwd]': {
- click: function(btn){
- window.location.href = window.location.href + '&flag=1';
- }
- },
- 'button[id=daily]': {
- click: function(btn){
- var date = Ext.util.Format.date(new Date(Ext.getCmp('wd_date').value),"Y-m-d");
- // alert(date);
- var win = new Ext.window.Window({
- id : 'win',
- title: "今日提交任务日志",
- height: "50%",
- width: "70%",
- maximizable : false,
- buttonAlign : 'left',
- layout : 'anchor',
- items: [{
- tag : 'iframe',
- frame : true,
- anchor : '100% 100%',
- layout : 'fit',
- html : '<iframe id="iframe_' + new Date() + '" src="' + basePath +
- 'jsps/oa/persontask/workDaily/daily.jsp?whoami=WorkRecord!Daily&urlcondition=wr_recorderemid=' + em_uu +
- " and to_char(wr_recorddate,'yyyy-MM-dd')='" + date + "'" + '" height="100%" width="100%" frameborder="0" scrolling="no"></iframe>'
- }]
- });
- win.show();
- }
-
- },
- 'button[id=see]': {
- click: function(btn){
- var d = new Date();
- var win = new Ext.window.Window({
- id : 'win',
- title: d.getFullYear() + '年' + (d.getMonth()+1) + '月份 月计划查看',
- height: "50%",
- width: "70%",
- maximizable : false,
- buttonAlign : 'left',
- layout : 'anchor',
- items: [{
- tag : 'iframe',
- frame : true,
- anchor : '100% 100%',
- layout : 'fit',
- html : '<iframe id="iframe_' + new Date() + '" src="' + basePath + 'jsps/oa/persontask/workPlan/see.jsp" height="100%" width="100%" frameborder="0" scrolling="yes"></iframe>'
- }]
- });
- win.show();
- }
- },
- 'erpUpdateButton': {
- click: function(btn){
- this.FormUtil.onUpdate(this);
- }
- },
- 'erpDeleteButton': {
- click: function(btn){
- me.onDelete((Ext.getCmp('at_id').value));
- }
- },
- 'erpCloseButton': {
- click: function(btn){
- parent.window.location.href = parent.window.location.href;
- this.FormUtil.onClose(this);
- }
- }
- });
- },
- getForm: function(btn){
- return btn.ownerCt.ownerCt;
- },
- onGridItemClick: function(selModel, record){//grid行选择
- var me = this;
- var id = record.data.ra_id;
- var panel = Ext.getCmp("task" + id);
- var main = parent.Ext.getCmp("content-panel");
- if(!panel){
- var title = "任务";
- panel = {
- title : title,
- tag : 'iframe',
- tabConfig:{tooltip: record.data['ra_taskname']},
- frame : true,
- border : false,
- layout : 'fit',
- iconCls : 'x-tree-icon-tab-tab1',
- html : '<iframe id="iframe_' + id + '" src="' + basePath + "jsps/plm/record/workrecord.jsp?whoami=ResourceAssignment&formCondition=ra_id=" + id + "&gridCondition=wr_raid=" + id + '" height="100%" width="100%" frameborder="0" scrolling="yes"></iframe>',
- closable : true,
- listeners : {
- close : function(){
- main.setActiveTab(main.getActiveTab().id);
- }
- }
- };
- me.FormUtil.openTab(panel, "task" + id);
- }else{
- main.setActiveTab(panel);
- }
- },
- save: function(form){
- var mm = this.FormUtil;
- if(form.getForm().isValid()){
- //form里面数据
- Ext.each(form.items.items, function(item){
- if(item.xtype == 'numberfield'){
- //number类型赋默认值,不然sql无法执行
- if(item.value == null || item.value == ''){
- item.setValue(0);
- }
- }
- });
- var r = form.getValues();
- var keys = Ext.Object.getKeys(r);
- var values = Ext.Object.getValues(r);
- var o = new Object();
- Ext.each(keys, function(key, index){
- if(contains(key, 'wd_', true)){
- o[key] = values[index];
- }
- });
- o.wd_context = Ext.getCmp('wd_context').value=='' ? '':Ext.getCmp('wd_context').value;
- if(!mm.contains(form.saveUrl, '?caller=', true)){
- form.saveUrl = form.saveUrl + "?caller=" + caller;
- }
- mm.save(o, []);
- }else{
- mm.checkForm();
- }
- },
- update: function(form){
- var mm = this.FormUtil;
- var s1 = mm.checkFormDirty(form);
- if(s1 == ''){
- showError($I18N.common.form.emptyData + '<br/>');
- return;
- }
- if(form && form.getForm().isValid()){
- //form里面数据
- var r = form.getValues();
- var keys = Ext.Object.getKeys(r);
- var values = Ext.Object.getValues(r);
- var o = new Object();
- Ext.each(keys, function(key, index){
- if(contains(key, 'wd_', true)){
- o[key] = values[index];
- }
- });
- o.wd_context = Ext.getCmp('wd_context').value=='' ? '':Ext.getCmp('wd_context').value;
- if(!mm.contains(form.updateUrl, '?caller=', true)){
- form.updateUrl = form.updateUrl + "?caller=" + caller;
- }
- mm.update(o, []);
- }else{
- mm.checkForm(form);
- }
- },
- getTi: function(n){
- var uom = new Date();
- uom.setDate(uom.getDate()+n);
- uom = uom.getFullYear() + "-" + (uom.getMonth()+1) + "-" + uom.getDate();
- return uom;
- },
- release: function(){
- var o = new Object();
- o.prd_recipient = em_name;
- o.prd_recipientid = em_uu;
- o.pr_context = Ext.getCmp('wd_tip').value;
- o.pr_date = this.getTi(1) + " 09:00:00";
- // alert(o.pr_date);
- Ext.Ajax.request({
- url : basePath + 'common/getId.action?seq=PAGINGRELEASE_SEQ',
- method : 'get',
- async: false,
- callback : function(options,success,response){
- var rs = new Ext.decode(response.responseText);
- if(rs.exceptionInfo){
- showError(rs.exceptionInfo);return;
- }
- if(rs.success){
- o.pr_id = rs.id;
- }
- }
- });
- // console.log(o);
- var params = new Object();
- params.formStore = unescape(Ext.JSON.encode(o).replace(/\\/g,"%"));
- Ext.Ajax.request({
- url : basePath + 'oa/info/sendPagingRelease.action?caller=PagingRelease',
- params : params,
- method : 'post',
- callback : function(options,success,response){
- // me.getActiveTab().setLoading(false);
- var localJson = new Ext.decode(response.responseText);
- if(localJson.success){
- saveSuccess(function(){
- alert('添加提示成功,提醒时间为:'+o.pr_date);
- });
- } else{
- // saveFailure();//@i18n/i18n.js
- }
- }
- });
- },
- getSeqId: function(o){
- Ext.Ajax.request({
- url : basePath + 'common/getId.action?seq=PAGINGRELEASE_SEQ',
- method : 'get',
- async: false,
- callback : function(options,success,response){
- var rs = new Ext.decode(response.responseText);
- if(rs.exceptionInfo){
- showError(rs.exceptionInfo);return;
- }
- if(rs.success){
- o.pr_id = rs.id;
- }
- }
- });
- },
- search: function(value){
- if(!contains(window.location.href,'formCondition',true)){
- Ext.Ajax.request({
- url : basePath + 'oa/persontask/workDaily/searchWorkDaily.action',
- params : {
- em_id: em_uu,
- date: value
- },
- method : 'post',
- callback : function(options,success,response){
- // me.getActiveTab().setLoading(false);
- var localJson = new Ext.decode(response.responseText);
- if(localJson.success){
- if(localJson.wd_id != 0){
- warnMsg('今日日报已提交!是否查看', function(btn){
- if(btn == 'yes'){
- window.location.href = window.location.href + '&formCondition=wd_idIS'+localJson.wd_id+'&gridCondition=';
- }else{
- return;
- }
- });
- }
- } else {
- // saveFailure();//@i18n/i18n.js
- }
- }
- });
- }
- }
- });
|