|
|
define(function (require, exports, module) {
|
|
|
let BaseBiz = require('apps/rht/base/rhtBiz');
|
|
|
let Service = require('./dst200104service');
|
|
|
let rhtComm = require('../../comm/rhtComm');
|
|
|
let multiWindow = require("system/views/pages/multiwindow/multiwindow");
|
|
|
/**
|
|
|
* 控制按钮的可用
|
|
|
* @param opCode 按钮编码
|
|
|
* @return [description]
|
|
|
*/
|
|
|
|
|
|
function Biz(vm) {
|
|
|
//继承第一步,构造继承
|
|
|
BaseBiz.call(this, vm);
|
|
|
vm.remark = ''
|
|
|
}
|
|
|
|
|
|
//继承第二步,方法继承
|
|
|
inherits(Biz, BaseBiz);
|
|
|
|
|
|
let IsMdKwMng = rhtComm.getRhtOptionValue('*', 'STK', 'IsMdKwMng', '1');
|
|
|
let Dst_IsUseBarCode = rhtComm.getRhtOptionValue('*', 'DST', 'Dst_IsUseBarCode', '0');
|
|
|
let Dst_MultiPluNoteType = rhtComm.getRhtOptionValue('*', 'DST', 'Dst_MultiPluNoteType', '1');
|
|
|
|
|
|
//功能初始化完毕调用该方法
|
|
|
Biz.prototype.initCompleted = function () {
|
|
|
if (Dst_IsUseBarCode == "0") {
|
|
|
if (Dst_MultiPluNoteType == "0") {
|
|
|
this.dsDetail.multiType = "1";
|
|
|
this.dsDetail.multiFields = "PluCode,PluType";
|
|
|
this.dsDetail.multiMsg = "不能重复录入商品!";
|
|
|
}
|
|
|
else if (Dst_MultiPluNoteType == "1") {
|
|
|
this.dsDetail.multiType = "2";
|
|
|
this.dsDetail.multiFields = "PluCode,PluType";
|
|
|
this.dsDetail.multiMsg = "当前商品重复录入!";
|
|
|
}
|
|
|
else {
|
|
|
this.dsDetail.multiType = "0";
|
|
|
this.dsDetail.multiFields = "";
|
|
|
this.dsDetail.multiMsg = "";
|
|
|
}
|
|
|
|
|
|
}
|
|
|
return this.super('initCompleted');
|
|
|
};
|
|
|
//增加后
|
|
|
Biz.prototype.afterAdd = function () {
|
|
|
let masterRow = this.dsMaster.currentRow;
|
|
|
let InOrgCode = rhtComm.GetInOrgCode(Store.logOn.orgCode).message;
|
|
|
masterRow.setColumnText('InOrgCode', InOrgCode);
|
|
|
masterRow.setColumnText('PlnShDate', rhtComm.GetServerDate(1));
|
|
|
return true;
|
|
|
};
|
|
|
//保存前校验
|
|
|
Biz.prototype.beforeSave = function () {
|
|
|
let masterRow = this.dsMaster.currentRow;
|
|
|
if (masterRow) {
|
|
|
let sBillNo = masterRow ? TypeUtil.toString(masterRow['BillNo']) : '';
|
|
|
let sPlnShDate = masterRow ? TypeUtil.toString(masterRow['PlnShDate']) : '';
|
|
|
let sShEtpCode = masterRow ? TypeUtil.toString(masterRow['ShEtpCode']) : '';
|
|
|
let sOrgCode = masterRow ? TypeUtil.toString(masterRow['OrgCode']) : '';
|
|
|
let sShOrgCode = masterRow ? TypeUtil.toString(masterRow['ShOrgCode']) : '';
|
|
|
let sShOrgName = masterRow ? TypeUtil.toString(masterRow['ShOrgName']) : '';
|
|
|
let sDepCode = masterRow ? TypeUtil.toString(masterRow['DepCode']) : '';
|
|
|
let sCurrCode = masterRow ? TypeUtil.toString(masterRow['CurrCode']) : '';
|
|
|
if (sPlnShDate < rhtComm.GetServerDate(0)) {
|
|
|
masterRow.setColumnError('BillNo', '计划送货日期必须大于或等于当前日期!');
|
|
|
return false;
|
|
|
}
|
|
|
if (sShEtpCode.length <= 0) {
|
|
|
masterRow.setColumnText('ShEtpCode', sShOrgCode);
|
|
|
}
|
|
|
let retSaleCtrl = Service.getSlideMenuData("BeforeSave", "UGetSaleCtrl", sDepCode, sShOrgCode, "", "", "");
|
|
|
if (retSaleCtrl.result !== 1) {
|
|
|
masterRow.setColumnError('BillNo', '可用信用额度出错:' + retSaleCtrl.message);
|
|
|
return false;
|
|
|
}
|
|
|
//可用信用额度检查
|
|
|
let JSONObject = { YwBillNo: sBillNo, YwType: "2003", OrgCode: Store.logOn.orgCode, DepCode: sDepCode, OppOrgCode: sShOrgCode, StlCurrCode: sCurrCode };
|
|
|
let ret = Service.getSlideMenuData("pubsysBaseBL", "UWslGetCustCredit", JSONObject, "", "", "", "");
|
|
|
if (ret.result === 1) {
|
|
|
let fKyCredit = 0.0
|
|
|
if (ret.data != null) {
|
|
|
fKyCredit = TypeUtil.toFloat(ret.data.KyCredit);
|
|
|
}
|
|
|
if (fKyCredit < TypeUtil.toFloat(masterRow['StlCurrPsTotal'])) {
|
|
|
masterRow.setColumnError('BillNo', "客户(" + sShOrgCode + "-" + sShOrgName + ")的配送金额不能大于可用信用额度:" + fKyCredit);
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
else {
|
|
|
masterRow.setColumnError('BillNo', '可用信用额度出错:' + ret.message);
|
|
|
return false;
|
|
|
}
|
|
|
let retYsYe = Service.getSlideMenuData("BeforeSave", "GetPreYsYeTotal", sOrgCode, sShOrgCode, sCurrCode, "", "");
|
|
|
if (retYsYe.result === 1) {
|
|
|
masterRow.setColumnValue('PreYsYeTotal', retYsYe.message);
|
|
|
}
|
|
|
this.setServerBiz('cn.qdhezheng.rht.app.dst.dst200104.SavePlugin');
|
|
|
}
|
|
|
return this.super('beforeSave');
|
|
|
};
|
|
|
//保存后
|
|
|
Biz.prototype.afterSave = function () {
|
|
|
let masterRow = this.dsMaster.currentRow;
|
|
|
if (masterRow) {
|
|
|
let sShOrgCode = masterRow ? TypeUtil.toString(masterRow['ShOrgCode']) : '';
|
|
|
let sDepCode = masterRow ? TypeUtil.toString(masterRow['DepCode']) : '';
|
|
|
let retPsCycle = Service.getSlideMenuData("BeforeSave", "USetDstHeadPsCycle", sDepCode, sShOrgCode, "", "", "");
|
|
|
if (retPsCycle.result !== 1) {
|
|
|
Store.messager.err(retPsCycle.message);
|
|
|
//masterRow.setColumnError('BillNo', retPsCycle.message);
|
|
|
//return false;
|
|
|
} /*
|
|
|
let sBillNo = masterRow ? TypeUtil.toString(masterRow['BillNo']) : '';
|
|
|
let retLock = Service.getSlideMenuData("LockLsKcByYwBill","",sBillNo,"2003","0","","");
|
|
|
if (retLock.result !== 1) {
|
|
|
Store.messager.err('锁定库存失败:'+retLock.message);
|
|
|
//masterRow.setColumnError('BillNo', '锁定库存失败:'+retLock.message);
|
|
|
//return false;
|
|
|
} */
|
|
|
}
|
|
|
this.super('afterSave');
|
|
|
};
|
|
|
//单据删除前处理
|
|
|
Biz.prototype.beforeDelete = function () {
|
|
|
let masterRow = this.dsMaster.currentRow;
|
|
|
let sBillNo = TypeUtil.toString(masterRow['BillNo']);
|
|
|
/*
|
|
|
let ret= Service.getSlideMenuData("LockLsKcByYwBill","",sBillNo,"2003","1","","");
|
|
|
if (ret.result !== 1) {
|
|
|
masterRow.setColumnError('BillNo', '删除锁定库存失败:'+ret.message);
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
this.setServerBiz('cn.qdhezheng.rht.app.dst.dst200104.SavePlugin');
|
|
|
*/
|
|
|
if (masterRow) {
|
|
|
let retDel = Service.getSlideMenuData("actExecute", "beforeDelete", sBillNo, "", "", "", "");
|
|
|
if (retDel.result !== 1) {
|
|
|
masterRow.setColumnError('BillNo', retDel.message);
|
|
|
return false;
|
|
|
}
|
|
|
else {
|
|
|
Store.messager.tip("删除成功!");
|
|
|
this.opRouter('refresh');
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
return this.super('beforeDelete');
|
|
|
};
|
|
|
//明细行单行提交触发的校验
|
|
|
Biz.prototype.dataRowValidate = function (dataSrc, dr) {
|
|
|
if (dataSrc.uiObjCode === this.dsDetail.uiObjCode) {
|
|
|
let masterRow = this.dsMaster.currentRow;
|
|
|
let sBillNo = TypeUtil.toString(masterRow['BillNo']);
|
|
|
let sPsType = TypeUtil.toString(masterRow['PsType']);
|
|
|
let sPluCode = TypeUtil.toString(dr['PluCode']);
|
|
|
let sPluName = TypeUtil.toString(dr['PluName']);
|
|
|
let sPluID = TypeUtil.toString(dr['PluID']);
|
|
|
let fPsCount = TypeUtil.toFloat(dr['PsCount']);
|
|
|
let fPlnCount = TypeUtil.toFloat(dr['PlnCount']);
|
|
|
|
|
|
if (sPluCode.length > 0) {
|
|
|
if (fPsCount < 0) {
|
|
|
return '配送数量不能小于零!';
|
|
|
}
|
|
|
if ((fPsCount == 0) && (this._state == "add")) {
|
|
|
return '配送数量不能等于零!';
|
|
|
}
|
|
|
let sAskType = TypeUtil.toString(dr['AskType']);
|
|
|
if (((sAskType == "3") || (sAskType == "4") || (sAskType == "5")) && ((PsCount > 0) && (PsCount != fPlnCount))) {
|
|
|
return '组合类配送不允许对配送数量进行修改,或只能修改为0!';
|
|
|
}
|
|
|
if (sPsType == "0") {
|
|
|
let sInOrgCode = rhtComm.GetInOrgCode(Store.logOn.orgCode).message;
|
|
|
let sCkCode = TypeUtil.toString(masterRow['CkCode']);
|
|
|
let sDepID = TypeUtil.toString(dr['DepID']);
|
|
|
let sDepCode = TypeUtil.toString(dr['DepCode']);
|
|
|
let sExPluCode = TypeUtil.toString(dr['ExPluCode']);
|
|
|
let sPluType = TypeUtil.toString(dr['PluType']);
|
|
|
let Params = sBillNo + ";" + "2003;*;" + sInOrgCode + ";" + sDepID + ";" + sCkCode + ";" + sPluID + ";" + sExPluCode + ";" + sPluType + ";";
|
|
|
let JSONObject = { DataType: "7", Params: Params };
|
|
|
let retKyCount = Service.getSlideMenuData("pubsysBaseBL", "MSysGetLsKcKyCount", JSONObject, "", "", "", "");
|
|
|
if (retKyCount.result === 1) {
|
|
|
if (fPsCount > TypeUtil.toFloat(retKyCount.message)) {
|
|
|
let errmsg = "商品[" + sPluCode + "-" + sPluName + "]的配送数量不能多于商品的库存[组织:" + sInOrgCode + "、仓库:" +
|
|
|
sCkCode + "、部门:" + sDepCode + "、商品类型:" + sPluType + "] <br> 当前可用数量:" + retKyCount.message;
|
|
|
return errmsg;
|
|
|
}
|
|
|
}
|
|
|
else {
|
|
|
return "查询商品库存失败:" + retKyCount.message;
|
|
|
}
|
|
|
}
|
|
|
let PackUnit = TypeUtil.toString(dr['PackUnit']);
|
|
|
if (PackUnit == "") {
|
|
|
dr.setColumnValue('PackCount', "0");
|
|
|
}
|
|
|
}
|
|
|
else {
|
|
|
return '商品编码不能为空!';
|
|
|
}
|
|
|
}
|
|
|
return true;
|
|
|
};
|
|
|
// 列校验,列赋值时调用,发生异常表示校验失败
|
|
|
Biz.prototype.dataColumnValidate = function (dataSrc, dr, dc, value) {
|
|
|
let self = this;
|
|
|
if (dataSrc.uiObjCode === this.dsDetail.uiObjCode) {
|
|
|
if (this.dsDetail.rows.length == 0) {
|
|
|
let masterRow = self.dsMaster.currentRow;
|
|
|
let sOrgCode = masterRow ? TypeUtil.toString(masterRow['OrgCode']) : '';
|
|
|
let sShOrgCode = masterRow ? TypeUtil.toString(masterRow['ShOrgCode']) : '';
|
|
|
let sHtCode = masterRow ? TypeUtil.toString(masterRow['HtCode']) : '';
|
|
|
if (sShOrgCode.length <= 0) {
|
|
|
return "请输入收货组织编码!";
|
|
|
}
|
|
|
let JSONObject = { OrgCode: sOrgCode, EtpCode: sShOrgCode };
|
|
|
let ret = Service.getSlideMenuData("pubsysBaseBL", "UOrgIsDlHs", JSONObject, "", "", "", "");
|
|
|
if (ret.result === 1) {
|
|
|
if (sHtCode.length <= 0) {
|
|
|
return "当前组织和收货组织不是同一核算组织,必须输入配送合同!";
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
return this.super('dataColumnValidate');
|
|
|
};
|
|
|
//校验小数精度
|
|
|
Biz.prototype.getPrecision = function (dataSrc, dr, dc, defaultPrecision) {
|
|
|
if (dataSrc.uiObjCode == this.dsDetail.uiObjCode) {
|
|
|
//把这里改成需要控制的字段
|
|
|
if (dc.fieldName == 'SglCount') {
|
|
|
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 'OrgType':
|
|
|
this.fieldChangedOrgType(dataSrc, dr, dc);
|
|
|
break;
|
|
|
case 'ShOrgCode':
|
|
|
this.fieldChangedShOrgCode(dataSrc, dr, dc);
|
|
|
break;
|
|
|
case 'HtCode':
|
|
|
this.fieldChangedHtCode(dataSrc, dr, dc);
|
|
|
break;
|
|
|
case 'ShEtpCode':
|
|
|
this.fieldChangedShEtpCode(dataSrc, dr, dc);
|
|
|
break;
|
|
|
case 'CkCode':
|
|
|
this.fieldChangedCkCode(dataSrc, dr, dc);
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
if (dataSrc.uiObjCode === this.dsDetail.uiObjCode) {
|
|
|
switch (dc.fieldName) {
|
|
|
case 'PluCode':
|
|
|
this.fieldChangedPluCode(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;
|
|
|
case 'StlCurrPsPrice':
|
|
|
this.fieldChangedStlCurrPsPrice(dataSrc, dr, dc);
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
this.super('fieldChanged');
|
|
|
};
|
|
|
//OrgType 字段变化执行事件
|
|
|
Biz.prototype.fieldChangedOrgType = function (dataSrc, dr, dc) {
|
|
|
let sOrgType = TypeUtil.toString(dr['OrgType']);
|
|
|
if (sOrgType.length > 0) {
|
|
|
dr.setColumnValue('ShOrgCode', "");
|
|
|
dr.setColumnValue('HtCode', "");
|
|
|
dr.setColumnValue('HtName', "");
|
|
|
dr.setColumnValue('CntID', "0");
|
|
|
dr.setColumnValue('JyMode', "0");
|
|
|
dr.setColumnValue('JsCode', "0");
|
|
|
dr.setColumnText('YwIOType', sOrgType);
|
|
|
}
|
|
|
return true;
|
|
|
};
|
|
|
//ShOrgCode 字段变化执行事件
|
|
|
Biz.prototype.fieldChangedShOrgCode = function (dataSrc, dr, dc) {
|
|
|
let sShOrgCode = dr ? TypeUtil.toString(dr['ShOrgCode']) : '';
|
|
|
let sCkCode = dr ? TypeUtil.toString(dr['CkCode']) : '';
|
|
|
if (sShOrgCode === '') return false;
|
|
|
if (sCkCode === ''){
|
|
|
dr.setColumnError(dc.fieldName, "仓库编码不能为空!");
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
let ret = Service.getSlideMenuData("DoOnMasterCalcRule", "ShOrgCode", dr.getData(), "", "", "", "");
|
|
|
if (ret.result !== 1) {
|
|
|
dr.setColumnError(dc.fieldName, ret.message);
|
|
|
return false;
|
|
|
}
|
|
|
if (ret.data != null) {
|
|
|
dr.setColumnValue('CurrCode', ret.data.currcode);
|
|
|
dr.setColumnValue('ExchangeRate', ret.data.exchangerate);
|
|
|
dr.setColumnValue('IsStdCurr', ret.data.isstdcurr);
|
|
|
let sInOrgCode = rhtComm.GetInOrgCode(sShOrgCode).message;
|
|
|
if (sInOrgCode != "*") {
|
|
|
dr.setColumnValue('InShOrgCode', sInOrgCode);
|
|
|
}
|
|
|
dr.setColumnValue('HtCode', "");
|
|
|
dr.setColumnValue('HtName', "");
|
|
|
dr.setColumnValue('CntID', "0");
|
|
|
dr.setColumnValue('PsPath', ret.data.pspath);
|
|
|
dr.setColumnValue('PathSerialNo', ret.data.pathno);
|
|
|
dr.setColumnValue('Address', ret.data.address);
|
|
|
}
|
|
|
dr.setColumnText('ShEtpCode', sShOrgCode);
|
|
|
return true;
|
|
|
};
|
|
|
//HtCode 字段变化执行事件
|
|
|
Biz.prototype.fieldChangedHtCode = function (dataSrc, dr, dc) {
|
|
|
let sHtCode = dr ? TypeUtil.toString(dr['HtCode']) : '';
|
|
|
if (sHtCode.length == 0) {
|
|
|
dr.setColumnValue('HtName', "");
|
|
|
dr.setColumnValue('CntID', "0");
|
|
|
dr.setColumnValue('JyMode', "0");
|
|
|
dr.setColumnValue('JsCode', "0");
|
|
|
}
|
|
|
else {
|
|
|
dr.setColumnValue('JyMode', dc.getRefValue('jymode'));
|
|
|
dr.setColumnValue('JsCode', dc.getRefValue('jscode'));
|
|
|
}
|
|
|
return true;
|
|
|
};
|
|
|
//ShEtpCode 字段变化执行事件
|
|
|
Biz.prototype.fieldChangedShEtpCode = function (dataSrc, dr, dc) {
|
|
|
let sShEtpCode = dr ? TypeUtil.toString(dr['ShEtpCode']) : '';
|
|
|
let sShOrgCode = dr ? TypeUtil.toString(dr['ShOrgCode']) : '';
|
|
|
let sShOrgName = dr ? TypeUtil.toString(dr['ShOrgName']) : '';
|
|
|
if (sShEtpCode == sShOrgCode) {
|
|
|
dr.setColumnValue('ShEtpName', sShOrgName);
|
|
|
}
|
|
|
return true;
|
|
|
};
|
|
|
//CkCode 字段变化执行事件
|
|
|
Biz.prototype.fieldChangedCkCode = function (dataSrc, dr, dc) {
|
|
|
let sCkCode = dr ? TypeUtil.toString(dr['CkCode']) : '';
|
|
|
if (sCkCode === '') return false;
|
|
|
|
|
|
let ret = Service.getSlideMenuData("DoOnMasterCalcRule", "CkCode", dr.getData(), "", "", "", "");
|
|
|
if (ret.result !== 1) {
|
|
|
dr.setColumnError(dc.fieldName, ret.message);
|
|
|
return false;
|
|
|
}
|
|
|
if (ret.data != null) {
|
|
|
dr.setColumnValue('PsPath', ret.data.pspath);
|
|
|
dr.setColumnValue('PathSerialNo', ret.data.pathno);
|
|
|
}
|
|
|
return true;
|
|
|
};
|
|
|
//PluCode 字段变化执行事件
|
|
|
Biz.prototype.fieldChangedPluCode = function (dataSrc, dr, dc) {
|
|
|
let masterRow = this.dsMaster.currentRow;
|
|
|
let sShOrgCode = TypeUtil.toString(masterRow['ShOrgCode']);
|
|
|
let sIsStdCurr = TypeUtil.toString(masterRow['IsStdCurr']);
|
|
|
let sPluCode = dr ? TypeUtil.toString(dr['PluCode']) : '';
|
|
|
let sPluID = dr ? TypeUtil.toString(dr['PluID']) : '';
|
|
|
let sInOrgCode = rhtComm.GetInOrgCode(sShOrgCode).message;
|
|
|
let JSONObject = null;
|
|
|
if (sPluCode === '') return false;
|
|
|
|
|
|
let retchk = Service.getSlideMenuData("DoOnDetailCalcRule", "PluCodeCheck", sShOrgCode, sPluCode, "", "", "");
|
|
|
if (retchk.result === 1) {
|
|
|
if (retchk.data != null) {
|
|
|
if (retchk.data.IsPs == "0") {
|
|
|
if (!Store.confirm("商品属性对于此客户设置为不允许配送,是否继续配送?")) {
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
dr.setColumnValue('PackUnit', "");
|
|
|
let ret = Service.getSlideMenuData("DoOnDetailCalcRule", "PluCode", masterRow.getData(), dr.getData(), "", "", "");
|
|
|
if (ret.result !== 1) {
|
|
|
dr.setColumnError(dc.fieldName, ret.message);
|
|
|
return false;
|
|
|
}
|
|
|
if (ret.data != null) {
|
|
|
let fPsPrice = TypeUtil.toFloat(ret.data[0].price);
|
|
|
let fXTaxRate = TypeUtil.toFloat(ret.data[0].xtaxrate);
|
|
|
dr.setColumnValue('JdRate', ret.data[0].jdrate);
|
|
|
dr.setColumnValue('PsPrice', ret.data[0].price);
|
|
|
dr.setColumnValue('StlCurrPsPrice', ret.data[0].stlcurrprice);
|
|
|
dr.setColumnValue('LsPrice', ret.data[0].lsprice);
|
|
|
dr.setColumnValue('ZkRate', ret.data[0].zkrate);
|
|
|
if (sIsStdCurr == "0") {
|
|
|
if ((ret.data[0].pricetype == "1") || (ret.data[0].pricetype == "2")) {
|
|
|
dr.setColumnError(dc.fieldName, "结算币不是本位币,当前商品不支持成本价和加点价!");
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
dr.setColumnText('PriceType', ret.data[0].pricetype);
|
|
|
dr.setColumnText('DepCode', ret.data[0].depcode);
|
|
|
dr.setColumnValue('WPsPrice', (fPsPrice / (1 + fXTaxRate / 100)).round(4));
|
|
|
dr.setColumnValue('XTaxRate', fXTaxRate);
|
|
|
|
|
|
//获取包装信息
|
|
|
JSONObject = { psPluCode: sPluCode, psYwType: "2003" };
|
|
|
let retPacket = Service.getSlideMenuData("pubsysBaseBL", "GetDefaultPluPackUnitByYwType", JSONObject, sPluCode, "", "", "");
|
|
|
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");
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
JSONObject = { OrgCode: sShOrgCode, PluCode: sPluCode, PluID: sPluID, FieldNameGrp: "Price", FieldCount: 1 };
|
|
|
let retEx = Service.getSlideMenuData("pubsysBaseBL", "USkuGetPluExPropInfo", JSONObject, "", "", "", "");
|
|
|
if (retEx.result === 1) {
|
|
|
if (retEx.data != null) {
|
|
|
dr.setColumnValue('Price', retEx.data.Price);
|
|
|
}
|
|
|
else {
|
|
|
JSONObject = { OrgCode: sInOrgCode, PluCode: sPluCode, PluID: sPluID, FieldNameGrp: "Price", FieldCount: 1 };
|
|
|
let retExB = Service.getSlideMenuData("pubsysBaseBL", "USkuGetPluExPropInfo", JSONObject, "", "", "", "");
|
|
|
if (retExB.result === 1) {
|
|
|
if (retExB.data != null) {
|
|
|
dr.setColumnValue('Price', retExB.data.Price);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
else {
|
|
|
dr.setColumnError('BillNo', retEx.message);
|
|
|
return false;
|
|
|
}
|
|
|
if (IsMdKwMng == "1") {
|
|
|
let sCkCode = TypeUtil.toString(masterRow['CkCode']);
|
|
|
JSONObject = { CurInOrgCode: sInOrgCode, CkCode: sCkCode, PluID: sPluID };
|
|
|
let retKwCode = Service.getSlideMenuData("pubsysBaseBL", "GetPluKw", JSONObject, "", "", "", "");
|
|
|
if (retKwCode.result === 1) {
|
|
|
if (retKwCode.data != null) {
|
|
|
dr.setColumnValue('KwCode', retKwCode.data.KwCode);
|
|
|
}
|
|
|
}
|
|
|
else {
|
|
|
dr.setColumnError('BillNo', retKwCode.message);
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
JSONObject = { PluCode: sPluCode, PluID: sPluID, FieldNameGrp: "ClsID", FieldCount: 1 };
|
|
|
let retCls = Service.getSlideMenuData("pubsysBaseBL", "USkuGetPluPropInfo", JSONObject, "", "", "", "");
|
|
|
if (retCls.result === 1) {
|
|
|
if (retCls.data != null) {
|
|
|
dr.setColumnText('ClsID', retCls.data.ClsID);
|
|
|
}
|
|
|
}
|
|
|
return true;
|
|
|
};
|
|
|
//PackUnit 字段变化执行事件
|
|
|
Biz.prototype.fieldChangedPackUnit = function (dataSrc, dr, dc) {
|
|
|
let PackUnit = TypeUtil.toString(dr['PackUnit']);
|
|
|
let sAskType = TypeUtil.toString(dr['AskType']);
|
|
|
if ((sAskType == "3") || (sAskType == "4") || (sAskType == "5")) {
|
|
|
dr.setColumnError(dc.fieldName, '组合类配送不允许对配送包装进行修改!');
|
|
|
return false;
|
|
|
}
|
|
|
if (PackUnit == "") {
|
|
|
dr.setColumnValue('PackQty', "0");
|
|
|
}
|
|
|
dr.setColumnText('PackCount', "0");
|
|
|
return true;
|
|
|
};
|
|
|
//PackCount 字段变化执行事件
|
|
|
Biz.prototype.fieldChangedPackCount = function (dataSrc, dr, dc) {
|
|
|
let masterRow = this.dsMaster.currentRow;
|
|
|
let fExchangeRate = TypeUtil.toFloat(masterRow['ExchangeRate']);
|
|
|
let sIsStdCurr = masterRow ? TypeUtil.toString(masterRow['IsStdCurr']) : '0';
|
|
|
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 fStlCurrPsPrice = TypeUtil.toFloat(dr['StlCurrPsPrice']);
|
|
|
let fXTaxRate = TypeUtil.toFloat(dr['XTaxRate']);
|
|
|
let fPrice = TypeUtil.toFloat(dr['Price']);
|
|
|
let fPsCount = fPackCount * fPackQty + fSglCount;
|
|
|
if (sPluCode === '') return false;
|
|
|
let fStlCurrPsTotal = (fStlCurrPsPrice * fPsCount).round(2);
|
|
|
let fPsTotal = (fStlCurrPsTotal * fExchangeRate).round(2);
|
|
|
let fWPsTotal = (fPsTotal / (1 + fXTaxRate / 100)).round(2);
|
|
|
let fPsPrice = 0.0;
|
|
|
if (sIsStdCurr == "1") {
|
|
|
fPsPrice = fStlCurrPsPrice;
|
|
|
}
|
|
|
else {
|
|
|
if (fPsTotal == 0) {
|
|
|
fPsPrice = (fStlCurrPsPrice * fExchangeRate).round(4);
|
|
|
}
|
|
|
else {
|
|
|
if (fPsCount == 0) {
|
|
|
fPsPrice = 0;
|
|
|
}
|
|
|
else {
|
|
|
fPsPrice = (fPsTotal / fPsCount).round(4);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
let fWPsPrice = 0.0;
|
|
|
if (fXTaxRate == 0) {
|
|
|
fWPsPrice = 0;
|
|
|
}
|
|
|
else {
|
|
|
if (fWPsTotal == 0) {
|
|
|
fWPsPrice = (fPsPrice / (1 + fXTaxRate / 100)).round(4);
|
|
|
}
|
|
|
else {
|
|
|
if (fPsCount == 0) {
|
|
|
fWPsPrice = 0;
|
|
|
}
|
|
|
else {
|
|
|
fWPsPrice = (fWPsTotal / fPsCount).round(4);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
let fXTaxTotal = fPsTotal - fWPsTotal;
|
|
|
let fSTotal = (fPsCount * fPrice).round(2);
|
|
|
|
|
|
if (fPsCount < 0) {
|
|
|
dr.setColumnError(dc.fieldName, '配送数量不能为负数!');
|
|
|
return false;
|
|
|
}
|
|
|
dr.setColumnValue('PsCount', fPsCount);
|
|
|
dr.setColumnValue('StlCurrPsTotal', fStlCurrPsTotal);
|
|
|
dr.setColumnValue('PsTotal', fPsTotal);
|
|
|
dr.setColumnValue('WPsTotal', fWPsTotal);
|
|
|
dr.setColumnValue('PsPrice', fPsPrice);
|
|
|
dr.setColumnValue('WPsPrice', fWPsPrice);
|
|
|
dr.setColumnValue('XTaxTotal', fXTaxTotal);
|
|
|
dr.setColumnValue('STotal', fSTotal);
|
|
|
return true;
|
|
|
};
|
|
|
//SglCount 字段变化执行事件
|
|
|
Biz.prototype.fieldChangedSglCount = function (dataSrc, dr, dc) {
|
|
|
let masterRow = this.dsMaster.currentRow;
|
|
|
let fExchangeRate = TypeUtil.toFloat(masterRow['ExchangeRate']);
|
|
|
let sIsStdCurr = masterRow ? TypeUtil.toString(masterRow['IsStdCurr']) : '0';
|
|
|
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 fStlCurrPsPrice = TypeUtil.toFloat(dr['StlCurrPsPrice']);
|
|
|
let fXTaxRate = TypeUtil.toFloat(dr['XTaxRate']);
|
|
|
let fPrice = TypeUtil.toFloat(dr['Price']);
|
|
|
let fPsCount = fPackCount * fPackQty + fSglCount;
|
|
|
if (sPluCode === '') return false;
|
|
|
let fStlCurrPsTotal = (fStlCurrPsPrice * fPsCount).round(2);
|
|
|
let fPsTotal = (fStlCurrPsTotal * fExchangeRate).round(2);
|
|
|
let fWPsTotal = (fPsTotal / (1 + fXTaxRate / 100)).round(2);
|
|
|
let fPsPrice = 0.0;
|
|
|
if (sIsStdCurr == "1") {
|
|
|
fPsPrice = fStlCurrPsPrice;
|
|
|
}
|
|
|
else {
|
|
|
if (fPsTotal == 0) {
|
|
|
fPsPrice = (fStlCurrPsPrice * fExchangeRate).round(4);
|
|
|
}
|
|
|
else {
|
|
|
if (fPsCount == 0) {
|
|
|
fPsPrice = 0;
|
|
|
}
|
|
|
else {
|
|
|
fPsPrice = (fPsTotal / fPsCount).round(4);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
let fWPsPrice = 0.0;
|
|
|
if (fXTaxRate == 0) {
|
|
|
fWPsPrice = 0;
|
|
|
}
|
|
|
else {
|
|
|
if (fWPsTotal == 0) {
|
|
|
fWPsPrice = (fPsPrice / (1 + fXTaxRate / 100)).round(4);
|
|
|
}
|
|
|
else {
|
|
|
if (fPsCount == 0) {
|
|
|
fWPsPrice = 0;
|
|
|
}
|
|
|
else {
|
|
|
fWPsPrice = (fWPsTotal / fPsCount).round(4);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
let fXTaxTotal = fPsTotal - fWPsTotal;
|
|
|
let fSTotal = (fPsCount * fPrice).round(2);
|
|
|
|
|
|
if (fPsCount < 0) {
|
|
|
dr.setColumnError(dc.fieldName, '配送数量不能为负数!');
|
|
|
return false;
|
|
|
}
|
|
|
dr.setColumnValue('PsCount', fPsCount);
|
|
|
dr.setColumnValue('StlCurrPsTotal', fStlCurrPsTotal);
|
|
|
dr.setColumnValue('PsTotal', fPsTotal);
|
|
|
dr.setColumnValue('WPsTotal', fWPsTotal);
|
|
|
dr.setColumnValue('PsPrice', fPsPrice);
|
|
|
dr.setColumnValue('WPsPrice', fWPsPrice);
|
|
|
dr.setColumnValue('XTaxTotal', fXTaxTotal);
|
|
|
dr.setColumnValue('STotal', fSTotal);
|
|
|
return true;
|
|
|
};
|
|
|
//StlCurrPsPrice 字段变化执行事件
|
|
|
Biz.prototype.fieldChangedStlCurrPsPrice = function (dataSrc, dr, dc) {
|
|
|
let masterRow = this.dsMaster.currentRow;
|
|
|
let fExchangeRate = TypeUtil.toFloat(masterRow['ExchangeRate']);
|
|
|
let sIsStdCurr = masterRow ? TypeUtil.toString(masterRow['IsStdCurr']) : '0';
|
|
|
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 fStlCurrPsPrice = TypeUtil.toFloat(dr['StlCurrPsPrice']);
|
|
|
let fXTaxRate = TypeUtil.toFloat(dr['XTaxRate']);
|
|
|
let fPrice = TypeUtil.toFloat(dr['Price']);
|
|
|
let sPriceType = TypeUtil.toString(dr['PriceType']);
|
|
|
let fPsCount = fPackCount * fPackQty + fSglCount;
|
|
|
if (sPluCode === '') return false;
|
|
|
if (sPriceType != "4") {
|
|
|
let Dst_IsXgGdPsPrice = rhtComm.getRhtOptionValue('*', 'DST', 'Dst_IsXgGdPsPrice', '0');
|
|
|
if ((sPriceType != "3") || ((sPriceType == "3") && (Dst_IsXgGdPsPrice == "0"))) {
|
|
|
dr.setColumnError(dc.fieldName, '非自由配送价,不能更改商品的配送价格!');
|
|
|
dr.setColumnValue('StlCurrPsPrice', dr.transData['StlCurrPsPrice']);
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
let fStlCurrPsTotal = (fStlCurrPsPrice * fPsCount).round(2);
|
|
|
let fPsTotal = (fStlCurrPsTotal * fExchangeRate).round(2);
|
|
|
let fWPsTotal = (fPsTotal / (1 + fXTaxRate / 100)).round(2);
|
|
|
let fPsPrice = 0.0;
|
|
|
if (sIsStdCurr == "1") {
|
|
|
fPsPrice = fStlCurrPsPrice;
|
|
|
}
|
|
|
else {
|
|
|
if (fPsTotal == 0) {
|
|
|
fPsPrice = (fStlCurrPsPrice * fExchangeRate).round(4);
|
|
|
}
|
|
|
else {
|
|
|
if (fPsCount == 0) {
|
|
|
fPsPrice = 0;
|
|
|
}
|
|
|
else {
|
|
|
fPsPrice = (fPsTotal / fPsCount).round(4);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
let fWPsPrice = 0.0;
|
|
|
if (fXTaxRate == 0) {
|
|
|
fWPsPrice = 0;
|
|
|
}
|
|
|
else {
|
|
|
if (fWPsTotal == 0) {
|
|
|
fWPsPrice = (fPsPrice / (1 + fXTaxRate / 100)).round(4);
|
|
|
}
|
|
|
else {
|
|
|
if (fPsCount == 0) {
|
|
|
fWPsPrice = 0;
|
|
|
}
|
|
|
else {
|
|
|
fWPsPrice = (fWPsTotal / fPsCount).round(4);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
let fXTaxTotal = fPsTotal - fWPsTotal;
|
|
|
let fSTotal = (fPsCount * fPrice).round(2);
|
|
|
|
|
|
if (fPsCount < 0) {
|
|
|
dr.setColumnError(dc.fieldName, '配送数量不能为负数!');
|
|
|
return false;
|
|
|
}
|
|
|
dr.setColumnValue('PsCount', fPsCount);
|
|
|
dr.setColumnValue('StlCurrPsTotal', fStlCurrPsTotal);
|
|
|
dr.setColumnValue('PsTotal', fPsTotal);
|
|
|
dr.setColumnValue('WPsTotal', fWPsTotal);
|
|
|
dr.setColumnValue('PsPrice', fPsPrice);
|
|
|
dr.setColumnValue('WPsPrice', fWPsPrice);
|
|
|
dr.setColumnValue('XTaxTotal', fXTaxTotal);
|
|
|
dr.setColumnValue('STotal', fSTotal);
|
|
|
return true;
|
|
|
};
|
|
|
//按钮事件控制
|
|
|
Biz.prototype.doOp = function (opCode) {
|
|
|
let self = this;
|
|
|
if (opCode == 'end') {
|
|
|
self.onend();
|
|
|
}
|
|
|
if (opCode == 'pladd') {
|
|
|
self.onpladd();
|
|
|
}
|
|
|
if (opCode == 'getzp') {
|
|
|
self.ongetzp();
|
|
|
}
|
|
|
};
|
|
|
//控制主界面按钮状态
|
|
|
Biz.prototype.getOpEnabled = function (opCode) {
|
|
|
let isOk = this.super('getOpEnabled', opCode);
|
|
|
if (!isOk) {
|
|
|
return false;
|
|
|
}
|
|
|
let curRow = this.dsMaster.currentRow;
|
|
|
let sYwStatus = curRow ? TypeUtil.toString(curRow['YwStatus']) : '0';
|
|
|
|
|
|
if (opCode == 'end') {
|
|
|
if (!curRow)
|
|
|
return false;
|
|
|
|
|
|
if (this.isEdit())
|
|
|
return false;
|
|
|
|
|
|
if (sYwStatus != "0")
|
|
|
return false;
|
|
|
}
|
|
|
if (opCode == 'pladd') {
|
|
|
if (!curRow)
|
|
|
return false;
|
|
|
|
|
|
if (!this.isEdit())
|
|
|
return false;
|
|
|
}
|
|
|
if (opCode == 'getzp') {
|
|
|
if (!curRow)
|
|
|
return false;
|
|
|
|
|
|
if (this.isEdit())
|
|
|
return false;
|
|
|
|
|
|
if (sYwStatus != "0")
|
|
|
return false;
|
|
|
}
|
|
|
return true;
|
|
|
};
|
|
|
//结案事件处理
|
|
|
Biz.prototype.onend = function () {
|
|
|
let curHRow = this.dsMaster.currentRow;
|
|
|
let sBillNo = curHRow ? TypeUtil.toString(curHRow['BillNo']) : '';
|
|
|
let sYwStatus = curHRow ? TypeUtil.toString(curHRow['YwStatus']) : '';
|
|
|
//弹出是否确认提交对话框
|
|
|
if (!Store.confirm("结案后将不能再验收,确定要结案吗?")) {
|
|
|
return false;
|
|
|
}
|
|
|
if (sYwStatus == "1") {
|
|
|
Store.messager.err("此配送单验收中,不能再结案!");
|
|
|
return false;
|
|
|
}
|
|
|
if (sYwStatus == "2") {
|
|
|
Store.messager.err("此配送单已经验收完成,不能再结案!");
|
|
|
return false;
|
|
|
}
|
|
|
let ret = Service.getSlideMenuData("actExecute", "onend", sBillNo, "", "", "", "");
|
|
|
if (ret.result !== 1) {
|
|
|
Store.messager.err(ret.message);
|
|
|
return false;
|
|
|
}
|
|
|
this.dsMaster.updateRow();
|
|
|
Store.messager.tip("结案成功!");
|
|
|
return true;
|
|
|
};
|
|
|
//批量多选商品事件处理
|
|
|
Biz.prototype.onpladd = function () {
|
|
|
let self = this;
|
|
|
let curHRow = self.dsMaster.currentRow;
|
|
|
let sCntID = curHRow ? TypeUtil.toString(curHRow['CntID']) : '';
|
|
|
//定义多选窗口界面
|
|
|
let exists = new Array();
|
|
|
for (let j = 0; j < self.dsDetail.rows.length; j++) {
|
|
|
exists.push({
|
|
|
'PluID': self.dsDetail.rows[j].PluID
|
|
|
});
|
|
|
}
|
|
|
let param = {
|
|
|
exists: exists,
|
|
|
uiObjCode: '8001',
|
|
|
serverBiz: 'cn.qdhezheng.rht.app.dst.dst200104.SavePlugin',
|
|
|
biz: self,
|
|
|
pk: "PluID",
|
|
|
fixQuery: {
|
|
|
'CntID': sCntID
|
|
|
},
|
|
|
showCheckColumn: true,
|
|
|
funcCode: self.FuncCode,
|
|
|
ds: self.dsDetail,
|
|
|
itreator: function (row) {
|
|
|
let isOK = self.pladdrows(row);
|
|
|
if (isOK != true) {
|
|
|
Store.messager.tip("批量导入商品失败!");
|
|
|
return false;
|
|
|
}
|
|
|
return true;
|
|
|
}
|
|
|
};
|
|
|
//new多选窗体 并打开
|
|
|
let myWindow = new multiWindow(param);
|
|
|
myWindow.open();
|
|
|
};
|
|
|
//批量增加每行后触发操作
|
|
|
Biz.prototype.pladdrows = function (row) {
|
|
|
let ds = this.dsDetail;
|
|
|
if (row != null) {
|
|
|
let dr = ds.addRow();
|
|
|
dr.setColumnValue('PluID', row['PluID']);
|
|
|
dr.setColumnText('PluCode', row['PluCode']);
|
|
|
dr.setColumnValue('PluName', row['PluName']);
|
|
|
dr.setColumnValue('Spec', row['Spec']);
|
|
|
dr.setColumnValue('Unit', row['Unit']);
|
|
|
dr.setColumnText('SglCount', "1");
|
|
|
}
|
|
|
return true;
|
|
|
};
|
|
|
//算赠品事件处理
|
|
|
Biz.prototype.ongetzp = function () {
|
|
|
let curHRow = this.dsMaster.currentRow;
|
|
|
let sBillNo = curHRow ? TypeUtil.toString(curHRow['BillNo']) : '';
|
|
|
let sYwType = curHRow ? TypeUtil.toString(curHRow['YwType']) : '';
|
|
|
let sYwStatus = curHRow ? TypeUtil.toString(curHRow['YwStatus']) : '';
|
|
|
if (sYwStatus != "0") {
|
|
|
Store.messager.err("此配送单已被处理,不能算赠品!");
|
|
|
return false;
|
|
|
}
|
|
|
let ret = Service.getSlideMenuData("actExecute", "ongetzp", sBillNo, sYwType, "", "", "");
|
|
|
if (ret.result !== 1) {
|
|
|
Store.messager.err(ret.message);
|
|
|
return false;
|
|
|
}
|
|
|
this.dsMaster.updateRow();
|
|
|
Store.messager.tip("算赠品成功!");
|
|
|
return true;
|
|
|
};
|
|
|
return Biz;
|
|
|
}); |