You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

138 lines
4.7 KiB

4 years ago
/**
* 复制权限按钮弹框文件
* @description [description]
* @version 1.0
* @author yangjinhua
*/
define(function(require, exports, module) {
var Window = require('system/views/pages/window');
var tpl = require('text!apps/rht/bas/bas0405/Add.tpl');
var service = require('./bas0405service');
var rhtComm = require('../../comm/rhtComm');
/**
* [复制权限弹框]
* @param {[type]} dsData 角色表数据源用于对角色ComBox进行赋值
*/
function Add(dsData, operType) {
var title = "添加地区";
if(operType == '1') {
title = "编辑地区";
}
this.options = {
title: title,
content: tpl,
width: 300,
height: 320,
modal: true,
closed: true,
closable: true,
draggable: true,
maximizable: false,
resizable: false,
data: null
}
this.dsData = dsData;
this.operType = operType;
this.preAreaCode = this.dsData.areacode;
Window.call(this, this.options);
}
inherits(Add, Window);
Add.prototype.init = function() {
}
Add.prototype.open = function() {
Window.prototype.open.call(this);
var $areaCode = this.getElement('.areaCode');
var $areaName = this.getElement('.areaName');
var $isLast = this.getElement('.isLast');
var $remark = this.getElement('.remark');
$areaCode.textbox('setValue', this.dsData.areacode);
if(this.operType == '1') {
$areaCode.textbox("readonly", true);
$isLast.checkbox("readonly", true);
$areaName.textbox('setValue', this.dsData.areaname);
if(this.dsData.islast == '1') {
$isLast.checkbox('check');
}
$remark.textbox('setValue', this.dsData.remark);
}
}
//执行windows窗体上自定义按钮事件
Add.prototype.customerize = function() {
var self = this;
//确定按钮事件
this.getElement('.btnOK').on('click', function(event) {
var $areaCode = self.getElement('.areaCode');
var $areaName = self.getElement('.areaName');
var $isLast = self.getElement('.isLast');
var $remark = self.getElement('.remark');
var areaCode = $areaCode.textbox('getValue');
var areaName = $areaName.textbox('getValue');
var isLast = $isLast.checkbox('options').checked ? 1 : 0;
var remark = $remark.textbox('getValue');
if(self.operType == '0') {
if(self.preAreaCode == "*") {
var pattern = new RegExp('^[0-9]{2}$');
// 顶级地区编号必须两位数字
if(!pattern.test(areaCode)) {
Store.messager.err('地区编号必须为两位数字!');
return false;
}
}else {
var pattern = new RegExp('^' + self.preAreaCode+'[0-9]{2}$');
// 子地区编号必须为父地区编号+两位数字
if(!pattern.test(areaCode)) {
Store.messager.err('地区编号必须为' + self.preAreaCode + '+两位数字!');
return false;
}
}
if(areaName == '') {
Store.messager.err('地区名称不能为空!');
return false;
}
var res= service.AddArea(areaCode, areaName, isLast, remark);
if (res.result !== 1) {
Store.messager.err('增加失败!' + res.message);
return false;
}else {
if (self.callback) {
self.callback();
}
self.close();
}
}else {
if(areaName == '') {
Store.messager.err('地区名称不能为空!');
return false;
}
var res= service.UpdateArea(areaCode, areaName, remark);
if (res.result !== 1) {
Store.messager.err('编辑失败!' + res.message);
return false;
}else {
if (self.callback) {
self.callback();
}
self.close();
}
}
});
//取消按钮事件
this.getElement('.btnCancel').on('click', function(event) {
self.close();
});
}
return Add;
})