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.
205 lines
7.7 KiB
205 lines
7.7 KiB
4 years ago
|
|
||
|
define(function (require, exports, module) {
|
||
|
let BaseBiz = require('apps/rht/base/rhtBiz');
|
||
|
let rhtComm = require('apps/rht/comm/rhtComm');
|
||
|
let IsdsMasterChg = false;
|
||
|
let IsdsDetailChg = false;
|
||
|
|
||
|
/**
|
||
|
* 控制按钮的可用
|
||
|
* @param opCode 按钮编码
|
||
|
* @return [description]
|
||
|
*/
|
||
|
|
||
|
function Biz(vm) {
|
||
|
//继承第一步,构造继承
|
||
|
BaseBiz.call(this, vm);
|
||
|
}
|
||
|
|
||
|
//继承第二步,方法继承
|
||
|
inherits(Biz, BaseBiz);
|
||
|
|
||
|
//保存前记录日志
|
||
|
Biz.prototype.afterEdit = function () {
|
||
|
this.UWriteOperateLog('保存前');
|
||
|
return this.super('afterEdit');
|
||
|
};
|
||
|
//保存后记录日志
|
||
|
Biz.prototype.beforeSave = function () {
|
||
|
this.UWriteOperateLog('保存后');
|
||
|
return this.super('beforeSave');
|
||
|
};
|
||
|
//记录日志事件
|
||
|
Biz.prototype.UWriteOperateLog = function (stype) {
|
||
|
let self = this;
|
||
|
let curRow = self.dsMaster.currentRow;
|
||
|
let ds = self.dsDetail;
|
||
|
let orgCode=Store.logOn.orgCode;
|
||
|
let userId=Store.logOn.userId;
|
||
|
let userCode=Store.logOn.userCode;
|
||
|
let userName=Store.logOn.userName;
|
||
|
|
||
|
//记录主表编辑界面显示的字段值
|
||
|
let sMain = stype+'记录主表数据:'+' \n '
|
||
|
+'主题编码:' + curRow['MainCode']+' \n ' + '主题名称:' + curRow['MainName']+' \n '
|
||
|
+'生成类型:' + curRow['GenType']+' \n ' + '订阅状态:' + curRow['CanRun']+' \n '
|
||
|
+'任务类型:' + curRow['JobType']+' \n ' + '主题简介:' + curRow['MainText']+' \n '
|
||
|
+'主题详述:' + curRow['Remark']+' \n ' ;
|
||
|
rhtComm.MWriteOprLog(orgCode,userId,userCode,userName,'','','日结主题设置',sMain.substring(0,2000));
|
||
|
|
||
|
//记录明细表编辑界面显示的字段值
|
||
|
for (let i = ds.rows.length - 1; i > -1; i--) {
|
||
|
let row = ds.rows[i];
|
||
|
let sDetail = stype+'记录明细表数据:'+' \n '
|
||
|
+'主题编码:' + row['MainCode']+' \n ' + '项目编码:' + row['ItemCode']+' \n '
|
||
|
+'项目名称:' + row['ItemName']+' \n ' + '是否订阅:' + row['CanRun']+' \n '
|
||
|
+'报表简介:' + row['ItemText']+' \n ' + '录入日期:' + row['LrDate']+' \n '
|
||
|
+'生成类型:' + row['GenType']+' \n ' + '引进门店编码:' + row['OrgCode']+' \n '
|
||
|
+'引进门店名称:' + row['OrgName']+' \n ' + '报表详述:' + row['Remark']+' \n '
|
||
|
+'汇总过程:' + row['PrcName']+' \n ' ;
|
||
|
rhtComm.MWriteOprLog(orgCode,userId,userCode,userName,'','','日结主题设置',sDetail.substring(0,2000));
|
||
|
}
|
||
|
return true;
|
||
|
};
|
||
|
//字段变化触发事件
|
||
|
Biz.prototype.fieldChanged = function (dataSrc, dr, dc) {
|
||
|
if (dataSrc.uiObjCode === this.dsMaster.uiObjCode) {
|
||
|
switch (dc.fieldName) {
|
||
|
case 'MainCode':
|
||
|
this.fieldChangedMainCode(dataSrc, dr, dc);
|
||
|
break;
|
||
|
case 'CanRun':
|
||
|
this.fieldChangedCanRun(dataSrc, dr, dc);
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
if (dataSrc.uiObjCode === this.dsDetail.uiObjCode) {
|
||
|
switch (dc.fieldName) {
|
||
|
case 'CanRun':
|
||
|
this.fieldChangedDetailCanRun(dataSrc, dr, dc);
|
||
|
break;
|
||
|
case 'OrgCode':
|
||
|
this.fieldChangedDetailOrgCode(dataSrc, dr, dc);
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
this.super('fieldChanged');
|
||
|
};
|
||
|
//主表 MainCode 字段变化执行事件
|
||
|
Biz.prototype.fieldChangedMainCode = function (dataSrc, dr, dc) {
|
||
|
let MainCode = dr['MainCode'];
|
||
|
//用正则表达式校验输入内容必须是0-9的数字
|
||
|
let re=/^[0-9]+$/;
|
||
|
if (!re.test(MainCode)) {
|
||
|
dr.setColumnError('MainCode',"主题编码必须是0-9的纯数字!");
|
||
|
return false;
|
||
|
}
|
||
|
return true;
|
||
|
};
|
||
|
//主表 CanRun 字段变化执行事件
|
||
|
Biz.prototype.fieldChangedCanRun = function (dataSrc, dr, dc) {
|
||
|
let CanRun = TypeUtil.toString(dr['CanRun']);
|
||
|
let ds = this.dsDetail;
|
||
|
|
||
|
if (CanRun == '') return false;
|
||
|
//如果是明细字段变化则返回成功 不再进行明细表触发,避免死循环
|
||
|
if (IsdsDetailChg) return true;
|
||
|
IsdsMasterChg=true;
|
||
|
for (let i = ds.rows.length - 1; i > -1; i--) {
|
||
|
let row = ds.rows[i];
|
||
|
if (CanRun != "2") {
|
||
|
row.setColumnText('CanRun', CanRun);
|
||
|
}
|
||
|
}
|
||
|
IsdsMasterChg=false;
|
||
|
return true;
|
||
|
};
|
||
|
//明细表 CanRun 字段变化执行事件
|
||
|
Biz.prototype.fieldChangedDetailCanRun = function (dataSrc, dr, dc) {
|
||
|
let masterRow = this.dsMaster.currentRow;
|
||
|
let iCount = 0;
|
||
|
let iTotal = dataSrc.rows.length;
|
||
|
//如果是主表字段变化则返回成功 不再进行主表触发,避免死循环
|
||
|
if (IsdsMasterChg) return true;
|
||
|
IsdsDetailChg=true;
|
||
|
for (let i = dataSrc.rows.length - 1; i > -1; i--) {
|
||
|
let row = dataSrc.rows[i];
|
||
|
if (row["CanRun"] == "1") {
|
||
|
iCount++;
|
||
|
}
|
||
|
}
|
||
|
if (iCount > 0){
|
||
|
if (iCount == iTotal){
|
||
|
masterRow.setColumnText('CanRun', "1");
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
masterRow.setColumnText('CanRun', "2");
|
||
|
}
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
masterRow.setColumnText('CanRun', "0");
|
||
|
}
|
||
|
IsdsDetailChg=false;
|
||
|
return true;
|
||
|
};
|
||
|
//明细表 OrgCode 字段变化执行事件
|
||
|
Biz.prototype.fieldChangedDetailOrgCode = function (dataSrc, dr, dc) {
|
||
|
dr.setColumnText('OrgName', Store.logOn.orgName);
|
||
|
return true;
|
||
|
};
|
||
|
//增加右键菜单按钮并控制状态
|
||
|
Biz.prototype.getContextMenus = function (ds, source) {
|
||
|
let menus = this.super("getContextMenus", ds, source)
|
||
|
let edit = ds.getEditable();
|
||
|
let curRow = this.dsMaster.currentRow;
|
||
|
|
||
|
//仅在明细表点击右键时 本按钮可用
|
||
|
menus.push({
|
||
|
text: '报表详述',
|
||
|
opCode: 'edtRemark',
|
||
|
disabled: (!(ds.name == "dsDetail")) || (curRow == 0) //仅编辑状态可修改备注
|
||
|
});
|
||
|
return menus;
|
||
|
};
|
||
|
//定义按钮事件
|
||
|
Biz.prototype.doOp = function (opCode) {
|
||
|
let self = this;
|
||
|
if (opCode == 'edtRemark') {
|
||
|
let ds = self.dsDetail;
|
||
|
this.onedtremark(self, ds);
|
||
|
}
|
||
|
};
|
||
|
//按钮事件处理
|
||
|
Biz.prototype.onedtremark = function (biz, ds) {
|
||
|
let dsrow=ds.currentRow;
|
||
|
let edit = ds.getEditable();
|
||
|
let Remark = dsrow ? TypeUtil.toString(dsrow['Remark']) : '';
|
||
|
//仅支持查看 不支持修改
|
||
|
Store.messager.tip(Remark);
|
||
|
return true;
|
||
|
};
|
||
|
//控制主界面按钮状态(预制信息不允许修改和删除)
|
||
|
Biz.prototype.getOpEnabled = function (opCode) {
|
||
|
let isOk = this.super('getOpEnabled', opCode);
|
||
|
if (!isOk) {
|
||
|
return false;
|
||
|
}
|
||
|
let curRow = this.dsMaster.currentRow;
|
||
|
|
||
|
if (opCode == 'edit') {
|
||
|
let MainCode = curRow ? TypeUtil.toString(curRow['MainCode']) : '';
|
||
|
if ((MainCode == "0"))
|
||
|
return false;
|
||
|
}
|
||
|
if (opCode == 'delete') {
|
||
|
let MainCode = curRow ? TypeUtil.toString(curRow['MainCode']) : '';
|
||
|
if ((MainCode == "0"))
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
return true;
|
||
|
};
|
||
|
return Biz;
|
||
|
});
|