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.

311 lines
12 KiB

This file contains ambiguous Unicode characters!

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

define(function (require, exports, module) {
let BaseBiz = require('apps/rht/base/rhtBiz');
let rhtComm = require('apps/rht/comm/rhtComm');
let SetSysOverItem = require('./SetSysOverItem');
let service = require('./sys010101service');
/**
* 控制按钮的可用
* @param opCode 按钮编码
* @return [description]
*/
function Biz(vm) {
//继承第一步,构造继承
BaseBiz.call(this, vm);
}
//继承第二步,方法继承
inherits(Biz, BaseBiz);
let orgCode=Store.logOn.orgCode;
let userId=Store.logOn.userId;
let userCode=Store.logOn.userCode;
let userName=Store.logOn.userName;
Biz.prototype.beforeDelete = function () {
let masterRow = this.dsMaster.currentRow;
let IsUserSet = TypeUtil.toString(masterRow['IsUserSet']);
if (IsUserSet=="0") {
masterRow.setColumnError("IsUserSet", '系统预置的日结项目不允许删除!');
return false;
}
return this.super('beforeDelete');
}
//当前状态为非浏览状态或者当前行为空时,【设置】按钮不可用
Biz.prototype.getOpEnabled = function (opCode) {
let isOk = this.super('getOpEnabled', opCode);
if (!isOk) {
return false;
}
let self = this;
let curRow = this.dsMaster.currentRow;
if (opCode == 'set') {
if (!curRow)
return false;
if (!this.isBrowser())
return false;
}
return true;
};
Biz.prototype.doOp = function (opCode) {
let self = this;
let setSysOverItem = null;
if (opCode == 'set') {
if (setSysOverItem) {
setSysOverItem.open();
} else {
//setSysOverItem = new SetSysOverItem(self.dsMaster.currentRow);
setSysOverItem = new SetSysOverItem(self.dsMaster);
setSysOverItem.open();
}
}
}
Biz.prototype.beforeEdit = function () {
let masterRow = this.dsMaster.currentRow;
let IsUserSet = TypeUtil.toString(masterRow['IsUserSet']);
if (IsUserSet=="0") {
Store.messager.warn('系统预置的日结项目不允许编辑');
return false;
}
return this.super('beforeEdit');
}
/**
* 增加后操作
* 给默认组织的组织类型赋值
*/
Biz.prototype.afterAdd = function () {
this.super('afterAdd');
let self = this;
let currentRow = self.dsMaster.currentRow;
if (currentRow === null) return false;
//给默认组织的组织类型赋值
let sOrgCode = currentRow["OrgCode"];
let ret = service.getOrgType(sOrgCode);
if(ret.result !== 1)
{
currentRow.setColumnError('OrgCode',ret.messager)
return false;
}
else
{
//当当前登录组织的组织类型不是1001-连锁总部时,组织字段不能编辑;否则允许编辑
currentRow.setColumnText('DutyCode',ret.data)
if(ret.data!== '1001')
{
this.callView('setEditLimit', this.dsMaster, 'OrgCode', false);
}
else
{
this.callView('setEditLimit', this.dsMaster, 'OrgCode', true);
}
}
//如果前置项目为空,则前置汇总项目有效为空,且不可编辑;否则可以编辑
let PreItemCode = TypeUtil.toString(currentRow['PreItemCode']);
if (PreItemCode==="") {
this.callView('setEditLimit', this.dsMaster, 'IsPreEnabled', false);
}
else
{
this.callView('setEditLimit', this.dsMaster, 'IsPreEnabled', true);
}
this.callView('setEditLimit', this.dsMaster, 'OrgCode', true);
this.callView('setEditLimit', this.dsMaster, 'ItemCode', true);
//获取最大序号
let ret = service.getMaxSerialno();
if(ret.result == 1){
currentRow.setColumnText('SerialNo',TypeUtil.toInt(ret.data.SerialNo)+1)
}
};
Biz.prototype.fieldChanged = function (dataSrc, dr, dc) {
let self = this;
let currentRow = self.dsMaster.currentRow;
if (currentRow === null) return false;
if(dataSrc.uiObjCode === '1018'){
//组织改变时,自动带出组织类型
if(dc.fieldName === 'OrgCode'){
let sOrgCode = currentRow["OrgCode"];
if(sOrgCode === ''){
return false;
}
let ret = service.getOrgType(sOrgCode);
if(ret.result !== 1){
currentRow.setColumnError('OrgCode',ret.messager)
return false;
}
else{
currentRow.setColumnText('DutyCode',ret.data)
}
/*//如果组织类型不是1001总部则组织不能编辑
if (TypeUtil.toString(currentRow['DutyCode'])!== '1001')
{
this.callView('setEditLimit', this.dsMaster, 'OrgCode', false);
}
else
{this.callView('setEditLimit', this.dsMaster, 'OrgCode', true);}
*/
//校验组织的业务控制组织是否为当前登录组织
let retOrg = service.checkOrg(Store.logOn.orgCode,sOrgCode);
if (retOrg.result !== 1)
{
currentRow.setColumnError('OrgCode',retOrg.message);
currentRow["OrgCode"] = '';
return false;
}
else
{
//获取当前登录组织的职能如果组织类型不是1001总部则组织不能编辑
ret = service.getOrgType(Store.logOn.orgCode);
if(ret.result !== 1){
currentRow.setColumnError('OrgCode',ret.messager)
return false;
}
else{
if(ret.data!== '1001')
{
this.callView('setEditLimit', this.dsMaster, 'OrgCode', false);
}
else
{
this.callView('setEditLimit', this.dsMaster, 'OrgCode', true);
}
}
}
}
//如果前置项目为空,则前置汇总项目有效为空,且不可编辑;否则可以编辑
if(dc.fieldName === 'PreItemCode'){
let spreItemCode = currentRow["PreItemCode"];
if(spreItemCode === ''){
currentRow.setColumnText('IsPreEnabled',"");
this.callView('setEditLimit', this.dsMaster, 'IsPreEnabled', false);
}
else
{
this.callView('setEditLimit', this.dsMaster, 'IsPreEnabled', true);
}
}
}
};
//编辑控制
//如果PreItemCode为空则IsPreEnabled不允许编辑否则允许编辑
/*Biz.prototype.beforeFieldEdit = function (dataSrc, dr, dc) {
let curRow = dr;
if (!curRow)
return false;
let drMaster = this.dsMaster.currentRow;
let preItemCode = TypeUtil.toString(drMaster['PreItemCode']);
if (preItemCode == "") {
if (dataSrc.uiObjCode == this.dsMaster.uiObjCode) {
switch (dc.fieldName) {
case 'IsPreEnabled':
return false;
}
return true;
}
}
return this.super('beforeFieldEdit', dataSrc, dr, dc);
}*/
/**
* 保存前操作,校验前置项目序号,
* @returns {boolean}
*/
Biz.prototype.beforeSave = function () {
let self = this;
let currentRow = self.dsMaster.currentRow;
if (currentRow === null) return false;
//校验前置项目序号不能大于当前项目序号
let orgCode = currentRow["OrgCode"];
let preItemCode = currentRow["PreItemCode"];
let serialNo=currentRow["SerialNo"];
if (!isEmpty(preItemCode))
{
let retPreItem = service.checkPreItemSerial(orgCode,preItemCode,serialNo);
if (retPreItem.result !== 1)
{
currentRow.setColumnError('PreItemCode',retPreItem.message);
rhtComm.MWriteErrLog(orgCode,userId,userCode,userName,"","","结账汇总列表","保存失败:"+retPreItem.message);
return false;
}
}
//校验查询编码是否非法检查用户自定义的日结项目存储过程在数据库中是否存在如果不存在则报错输入的查询编码非法项目xx未定义
let scriptCode = currentRow["ScriptCode"];
let retScriptCode = service.CheckScriptCode(scriptCode);
if (retScriptCode.result !== 1)
{
currentRow.setColumnError('ScriptCode',retScriptCode.message);
rhtComm.MWriteErrLog(orgCode,userId,userCode,userName,"","","结账汇总列表","保存失败:"+retScriptCode.message);
return false;
}
//校验查询编码在其他项目中是否设置为了不允许重复日结
let itemCode = currentRow["ItemCode"];
if (itemCode!==null)
{
let retScriptCodeReOver = service.checkScriptCodeReOver(scriptCode,itemCode);
if (retScriptCodeReOver.result !== 1)
{
currentRow.setColumnError('ScriptCode',retScriptCodeReOver.message);
rhtComm.MWriteErrLog(orgCode,userId,userCode,userName,"","","结账汇总列表","保存失败:"+retScriptCodeReOver.message);
return false;
}
}
rhtComm.MWriteOprLog(orgCode,userId,userCode,userName,'','','结账汇总列表',"保存成功。");
return this.super('beforeSave');
};
//点击编辑后如果PreItemCode为空则IsPreEnabled不允许编辑否则允许编辑
Biz.prototype.afterEdit= function () {
let masterRow = this.dsMaster.currentRow;
let PreItemCode = TypeUtil.toString(masterRow['PreItemCode']);
if (PreItemCode==="") {
this.callView('setEditLimit', this.dsMaster, 'IsPreEnabled', false);
}
else
{
this.callView('setEditLimit', this.dsMaster, 'IsPreEnabled', true);
}
//4、 点击编辑时,【组织编码】【项目编码】不允许编辑
this.callView('setEditLimit', this.dsMaster, 'OrgCode', false);
this.callView('setEditLimit', this.dsMaster, 'ItemCode', false);
};
return Biz;
});