'use strict'; var /** * 設定部門主管下拉選單 * @param {Object} handle 當前控件 * @param {String} deptid 部門id * @return {Object} Ajax 物件 */ fnSetDeptDrop = function (handle, deptid) { var oParm = {}; oParm.OrgID = parent.OrgID; oParm.DeptID = deptid || ''; return g_api.ConnectLite(Service.sys, 'GetDepartmentList', oParm, function (res) { if (res.RESULT) { var saData = res.DATA.rel; handle.html(createOptions(saData, 'DepartmentID', 'AccountNameSort', true)); } }); }, /** * 設定部門主管下拉選單 * @param {Object} handle 當前控件 * @param {String} deptid 部門id * @return {Object} Ajax 物件 */ fnSetDeptDropWithLimtedDeptId = function (handle) { var oParm = {}; oParm.OrgID = parent.OrgID; oParm.DeptID = ''; return g_api.ConnectLite(Service.sys, 'GetDepartmentListNoVoid', oParm, function (res) { if (res.RESULT) { //debugger; var saData = res.DATA.rel; var DepId = parent.UserInfo.DepartmentID; var AdminUser = parent.UserInfo.roles.toLowerCase().indexOf('admin') > -1; if (!AdminUser) { saData = saData.filter(c => c.ParentDepartmentID === DepId || c.DepartmentID === DepId || c.DepartmentID1 === DepId); } handle.html(createOptions(saData, 'DepartmentID', 'AccountNameSort', true)); if (!AdminUser) { $(handle.selector + ' option:first').remove(); } } }); }, /** * 設定人員下拉選單 * @param {Object} drops 當前控件 * @return {Object} Ajax 物件 */ fnSetUserDrop = function (drops) { var saPost = []; $.each(drops, function (index, drop) { drop.Effective = 'Y'; //if (drop.Action && drop.Action.toLowerCase() === 'add') { // drop.Effective = 'Y'; //} saPost.push(g_api.ConnectLite(Service.com, ComFn.GetUserList, { DepartmentID: drop.DepartmentID || '', MemberID: drop.MemberID || '', UserIDs: drop.UserIDs || '', NotUserIDs: drop.NotUserIDs || '', ServiceCode: drop.ServiceCode || '', Effective: drop.Effective || '' }, function (res) { if (res.RESULT) { var saRes = res.DATA.rel; if (drop.Select) { drop.Select.html(createOptions(saRes, 'MemberID', 'MemberName', drop.ShowId || false)); if (drop.DefultVal) { drop.Select.val(drop.DefultVal); } if (drop.Select2) { drop.Select.each(function () { $(this).select2(); $(this).next().after($(this)); }); } } if (drop.CallBack && typeof drop.CallBack === 'function') { drop.CallBack(saRes); } } })); }); return $.whenArray(saPost); }, /** * 設定下拉選單(參數設定) * @param {Array} drops 下拉配置 * @return {Object} Ajax 物件 */ fnSetArgDrop = function (drops) { var saPost = []; $.each(drops, function (index, drop) { if (drop.ArgClassID) { saPost.push(g_api.ConnectLite(Service.com, ComFn.GetArguments, { ArgClassID: drop.ArgClassID, ParentID: drop.ParentID || '', ArgIDs: drop.Ids || '', LevelOfArgument: drop.Level || -1, OrgID: drop.OrgID || '' }, function (res) { if (res.RESULT) { var saRes = res.DATA.rel; if (drop.Select) { drop.Select.html(createOptions(saRes, 'id', 'text', drop.ShowId || false)) .on('change', function () { if (drop.OnChange && typeof drop.OnChange === 'function') { drop.OnChange(this.value); } }); if (drop.DefultVal) { drop.Select.val(drop.DefultVal); } if (drop.Select2) { drop.Select.each(function () { $(this).select2(); $(this).next().after($(this)); }); } } if (drop.CallBack && typeof drop.CallBack === 'function') { drop.CallBack(saRes); } } })); } }); return $.whenArray(saPost); }, /** * 設定展覽下拉選單 * @param {Object} drop 當前控件 * @return {Object} Ajax 物件 */ fnSetEpoDrop = function (drop) { return g_api.ConnectLite('Exhibition_Upd', 'GetExhibitions', { SN: drop.SN || '' }, function (res) { if (res.RESULT) { var saRes = res.DATA.rel; if (drop.Select) { drop.Select.html(createOptions(saRes, drop.IdName || 'SN', drop.TextName || 'ExhibitioFullName', drop.ShowId || false)); if (drop.DefultVal) { drop.Select.val(drop.DefultVal); } if (drop.Select2) { drop.Select.each(function () { $(this).select2(); $(this).next().after($(this)); }); } } if (drop.CallBack && typeof drop.CallBack === 'function') { drop.CallBack(saRes); } } }); }, /* * 設定展覽選單(ExhibitionCode) */ fnSetEpoDropWithExhibitionCode = function (drop) { return g_api.ConnectLite('BillsReport', 'GetProjects', {}, function (res) { if (res.RESULT) { var saRes = res.DATA.rel; if (drop.Select) { drop.Select.html(createOptions(saRes, drop.IdName || 'id', drop.TextName || 'text', drop.ShowId || false)); if (drop.DefultVal) { drop.Select.val(drop.DefultVal); } if (drop.Select2) { drop.Select.each(function () { $(this).select2(); $(this).next().after($(this)); }); } } if (drop.CallBack && typeof drop.CallBack === 'function') { drop.CallBack(saRes); } } }); }, /* * 設定客戶資料(customer_guid) */ fnSetCustomerWithGuid = function (drop) { return g_api.ConnectLite(Service.sys, 'GetCustomerlist', {}, function (res) { if (res.RESULT) { var saRes = res.DATA.rel; if (drop.Select) { drop.Select.html(createOptions(saRes, 'id', 'text', drop.ShowId || false)); if (drop.DefultVal) { drop.Select.val(drop.DefultVal); } if (drop.Select2) { drop.Select.each(function () { $(this).select2(); $(this).next().after($(this)); }); } } if (drop.CallBack && typeof drop.CallBack === 'function') { drop.CallBack(saRes); } } }); }, /** * 設定展覽下拉選單 * @param {Object} o 參數 * @return {Object} Ajax 物件 */ fnGetOfficeTempls = function (o) { return g_api.ConnectLite(Service.com, 'GetOfficeTempls', { TemplID: o.TemplID || '' }, function (res) { if (res.RESULT) { var saRes = res.DATA.rel; if (o.CallBack && typeof o.CallBack === 'function') { o.CallBack(saRes); } } }); }, /** * 開啟單選選單Pop * @param {Object} option 配置 */ oPenPops = function (option) { var oGrid = null, oCurItem = null, sContent = '', sGrid = '
', saRow = []; $.each(option.SearchFields, function (index, item) { var oLabel = $('