Created
June 25, 2014 03:20
-
-
Save vikingmute/eb7b870255b8bde15079 to your computer and use it in GitHub Desktop.
temai-biz action template - form类型
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @file 计划新建或编辑的Action | |
* @author zhangxuan06 | |
*/ | |
define(function (require) { | |
var Action = require('er/Action'); | |
/** | |
* 新建计划Action的构造函数 | |
* | |
* @constructor | |
* @extends Action | |
*/ | |
function PlanForm() { | |
Action.apply(this, arguments); | |
} | |
PlanForm.prototype.modelType = require('./FormModel'); | |
PlanForm.prototype.viewType = require('./FormView'); | |
/** | |
* 初始化PlanForm | |
* | |
* @public | |
*/ | |
PlanForm.prototype.initBehavior = function () { | |
var me = this; | |
var view = me.view; | |
//在view上绑定自定义事件 | |
view.on('create', function (event) { | |
me.doUpdate(event.data.planName); | |
}); | |
view.on('cancel', function () { | |
me.close(); | |
}); | |
}; | |
/** | |
* 删除PlanForm的方法 | |
* | |
* @public | |
*/ | |
PlanForm.prototype.close = function () { | |
if (this.dialog) { | |
this.dialog.dispose(); | |
} | |
}; | |
/** | |
* PlanForm创建成功后的回调 | |
* | |
* @public | |
* @param {string} 传入的计划名称 | |
*/ | |
PlanForm.prototype.doUpdate = function (planName) { | |
var me = this; | |
var content = '新建成功'; | |
if (me.context.planId) { | |
content = '修改成功'; | |
} | |
//@ src/biz/plan/FormModel.js | |
me.model.getUpdateRequest({ | |
planName: planName | |
}, function (result) { | |
var args = (result && result.hasBizError) ? result : {}; | |
args.content = content; | |
// @ src/biz/plan/FormView.js | |
me.view.dialogHandle(args); | |
}); | |
}; | |
require('er/util').inherits(PlanForm, Action); | |
return PlanForm; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment