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.

158 lines
5.0 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 rhtService = require('../../base/rhtService');
let rhtComm = require('apps/rht/comm/rhtComm');
//引入业务服务
let Service = require('./cnt070103service');
/**
* 定义业务类对象
* @param vm 界面相关ViewModule
*/
function Biz(vm) {
//继承第一步,构造继承
BaseBiz.call(this, vm);
}
//继承第二步,方法继承
inherits(Biz, BaseBiz);
let orgType = rhtComm.GetOrgType(Store.logOn.orgCode);
//控制主界面按钮状态
Biz.prototype.getOpEnabled = function (opCode) {
let self = this;
let isOk = this.super('getOpEnabled', opCode);
if (!isOk) return false;
let curRow = this.dsMaster.currentRow;
let zkAreaCode = curRow ? TypeUtil.toString(curRow.ZkAreaCode) : '';
if (opCode == 'add') {
if(orgType != '1001')
return false;
}
if (opCode == 'edit') {
if (!curRow)
return false;
if(orgType != '1001')
return false;
if(zkAreaCode == '*0' || zkAreaCode == '*1' || zkAreaCode == '*2')
return false;
}
if (opCode == 'delete') {
if (!curRow)
return false;
if(orgType != '1001')
return false;
if(zkAreaCode == '*0' || zkAreaCode == '*1' || zkAreaCode == '*2')
return false;
}
return true;
};
/**
* @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 'MinZkRate':
this.fieldChangedMinZkRate(dataSrc, dr, dc);
break;
case 'MaxZkRate':
this.fieldChangedMaxZkRate(dataSrc, dr, dc);
break;
}
}
return this.super('fieldChanged');
};
Biz.prototype.fieldChangedMinZkRate = function (dataSrc, dr, dc) {
let minZkRate = TypeUtil.toFloat(dr.MinZkRate);
let maxZkRate = TypeUtil.toFloat(dr.MaxZkRate);
if(minZkRate < 0 || minZkRate > 100) {
dr.setColumnError('MinZkRate', '折扣下限必须在0~100之间');
return false;
}
return true;
};
Biz.prototype.fieldChangedMaxZkRate = function (dataSrc, dr, dc) {
let minZkRate = TypeUtil.toFloat(dr.MinZkRate);
let maxZkRate = TypeUtil.toFloat(dr.MaxZkRate);
if(maxZkRate < 0 || maxZkRate > 100) {
dr.setColumnError('MaxZkRate', '折扣上限必须在0~100之间');
return false;
}
return true;
};
//添加后执行
Biz.prototype.afterAdd = function () {
let masterAdapter = this.view.vm['ep_dsMaster'];
masterAdapter.setEditorEditable('ZkAreaCode', true);
return this.super('afterAdd');
};
Biz.prototype.afterEdit = function () {
let masterAdapter = this.view.vm['ep_dsMaster'];
masterAdapter.setEditorEditable('ZkAreaCode', false);
return this.super('afterEdit');
}
//保存前校验
Biz.prototype.beforeSave = function () {
let curRow = this.dsMaster.currentRow;
let zkAreaCode = TypeUtil.toString(curRow.ZkAreaCode);
let zkType = TypeUtil.toString(curRow.ZkType);
let minZkRate = TypeUtil.toFloat(curRow.MinZkRate);
let maxZkRate = TypeUtil.toFloat(curRow.MaxZkRate);
if(minZkRate > maxZkRate) {
Store.messager.err('折扣下限不能大于折扣上限!');
return false;
}
let ret = Service.ChkZkArea(zkAreaCode, zkType, minZkRate, maxZkRate);
if (ret.result != 1) {
Store.messager.err(ret.message);
return false;
}
return this.super('beforeSave');
};
/**
* 删除前询问,通常进行一些删除前校验操作
* 默认操作会提示‘确定删除?’询问
* @return {Boolean,String} 返回操作是否被允许,只有false时才会不允许执行其他则作为提示询问用户
*
*/
Biz.prototype.beforeDelete = function () {
let curRow = this.dsMaster.currentRow;
let zkAreaCode = TypeUtil.toString(curRow.ZkAreaCode);
let ret = Service.ChkZkAreaDel(zkAreaCode);
if (ret.result != 1) {
Store.messager.err(ret.message);
return false;
}
return this.super('beforeDelete');
};
return Biz;
});