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.

151 lines
5.3 KiB

4 years ago
define(function (require, exports, module) {
let BaseBiz = require('apps/rht/base/rhtBiz');
let rhtComm = require('apps/rht/comm/rhtComm');
let IsdsMasterChg = false;
let IsdsDetailChg = false;
/**
* 控制按钮的可用
* @param opCode 按钮编码
* @return [description]
*/
function Biz(vm) {
//继承第一步,构造继承
BaseBiz.call(this, vm);
}
//继承第二步,方法继承
inherits(Biz, BaseBiz);
Biz.prototype.initCompleted = function () {
this.super('initCompleted');
this.dsMaster.serverBiz = 'pluExPatternBiz'
};
let MaxSerialNo = 1;
//保存前记录日志
Biz.prototype.afterEdit = function () {
return this.super('afterEdit');
};
//保存后记录日志
Biz.prototype.beforeSave = function () {
return this.super('beforeSave');
};
//新增行后处理,默认值已经处理
Biz.prototype.afterNewRow = function (dataSrc, newRow) {
//let sdate=new Date(Store.bizDao.getSysDate()).format('yyyy-MM-dd');
if (dataSrc.uiObjCode === this.dsDetail.uiObjCode) {
this.getMaxSerialNo();
newRow.setColumnValue('SerialNo',MaxSerialNo+1);
}
};
//主表 CanRun 字段变化执行事件
Biz.prototype.getMaxSerialNo = function () {
let curRow = this.dsMaster.currentRow;
if(curRow){
MaxSerialNo = 0;
for(let i=0;i<this.dsDetail.rows.length;i++){
let row = this.dsDetail.rows[i]
let SerialNo = TypeUtil.toFloat(row['SerialNo']);
if (MaxSerialNo < SerialNo){
MaxSerialNo = SerialNo;
}
}
}
return true;
};
//字段变化触发事件
Biz.prototype.fieldChanged = function (dataSrc, dr, dc) {
if (dataSrc.uiObjCode === this.dsMaster.uiObjCode) {
switch (dc.fieldName) {
case 'PatternCode':
this.fieldChangedPatternCode(dataSrc, dr, dc);
break;
case 'PatternNo':
this.fieldChangedPatternNo(dataSrc, dr, dc);
break;
}
}
if (dataSrc.uiObjCode === this.dsDetail.uiObjCode) {
switch (dc.fieldName) {
case 'FieldCode':
this.fieldChangedDetailFieldCode(dataSrc, dr, dc);
break;
}
}
this.super('fieldChanged');
};
//主表 PatternCode 字段变化执行事件
Biz.prototype.fieldChangedPatternCode = function (dataSrc, dr, dc) {
let PatternCode = dr['PatternCode'];
//用正则表达式校验输入内容必须是0-9的数字
let re=/^[0-9]+$/;
if (!re.test(PatternCode)) {
dr.setColumnError('PatternCode',"模版编码必须是0-9的纯数字!");
return false;
}
return true;
};
//主表 PatternNo 字段变化执行事件
Biz.prototype.fieldChangedPatternNo = function (dataSrc, dr, dc) {
let PatternNo = dr['PatternNo'];
//用正则表达式校验输入内容必须是0-9的数字
let re=/^[0-9]+$/;
if (!re.test(PatternNo)) {
dr.setColumnError('PatternNo',"模版序号必须是0-9的纯数字!");
return false;
}
return true;
};
//明细表 FieldCode 字段变化执行事件
Biz.prototype.fieldChangedDetailFieldCode = function (dataSrc, dr, dc) {
let FieldCode = TypeUtil.toString(dr['FieldCode']);
let SerialNo = TypeUtil.toString(dr['SerialNo']);
let DefaultValue = TypeUtil.toString(dr['DefaultValue']);
let curRow = this.dsMaster.currentRow;
if(curRow){
for(let i=0;i<this.dsDetail.rows.length;i++){
let row = this.dsDetail.rows[i]
if ((FieldCode == TypeUtil.toString(row['FieldCode'])) && (SerialNo != TypeUtil.toString(row['SerialNo']))){
dr.setColumnError('FieldCode',FieldCode+"辅助属性重复!");
return false;
}
}
}
dr.setColumnValue('FieldValue',DefaultValue);
return true;
};
//定义按钮事件
Biz.prototype.doOp = function (opCode) {
let self = this;
if (opCode == 'edtRemark') {
let ds = self.dsDetail;
this.onedtremark(self, ds);
}
};
//控制主界面按钮状态(预制信息不允许修改和删除)
Biz.prototype.getOpEnabled = function (opCode) {
let isOk = this.super('getOpEnabled', opCode);
if (!isOk) {
return false;
}
let curRow = this.dsMaster.currentRow;
if (opCode == 'edit') {
let PatternType = curRow ? TypeUtil.toString(curRow['PatternType']) : '';
if ((PatternType == "0"))
return false;
}
if (opCode == 'delete') {
let PatternType = curRow ? TypeUtil.toString(curRow['PatternType']) : '';
if ((PatternType == "0"))
return false;
}
return true;
};
return Biz;
});