|
|
|
|
define(function (require, exports, module) {
|
|
|
|
|
let BaseBiz = require('apps/rht/base/rhtBiz');
|
|
|
|
|
let rhtComm = require('../../comm/rhtComm');
|
|
|
|
|
//引入业务服务
|
|
|
|
|
let Service = require('./stk180902service');
|
|
|
|
|
var ScDateWindow = require('system/views/pages/scdatewindow/scdatewindow');
|
|
|
|
|
|
|
|
|
|
function Biz(vm) {
|
|
|
|
|
//继承第一步,构造继承
|
|
|
|
|
BaseBiz.call(this, vm);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//继承第二步,方法继承
|
|
|
|
|
inherits(Biz, BaseBiz);
|
|
|
|
|
|
|
|
|
|
let IsMulScDate = rhtComm.getRhtOptionValue("*",'SYS','SYS_IsMulScDate','0');
|
|
|
|
|
/*
|
|
|
|
|
//明细行单行提交触发的校验
|
|
|
|
|
Biz.prototype.dataRowValidate = function (dataSrc, dr) {
|
|
|
|
|
if (dataSrc.uiObjCode === this.dsDetail.uiObjCode) {
|
|
|
|
|
let PluCode = TypeUtil.toString(dr['PluCode']);
|
|
|
|
|
let PlanDbCount = TypeUtil.toFloat(dr['PlanDbCount']);
|
|
|
|
|
if (PluCode.length <= 0) {
|
|
|
|
|
return "商品编码不能为空!";
|
|
|
|
|
}
|
|
|
|
|
if (PlanDbCount <= 0) {
|
|
|
|
|
return "调拨数量应该大于0!";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let self = this;
|
|
|
|
|
let currentRow = self.dsMaster.currentRow;
|
|
|
|
|
let sBillNo = currentRow['BillNo'];
|
|
|
|
|
let sInOrgCode = currentRow ? TypeUtil.toString(currentRow['InOrgCode']) : '';
|
|
|
|
|
let sYwStatus = currentRow ? TypeUtil.toString(currentRow['YwStatus']) : '';
|
|
|
|
|
if (sYwStatus != '1'){
|
|
|
|
|
let sCkCode = TypeUtil.toString(currentRow['CkCode']);
|
|
|
|
|
let sDepID = TypeUtil.toString(currentRow['DepID']);
|
|
|
|
|
let sDepCode = TypeUtil.toString(currentRow['DepCode']);
|
|
|
|
|
let sExPluCode = TypeUtil.toString(dr['ExPluCode']);
|
|
|
|
|
let sPluType = TypeUtil.toString(dr['PluType']);
|
|
|
|
|
let sPluID = TypeUtil.toString(dr['PluID']);
|
|
|
|
|
let Params = sBillNo + ";" + "1804;*;" + sInOrgCode + ";" + sDepID + ";" + sCkCode + ";" + sPluID + ";" + sExPluCode + ";" + sPluType + ";*";
|
|
|
|
|
let JSONObject = { DataType: "6", Params: Params };
|
|
|
|
|
let retKyCount = Service.getSlideMenuData("pubsysBaseBL", "MSysGetLsKcKyCount", JSONObject, "", "", "", "");
|
|
|
|
|
if (retKyCount.result === 1) {
|
|
|
|
|
if (PlanDbCount > TypeUtil.toFloat(retKyCount.message)) {
|
|
|
|
|
let errmsg = "商品[" + sPluCode + "-" + sPluName + "]的调拨数量不能多于商品的库存[组织:" + sInOrgCode + "、仓库:" +
|
|
|
|
|
sCkCode + "、部门:" + sDepCode + "、商品类型:" + sPluType + "] <br> 当前可用数量:" + retKyCount.message;
|
|
|
|
|
return errmsg;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
return "查询商品库存失败:" + retKyCount.message;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let Price = TypeUtil.toFloat(dr['Price']);
|
|
|
|
|
dr.setColumnValue("STotal", (PlanDbCount*Price).round(2));
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
};
|
|
|
|
|
//字段变化触发事件
|
|
|
|
|
Biz.prototype.fieldChanged = function (dataSrc, dr, dc) {
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
this.super('fieldChanged');
|
|
|
|
|
};
|
|
|
|
|
//PluCode 字段变化执行事件
|
|
|
|
|
Biz.prototype.fieldChangedPluCode = function (dataSrc, dr, dc) {
|
|
|
|
|
let masterRow = this.dsMaster.currentRow;
|
|
|
|
|
let OrgCode = TypeUtil.toString(masterRow['OrgCode']);
|
|
|
|
|
let PluID = TypeUtil.toString(dr['PluID']);
|
|
|
|
|
let PluCode = TypeUtil.toString(dr['PluCode']);
|
|
|
|
|
if (OrgCode === '') return false;
|
|
|
|
|
if (PluCode === '') return false;
|
|
|
|
|
|
|
|
|
|
let JSONObject = { OrgCode: OrgCode, PluCode: PluCode, PluID: PluID, 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{
|
|
|
|
|
Store.messager.err('调出组织没有经营此商品,不允许调拨!');
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}else{
|
|
|
|
|
Store.messager.err(retExB.message);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
};
|
|
|
|
|
//PackUnit 字段变化执行事件
|
|
|
|
|
Biz.prototype.fieldChangedPackUnit = function (dataSrc, dr, dc) {
|
|
|
|
|
let PackUnit = TypeUtil.toString(dr['PackUnit']);
|
|
|
|
|
if (PackUnit == "")
|
|
|
|
|
{
|
|
|
|
|
dr.setColumnValue('PackQty', "0");
|
|
|
|
|
}
|
|
|
|
|
dr.setColumnText('PackCount', "0");
|
|
|
|
|
return true;
|
|
|
|
|
};
|
|
|
|
|
//PackCount 字段变化执行事件
|
|
|
|
|
Biz.prototype.fieldChangedPackCount = function (dataSrc, dr, dc) {
|
|
|
|
|
let PluCode = TypeUtil.toString(dr['PluCode']);
|
|
|
|
|
let PackCount = TypeUtil.toFloat(dr['PackCount']);
|
|
|
|
|
let PackQty = TypeUtil.toFloat(dr['PackQty']);
|
|
|
|
|
let SglCount = TypeUtil.toFloat(dr['SglCount']);
|
|
|
|
|
let PlanDbCount = (PackCount*PackQty+SglCount).round(4);
|
|
|
|
|
if (PluCode === '') return false;
|
|
|
|
|
if (SglCount < 0)
|
|
|
|
|
{
|
|
|
|
|
dr.setColumnError(dc.fieldName, '单件件数不允许为负数!');
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
dr.setColumnText('PlanDbCount', PlanDbCount);
|
|
|
|
|
return true;
|
|
|
|
|
};
|
|
|
|
|
//SglCount 字段变化执行事件
|
|
|
|
|
Biz.prototype.fieldChangedSglCount = function (dataSrc, dr, dc) {
|
|
|
|
|
let PluCode = TypeUtil.toString(dr['PluCode']);
|
|
|
|
|
let PackCount = TypeUtil.toFloat(dr['PackCount']);
|
|
|
|
|
let PackQty = TypeUtil.toFloat(dr['PackQty']);
|
|
|
|
|
let SglCount = TypeUtil.toFloat(dr['SglCount']);
|
|
|
|
|
let PlanDbCount = (PackCount*PackQty+SglCount).round(4);
|
|
|
|
|
if (PluCode === '') return false;
|
|
|
|
|
if (SglCount < 0)
|
|
|
|
|
{
|
|
|
|
|
dr.setColumnError(dc.fieldName, '单件件数不允许为负数!');
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
dr.setColumnText('PlanDbCount', PlanDbCount);
|
|
|
|
|
return true;
|
|
|
|
|
};
|
|
|
|
|
*/
|
|
|
|
|
//增加右键菜单按钮并控制按钮状态
|
|
|
|
|
Biz.prototype.getContextMenus = function (ds, source) {
|
|
|
|
|
let menus = this.super("getContextMenus", ds, source);
|
|
|
|
|
if (ds.uiObjCode === this.dsDetail.uiObjCode) {
|
|
|
|
|
let edit = ds.getEditable();
|
|
|
|
|
if ((!edit) && (IsMulScDate =='1')){
|
|
|
|
|
let curBodyRow = this.dsDetail.currentRow;
|
|
|
|
|
let PluCode = curBodyRow ? TypeUtil.toString(curBodyRow['PluCode']) : '';
|
|
|
|
|
if (PluCode != ''){
|
|
|
|
|
menus.push({
|
|
|
|
|
text: '生产日期管理',
|
|
|
|
|
opCode: 'scdate',
|
|
|
|
|
disabled: false
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return menus;
|
|
|
|
|
};
|
|
|
|
|
//控制主界面按钮状态
|
|
|
|
|
Biz.prototype.getOpEnabled = function (opCode) {
|
|
|
|
|
let isOk = this.super('getOpEnabled', opCode);
|
|
|
|
|
if (!isOk) return false;
|
|
|
|
|
let curRow = this.dsMaster.currentRow;
|
|
|
|
|
let DataStatus = curRow ? TypeUtil.toString(curRow['DataStatus']) : '0';
|
|
|
|
|
if (opCode == 'add') {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
if (opCode == 'edit') {
|
|
|
|
|
if (!curRow)
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
if (DataStatus !== '0')
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
if (opCode == 'delete') {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
if (opCode == 'accs') {
|
|
|
|
|
if (!curRow)
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
if (DataStatus !== '0')
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
if (opCode == 'end') {
|
|
|
|
|
if (!curRow)
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
if (DataStatus !== '9')
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
};
|
|
|
|
|
//按钮事件控制
|
|
|
|
|
Biz.prototype.doOp = function (opCode) {
|
|
|
|
|
let self = this;
|
|
|
|
|
if (opCode == 'accs') {
|
|
|
|
|
this.onaccs(self);
|
|
|
|
|
}
|
|
|
|
|
if (opCode == 'end') {
|
|
|
|
|
this.onend(self);
|
|
|
|
|
}
|
|
|
|
|
if (opCode == 'scdate') {
|
|
|
|
|
let dhead = self.dsMaster;
|
|
|
|
|
let dbodyrow = self.dsDetail.currentRow;
|
|
|
|
|
this.onscdate(self, dhead,dbodyrow);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
//记账事件处理
|
|
|
|
|
Biz.prototype.onaccs = function (self) {
|
|
|
|
|
let dsrow = self.dsMaster.currentRow;
|
|
|
|
|
let BillNo = dsrow ? TypeUtil.toString(dsrow['BillNo']) : '';
|
|
|
|
|
|
|
|
|
|
if (BillNo.length > 0){
|
|
|
|
|
let ret= Service.getSlideMenuData("actExecute","onaccs",BillNo,'1835','','','');
|
|
|
|
|
if (ret.result !== 1) {
|
|
|
|
|
Store.messager.err(ret.message);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
else{
|
|
|
|
|
Store.messager.tip('记账成功!');
|
|
|
|
|
//刷新当前行
|
|
|
|
|
self.dsMaster.updateRow();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
};
|
|
|
|
|
//生产日期信息按钮事件处理
|
|
|
|
|
Biz.prototype.onscdate = function (self, dhead, dbodyrow) {
|
|
|
|
|
let curRow = self.dsMaster.currentRow;
|
|
|
|
|
let YwType = curRow ? TypeUtil.toString(curRow['YwType']) : '*';
|
|
|
|
|
if (IsMulScDate !=='1'){
|
|
|
|
|
Store.messager.err("系统没有开启多生产日期管理,请先开启后再执行本操作!");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
//定义窗口界面
|
|
|
|
|
let param = {
|
|
|
|
|
uiObjCode: self.dsMaster.funcCode,
|
|
|
|
|
billNo: dbodyrow.BillNo,
|
|
|
|
|
ywType: YwType,
|
|
|
|
|
toSerialNo: dbodyrow.SerialNo,
|
|
|
|
|
pluInf: dbodyrow.PluCode+'-'+dbodyrow.PluName,
|
|
|
|
|
recCount: dbodyrow.PlanDbCount,
|
|
|
|
|
biz: self,
|
|
|
|
|
pk: "BillNo,YwType,ToSerialNo,SerialNo",
|
|
|
|
|
fixQuery: {
|
|
|
|
|
'ToSerialNo': dbodyrow.SerialNo,
|
|
|
|
|
'BillNo': dbodyrow.BillNo,
|
|
|
|
|
'YwType': YwType
|
|
|
|
|
},
|
|
|
|
|
showCheckColumn: true,
|
|
|
|
|
isToEdit: false,
|
|
|
|
|
enablePager: false,
|
|
|
|
|
funcCode: self.FuncCode,
|
|
|
|
|
ds: dbodyrow
|
|
|
|
|
};
|
|
|
|
|
//new多选窗体 并打开
|
|
|
|
|
let myWindow = new ScDateWindow(param);
|
|
|
|
|
myWindow.open();
|
|
|
|
|
};
|
|
|
|
|
return Biz;
|
|
|
|
|
});
|