|
|
define(function (require, exports, module) {
|
|
|
let BaseBiz = require('apps/rht/base/rhtBiz');
|
|
|
let Service = require('./cou190205service');
|
|
|
let rhtComm = require('../../comm/rhtComm');
|
|
|
/**
|
|
|
* 控制按钮的可用
|
|
|
* @param opCode 按钮编码
|
|
|
* @return [description]
|
|
|
*/
|
|
|
|
|
|
function Biz(vm) {
|
|
|
//继承第一步,构造继承
|
|
|
BaseBiz.call(this, vm);
|
|
|
vm.remark =''
|
|
|
}
|
|
|
|
|
|
//继承第二步,方法继承
|
|
|
inherits(Biz, BaseBiz);
|
|
|
|
|
|
let Cou_LsPdDataLrPacket = rhtComm.getRhtOptionValue('*','COU','Cou_LsPdDataLrPacket','1');
|
|
|
let COU_PdDataKcPacket = rhtComm.getRhtOptionValue('*','COU','COU_PdDataKcPacket','1');
|
|
|
let Cou_LsPdDataLrMulti = rhtComm.getRhtOptionValue('*','COU','Cou_LsPdDataLrMulti','1');
|
|
|
let Cou_LsSamePdLrMulti = rhtComm.getRhtOptionValue('*','COU','Cou_LsSamePdLrMulti','1');
|
|
|
|
|
|
//功能初始化完毕调用该方法
|
|
|
Biz.prototype.initCompleted = function() {
|
|
|
let Cou_LsPdDataLrDep = rhtComm.getRhtOptionValue('*','COU','Cou_LsPdDataLrDep','1');
|
|
|
if (Cou_LsPdDataLrDep != "1"){
|
|
|
this.dsDetail.getColumn('DepCode').set('isEditable',false);
|
|
|
}
|
|
|
if (Cou_LsPdDataLrPacket != "1"){
|
|
|
this.dsDetail.getColumn('PackUnit').set('isEditable',false);
|
|
|
this.dsDetail.getColumn('PackQty').set('isEditable',false);
|
|
|
this.dsDetail.getColumn('PackCount').set('isEditable',false);
|
|
|
}
|
|
|
return this.super('initCompleted');
|
|
|
};
|
|
|
//单据编辑前处理
|
|
|
Biz.prototype.beforeEdit = function () {
|
|
|
let masterRow = this.dsMaster.currentRow;
|
|
|
let sSpDataType = TypeUtil.toString(masterRow['SpDataType']);
|
|
|
if ((sSpDataType == '0') && (Cou_LsPdDataLrMulti == "1")){
|
|
|
this.dsDetail.multiType = "0";
|
|
|
this.dsDetail.multiFields = "";
|
|
|
this.dsDetail.multiMsg = "";
|
|
|
}
|
|
|
else{
|
|
|
this.dsDetail.multiType = "1";
|
|
|
this.dsDetail.multiFields = "DepCode,PluCode,ExPluCode";
|
|
|
this.dsDetail.multiMsg = "不能重复录入商品!";
|
|
|
}
|
|
|
return this.super('beforeEdit');
|
|
|
};
|
|
|
//明细行单行提交触发的校验
|
|
|
Biz.prototype.dataRowValidate = function (dataSrc, dr) {
|
|
|
if (dataSrc.uiObjCode === this.dsDetail.uiObjCode) {
|
|
|
let masterRow = this.dsMaster.currentRow;
|
|
|
let sSpDataType = TypeUtil.toString(masterRow['SpDataType']);
|
|
|
let sPdBillNo = TypeUtil.toString(masterRow['PdBillNo']);
|
|
|
let sPluCode = TypeUtil.toString(dr['PluCode']);
|
|
|
let sPluID = TypeUtil.toString(dr['PluID']);
|
|
|
if (sPluCode.length > 0) {
|
|
|
if ((Cou_LsSamePdLrMulti != "1" ) && (sSpDataType == "0")) {
|
|
|
let ret= Service.getSlideMenuData("DoOnDetailCalcRule","UChecIsExistPlu", sPdBillNo,sPluID,"","","");
|
|
|
if (ret.result !== 1) {
|
|
|
return ret.message;
|
|
|
}
|
|
|
}
|
|
|
if ((Cou_LsPdDataLrPacket == "1") && (COU_PdDataKcPacket == "1")){
|
|
|
let retPacket= Service.getSlideMenuData("DoOnDetailCalcRule","CheckKcPacket",JSONObject,"","","","");
|
|
|
if (retPacket.result !== 1) {
|
|
|
return "输入此商品的包装单位必须是库存基础包装!";
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
return true;
|
|
|
};
|
|
|
// 列校验,列赋值时调用,发生异常表示校验失败
|
|
|
Biz.prototype.dataColumnValidate = function (dataSrc, dr, dc, value) {
|
|
|
if (dataSrc.uiObjCode === this.dsDetail.uiObjCode) {
|
|
|
if (this.dsDetail.rows.length == 0){
|
|
|
let masterRow = this.dsMaster.currentRow;
|
|
|
let sSpDataType = TypeUtil.toString(masterRow['SpDataType']);
|
|
|
let sPdBillNo = TypeUtil.toString(masterRow['PdBillNo']);
|
|
|
let ret= Service.getSlideMenuData("DoOnDetailCalcRule","CouSpDataLrChk", sPdBillNo,sSpDataType,"","","");
|
|
|
if (ret.result !== 1) {
|
|
|
dr.setColumnError("BillNo", ret.message);
|
|
|
return false;
|
|
|
}
|
|
|
if ((sSpDataType == '0') && (Cou_LsPdDataLrMulti == "1")){
|
|
|
this.dsDetail.multiType = "0";
|
|
|
this.dsDetail.multiFields = "";
|
|
|
this.dsDetail.multiMsg = "";
|
|
|
}
|
|
|
else{
|
|
|
this.dsDetail.multiType = "1";
|
|
|
this.dsDetail.multiFields = "DepCode,PluCode,ExPluCode";
|
|
|
this.dsDetail.multiMsg = "不能重复录入商品!";
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
return this.super('dataColumnValidate');
|
|
|
};
|
|
|
//校验小数精度
|
|
|
Biz.prototype.getPrecision = function (dataSrc, dr, dc, defaultPrecision) {
|
|
|
if (dataSrc.uiObjCode == this.dsDetail.uiObjCode) {
|
|
|
//把这里改成需要控制的字段
|
|
|
if (dc.fieldName == 'SjCount') {
|
|
|
return TypeUtil.toInt(dr['R_DotDecimal']);
|
|
|
}
|
|
|
}
|
|
|
return this.super('getPrecision', dataSrc, dr, dc, defaultPrecision);
|
|
|
};
|
|
|
//字段变化触发事件
|
|
|
Biz.prototype.fieldChanged = function (dataSrc, dr, dc) {
|
|
|
if (dataSrc.uiObjCode === this.dsMaster.uiObjCode) {
|
|
|
switch (dc.fieldName) {
|
|
|
case 'PdBillNo':
|
|
|
this.fieldChangedPdBillNo(dataSrc, dr, dc);
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
if (dataSrc.uiObjCode === this.dsDetail.uiObjCode) {
|
|
|
switch (dc.fieldName) {
|
|
|
case 'PluCode':
|
|
|
this.fieldChangedPluCode(dataSrc, dr, dc);
|
|
|
break;
|
|
|
case 'DepCode':
|
|
|
this.fieldChangedDepCode(dataSrc, dr, dc);
|
|
|
break;
|
|
|
case 'PackCount':
|
|
|
this.fieldChangedPackCount(dataSrc, dr, dc);
|
|
|
break;
|
|
|
case 'PackUnit':
|
|
|
this.fieldChangedPackUnit(dataSrc, dr, dc);
|
|
|
break;
|
|
|
case 'SglCount':
|
|
|
this.fieldChangedSglCount(dataSrc, dr, dc);
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
this.super('fieldChanged');
|
|
|
};
|
|
|
//PdBillNo 字段变化执行事件
|
|
|
Biz.prototype.fieldChangedPdBillNo = function (dataSrc, dr, dc) {
|
|
|
let sPdBillNo = TypeUtil.toString(dr['PdBillNo']);
|
|
|
let sSpDataType = "0";
|
|
|
if (sPdBillNo.length > 0){
|
|
|
let ret= Service.getSlideMenuData("DoOnMasterRule","PdBillNo", sPdBillNo,"","","","");
|
|
|
if (ret.result === 1) {
|
|
|
sSpDataType = "1";
|
|
|
}
|
|
|
dr.setColumnValue('OrgCode', dc.getRefValue('orgcode'));
|
|
|
dr.setColumnValue('OrgName', dc.getRefValue('orgname'));
|
|
|
dr.setColumnValue('InOrgCode', dc.getRefValue('inorgcode'));
|
|
|
dr.setColumnValue('DeptId', dc.getRefValue('deptid'));
|
|
|
dr.setColumnValue('DepCode', dc.getRefValue('depcode'));
|
|
|
dr.setColumnValue('DepName', dc.getRefValue('depname'));
|
|
|
dr.setColumnValue('CkCode', dc.getRefValue('ckcode'));
|
|
|
dr.setColumnValue('CkName', dc.getRefValue('ckname'));
|
|
|
dr.setColumnValue('BillType', dc.getRefValue('billtype'));
|
|
|
dr.setColumnText('LyType', "0");
|
|
|
dr.setColumnText('SpDataType', sSpDataType);
|
|
|
}
|
|
|
return true;
|
|
|
};
|
|
|
//PluCode 字段变化执行事件
|
|
|
Biz.prototype.fieldChangedPluCode = function (dataSrc, dr, dc) {
|
|
|
let masterRow = this.dsMaster.currentRow;
|
|
|
let sPdBillNo = TypeUtil.toString(masterRow['PdBillNo']);
|
|
|
let sPluCode = dr ? TypeUtil.toString(dr['PluCode']) : '';
|
|
|
let sPluID = dr ? TypeUtil.toString(dr['PluID']) : '';
|
|
|
let sDepCode = dr ? TypeUtil.toString(dr['DepCode']) : '';
|
|
|
if (sPluCode === '') return false;
|
|
|
|
|
|
let ret= Service.getSlideMenuData("DoOnDetailCalcRule","PluCode", sPdBillNo, sPluCode,"","","");
|
|
|
if (ret.result !== 1) {
|
|
|
dr.setColumnError(dc.fieldName, ret.message);
|
|
|
return false;
|
|
|
}
|
|
|
if (ret.data != null) {
|
|
|
dr.setColumnValue('ExPluCode', ret.data.explucode);
|
|
|
dr.setColumnValue('ExPluName', ret.data.expluname);
|
|
|
if (sDepCode.length <= 0){
|
|
|
dr.setColumnValue('DeptId', ret.data.depid);
|
|
|
dr.setColumnValue('DepCode', ret.data.depcode);
|
|
|
dr.setColumnValue('DepName', ret.data.depname);
|
|
|
sDepCode = ret.data.depcode;
|
|
|
}
|
|
|
}
|
|
|
let retchk= Service.getSlideMenuData("DoOnDetailCalcRule","UCheckInput", sPdBillNo,sPluCode,sDepCode,"","");
|
|
|
if (retchk.result !== 1) {
|
|
|
dr.setColumnError(dc.fieldName, "该部门商品不存在于对应盘点单,请核对!");
|
|
|
return false;
|
|
|
}
|
|
|
//获取包装信息
|
|
|
if (Cou_LsPdDataLrPacket == "1"){
|
|
|
if (COU_PdDataKcPacket == "1"){
|
|
|
let JSONObject={PluID:sPluID};
|
|
|
let retPacket= Service.getSlideMenuData("pubsysBaseBL","GetDefaultLsKcPackUnit",JSONObject,"","","","");
|
|
|
if (retPacket.result === 1) {
|
|
|
if (retPacket.data != null) {
|
|
|
dr.setColumnValue('PackUnit', retPacket.data.Unit);
|
|
|
dr.setColumnValue('PackQty', retPacket.data.Qty);
|
|
|
dr.setColumnValue('PackCount', "0");
|
|
|
dr.setColumnText('SglCount', "0");
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
else{
|
|
|
let JSONObject={PluCode:sPluCode};
|
|
|
let retPacket= Service.getSlideMenuData("pubsysBaseBL","GetDefaultPluPackUnit",JSONObject,"","","","");
|
|
|
if (retPacket.result === 1) {
|
|
|
if (retPacket.data != null) {
|
|
|
dr.setColumnValue('PackUnit', retPacket.data.Unit);
|
|
|
dr.setColumnValue('PackQty', retPacket.data.Qty);
|
|
|
dr.setColumnValue('PackCount', "0");
|
|
|
dr.setColumnText('SglCount', "0");
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
else{
|
|
|
dr.setColumnValue('PackUnit', "");
|
|
|
dr.setColumnValue('PackQty', 0);
|
|
|
dr.setColumnValue('PackCount', "0");
|
|
|
dr.setColumnText('SglCount', "0");
|
|
|
}
|
|
|
return true;
|
|
|
};
|
|
|
//DepCode 字段变化执行事件
|
|
|
Biz.prototype.fieldChangedDepCode = function (dataSrc, dr, dc) {
|
|
|
let sPluCode = dr ? TypeUtil.toString(dr['PluCode']) : '';
|
|
|
let sDepCode = dr ? TypeUtil.toString(dr['DepCode']) : '';
|
|
|
if (sPluCode === '') return false;
|
|
|
if (sDepCode === '') return false;
|
|
|
let masterRow = this.dsMaster.currentRow;
|
|
|
let sPdBillNo = TypeUtil.toString(masterRow['PdBillNo']);
|
|
|
let ret= Service.getSlideMenuData("DoOnDetailCalcRule","UCheckInput", sPdBillNo,sPluCode,sDepCode,"","");
|
|
|
if (ret.result !== 1) {
|
|
|
dr.setColumnError(dc.fieldName, "该部门商品不存在于对应盘点单,请核对!");
|
|
|
return false;
|
|
|
}
|
|
|
return true;
|
|
|
};
|
|
|
//PackUnit 字段变化执行事件
|
|
|
Biz.prototype.fieldChangedPackUnit = function (dataSrc, dr, dc) {
|
|
|
let PackUnit = TypeUtil.toString(dr['PackUnit']);
|
|
|
if (PackUnit == "")
|
|
|
{
|
|
|
dr.setColumnValue('PackQty', "0");
|
|
|
}
|
|
|
return true;
|
|
|
};
|
|
|
//PackCount 字段变化执行事件
|
|
|
Biz.prototype.fieldChangedPackCount = function (dataSrc, dr, dc) {
|
|
|
let fPackCount = TypeUtil.toFloat(dr['PackCount']);
|
|
|
let fPackQty = TypeUtil.toFloat(dr['PackQty']);
|
|
|
let fSglCount = TypeUtil.toFloat(dr['SglCount']);
|
|
|
let sPluCode = dr ? TypeUtil.toString(dr['PluCode']) : '';
|
|
|
let fSjCount = fPackCount*fPackQty+fSglCount;
|
|
|
if (sPluCode === '') return false;
|
|
|
dr.setColumnValue('SjCount', fSjCount);
|
|
|
if (fSjCount < 0)
|
|
|
{
|
|
|
dr.setColumnError(dc.fieldName, '盘点数量必须大于等于0!');
|
|
|
return false;
|
|
|
}
|
|
|
return true;
|
|
|
};
|
|
|
//SglCount 字段变化执行事件
|
|
|
Biz.prototype.fieldChangedSglCount = function (dataSrc, dr, dc) {
|
|
|
let fPackCount = TypeUtil.toFloat(dr['PackCount']);
|
|
|
let fPackQty = TypeUtil.toFloat(dr['PackQty']);
|
|
|
let fSglCount = TypeUtil.toFloat(dr['SglCount']);
|
|
|
let sPluCode = dr ? TypeUtil.toString(dr['PluCode']) : '';
|
|
|
let fSjCount = fPackCount*fPackQty+fSglCount;
|
|
|
if (sPluCode === '') return false;
|
|
|
dr.setColumnValue('SjCount', fSjCount);
|
|
|
if (fSjCount < 0)
|
|
|
{
|
|
|
dr.setColumnError(dc.fieldName, '盘点数量必须大于等于0!');
|
|
|
return false;
|
|
|
}
|
|
|
return true;
|
|
|
};
|
|
|
//按钮事件控制
|
|
|
Biz.prototype.doOp = function (opCode) {
|
|
|
if (opCode == 'myacc') {
|
|
|
this.onmyacc();
|
|
|
}
|
|
|
};
|
|
|
//控制主界面按钮状态
|
|
|
Biz.prototype.getOpEnabled = function (opCode) {
|
|
|
let isOk = this.super('getOpEnabled', opCode);
|
|
|
if (!isOk) {
|
|
|
return false;
|
|
|
}
|
|
|
let curRow = this.dsMaster.currentRow;
|
|
|
let sJzDate = curRow ? TypeUtil.toString(curRow['JzDate']) : '';
|
|
|
let sDataStatus = curRow ? TypeUtil.toString(curRow['DataStatus']) : '';
|
|
|
|
|
|
if (opCode == 'myacc'){
|
|
|
if (!curRow)
|
|
|
return false;
|
|
|
|
|
|
if (this.isEdit())
|
|
|
return false;
|
|
|
|
|
|
if ((sJzDate != "") || (sDataStatus != "0"))
|
|
|
return false;
|
|
|
}
|
|
|
return true;
|
|
|
};
|
|
|
//记账事件处理
|
|
|
Biz.prototype.onmyacc = function () {
|
|
|
let curHRow = this.dsMaster.currentRow;
|
|
|
let sBillNo = curHRow ? TypeUtil.toString(curHRow['BillNo']) : '';
|
|
|
let sSpDataType = curHRow ? TypeUtil.toString(curHRow['SpDataType']) : '';
|
|
|
let sShowMsg = "确认要记账选择的单据吗?";
|
|
|
if (sSpDataType == "1"){
|
|
|
sShowMsg = "您录入的实盘数据录入单为复盘类型,这张单据将以覆盖的方式回写商品的实际数量,确认要记账选择的单据吗?";
|
|
|
}
|
|
|
//弹出是否确认提交对话框
|
|
|
if (!Store.confirm(sShowMsg)) {
|
|
|
return false;
|
|
|
}
|
|
|
let ret= Service.getSlideMenuData("actExecute","onmyacc", sBillNo,"","","","");
|
|
|
if (ret.result !== 1) {
|
|
|
Store.messager.err(ret.message);
|
|
|
return false;
|
|
|
}
|
|
|
this.dsMaster.updateRow();
|
|
|
Store.messager.tip("记账成功!");
|
|
|
return true;
|
|
|
};
|
|
|
return Biz;
|
|
|
}); |