|
|
|
|
define(function (require, exports, module) {
|
|
|
|
|
let BaseBiz = require('apps/rht/base/rhtBiz');
|
|
|
|
|
let Service = require('./fsh140301service');
|
|
|
|
|
let rhtComm = require('../../comm/rhtComm');
|
|
|
|
|
let multiWindow = require("system/views/pages/multiwindow/multiwindow");
|
|
|
|
|
let IngredientWin = require('./ingredient-win')
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 控制按钮的可用
|
|
|
|
|
* @param opCode 按钮编码
|
|
|
|
|
* @return [description]
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
function Biz(vm) {
|
|
|
|
|
//继承第一步,构造继承
|
|
|
|
|
BaseBiz.call(this, vm);
|
|
|
|
|
vm.remark =''
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//继承第二步,方法继承
|
|
|
|
|
inherits(Biz, BaseBiz);
|
|
|
|
|
|
|
|
|
|
//根据登录组织等拼装查询条件
|
|
|
|
|
Biz.prototype.beforeDataSrcSearch = function (dataSrc, params) {
|
|
|
|
|
let self = this;
|
|
|
|
|
self.setServerBiz('cn.qdhezheng.rht.app.fsh.fsh140301.SavePlugin');
|
|
|
|
|
};
|
|
|
|
|
//保存前校验
|
|
|
|
|
Biz.prototype.beforeSave = function () {
|
|
|
|
|
let masterRow = this.dsMaster.currentRow;
|
|
|
|
|
if(masterRow){
|
|
|
|
|
let sGyCode = masterRow ? TypeUtil.toString(masterRow['GyCode']) : '';
|
|
|
|
|
let fFlCost = TypeUtil.toFloat(masterRow['FlCost']);
|
|
|
|
|
let sDepCode = masterRow ? TypeUtil.toString(masterRow['DepCode']) : '';
|
|
|
|
|
if (sDepCode.length <= 0){
|
|
|
|
|
return '主表部门不能为空!';
|
|
|
|
|
}
|
|
|
|
|
if (fFlCost < 0){
|
|
|
|
|
masterRow.setColumnError('GyCode', '辅料成本不能小于零!');
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
if (this.dsYl.rows == 0){
|
|
|
|
|
masterRow.setColumnError('GyCode', '工艺原料没有记录请输入!');
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
if (this.dsCp.rows == 0){
|
|
|
|
|
masterRow.setColumnError('GyCode', '工艺成品没有记录请输入!');
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
if (this.dsOrg.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;
|
|
|
|
|
}
|
|
|
|
|
let isAllOrg = '0';
|
|
|
|
|
for (let i = 0; i< this.dsOrg.rows.length; i++) {
|
|
|
|
|
let row = this.dsOrg.rows[i];
|
|
|
|
|
let sOrgCode = TypeUtil.toString(row['OrgCode']);
|
|
|
|
|
if (sOrgCode == '*'){
|
|
|
|
|
isAllOrg = '1';
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (isAllOrg == '1'){
|
|
|
|
|
if (this.dsOrg.rows.length > 1){
|
|
|
|
|
if (!Store.confirm('录入“*”代表全部适用,将自动删除“*”以外的使用组织!确认要继续保存吗?')) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
for (let i = this.dsOrg.rows.length - 1; i >= 0 ; i--) {
|
|
|
|
|
let row = this.dsOrg.rows[i];
|
|
|
|
|
let sOrgCode = TypeUtil.toString(row['OrgCode']);
|
|
|
|
|
if (sOrgCode != '*'){
|
|
|
|
|
row.delete();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
let ret= Service.getSlideMenuData("actExecute","DelYlForReplace",sGyCode,"","","","");
|
|
|
|
|
if (ret.result !== 1) {
|
|
|
|
|
masterRow.setColumnError('GyCode', ret.message);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
masterRow.setColumnValue('ModifyID', Store.logOn.userId);
|
|
|
|
|
masterRow.setColumnValue('ModifyCode', Store.logOn.userCode);
|
|
|
|
|
masterRow.setColumnValue('ModifyName', Store.logOn.userName);
|
|
|
|
|
masterRow.setColumnValue('ModifyDate', rhtComm.GetServerDateTime(0));
|
|
|
|
|
}
|
|
|
|
|
return this.super('beforeSave');
|
|
|
|
|
};
|
|
|
|
|
//单据删除前处理
|
|
|
|
|
Biz.prototype.beforeDelete = function () {
|
|
|
|
|
let masterRow = this.dsMaster.currentRow;
|
|
|
|
|
let sGyCode = masterRow ? TypeUtil.toString(masterRow['GyCode']) : '';
|
|
|
|
|
let ret= Service.getSlideMenuData("actExecute","FrsGyIsUsed",sGyCode,"","","","");
|
|
|
|
|
if (ret.result !== 1) {
|
|
|
|
|
masterRow.setColumnError('GyCode', ret.message);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
return this.super('beforeDelete');
|
|
|
|
|
};
|
|
|
|
|
//明细行单行提交触发的校验
|
|
|
|
|
Biz.prototype.dataRowValidate = function (dataSrc, dr) {
|
|
|
|
|
let curRow = this.dsMaster.currentRow;
|
|
|
|
|
let sDepCode = curRow ? TypeUtil.toString(curRow['DepCode']) : '';
|
|
|
|
|
if (sDepCode.length <= 0){
|
|
|
|
|
return '主表部门不能为空!';
|
|
|
|
|
}
|
|
|
|
|
if (dataSrc.uiObjCode === this.dsYl.uiObjCode) {
|
|
|
|
|
let sPluCode = TypeUtil.toString(dr['PluCode']);
|
|
|
|
|
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 "原料商品编码不能为空!";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
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 "成品商品编码不能为空!";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (dataSrc.uiObjCode === this.dsOrg.uiObjCode) {
|
|
|
|
|
let sOrgCode = dr ? TypeUtil.toString(dr['OrgCode']) : '';
|
|
|
|
|
if (sOrgCode.length <= 0) {
|
|
|
|
|
return "组织编码不能为空!";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (dataSrc.uiObjCode === this.dsYlRep.uiObjCode) {
|
|
|
|
|
let sPluCode = TypeUtil.toString(dr['PluCode']);
|
|
|
|
|
let fYlCount = TypeUtil.toFloat(dr['YlCount']);
|
|
|
|
|
if (sPluCode.length > 0) {
|
|
|
|
|
if (fYlCount <= 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 sPluCode+"此商品已经在原料表中出现,不能作为原料替换商品!";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
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 sPluCode+"此商品已经在成品表中出现,不能作为原料替换商品!";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else{
|
|
|
|
|
return "成品商品编码不能为空!";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
};
|
|
|
|
|
//校验小数精度
|
|
|
|
|
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.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;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
this.super('fieldChanged');
|
|
|
|
|
};
|
|
|
|
|
//YlPluCode 字段变化执行事件
|
|
|
|
|
Biz.prototype.fieldChangedYlPluCode = function (dataSrc, dr, dc) {
|
|
|
|
|
let sPluCode = TypeUtil.toString(dr['PluCode']);
|
|
|
|
|
let sPluID = TypeUtil.toString(dr['PluID']);
|
|
|
|
|
if (sPluCode === '') return false;
|
|
|
|
|
let curRow = this.dsMaster.currentRow;
|
|
|
|
|
let sDepCode = curRow ? TypeUtil.toString(curRow['DepCode']) : '';
|
|
|
|
|
if (sDepCode.length <= 0){
|
|
|
|
|
dr.setColumnError(dc.fieldName, '主表部门不能为空!');
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
let ret= Service.getSlideMenuData("DoOnDetailCalcRule","YlPluCode", sPluID,"","","","");
|
|
|
|
|
if (ret.result === 1) {
|
|
|
|
|
if (ret.data !== null) {
|
|
|
|
|
dr.setColumnValue('CKJPrice', ret.data.hjprice);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
};
|
|
|
|
|
//YlCount 字段变化执行事件
|
|
|
|
|
Biz.prototype.fieldChangedYlCount = function (dataSrc, dr, dc) {
|
|
|
|
|
let sPluCode = TypeUtil.toString(dr['PluCode']);
|
|
|
|
|
let fYlCount = TypeUtil.toFloat(dr['YlCount']);
|
|
|
|
|
let fCKJPrice = TypeUtil.toFloat(dr['CKJPrice']);
|
|
|
|
|
if (sPluCode === '') return false;
|
|
|
|
|
dr.setColumnValue('CKHCost', (fYlCount*fCKJPrice).round(2));
|
|
|
|
|
return true;
|
|
|
|
|
};
|
|
|
|
|
//CpPluCode 字段变化执行事件
|
|
|
|
|
Biz.prototype.fieldChangedCpPluCode = function (dataSrc, dr, dc) {
|
|
|
|
|
let curRow = this.dsMaster.currentRow;
|
|
|
|
|
let sDepCode = curRow ? TypeUtil.toString(curRow['DepCode']) : '';
|
|
|
|
|
if (sDepCode.length <= 0){
|
|
|
|
|
dr.setColumnError(dc.fieldName, '主表部门不能为空!');
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
let sPluCode = TypeUtil.toString(dr['PluCode']);
|
|
|
|
|
if (sPluCode === '') return false;
|
|
|
|
|
let ret= Service.getSlideMenuData("DoOnDetailCalcRule","CpPluCode", sPluCode,"","","","");
|
|
|
|
|
if (ret.result !== 1) {
|
|
|
|
|
dr.setColumnError(dc.fieldName, ret.message);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
if (ret.data != null) {
|
|
|
|
|
dr.setColumnValue('Price', ret.data.price);
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
};
|
|
|
|
|
//按钮事件控制
|
|
|
|
|
Biz.prototype.doOp = function (opCode) {
|
|
|
|
|
let self = this;
|
|
|
|
|
|
|
|
|
|
switch(opCode) {
|
|
|
|
|
case 'start':
|
|
|
|
|
self.onpubgydeal('0')
|
|
|
|
|
break
|
|
|
|
|
case 'modidy':
|
|
|
|
|
self.onpubgydeal('1')
|
|
|
|
|
break
|
|
|
|
|
case 'lose':
|
|
|
|
|
self.onpubgydeal('2')
|
|
|
|
|
break
|
|
|
|
|
case 'share':
|
|
|
|
|
self.onshare()
|
|
|
|
|
break
|
|
|
|
|
case 'pladduseorg':
|
|
|
|
|
self.onpladduseorg();
|
|
|
|
|
break
|
|
|
|
|
case 'ingredient-replace':
|
|
|
|
|
self.showIngredientWindow()
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
Biz.prototype.beforeDataSrcAddFirstRow = function(ds) {
|
|
|
|
|
if (ds === this.dsYl || ds === this.dsCp || ds === this.dsOrg) {
|
|
|
|
|
let isOk = this.dsMaster.currentRow && this.dsMaster.currentRow['GyCode']
|
|
|
|
|
if (!isOk) {
|
|
|
|
|
Store.messager.warn('请先填写加工工艺编码')
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return !!isOk
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Biz.prototype.afterNewRow = function (dataSrc, newRow) {
|
|
|
|
|
if (dataSrc === this.dsYlRep) {
|
|
|
|
|
newRow.setColumnText('GyCode', this.dsYl.currentRow['GyCode'])
|
|
|
|
|
// newRow.setColumnText('OriPluId', this.dsYl.currentRow['PluId'])
|
|
|
|
|
newRow.setColumnText('OriPluCode', this.dsYl.currentRow['PluCode'])
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Biz.prototype.showIngredientWindow = function() {
|
|
|
|
|
if (!this.dsYl.currentRow) {
|
|
|
|
|
Store.messager.err('请选择一条加工原料')
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let headerData = []
|
|
|
|
|
let ds = this.dsYl
|
|
|
|
|
this.dsYl.columns.forEach(col => {
|
|
|
|
|
if (col.dispPosition !== Store.Enums.DispPosition.ALL && col.dispPosition !== Store.Enums.DispPosition.BROWSER) {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
headerData.push({
|
|
|
|
|
label: col.dispName,
|
|
|
|
|
value: ds.currentRow.getColumnText(col)
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
this.dsYlRep.fixQuery = {
|
|
|
|
|
gyCode: ds.currentRow['GyCode'],
|
|
|
|
|
oriPluId: ds.currentRow['PluID']
|
|
|
|
|
}
|
|
|
|
|
let win = new IngredientWin({
|
|
|
|
|
headerData: headerData,
|
|
|
|
|
dataSource: this.dsYlRep
|
|
|
|
|
})
|
|
|
|
|
win.open()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//控制主界面按钮状态
|
|
|
|
|
Biz.prototype.getOpEnabled = function (opCode) {
|
|
|
|
|
let isOk = this.super('getOpEnabled', opCode);
|
|
|
|
|
if (!isOk) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
let curRow = this.dsMaster.currentRow;
|
|
|
|
|
let sUseStatus = curRow ? TypeUtil.toString(curRow['UseStatus']) : '';
|
|
|
|
|
let sOrgCode = curRow ? TypeUtil.toString(curRow['OrgCode']) : '';
|
|
|
|
|
|
|
|
|
|
if (opCode == 'share'){
|
|
|
|
|
if (!curRow)
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
if (!this.isEdit())
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
if ((opCode == 'edit') || (opCode == 'start')){
|
|
|
|
|
if (!curRow)
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
if (!this.isBrowser())
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
if ((sUseStatus != "0") && (sUseStatus != "1"))
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
if ((this._state =="edit") || (this._state =="add") )
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
if (sOrgCode != Store.logOn.orgCode)
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
if (opCode == 'delete'){
|
|
|
|
|
if (!curRow){
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ((sUseStatus != "0") ){
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ((this._state =="edit") || (this._state =="add") ){
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (sOrgCode != Store.logOn.orgCode){
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (opCode == 'lose'){
|
|
|
|
|
if (!curRow){
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!this.isBrowser()){
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ((sUseStatus != "2") && (sUseStatus != "1")){
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ((this._state =="edit") || (this._state =="add") ){
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (sOrgCode != Store.logOn.orgCode){
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (opCode == 'modidy'){
|
|
|
|
|
if (!curRow){
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!this.isBrowser()){
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (sUseStatus != "2"){
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ((this._state =="edit") || (this._state =="add") ){
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (sOrgCode != Store.logOn.orgCode){
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
};
|
|
|
|
|
//增加右键菜单按钮并控制按钮状态
|
|
|
|
|
Biz.prototype.getContextMenus = function (ds, source) {
|
|
|
|
|
let menus = this.super("getContextMenus", ds, source)
|
|
|
|
|
|
|
|
|
|
if (ds.uiObjCode=="14020"){
|
|
|
|
|
menus.push({
|
|
|
|
|
text: '批量添加使用组织',
|
|
|
|
|
opCode: 'pladduseorg',
|
|
|
|
|
disabled: !ds.getEditable()
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (ds.uiObjCode === '14002') {
|
|
|
|
|
let curRow = this.dsMaster.currentRow;
|
|
|
|
|
let sUseStatus = curRow ? TypeUtil.toString(curRow['UseStatus']) : '';
|
|
|
|
|
let sOrgCode = curRow ? TypeUtil.toString(curRow['OrgCode']) : '';
|
|
|
|
|
menus.push({
|
|
|
|
|
text: '替换配料',
|
|
|
|
|
opCode: 'ingredient-replace',
|
|
|
|
|
disabled: ds.getEditable() || ((sUseStatus != "0") && (sUseStatus != "1")) || (sOrgCode != Store.logOn.orgCode)
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return menus;
|
|
|
|
|
};
|
|
|
|
|
//批量多选组织事件处理
|
|
|
|
|
Biz.prototype.onpladduseorg = function () {
|
|
|
|
|
let self = this;
|
|
|
|
|
//定义多选窗口界面
|
|
|
|
|
let exists = new Array();
|
|
|
|
|
for (let j = 0; j < self.dsOrg.rows.length; j++) {
|
|
|
|
|
exists.push({
|
|
|
|
|
'OrgCode': self.dsOrg.rows[j].OrgCode
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let param={
|
|
|
|
|
exists: exists,
|
|
|
|
|
uiObjCode: 'vFrsOrg',
|
|
|
|
|
biz: self,
|
|
|
|
|
pk: "OrgCode",
|
|
|
|
|
showCheckColumn: true,
|
|
|
|
|
funcCode: self.FuncCode,
|
|
|
|
|
ds: self.dsOrg,
|
|
|
|
|
itreator: function (row) {
|
|
|
|
|
let isOK = self.addrows(row);
|
|
|
|
|
if (isOK != true) {
|
|
|
|
|
Store.messager.err("批量导入组织失败,校验失败!");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
//new多选窗体 并打开
|
|
|
|
|
let myWindow = new multiWindow(param);
|
|
|
|
|
myWindow.open();
|
|
|
|
|
};
|
|
|
|
|
//批量增加每行后触发操作
|
|
|
|
|
Biz.prototype.addrows = function (row) {
|
|
|
|
|
let ds = this.dsOrg;
|
|
|
|
|
if (row != null) {
|
|
|
|
|
let dr = ds.addRow();
|
|
|
|
|
if (!dr.setColumnText('OrgCode', row.OrgCode)){
|
|
|
|
|
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;
|
|
|
|
|
};
|
|
|
|
|
//启用、调整、作废公用按钮触发操作
|
|
|
|
|
Biz.prototype.onpubgydeal = function (sDealType) {
|
|
|
|
|
let sMsg = '确认要启用该工艺吗?';
|
|
|
|
|
if (sDealType == '1'){
|
|
|
|
|
sMsg = '调整期间工艺不可用于加工,确认要调整该工艺吗?';
|
|
|
|
|
}
|
|
|
|
|
if (sDealType == '2'){
|
|
|
|
|
sMsg = '作废后该工艺不可用于加工,确认要作废该工艺吗?';
|
|
|
|
|
}
|
|
|
|
|
if (!Store.confirm(sMsg)) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
let masterRow = this.dsMaster.currentRow;
|
|
|
|
|
let sGyCode = masterRow ? TypeUtil.toString(masterRow['GyCode']) : '';
|
|
|
|
|
let ret= Service.getSlideMenuData("actExecute","onpubgydeal", sGyCode,sDealType,"","","");
|
|
|
|
|
if (ret.result !== 1) {
|
|
|
|
|
Store.messager.err("处理失败:"+ret.message);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
this.dsMaster.updateRow();
|
|
|
|
|
Store.messager.tip("处理成功!");
|
|
|
|
|
return true;
|
|
|
|
|
};
|
|
|
|
|
return Biz;
|
|
|
|
|
});
|