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.

284 lines
11 KiB

4 years ago
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('./cnt070205service');
/**
* 定义业务类对象
* @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', '');
dr.setColumnText('PluCode', '');
dr.setColumnText('BarCode', '');
}
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 == '0') {
masterAdapter.setEditorEditable('AsnRate', true);
}else {
dr.setColumnValue('AsnRate', 0);
masterAdapter.setEditorEditable('AsnRate', false);
}
if(asnMode == '2') {
masterAdapter.setEditorEditable('AsnTotal', true);
}else {
dr.setColumnValue('AsnTotal', 0);
masterAdapter.setEditorEditable('AsnTotal', false);
}
return true;
};
Biz.prototype.fieldChangedAsnBase = function (dataSrc, dr, dc) {
let asnBase = TypeUtil.toString(this.dsMaster.currentRow['AsnBase']);
let masterAdapter = this.view.vm['ep_dsMaster'];
if(asnBase == '24') {
masterAdapter.setEditorEditable('PayMode', true);
}else {
dr.setColumnText('PayMode', '');
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;
}
dr.setColumnText('PluCode', '');
dr.setColumnText('BarCode', '');
// 查询签订组织、部门、是否管理品牌
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', '1');
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("7014","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.afterAdd = 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);
}
if(asnMode == '2') {
masterAdapter.setEditorEditable('AsnTotal', true);
}else {
masterAdapter.setEditorEditable('AsnTotal', false);
}
return this.super('afterEdit');
}
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);
}
if(asnMode == '2') {
masterAdapter.setEditorEditable('AsnTotal', true);
}else {
masterAdapter.setEditorEditable('AsnTotal', 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(asnBase == '24' && payMode == '') {
Store.messager.err('请指定支付方式!');
return false;
}
if(bgnDate > endDate) {
Store.messager.err('开始日期不能大于结束日期!');
return false;
}
if(asnBase == '30' && asnMode != '2') {
Store.messager.err('当分配基数为“30-商品销售数量”时分配方式只能是“2-按指定金额”!');
return false;
}
if(asnBase != '30' && asnMode == '2') {
Store.messager.err('当分配方式为“2-按指定金额”时分配基数只能是“30-商品销售数量”!');
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, '1');
if (whRes.result !== 1) {
Store.messager.tip('删除失败!' + whRes.message);
return false;
}
self.opRouter('refresh');
}
}
);
return false;
};
return Biz;
});