You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

276 lines
11 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

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('./cnt070204service');
/**
* 定义业务类对象
* @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.cnt070204.PreProcess');
};
/**
* @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 'AsnMode':
this.fieldChangedAsnMode(dataSrc, dr, dc);
break;
case 'AsnBase':
this.fieldChangedAsnBase(dataSrc, dr, dc);
break;
case 'HtCode':
this.fieldChangedHtCode(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 'UsOrgCode':
this.fieldChangedUsOrgCode(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.fieldChangedAsnMode = function (dataSrc, dr, dc) {
let masterAdapter = this.view.vm['ep_dsMaster'];
let asnMode = TypeUtil.toString(this.dsMaster.currentRow['AsnMode']);
if(asnMode == '2') {
dr.setColumnError('AsnMode','合同折扣承担条款不支持分配方式2-按指定金额。');
return false;
}
if(asnMode == '0') {
masterAdapter.setEditorEditable('AsnRate', true);
}else {
masterAdapter.setEditorEditable('AsnRate', false);
}
if(asnMode == '1') {
dr.setColumnValue('AsnRate', 0);
}
return true;
};
Biz.prototype.fieldChangedAsnBase = function (dataSrc, dr, dc) {
let asnBase = TypeUtil.toString(this.dsMaster.currentRow['AsnBase']);
if(asnBase == '24') {
dr.setColumnError('AsnBase','【合同折扣承担条款设置】不支持分配基数24-指定支付方式销售额。<br/>' +
'可通过扣项的“计算基数”“24-零售支付方式销售额”实现 <br/>' +
'在扣项中设置“支付方式”,指定扣项比例即可。' +
'通过扣项设置,指定支付方式发生销售后,就会按照扣项中指定的比例进行扣项,<br/>' +
'最终扣项结果反映在对账单的“扣项金额”上。<br/>');
return false;
}else if(asnBase == '30') {
dr.setColumnError('AsnBase','合同折扣承担条款不支持分配基数30-商品销售数量。');
return false;
}else {
dr.setColumnText('PayMode', '');
let masterAdapter = this.view.vm['ep_dsMaster'];
masterAdapter.setEditorEditable('PayMode', false);
}
return true;
};
Biz.prototype.fieldChangedHtCode = function (dataSrc, dr, dc) {
let htCode = TypeUtil.toString(this.dsMaster.currentRow.HtCode);
if(htCode === '') {
return true;
}
// 查询签订组织、部门、是否管理品牌
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);
return true;
};
Biz.prototype.fieldChangedUsOrgCode = function (dataSrc, dr, dc) {
dr.setColumnText('PrjType', '0');
return true;
};
//新增行后处理,默认值已经处理
Biz.prototype.afterNewRow = function (dataSrc, newRow) {
if (dataSrc.uiObjCode === this.dsMaster.uiObjCode) {
this.dsMaster.getColumn('PayMode').set('isEditable',false);
dataSrc.currentRow.setColumnValue('OrgCode', '*');
dataSrc.currentRow.setColumnValue('SerialNo', rhtComm.GetNextId("7013","1",Store.logOn.orgCode));
}else if (dataSrc.uiObjCode === this.dsDetail.uiObjCode) {
if(TypeUtil.toString(this.dsMaster.currentRow['HtCode']) == '') {
Store.messager.err('请录入合同!');
dataSrc.currentRow.delete();
return false;
}
}
return this.super('afterNewRow', dataSrc, newRow);
};
Biz.prototype.afterEdit = function () {
let masterAdapter = this.view.vm['ep_dsMaster'];
let asnBase = TypeUtil.toString(this.dsMaster.currentRow['AsnBase']);
let asnMode = TypeUtil.toString(this.dsMaster.currentRow['AsnMode']);
if(asnBase == '24') {
masterAdapter.setEditorEditable('PayMode', true);
}else {
masterAdapter.setEditorEditable('PayMode', false);
}
if(asnMode == '0') {
masterAdapter.setEditorEditable('AsnRate', true);
}else {
masterAdapter.setEditorEditable('AsnRate', false);
}
return this.super('afterEdit');
}
//保存前数据判断
Biz.prototype.beforeSave = function () {
let curRow = this.dsMaster.currentRow;
if(curRow){
let asnBase = TypeUtil.toString(this.dsMaster.currentRow['AsnBase']);
let asnMode = TypeUtil.toString(this.dsMaster.currentRow['AsnMode']);
let payMode = TypeUtil.toString(this.dsMaster.currentRow['PayMode']);
let bgnDate = TypeUtil.toString(this.dsMaster.currentRow['BgnDate']);
let endDate = TypeUtil.toString(this.dsMaster.currentRow['EndDate']);
let jTaxRate = TypeUtil.toFloat(this.dsMaster.currentRow['JTaxRate']);
let xTaxRate = TypeUtil.toFloat(this.dsMaster.currentRow['XTaxRate']);
if(asnMode == '2') {
Store.messager.err('合同折扣承担条款不支持分配方式2-按指定金额。');
return false;
}
if(asnBase == '24') {
Store.messager.err('【合同折扣承担条款设置】不支持分配基数24-指定支付方式销售额。<br/>' +
'可通过扣项的“计算基数”“24-零售支付方式销售额”实现 <br/>' +
'在扣项中设置“支付方式”,指定扣项比例即可。' +
'通过扣项设置,指定支付方式发生销售后,就会按照扣项中指定的比例进行扣项,<br/>' +
'最终扣项结果反映在对账单的“扣项金额”上。<br/>');
return false;
}else if(asnBase == '30') {
Store.messager.err('合同折扣承担条款不支持分配基数30-商品销售数量。');
return false;
}
if(asnBase == '24' && payMode == '') {
Store.messager.err('请指定支付方式!');
return false;
}
if(bgnDate > endDate) {
Store.messager.err('开始日期不能大于结束日期!');
return false;
}
if(jTaxRate < 0) {
Store.messager.err('进项税率必须大于等于零!!');
return false;
}
if(xTaxRate < 0) {
Store.messager.err('销项税率必须大于等于零!!');
return false;
}
curRow.setColumnValue('PRISet', '0');
}
return this.super('beforeSave');
}
/**
* 删除前询问,通常进行一些删除前校验操作
* 默认操作会提示‘确定删除?’询问
* @return {Boolean,String} 返回操作是否被允许,只有false时才会不允许执行其他则作为提示询问用户
*
*/
Biz.prototype.beforeDelete = function () {
let self = this;
let curRow = this.dsMaster.currentRow;
Store.messager.confirm("确定删除当前数据吗?",
function (isOK) {
if(isOK) {
let serialNo = TypeUtil.toString(curRow['SerialNo']);
let orgCode = TypeUtil.toString(curRow['OrgCode']);
// 合同状态维护
let whRes= Service.CntDeleteDisCd(serialNo, orgCode, '0');
if (whRes.result !== 1) {
Store.messager.tip('删除失败!' + whRes.message);
return false;
}
self.opRouter('refresh');
}
}
);
return false;
};
return Biz;
});