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.

312 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 Service = require('./sys010107service');
let runOrgRpt = require('./addwindow');
let queryTpl = require('text!./custom-built-query.tpl')
let queryWindow = require("system/views/pages/querywindow/querywindow");
let multiWindow = require("system/views/pages/multiwindow/multiwindow");
function Biz(vm) {
//继承第一步,构造继承
BaseBiz.call(this, vm);
}
//继承第二步,方法继承
inherits(Biz, BaseBiz);
Biz.prototype.getCustomBuiltQuery = function() {
return queryTpl
};
//单据删除前处理 需要调用过程
Biz.prototype.beforeDelete = function () {
let masterRow = this.dsMaster.currentRow;
let sJobCode = masterRow ? TypeUtil.toString(masterRow['JobCode']) : '';
let sGenType = masterRow ? TypeUtil.toString(masterRow['GenType']) : '';
if (sJobCode.length <= 0){
masterRow.setColumnError("JobCode", '请选择待删除的系统作业!');
return false;
}
if (sGenType == "1") {
masterRow.setColumnError("JobCode", '系统预置任务,不允许删除!');
return false;
}
let ret= Service.getSlideMenuData("beforeDelete","delete",sJobCode,"","","","");
if (ret.result !== 1) {
masterRow.setColumnError('JobCode', ret.message);
return false;
}
return this.super('beforeDelete');
};
//保存前校验
Biz.prototype.beforeSave = function () {
let masterRow = this.dsMaster.currentRow;
if(masterRow){
let arrBody = new Array();
for(let i=0;i<this.dsDetail.rows.length;i++){
let row = this.dsDetail.rows[i];
arrBody[i] = row.getData();
}
let ret= Service.getSlideMenuData("beforeSave","save",masterRow.getData(),arrBody,this._state,"","");
if (ret.result !== 1) {
masterRow.setColumnError('JobCode', ret.message);
return false;
}
}
return this.super('beforeSave');
};
//明细行单行提交触发的校验
Biz.prototype.dataRowValidate = function (dataSrc, dr) {
if (dataSrc.uiObjCode === this.dsDetail.uiObjCode) {
let sBgnDate = TypeUtil.toString(dr['BgnDate']);
let sEndDate = TypeUtil.toString(dr['EndDate']);
let sBgnTime = TypeUtil.toString(dr['BgnTime']);
let sEndTime = TypeUtil.toString(dr['EndTime']);
if (sBgnDate.length != sEndDate.length) {
return '开始日期与结束日期必须成对设置!';
}
if (sBgnTime.length != sEndTime.length) {
return '开始时间与结束时间必须成对设置!';
}
}
return true;
};
//按钮事件控制
Biz.prototype.doOp = function (opCode) {
let self = this;
if (opCode == 'chgstatus') {
self.onchgstatus();
}
if (opCode == 'runing') {
this.onruning();
}
if (opCode == 'runorg') {
let masterRow = self.dsMaster.currentRow;
let sJobCode = masterRow ? TypeUtil.toString(masterRow['JobCode']) : '';
if (sJobCode == '0103'){
this.onrunorgsales();
}
else{
this.onrunorgrpt();
}
}
if (opCode == 'getlog') {
this.ongetlog();
}
};
//控制主界面按钮状态
Biz.prototype.getOpEnabled = function (opCode) {
let isOk = this.super('getOpEnabled', opCode);
if (!isOk) {
return false;
}
let masterRow = this.dsMaster.currentRow;
let sJobCode = masterRow ? TypeUtil.toString(masterRow['JobCode']) : '';
if (opCode == 'chgstatus'){
if (this.isEdit())
return false;
if (!masterRow)
return false;
}
if (opCode == 'runing'){
if (this.isEdit())
return false;
if (!masterRow)
return false;
}
if (opCode == 'runorg'){
if (this.isEdit())
return false;
if (!masterRow)
return false;
if ((sJobCode != '0103') && (sJobCode != '0104'))
return false;
}
if (opCode == 'getlog'){
if (this.isEdit())
return false;
if (!masterRow)
return false;
if (sJobCode === '0202')
return false;
}
return true;
};
//日结汇总事件处理
Biz.prototype.onrunorgsales = function () {
let self = this;
//定义多选窗口界面
let param={
uiObjCode: '5001',
serverBiz: 'cn.qdhezheng.rht.app.sys.sys010107.SavePlugin',
biz: self,
pk: "OrgCode",
/*fixQuery: {'JobType': '01'}, */
showCheckColumn: true,
isMultiPage: '0',
funcCode: self.FuncCode,
ds: self.dsDetail,
callback: function (rows) {
if (rows.length == 0){
Store.messager.tip("请先选择数据再执行本操作!");
return false;
}
if (!Store.confirm("确认要手动汇总这些组织的销售明细吗?")) {
return false;
}
let addDataList = new Array();
for (let j = 0; j < rows.length; j++) {
addDataList.push({
'OrgCode': rows[j].OrgCode
});
}
let ret = Service.getSlideMenuData("actExecute", "onrunorgsales", addDataList, "", "", "", "");
if (ret.result !== 1){
let ushowErrorInfo = new showErrorInfo(800,500,"处理失败信息如下:",ret.message);
ushowErrorInfo.open();
return false;
}
else{
Store.messager.tip("生成成功!");
return true;
}
}
};
//new多选窗体 并打开
let myWindow = new multiWindow(param);
myWindow.open();
};
//报表汇总事件处理
Biz.prototype.onrunorgrpt = function () {
let self = this;
//定义多选窗口界面
let param={
uiObjCode: '1109',
//serverBiz: 'cn.qdhezheng.rht.app.sys.sys010107.SavePlugin',
biz: self,
pk: "OrgCode",
/*fixQuery: {'JobType': '01'}, */
showCheckColumn: true,
enablePager: false,
isMultiPage: '0',
funcCode: self.FuncCode,
ds: self.dsDetail,
callback: function (rows,shzDate) {
if (rows.length == 0){
Store.messager.tip("请先选择数据再执行本操作!");
return false;
}
if (!Store.confirm("确认要手动汇总这些组织的报表数据吗?")) {
return false;
}
let addDataList = new Array();
for (let j = 0; j < rows.length; j++) {
addDataList.push({
'OrgCode': rows[j].OrgCode,
'MainCode': rows[j].MainCode,
'ItemCode': rows[j].ItemCode,
'UserId':Store.logOn.userId
});
}
let ret = Service.getSlideMenuData("actExecute", "onrunorgrpt", addDataList, shzDate, "", "", "");
if (ret.result !== 1){
Store.messager.err("处理失败信息如下:",ret.message);
return false;
}
else{
Store.messager.tip("生成成功!");
self.dsMaster.updateRow();
return true;
}
}
};
//new多选窗体 并打开
let myWindow = new runOrgRpt(param);
myWindow.open();
};
//日志查询事件处理
Biz.prototype.ongetlog = function () {
let self = this;
let masterRow = self.dsMaster.currentRow;
let sJobCode = masterRow ? TypeUtil.toString(masterRow['JobCode']) : '';
let param;
if (sJobCode === '0201'){
param = {
uiObjCode: '1099',
biz: self,
pk: 'LogID',
//fixQuery: {'JobCode': sJobCode },
funcCode: self.FuncCode,
isMultiPage: '1',
ds: self.dsMaster
};
}
else {
param = {
uiObjCode: '1220',
biz: self,
pk: 'SerialNo',
fixQuery: {'JobCode': sJobCode },
funcCode: self.FuncCode,
isMultiPage: '1',
ds: self.dsMaster
};
}
//定义多选窗口界面
//new多选窗体 并打开
let myWindow = new queryWindow(param);
myWindow.open();
return true;
};
//改变状态处理
Biz.prototype.onchgstatus = function () {
let masterRow = this.dsMaster.currentRow;
let sJobCode = masterRow ? TypeUtil.toString(masterRow['JobCode']) : '';
let sJob_Broken = masterRow ? TypeUtil.toString(masterRow['Job_broken']) : '';
if(masterRow){
if (!Store.confirm("您确定要修改当前系统作业"+sJobCode+"的运行状态吗?")) {
return false;
}
let ret= Service.getSlideMenuData("actExecute","onchgstatus",sJobCode,sJob_Broken,"","","");
if (ret.result !== 1) {
masterRow.setColumnError('JobCode', ret.message);
return false;
}
else{
this.dsMaster.updateRow();
Store.messager.tip(ret.message);
return true;
}
}
return true;
};
//运行处理
Biz.prototype.onruning = function () {
let masterRow = this.dsMaster.currentRow;
let sJobCode = masterRow ? TypeUtil.toString(masterRow['JobCode']) : '';
if(masterRow){
if ((sJobCode == '0103') || (sJobCode == '0104')){
if (!Store.confirm("您确定要按全部组织运行当前系统作业"+sJobCode+"吗?\n由系统自动选择能够进行汇总的项目进行数据汇总。\n如需按指定门店汇总请点击(按门店汇总)按钮")) {
return false;
}
}
else{
if (!Store.confirm("您确定要运行当前系统作业"+sJobCode+"吗?")) {
return false;
}
}
let ret= Service.getSlideMenuData("actExecute","onruning",sJobCode,"","","","");
if (ret.result !== 1) {
masterRow.setColumnError('JobCode', ret.message);
return false;
}
else{
this.dsMaster.updateRow();
Store.messager.tip(ret.message);
return true;
}
}
return true;
};
return Biz;
});