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.

170 lines
6.3 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

define(function (require, exports, module) {
//引入业务类基类
let BaseBiz = require('apps/rht/base/rhtBiz');
//引入业务服务
let service = require('./sys01030803service');
/**
* 定义业务类对象
* @param vm 界面相关ViewModule
*/
function Biz(vm) {
//继承第一步,构造继承
BaseBiz.call(this, vm);
}
//继承第二步,方法继承
inherits(Biz, BaseBiz);
/**
* @description 数据发生变化时调用
* @param dataSrc 数据集
* @param dr 数据行
* @param dc 数据列
*/
Biz.prototype.fieldChanged = function (dataSrc, dr, dc) {
let self = this;
if (dataSrc.uiObjCode === this.dsMaster.uiObjCode) {
let currentRow = self.dsMaster.currentRow;
if (currentRow === null) return false;
switch (dc.fieldName) {
case 'IsRule':
this.fieldChangedIsRule(dataSrc, dr, dc);
break;
case 'IsPrefix':
this.fieldChangedIsPrefix(dataSrc, dr, dc);
break;
case 'IsDate':
this.fieldChangedIsDate(dataSrc, dr, dc);
break;
}
}
return this.super('fieldChanged');
};
Biz.prototype.fieldChangedIsRule = function (dataSrc, dr, dc) {
let isRule = TypeUtil.toString(dr['IsRule']);
let masterAdapter = this.view.vm['ep_dsMaster'];
if(isRule == '1') {
masterAdapter.setEditorEditable('NoLength', true);
masterAdapter.setEditorEditable('IsPrefix', true);
masterAdapter.setEditorEditable('PrefixLen', true);
masterAdapter.setEditorEditable('PrefixNo', true);
masterAdapter.setEditorEditable('IsDate', true);
masterAdapter.setEditorEditable('DateFmt', true);
masterAdapter.setEditorEditable('SerialLen', true);
}else {
masterAdapter.setEditorEditable('NoLength', false);
masterAdapter.setEditorEditable('IsPrefix', false);
masterAdapter.setEditorEditable('PrefixLen', false);
masterAdapter.setEditorEditable('PrefixNo', false);
masterAdapter.setEditorEditable('IsDate', false);
masterAdapter.setEditorEditable('DateFmt', false);
masterAdapter.setEditorEditable('SerialLen', false);
}
return true;
};
Biz.prototype.fieldChangedIsPrefix = function (dataSrc, dr, dc) {
let isPrefix = TypeUtil.toString(dr['IsPrefix']);
let masterAdapter = this.view.vm['ep_dsMaster'];
if(isPrefix == '1') {
masterAdapter.setEditorEditable('PrefixLen', true);
masterAdapter.setEditorEditable('PrefixNo', true);
}else {
masterAdapter.setEditorEditable('PrefixLen', false);
masterAdapter.setEditorEditable('PrefixNo', false);
}
return true;
};
Biz.prototype.fieldChangedIsDate = function (dataSrc, dr, dc) {
let isDate = TypeUtil.toString(dr['IsDate']);
let masterAdapter = this.view.vm['ep_dsMaster'];
if(isDate == '1') {
masterAdapter.setEditorEditable('DateFmt', true);
}else {
masterAdapter.setEditorEditable('DateFmt', false);
}
return true;
};
Biz.prototype.beforeEdit = function () {
let currentRow = this.dsMaster.currentRow;
let tblName = TypeUtil.toString(currentRow['BillHeadTbl']);
let ret = service.ControlCodeRule(tblName);
if(ret.result != 1) {
Store.messager.err(ret.message);
return false;
}
return this.super('beforeEdit');
}
Biz.prototype.afterEdit = function () {
let masterAdapter = this.view.vm['ep_dsMaster'];
let currentRow = this.dsMaster.currentRow;
let isRule = TypeUtil.toString(currentRow['IsRule']);
if(isRule == '0') {
masterAdapter.setEditorEditable('NoLength', false);
masterAdapter.setEditorEditable('IsPrefix', false);
masterAdapter.setEditorEditable('PrefixLen', false);
masterAdapter.setEditorEditable('PrefixNo', false);
masterAdapter.setEditorEditable('IsDate', false);
masterAdapter.setEditorEditable('DateFmt', false);
masterAdapter.setEditorEditable('SerialLen', false);
}else {
let isPrefix = TypeUtil.toString(currentRow['IsPrefix']);
if(isPrefix == '0') {
masterAdapter.setEditorEditable('PrefixLen', false);
masterAdapter.setEditorEditable('PrefixNo', false);
}
let isDate = TypeUtil.toString(currentRow['IsDate']);
if(isDate == '0') {
masterAdapter.setEditorEditable('DateFmt', false);
}
}
return this.super('beforeEdit');
}
//保存前数据判断
Biz.prototype.beforeSave = function () {
let currentRow = this.dsMaster.currentRow;
let ret = service.GetDBID();
if(ret.result != 1) {
Store.messager.err('获取DBID失败' + ret.message);
return false;
}
let noLength = ret.data.length;
let isPrefix = TypeUtil.toString(currentRow['IsPrefix']);
if(isPrefix == '1') {
let prefixLen = TypeUtil.toString(currentRow['PrefixLen']);
let prefixNo = TypeUtil.toString(currentRow['PrefixNo']);
if(prefixLen == '') {
Store.messager.err('请输入"前缀长度"');
return false;
}
if(prefixLen != prefixNo.length) {
Store.messager.err('“前缀”的长度与设置的“前缀长度”不一致!');
return false;
}
noLength += prefixNo.length;
}
let isDate = TypeUtil.toString(currentRow['IsDate']);
let dateFmt = TypeUtil.toString(currentRow['DateFmt']);
if(isDate == '1' && dateFmt == '') {
Store.messager.err('请输入"日期格式"');
return false;
}
noLength += dateFmt.length + TypeUtil.toFloat(currentRow['SerialLen']);
currentRow.setColumnValue('NoLength', noLength);
return this.super('beforeSave');
}
return Biz;
});