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.

252 lines
9.8 KiB

define(function (require, exports, module) {
//引入业务类基类
let BaseBiz = require('apps/rht/base/rhtBiz');
let rhtComm = require('apps/rht/comm/rhtComm');
//引入业务服务
let Service = require('./pri100104service');
/**
* 定义业务类对象
* @param vm 界面相关ViewModule
*/
function Biz(vm) {
//继承第一步,构造继承
BaseBiz.call(this, vm);
}
//继承第二步,方法继承
inherits(Biz, BaseBiz);
/**
* 全局变量
*/
let Prc_IsUrgChg = rhtComm.getRhtOptionValue(Store.logOn.orgCode,'PRC','Prc_IsUrgChg','0');
let UrgChgMaxLimit = TypeUtil.toFloat(rhtComm.getRhtOptionValue(Store.logOn.orgCode,'PRC','UrgChgMaxLimit','0'));
if (Prc_IsUrgChg != "1"){
UrgChgMaxLimit = 0;
}
let sEndDate = new Date(rhtComm.GetServerDateTime(UrgChgMaxLimit)).format('yyyy-MM-dd');
//保存前校验 计算主表合计数量等字段
Biz.prototype.beforeSave = function () {
let curRow = this.dsMaster.currentRow;
let EndDate = curRow['EndDate'];
let sdate=new Date(Store.bizDao.getSysDate()).format('yyyy-MM-dd');
if (EndDate <= sdate){
curRow.setColumnError('EndDate', "截止日期应大于当前日期!" );
return false;
}
if (EndDate > sEndDate){
curRow.setColumnError('EndDate', "截止日期应小于最大截止日期" +sEndDate);
return false;
}
return this.super('beforeSave');
}
//新增行后处理,默认值已经处理
Biz.prototype.afterNewRow = function (dataSrc, newRow) {
if (dataSrc.uiObjCode === this.dsMaster.uiObjCode) {
newRow.setColumnValue('YwType',"1004");
newRow.setColumnValue('EndDate', sEndDate);
}
};
//明细行单行提交触发的校验
Biz.prototype.dataRowValidate = function (dataSrc, dr) {
if (dataSrc.uiObjCode === this.dsDetail.uiObjCode) {
let NewPrice = TypeUtil.toFloat(dr['NewPrice']);
let NewHyPrice = TypeUtil.toFloat(dr['NewHyPrice']);
let NewPfPrice = TypeUtil.toFloat(dr['NewPfPrice']);
let CjPrice = TypeUtil.toFloat(dr['CjPrice']);
let CjHyPrice = TypeUtil.toFloat(dr['CjHyPrice']);
let CjPfPrice = TypeUtil.toFloat(dr['CjPfPrice']);
if (NewPrice <= 0) {
return "现售价应大于零!";
}
if (NewHyPrice <= 0) {
return "现会员价应大于零!";
}
if (NewPfPrice <= 0) {
return "现批发价应大于零!";
}
if ((CjPrice == 0) && (CjHyPrice == 0) && (CjPfPrice == 0)){
return "变价后价格等于原价,调整无效!";
}
}
return true;
}
/**
* @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 'NewPrice':
this.fieldChangedNewPrice(dataSrc, dr, dc);
break;
case 'NewHyPrice':
this.fieldChangedNewHyPrice(dataSrc, dr, dc);
break;
case 'NewPfPrice':
this.fieldChangedNewPfPrice(dataSrc, dr, dc);
break;
}
}
this.super('fieldChanged');
};
//PluCode 字段变化执行事件
Biz.prototype.fieldChangedPluCode = function (dataSrc, dr, dc) {
let PluCode = dr['PluCode'];
let ret= Service.getSlideMenuData("DoOnDetailCalcRule","PluCode","",Store.logOn.orgCode,PluCode,"","Price,HyPrice,PfPrice");
if (ret.result === 1) {
if (ret.data != null) {
dr.setColumnValue('Price', ret.data.Price);
dr.setColumnValue('HyPrice', ret.data.HyPrice);
dr.setColumnValue('PfPrice', ret.data.PfPrice);
dr.setColumnValue('NewPrice', ret.data.Price);
dr.setColumnValue('NewHyPrice', ret.data.HyPrice);
dr.setColumnValue('NewPfPrice', ret.data.PfPrice);
}
}
return true;
};
//NewPrice 字段变化执行事件
Biz.prototype.fieldChangedNewPrice = function (dataSrc, dr, dc) {
let NewPrice = TypeUtil.toFloat(dr['NewPrice']);
let Price = TypeUtil.toFloat(dr['Price']);
let PluID = TypeUtil.toString(dr['PluID']);
let PluCode = TypeUtil.toString(dr['PluCode']);
if (NewPrice < 0){
dr.setColumnError(dc.fieldName, "现售价不能小于零,请重新录入!");
return false;
}
if (PluID != ""){
let ret= Service.getSlideMenuData("DoOnDetailCalcRule","NewPrice",PluID,PluCode,Store.logOn.orgCode,"","");
if (ret.result === 1) {
if (ret.data != null) {
if (TypeUtil.toFloat(ret.data.HjPrice) > NewPrice) {
if (Prc_IsChgCmp =="1"){
if (!Store.confirm("商品售价小于商品最新进价,是否继续?")) {
return false;
}
}
else{
dr.setColumnError(dc.fieldName, "商品售价不允许小于商品最新进价:" + ret.data.HjPrice + ",请重新录入!");
return false;
}
}
}
}
else
{
dr.setColumnError(dc.fieldName, ret.message);
return false;
}
ret= Service.getSlideMenuData("DoOnDetailCalcRule","NewPricePluEx",PluID,PluCode,Store.logOn.orgCode,NewPrice,"");
if (ret.result === 2) {
dr.setColumnError(dc.fieldName, ret.message);
}
else if (ret.result !== 1)
{
dr.setColumnError(dc.fieldName, ret.message);
return false;
}
dr.setColumnValue('CjPrice', (NewPrice-Price).round(2));
}
return true;
};
//NewHyPrice 字段变化执行事件
Biz.prototype.fieldChangedNewHyPrice = function (dataSrc, dr, dc) {
let NewPrice = TypeUtil.toFloat(dr['NewPrice']);
let NewHyPrice = TypeUtil.toFloat(dr['NewHyPrice']);
let HyPrice = TypeUtil.toFloat(dr['HyPrice']);
let PluID = TypeUtil.toString(dr['PluID']);
if (NewHyPrice < 0){
dr.setColumnError(dc.fieldName, "现会员价不能小于零,请重新录入!");
return false;
}
if (PluID != ""){
if (NewHyPrice > NewPrice){
dr.setColumnError(dc.fieldName, "会员价不应大于售价!");
return false;
}
}
dr.setColumnValue('CjHyPrice', (NewHyPrice-HyPrice).round(2));
return true;
};
//NewPfPrice 字段变化执行事件
Biz.prototype.fieldChangedNewPfPrice = function (dataSrc, dr, dc) {
let NewPfPrice = TypeUtil.toFloat(dr['NewPfPrice']);
let PfPrice = TypeUtil.toFloat(dr['PfPrice']);
let PluID = TypeUtil.toString(dr['PluID']);
let PluCode = TypeUtil.toString(dr['PluCode']);
if (NewPfPrice < 0){
dr.setColumnError(dc.fieldName, "批发价不能小于零,请重新录入!");
return false;
}
if (PluID != ""){
let ret= Service.getSlideMenuData("DoOnDetailCalcRule","NewPfPrice",PluID,PluCode,Store.logOn.orgCode,NewPfPrice,"");
if (ret.result !== 1) {
dr.setColumnError(dc.fieldName, ret.message);
return false;
}
}
dr.setColumnValue('CjPfPrice', (NewPfPrice-PfPrice).round(2));
return true;
};
//按钮事件控制
Biz.prototype.doOp = function (opCode) {
let self = this;
if (opCode == 'review') {
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 == 'review') {
//let IsEnabled = curRow ? TypeUtil.toString(curRow['IsEnabled']) : '';
//let DataStatus = curRow ? TypeUtil.toString(curRow['DataStatus']) : '';
if (!curRow)
return false;
//if ((IsEnabled !="1") && (DataStatus == "9"))
// return false;
}
return true;
};
return Biz;
});