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('./cnt070101service');
let SglRenew = require('./SglRenew');
let BatchRenewDate = require('./BatchRenewDate');
/**
* 定义业务类对象
* @param vm 界面相关ViewModule
*/
function Biz(vm) {
//继承第一步,构造继承
BaseBiz.call(this, vm);
}
//继承第二步,方法继承
inherits(Biz, BaseBiz);
let orgType = rhtComm.GetOrgType(Store.logOn.orgCode);
let cntStrictCtrlOrgDep = rhtComm.getRhtOptionValue("*",'CNT','CntStrictCtrlOrgDep','0');
let ctrlCntOrgDepRight = rhtComm.getRhtOptionValue("*",'CNT','CtrlCntOrgDepRight','0');
let cntCtrlCntOrgRight = rhtComm.getRhtOptionValue("*",'CNT','Cnt_CtrlCntOrgRight','0');
let cntBdShowYS = rhtComm.getRhtOptionValue("*",'CNT','Cnt_BdShowYS','0');
let cntIsCtrlCntStore = rhtComm.getRhtOptionValue("*",'CNT','Cnt_IsCtrlCntStore','0');
let sysIsForeignCheck = rhtComm.getRhtOptionValue(Store.logOn.orgCode,'SYS','Sys_IsForeignCheck','0');
let cntAfterExecute = rhtComm.getRhtOptionValue(Store.logOn.orgCode,'CNT','Cnt_AfterExecute','0');
let autoCntCode = rhtComm.getRhtOptionValue("*",'CNT','AutoCntCode','0');
let codeWasteWidth = rhtComm.getRhtOptionValue("*",'CNT','CodeWasteWidth','1');
let cntIsAutoName = rhtComm.getRhtOptionValue("*",'CNT','Cnt_IsAutoName','0');
let cntJsCodeJyModeYz = rhtComm.getRhtOptionValue("*",'CNT','Cnt_JsCodeJyMode','0');
let cntIsCtrlDays = rhtComm.getRhtOptionValue("*",'CNT','Cnt_IsCtrlDays','0');
let cntIsWCgZsYsZdHt = rhtComm.getRhtOptionValue("*",'CNT','Cnt_IsWCgZsYsZdHt','0');
let cntIsUseNewLease = rhtComm.getRhtOptionValue("*",'CNT','CNT_IsUseNewLease','0');
let cntIsAutoHtKkNo = rhtComm.getRhtOptionValue("*",'CNT','Cnt_IsAutoHtKkNo','0');
let cntAutoHtKkNoPrefix = rhtComm.getRhtOptionValue("*",'CNT','Cnt_AutoHtKkNoPrefix','Z');
var needSignDept = rhtComm.getRhtOptionValue("",'CNT','NeedSignDept','0');
var orgCatRelation = rhtComm.getRhtOptionValue("",'CAT','Org_CatRelation','0');
var productClass = rhtComm.getRhtOptionValue("*",'SYS','PRODUCT_CLASS','0');
var autoRank = false;
var isRight = false;
var orgCodeValue = '';
var fInit = false;
var isZB = false; // 是否总部
var czType = 0; //操作方式 0-增加1-修改3-续签4-显示详细信息
var preJsCode = '0';
Biz.prototype.initCompleted = function () {
this.super('initCompleted');
var masterAdapter = this.view.vm['ep_dsMaster'];
if(orgType == '1001' || orgType == '1002') {
isZB = true;
}
if(cntJsCodeJyModeYz == '1') {
masterAdapter.setEditorEditable('JyMode', false);
}
if(productClass == '1') {
masterAdapter.setEditorEditable('JyMode', false);
masterAdapter.setEditorEditable('JsCode', false);
}
if((orgType == '1001' || orgType == '1002') && czType != '4') {
this.dsDetailStore.setEditable(true);
}else {
this.dsDetailStore.setEditable(false);
}
};
//根据登录组织等拼装查询条件
Biz.prototype.beforeDataSrcSearch = function (dataSrc, params) {
var self = this;
self.setServerBiz('cn.qdhezheng.rht.app.cnt.cnt070101.PreProcess');
};
//控制主界面按钮状态
Biz.prototype.getOpEnabled = function (opCode) {
var self = this;
var isOk = this.super('getOpEnabled', opCode);
if (!isOk) return false;
var curRow = this.dsMaster.currentRow;
var orgCode = curRow ? TypeUtil.toString(curRow['OrgCode']) : '';
var htStatus = curRow ? TypeUtil.toString(curRow['HtStatus']) : '';
var jsCode = curRow ? TypeUtil.toString(curRow['JsCode']) : '';
var signDepCode = curRow ? TypeUtil.toString(curRow['SignDepCode']) : '';
var forChkStatus = curRow ? TypeUtil.toString(curRow['ForeignChkStatus']) : '';
if (opCode == 'add') {
// 控制“新增"按钮的可用性:只有业务组织才能添加采购合同(包括:连锁总部和门店)
if(orgType >= '1001' && orgType <= '1999') {
return true;
}else {
return false;
}
}
if (opCode == 'edit') {
if (!curRow)
return false;
if (orgCode != Store.logOn.orgCode)
return false;
if(htStatus == '3')
return false;
if(sysIsForeignCheck == '1' && !(((forChkStatus == '0') || (forChkStatus == '3') || (forChkStatus == '2')) && (htStatus == '0')))
return false;
if(cntAfterExecute == '0' && htStatus == '1')
return false;
}
if (opCode == 'delete') {
if (!curRow)
return false;
if (orgCode != Store.logOn.orgCode)
return false;
if(htStatus != '0' && htStatus != '3')
return false;
if(sysIsForeignCheck == '1' && !(((forChkStatus == '0') || (forChkStatus == '3')) && (forChkStatus == '0')))
return false;
}
if (opCode == 'acc') {
if (!curRow)
return false;
if (orgCode != Store.logOn.orgCode)
return false;
}
if (opCode == 'act') {
if (!curRow)
return false;
if (orgCode != Store.logOn.orgCode)
return false;
if(sysIsForeignCheck === '1')
return false;
if(htStatus != '0')
return false;
if(sysIsForeignCheck == '1' && !(((forChkStatus == '2') && (htStatus == '0'))))
return false;
}
if (opCode == 'stop') {
if (!curRow)
return false;
if (orgCode != Store.logOn.orgCode)
return false;
if(htStatus != '1' && htStatus != '4')
return false;
}
if (opCode == 'renew') {
if (!curRow)
return false;
if (orgCode != Store.logOn.orgCode)
return false;
if(htStatus == '0')
return false;
}
if (opCode == 'singlerenew') {
if (!curRow)
return false;
if (orgCode != Store.logOn.orgCode)
return false;
if(htStatus != '3')
return false;
}
if (opCode == 'trysale') {
if (!curRow)
return false;
if (orgCode != Store.logOn.orgCode)
return false;
if(htStatus == '3')
return false;
}
if (opCode == 'attachment') {
if (!curRow)
return false;
if (orgCode != Store.logOn.orgCode)
return false;
}
if (opCode == 'delattachment') {
if (!curRow)
return false;
if (orgCode != Store.logOn.orgCode)
return false;
}
if (opCode == 'forchk') {
if (!curRow)
return false;
if (orgCode != Store.logOn.orgCode)
return false;
if(sysIsForeignCheck == '0')
return false;
if(htStatus != '0')
return false;
if(!((htStatus == '0') && ((forChkStatus == '0' ) || (forChkStatus == '3'))))
return false;
}
if (opCode == 'protest') {
if (!curRow)
return false;
if (orgCode != Store.logOn.orgCode)
return false;
if(htStatus == '0')
return false;
}
return true;
};
// 主表数据行变化
Biz.prototype.currentChanged = function(dataSrc, oldRow, newRow) {
if(dataSrc.name == 'dsMaster') {
var masterAdapter = this.view.vm['ep_dsMaster'];
var jsCode = newRow ? TypeUtil.toString(newRow['JsCode']) : '';
var yqDays = newRow ? TypeUtil.toString(newRow['YqDays']) : '';
var yjDays = newRow ? TypeUtil.toString(newRow['YjDays']) : '';
var htStatus = newRow ? TypeUtil.toString(newRow['HtStatus']) : '';
if(jsCode <= '1') {
$('#detail-tab').children().first().tabs('enableTab', 6);
}else {
$('#detail-tab').children().first().tabs('disableTab', 6);
}
if(jsCode == '2') {
$('#detail-tab').children().first().tabs('enableTab', 4);
if(cntBdShowYS == '1') {
}else {
}
}else {
$('#detail-tab').children().first().tabs('disableTab', 4);
}
// 显示收货仓库
if(jsCode != '3' && cntIsCtrlCntStore == '1') {
$('#detail-tab').children().first().tabs('enableTab', 11);
}else {
$('#detail-tab').children().first().tabs('disableTab', 11);
}
this.ChangeJsModeBtn();
if(jsCode == '0' || jsCode == '1') {
masterAdapter.setEditorEditable('IsMngJPrice', true);
}else {
masterAdapter.setEditorEditable('IsMngJPrice', false);
}
if(jsCode == '0') {
masterAdapter.setEditorEditable('YkRate', true);
}else {
masterAdapter.setEditorEditable('YkRate', false);
}
if(yqDays == '' || yqDays == '0') {
masterAdapter.setEditorEditable('YjDays', true);
}else {
masterAdapter.setEditorEditable('YjDays', false);
}
if(yjDays == '' || yjDays == '0') {
masterAdapter.setEditorEditable('YqDays', true);
}else {
masterAdapter.setEditorEditable('YqDays', false);
}
if((yqDays == '' || yqDays == '0') && (yjDays == '' || yjDays == '0') && jsCode !='3') {
masterAdapter.setEditorEditable('JsPeriod', true);
}else {
masterAdapter.setEditorEditable('JsPeriod', false);
}
if((orgType == '1001' || orgType == '1002') && czType != '4') {
this.dsDetailStore.setEditable(true);
}else {
this.dsDetailStore.setEditable(false);
}
}
return this.super('currentChanged', dataSrc, oldRow, newRow);
};
//点击添加按钮时执行
Biz.prototype.beforeAdd = function () {
czType = 0;
if(autoCntCode != '0' && autoCntCode != '1' && autoCntCode != '2') {
Store.messager.err('系统选项中设置的合同编码生成方式不正确,请重新设置!');
return false;
}
//this.dsDetailBd.addRow();
return this.super('beforeAdd');
};
//添加后执行
Biz.prototype.afterAdd = function () {
this.dsDetailBd.addRow();
var detailBdAdapter = this.view.vm['ep_dsDetailBd'];
detailBdAdapter.setEditorEditable('IsBdEveryMonth', false);
return this.super('afterAdd');
};
//编辑前
Biz.prototype.beforeEdit = function () {
czType = 1;
return this.super('beforeEdit');
};
Biz.prototype.afterEdit = function () {
if(czType == '1') {
if(this.dsMaster.currentRow.JsCode == '0' || this.dsMaster.currentRow.JsCode == '1') {
if(this.dsMaster.currentRow.HtStatus != '0' || this.dsDetailPlu.rows.length > 0) {
this.dsDetailPlu.setEditable(false);
}
}
if(this.dsMaster.currentRow.HtStatus == '1' || this.dsMaster.currentRow.HtStatus == '4') {
this.dsDetailRentRate.setEditable(false);
}
}else if(czType == '3') {
var masterAdapter = this.view.vm['ep_dsMaster'];
if(this.dsMaster.currentRow.OriCntId != '0') {
masterAdapter.setEditorEditable('StartDate', false);
}else {
masterAdapter.setEditorEditable('StartDate', true);
}
if(this.dsMaster.currentRow.JsCode == '0' || this.dsMaster.currentRow.JsCode == '1') {
masterAdapter.setEditorEditable('JyMode', false);
}else {
masterAdapter.setEditorEditable('JyMode', true);
}
masterAdapter.setEditorEditable('JsCode', false);
}
return this.super('afterEdit');
};
//新增行后处理,默认值已经处理
Biz.prototype.afterNewRow = function (dataSrc, newRow) {
if (dataSrc.uiObjCode === this.dsMaster.uiObjCode) {
var cntID = rhtComm.GetNextId("7001","1",Store.logOn.orgCode);
var currDate=new Date(Store.bizDao.getSysDate()).format('yyyy-MM-dd');
var currTime=new Date(Store.bizDao.getSysDate()).format('yyyy-MM-dd hh:mm:ss');
newRow.setColumnValue('CntID',cntID);
newRow.setColumnValue('StartDate',currDate);
newRow.setColumnValue('SignDate',currDate);
newRow.setColumnValue('LoginDate',currDate);
newRow.setColumnValue('LrDate',currTime);
if(autoCntCode != '0') {
this.dsMaster.getColumn('HtCode').set('isEditable',false);
}
}
return this.super('afterNewRow', dataSrc, newRow);
};
//保存前校验
Biz.prototype.beforeSave = function () {
var curRow = this.dsMaster.currentRow;
if(TypeUtil.toString(curRow.HtCode) == '') {
return this.AutoGenHtCode();
}
var currDate = new Date(rhtComm.GetServerDateTime(0)).format('yyyy-MM-dd');
var cntId = TypeUtil.toString(curRow.CntID);
var orgCode = TypeUtil.toString(curRow.OrgCode);
var htCode = TypeUtil.toString(curRow.HtCode);
var jsCode = TypeUtil.toString(curRow.JsCode);
var endDate = TypeUtil.toString(curRow.EndDate);
var signDate = TypeUtil.toString(curRow.SignDate);
var shpCode = TypeUtil.toString(curRow.ShpCode);
var shpName = TypeUtil.toString(curRow.ShpName);
var leaseJsCode = TypeUtil.toString(curRow.LeaseJsCode);
var signDepCode = TypeUtil.toString(curRow.SignDepCode);
var yqDays = TypeUtil.toString(curRow.YqDays);
var zqDays = TypeUtil.toString(curRow.ZqDays);
var yjDays = TypeUtil.toString(curRow.YjDays);
var isMngJPrice = TypeUtil.toString(curRow.IsMngJPrice);
var chgStatus = TypeUtil.toString(curRow.ChgStatus);
var isMngCls = TypeUtil.toString(curRow.IsMngCls);
var isMngBrand = TypeUtil.toString(curRow.IsMngBrand);
if(jsCode == '3') {
if(leaseJsCode != '4' && shpCode == '') {
Store.messager.err('必须录入店铺!');
return false;
}
if(leaseJsCode == '9') {
Store.messager.err('结算方式为租金结算时,租金计算方式不能为空!');
return false;
}
var ret = Service.GetShopInfo(shpCode, Store.logOn.orgCode);
if (ret.result != 1 && leaseJsCode != '4') {
Store.messager.tip('验证店铺信息失败!' + ret.message);
return false;
}
}
if(jsCode != '3' && leaseJsCode != '9') {
Store.messager.err('结算方式为非租金结算时,租金计算方式必须设为空!');
return false;
}
if(needSignDept == '1' && signDepCode == '') {
Store.messager.err('合同必须填写签订部门!');
return false;
}
// 华普专用控制
if(cntIsCtrlDays == '1' && jsCode <= '1') {
if(yqDays == '0' && zqDays == '0' && yjDays == '0') {
Store.messager.err('系统控制:账期天数、延期对账天数、月结天数必须填写其中之一,请填写!');
return false;
}
}
// 联销合同必须进行合同报价控制
if(jsCode == '2' && isMngJPrice != '1') {
curRow.setColumnValue('IsMngJPrice', '1')
}
if(endDate < currDate) {
Store.messager.err('合同失效日期不能早于今天!');
return false;
}
if(signDate > currDate) {
Store.messager.err('合同签订日期不能晚于今天!');
return false;
}
if(czType == '3') {
curRow.setColumnValue('HtStatus', '1')
if(chgStatus == '0') {
curRow.setColumnValue('ChgStatus', '1');
}else {
curRow.setColumnValue('ChgStatus', '3');
}
curRow.setColumnValue('ChgDate', currDate);
}
var ret = Service.CntChkHtCode(htCode);
if (ret.result != 1) {
Store.messager.tip('验证合同编码失败!' + ret.message);
this.dsMaster.getColumn('HtCode').set('isEditable',true);
return false;
}
if(isZB && this.dsDetailOrg.rows.length < 1) {
Store.messager.tip('请录入使用组织!');
return false;
}
if(jsCode == '2' || jsCode == '3') {
if(TypeUtil.toString(this.dsDetailBd.currentRow.BdDate) == '') {
Store.messager.tip('请录入'+$('#detail-tab').find("span.tabs-title.tabs-with-icon:eq(4)")[0].innerHTML);
return false;
}
if(TypeUtil.toFloat(this.dsDetailBd.currentRow.BdTotal) <= 0 && TypeUtil.toFloat(this.dsDetailBd.currentRow.TcRate) <= 0) {
if(jsCode == '2') {
if(cntBdShowYS == '1') {
if (!Store.confirm("您确认合同预算销售额和提成比率都为0吗?")) {
return false;
}
}else {
if (!Store.confirm("您确认合同保底额和提成比率都为0吗?")) {
return false;
}
}
}else {
if(leaseJsCode != '4') {
if (!Store.confirm("您确认合同租金金额为0吗?")) {
return false;
}
}
}
}
if(TypeUtil.toFloat(this.dsDetailBd.currentRow.BdTotal) > 0 && TypeUtil.toFloat(this.dsDetailBd.currentRow.BdMonths) <= 0) {
if(jsCode == '2') {
if(cntBdShowYS == '1') {
Store.messager.tip('合同有预算销售额时预算销售月数必须大于0!');
return false;
}else {
Store.messager.tip('合同有保底额时保底月数必须大于0!');
return false;
}
}else {
Store.messager.tip('合同有租金金额时租赁月数必须大于0!');
return false;
}
}
if(jsCode == '2') {
if(TypeUtil.toString(this.dsDetailBd.currentRow.JsCode) != '0') {
this.dsDetailBd.currentRow.setColumnValue('JsCode', '0');
}
}else {
if(TypeUtil.toString(this.dsDetailBd.currentRow.JsCode) != '1') {
this.dsDetailBd.currentRow.setColumnValue('JsCode', '1');
}
}
if(TypeUtil.toString(this.dsDetailBd.currentRow.IsBdEveryMonth) == '1') {
if(!this.ChkCntBdDetail()) {
return false;
}
}
if(jsCode == '2') {
// 检查特殊提成比例商品
if(!this.ChkCntSkuTcRate(False)) {
return false;
}
// 检查联销结算期
if(this.dsDetailJsPeriod.rows.length > 0) {
if(!this.ChkCntLxTcJsPeriod(False)) {
return false;
}
}
// 检查联销提成比例
if(TypeUtil.toString(this.dsDetailBd.currentRow.IsEncourage) == '1') {
if(!this.ChkCntLxTcRate(False)) {
return false;
}
}
}
if(jsCode == '3') {
// 检查联销提成比例
if(TypeUtil.toString(this.dsDetailBd.currentRow.IsEncourage) == '1') {
if(!this.ChkCntLxTcRate(False)) {
return false;
}
}
}
if(!this.ChkCntLxTc(False)) {
return false;
}
}
// 如果自动生成合同名称,则给合同名称赋值
if(TypeUtil.toString(curRow.HtCode) == '') {
var jsName = '';
if(jsCode == '0') {
jsName = '经销';
}else if(jsCode == '1') {
jsName = '代销';
}else if(jsCode == '2') {
jsName = '联销';
}else if(jsCode == '3') {
jsName = '租赁';
}
var etpName = TypeUtil.toString(curRow.EtpName);
if(etpName.length > 46) {
etpName = etpName.substring(0, 46);
}
curRow.setColumnValue('HtName',etpName+jsName+'合同');
}
if(this.dsDetailStore.rows.length < 1) {
if (!Store.confirm("尚未设置合同的收货仓库,是否继续保存?")) {
return false;
}
}
if(jsCode == '3' && leaseJsCode != 4) {
var ret = Service.LeaseCntShpStatus(cntId, shpCode, orgCode, '0');
if (ret.result != 1) {
Store.messager.tip('修改租赁店铺状态失败!' + ret.message);
return false;
}
}
if(shpCode == '') {
curRow.setColumnValue('ShpCode', '*')
}
if(shpName == '') {
curRow.setColumnValue('ShpName', '*')
}
return this.super('beforeSave');
};
/**
* 保存后操作,保存成功调用
* @return {[type]} [description]
*/
Biz.prototype.afterSave = function () {
var self = this;
var curRow = this.dsMaster.currentRow;
var bgnDate = TypeUtil.toString(curRow['StartDate']);
var htStatus = TypeUtil.toString(curRow['HtStatus']);
var currDate = new Date(rhtComm.GetServerDateTime(0)).format('yyyy-MM-dd');
if(htStatus == '0' && bgnDate <= currDate && sysIsForeignCheck != '1') {
Store.messager.confirm("合同有效期已经开始,立即执行合同吗?",
function (isOK) {
if(isOK) {
// 执行
self.opRouter('act');
}
}
);
}
return this.super('afterSave');
};
//明细行单行提交触发的校验
Biz.prototype.dataRowValidate = function (dataSrc, dr) {
if (dataSrc.uiObjCode === this.dsDetailBdMx.uiObjCode) {
var month = TypeUtil.toFloat(dr['Month']);
if(month < 10) {
dr.setColumnValue("Month", '0' + month);
}
}
return true;
};
/**
* @description 数据发生变化时调用
* @param dataSrc 数据集
* @param dr 数据行
* @param dc 数据列
*/
Biz.prototype.fieldChanged = function (dataSrc, dr, dc) {
var self = this;
if (dataSrc.uiObjCode === this.dsMaster.uiObjCode) {
var currentRow = self.dsMaster.currentRow;
if (currentRow === null) return false;
switch (dc.fieldName) {
case 'IsMngCls':
this.fieldChangedIsMngCls(dataSrc, dr, dc);
break;
case 'IsMngBrand':
this.fieldChangedIsMngBrand(dataSrc, dr, dc);
break;
case 'JsCode':
this.fieldChangedJsCode(dataSrc, dr, dc);
break;
case 'EtpCode':
this.fieldChangedEtpCode(dataSrc, dr, dc);
break;
case 'IsDefault':
this.fieldChangedIsDefault(dataSrc, dr, dc);
break;
case 'SdDscRate':
this.fieldChangedSdDscRate(dataSrc, dr, dc);
break;
case 'XsTotal':
this.fieldChangedXsTotal(dataSrc, dr, dc);
break;
case 'PdTotal':
this.fieldChangedPdTotal(dataSrc, dr, dc);
break;
case 'ZqDays':
this.fieldChangedZqDays(dataSrc, dr, dc);
break;
case 'YqDays':
this.fieldChangedYqDays(dataSrc, dr, dc);
break;
case 'YjDays':
this.fieldChangedYjDays(dataSrc, dr, dc);
break;
case 'IsMngJPrice':
this.fieldChangedIsMngJPrice(dataSrc, dr, dc);
break;
case 'LeaseJsCode':
this.fieldChangedLeaseJsCode(dataSrc, dr, dc);
this.fieldChangedJsCode(dataSrc, dr, dc);
break;
case 'YkRate':
this.fieldChangedYkRate(dataSrc, dr, dc);
break;
case 'StartDate':
this.fieldChangedStartDate(dataSrc, dr, dc);
break;
case 'EndDate':
this.fieldChangedStartDate(dataSrc, dr, dc);
break;
case 'HtCode':
this.fieldChangedHtCode(dataSrc, dr, dc);
break;
}
}else if (dataSrc.uiObjCode === this.dsDetailBd.uiObjCode) {
var currentRow = self.dsDetailBd.currentRow;
if (currentRow === null) return false;
switch (dc.fieldName) {
case 'BdTotal':
this.fieldChangedBdTotal(dataSrc, dr, dc);
break;
case 'BdMonths':
this.fieldChangedBdMonths(dataSrc, dr, dc);
break;
case 'IsBdEveryMonth':
this.fieldChangedIsBdEveryMonth(dataSrc, dr, dc);
break;
case 'IsEncourage':
this.fieldChangedIsEncourage(dataSrc, dr, dc);
break;
}
}else if (dataSrc.uiObjCode === this.dsDetailLxTc.uiObjCode) {
var currentRow = self.dsDetailLxTc.currentRow;
if (currentRow === null) return false;
switch (dc.fieldName) {
case 'TcRate':
this.fieldChangedTcRate(dataSrc, dr, dc);
break;
case 'MinTotal':
this.fieldChangedMinTotal(dataSrc, dr, dc);
break;
case 'MaxTotal':
this.fieldChangedMaxTotal(dataSrc, dr, dc);
break;
}
}else if (dataSrc.uiObjCode === this.dsDetailBdMx.uiObjCode) {
var currentRow = self.dsDetailBdMx.currentRow;
var currentBdRow = self.dsDetailBd.currentRow;
if (currentRow === null || currentBdRow === null) return false;
if(TypeUtil.toString(currentBdRow.BdDate) == '') {
dr.setColumnError('MinTotal', '请先录入保底设置(联租设置)信息!');
}
switch (dc.fieldName) {
case 'BdTotal':
this.fieldChangedBdMxTotal(dataSrc, dr, dc);
break;
case 'Year':
this.fieldChangedYear(dataSrc, dr, dc);
break;
case 'Month':
this.fieldChangedMonth(dataSrc, dr, dc);
break;
}
}else if (dataSrc.uiObjCode === this.dsDteailTcRateSku.uiObjCode) {
var currentRow = self.dsDteailTcRateSku.currentRow;
var currentBdRow = self.dsDetailBd.currentRow;
if (currentRow === null || currentBdRow === null) return false;
if(TypeUtil.toString(currentBdRow.BdDate) == '') {
if(cntBdShowYS == '1') {
dr.setColumnError('OrgCode', '请先录入预算销售额设置信息!');
}else {
dr.setColumnError('OrgCode', '请先录入保底设置信息!');
}
}
switch (dc.fieldName) {
case 'OrgCode':
this.fieldChangedTcRateSkuOrgCode(dataSrc, dr, dc);
break;
case 'PluCode':
this.fieldChangedTcRateSkuPluCode(dataSrc, dr, dc);
break;
case 'TcRate':
this.fieldChangedTcRateSkuTcRate(dataSrc, dr, dc);
break;
}
}else if (dataSrc.uiObjCode === this.dsDetailPlu.uiObjCode) {
var currentRow = self.dsDetailPlu.currentRow;
if (currentRow === null) return false;
switch (dc.fieldName) {
case 'PluCode':
this.fieldChangedPluCode(dataSrc, dr, dc);
break;
case 'HJPrice':
this.fieldChangedHJPrice(dataSrc, dr, dc);
break;
case 'WJPrice':
this.fieldChangedWJPrice(dataSrc, dr, dc);
break;
}
}else if (dataSrc.uiObjCode === this.dsDetailJsPeriod.uiObjCode) {
var currentRow = self.dsDetailJsPeriod.currentRow;
if (currentRow === null) return false;
this.fieldChangedJsPeriod(dataSrc, dr, dc);
}else if (dataSrc.uiObjCode === this.dsDetailRentRateMx.uiObjCode) {
var currentRow = self.dsDetailRentRateMx.currentRow;
if (currentRow === null) return false;
switch (dc.fieldName) {
case 'RentAmount':
this.fieldChangedRentRateMxRentAmount(dataSrc, dr, dc);
break;
case 'BgnDate':
this.fieldChangedRentRateMxBgnDate(dataSrc, dr, dc);
break;
case 'EndDate':
this.fieldChangedWRentRateMxEndDate(dataSrc, dr, dc);
break;
}
}
return this.super('fieldChanged');
};
// 字段变化执行事件
Biz.prototype.fieldChangedIsMngCls = function (dataSrc, dr, dc) {
if(dr.IsMngCls === '0') {
$('#detail-tab').children().first().tabs('disableTab', 2);
}else if(dr.IsMngCls === '1') {
$('#detail-tab').children().first().tabs('enableTab', 2);
}
return true;
};
Biz.prototype.fieldChangedIsMngBrand = function (dataSrc, dr, dc) {
if(dr.IsMngBrand === '0') {
$('#detail-tab').children().first().tabs('disableTab', 3);
}else if(dr.IsMngBrand === '1') {
$('#detail-tab').children().first().tabs('enableTab', 3);
}
return true;
};
Biz.prototype.fieldChangedJsCode = function (dataSrc, dr, dc) {
var masterAdapter = this.view.vm['ep_dsMaster'];
// var detailStoreAdapter = this.view.vm['ep_dsDetailBd'];
// detailStoreAdapter.setEditorEditable(false);
// detailStoreAdapter.setValue("3");
var jsCode = dr.JsCode;
if(czType == '3') {
if(jsCode != '' && jsCode != '2' && jsCode != '3') {
dr.setColumnError('JsCode', '只能选择联销和租金结算!');
dr.setColumnValue('JsCode', preJsCode);
return false;
}
}
if(preJsCode <= '1' && jsCode == '2') {
if(this.dsDetailPlu.rows.length !== 0) {
if (!Store.confirm("切换结算方式将删除合同商品, 您确认要继续吗?")) {
dr.setColumnValue('JsCode', preJsCode);
return false;
}
}
}
if(preJsCode != '3' && jsCode == '3') {
if(this.dsDetailStore.rows.length !== 0) {
if (!Store.confirm("切换结算方式为租金结算将删除合同收货仓库, 您确认要继续吗?")) {
dr.setColumnValue('JsCode', preJsCode);
return false;
}
}
dr.setColumnValue('JsPeriod', '0');
}
if(jsCode == '2' || jsCode == '3') {
$('#detail-tab').children().first().tabs('enableTab', 4);
if(jsCode == '2') {
$($($($('#detail-tab').children().first().children()[1]).children()[4]).find(".editorWrapper")[0]).removeAttr("style");
$($($($('#detail-tab').children().first().children()[1]).children()[4]).find(".editorWrapper")[1]).removeAttr("style");
$($($($('#detail-tab').children().first().children()[1]).children()[4]).find(".editorWrapper")[2]).removeAttr("style");
$($($($('#detail-tab').children().first().children()[1]).children()[4]).find(".editorWrapper")[3]).removeAttr("style");
$($($($('#detail-tab').children().first().children()[1]).children()[4]).find(".editorWrapper")[4]).removeAttr("style");
$($($($('#detail-tab').children().first().children()[1]).children()[4]).find(".editorWrapper")[5]).removeAttr("style");
$($($($('#detail-tab').children().first().children()[1]).children()[4]).find(".editorWrapper")[6]).removeAttr("style");
$($($($('#detail-tab').children().first().children()[1]).children()[4]).find(".editorWrapper")[7]).removeAttr("style");
$($($($('#detail-tab').children().first().children()[1]).children()[4]).find(".editorWrapper")[8]).attr("style","display:none;");
$($($($('#detail-tab').children().first().children()[1]).children()[4]).find(".editorWrapper")[9]).attr("style","display:none;");
$($($($('#detail-tab').children().first().children()[1]).children()[4]).find(".editorWrapper")[10]).removeAttr("style");
$($($($('#detail-tab').children().first().children()[1]).children()[4]).find(".editorWrapper")[11]).removeAttr("style");
$($($($('#detail-tab').children().first().children()[1]).children()[4]).find(".editorWrapper")[12]).attr("style","display:none;");
$($($($('#detail-tab').children().first().children()[1]).children()[4]).find(".editorWrapper")[6]).find(".easyui-tooltip").html('保底额:');
$($($($('#detail-tab').children().first().children()[1]).children()[4]).find(".editorWrapper")[7]).find(".easyui-tooltip").html('保底月数:');
$($($($('#detail-tab').children().first().children()[1]).children()[4]).find(".editorWrapper")[11]).find(".easyui-tooltip").html('保底明细到月');
document.getElementById("bdDesc").innerHTML='联租设置
'+
'当联销保底合同的使用组织属于多个财务组织时,保底金额指每个财务组织的保底额。如果存在保底差异,则均分到财务组织所属的各个业务组织中。
'+
'通常情况下,不足月时预算销售额按整月进行处理;如果不足月时预算销售额不按整月进行处理,则需要设置该月的预算销售额明细。
'+
'结算对账时,优先使用合同中设置的预算销售额明细,如果该结算期间没有设置预算销售额明细,则取 预算销售额/预算销售月数
'+
'作为该月的预算销售额。';
}
if(jsCode == '3') {
$($($($('#detail-tab').children().first().children()[1]).children()[4]).find(".editorWrapper")[0]).removeAttr("style");
$($($($('#detail-tab').children().first().children()[1]).children()[4]).find(".editorWrapper")[1]).attr("style","display:none;");
$($($($('#detail-tab').children().first().children()[1]).children()[4]).find(".editorWrapper")[2]).attr("style","display:none;");
$($($($('#detail-tab').children().first().children()[1]).children()[4]).find(".editorWrapper")[3]).attr("style","display:none;");
$($($($('#detail-tab').children().first().children()[1]).children()[4]).find(".editorWrapper")[4]).attr("style","display:none;");
$($($($('#detail-tab').children().first().children()[1]).children()[4]).find(".editorWrapper")[5]).attr("style","display:none;");
$($($($('#detail-tab').children().first().children()[1]).children()[4]).find(".editorWrapper")[6]).removeAttr("style");
$($($($('#detail-tab').children().first().children()[1]).children()[4]).find(".editorWrapper")[7]).removeAttr("style");
$($($($('#detail-tab').children().first().children()[1]).children()[4]).find(".editorWrapper")[8]).attr("style","display:none;");
$($($($('#detail-tab').children().first().children()[1]).children()[4]).find(".editorWrapper")[9]).attr("style","display:none;");
$($($($('#detail-tab').children().first().children()[1]).children()[4]).find(".editorWrapper")[10]).attr("style","display:none;");
$($($($('#detail-tab').children().first().children()[1]).children()[4]).find(".editorWrapper")[11]).removeAttr("style");
$($($($('#detail-tab').children().first().children()[1]).children()[4]).find(".editorWrapper")[12]).removeAttr("style");
$($($($('#detail-tab').children().first().children()[1]).children()[4]).find(".editorWrapper")[6]).find(".easyui-tooltip").html('租金金额:');
$($($($('#detail-tab').children().first().children()[1]).children()[4]).find(".editorWrapper")[7]).find(".easyui-tooltip").html('租赁月数:');
$($($($('#detail-tab').children().first().children()[1]).children()[4]).find(".editorWrapper")[11]).find(".easyui-tooltip").html('租金明细到月');
document.getElementById("bdDesc").innerHTML='保底设置
'+
'通常情况下,不足月时保底按整月进行处理;如果不足月时保底不按整月进行处理,则需要设置该月的保底明细。
'+
'结算对账时,优先使用合同中设置的保底明细,如果该结算期间没有设置保底明细,则取 保底额/保底月数 作为该月的保底额。';
}
}else {
$('#detail-tab').children().first().tabs('disableTab', 4);
}
if(jsCode == '2') {
$('#detail-tab').children().first().tabs('enableTab', 9);
}else {
$('#detail-tab').children().first().tabs('disableTab', 9);
}
$('#detail-tab').children().first().tabs('disableTab', 5);
$('#detail-tab').children().first().tabs('disableTab', 8);
$('#detail-tab').children().first().tabs('disableTab', 10);
this.ChangeJsModeBtn();
if(cntJsCodeJyModeYz == '1') {
dr.setColumnValue('JyMode', jsCode);
}
if(!fInit) {
if(jsCode == '0' || jsCode == '1') {
masterAdapter.setEditorEditable('ZqDays', true);
masterAdapter.setEditorEditable('YqDays', true);
masterAdapter.setEditorEditable('SdDscRate', true);
masterAdapter.setEditorEditable('IsMngJPrice', true);
masterAdapter.setEditorEditable('YjDays', true);
masterAdapter.setEditorEditable('JsPeriod', true);
dr.setColumnValue('IsMngJPrice', '1');
dr.setColumnValue('LeaseJsCode', '9');
if(jsCode == '0') {
masterAdapter.setEditorEditable('YkRate', true);
}else {
masterAdapter.setEditorEditable('YkRate', false);
dr.setColumnValue('YkRate', '0');
}
}else {
dr.setColumnValue('ZqDays', '0');
dr.setColumnValue('YqDays', '0');
dr.setColumnValue('SdDscRate', '0');
dr.setColumnValue('IsMngJPrice', '1');
if(jsCode == '2') {
masterAdapter.setEditorEditable('ZqDays', true);
masterAdapter.setEditorEditable('JsPeriod', true);
dr.setColumnValue('LeaseJsCode', '9');
}else {
masterAdapter.setEditorEditable('ZqDays', false);
dr.setColumnValue('JsPeriod', '0');
if(orgType == '1001' || cntIsUseNewLease == '0') {
dr.setColumnValue('LeaseJsCode', '4');
}
masterAdapter.setEditorEditable('JsPeriod', false);
}
masterAdapter.setEditorEditable('YqDays', false);
masterAdapter.setEditorEditable('SdDscRate', false);
masterAdapter.setEditorEditable('IsMngJPrice', false);
masterAdapter.setEditorEditable('YjDays', false);
masterAdapter.setEditorEditable('YkRate', false);
dr.setColumnValue('YkRate', '0');
}
}
// if(jsCode == '2' || jsCode == '3') {
// $($($($('#detail-tab').children().first().children()[1]).children()[4]).find(".editorWrapper")[0]).find(".textbox-text").attr("value","2020-02-02");
// $($($($('#detail-tab').children().first().children()[1]).children()[4]).find(".editorWrapper")[0]).find(".textbox-value").attr("value","2020-02-02");
// }
if(!fInit) {
this.USetCntLxTc(0, 0);
}
if(jsCode == '2') {
if(cntBdShowYS == '1') {
$('#detail-tab').find("span.tabs-title.tabs-with-icon:eq(4)").html("联租设置");
$('#detail-tab').find("span.tabs-title.tabs-with-icon:eq(5)").html("联租设置明细");
$($($($('#detail-tab').children().first().children()[1]).children()[4]).find(".editorWrapper")[11]).find(".easyui-tooltip").html('预算销售额明细到月');
document.getElementById("bdDesc").innerHTML= '通常情况下,不足月时预算销售额按整月进行处理;如果不足月时预算销售额不按整月进行处理,则需要设置该月的预算销售额明细。
'+
'结算对账时,优先使用合同中设置的预算销售额明细,如果该结算期间没有设置预算销售额明细,则取 预算销售额/预算销售月数
'+
'作为该月的预算销售额。';
}else {
$('#detail-tab').find("span.tabs-title.tabs-with-icon:eq(4)").html("保底设置");
$('#detail-tab').find("span.tabs-title.tabs-with-icon:eq(5)").html("保底明细");
$($($($('#detail-tab').children().first().children()[1]).children()[4]).find(".editorWrapper")[11]).find(".easyui-tooltip").html('保底明细到月');
document.getElementById("bdDesc").innerHTML= '通常情况下,不足月时保底按整月进行处理;如果不足月时保底不按整月进行处理,则需要设置该月的保底明细。
'+
'结算对账时,优先使用合同中设置的保底明细,如果该结算期间没有设置保底明细,则取 保底额/保底月数 作为该月的保底额。';
}
}
// 删除商品列表
if(jsCode == '0' || jsCode == '1') {
if(preJsCode != '0' && preJsCode != '1') {
if(this.dsDetailPlu.rows.length > 0) {
this.dsDetailPlu.deleteAll();
}
}
}else {
if(preJsCode != '2' && preJsCode != '3') {
this.dsDetailPlu.deleteAll();
}
}
// 设置收货仓库页是否显示
if(jsCode != '3' && cntIsCtrlCntStore == '1') {
$('#detail-tab').children().first().tabs('enableTab', 11);
}else {
$('#detail-tab').children().first().tabs('disableTab', 11);
}
preJsCode = jsCode;
return true;
};
Biz.prototype.fieldChangedEtpCode = function (dataSrc, dr, dc) {
var res= Service.CntChkDefaultHt('', dr.EtpCode, '');
if (res.result !== 1) {
dr.setColumnError('EtpCode', '查询供应商默认合同失败!' + res.message);
return false;
}else {
if(res.data.isinuse == 1) {
dr.setColumnValue('IsDefault', '0');
}else {
dr.setColumnValue('IsDefault', '1');
}
}
return true;
};
Biz.prototype.fieldChangedIsDefault = function (dataSrc, dr, dc) {
var res= Service.CntChkDefaultHt(dr.CntID, dr.EtpCode, '');
if(dr.IsDefault == '1') {
if (res.result !== 1) {
dr.setColumnError('IsDefault', '查询供应商默认合同失败!' + res.message);
return false;
}else {
if(res.data.isinuse == 1) {
dr.setColumnError('IsDefault', '已存在此供应商的默认合同!');
return false;
}
}
}
return true;
};
Biz.prototype.fieldChangedSdDscRate = function (dataSrc, dr, dc) {
var sdDscRate = TypeUtil.toFloat(dr.SdDscRate);
if(sdDscRate < 0 || sdDscRate > 100) {
dr.setColumnError('SdDscRate', '首单折扣率必须满足条件大于等于0小于100!');
return false;
}
return true;
};
Biz.prototype.fieldChangedXsTotal = function (dataSrc, dr, dc) {
var xsTotal = TypeUtil.toFloat(dr.XsTotal);
if(xsTotal < 0 || xsTotal > 99999999999999) {
dr.setColumnError('XsTotal', '金额必须在0-99999999999999之间!');
return false;
}
return true;
};
Biz.prototype.fieldChangedPdTotal = function (dataSrc, dr, dc) {
var pdTotal = TypeUtil.toFloat(dr.PdTotal);
if(pdTotal < 0 || pdTotal > 99999999999999) {
dr.setColumnError('XsTotal', '金额必须在0-99999999999999之间!');
return false;
}
return true;
};
Biz.prototype.fieldChangedZqDays = function (dataSrc, dr, dc) {
return true;
};
Biz.prototype.fieldChangedYqDays = function (dataSrc, dr, dc) {
var masterAdapter = this.view.vm['ep_dsMaster'];
var yqDays = TypeUtil.toFloat(dr.YqDays);
var jsCode = TypeUtil.toFloat(dr.JsCode);
if(yqDays == '' || yqDays == '0') {
masterAdapter.setEditorEditable('YjDays', true);
}else {
masterAdapter.setEditorEditable('YjDays', false);
dr.setColumnValue('JsPeriod', '0');
}
if((yqDays == '' || yqDays == '0') && jsCode != '3') {
masterAdapter.setEditorEditable('JsPeriod', true);
}else {
masterAdapter.setEditorEditable('JsPeriod', false);
}
return true;
};
Biz.prototype.fieldChangedYjDays = function (dataSrc, dr, dc) {
var masterAdapter = this.view.vm['ep_dsMaster'];
var yjDays = TypeUtil.toFloat(dr.YjDays);
var jsCode = TypeUtil.toFloat(dr.JsCode);
if(yjDays == '' || yjDays == '0') {
masterAdapter.setEditorEditable('YqDays', true);
}else {
masterAdapter.setEditorEditable('YqDays', false);
dr.setColumnValue('JsPeriod', '0');
}
if((yjDays == '' || yjDays == '0') && jsCode != '3') {
masterAdapter.setEditorEditable('JsPeriod', true);
}else {
masterAdapter.setEditorEditable('JsPeriod', false);
}
return true;
};
Biz.prototype.fieldChangedIsMngJPrice = function (dataSrc, dr, dc) {
var masterAdapter = this.view.vm['ep_dsMaster'];
var isMngJPrice = TypeUtil.toFloat(dr.IsMngJPrice);
if(isMngJPrice == '0') {
masterAdapter.setEditorEditable('IsMngCls', false);
masterAdapter.setEditorEditable('IsMngBrand', false);
}else {
masterAdapter.setEditorEditable('IsMngCls', true);
masterAdapter.setEditorEditable('IsMngBrand', true);
}
return true;
};
Biz.prototype.fieldChangedLeaseJsCode = function (dataSrc, dr, dc) {
var leaseJsCode = TypeUtil.toFloat(dr.LeaseJsCode);
var jsCode = TypeUtil.toFloat(dr.JsCode);
if(leaseJsCode != '4' && orgType == '1001' && jsCode == '3') {
dr.setColumnError('LeaseJsCode', '总部只允许录入租金计算方式为4的租赁合同!');
}
return true;
};
Biz.prototype.fieldChangedYkRate = function (dataSrc, dr, dc) {
var ykRate = TypeUtil.toFloat(dr.YkRate);
if(ykRate < 0 || ykRate > 100) {
dr.setColumnError('SdDscRate', '压款比例必须在0~100之间!');
return false;
}
return true;
};
Biz.prototype.fieldChangedStartDate = function (dataSrc, dr, dc) {
var startDate = TypeUtil.toString(dr.StartDate);
var endDate = TypeUtil.toString(dr.EndDate);
if(startDate != '' && endDate != '') {
if(endDate < startDate) {
dr.setColumnError('SdDscRate', '生效日期不能大于失效日期!');
return false;
}
}
return true;
};
Biz.prototype.fieldChangedHtCode = function (dataSrc, dr, dc) {
var htCode = TypeUtil.toString(dr.HtCode);
var pattern = /[+ -''*|=,{};]/;
if(pattern.test(htCode)) {
dr.setColumnError('HtCode', '合同号不能包含+ -\'\'*|=,{};等非法字符!');
return false;
}
return true;
};
Biz.prototype.fieldChangedBdTotal = function (dataSrc, dr, dc) {
var jsCode = this.dsMaster.currentRow.JsCode;
var detailBdAdapter = this.view.vm['ep_dsDetailBd'];
var bdTotal = TypeUtil.toFloat(dr.BdTotal);
if(jsCode == '3' && dr.BdTotal == '') {
dr.setColumnError('BdTotal', '属性"租金金额"的值不能为空!');
return false;
}
if(dr.BdTotal != '') {
if(bdTotal < 0 || bdTotal > 99999999999999) {
dr.setColumnError('BdTotal', '输入金额必须在0-99999999999999之间!');
return false;
}
}
if(bdTotal > 0) {
detailBdAdapter.setEditorEditable('IsBdEveryMonth', true);
}else {
detailBdAdapter.setEditorEditable('IsBdEveryMonth', false);
}
this.USetCntLxTc(bdTotal, 0);
};
Biz.prototype.fieldChangedTcRate = function (dataSrc, dr, dc) {
var tcRate = TypeUtil.toFloat(dr.TcRate);
if(tcRate < 0 || tcRate > 100) {
dr.setColumnError('TcRate', '提成比率必须在0-100之间!');
return false;
}
};
Biz.prototype.fieldChangedMinTotal = function (dataSrc, dr, dc) {
var minTotal = TypeUtil.toFloat(dr.MinTotal);
var maxTotal = TypeUtil.toFloat(dr.MaxTotal);
if(minTotal < 0 || minTotal > 99999999999999) {
dr.setColumnError('MinTotal', '输入金额必须在0-99999999999999之间!');
return false;
}
if(minTotal > maxTotal) {
dr.setColumnError('MinTotal', '金额下限应小于金额上限!');
}
};
Biz.prototype.fieldChangedMaxTotal = function (dataSrc, dr, dc) {
var minTotal = TypeUtil.toFloat(dr.MinTotal);
var maxTotal = TypeUtil.toFloat(dr.MaxTotal);
if(maxTotal < 0 || maxTotal > 99999999999999) {
dr.setColumnError('MaxTotal', '输入金额必须在0-99999999999999之间!');
return false;
}
if(minTotal > maxTotal) {
dr.setColumnError('MaxTotal', '金额上限应大于金额下限!');
return false;
}
};
Biz.prototype.fieldChangedBdMonths = function (dataSrc, dr, dc) {
var bdMonths = TypeUtil.toFloat(dr.BdMonths);
this.USetCntLxTc(0, bdMonths);
};
Biz.prototype.fieldChangedIsBdEveryMonth = function (dataSrc, dr, dc) {
var isBdEveryMonth = TypeUtil.toString(dr.IsBdEveryMonth);
if(isBdEveryMonth == '0' && this.dsDetailLxTc.rows.length > 0) {
if(cntBdShowYS == '1') {
dr.setColumnError('IsBdEveryMonth', '已经录入预算额明细,请先删除!');
}else {
dr.setColumnError('IsBdEveryMonth', '已经录入保底明细,请先删除!');
}
return false;
}
this.USetCntLxTc(0, 0);
if(isBdEveryMonth == '1') {
$('#detail-tab').children().first().tabs('enableTab', 5);
}else {
$('#detail-tab').children().first().tabs('disableTab', 5);
}
};
Biz.prototype.fieldChangedIsEncourage = function (dataSrc, dr, dc) {
var isEncourage = TypeUtil.toString(dr.IsEncourage);
if(isEncourage == '0' && this.dsDetailLxTc.rows.length > 0) {
dr.setColumnError('IsEncourage', '已经录入鼓励政策,请先删除!');
return false;
}
this.USetCntLxTc(0, 0);
if(isEncourage == '1') {
$('#detail-tab').children().first().tabs('enableTab', 8);
}else {
$('#detail-tab').children().first().tabs('disableTab', 8);
}
};
Biz.prototype.fieldChangedBdMxTotal = function (dataSrc, dr, dc) {
var bdMxTotal = TypeUtil.toFloat(dr.BdTotal);
if(bdMxTotal < 0 || bdMxTotal > 99999999999999) {
dr.setColumnError('MaxTotal', '输入金额必须在0-99999999999999之间!');
return false;
}
};
Biz.prototype.fieldChangedYear = function (dataSrc, dr, dc) {
var year = TypeUtil.toString(dr.Year);
var pattern = /[1-9][0-9]{3}/;
if(!pattern.test(year)) {
dr.setColumnError('Year', '年份输入非法!');
return false;
}
};
Biz.prototype.fieldChangedMonth = function (dataSrc, dr, dc) {
var month = TypeUtil.toString(dr.Month);
var pattern = /^0?[1-9]$|^1[0-2]$/;
if(!pattern.test(month)) {
dr.setColumnError('Month', '月份输入非法!');
return false;
}
};
Biz.prototype.fieldChangedTcRateSkuOrgCode = function (dataSrc, dr, dc) {
var orgCode = TypeUtil.toString(dr.OrgCode);
var bdOrgCode = TypeUtil.toString(this.dsDetailBd.currentRow.OrgCode)
if(orgCode != bdOrgCode) {
if(cntBdShowYS == '1') {
dr.setColumnError('OrgCode', '没有设置'+orgCode+'组织的预算销售额设置,不能录入特殊提成比率商品!');
}else {
dr.setColumnError('OrgCode', '没有设置'+orgCode+'组织的保底设置,不能录入特殊提成比率商品!');
}
return false;
}
};
Biz.prototype.fieldChangedTcRateSkuPluCode = function (dataSrc, dr, dc) {
if(this.dsDetailPlu.rows.length < 1) {
dr.setColumnError('PluCode', '请首先录入合同商品,再录入特殊提成比率商品!');
return false;
}
};
Biz.prototype.fieldChangedTcRateSkuTcRate = function (dataSrc, dr, dc) {
var tcRate = TypeUtil.toFloat(dr.TcRate);
if(tcRate < 0 || tcRate > 100) {
dr.setColumnError('TcRate', '提成比例必须在0-100之间!');
return false;
}
};
Biz.prototype.fieldChangedPluCode = function (dataSrc, dr, dc) {
var masterRow = this.dsMaster.currentRow;
var pluCode = TypeUtil.toFloat(dr.PluCode);
var isCtlCls = TypeUtil.toString(masterRow.IsMngCls);
var isCtlBrand = TypeUtil.toString(masterRow.IsMngBrand);
var rJTaxRate = TypeUtil.toString(dr.R_JTaxRate);
var jsCode = TypeUtil.toString(masterRow.JsCode);
//dr.setColumnValue("JTaxRate", rJTaxRate);
if(pluCode == '') {
return true;
}
// 查询商品的售价和最高含税进价
var resSku = Service.SkuGetPluExPropInfo('', pluCode, Store.logOn.orgCode, 'Price,MaxHJPrice');
if (resSku.result != 1) {
dr.setColumnError('PluCode', '查询售价/最高含税进价失败!' + resSku.message);
return false;
}
if(jsCode == '0' || jsCode == '1') {
res = Service.CheckPluIsKc(pluCode);
if (res.result != 1) {
dr.setColumnError('PluCode', '验证商品库存属性失败!' + res.message);
return false;
}
}
dr.setColumnValue("Price", resSku.data.price);
dr.setColumnValue("MinPrice", resSku.data.maxhjprice);
if(isCtlCls != '1' && isCtlBrand != '1') {
return true;
}
if(isCtlCls == '1') {
var cntId = TypeUtil.toString(masterRow.CntID);
var signDepCode = TypeUtil.toString(masterRow.SignDepCode);
var isMngCls = TypeUtil.toString(masterRow.IsMngCls);
var clsId = '0';
if(this.dsDetailCls.rows.length < 1) {
dr.setColumnError('PluCode', '合同设置了管理品类,但未录入任何品类,请录入品类信息或取消管理品类选项');
return false;
}
for(var i=0;i 0) {
brandCode += '\',\'';
}
brandCode += TypeUtil.toFloat(row['BrandCode']);
}
var resBrand = Service.ChkCntBrandPlu(pluCode, brandCode);
if (resBrand.result != 1) {
dr.setColumnError('PluCode', '验证商品品牌失败!' + resBrand.message);
return false;
}
}
};
Biz.prototype.fieldChangedHJPrice = function (dataSrc, dr, dc) {
var maxHjPrice = TypeUtil.toFloat(dr.MinPrice);
var hjPrice = TypeUtil.toFloat(dr.HJPrice);
if(maxHjPrice == 0) {
return true;
}
if(hjPrice > maxHjPrice) {
dr.setColumnError('HJPrice', '含税进价不能高于' + maxHjPrice + ',请确认!');
return false;
}
};
Biz.prototype.fieldChangedWJPrice = function (dataSrc, dr, dc) {
var jsType = TypeUtil.toFloat(dr.JTaxCalType);
var taxRate = TypeUtil.toFloat(dr.JTaxRate);
var maxHjPrice = TypeUtil.toFloat(dr.MinPrice);
var wJPrice = TypeUtil.toFloat(dr.WJPrice);
var maxWJPrice = 0;
if(maxHjPrice == 0) {
return true;
}
if(jsType == '0') {
maxWJPrice = maxHjPrice / (1 + taxRate/100);
}else {
maxWJPrice = maxHjPrice * (1 - taxRate/100);
}
if(wJPrice > maxWJPrice) {
dr.setColumnError('HJPrice', '无税进价不能高于' + maxWJPrice + ',请确认!');
return false;
}
};
Biz.prototype.fieldChangedJsPeriod = function (dataSrc, dr, dc) {
if(TypeUtil.toString(dr.IsJs) == '1') {
dr.setColumnError('BgnDate', '此结算期已对账不能修改!');
return false;
}
};
Biz.prototype.fieldChangedRentRateMxRentAmount = function (dataSrc, dr, dc) {
var rentAmount = TypeUtil.toFloat(dr.RentAmount);
if(rentAmount < 0 || rentAmount > 99999999999999) {
dr.setColumnError('RentAmount', '输入金额必须在0-99999999999999之间!');
return false;
}
};
Biz.prototype.fieldChangedRentRateMxBgnDate = function (dataSrc, dr, dc) {
var bgnDate = TypeUtil.toString(dr.BgnDate);
var endDate = TypeUtil.toString(dr.EndDate);
if(bgnDate != '' && endDate != '') {
if(endDate < startDate) {
dr.setColumnError('BgnDate', '起始日期应该小于结束日期!');
return false;
}
}
return true;
};
Biz.prototype.fieldChangedWRentRateMxEndDate = function (dataSrc, dr, dc) {
var bgnDate = TypeUtil.toString(dr.BgnDate);
var endDate = TypeUtil.toString(dr.EndDate);
if(bgnDate != '' && endDate != '') {
if(endDate < startDate) {
dr.setColumnError('EndDate', '起始日期应该小于结束日期!');
return false;
}
}
return true;
};
Biz.prototype.USetCntLxTc = function (pdBdTotal, piBdMonths) {
var bdMonth = 0;
var bdTotal = 0;
if(pdBdTotal <= 0) {
bdTotal = TypeUtil.toFloat($($($($('#detail-tab').children().first().children()[1]).children()[4]).find(".editorWrapper")[6]).find(".textbox-text").val());
}else {
bdTotal = pdBdTotal;
}
if(piBdMonths <= 0) {
bdMonth = TypeUtil.toFloat($($($($('#detail-tab').children().first().children()[1]).children()[4]).find(".editorWrapper")[7]).find(".textbox-text").val());
}else {
bdMonth = piBdMonths;
}
var isEncourage = this.dsDetailBd.currentRow ? this.dsDetailBd.currentRow.IsEncourage : '0';
var isBdEveryMonth = this.dsDetailBd.currentRow ? this.dsDetailBd.currentRow.IsBdEveryMonth : '0';
var jsCode = this.dsMaster.currentRow.JsCode;
if(bdMonth > 0) {
$($($($('#detail-tab').children().first().children()[1]).children()[4]).find(".editorWrapper")[10]).find(".textbox-text").removeAttr("readonly");
$($($($('#detail-tab').children().first().children()[1]).children()[4]).find(".editorWrapper")[10]).find(".textbox-text").removeAttr("disabled");
$($($($($('#detail-tab').children().first().children()[1]).children()[4]).find(".editorWrapper")[10]).find(".textbox-addon").children()[0]).removeClass("textbox-icon-disabled");
}else {
$($($($('#detail-tab').children().first().children()[1]).children()[4]).find(".editorWrapper")[10]).find(".textbox-text").attr("readonly","readonly");
$($($($('#detail-tab').children().first().children()[1]).children()[4]).find(".editorWrapper")[10]).find(".textbox-text").attr("disabled","disabled");
$($($($($('#detail-tab').children().first().children()[1]).children()[4]).find(".editorWrapper")[10]).find(".textbox-addon").children()[0]).addClass("textbox-icon-disabled");
}
if(isEncourage == '1') {
$($($($('#detail-tab').children().first().children()[1]).children()[4]).find(".editorWrapper")[3]).find(".textbox-text").removeAttr("readonly");
$($($($('#detail-tab').children().first().children()[1]).children()[4]).find(".editorWrapper")[3]).find(".textbox-text").removeAttr("disabled");
$($($($($('#detail-tab').children().first().children()[1]).children()[4]).find(".editorWrapper")[3]).find(".textbox-addon").children()[0]).removeClass("textbox-icon-disabled");
$($($($('#detail-tab').children().first().children()[1]).children()[4]).find(".editorWrapper")[4]).find(".textbox-text").removeAttr("readonly");
$($($($('#detail-tab').children().first().children()[1]).children()[4]).find(".editorWrapper")[4]).find(".textbox-text").removeAttr("disabled");
$($($($($('#detail-tab').children().first().children()[1]).children()[4]).find(".editorWrapper")[4]).find(".textbox-addon").children()[0]).removeClass("textbox-icon-disabled");
}else {
$($($($('#detail-tab').children().first().children()[1]).children()[4]).find(".editorWrapper")[3]).find(".textbox-text").attr("readonly","readonly");
$($($($('#detail-tab').children().first().children()[1]).children()[4]).find(".editorWrapper")[3]).find(".textbox-text").attr("disabled","disabled");
$($($($($('#detail-tab').children().first().children()[1]).children()[4]).find(".editorWrapper")[3]).find(".textbox-addon").children()[0]).addClass("textbox-icon-disabled");
$($($($('#detail-tab').children().first().children()[1]).children()[4]).find(".editorWrapper")[4]).find(".textbox-text").attr("readonly","readonly");
$($($($('#detail-tab').children().first().children()[1]).children()[4]).find(".editorWrapper")[4]).find(".textbox-text").attr("disabled","disabled");
$($($($($('#detail-tab').children().first().children()[1]).children()[4]).find(".editorWrapper")[4]).find(".textbox-addon").children()[0]).addClass("textbox-icon-disabled");
}
if(bdTotal > 0) {
$($($($('#detail-tab').children().first().children()[1]).children()[4]).find(".editorWrapper")[11]).find(".textbox-text").removeAttr("disabled");
}else {
$($($($('#detail-tab').children().first().children()[1]).children()[4]).find(".editorWrapper")[11]).find(".editor-checkbox").attr("disabled","disabled");
}
if(isBdEveryMonth == '1') {
$('#detail-tab').children().first().tabs('enableTab', 5);
}else {
$('#detail-tab').children().first().tabs('disableTab', 5);
}
if(jsCode == '2') {
if(cntBdShowYS == '1') {
$('#detail-tab').find("span.tabs-title.tabs-with-icon:eq(5)").html("联租设置明细");
}else {
$('#detail-tab').find("span.tabs-title.tabs-with-icon:eq(5)").html("保底明细");
}
}
if((jsCode == '2' || jsCode == '3') && isEncourage == '1') {
$('#detail-tab').children().first().tabs('enableTab', 8);
}else {
$('#detail-tab').children().first().tabs('disableTab', 8);
}
if((jsCode == '2' || jsCode == '3') && ((bdTotal > 0) || isEncourage == '1')) {
$('#detail-tab').children().first().tabs('enableTab', 10);
}else {
$('#detail-tab').children().first().tabs('disableTab', 10);
}
return true;
};
Biz.prototype.ChangeJsModeBtn = function () {
if(!this.dsMaster.currentRow) {
return true;
}
var masterAdapter = this.view.vm['ep_dsMaster'];
var jsCode = this.dsMaster.currentRow.JsCode;
$('#detail-tab').children().first().tabs('disableTab', 12);
$('#detail-tab').children().first().tabs('disableTab', 14);
if(jsCode == '3' && cntIsUseNewLease == '1' && orgType != '1001') {
masterAdapter.setEditorEditable('CntArea', true);
masterAdapter.setEditorEditable('CashRegMode', true);
masterAdapter.setEditorEditable('WallArea', true);
masterAdapter.setEditorEditable('PillarArea', true);
masterAdapter.setEditorEditable('LeaseJsCode', true);
masterAdapter.setEditorEditable('ShpCode', true);
masterAdapter.setEditorEditable('MakeupDate', true);
this.ChangeLeaseJsCode();
}else {
masterAdapter.setEditorEditable('CntArea', false);
masterAdapter.setEditorEditable('CashRegMode', false);
masterAdapter.setEditorEditable('WallArea', false);
masterAdapter.setEditorEditable('PillarArea', false);
masterAdapter.setEditorEditable('LeaseJsCode', false);
masterAdapter.setEditorEditable('ShpCode', false);
masterAdapter.setEditorEditable('MakeupDate', false);
}
return true;
};
Biz.prototype.ChangeLeaseJsCode = function () {
$('#detail-tab').children().first().tabs('disableTab', 12);
$('#detail-tab').children().first().tabs('disableTab', 14);
var jsCode = this.dsMaster.currentRow.JsCode;
var leaseJsCode = this.dsMaster.currentRow.LeaseJsCode;
var isBdEveryMonth = $($($($('#detail-tab').children().first().children()[1]).children()[4]).find(".editorWrapper")[11]).find(".editor-checkbox").prop('checked');
if(jsCode == '3' && (leaseJsCode == '0' || leaseJsCode == '2' || leaseJsCode == '3')) {
$('#detail-tab').children().first().tabs('enableTab', 12);
}
if(jsCode == '3' && (leaseJsCode == '0' || leaseJsCode == '1' || leaseJsCode == '2' || leaseJsCode == '3')) {
$('#detail-tab').children().first().tabs('enableTab', 14);
}
if((jsCode == '2' || jsCode == '3') && (leaseJsCode == '1' || leaseJsCode == '2' || leaseJsCode == '3' || leaseJsCode == '4')) {
$('#detail-tab').children().first().tabs('enableTab', 4);
}else {
$('#detail-tab').children().first().tabs('enableTab', 4);
}
if((jsCode == '2' || jsCode == '3') && (leaseJsCode == '1' || leaseJsCode == '2' || leaseJsCode == '3' || leaseJsCode == '4') && isBdEveryMonth) {
$('#detail-tab').children().first().tabs('enableTab', 5);
}else {
$('#detail-tab').children().first().tabs('disableTab', 5);
}
if(jsCode == '3' && (leaseJsCode == '0' || leaseJsCode == '1' || leaseJsCode == '2' || leaseJsCode == '3')) {
$('#detail-tab').find("span.tabs-title.tabs-with-icon:eq(4)").html("浮动租金设置");
$('#detail-tab').find("span.tabs-title.tabs-with-icon:eq(5)").html("浮动租金明细");
$($($($('#detail-tab').children().first().children()[1]).children()[4]).find(".editorWrapper")[0]).removeAttr("style");
$($($($('#detail-tab').children().first().children()[1]).children()[4]).find(".editorWrapper")[1]).removeAttr("style");
$($($($('#detail-tab').children().first().children()[1]).children()[4]).find(".editorWrapper")[2]).removeAttr("style");
$($($($('#detail-tab').children().first().children()[1]).children()[4]).find(".editorWrapper")[3]).removeAttr("style");
$($($($('#detail-tab').children().first().children()[1]).children()[4]).find(".editorWrapper")[4]).removeAttr("style");
$($($($('#detail-tab').children().first().children()[1]).children()[4]).find(".editorWrapper")[5]).removeAttr("style");
$($($($('#detail-tab').children().first().children()[1]).children()[4]).find(".editorWrapper")[6]).removeAttr("style");
$($($($('#detail-tab').children().first().children()[1]).children()[4]).find(".editorWrapper")[7]).removeAttr("style");
$($($($('#detail-tab').children().first().children()[1]).children()[4]).find(".editorWrapper")[8]).attr("style","display:none;");
$($($($('#detail-tab').children().first().children()[1]).children()[4]).find(".editorWrapper")[9]).attr("style","display:none;");
$($($($('#detail-tab').children().first().children()[1]).children()[4]).find(".editorWrapper")[10]).removeAttr("style");
$($($($('#detail-tab').children().first().children()[1]).children()[4]).find(".editorWrapper")[11]).removeAttr("style");
$($($($('#detail-tab').children().first().children()[1]).children()[4]).find(".editorWrapper")[12]).attr("style","display:none;");
$($($($('#detail-tab').children().first().children()[1]).children()[4]).find(".editorWrapper")[6]).find(".easyui-tooltip").html('保底额:');
$($($($('#detail-tab').children().first().children()[1]).children()[4]).find(".editorWrapper")[7]).find(".easyui-tooltip").html('保底月数:');
$($($($('#detail-tab').children().first().children()[1]).children()[4]).find(".editorWrapper")[11]).find(".easyui-tooltip").html('保底明细到月');
document.getElementById("bdDesc").innerHTML='联租设置
'+
'当联销保底合同的使用组织属于多个财务组织时,保底金额指每个财务组织的保底额。如果存在保底差异,则均分到财务组织所属的各个业务组织中。
'+
'通常情况下,不足月时预算销售额按整月进行处理;如果不足月时预算销售额不按整月进行处理,则需要设置该月的预算销售额明细。
'+
'结算对账时,优先使用合同中设置的预算销售额明细,如果该结算期间没有设置预算销售额明细,则取 预算销售额/预算销售月数
'+
'作为该月的预算销售额。';
}else if(jsCode == '3' && leaseJsCode == '4') {
$('#detail-tab').find("span.tabs-title.tabs-with-icon:eq(4)").html("租金设置");
$('#detail-tab').find("span.tabs-title.tabs-with-icon:eq(5)").html("租金明细");
$($($($('#detail-tab').children().first().children()[1]).children()[4]).find(".editorWrapper")[0]).removeAttr("style");
$($($($('#detail-tab').children().first().children()[1]).children()[4]).find(".editorWrapper")[1]).attr("style","display:none;");
$($($($('#detail-tab').children().first().children()[1]).children()[4]).find(".editorWrapper")[2]).attr("style","display:none;");
$($($($('#detail-tab').children().first().children()[1]).children()[4]).find(".editorWrapper")[3]).attr("style","display:none;");
$($($($('#detail-tab').children().first().children()[1]).children()[4]).find(".editorWrapper")[4]).attr("style","display:none;");
$($($($('#detail-tab').children().first().children()[1]).children()[4]).find(".editorWrapper")[5]).attr("style","display:none;");
$($($($('#detail-tab').children().first().children()[1]).children()[4]).find(".editorWrapper")[6]).removeAttr("style");
$($($($('#detail-tab').children().first().children()[1]).children()[4]).find(".editorWrapper")[7]).removeAttr("style");
$($($($('#detail-tab').children().first().children()[1]).children()[4]).find(".editorWrapper")[8]).attr("style","display:none;");
$($($($('#detail-tab').children().first().children()[1]).children()[4]).find(".editorWrapper")[9]).attr("style","display:none;");
$($($($('#detail-tab').children().first().children()[1]).children()[4]).find(".editorWrapper")[10]).attr("style","display:none;");
$($($($('#detail-tab').children().first().children()[1]).children()[4]).find(".editorWrapper")[11]).removeAttr("style");
$($($($('#detail-tab').children().first().children()[1]).children()[4]).find(".editorWrapper")[12]).removeAttr("style");
$($($($('#detail-tab').children().first().children()[1]).children()[4]).find(".editorWrapper")[6]).find(".easyui-tooltip").html('租金金额:');
$($($($('#detail-tab').children().first().children()[1]).children()[4]).find(".editorWrapper")[7]).find(".easyui-tooltip").html('租赁月数:');
$($($($('#detail-tab').children().first().children()[1]).children()[4]).find(".editorWrapper")[11]).find(".easyui-tooltip").html('租金明细到月');
document.getElementById("bdDesc").innerHTML='保底设置
'+
'通常情况下,不足月时保底按整月进行处理;如果不足月时保底不按整月进行处理,则需要设置该月的保底明细。
'+
'结算对账时,优先使用合同中设置的保底明细,如果该结算期间没有设置保底明细,则取 保底额/保底月数 作为该月的保底额。';
}
return true;
};
Biz.prototype.ChkCntLxTc = function (onlyChkCurrentRow) {
if(!this.dsDetailBd.currentRow) {
return true;
}
var isEncourage = TypeUtil.toString(this.dsDetailBd.currentRow.IsEncourage);
var isBdEveryMonth = TypeUtil.toString(this.dsDetailBd.currentRow.IsBdEveryMonth);
var bdDate = TypeUtil.toString(this.dsDetailBd.currentRow.BdDate);
var jsCode = TypeUtil.toString(this.dsDetailBd.currentRow.JsCode);
var cntStartDate = TypeUtil.toString(this.dsDetailBd.currentRow.StartDate);
var cntEndDate = TypeUtil.toString(this.dsDetailBd.currentRow.EndDate);
var orgErrMsg = '保底设置';
if(jsCode == '0') {
if(cntBdShowYS == '1') {
orgErrMsg = '预算额设置';
}else {
orgErrMsg = '保底设置';
}
}else {
orgErrMsg = '租金设置';
}
if(bdDate < cntStartDate || bdDate > cntEndDate) {
Store.messager.tip(orgErrMsg + '的起始日期应在合同有效期内!');
return false;
}
if(!onlyChkCurrentRow && isEncourage == '1') {
if(this.dsDetailLxTc.rows.length < 1) {
Store.messager.tip('请录入鼓励政策!');
return false;
}
}
if(!onlyChkCurrentRow && isBdEveryMonth == '1') {
if(this.dsDetailBdMx.rows.length < 1) {
if(cntBdShowYS == '1') {
Store.messager.tip('请录入预算额明细!');
}else {
Store.messager.tip('请录入保底明细!');
}
return false;
}
}
return true;
};
/**
* 删除前询问,通常进行一些删除前校验操作
* 默认操作会提示‘确定删除?’询问
* @return {Boolean,String} 返回操作是否被允许,只有false时,才会不允许执行,其他则作为提示询问用户
*
*/
Biz.prototype.beforeDelete = function () {
var self = this;
var curRow = this.dsMaster.currentRow;
Store.messager.confirm("确定删除当前合同吗?",
function (isOK) {
if(isOK) {
var htStatus = TypeUtil.toString(curRow['HtStatus']);
if(htStatus != '0' && htStatus != '3') {
Store.messager.tip('此合同已有业务发生且未处理完成,不能删除!');
return false;
}
var shpCode = curRow ? TypeUtil.toString(curRow['ShpCode']) : '';
var orgCode = curRow ? TypeUtil.toString(curRow['OrgCode']) : '';
var cntId = curRow ? TypeUtil.toString(curRow['CntID']) : '';
var jsCode = curRow ? TypeUtil.toString(curRow['JsCode']) : '';
var leaseJsCode = curRow ? TypeUtil.toString(curRow['LeaseJsCode']) : '';
// 合同状态维护
var whRes= Service.WhHtStatus(cntId, 'SC', '');
if (whRes.result !== 1) {
Store.messager.tip('维护合同状态失败!' + whRes.message);
return false;
}
// 修改店铺状态
if(jsCode =='3' && leaseJsCode != '4') {
var ret= Service.updateShopStatus(cntId, shpCode, orgCode);
if (ret.result !== 1) {
Store.messager.tip('修改店铺状态失败!');
return false;
}
}
self.opRouter('refresh');
}
}
);
};
//按钮事件控制
Biz.prototype.doOp = function (opCode) {
var self = this;
if (opCode == 'child') {
czType = '4';
}
if (opCode == 'act') {
var ds = self.dsMaster;
this.onAct(self, ds);
}
if (opCode == 'stop') {
var ds = self.dsMaster;
this.onStop(self, ds);
}
if (opCode == 'renew') {
var ds = self.dsMaster;
this.onRenew(self, ds);
}
if (opCode == 'batchrenew') {
var ds = self.dsMaster.getSelectedRows();
this.onBatchRenew(self, ds);
}
if (opCode == 'singlerenew') {
var ds = self.dsMaster;
this.onSglRenew(self, ds);
}
if (opCode == 'forchk') {
var ds = self.dsMaster;
this.onForChk(self, ds);
}
if (opCode == 'protest') {
var ds = self.dsMaster;
this.onProtest(self, ds);
}
};
//按钮事件
Biz.prototype.onAct = function (biz, ds) {
var dsrow=ds.currentRow;
var cntId = dsrow ? TypeUtil.toString(dsrow['CntID']) : '';
var htStatus = dsrow ? TypeUtil.toString(dsrow['HtStatus']) : '';
var oriCntId = dsrow ? TypeUtil.toString(dsrow['OriCntId']) : '';
var foreignChkStatus = dsrow ? TypeUtil.toString(dsrow['ForeignChkStatus']) : '';
if(oriCntId != '0' && oriCntId != cntId) {
dsrow.setColumnError('合同续签样本不能手工执行!');
return false;
}
if(htStatus == '1') {
dsrow.setColumnError('合同已处于执行状态!');
return false;
}
if(htStatus == '3') {
dsrow.setColumnError('合同已终止!');
return false;
}
if(htStatus == '4') {
dsrow.setColumnError('单方续签合同不能执行!');
return false;
}
if(foreignChkStatus != '2' && sysIsForeignCheck == '1') {
dsrow.setColumnError('合同未被审批不能执行!');
return false;
}
if (!Store.confirm("您确定要执行当前合同吗?")) {
return false;
}else {
var currDate = new Date(rhtComm.GetServerDateTime(0)).format('yyyy-MM-dd');
var actRes= Service.WhHtStatus(cntId, 'ZX', currDate);
if (actRes.result !== 1) {
dsrow.setColumnError('CntID','执行失败!' + actRes.message);
return false;
}else {
Store.messager.tip('执行成功!');
biz.dsMaster.updateRow();
var OrgCode = Store.logOn.orgCode;
var UserID = Store.logOn.userId;
var UserCode = Store.logOn.userCode;
var UserName = Store.logOn.userName;
var LogPosition = "采购合同";
var LogContent = "合同编号:" + TypeUtil.toString(dsrow['HtCode']) + "执行";
var Computer = "";
var ComputerInfo = "";
rhtComm.MWriteOprLog(OrgCode,UserID,UserCode,UserName,Computer,ComputerInfo,LogPosition,LogContent);
}
}
return true;
};
Biz.prototype.onStop = function (biz, ds) {
var dsrow=ds.currentRow;
var cntId = dsrow ? TypeUtil.toString(dsrow['CntID']) : '';
var htStatus = dsrow ? TypeUtil.toString(dsrow['HtStatus']) : '';
var oriCntId = dsrow ? TypeUtil.toString(dsrow['OriCntId']) : '';
var foreignChkStatus = dsrow ? TypeUtil.toString(dsrow['ForeignChkStatus']) : '';
if(htStatus == '0') {
dsrow.setColumnError('合同还未执行, 不能终止!');
return false;
}
if(htStatus == '3') {
dsrow.setColumnError('合同已终止!');
return false;
}
if (!Store.confirm("您确定要终止当前合同吗?")) {
return false;
}else {
var currDate = new Date(rhtComm.GetServerDateTime(0)).format('yyyy-MM-dd');
var actRes= Service.WhHtStatus(cntId, 'ZZ', currDate);
if (actRes.result !== 1) {
dsrow.setColumnError('CntID','终止失败!' + actRes.message);
return false;
}else {
Store.messager.tip('终止成功!');
biz.dsMaster.updateRow();
}
}
return true;
};
Biz.prototype.onSglRenew = function (biz, ds) {
sglRenew = new SglRenew(ds.currentRow);
sglRenew.callback = function () {
biz.dsMaster.updateRow();
}
sglRenew.open();
return true;
};
Biz.prototype.onForChk = function (biz, ds) {
var dsrow=ds.currentRow;
var cntId = dsrow ? TypeUtil.toString(dsrow['CntID']) : '';
var htStatus = dsrow ? TypeUtil.toString(dsrow['HtStatus']) : '';
var oriCntId = dsrow ? TypeUtil.toString(dsrow['OriCntId']) : '';
var foreignChkStatus = dsrow ? TypeUtil.toString(dsrow['ForeignChkStatus']) : '';
if(oriCntId != '0' && oriCntId != cntId) {
dsrow.setColumnError('合同续签样本不能提交审核!');
return false;
}
if(htStatus == '1') {
dsrow.setColumnError('合同已处于执行状态!');
return false;
}
if(htStatus == '3') {
dsrow.setColumnError('合同已终止!');
return false;
}
if(htStatus == '4') {
dsrow.setColumnError('单方续签合同不能提交审核!');
return false;
}
if(foreignChkStatus == '1') {
dsrow.setColumnError('合同已经在审批中,请勿重复提交!');
return false;
}
if(foreignChkStatus == '2') {
dsrow.setColumnError('合同已经审批通过,不需要再次审批!');
return false;
}
if (!Store.confirm("您确认要将选中合同提交审核吗?")) {
return false;
}else {
var ret= Service.CntForChk(cntId);
if (ret.result !== 1) {
Store.messager.tip('提交审核失败!' + ret.message);
return false;
}else {
Store.messager.tip('提交审核成功!');
biz.dsMaster.updateRow();
var OrgCode = Store.logOn.orgCode;
var UserID = Store.logOn.userId;
var UserCode = Store.logOn.userCode;
var UserName = Store.logOn.userName;
var LogPosition = "采购合同";
var LogContent = "合同编号:" + TypeUtil.toString(dsrow['HtCode']) + "提交审核";
var Computer = "";
var ComputerInfo = "";
rhtComm.MWriteOprLog(OrgCode,UserID,UserCode,UserName,Computer,ComputerInfo,LogPosition,LogContent);
}
}
return true;
};
Biz.prototype.onRenew = function (biz, ds) {
var self = this;
self.opRouter('edit');
//$($("#master-editpanel").find(".editorWrapper").children()[0]).find(".textbox-text").attr("style","display:none");
czType = 3;
return true;
};
Biz.prototype.onProtest = function (biz, ds) {
var dsrow=ds.currentRow;
var cntId = dsrow ? TypeUtil.toString(dsrow['CntID']) : '';
var isProtest = dsrow ? TypeUtil.toString(dsrow['IsProtest']) : '';
isProtest = isProtest == '0' ? '1' : '0';
if (!Store.confirm("您确认要更改拒付状态吗?")) {
return false;
}else {
var ret= Service.CntPortest(cntId, isProtest);
if (ret.result !== 1) {
Store.messager.tip('更改拒付状态失败!' + ret.message);
return false;
}else {
Store.messager.tip('更改拒付状态成功!');
biz.dsMaster.updateRow();
var OrgCode = Store.logOn.orgCode;
var UserID = Store.logOn.userId;
var UserCode = Store.logOn.userCode;
var UserName = Store.logOn.userName;
var LogPosition = "采购合同";
var LogContent = "合同编号:" + TypeUtil.toString(dsrow['HtCode']) + "更改拒付状态";
var Computer = "";
var ComputerInfo = "";
rhtComm.MWriteOprLog(OrgCode,UserID,UserCode,UserName,Computer,ComputerInfo,LogPosition,LogContent);
}
}
return true;
};
Biz.prototype.onBatchRenew = function (biz, ds) {
var self = this;
if(ds.length < 1) {
Store.messager.err('请至少选择一条数据!');
return false;
}
var isvalid = true;
var msg = '';
var htList = '[';
for(var i = 0; i < ds.length; i++) {
row = ds[i];
if(row.OrgCode != Store.logOn.orgCode) {
msg = '不能批量续签非当前组织的合同!';
isvalid = false;
break;
}
if(row.HtStatus == '0') {
msg = '未执行的合同不能续签!';
isvalid = false;
break;
}
if(row.HtType != '0') {
msg = '只能续签类型为0-供货合同的合同!';
isvalid = false;
break;
}
if(row.IsActive != '1') {
msg = '选中的合同包括不可用合同,请检查!';
isvalid = false;
break;
}
var isExtend = '0';
var cntId = TypeUtil.toString(row.CntID);
var chgStatus = TypeUtil.toString(row.ChgStatus);
chgStatus = chgStatus == '0' ? '1' :'3';
var oldEndDate = TypeUtil.toString(row.EndDate);
if(i > 0) {
htList += ',';
}
htList += '{"cntid":"' + cntId + '", "chgstatus":"' + chgStatus + '", "oldenddate":"' + oldEndDate + '"}'
}
htList += ']';
if(isvalid) {
var isExtend = '0';
if (Store.confirm("需要将与合同原结束日期一致的扣款项目延长至失效日期吗?")) {
isExtend = '1';
}
// 输入新的结束日期
batchRenewDate = new BatchRenewDate(ds.currentRow);
batchRenewDate.callback = function (date) {
if(date == '') {
return false;
}
var ret= Service.CntBatchRenew(htList, date, isExtend);
if (ret.result !== 1) {
Store.messager.tip('批量续签失败!' + ret.message);
return false;
}else {
Store.messager.tip('批量续签成功!' + ret.message);
var OrgCode = Store.logOn.orgCode;
var UserID = Store.logOn.userId;
var UserCode = Store.logOn.userCode;
var UserName = Store.logOn.userName;
var LogPosition = "采购合同";
var LogContent = "批量续签";
var Computer = "";
var ComputerInfo = "";
rhtComm.MWriteOprLog(OrgCode,UserID,UserCode,UserName,Computer,ComputerInfo,LogPosition,LogContent);
// 刷新当前页面
self.opRouter('refresh');
return true;
}
}
batchRenewDate.open();
}else {
Store.messager.err(msg);
}
return true;
};
Biz.prototype.AutoGenHtCode = function (biz, ds) {
if(codeWasteWidth <= '0' || codeWasteWidth >= '9') {
Store.messager.tip('选项(合同编码流水部分位数)设置的流水号范围应该在1-9之间,请重新设置!');
return false;
}
var etpCode = TypeUtil.toString(this.dsMaster.currentRow.EtpCode);
var signDepCode = TypeUtil.toString(this.dsMaster.currentRow.SignDepCode);
if(etpCode == '') {
Store.messager.tip('请填写供应商!');
return false;
}
if(autoCntCode == '2' && signDepCode == '') {
Store.messager.tip('设置了合同编码自动生成,请填写签订部门,或修改选项设置!');
return false;
}
var preCode = '';
if(autoCntCode == '1') {
preCode = etpCode;
}else if(autoCntCode == '2') {
preCode = etpCode + signDepCode;
}
if((preCode + codeWasteWidth).length > 10) {
if(autoCntCode == '1') {
Store.messager.tip('选项(合同编码流水部分位数)设置的流水号范围+供应商编码长度超过十位,请手工录入合同编码或更改选项设置!');
}else if(autoCntCode == '2') {
Store.messager.tip('选项(合同编码流水部分位数)设置的流水号范围+签订部门编码+供应商编码长度超过十位,请手工录入合同编码或更改选项设置!');
}
this.dsMaster.getColumn('HtCode').set('isEditable',true);
return false;
}
var ret = Service.AutoGenHtCode(preCode, autoCntCode, codeWasteWidth);
if (ret.result != 1) {
Store.messager.tip('获取合同号失败!' + ret.message);
this.dsMaster.getColumn('HtCode').set('isEditable',true);
return false;
}
var newHtCode = ret.data;
this.dsMaster.currentRow.setColumnValue('HtCode', newHtCode);
return true;
};
Biz.prototype.ChkCntBdDetail = function () {
if(this.dsDetailBdMx.rows.length < 1) {
return true;
}
var cntStartDate = TypeUtil.toString(this.dsMaster.currentRow.StartDate);
var cntEndDate = TypeUtil.toString(this.dsMaster.currentRow.EndDate);
var minMonth = cntStartDate.split('-')[0] + '-' + cntStartDate.split('-')[1];
var maxMonth = cntEndDate.split('-')[0] + '-' + cntEndDate.split('-')[1];
for(var i = 0; i < this.dsDetailBdMx.rows.length; i++) {
var month = this.dsDetailBdMx.rows[i].Year + '-' + this.dsDetailBdMx.rows[i].Month;
if(month < minMonth || month > maxMonth) {
Store.messager.err($('#detail-tab').find("span.tabs-title.tabs-with-icon:eq(5)")[0].innerHTML+'年月不在合同有效期内!');
return false;
}
}
return true;
};
Biz.prototype.ChkCntSkuTcRate = function (onlyChkCurrentRow) {
if(this.dsDteailTcRateSku.rows.length < 1) {
return true;
}
if(this.dsDetailPlu.rows.length < 1) {
Store.messager.err('没有设置合同商品,不能设置特殊提成比率商品!');
return false;
}
if(onlyChkCurrentRow) {
var pluId = TypeUtil.toString(this.dsDteailTcRateSku.currentRow.PluID);
for(var i = 0; i < this.dsDetailPlu.rows.length; i++) {
if(pluId == TypeUtil.toString(this.dsDetailPlu.rows[i].PluID)) {
return true;
}
}
var pluCode = TypeUtil.toString(this.dsDteailTcRateSku.currentRow.PluCode);
var pluName = TypeUtil.toString(this.dsDteailTcRateSku.currentRow.PluName);
Store.messager.err('特殊提成比率商品' + pluCode + '-' + pluName + '不是合同商品,不能设置!');
return false;
}else {
for(var i = 0; i < this.dsDteailTcRateSku.rows.length; i++) {
var isHtPlu = false;
var pluId = TypeUtil.toString(this.dsDteailTcRateSku.rows[i].PluID);
for(var i = 0; i < this.dsDetailPlu.rows.length; i++) {
if(pluId == TypeUtil.toString(this.dsDetailPlu.rows[i].PluID)) {
isHtPlu = true;
}
}
if(!isHtPlu) {
var pluCode = TypeUtil.toString(this.dsDteailTcRateSku.rows[i].PluCode);
var pluName = TypeUtil.toString(this.dsDteailTcRateSku.rows[i].PluName);
Store.messager.err('特殊提成比率商品' + pluCode + '-' + pluName + '不是合同商品,不能设置!');
return false;
}
}
return true;
}
};
Biz.prototype.ChkCntLxTcJsPeriod = function (onlyChkCurrentRow) {
if(this.dsDetailJsPeriod.rows.length < 1) {
return true;
}
var cntStartDate = TypeUtil.toString(this.dsMaster.currentRow.StartDate);
var cntEndDate = TypeUtil.toString(this.dsMaster.currentRow.EndDate);
var bdDate = TypeUtil.toString(this.dsDetailBd.currentRow.BdDate);
if(bdDate == '') {
bdDate = cntStartDate;
}
if(onlyChkCurrentRow) {
if(!this.ChkJsPeriodInput(cntStartDate, cntEndDate, this.dsDetailJsPeriod.currentRow)) {
return false;
}
}else {
var minStartDate = TypeUtil.toString(this.dsDetailJsPeriod.rows[0].BgnDate);
for(var i = 1; i < this.dsDetailJsPeriod.rows.length; i++) {
var bgnDate = TypeUtil.toString(this.dsDetailJsPeriod.rows[i].BgnDate);
if(minStartDate > bgnDate) {
minStartDate = bgnDate;
}
if(!this.ChkJsPeriodInput(cntStartDate, cntEndDate, this.dsDetailJsPeriod.rows[i])) {
return false;
}
}
if(minStartDate != bdDate) {
if(cntBdShowYS == '1') {
Store.messager.err('结算期最小开始日期' + minStartDate + '应该与预算销售开始日期' + bdDate + '一致!');
return false;
}else {
Store.messager.err('结算期最小开始日期' + minStartDate + '应该与保底开始日期' + bdDate + '一致!');
return false;
}
}
this.dsDetailJsPeriod.rows.sort(this.SortJsPeriod);
var rowBgnDate;
var rowEndDate;
var nextDate = '';
for(var i = 0; i < this.dsDetailJsPeriod.rows.length; i++) {
if(TypeUtil.toString(this.dsDetailJsPeriod.rows[i].PeriodType) == '1') {
continue;
}
rowBgnDate = TypeUtil.toString(this.dsDetailJsPeriod.rows[i].BgnDate);
rowEndDate = TypeUtil.toString(this.dsDetailJsPeriod.rows[i].EndDate);
if(nextDate != '' && nextDate != rowBgnDate) {
Store.messager.err('结算期' + TypeUtil.toString(this.dsDetailJsPeriod.rows[i].PeriodCode) + '日期不连续');
return false;
}
nextDate = rhtComm.DateChangeDays(1, rowEndDate);
}
// 判断多月通算期是否符合要求
for(var i = 0; i < this.dsDetailJsPeriod.rows.length; i++) {
if(TypeUtil.toString(this.dsDetailJsPeriod.rows[i].PeriodType) != '1') {
continue;
}
rowBgnDate = TypeUtil.toString(this.dsDetailJsPeriod.rows[i].BgnDate);
rowEndDate = TypeUtil.toString(this.dsDetailJsPeriod.rows[i].EndDate);
var isBgnDateValid = false;
var isEndDateValid = false;
for(var j = 0; j < this.dsDetailJsPeriod.rows.length; j++) {
if(TypeUtil.toString(this.dsDetailJsPeriod.rows[j].PeriodType) == '1') {
continue;
}
if(TypeUtil.toString(this.dsDetailJsPeriod.rows[j].BgnDate) == rowBgnDate) {
isBgnDateValid = true;
break;
}
}
if(!isBgnDateValid) {
Store.messager.err('结算期' + TypeUtil.toString(this.dsDetailJsPeriod.rows[i].PeriodCode) + '开始日期输入错误(多月结算期的开始日期应该是某个子结算期的开始日期)');
return false;
}
for(var j = 0; j < this.dsDetailJsPeriod.rows.length; j++) {
if(TypeUtil.toString(this.dsDetailJsPeriod.rows[j].PeriodType) == '1') {
continue;
}
if(TypeUtil.toString(this.dsDetailJsPeriod.rows[j].EndDate) == rowEndDate) {
isEndDateValid = true;
break;
}
}
if(!isEndDateValid) {
Store.messager.err('结算期' + TypeUtil.toString(this.dsDetailJsPeriod.rows[i].PeriodCode) + '结束日期输入错误(多月结算期的结束日期应该是某个子结算期的结束日期)');
return false;
}
}
}
return true;
};
Biz.prototype.SortJsPeriod = function (a, b) {
return a.BgnDate - b.BgnDate;
};
Biz.prototype.ChkJsPeriodInput = function (cntStartDate, cntEndDate, jsPeriodRow) {
var jsBgnDate = TypeUtil.toString(jsPeriodRow.BgnDate);
var jsEndDate = TypeUtil.toString(jsPeriodRow.EndDate);
var bdTotal = TypeUtil.toFloat(jsPeriodRow.BdTotal);
var mulBdCalcuType = TypeUtil.toString(jsPeriodRow.MulBdCalcuType);
var periodType = TypeUtil.toString(jsPeriodRow.PeriodType);
var isBdTs = TypeUtil.toString(jsPeriodRow.IsBdTs);
var isChild = TypeUtil.toString(jsPeriodRow.IsChild);
if(jsBgnDate > jsEndDate) {
Store.messager.err('联销结算期结束日期必须大于等于开始日期!');
return false;
}
if(jsBgnDate < cntStartDate || jsBgnDate > cntEndDate) {
Store.messager.err('联销结算期的开始日期应在合同有效期内!');
return false;
}
if(jsEndDate < cntStartDate || jsEndDate > cntEndDate) {
Store.messager.err('联销结算期的结束日期应在合同有效期内!');
return false;
}
if(bdTotal > 0 && mulBdCalcuType == '0' && periodType == '1' && isBdEveryMonth == '0') {
Store.messager.err('多月通算期必须进行保底通算。');
return false;
}
if(periodType == '0' && isBdTs == '1' && isChild == '0') {
Store.messager.err('非子结算期的整月结算期不需要进行保底通算。');
return false;
}
};
Biz.prototype.ChkCntLxTcRate = function (onlyChkCurrentRow) {
if(this.dsDetailLxTc.rows.length < 1) {
return true;
}
// 根据金额下限升序排序
this.dsDetailLxTc.rows.sort(this.SortLxTcRate);
if(onlyChkCurrentRow) {
}else {
if(TypeUtil.toFloat(this.dsDetailLxTc.rows[0].MinTotal) != 0) {
Store.messager.err('最低金额下限必须为0!');
return false;
}
var thisMaxTotal;
var nextMinTotal;
for(var i = 0; i < this.dsDetailJsPeriod.rows.length-1; i++) {
thisMaxTotal = TypeUtil.toFloat(this.dsDetailJsPeriod.rows[i].MaxTotal);
nextMinTotal = TypeUtil.toFloat(this.dsDetailJsPeriod.rows[i+1].MinTotal);
if(thisMaxTotal > nextMinTotal) {
Store.messager.err('鼓励政策金额区间重复');
return false;
}
}
for(var i = 0; i < this.dsDetailJsPeriod.rows.length-1; i++) {
thisMaxTotal = TypeUtil.toFloat(this.dsDetailJsPeriod.rows[i].MaxTotal);
nextMinTotal = TypeUtil.toFloat(this.dsDetailJsPeriod.rows[i+1].MinTotal);
if(thisMaxTotal != nextMinTotal) {
Store.messager.err('鼓励政策的金额区间不连续!');
return false;
}
}
if(TypeUtil.toFloat(this.dsDetailLxTc.rows[this.dsDetailLxTc.rows.length-1].MaxTotal) != 0) {
Store.messager.err('最高金额上限必须设置为0,金额上限为0代表上限不做限制。');
return false;
}
}
return true;
};
Biz.prototype.SortLxTcRate = function (a, b) {
return a.MinTotal - b.MinTotal;
};
return Biz;
});