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.

209 lines
8.4 KiB

4 years ago
define(function (require, exports, module) {
//引入业务类基类
let BaseBiz = require('apps/rht/base/rhtBiz');
let rhtComm = require('apps/rht/comm/rhtComm');
//引入业务服务
let Service = require('./pri10020101service');
/**
* 定义业务类对象
* @param vm 界面相关ViewModule
*/
function Biz(vm) {
//继承第一步,构造继承
BaseBiz.call(this, vm);
}
//继承第二步,方法继承
inherits(Biz, BaseBiz);
/**
* 全局变量
*/
let PluMlLimit = rhtComm.getRhtOptionValue("*",'CAT','PluMlLimit','0');
//保存前校验 计算主表合计数量等字段
Biz.prototype.beforeSave = function () {
let curRow = this.dsMaster.currentRow;
if(curRow){
let JgZcCode = TypeUtil.toString(curRow['JgZcCode']);
let retUsed= Service.getSlideMenuData("OtherProcess","UJgzcIsUsed",JgZcCode,"1",Store.logOn.orgCode,"","");
if (retUsed.result !== 0) {
curRow.setColumnError('JgZcCode', '售价政策已被使用不能再编辑!');
return false;
}
for(let i=0;i<this.dsDetail.rows.length;i++){
if (PluMlLimit == "1"){
let row = this.dsDetail.rows[i];
let PluCode = TypeUtil.toString(row['PluCode']);
let PluName = TypeUtil.toString(row['PluName']);
let NewPrice = TypeUtil.toFloat(row['Price']);
let ret= Service.getSlideMenuData("OtherProcess","ChkMlRate",PluCode,"","","","");
if (ret.result === 1) {
if (ret.data != null) {
let curMinMlRate=TypeUtil.toFloat(ret.data.MinMlRate);
let curMaxMlRate=TypeUtil.toFloat(ret.data.MaxMlRate);
let HjPrice=TypeUtil.toFloat(ret.data.HjPrice);
if ((curMinMlRate != 0) || (curMaxMlRate != 0) || (NewPrice != 0)){
let curRate = ((NewPrice - HjPrice) * 10000 / NewPrice).round(0) / 100;
if ((curMinMlRate != 0) && (curRate < curMinMlRate)){
if (!Store.confirm("商品["+PluName+"]进价为"+HjPrice+",售价为"+NewPrice+",毛利率为"+curRate+",毛利率低于品类最低毛利率"+curMinMlRate+"的限制,是否继续?")) {
return false;
}
}
if ((curMaxMlRate != 0) && (curRate > curMaxMlRate)){
if (!Store.confirm("商品["+PluName+"]进价为"+HjPrice+",售价为"+NewPrice+",毛利率为"+curRate+",毛利率低于品类最高毛利率"+curMaxMlRate+"的限制,是否继续?")) {
return false;
}
}
}
}
}
}
}
}
return this.super('beforeSave');
};
//明细行单行提交触发的校验
Biz.prototype.dataRowValidate = function (dataSrc, dr) {
if (dataSrc.uiObjCode === this.dsDetail.uiObjCode) {
let Price = TypeUtil.toFloat(dr['Price']);
let HyPrice = TypeUtil.toFloat(dr['HyPrice']);
if (Price <= 0) {
return "售价应大于零!";
}
if (HyPrice > Price) {
return "会员价不应大于售价!";
}
}
return true;
};
//单据删除前处理
Biz.prototype.beforeDelete = function () {
let masterRow = this.dsMaster.currentRow;
let JgZcCode = TypeUtil.toString(masterRow['JgZcCode']);
if (masterRow){
let ret= Service.getSlideMenuData("OtherProcess","UJgzcIsUsed",JgZcCode,"1",Store.logOn.orgCode,"","");
if (ret.result !== 0) {
masterRow.setColumnError('JgZcCode', '售价政策已被使用不能被删除!');
return false;
}
}
return this.super('beforeDelete');
};
/**
* @description 数据发生变化时调用
* @param dataSrc 数据集
* @param dr 数据行
* @param dc 数据列
*/
Biz.prototype.fieldChanged = function (dataSrc, dr, dc) {
let self = this;
let currentRow = self.dsMaster.currentRow;
if (currentRow === null) return false;
if (dataSrc.uiObjCode === this.dsDetail.uiObjCode) {
switch (dc.fieldName) {
case 'PluCode':
this.fieldChangedPluCode(dataSrc, dr, dc);
break;
case 'HyPrice':
this.fieldChangedHyPrice(dataSrc, dr, dc);
break;
}
}
this.super('fieldChanged');
};
//PluCode 字段变化执行事件
Biz.prototype.fieldChangedPluCode = function (dataSrc, dr, dc) {
let PluID = TypeUtil.toString(dr['PluID']);
let PluCode = TypeUtil.toString(dr['PluCode']);
let ret= Service.getSlideMenuData("DoOnDetailCalcRule","PluCode",PluID,PluCode,Store.logOn.orgCode,"","");
if (ret.result === 1) {
if (ret.data != null) {
dr.setColumnValue('UptDate', rhtComm.GetServerDateTime(0).toString());
dr.setColumnValue('Price', ret.data.Price);
dr.setColumnValue('HyPrice', ret.data.HyPrice);
}
}
return true;
};
//HyPrice 字段变化执行事件
Biz.prototype.fieldChangedHyPrice = function (dataSrc, dr, dc) {
let HyPrice = TypeUtil.toFloat(dr['HyPrice']);
if (HyPrice < 0){
dr.setColumnError(dc.fieldName, "会员售价不能小于零,请重新录入!");
return false;
}
return true;
};
//按钮事件控制
Biz.prototype.doOp = function (opCode) {
let self = this;
if (opCode == 'edit') {
let ds = self.dsMaster;
this.onreview(self, ds);
}
};
//手调按钮事件
Biz.prototype.onreview = function (biz, ds) {
let dsrow=ds.currentRow;
let BillNo = dsrow ? TypeUtil.toString(dsrow['BillNo']) : '';
let ret= Service.getSlideMenuData("actExecute","onreview",BillNo,PluID);
if (ret.result === 1) {
biz.dsMaster.updateRow();
}
else
{
Store.messager.err("记账失败!"+ret.message);
return false;
}
return true;
};
//控制主界面按钮状态
Biz.prototype.getOpEnabled = function (opCode) {
let isOk = this.super('getOpEnabled', opCode);
if (!isOk) return false;
let curRow = this.dsMaster.currentRow;
if (opCode == 'edit') {
let OrgCode = curRow ? TypeUtil.toString(curRow['OrgCode']) : '';
let JgZcCode = curRow ? TypeUtil.toString(curRow['JgZcCode']) : '';
if (!curRow)
return false;
if (OrgCode != Store.logOn.orgCode)
return false;
let ret= Service.getSlideMenuData("OtherProcess","UJgzcIsUsed",JgZcCode,"1",Store.logOn.orgCode,"","");
if (ret.result === 1) {
return false;
}
if (ret.result === -1) {
Store.messager.err("查询价格政策组织对应失败!"+ret.message);
return false;
}
}
if (opCode == 'delete') {
let OrgCode = curRow ? TypeUtil.toString(curRow['OrgCode']) : '';
let JgZcCode = curRow ? TypeUtil.toString(curRow['JgZcCode']) : '';
if (!curRow)
return false;
if (OrgCode != Store.logOn.orgCode)
return false;
let ret= Service.getSlideMenuData("OtherProcess","UJgzcIsUsed",JgZcCode,"1",Store.logOn.orgCode,"","");
if (ret.result === 1) {
return false;
}
if (ret.result === -1) {
Store.messager.err("查询价格政策组织对应失败!"+ret.message);
return false;
}
}
return true;
};
return Biz;
});