|
|
|
|
|
define(function (require, exports, module) {
|
|
|
//引入业务类基类
|
|
|
let BaseBiz = require('apps/rht/base/rhtBiz');
|
|
|
let rhtComm = require('apps/rht/comm/rhtComm');
|
|
|
|
|
|
//引入业务服务
|
|
|
let Service = require('./pri10020201service');
|
|
|
|
|
|
/**
|
|
|
* 定义业务类对象
|
|
|
* @param vm 界面相关ViewModule
|
|
|
*/
|
|
|
function Biz(vm) {
|
|
|
//继承第一步,构造继承
|
|
|
BaseBiz.call(this, vm);
|
|
|
}
|
|
|
|
|
|
//继承第二步,方法继承
|
|
|
inherits(Biz, BaseBiz);
|
|
|
|
|
|
/**
|
|
|
* 全局变量
|
|
|
*/
|
|
|
let PluMlLimit = rhtComm.getRhtOptionValue("*",'CAT','PluMlLimit','0');
|
|
|
|
|
|
Biz.prototype.beforeFieldEdit = function(dataSrc, dr, dc) {
|
|
|
let masterRow = this.dsMaster.currentRow;
|
|
|
// 0-售价;1-成本配送价;2-加点配送价;3-固定价配送价;4-自由价配送价
|
|
|
var PriceType = TypeUtil.toString(masterRow['PriceType']);
|
|
|
if (dataSrc.uiObjCode == this.dsDetail.uiObjCode) {
|
|
|
if (dc.fieldName == 'Price') {
|
|
|
if (PriceType !== '3') {
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
if (dc.fieldName == 'JdRate') {
|
|
|
if (PriceType !== '2') {
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
return this.super('beforeFieldEdit', dataSrc, dr, dc);
|
|
|
};
|
|
|
//保存前校验 计算主表合计数量等字段
|
|
|
Biz.prototype.beforeSave = function () {
|
|
|
let curRow = this.dsMaster.currentRow;
|
|
|
if(curRow){
|
|
|
let ZcMode = TypeUtil.toString(curRow['ZcMode']);
|
|
|
if (ZcMode == "1") {
|
|
|
let BgnDate = TypeUtil.toString(curRow['BgnDate']);
|
|
|
let EndDate = TypeUtil.toString(curRow['EndDate']);
|
|
|
let sdate=new Date(Store.bizDao.getSysDate()).format('yyyy-MM-dd');
|
|
|
if (sdate > BgnDate){
|
|
|
curRow.setColumnError('BgnDate', "促销开始日期应大于等于当前日期!" );
|
|
|
return false;
|
|
|
}
|
|
|
if (EndDate < BgnDate){
|
|
|
curRow.setColumnError('EndDate', "促销结束日期应大于等于开始日期!" );
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
let JgZcCode = TypeUtil.toString(curRow['JgZcCode']);
|
|
|
let ret= Service.getSlideMenuData("OtherProcess","UJgzcIsUsed",JgZcCode,"2",Store.logOn.orgCode,"","");
|
|
|
if (ret.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 retChk= Service.getSlideMenuData("OtherProcess","ChkMlRate",PluCode,"","","","");
|
|
|
if (retChk.result === 1) {
|
|
|
if (retChk.data != null) {
|
|
|
let curMinMlRate=TypeUtil.toFloat(retChk.data.MinMlRate);
|
|
|
let curMaxMlRate=TypeUtil.toFloat(retChk.data.MaxMlRate);
|
|
|
let HjPrice=TypeUtil.toFloat(retChk.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;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
let iPri = "0";
|
|
|
let retPri= Service.getSlideMenuData("OtherProcess","GetPri",ZcMode,"","","","");
|
|
|
if (retPri.result === 1) {
|
|
|
if (retPri.data != null){
|
|
|
iPri = retPri.data.Pri;
|
|
|
}
|
|
|
}
|
|
|
curRow.setColumnValue('Pri', iPri);
|
|
|
}
|
|
|
return this.super('beforeSave');
|
|
|
};
|
|
|
//明细行单行提交触发的校验
|
|
|
Biz.prototype.dataRowValidate = function (dataSrc, dr) {
|
|
|
if (dataSrc.uiObjCode === this.dsDetail.uiObjCode) {
|
|
|
let masterRow = this.dsMaster.currentRow;
|
|
|
let Price = TypeUtil.toFloat(dr['Price']);
|
|
|
let JdRate = TypeUtil.toFloat(dr['JdRate']);
|
|
|
|
|
|
let PriceType = TypeUtil.toFloat(masterRow['PriceType']);
|
|
|
|
|
|
if (Price < 0) {
|
|
|
return "配送价不能小于零!";
|
|
|
}
|
|
|
if ((PriceType == "2") && (JdRate <= 0)) {
|
|
|
return "加点配送价加点率不能为零!";
|
|
|
}
|
|
|
if ((PriceType == "3") && (Price == 0)) {
|
|
|
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,"2",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.dsMaster.uiObjCode) {
|
|
|
switch (dc.fieldName) {
|
|
|
case 'ZcMode':
|
|
|
this.fieldChangedZcMode(dataSrc, dr, dc);
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
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;
|
|
|
case 'JdRate':
|
|
|
this.fieldChangedJdRate(dataSrc, dr, dc);
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
this.super('fieldChanged');
|
|
|
};
|
|
|
//ZcMode 字段变化执行事件
|
|
|
Biz.prototype.fieldChangedZcMode = function (dataSrc, dr, dc) {
|
|
|
let ZcMode = TypeUtil.toString(dr['ZcMode']);
|
|
|
if (ZcMode == "1") {
|
|
|
let sBgnDate = new Date(rhtComm.GetServerDateTime(0)).format('yyyy-MM-dd');
|
|
|
let sEndDate = new Date(rhtComm.GetServerDateTime(10)).format('yyyy-MM-dd');
|
|
|
dr.setColumnValue('BgnDate', sBgnDate);
|
|
|
dr.setColumnValue('EndDate', sEndDate);
|
|
|
}
|
|
|
else{
|
|
|
dr.setColumnValue('BgnDate', "");
|
|
|
dr.setColumnValue('EndDate', "");
|
|
|
}
|
|
|
return true;
|
|
|
};
|
|
|
//PluCode 字段变化执行事件
|
|
|
Biz.prototype.fieldChangedPluCode = function (dataSrc, dr, dc) {
|
|
|
let PluID = TypeUtil.toString(dr['PluID']);
|
|
|
let PluCode = TypeUtil.toString(dr['PluCode']);
|
|
|
let ZcType = TypeUtil.toString(dr['ZcType']);
|
|
|
let PriceType = TypeUtil.toString(dr['PriceType']);
|
|
|
let ret= Service.getSlideMenuData("DoOnDetailCalcRule","PluCode",PluID,PluCode,Store.logOn.orgCode,"","");
|
|
|
if (ret.result === 1) {
|
|
|
if (ret.data != null) {
|
|
|
if ((ZcType == "1") && ((PriceType == "3") || (PriceType == "4"))){
|
|
|
dr.setColumnValue('Price', ret.data.Price);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
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;
|
|
|
};
|
|
|
//JdRate 字段变化执行事件
|
|
|
Biz.prototype.fieldChangedJdRate = function (dataSrc, dr, dc) {
|
|
|
let PluCode = TypeUtil.toString(dr['PluCode']);
|
|
|
let JdRate = TypeUtil.toFloat(dr['JdRate']);
|
|
|
if (JdRate != 0){
|
|
|
let ret= Service.getSlideMenuData("DoOnDetailCalcRule","JdRate","",PluCode,"","","");
|
|
|
if (ret.result === 1) {
|
|
|
if (ret.data === null) {
|
|
|
dr.setColumnError(dc.fieldName, "当前组织没有经营此商品!");
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
else{
|
|
|
dr.setColumnError(dc.fieldName, ret.message);
|
|
|
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,"2",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,"2",Store.logOn.orgCode,"","");
|
|
|
if (ret.result === 1) {
|
|
|
return false;
|
|
|
}
|
|
|
if (ret.result === -1) {
|
|
|
Store.messager.err("查询价格政策组织对应失败!"+ret.message);
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
return true;
|
|
|
};
|
|
|
return Biz;
|
|
|
}); |