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.

451 lines
18 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('./cnt070206service');
/**
* 定义业务类对象
* @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.isForeignCheck = rhtComm.getRhtOptionValue(Store.logOn.orgCode,'SYS','Sys_IsForeignCheck','0');
this.ctrlCntOrgDepRight = rhtComm.getRhtOptionValue("",'CNT','CtrlCntOrgDepRight','0');
if(this.orgType >= '1003' && this.orgType <= '1999') {
this.dsMaster.getColumn('UsOrgCode').set('isEditable',false);
}
if(this.orgType == '1001' || this.orgType == '1002') {
this.dsMaster.getColumn('UsOrgCode').set('isEditable',false);
}
};
//拼装查询条件
Biz.prototype.beforeDataSrcSearch = function (dataSrc, params) {
let self = this;
self.setServerBiz('cn.qdhezheng.rht.app.cnt.cnt070206.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 == 'acc') {
// 入账
if (!curRow)
return false;
if (orgCode != Store.logOn.orgCode)
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(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 'Months':
this.fieldChangedMonths(dataSrc, dr, dc);
break;
case 'JsBase':
this.fieldChangedJsBase(dataSrc, dr, dc);
break;
case 'CalMode':
this.fieldChangedCalMode(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 'HtCode':
this.fieldChangedHtCode(dataSrc, dr, dc);
break;
}
}
return this.super('fieldChanged');
};
Biz.prototype.fieldChangedMonths = function (dataSrc, dr, dc) {
let months = TypeUtil.toString(dr['Months']);
let pattern = /^([1-9][0-9]{3})(0[1-9]|1[0-2])$/;
if(!pattern.test(months) && months != '*') {
dr.setColumnError('Months', '请正确的输入月份格式YYYYMM例如202012');
dataSrc.currentRow.setColumnValue('Months','');
return false;
}
if(months != '*') {
let year = months.substring(0, 4);
let month = months.substring(4, 6);
let ret = Service.GetAccMonth(year, month);
if (ret.result != 1) {
dr.setColumnError('Months', '获取会计月失败!' + ret.message);
dataSrc.currentRow.setColumnValue('Months','');
return false;
}
dataSrc.currentRow.setColumnValue('BgnDate',TypeUtil.toString(ret.data.bgndate));
dataSrc.currentRow.setColumnValue('EndDate',TypeUtil.toString(ret.data.enddate));
}
return true;
};
Biz.prototype.fieldChangedJsBase = function (dataSrc, dr, dc) {
let jsBase = TypeUtil.toString(dr['JsBase']);
let masterAdapter = this.view.vm['ep_dsMaster'];
if(jsBase == '00') {
masterAdapter.setEditorEditable('TkTotal', true);
masterAdapter.setEditorEditable('KxRate', false);
masterAdapter.setEditorEditable('ZfCode', false);
masterAdapter.setEditorEditable('ClsCode', false);
masterAdapter.setEditorEditable('BrandCode', false);
masterAdapter.setEditorEditable('PluCode', false);
masterAdapter.setEditorEditable('FormulaId', false);
}else if(jsBase == '12' || jsBase == '25') {
masterAdapter.setEditorEditable('TkTotal', false);
masterAdapter.setEditorEditable('KxRate', true);
masterAdapter.setEditorEditable('ZfCode', false);
masterAdapter.setEditorEditable('ClsCode', false);
masterAdapter.setEditorEditable('BrandCode', false);
masterAdapter.setEditorEditable('PluCode', true);
masterAdapter.setEditorEditable('FormulaId', false);
}else if(jsBase == '26') {
masterAdapter.setEditorEditable('TkTotal', false);
masterAdapter.setEditorEditable('KxRate', true);
masterAdapter.setEditorEditable('ZfCode', false);
masterAdapter.setEditorEditable('ClsCode', false);
masterAdapter.setEditorEditable('BrandCode', false);
masterAdapter.setEditorEditable('PluCode', true);
masterAdapter.setEditorEditable('FormulaId', false);
}else if(jsBase == '24') {
masterAdapter.setEditorEditable('TkTotal', false);
masterAdapter.setEditorEditable('KxRate', true);
masterAdapter.setEditorEditable('ZfCode', true);
masterAdapter.setEditorEditable('ClsCode', false);
masterAdapter.setEditorEditable('BrandCode', false);
masterAdapter.setEditorEditable('PluCode', false);
masterAdapter.setEditorEditable('FormulaId', false);
}else if(jsBase == '60') {
masterAdapter.setEditorEditable('TkTotal', false);
masterAdapter.setEditorEditable('KxRate', false);
masterAdapter.setEditorEditable('ZfCode', false);
masterAdapter.setEditorEditable('ClsCode', false);
masterAdapter.setEditorEditable('BrandCode', false);
masterAdapter.setEditorEditable('PluCode', false);
masterAdapter.setEditorEditable('FormulaId', false);
}else if(jsBase == '71' || jsBase == '72') {
masterAdapter.setEditorEditable('TkTotal', false);
masterAdapter.setEditorEditable('KxRate', true);
masterAdapter.setEditorEditable('ZfCode', false);
masterAdapter.setEditorEditable('ClsCode', true);
masterAdapter.setEditorEditable('BrandCode', true);
masterAdapter.setEditorEditable('PluCode', false);
masterAdapter.setEditorEditable('FormulaId', false);
}else if(jsBase == '74') {
masterAdapter.setEditorEditable('TkTotal', false);
masterAdapter.setEditorEditable('KxRate', true);
masterAdapter.setEditorEditable('ZfCode', false);
masterAdapter.setEditorEditable('ClsCode', false);
masterAdapter.setEditorEditable('BrandCode', false);
masterAdapter.setEditorEditable('PluCode', false);
masterAdapter.setEditorEditable('FormulaId', true);
}else {
masterAdapter.setEditorEditable('TkTotal', false);
masterAdapter.setEditorEditable('KxRate', true);
masterAdapter.setEditorEditable('ZfCode', false);
masterAdapter.setEditorEditable('ClsCode', false);
masterAdapter.setEditorEditable('BrandCode', false);
masterAdapter.setEditorEditable('PluCode', false);
masterAdapter.setEditorEditable('FormulaId', false);
}
return true;
};
Biz.prototype.fieldChangedCalMode = function (dataSrc, dr, dc) {
let calMode = TypeUtil.toString(dr['CalMode']);
let masterAdapter = this.view.vm['ep_dsMaster'];
if(calMode == '0') {
masterAdapter.setEditorEditable('CalBgnDate', false);
masterAdapter.setEditorEditable('CalEndDate', false);
}else {
masterAdapter.setEditorEditable('CalBgnDate', true);
masterAdapter.setEditorEditable('CalEndDate', true);
}
return true;
};
Biz.prototype.fieldChangedHtCode = function (dataSrc, dr, dc) {
let htCode = TypeUtil.toString(dr.HtCode);
let ret = Service.GetCntInfo(htCode);
if (ret.result != 1) {
dr.setColumnError('HtCode','加载合同信息失败!' + ret.message);
return false;
}
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('UsOrgCode', TypeUtil.toString(this.dsMaster.currentRow['UsOrgCode']));
dr.setColumnValue('UsOrgName', TypeUtil.toString(this.dsMaster.currentRow['UsOrgName']));
dr.setColumnValue('ItemNo', TypeUtil.toString(this.dsMaster.currentRow['ItemNo']));
dr.setColumnValue('Months', TypeUtil.toString(this.dsMaster.currentRow['Months']));
dr.setColumnValue('BgnDate', TypeUtil.toString(this.dsMaster.currentRow['BgnDate']));
dr.setColumnValue('EndDate', TypeUtil.toString(this.dsMaster.currentRow['EndDate']));
dr.setColumnValue('IsCalMl', TypeUtil.toString(this.dsMaster.currentRow['IsCalMl']));
dr.setColumnValue('IsInvoice', TypeUtil.toString(this.dsMaster.currentRow['IsInvoice']));
dr.setColumnValue('IsSr', TypeUtil.toString(this.dsMaster.currentRow['IsSr']));
dr.setColumnValue('ItemCode', TypeUtil.toString(this.dsMaster.currentRow['ItemCode']));
dr.setColumnValue('ZfCode', TypeUtil.toString(this.dsMaster.currentRow['ZfCode']));
dr.setColumnValue('BrandCode', TypeUtil.toString(this.dsMaster.currentRow['BrandCode']));
dr.setColumnValue('FormulaId', TypeUtil.toString(this.dsMaster.currentRow['FormulaId']));
dr.setColumnValue('CalBgnDate', TypeUtil.toString(this.dsMaster.currentRow['CalBgnDate']));
dr.setColumnValue('CalEndDate', TypeUtil.toString(this.dsMaster.currentRow['CalEndDate']));
let zfType = TypeUtil.toString(this.dsMaster.currentRow['ZfType']);
if(zfType != '') {
dr.setColumnValue('ZfType', zfType);
}
let tkType = TypeUtil.toString(this.dsMaster.currentRow['TkType']);
if(tkType != '') {
dr.setColumnValue('TkType', tkType);
}
let czType = TypeUtil.toString(this.dsMaster.currentRow['CzType']);
if(czType != '') {
dr.setColumnValue('CzType', czType);
}
let cgyId = TypeUtil.toString(this.dsMaster.currentRow['CgyId']);
if(cgyId != '') {
dr.setColumnValue('CgyId', cgyId);
}
let cgyCode = TypeUtil.toString(this.dsMaster.currentRow['CgyCode']);
if(cgyCode != '') {
dr.setColumnValue('CgyCode', cgyCode);
}
let cgyName = TypeUtil.toString(this.dsMaster.currentRow['CgyName']);
if(cgyName != '') {
dr.setColumnValue('CgyName', cgyName);
}
let gsOrgCode = TypeUtil.toString(this.dsMaster.currentRow['GsOrgCode']);
if(gsOrgCode != '') {
dr.setColumnValue('GsOrgCode', gsOrgCode);
}
let gsOrgName = TypeUtil.toString(this.dsMaster.currentRow['GsOrgName']);
if(gsOrgName != '') {
dr.setColumnValue('GsOrgName', gsOrgName);
}
let jsBase = TypeUtil.toString(this.dsMaster.currentRow['JsBase']);
if(jsBase != '') {
dr.setColumnText('JsBase', jsBase);
}else {
dr.setColumnText('JsBase', '00');
}
let clType = TypeUtil.toString(this.dsMaster.currentRow['ClType']);
if(clType != '') {
dr.setColumnValue('ClType', clType);
}else {
dr.setColumnValue('ClType', '0');
}
let clsCode = TypeUtil.toString(this.dsMaster.currentRow['ClsCode']);
if(clsCode != '') {
dr.setColumnValue('ClsCode', clsCode);
}
let pluCode = TypeUtil.toString(this.dsMaster.currentRow['PluCode']);
if(pluCode != '') {
dr.setColumnValue('PluCode', pluCode);
}
let calMode = TypeUtil.toString(this.dsMaster.currentRow['CalMode']);
if(calMode != '') {
dr.setColumnValue('CalMode', calMode);
}else {
dr.setColumnValue('CalMode', '0');
}
let isOutlayRate = TypeUtil.toString(this.dsMaster.currentRow['IsOutlayRate']);
if((czType == '1' || czType == '2') && isOutlayRate == '1') {
let cntId = TypeUtil.toString(dr['CntId']);
let itemCode = TypeUtil.toString(dr['ItemCode']);
let itemNo = TypeUtil.toString(dr['ItemNo']);
let usOrgCode = TypeUtil.toString(dr['UsOrgCode']);
let months = TypeUtil.toString(dr['Months']);
let res= Service.GetOutlayClauseInfo(cntId, itemCode, itemNo, usOrgCode, months);
if (res.result != 1) {
Store.messager.tip('获取合同扣项比率失败!' + res.message);
return false;
}
dr.setColumnValue('KxRate', TypeUtil.toString(res.data.kxrate));
dr.setColumnValue('TkTotal', TypeUtil.toString(res.data.tktotal));
}else {
dr.setColumnValue('KxRate', TypeUtil.toString(this.dsMaster.currentRow['KxRate']));
let tkTotal = TypeUtil.toString(this.dsMaster.currentRow['TkTotal']);
if(tkTotal != '') {
dr.setColumnValue('TkTotal', tkTotal);
}
}
return true;
};
//新增行后处理,默认值已经处理
Biz.prototype.afterNewRow = function (dataSrc, newRow) {
if (dataSrc.uiObjCode === this.dsMaster.uiObjCode) {
//dataSrc.currentRow.setColumnValue('Months', new Date(Store.bizDao.getSysDate()).format('yyyyMM'));
}else if (dataSrc.uiObjCode === this.dsDetail.uiObjCode) {
if(TypeUtil.toString(this.dsMaster.currentRow['ItemCode']) == '') {
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);
}
if(asnMode == '2') {
masterAdapter.setEditorEditable('AsnTotal', true);
}else {
masterAdapter.setEditorEditable('AsnTotal', false);
}
return this.super('afterEdit');
}
//按钮事件控制
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) {
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) {
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;
});