Skip to content

Instantly share code, notes, and snippets.

@vikingmute
Last active August 29, 2015 14:02
Show Gist options
  • Save vikingmute/1ebd9ce493859c311821 to your computer and use it in GitHub Desktop.
Save vikingmute/1ebd9ce493859c311821 to your computer and use it in GitHub Desktop.
temai-biz view template
/**
* @file 新建的View类模板
* @author zhangxuan06
*/
define(function (require) {
require('er/tpl!./form.tpl.html');
var langPlan = require('biz/lang/plan');
var UIView = require('ef/UIView');
var Dialog = require('esui/Dialog');
var locator = require('er/locator');
var accountTree = require('common/accountTree');
/**
* 计划列表View的构造函数
*
* @constructor
* @extends UIView
*/
function PlanFormView() {
UIView.apply(this, arguments);
}
require('er/util').inherits(PlanFormView, UIView);
PlanFormView.prototype.template = 'planForm';
/**
* View绑定esui组件的数据和属性
*
* @public
*/
PlanFormView.prototype.uiProperties = {
PlanName: {
validityLabel: 'PlanNameValidity',
exMaxLength: langPlan.PLAN_NAME_MAX_LENTH,
exMaxLengthErrorMessage: '字符串不能超过30个字符',
required: 1,
requiredErrorMessage: '计划名称不能为空',
value: '@planName'
}
};
PlanFormView.prototype.uiEvents = {
/**
* 文本框输入时触发
*
* @event input
* @param {Object} esui传入的默认参数
*/
'PlanName:input': function (event) {
var value = event.target.getValue();
// to be continued
},
/**
* 点击取消时候触发
*
* @event click
*/
'CancelBtn:click': function () {
this.fire('cancel');
},
/**
* 点击创建的时候触发
*
* @event click
*/
'CreateBtn:click': function () {
var uiPlanName = this.get('PlanName');
if (!uiPlanName.validate()) {
return;
}
this.fire('create', {
data: {
planName: uiPlanName.getValue()
}
});
}
};
/**
* ajax请求结束后 显示对话框
*
* @public
* @param {object} ajax结束后传入的参数
*/
PlanFormView.prototype.dialogHandle = function (args) {
var view = this;
//返回值有错误
if (args.hasBizError) {
Dialog.alert({
content: args.statusInfo || '请求出错+_+',
type: 'fail'
});
// 返回值成功
} else {
Dialog.alert({
title: '提示',
content: args.content,
type: 'success'
}).on('ok', function () {
view.fire('cancel');
//刷新locator 和 accoutTree
locator.reload();
accountTree.refresh(0, 'user', true);
});
}
};
return PlanFormView;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment