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.

191 lines
7.0 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 sys010307service = require('./sys010307service');
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.beforeSave = function () {
let dataRow=this.dsMaster.currentRow;
let optionCode=TypeUtil.toString(dataRow["SysOption"]);
let optionValue=TypeUtil.toString(dataRow["OptionValue"]);
rhtComm.MWriteOprLog(orgCode,userId,userCode,userName,"","","设置一般选项","选项"+optionCode+"修改后选项值为"+optionValue);
this.super('beforeSave');
};
Biz.prototype.beforeEdit = function () {
let dataRow=this.dsMaster.currentRow;
let optionCode=TypeUtil.toString(dataRow["SysOption"]);
let optionValue=TypeUtil.toString(dataRow["OptionValue"]);
//合同编码长度
if (optionCode==="HT_CODE_LEN"){
let hasData = sys010307service.ChkHasData("tCntContract");
if (hasData.result!==1) {
rhtComm.MWriteErrLog(orgCode,userId,userCode,userName,"","","设置一般选项",hasData.message);
return false;
}
}
//商品编码长度或商品编码是否按规则产生
if (optionCode==="PLU_CODE_LEN" || optionCode==="IS_RULE"){
let hasData = sys010307service.ChkHasData("tSkuPlu");
if (hasData.result!==1) {
rhtComm.MWriteErrLog(orgCode,userId,userCode,userName,"","","设置一般选项",hasData.message);
return false;
}
}
//门店紧急变价最大时限
if (optionCode==="UrgChgMaxLimit"){
let valueInfo=sys010307service.ChkChgMaxLimit();
if (valueInfo.result!==1){
rhtComm.MWriteErrLog(orgCode,userId,userCode,userName,"","","设置一般选项",valueInfo.message);
return false;
}
}
//允许验收多采购多少
if (optionCode==="Ord_MoreCheckRate"){
let valueInfo=sys010307service.ChkOrdMoreRateCanEdit();
if (valueInfo.result!==1){
rhtComm.MWriteErrLog(orgCode,userId,userCode,userName,"","","设置一般选项",valueInfo.message);
return false;
}
else {
let value=valueInfo.data.optionvalue;
if (value!=="1"){
rhtComm.MWriteErrLog(orgCode,userId,userCode,userName,"","","设置一般选项","关联选项“Ord_IsMoreCheck”采购验收不允许验收量大于采购量因此不允许编辑此选项");
return false;
}
}
}
//应付结算流程
if (optionCode==="QkBill_IsAutoGen"){
let valueInfo=sys010307service.ChkAcpAcc();
if (valueInfo.result!==1){
Store.messager.tip(valueInfo.message);
rhtComm.MWriteErrLog(orgCode,userId,userCode,userName,"","","设置一般选项",valueInfo.message);
return false;
}
}
this.super('beforeEdit');
};
/**
* 列校验,列赋值时调用,发生异常表示校验失败
* @param {DataSource} dataSrc [description]
* @param {DataRow} dr [description]
* @param {DataColumn} dc [description]
* @param {Object} value [description]
* @return {Boolean} [description]
*/
Biz.prototype.dataColumnValidate = function (dataSrc, dr, dc, value) {
let self = this;
//明细表触发
if (dataSrc.uiObjCode === '1001') {
//字段为JhCount且值小于零
if (dc.fieldName === 'OptionValue') {
let sysOption=dr["SysOption"];
//合同编码长度
if (sysOption==="HT_CODE_LEN" && ChkDataLen(value,1,10)===false){
Store.messager.warn("系统允许该选项设置的长度范围为1-10请重新设置。");
return false;
}
//商品编码长度
if (sysOption==="PLU_CODE_LEN" && ChkDataLen(value,1,20)===false){
Store.messager.warn("系统允许该选项设置的长度范围为1-20请重新设置。");
return false;
}
//会计日
if (sysOption==="System_AcctMonthDate" && ChkDataLen(value,1,31)===false){
Store.messager.warn("系统允许该选项设置的长度范围为1-31请重新设置。");
return false;
}
//加工成品成本分配方式
if (sysOption==="Frs_CostDis" && ChkInThree(value,"0","1","2")===false){
Store.messager.warn("选项值只能取0、1或2。");
return false;
}
//是否允许零库存销售
if (sysOption==="SAL_ZERO" && ChkInThree(value,"0","1","2")===false){
Store.messager.warn("选项值只能取0、1或2。");
return false;
}
}
}
return this.super('dataColumnValidate');
};
Biz.prototype.afterSave = function () {
Store.messager.tip("注意增加或者修改选项值后系统并非立即生效默认5分钟后统一刷新生效。<br>如果要立即生效,则需要按照以下步骤执行:<br>"+
"1、点击【发布】按钮发布选项到后台服务器缓存。<br>"+
"2、退出系统重新进入或者按F5刷新。<br>"+
"3、如果要让其他在使用系统的人也能立即使用选项则其他人也应执行步骤 2 ,否则其他人的本地缓存未更新仍将不能使用新的选项值。");
return this.super('afterSave');
};
Biz.prototype.doOp = function (opCode) {
if (opCode === 'flush') {
Store.services.flushOption({}, function(isOk) {
if (isOk) {
Store.messager.tip('系统选项缓存已刷新')
}
})
}
this.super('doOp', opCode);
};
/**
* 自定义函数判断选项值数值范围
* @return {boolean}
*/
function ChkDataLen(optionValue,min,max){
if (parseInt(optionValue)<min || parseInt(optionValue)>max) {
return false;
}
}
/**
* 自定义函数判断选项值是否在规定的3个数值内
* @return {boolean}
*/
function ChkInThree(optionValue,val1,val2,val3){
if (optionValue!==val1 && optionValue!==val2 && optionValue!==val3) {
return false;
}
}
return Biz;
});