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.
135 lines
4.5 KiB
135 lines
4.5 KiB
'use strict';
|
|
var ReportService = 'CostAndProfitReport';
|
|
var sProgramId = getProgramId();
|
|
var LastQueryResult = "";
|
|
var LastForm;
|
|
var fnPageInit = function () {
|
|
var canDo = new CanDo({
|
|
/**
|
|
* 客製化按鈕
|
|
* @param {Object} pargs CanDo 對象
|
|
*/
|
|
cusBtns: function (pargs) {
|
|
var saCusBtns = [{
|
|
id: 'Toolbar_PreviewReport',
|
|
value: 'common.Toolbar_PreviewReport',// ╠common.Toolbar_PreviewReport⇒預覽報表╣
|
|
action: function (pargs) {
|
|
fnReport('pdf');
|
|
}
|
|
},
|
|
{
|
|
id: 'Toolbar_DownloadReport',
|
|
value: 'common.Toolbar_DownloadReport',// ╠common.Toolbar_DownloadReport⇒下載報表╣
|
|
action: function (pargs) {
|
|
fnReport('excel');
|
|
}
|
|
}];
|
|
return saCusBtns;
|
|
},
|
|
/**
|
|
* 頁面初始化
|
|
* @param {Object} pargs CanDo 對象
|
|
*/
|
|
pageInit: function (pargs) {
|
|
|
|
|
|
$.whenArray([fnSetDeptDropWithLimtedDeptId($('#ResponsibleDeptID')),
|
|
fnSetUserDrop([
|
|
{
|
|
Select: $('#ResponsiblePerson'),
|
|
Select2: true,
|
|
ShowId: true,
|
|
}
|
|
],
|
|
fnSetArgDrop([
|
|
{
|
|
Select: $('#FeeClass'),
|
|
ArgClassID: 'FeeClass',
|
|
OrgID: pargs.OrgID,
|
|
CallBack: function (data) {
|
|
data = data.filter(c => c.id.indexOf('99') === 0);
|
|
$('#FeeClass').html(createOptions(data, 'id', 'text', true));
|
|
}
|
|
}
|
|
])),
|
|
fnSetEpoDropWithExhibitionCode({
|
|
Select: $('#ProjectNO'),
|
|
Select2: true,
|
|
})
|
|
]).done(function () { });
|
|
var iheight = $('body').height() - $('.page-title').height() - $('#searchbar').height() - 107;
|
|
$('#report').css('height', iheight + 'px');
|
|
$('.slide-box').on('click', function () {
|
|
if ($(this).hasClass('fa-arrow-down')) {
|
|
$('#report').css('height', iheight + 80 + 'px');
|
|
}
|
|
else {
|
|
$('#report').css('height', iheight + 'px');
|
|
}
|
|
});
|
|
|
|
$('#ResponsibleDeptID').on('change', function () {
|
|
//fnSetHandle_PersonDrop(this.value);
|
|
});
|
|
|
|
}
|
|
}),
|
|
/**
|
|
* 設定展覽名稱選單
|
|
* @return ajax 物件
|
|
*/
|
|
fnSetProjectDrop = function () {
|
|
return g_api.ConnectLite('BillsReport', 'GetProjects', {}, function (res) {
|
|
if (res.RESULT) {
|
|
var saCustomers = res.DATA.rel;
|
|
if (saCustomers.length > 0) {
|
|
$('#ProjectNO').html(createOptions(saCustomers, 'id', 'text')).select2();
|
|
}
|
|
}
|
|
});
|
|
},
|
|
|
|
/**
|
|
* 設置部門資料,連動業務
|
|
* @param {String} deptid 部門ID
|
|
*/
|
|
fnSetHandle_PersonDrop = function (deptid) {
|
|
var sDepartmentID = deptid || '';
|
|
fnSetUserDrop([
|
|
{
|
|
Action: 'add',
|
|
DepartmentID: sDepartmentID,
|
|
CallBack: function (data) {
|
|
var saList = data;
|
|
$('#ResponsiblePerson').html(createOptions(saList, 'MemberID', 'MemberName', true));
|
|
}
|
|
}
|
|
]);
|
|
},
|
|
/**
|
|
* 預覽報表或下載報表
|
|
* @param {String} flag 預覽或下載
|
|
*/
|
|
fnReport = function (flag) {
|
|
var oQuery = canDo._getFormSerialize();
|
|
oQuery.Flag = flag;
|
|
return g_api.ConnectLite(ReportService, sProgramId, oQuery, function (res) {
|
|
if (res.RESULT) {
|
|
var sPath = res.DATA.rel;
|
|
LastQueryResult = sPath;
|
|
if (flag === 'pdf') {
|
|
$('#report').attr('src', gServerUrl + '/' + sPath);
|
|
}
|
|
else {
|
|
canDo._downLoadFile(sPath);
|
|
}
|
|
}
|
|
else {
|
|
showMsg("Fail", 'error');
|
|
console.log(res.MSG);
|
|
}
|
|
});
|
|
};
|
|
};
|
|
|
|
require(['base', 'select2', 'cando'], fnPageInit);
|