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.
169 lines
5.9 KiB
169 lines
5.9 KiB
|
|
define(function (require, exports, module) {
|
|
//引入业务类基类
|
|
let BaseBiz = require('apps/rht/base/rhtBiz');
|
|
|
|
//引入业务服务
|
|
let Service = require('./pri100105service');
|
|
|
|
/**
|
|
* 定义业务类对象
|
|
* @param vm 界面相关ViewModule
|
|
*/
|
|
function Biz(vm) {
|
|
//继承第一步,构造继承
|
|
BaseBiz.call(this, vm);
|
|
}
|
|
|
|
//继承第二步,方法继承
|
|
inherits(Biz, BaseBiz);
|
|
|
|
/**
|
|
* 全局变量
|
|
*/
|
|
//let PRC_REDUCEMODE = rhtComm.getRhtOptionValue("*",'PRC','PRC_REDUCEMODE','0');
|
|
|
|
//保存前校验 计算主表合计数量等字段
|
|
Biz.prototype.beforeSave = function () {
|
|
let curRow = this.dsMaster.currentRow;
|
|
if(curRow){
|
|
let XjCount = 0.0;
|
|
let OPriTotal = 0.0;
|
|
let PriTotal = 0.0;
|
|
let XjCeTotal = 0.0;
|
|
for(let i=0;i<this.dsDetail.rows.length;i++){
|
|
let row = this.dsDetail.rows[i];
|
|
XjCount = XjCount + TypeUtil.toFloat(row['XjCount']);
|
|
OPriTotal = OPriTotal + TypeUtil.toFloat(row['OPriTotal']);
|
|
PriTotal = PriTotal + TypeUtil.toFloat(row['PriTotal']);
|
|
XjCeTotal = XjCeTotal + TypeUtil.toFloat(row['XjCeTotal']);
|
|
}
|
|
curRow.setColumnValue('XjCount',XjCount);
|
|
curRow.setColumnValue('OPriTotal',OPriTotal);
|
|
curRow.setColumnValue('PriTotal',PriTotal);
|
|
curRow.setColumnValue('XjCeTotal',XjCeTotal);
|
|
}
|
|
return this.super('beforeSave');
|
|
}
|
|
//新增行后处理,默认值已经处理
|
|
Biz.prototype.afterNewRow = function (dataSrc, newRow) {
|
|
if (dataSrc.uiObjCode === this.dsMaster.uiObjCode) {
|
|
newRow.setColumnValue('YwType',"1009");
|
|
}
|
|
};
|
|
//明细行单行提交触发的校验
|
|
Biz.prototype.dataRowValidate = function (dataSrc, dr) {
|
|
if (dataSrc.uiObjCode === this.dsDetail.uiObjCode) {
|
|
let Price = TypeUtil.toFloat(dr['Price']);
|
|
let XjCount = TypeUtil.toFloat(dr['XjCount']);
|
|
if (Price <= 0) {
|
|
return "售价应大于零!";
|
|
}
|
|
if (XjCount <= 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 'Price':
|
|
this.fieldChangedPrice(dataSrc, dr, dc);
|
|
break;
|
|
case 'XjCount':
|
|
this.fieldChangedXjCount(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.setColumnText('PluName', ret.data.PluName);
|
|
dr.setColumnValue('OldPrice', ret.data.Price);
|
|
dr.setColumnValue('Price', ret.data.Price);
|
|
dr.setColumnText('NewBarCode', ret.data.NewBarCode);
|
|
}
|
|
}
|
|
return true;
|
|
};
|
|
//Price 字段变化执行事件
|
|
Biz.prototype.fieldChangedPrice = function (dataSrc, dr, dc) {
|
|
let Price = TypeUtil.toFloat(dr['Price']);
|
|
if (Price < 0){
|
|
dr.setColumnError(dc.fieldName, "现售价不能小于零,请重新录入!");
|
|
return false;
|
|
}
|
|
return true;
|
|
};
|
|
//XjCount 字段变化执行事件
|
|
Biz.prototype.fieldChangedXjCount = function (dataSrc, dr, dc) {
|
|
let XjCount = TypeUtil.toFloat(dr['XjCount']);
|
|
if (XjCount < 0){
|
|
dr.setColumnError(dc.fieldName, "削价商品数量不能小于零,请重新录入!");
|
|
return false;
|
|
}
|
|
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;
|
|
}); |