|
|
define(function (require, exports, module) {
|
|
|
let BaseBiz = require('apps/rht/base/rhtBiz');
|
|
|
let Service = require('./fsh140302service');
|
|
|
let rhtComm = require('../../comm/rhtComm');
|
|
|
/**
|
|
|
* 控制按钮的可用
|
|
|
* @param opCode 按钮编码
|
|
|
* @return [description]
|
|
|
*/
|
|
|
|
|
|
function Biz(vm) {
|
|
|
//继承第一步,构造继承
|
|
|
BaseBiz.call(this, vm);
|
|
|
vm.remark =''
|
|
|
}
|
|
|
|
|
|
//继承第二步,方法继承
|
|
|
inherits(Biz, BaseBiz);
|
|
|
|
|
|
let FRS_ISREFPEILIAO = rhtComm.getRhtOptionValue('*','FRS','FRS_ISREFPEILIAO','1');
|
|
|
let FrsCpPluType = rhtComm.getRhtOptionValue('*','FRS','FrsCpPluType','0');
|
|
|
|
|
|
//功能初始化完毕调用该方法
|
|
|
Biz.prototype.initCompleted = function() {
|
|
|
if (FRS_ISREFPEILIAO == '0'){
|
|
|
this.dsYl.allowDel = true;
|
|
|
this.dsYl.allowEdit = true;
|
|
|
this.dsYl.allowInsert = true;
|
|
|
this.dsCp.allowDel = true;
|
|
|
this.dsCp.allowEdit = true;
|
|
|
this.dsCp.allowInsert = true;
|
|
|
}
|
|
|
else{
|
|
|
this.dsYl.allowDel = false;
|
|
|
this.dsYl.allowEdit = false;
|
|
|
this.dsYl.allowInsert = false;
|
|
|
this.dsCp.allowDel = false;
|
|
|
this.dsCp.allowEdit = false;
|
|
|
this.dsCp.allowInsert = false;
|
|
|
}
|
|
|
return this.super('initCompleted');
|
|
|
};
|
|
|
//增加后
|
|
|
Biz.prototype.afterAdd = function () {
|
|
|
let masterRow = this.dsMaster.currentRow;
|
|
|
let ret= Service.getSlideMenuData("actExecute","GetCkCode","","","","","");
|
|
|
if (ret.result === 1) {
|
|
|
if (ret.data !== null){
|
|
|
masterRow.setColumnText('CkCode', ret.data.ckcode);
|
|
|
masterRow.setColumnValue('CkName', ret.data.ckname);
|
|
|
}
|
|
|
}
|
|
|
masterRow.setColumnText('GyRate', '1');
|
|
|
return true;
|
|
|
};
|
|
|
//保存前校验
|
|
|
Biz.prototype.beforeSave = function () {
|
|
|
let masterRow = this.dsMaster.currentRow;
|
|
|
if(masterRow){
|
|
|
if (this.dsYl.rows == 0){
|
|
|
masterRow.setColumnError('GyCode', '加工单原料没有记录请输入!');
|
|
|
return false;
|
|
|
}
|
|
|
if (this.dsCp.rows == 0){
|
|
|
masterRow.setColumnError('GyCode', '加工单成品没有记录请输入!');
|
|
|
return false;
|
|
|
}
|
|
|
let iPercent = 0.0;
|
|
|
for (let i = 0; i< this.dsCp.rows.length; i++) {
|
|
|
let row = this.dsCp.rows[i];
|
|
|
let fFpPercent = TypeUtil.toFloat(row['FpPercent']);
|
|
|
iPercent = iPercent + fFpPercent;
|
|
|
}
|
|
|
if (iPercent != 100) {
|
|
|
masterRow.setColumnError('GyCode', '成品占比之和应该为100%!');
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
return this.super('beforeSave');
|
|
|
};
|
|
|
//明细行单行提交触发的校验
|
|
|
Biz.prototype.dataRowValidate = function (dataSrc, dr) {
|
|
|
let curRow = this.dsMaster.currentRow;
|
|
|
let sBillNo = curRow ? TypeUtil.toString(curRow['BillNo']) : '';
|
|
|
let sDepID = curRow ? TypeUtil.toString(curRow['DepID']) : '';
|
|
|
let sDepCode = curRow ? TypeUtil.toString(curRow['DepCode']) : '';
|
|
|
let sCkCode = curRow ? TypeUtil.toString(curRow['CkCode']) : '';
|
|
|
let CurInOrgCode = rhtComm.GetInOrgCode(Store.logOn.orgCode).message;
|
|
|
if (sDepCode.length <= 0){
|
|
|
return '主表部门不能为空!';
|
|
|
}
|
|
|
if (dataSrc.uiObjCode === this.dsYl.uiObjCode) {
|
|
|
let sPluCode = TypeUtil.toString(dr['PluCode']);
|
|
|
let sPluID = TypeUtil.toString(dr['PluID']);
|
|
|
let sExPluCode = TypeUtil.toString(dr['ExPluCode']);
|
|
|
let sPluName = TypeUtil.toString(dr['PluName']);
|
|
|
let fYlCount = TypeUtil.toFloat(dr['YlCount']);
|
|
|
if (sPluCode.length > 0) {
|
|
|
if (fYlCount <= 0 ) {
|
|
|
return "原料数量不能小于或等于零!";
|
|
|
}
|
|
|
for (let i = 0; i< this.dsCp.rows.length; i++) {
|
|
|
let row = this.dsCp.rows[i];
|
|
|
let sCpPluCode = TypeUtil.toString(row['PluCode']);
|
|
|
if (sPluCode == sCpPluCode){
|
|
|
return "此商品已经在成品表中出现,不能作为原料商品!";
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
else{
|
|
|
return "原料商品编码不能为空!";
|
|
|
}
|
|
|
fYlCount = TypeUtil.toFloat(dr['YlCount']);
|
|
|
let Params = sBillNo+";"+"1401;*;"+CurInOrgCode+";"+sDepID+";"+sPluID+";"+sExPluCode+";"+sCkCode;
|
|
|
let JSONObject={DataType:"11",Params:Params};
|
|
|
let retKyCount = Service.getSlideMenuData("pubsysBaseBL","MSysGetLsKcKyCount",JSONObject,"","","","");
|
|
|
if (retKyCount.result === 1) {
|
|
|
if (fYlCount > TypeUtil.toFloat(retKyCount.message)){
|
|
|
let errmsg = "原料["+sPluCode+"-"+sPluName+"]的使用数量大于当前可用数量! <br> 当前可用数量:"+retKyCount.message;
|
|
|
return errmsg;
|
|
|
}
|
|
|
}
|
|
|
else{
|
|
|
return "查询商品库存失败:"+retKyCount.message;
|
|
|
}
|
|
|
}
|
|
|
if (dataSrc.uiObjCode === this.dsCp.uiObjCode) {
|
|
|
let sPluCode = TypeUtil.toString(dr['PluCode']);
|
|
|
let fCpCount = TypeUtil.toFloat(dr['CpCount']);
|
|
|
if (sPluCode.length > 0) {
|
|
|
if (fCpCount <= 0 ) {
|
|
|
return "成品数量不能小于或等于零!";
|
|
|
}
|
|
|
for (let i = 0; i< this.dsYl.rows.length; i++) {
|
|
|
let row = this.dsYl.rows[i];
|
|
|
let sYlPluCode = TypeUtil.toString(row['PluCode']);
|
|
|
if (sPluCode == sYlPluCode){
|
|
|
return "此商品已经在原料表中出现,不能作为成品商品!";
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
else{
|
|
|
return "成品商品编码不能为空!";
|
|
|
}
|
|
|
}
|
|
|
return true;
|
|
|
};
|
|
|
//列校验,列赋值时调用,发生异常表示校验失败
|
|
|
Biz.prototype.dataColumnValidate = function (dataSrc, dr, dc, value) {
|
|
|
if (dataSrc.uiObjCode === this.dsYl.uiObjCode) {
|
|
|
let curRow = this.dsMaster.currentRow;
|
|
|
let sDepCode = curRow ? TypeUtil.toString(curRow['DepCode']) : '';
|
|
|
if (sDepCode.length <= 0){
|
|
|
return '主表部门不能为空!';
|
|
|
}
|
|
|
}
|
|
|
if (dataSrc.uiObjCode === this.dsCp.uiObjCode) {
|
|
|
let curRow = this.dsMaster.currentRow;
|
|
|
let sDepCode = curRow ? TypeUtil.toString(curRow['DepCode']) : '';
|
|
|
if (sDepCode.length <= 0){
|
|
|
return '主表部门不能为空!';
|
|
|
}
|
|
|
}
|
|
|
return this.super('dataColumnValidate');
|
|
|
};
|
|
|
//校验小数精度
|
|
|
Biz.prototype.getPrecision = function (dataSrc, dr, dc, defaultPrecision) {
|
|
|
if (dataSrc.uiObjCode == this.dsYl.uiObjCode) {
|
|
|
//把这里改成需要控制的字段
|
|
|
if (dc.fieldName == 'YlCount') {
|
|
|
return TypeUtil.toInt(dr['R_DotDecimal']);
|
|
|
}
|
|
|
}
|
|
|
if (dataSrc.uiObjCode == this.dsCp.uiObjCode) {
|
|
|
//把这里改成需要控制的字段
|
|
|
if (dc.fieldName == 'CpCount') {
|
|
|
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 'GyCode':
|
|
|
this.fieldChangedGyCode(dataSrc, dr, dc);
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
if (dataSrc.uiObjCode === this.dsYl.uiObjCode) {
|
|
|
switch (dc.fieldName) {
|
|
|
case 'PluCode':
|
|
|
this.fieldChangedYlPluCode(dataSrc, dr, dc);
|
|
|
break;
|
|
|
case 'YlCount':
|
|
|
this.fieldChangedYlCount(dataSrc, dr, dc);
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
if (dataSrc.uiObjCode === this.dsCp.uiObjCode) {
|
|
|
switch (dc.fieldName) {
|
|
|
case 'PluCode':
|
|
|
this.fieldChangedCpPluCode(dataSrc, dr, dc);
|
|
|
break;
|
|
|
case 'CpCount':
|
|
|
this.fieldChangedCpCount(dataSrc, dr, dc);
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
this.super('fieldChanged');
|
|
|
};
|
|
|
//GyCode 字段变化执行事件
|
|
|
Biz.prototype.fieldChangedGyCode = function (dataSrc, dr, dc) {
|
|
|
let sGyCode = dr ? TypeUtil.toString(dr['GyCode']) : '';
|
|
|
let sDepCode = dr ? TypeUtil.toString(dr['DepCode']) : '';
|
|
|
let sGyRate = TypeUtil.toFloat(dr['GyRate']);
|
|
|
if (sGyCode.length > 0){
|
|
|
if (sGyRate <= 0){
|
|
|
Store.messager.err("请输入加工倍数(正整数)!");
|
|
|
return false;
|
|
|
}
|
|
|
if (sDepCode.length <= 0){
|
|
|
dr.setColumnValue('GyCode', '');
|
|
|
//dr.setColumnError(dc.fieldName,"请输入部门编码!");
|
|
|
Store.messager.err("请输入部门编码!");
|
|
|
return false;
|
|
|
}
|
|
|
let ret= Service.getSlideMenuData("getRefData","",sGyCode, sGyRate,"","","");
|
|
|
if (ret.result === 1) {
|
|
|
if (ret.data !== null){
|
|
|
if (ret.data[0] !== null) {
|
|
|
dr.setColumnValue('FlCost', ret.data[0][0].flcost);
|
|
|
}
|
|
|
if (ret.data[1] !== null) {
|
|
|
for(let i = 0; i < ret.data[1].length; i++) {
|
|
|
let newRow = this.dsYl.addRow();
|
|
|
//newRow.setColumnValue('SerialNo', i+1);
|
|
|
newRow.setColumnValue('PluID', ret.data[1][i].pluid);
|
|
|
newRow.setColumnValue('PluCode', ret.data[1][i].plucode);
|
|
|
newRow.setColumnValue('PluName', ret.data[1][i].pluname);
|
|
|
newRow.setColumnValue('BarCode', ret.data[1][i].barcode);
|
|
|
newRow.setColumnValue('Spec', ret.data[1][i].spec);
|
|
|
newRow.setColumnValue('Unit', ret.data[1][i].unit);
|
|
|
newRow.setColumnValue('ExPluCode', ret.data[1][i].explucode);
|
|
|
newRow.setColumnValue('ExPluName', ret.data[1][i].expluname);
|
|
|
newRow.setColumnValue('HJPrice', ret.data[1][i].hjprice);
|
|
|
newRow.setColumnValue('WJPrice', ret.data[1][i].wjprice);
|
|
|
newRow.setColumnValue('Price', ret.data[1][i].price);
|
|
|
newRow.setColumnValue('JTaxRate', ret.data[1][i].jtaxrate);
|
|
|
newRow.setColumnValue('YlPercent', ret.data[1][i].ylpercent);
|
|
|
newRow.setColumnValue('YlCount', ret.data[1][i].ylcount);
|
|
|
newRow.setColumnValue('YlHCost', ret.data[1][i].ylhcost);
|
|
|
newRow.setColumnValue('YlWCost', ret.data[1][i].ylwcost);
|
|
|
newRow.setColumnValue('YlTotal', ret.data[1][i].yltotal);
|
|
|
newRow.setColumnValue('JTaxCalType', ret.data[1][i].jtaxcaltype);
|
|
|
newRow.setColumnValue('Remark', ret.data[1][i].remark);
|
|
|
}
|
|
|
}
|
|
|
if (ret.data[2] !== null) {
|
|
|
for(let i = 0; i < ret.data[2].length; i++) {
|
|
|
let newRow = this.dsCp.addRow();
|
|
|
//newRow.setColumnValue('SerialNo', i+1);
|
|
|
newRow.setColumnValue('PluID', ret.data[2][i].pluid);
|
|
|
newRow.setColumnValue('PluCode', ret.data[2][i].plucode);
|
|
|
newRow.setColumnValue('PluName', ret.data[2][i].pluname);
|
|
|
newRow.setColumnValue('BarCode', ret.data[2][i].barcode);
|
|
|
newRow.setColumnValue('Spec', ret.data[2][i].spec);
|
|
|
newRow.setColumnValue('Unit', ret.data[2][i].unit);
|
|
|
newRow.setColumnValue('ExPluCode', ret.data[2][i].explucode);
|
|
|
newRow.setColumnValue('ExPluName', ret.data[2][i].expluname);
|
|
|
newRow.setColumnValue('HJPrice', ret.data[2][i].hjprice);
|
|
|
newRow.setColumnValue('WJPrice', ret.data[2][i].wjprice);
|
|
|
if (ret.data[2][i].exprice === null)
|
|
|
{
|
|
|
newRow.setColumnValue('Price', ret.data[2][i].price);
|
|
|
newRow.setColumnValue('CpTotal', ret.data[2][i].cptotal);
|
|
|
}
|
|
|
else{
|
|
|
let fExPrice = TypeUtil.toFloat(ret.data[2][i].exprice);
|
|
|
let fCpCount = TypeUtil.toFloat(ret.data[2][i].cpcount);
|
|
|
newRow.setColumnValue('Price', ret.data[2][i].exprice);
|
|
|
newRow.setColumnValue('CpTotal', (fExPrice*fCpCount).round(2));
|
|
|
}
|
|
|
newRow.setColumnValue('JTaxRate', ret.data[2][i].jtaxrate);
|
|
|
newRow.setColumnValue('CpPercent', ret.data[2][i].cppercent);
|
|
|
newRow.setColumnValue('CpCount', ret.data[2][i].cpcount);
|
|
|
newRow.setColumnValue('CpHCost', ret.data[2][i].cphcost);
|
|
|
newRow.setColumnValue('CpWCost', ret.data[2][i].cpwcost);
|
|
|
newRow.setColumnValue('JTaxCalType', ret.data[2][i].jtaxcaltype);
|
|
|
newRow.setColumnValue('Remark', ret.data[2][i].remark);
|
|
|
newRow.setColumnValue('FpPercent', ret.data[2][i].fppercent);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
return true;
|
|
|
};
|
|
|
//YlPluCode 字段变化执行事件
|
|
|
Biz.prototype.fieldChangedYlPluCode = function (dataSrc, dr, dc) {
|
|
|
let sPluCode = TypeUtil.toString(dr['PluCode']);
|
|
|
let sOldPluCode = TypeUtil.toString(dr.transData['PluCode']);
|
|
|
if (sPluCode === '') return false;
|
|
|
if (sPluCode != sOldPluCode){
|
|
|
let JSONObject={PluCode:sPluCode,PluID:'',FieldNameGrp:"HJPrice,WJPrice,Price,JTaxRate,JTaxCalType",FieldCount:5};
|
|
|
let ret = Service.getSlideMenuData("pubsysBaseBL","USkuGetPluPropInfo",JSONObject,"","","","");
|
|
|
if (ret.result === 1) {
|
|
|
if (ret.data != null) {
|
|
|
dr.setColumnValue('HJPrice', ret.data.HJPrice);
|
|
|
dr.setColumnValue('WJPrice', ret.data.WJPrice);
|
|
|
dr.setColumnValue('Price', ret.data.Price);
|
|
|
dr.setColumnValue('JTaxRate', ret.data.JTaxRate);
|
|
|
dr.setColumnValue('JTaxCalType', ret.data.JTaxCalType);
|
|
|
dr.setColumnValue('YlCount', '0');
|
|
|
dr.setColumnValue('YlHCost', '0');
|
|
|
dr.setColumnValue('YlWCost', '0');
|
|
|
dr.setColumnValue('YlTotal', '0');
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
return true;
|
|
|
};
|
|
|
//YlCount 字段变化执行事件
|
|
|
Biz.prototype.fieldChangedYlCount = function (dataSrc, dr, dc) {
|
|
|
let sPluCode = TypeUtil.toString(dr['PluCode']);
|
|
|
let sJTaxCalType = TypeUtil.toString(dr['JTaxCalType']);
|
|
|
let sJTaxRate = TypeUtil.toFloat(dr['JTaxRate']);
|
|
|
let fYlCount = TypeUtil.toFloat(dr['YlCount']);
|
|
|
let fPrice = TypeUtil.toFloat(dr['Price']);
|
|
|
let fHJPrice = TypeUtil.toFloat(dr['HJPrice']);
|
|
|
let fYlHCost = TypeUtil.toFloat((fHJPrice*fYlCount).round(2));
|
|
|
if (sPluCode === '') return false;
|
|
|
dr.setColumnValue('YlHCost', fYlHCost);
|
|
|
if (sJTaxCalType == '0'){
|
|
|
dr.setColumnValue('YlWCost', (fYlHCost/(1+sJTaxRate/100)).round(2));
|
|
|
}
|
|
|
else{
|
|
|
dr.setColumnValue('YlWCost', (fYlHCost*(1-sJTaxRate/100)).round(2));
|
|
|
}
|
|
|
dr.setColumnValue('YlTotal', (fPrice*fYlCount).round(2));
|
|
|
return true;
|
|
|
};
|
|
|
//CpPluCode 字段变化执行事件
|
|
|
Biz.prototype.fieldChangedCpPluCode = function (dataSrc, dr, dc) {
|
|
|
let masterRow = this.dsMaster.currentRow;
|
|
|
let sOrgCode = masterRow ? TypeUtil.toString(masterRow['OrgCode']) : '';
|
|
|
let sDepID = masterRow ? TypeUtil.toString(masterRow['DepID']) : '';
|
|
|
let sPluCode = TypeUtil.toString(dr['PluCode']);
|
|
|
let sOldPluCode = TypeUtil.toString(dr.transData['PluCode']);
|
|
|
let sInOrgCode = rhtComm.GetInOrgCode(sOrgCode).message;
|
|
|
if (sPluCode === '') return false;
|
|
|
if (sPluCode != sOldPluCode){
|
|
|
|
|
|
let JSONObjectEx={OrgCode:sInOrgCode,PluCode:sPluCode,PluID:'',FieldNameGrp:"DepID,Price",FieldCount:2};
|
|
|
let retEx = Service.getSlideMenuData("pubsysBaseBL","USkuGetPluExPropInfo",JSONObjectEx,"","","","");
|
|
|
let sExPrice = '';
|
|
|
if (retEx.result === 1) {
|
|
|
if (retEx.data != null) {
|
|
|
if (sDepID == retEx.data.DepID){
|
|
|
sExPrice = retEx.data.Price;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
let JSONObject={PluCode:sPluCode,PluID:'',FieldNameGrp:"PluCls,HJPrice,WJPrice,Price,JTaxRate,JTaxCalType",FieldCount:6};
|
|
|
let ret = Service.getSlideMenuData("pubsysBaseBL","USkuGetPluPropInfo",JSONObject,"","","","");
|
|
|
if (ret.result === 1) {
|
|
|
if (ret.data != null) {
|
|
|
if ((ret.data.PluCls !== null) && (FrsCpPluType == '1')){
|
|
|
if (ret.data.PluCls != '3'){
|
|
|
Store.messager.err("生鲜加工中成品必须选择商品类别为<加工成品>的商品。");
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
dr.setColumnValue('HJPrice', ret.data.HJPrice);
|
|
|
dr.setColumnValue('WJPrice', ret.data.WJPrice);
|
|
|
if (sExPrice == ''){
|
|
|
dr.setColumnValue('Price', ret.data.Price);
|
|
|
}
|
|
|
else{
|
|
|
dr.setColumnValue('Price', sExPrice);
|
|
|
}
|
|
|
dr.setColumnValue('JTaxRate', ret.data.JTaxRate);
|
|
|
dr.setColumnValue('JTaxCalType', ret.data.JTaxCalType);
|
|
|
dr.setColumnValue('CpCount', '0');
|
|
|
dr.setColumnValue('CpHCost', '0');
|
|
|
dr.setColumnValue('CpWCost', '0');
|
|
|
dr.setColumnValue('CpTotal', '0');
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
return true;
|
|
|
};
|
|
|
//CpCount 字段变化执行事件
|
|
|
Biz.prototype.fieldChangedCpCount = function (dataSrc, dr, dc) {
|
|
|
let sPluCode = TypeUtil.toString(dr['PluCode']);
|
|
|
let sJTaxCalType = TypeUtil.toString(dr['JTaxCalType']);
|
|
|
let sJTaxRate = TypeUtil.toFloat(dr['JTaxRate']);
|
|
|
let fCpCount = TypeUtil.toFloat(dr['CpCount']);
|
|
|
let fPrice = TypeUtil.toFloat(dr['Price']);
|
|
|
let fHJPrice = TypeUtil.toFloat(dr['HJPrice']);
|
|
|
let fCpHCost = TypeUtil.toFloat((fHJPrice*fCpCount).round(2));
|
|
|
if (sPluCode === '') return false;
|
|
|
dr.setColumnValue('CpHCost', fCpHCost);
|
|
|
if (sJTaxCalType == '0'){
|
|
|
dr.setColumnValue('CpWCost', (fCpHCost/(1+sJTaxRate/100)).round(2));
|
|
|
}
|
|
|
else{
|
|
|
dr.setColumnValue('CpWCost', (fCpHCost*(1-sJTaxRate/100)).round(2));
|
|
|
}
|
|
|
dr.setColumnValue('CpTotal', (fPrice*fCpCount).round(2));
|
|
|
return true;
|
|
|
};
|
|
|
//按钮事件控制
|
|
|
Biz.prototype.doOp = function (opCode) {
|
|
|
let self = this;
|
|
|
if (opCode == 'share') {
|
|
|
self.onshare();
|
|
|
}
|
|
|
};
|
|
|
//控制主界面按钮状态
|
|
|
Biz.prototype.getOpEnabled = function (opCode) {
|
|
|
let isOk = this.super('getOpEnabled', opCode);
|
|
|
if (!isOk) {
|
|
|
return false;
|
|
|
}
|
|
|
let curRow = this.dsMaster.currentRow;
|
|
|
if (opCode == 'share'){
|
|
|
if (!curRow)
|
|
|
return false;
|
|
|
|
|
|
if (!this.isEdit())
|
|
|
return false;
|
|
|
}
|
|
|
return true;
|
|
|
};
|
|
|
//分配按钮触发操作
|
|
|
Biz.prototype.onshare = function () {
|
|
|
if (this.dsCp.rows !== null){
|
|
|
let fSumCurr = 0.0;
|
|
|
for (let j = 0; j < this.dsCp.rows.length; j++) {
|
|
|
let row = this.dsCp.rows[j];
|
|
|
let fCpCount = TypeUtil.toFloat(row['CpCount']);
|
|
|
let fPrice = TypeUtil.toFloat(row['Price']);
|
|
|
fSumCurr = fSumCurr + (fCpCount*fPrice);
|
|
|
}
|
|
|
if (fSumCurr == 0){
|
|
|
Store.messager.err("售价金额合计值为零,不能进行自动分配!");
|
|
|
return false;
|
|
|
}
|
|
|
let fPercent = 0.0;
|
|
|
for (let j = 0; j < this.dsCp.rows.length; j++) {
|
|
|
let row = this.dsCp.rows[j];
|
|
|
if ((j+1) == this.dsCp.rows.length){
|
|
|
row.setColumnValue('FpPercent', (100-fPercent));
|
|
|
}
|
|
|
else{
|
|
|
let fCpCount = TypeUtil.toFloat(row['CpCount']);
|
|
|
let fPrice = TypeUtil.toFloat(row['Price']);
|
|
|
let fFpPercent = TypeUtil.toFloat(((fCpCount*fPrice*100)/fSumCurr).round(2));
|
|
|
row.setColumnValue('FpPercent', fFpPercent);
|
|
|
fPercent = fPercent + fFpPercent;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
return true;
|
|
|
};
|
|
|
return Biz;
|
|
|
}); |