|
|
|
|
define(function (require, exports, module) {
|
|
|
|
|
//引入业务类基类
|
|
|
|
|
let BaseBiz = require('apps/rht/base/rhtBiz');
|
|
|
|
|
let rhtService = require('../../base/rhtService');
|
|
|
|
|
let rhtComm = require('apps/rht/comm/rhtComm');
|
|
|
|
|
|
|
|
|
|
//引入业务服务
|
|
|
|
|
let Service = require('./cnt070203service');
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 定义业务类对象
|
|
|
|
|
* @param vm 界面相关ViewModule
|
|
|
|
|
*/
|
|
|
|
|
function Biz(vm) {
|
|
|
|
|
//继承第一步,构造继承
|
|
|
|
|
BaseBiz.call(this, vm);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//继承第二步,方法继承
|
|
|
|
|
inherits(Biz, BaseBiz);
|
|
|
|
|
|
|
|
|
|
Biz.prototype.initCompleted = function () {
|
|
|
|
|
this.super('initCompleted');
|
|
|
|
|
|
|
|
|
|
this.orgType = rhtComm.GetOrgType(Store.logOn.orgCode);
|
|
|
|
|
this.ctrlCntOrgDepRight = rhtComm.getRhtOptionValue("",'CNT','CtrlCntOrgDepRight','0');
|
|
|
|
|
this.isRefZkRate = rhtComm.getRhtOptionValue(Store.logOn.orgCode,'CNT','IsRefZkRate','1');
|
|
|
|
|
this.tcRateSecond = rhtComm.getRhtOptionValue(Store.logOn.orgCode,'CNT','CNT_TCRATE_SECOND','1');
|
|
|
|
|
this.isForeignCheck = rhtComm.getRhtOptionValue(Store.logOn.orgCode,'SYS','Sys_IsForeignCheck','0');
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
//拼装查询条件
|
|
|
|
|
Biz.prototype.beforeDataSrcSearch = function (dataSrc, params) {
|
|
|
|
|
let self = this;
|
|
|
|
|
self.setServerBiz('cn.qdhezheng.rht.app.cnt.cnt070202.PreProcess');
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
//控制主界面按钮状态
|
|
|
|
|
Biz.prototype.getOpEnabled = function (opCode) {
|
|
|
|
|
let self = this;
|
|
|
|
|
let isOk = this.super('getOpEnabled', opCode);
|
|
|
|
|
if (!isOk) return false;
|
|
|
|
|
let curRow = this.dsMaster.currentRow;
|
|
|
|
|
let orgCode = curRow ? TypeUtil.toString(curRow['OrgCode']) : '';
|
|
|
|
|
let forChkStatus = curRow ? TypeUtil.toString(curRow['ForeignChkStatus']) : '';
|
|
|
|
|
let jzDate = curRow ? TypeUtil.toString(curRow['JzDate']) : '';
|
|
|
|
|
|
|
|
|
|
if (opCode == 'edit') {
|
|
|
|
|
|
|
|
|
|
if (!curRow)
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
if (orgCode != Store.logOn.orgCode)
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
if(forChkStatus != '0' && forChkStatus != '3')
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
if(jzDate != '')
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
if (opCode == 'delete') {
|
|
|
|
|
if (!curRow)
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
if (orgCode != Store.logOn.orgCode)
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
if(forChkStatus != '0' && forChkStatus != '3')
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
if(jzDate != '')
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
if (opCode == 'account') {
|
|
|
|
|
// 入账
|
|
|
|
|
if (!curRow)
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
if (orgCode != Store.logOn.orgCode)
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
if (self.getState() === 'add' || self.getState() === 'edit') {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(this.isForeignCheck != '0')
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
if(jzDate != '')
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
if (opCode == 'forchk') {
|
|
|
|
|
// 外部审核
|
|
|
|
|
if (!curRow)
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
if (orgCode != Store.logOn.orgCode)
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
if (self.getState() === 'add' || self.getState() === 'edit') {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(jzDate != '')
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
if(this.isForeignCheck != '1')
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
if(forChkStatus != '0' && forChkStatus != '3')
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @description 数据发生变化时调用
|
|
|
|
|
* @param dataSrc 数据集
|
|
|
|
|
* @param dr 数据行
|
|
|
|
|
* @param dc 数据列
|
|
|
|
|
*/
|
|
|
|
|
Biz.prototype.fieldChanged = function (dataSrc, dr, dc) {
|
|
|
|
|
let self = this;
|
|
|
|
|
if (dataSrc.uiObjCode === this.dsMaster.uiObjCode) {
|
|
|
|
|
let currentRow = self.dsMaster.currentRow;
|
|
|
|
|
if (currentRow === null) return false;
|
|
|
|
|
switch (dc.fieldName) {
|
|
|
|
|
case 'SupCode':
|
|
|
|
|
this.fieldChangedSupCode(dataSrc, dr, dc);
|
|
|
|
|
break;
|
|
|
|
|
case 'HtCode':
|
|
|
|
|
this.fieldChangedHtCode(dataSrc, dr, dc);
|
|
|
|
|
break;
|
|
|
|
|
case 'MjFkCalType':
|
|
|
|
|
this.fieldChangedMjFkCalType(dataSrc, dr, dc);
|
|
|
|
|
break;
|
|
|
|
|
case 'IsMjJrXs':
|
|
|
|
|
this.fieldChangedMjFkCalType(dataSrc, dr, dc);
|
|
|
|
|
break;
|
|
|
|
|
case 'BgnDate':
|
|
|
|
|
this.fieldChangedBgnDate(dataSrc, dr, dc);
|
|
|
|
|
break;
|
|
|
|
|
case 'EndDate':
|
|
|
|
|
this.fieldChangedEndDate(dataSrc, dr, dc);
|
|
|
|
|
break;
|
|
|
|
|
case 'BgnTime':
|
|
|
|
|
this.fieldChangedBgnTime(dataSrc, dr, dc);
|
|
|
|
|
break;
|
|
|
|
|
case 'EndTime':
|
|
|
|
|
this.fieldChangedEndTime(dataSrc, dr, dc);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}else if (dataSrc.uiObjCode === this.dsDetail.uiObjCode) {
|
|
|
|
|
let currentRow = self.dsDetail.currentRow;
|
|
|
|
|
if (currentRow === null) return false;
|
|
|
|
|
switch (dc.fieldName) {
|
|
|
|
|
case 'ZkAreaCode':
|
|
|
|
|
this.fieldChangedZkAreaCode(dataSrc, dr, dc);
|
|
|
|
|
break;
|
|
|
|
|
case 'TcRate':
|
|
|
|
|
this.fieldChangedTcRate(dataSrc, dr, dc);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return this.super('fieldChanged');
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
Biz.prototype.fieldChangedSupCode = function (dataSrc, dr, dc) {
|
|
|
|
|
let supCode = TypeUtil.toString(dr['SupCode']);
|
|
|
|
|
if(supCode != '') {
|
|
|
|
|
dr.setColumnText('HtCode', '');
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
Biz.prototype.fieldChangedHtCode = function (dataSrc, dr, dc) {
|
|
|
|
|
let cntId = TypeUtil.toString(this.dsMaster.currentRow.CntID);
|
|
|
|
|
let htCode = TypeUtil.toString(this.dsMaster.currentRow.HtCode);
|
|
|
|
|
|
|
|
|
|
// 查询签订组织、部门、是否管理品牌
|
|
|
|
|
let ret = Service.GetCntInfo(htCode);
|
|
|
|
|
if (ret.result != 1) {
|
|
|
|
|
dr.setColumnError('HtCode','加载合同信息失败!' + ret.message);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.isMngBrand = TypeUtil.toString(ret.data.ismngbrand);
|
|
|
|
|
let supCode = TypeUtil.toString(ret.data.etpcode);
|
|
|
|
|
let signOrgCode = TypeUtil.toString(ret.data.orgcode);
|
|
|
|
|
let signDepCode = TypeUtil.toString(ret.data.signdepcode);
|
|
|
|
|
|
|
|
|
|
if(this.ctrlCntOrgDepRight == '1') {
|
|
|
|
|
// 检查合同的组织部门权限
|
|
|
|
|
ret = Service.CheckCntOrgDepRightAll('0', Store.logOn.userId, '', htCode, signOrgCode, signDepCode, '');
|
|
|
|
|
if (ret.result != 1) {
|
|
|
|
|
dr.setColumnError('HtCode','验证用户权限失败!' + ret.message);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
dr.setColumnValue('SupCode', supCode);
|
|
|
|
|
|
|
|
|
|
// 加载合同商品
|
|
|
|
|
// ret = Service.GetCntPlu(cntId);
|
|
|
|
|
// if (ret.result != 1) {
|
|
|
|
|
// Store.messager.err('加载合同商品失败!' + ret.message);
|
|
|
|
|
// return false;
|
|
|
|
|
// }
|
|
|
|
|
// this.cntPluJTaxRateList = ret.data;
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
Biz.prototype.fieldChangedMjFkCalType = function (dataSrc, dr, dc) {
|
|
|
|
|
let mjFkCalType = TypeUtil.toString(dr['MjFkCalType']);
|
|
|
|
|
let isMjJrXs = TypeUtil.toString(dr['IsMjJrXs']);
|
|
|
|
|
if(mjFkCalType == '1' && isMjJrXs == '1') {
|
|
|
|
|
dr.setColumnError('MjFkCalType','满减金额计入销售金额时,不需要设置满减返款方式,默认为“0-按销售金额返款”。');
|
|
|
|
|
dr.setColumnValue('MjFkCalType', '0');
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
Biz.prototype.fieldChangedBgnDate = function (dataSrc, dr, dc) {
|
|
|
|
|
let bgnDate = TypeUtil.toString(dr['BgnDate']);
|
|
|
|
|
let endDate = TypeUtil.toString(dr['EndDate']);
|
|
|
|
|
if(bgnDate != '' && endDate != '') {
|
|
|
|
|
if(bgnDate > endDate) {
|
|
|
|
|
dr.setColumnError('BgnDate','开始日期不能大于结束日期');
|
|
|
|
|
dr.setColumnValue('BgnDate', '');
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
Biz.prototype.fieldChangedEndDate = function (dataSrc, dr, dc) {
|
|
|
|
|
let bgnDate = TypeUtil.toString(dr['BgnDate']);
|
|
|
|
|
let endDate = TypeUtil.toString(dr['EndDate']);
|
|
|
|
|
if(bgnDate != '' && endDate != '') {
|
|
|
|
|
if(bgnDate > endDate) {
|
|
|
|
|
dr.setColumnError('EndDate','开始日期不能大于结束日期');
|
|
|
|
|
dr.setColumnValue('EndDate', '');
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
Biz.prototype.fieldChangedBgnTime = function (dataSrc, dr, dc) {
|
|
|
|
|
let bgnTime = TypeUtil.toString(dr['BgnTime']);
|
|
|
|
|
let endTime = TypeUtil.toString(dr['EndTime']);
|
|
|
|
|
if(bgnTime != '' && endTime != '') {
|
|
|
|
|
if(bgnTime > endTime) {
|
|
|
|
|
dr.setColumnError('BgnTime','开始时间不能大于结束时间');
|
|
|
|
|
dr.setColumnValue('BgnTime', '');
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
Biz.prototype.fieldChangedEndTime = function (dataSrc, dr, dc) {
|
|
|
|
|
let bgnTime = TypeUtil.toString(dr['BgnTime']);
|
|
|
|
|
let endTime = TypeUtil.toString(dr['EndTime']);
|
|
|
|
|
if(bgnTime != '' && endTime != '') {
|
|
|
|
|
if(bgnTime > endTime) {
|
|
|
|
|
dr.setColumnError('BgnTime','开始时间不能大于结束时间');
|
|
|
|
|
dr.setColumnValue('BgnTime', '');
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Biz.prototype.fieldChangedZkAreaCode = function (dataSrc, dr, dc) {
|
|
|
|
|
let zkAreaCode = TypeUtil.toFloat(dr['ZkAreaCode']);
|
|
|
|
|
if(this.isRefZkRate == '0' && zkAreaCode != '*0' && zkAreaCode != '*2' && zkAreaCode != '*3') {
|
|
|
|
|
dr.setColumnError('ZkAreaCode', '当前不允许使用折扣区间!');
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
Biz.prototype.fieldChangedTcRate = function (dataSrc, dr, dc) {
|
|
|
|
|
let tcRate = TypeUtil.toFloat(dr['TcRate']);
|
|
|
|
|
if(tcRate < 0 || tcRate >= 100) {
|
|
|
|
|
dr.setColumnError('TcRate', '提成率必须满足条件大于等于0小于100!');
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
//新增行后处理,默认值已经处理
|
|
|
|
|
Biz.prototype.afterNewRow = function (dataSrc, newRow) {
|
|
|
|
|
if (dataSrc.uiObjCode === this.dsMaster.uiObjCode) {
|
|
|
|
|
if(this.tcRateSecond == '1') {
|
|
|
|
|
this.dsMaster.getColumn('BgnTime').set('isEditable',true);
|
|
|
|
|
this.dsMaster.getColumn('EndTime').set('isEditable',true);
|
|
|
|
|
}else {
|
|
|
|
|
this.dsMaster.getColumn('BgnTime').set('isEditable',false);
|
|
|
|
|
this.dsMaster.getColumn('EndTime').set('isEditable',false);
|
|
|
|
|
}
|
|
|
|
|
}else if (dataSrc.uiObjCode === this.dsDetail.uiObjCode) {
|
|
|
|
|
if(TypeUtil.toString(this.dsMaster.currentRow['HtCode']) == '') {
|
|
|
|
|
Store.messager.err('请录入合同!');
|
|
|
|
|
dataSrc.currentRow.delete();
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
dataSrc.currentRow.setColumnValue('ZkAreaCode', '*0');
|
|
|
|
|
}
|
|
|
|
|
return this.super('afterNewRow', dataSrc, newRow);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
//按钮事件控制
|
|
|
|
|
Biz.prototype.doOp = function (opCode) {
|
|
|
|
|
let self = this;
|
|
|
|
|
if (opCode == 'account') {
|
|
|
|
|
let ds = self.dsMaster;
|
|
|
|
|
this.onAcc(self, ds);
|
|
|
|
|
}
|
|
|
|
|
if (opCode == 'forchk') {
|
|
|
|
|
let ds = self.dsMaster;
|
|
|
|
|
this.onForchk(self, ds);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
//按钮事件
|
|
|
|
|
Biz.prototype.onAcc = function (biz, ds) {
|
|
|
|
|
if (!Store.confirm("确定要记账吗")) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
let billNo = TypeUtil.toString(ds.currentRow['BillNo']);
|
|
|
|
|
let ret = Service.DoAccount(billNo, '0702');
|
|
|
|
|
if (ret.result != 1) {
|
|
|
|
|
Store.messager.err('记账失败!' + ret.message);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
Store.messager.tip('记账成功!');
|
|
|
|
|
biz.dsMaster.updateRow();
|
|
|
|
|
return true;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
Biz.prototype.onForchk = function (biz, ds) {
|
|
|
|
|
|
|
|
|
|
if (!Store.confirm("确定要审核吗")) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
let billNo = TypeUtil.toString(ds.currentRow['BillNo']);
|
|
|
|
|
let ret = Service.DoForchk(billNo);
|
|
|
|
|
if (ret.result != 1) {
|
|
|
|
|
Store.messager.err('提交外部审核失败!' + ret.message);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
Store.messager.tip('提交外部审核成功!');
|
|
|
|
|
biz.dsMaster.updateRow();
|
|
|
|
|
return true;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return Biz;
|
|
|
|
|
});
|