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.

350 lines
13 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 sys010103service = require('./sys010103service');
let UApp = require('apps/rht/comm/UApp');
let IsChooseOne = false; //是否选中【选择单个项目】
let IsOneTime = false; //是否选中【多组织同时日结】
let SelOrgs; //树状列表选中的组织
let SelJZItem; //日结项目(存储过程名)
let SelJZName; //日结项目(名称)
let SelJZCode; //日结项目(编号)
let MemoText; //提示信息
let dJzDate; //日结日期
/**
* 定义业务类对象
* @param vm 界面相关ViewModule
*/
function Biz(vm) {
//继承第一步,构造继承
BaseBiz.call(this, vm);
}
//继承第二步,方法继承
inherits(Biz, BaseBiz);
/**
* @description 点击【结账】按钮
*/
function btnJZClick() {
//判断是否选择了结账组织
if (SelOrgs.length == 0) {
Store.messager.err('请选择需要结账的组织!');
return;
};
//判断是否选择了结账项目
if (IsChooseOne == true) {
if (SelJZItem == '') {
Store.messager.err('请选择需要结账的项目!');
return;
}
};
//判断结账日期
dJzDate = $('#RjDate').datebox('getValue');
if (!UApp.IsDate(dJzDate)) {
Store.messager.err('请选择日结日期或日结日期格式不正确!');
return;
};
//结账提示文字
let tmp = '结账日期:【' + dJzDate + '】\n';
tmp = tmp + '结账组织数量:【' + SelOrgs.length + '】\n';
if (IsOneTime == true) {
tmp = tmp + '多组织同时日结:【是】\n';
} else {
tmp = tmp + '多组织同时日结:【否】\n';
if (IsChooseOne == true) {
tmp = tmp + '选择单个项目:【是】\n';
tmp = tmp + '日结项目:【' + SelJZName + '】\n';
}
}
tmp = tmp + '现在开始结账,请耐心等待......' + '\n';
MemoText = MemoText + tmp;
//确认是否需要结账
Store.messager.confirm('确认要本次日结吗?',
function (isOK) {
//点击【取消】跳出
if (!isOK) {
return;
} else { //点击【确定】执行结账处理
$('#Memo').textbox('setValue', MemoText);
//停用所有页面元素(其实没必要调用异步插件时系统自带loading动画且屏蔽页面)
SetAllElementStatus(false);
//异步执行结账
sys010103service.doOrgJZAsync(Store.logOn.orgCode, SelOrgs, IsOneTime, IsChooseOne, SelJZCode, SelJZName, SelJZItem, dJzDate,
//异步执行完时的回调处理
function (isOk, ret) {
if (!isOk) throw '访问服务器失败';
if (ret == null) throw '业务服务器异常';
if (ret.result == null) throw '业务服务器异常';
if (ret.result != 1) {
tmp = '--==<<结账失败>>==--\n';
tmp = tmp + '原因:' + ret.message + '\n';
} else {
tmp = '--==<<结账成功>>==--\n' + ret.message;
}
MemoText = MemoText + tmp + '==============================================\n';
$('#Memo').textbox('setValue', MemoText);
//启用所有页面元素(其实没必要调用异步插件时系统自带loading动画且屏蔽页面)
SetAllElementStatus(true);
return
})
}
})
};
/**
* @description 控制页面所有元素的启用或停用
* @param {*} bEnable true:启用;false:停用
*/
function SetAllElementStatus(bEnable) {
//启用
if (bEnable == true) {
$('#RjDate').datebox('enable');
let co = $('#ChooseOne');
let ot = $('#OneTime');
co.checkbox('enable');
if(IsChooseOne) {
co.checkbox('check');
}else {
co.checkbox('uncheck');
}
if (IsChooseOne == true) {
$('#RjItem').combobox('enable');
ot.checkbox('disable');
ot.checkbox('uncheck');
IsOneTime = false;
} else {
$('#RjItem').combobox('disable');
ot.checkbox('enable');
};
document.getElementById('btnJZ').disabled = false;
let treeObj = $.fn.zTree.getZTreeObj("tree_Org");
let nodes = treeObj.getNodes();
let nodearray = treeObj.transformToArray(nodes);
for (let i = 0, l = nodearray.length; i < l; i++) {
treeObj.setChkDisabled(nodearray[i], false);
}
}
//停用
else {
let co = $('#ChooseOne');
let ot = $('#OneTime');
$('#RjDate').datebox('disable');
co.checkbox('disable');
$('#RjItem').combobox('disable');
ot.checkbox('disable');
document.getElementById('btnJZ').disabled = true;
let treeObj = $.fn.zTree.getZTreeObj("tree_Org");
let nodes = treeObj.getNodes();
let nodearray = treeObj.transformToArray(nodes);
for (let i = 0, l = nodearray.length; i < l; i++) {
treeObj.setChkDisabled(nodearray[i], true);
}
}
};
/**
* @description 点击【选择单个项目】
*/
function ChooseOneClick() {
let ChooseOne = $('#ChooseOne');
let ot = $('#OneTime');
if (ChooseOne.checkbox('options').checked) {
IsChooseOne = true;
$('#RjItem').combobox('enable');
ot.checkbox('uncheck');
IsOneTime = false;
ot.checkbox('disable');
$('#RjItem').combobox('enable');
} else {
IsChooseOne = false;
$('#RjItem').combobox('disable');
ot.checkbox('check');
IsOneTime = true;
ot.checkbox('enable');
$('#RjItem').combobox('disable');
$('#RjItem').combobox('clear');
}
};
/**
* @description 点击【多组织同时日结】
*/
function OneTimeClick() {
let OneTime = $('#OneTime');
if (OneTime.checkbox('options').checked) {
IsOneTime = true;
} else {
IsOneTime = false;
}
};
/**
* @description 点击树时
* @param {*} e
* @param {*} treeId 树ID
* @param {*} treeNode 节点ID
*/
function onNodeTreeClick(e, treeId, treeNode) {
//无处理
};
/**
* @description 节点checked或unchecked时
* @param {*} e
* @param {*} treeId 树ID
* @param {*} treeNode 节点ID
*/
function onNodeCheck(e, treeId, treeNode) {
//获取已选择的节点信息
SelOrgs = $.fn.zTree.getZTreeObj(treeId).getCheckedNodes(true);
if(SelOrgs.length > 1) {
let co = $('#ChooseOne');
co.checkbox('disable');
co.checkbox('uncheck');
IsChooseOne = false;
$('#RjItem').combobox('disable');
$('#RjItem').combobox('clear');
SelJZCode = '';
SelJZItem = '';
SelJZName = '';
}else {
$('#ChooseOne').checkbox('enable');
}
};
/**
* @description 初始化下拉列表
* @param {*} comboboxObj 下拉列表对象
*/
function initComboBox(comboboxObj) {
//调用插件获取日结项目并组装为下拉列表项
let RjItemInfo = sys010103service.getRjItem(Store.logOn.orgCode);
let RjItems = [];
if (RjItemInfo.result != 1) {
Store.MESSAGER.err(RjItemInfo.message);
} else {
for (let i = 0, len = RjItemInfo.data.length; i <= len - 1; i++) {
RjItems.push({
itemCode: RjItemInfo.data[i].itemcode,
itemName: RjItemInfo.data[i].itemcode + '-' + RjItemInfo.data[i].itemname,
scriptCode: RjItemInfo.data[i].scriptcode
});
};
};
//生成下拉列表内容
comboboxObj.combobox('loadData', RjItems);
//日结项目选择时
$('#RjItem').combobox({
onSelect: function (record) {
SelJZItem = record.scriptCode;
SelJZName = record.itemName;
SelJZCode = record.itemCode;
}
});
};
/**
* @description 初始化树状列表
* @param {*} treeObj 树对象
*/
function initTree(treeObj) {
//树选项
let treeSetting = {
view: {
selectedMulti: false //允许多选
},
check: {
enable: true, //允许勾选
chkboxType: {
"Y": "s",
"N": "s"
} //父节点与子节点勾选关系
},
data: {
simpleData: {
enable: true //使用简单JSON构建树
}
},
callback: {
onClick: onNodeTreeClick, //单击时响应事件
onCheck: onNodeCheck //勾选时响应事件
}
};
//调用插件获取组织信息并组装为树的节点信息
let OrgTreeInfo = sys010103service.getOrgTree(Store.logOn.orgCode);
let zTreeNodes = [];
if (OrgTreeInfo.result != 1) {
Store.MESSAGER.err(OrgTreeInfo.message);
} else {
for (let i = 0, len = OrgTreeInfo.data.length; i <= len - 1; i++) {
zTreeNodes.push({
id: OrgTreeInfo.data[i].id, //节点ID
pId: OrgTreeInfo.data[i].pid, //父节点ID
orgcode: OrgTreeInfo.data[i].orgcode, //组织编码
name: OrgTreeInfo.data[i].orgcode + '-' + OrgTreeInfo.data[i].orgname, //节点显示信息
open: true //是否展开
});
};
};
//创建树
$.fn.zTree.init(treeObj, treeSetting, zTreeNodes);
};
/**
* @description 初始化完毕
*/
Biz.prototype.initCompleted = function () {
//初始化全局变量
IsChooseOne = false;
IsOneTime = false;
SelOrgs = [];
SelJZCode = '';
SelJZName = '';
SelJZItem = '';
MemoText = '';
//对页面中的元素进行事件绑定
let btnJZ = document.getElementById('btnJZ');
btnJZ.addEventListener('click', btnJZClick, false);
//let ChooseOne = document.getElementById('ChooseOne');
//ChooseOne.addEventListener('click', ChooseOneClick, false);
$('#ChooseOne').checkbox({onChange:ChooseOneClick})
// let OneTime = document.getElementById('OneTime');
// OneTime.addEventListener('click', OneTimeClick, false);
$('#OneTime').checkbox({onChange:OneTimeClick})
//初始化日结项目ComboBox
initComboBox($('#RjItem'));
//初始化组织树
initTree($('#tree_Org'));
//页面元素默认状态
$('#OneTime').checkbox('check');
IsOneTime = true;
$('#RjDate').datebox('setValue', UApp.getNowFormatDate());
$('#RjItem').combobox('disable');
};
return Biz;
});