'use strict'; var fnPageInit = function () { var canDo = new CanDo({ /** * 修改完后是否跳轉 */ updateGo: false, /** * 須初始化的UEEditer 的物件ID集合 */ ueEditorIds: ['Introduction', 'Introduction_CN', 'Introduction_EN', 'MissionAndVision_TW', 'MissionAndVision_CN', 'MissionAndVision_EN', 'MissionAndVision_EN', 'ServiceTitle', 'ServiceTitle_CN', 'ServiceTitle_EN', 'VideoDescription', 'VideoDescription_CN', 'VideoDescription_EN', 'SettingInfo'], /** * 查詢當前資料 * @param {Object} pargs CanDo 對象 * @param {Object} data 當前資料實體 */ getOneBack: function (pargs, data) { pargs._setFormVal(data); pargs._setUEValues(data); fnGetUploadFiles(data.WebsiteLgoId, fnUpload, $('#WebsiteLogoId')); fnGetUploadFiles(data.PicShowId, fnUpload, $('#PicShowId')); fnGetUploadFiles(data.PicShowId_CN, fnUpload, $('#PicShowId_CN')); fnGetUploadFiles(data.PicShowId_EN, fnUpload, $('#PicShowId_EN')); }, /** * 頁面初始化 * @param {Object} pargs CanDo 對象 */ pageInit: function (pargs) { pargs.action = 'update'; pargs._getOne(); fnGridInit('Carousel', 'TW');//初始化輪播(繁中) fnGridInit('ServiceItems', 'TW');//初始化服務項目(繁中) fnGridInit('ClassicCase', 'TW');//初始化經典案例(繁中) fnGridInit('Video', 'TW');//初始化品牌影音(繁中) fnGridInit('Downloads', 'TW');//文檔下載(繁中) fnGridInit('ServiceBase', 'TW');//初始化全球服務據點(繁中) fnGridInit('Carousel', 'CN');//初始化輪播(簡中) fnGridInit('ServiceItems', 'CN');//初始化服務項目(簡中) fnGridInit('ClassicCase', 'CN');//初始化經典案例(簡中) fnGridInit('Video', 'CN');//初始化品牌影音(簡中) fnGridInit('Downloads', 'CN');//文檔下載(簡中) fnGridInit('ServiceBase', 'CN');//初始化全球服務據點(簡中) fnGridInit('Carousel', 'EN');//初始化輪播(英文) fnGridInit('ServiceItems', 'EN');//初始化服務項目(英文) fnGridInit('ClassicCase', 'EN');//初始化經典案例(英文) fnGridInit('Video', 'EN');//初始化品牌影音(英文) fnGridInit('Downloads', 'EN');//文檔下載(英文) fnGridInit('ServiceBase', 'EN');//初始化全球服務據點(英文) } }), oGrid = {}, oOption = {}, oBaseQueryPm = { pageIndex: 1, pageSize: parent.SysSet.GridRecords || 10, sortField: 'ParentId,OrderByValue', sortOrder: 'asc' }, oLang = { 'TW': 'zh-TW', 'CN': 'zh', 'EN': 'en' }, /** * 新增輪播資訊 * @param {Object} args 參數 * @return {Function} Ajax */ fnSetInsert = function (args) { return g_api.ConnectLite(canDo.ProgramId, canDo._api.ginsert, args, function (res) { if (res.RESULT) { var oRes = res.DATA.rel; } }); }, /** * 修改輪播資訊 * @param {Object} args 參數 * @return {Function} Ajax */ fnSetUpdate = function (args) { return g_api.ConnectLite(canDo.ProgramId, canDo._api.gupdate, args, function (res) { if (res.RESULT) { var oRes = res.DATA.rel; } }); }, /** * 刪除輪播資訊 * @param {Object} args 參數 * @return {Function} Ajax */ fnSetDelete = function (args) { return g_api.ConnectLite(canDo.ProgramId, canDo._api.gdelete, args, function (res) { if (res.RESULT) { var oRes = res.DATA.rel; } }); }, /** * 抓去輪播資訊 * @param {Object} args 參數 * @param {String} settype 設定類別 * @param {String} lang 語系 * @return {Object} ajax */ fnGetSetting = function (args, settype, lang) { var sKey = settype + '_' + lang, oQueryPm = { SetType: settype, LangId: oLang[lang] }; $.extend(oQueryPm, oBaseQueryPm, args); return g_api.ConnectLite(canDo.ProgramId, canDo._api.getpage, oQueryPm, function (res) { if (res.RESULT) { var oRes = res.DATA.rel; if (settype === 'ClassicCase') { var saParentId = $.grep(oRes.DataList, function (item) { if (!item.ParentId) { return item; } }); oOption[sKey].ParentIdHtml = createOptions(saParentId, 'Guid', 'Title'); } } }); }, /** * Grid客戶化計價模式控件 * @param {String}flag 標記 * @return {HTMLElement} html 物件 */ fnCreateActiveInput = function (flag) { var elDiv = $('
'), data = [{ id: true, text: i18next.t('common.Effective') }, { id: false, text: i18next.t('common.Invalid') }]; elDiv.html(createRadios(data, 'id', 'text', '~Active' + flag, flag, false, false)); return elDiv; }, /** * 初始化輪播 * @param {String} settype 設定類別 * @param {String} lang 語系 */ fnGridInit = function (settype, lang) { var sKey = settype + '_' + lang, saFields = [{ name: "RowIndex", title: 'common.RowNumber', align: 'center', width: 40, sorting: false }]; if ('ClassicCase'.indexOf(settype) > -1) { saFields.push({ name: "ParentId", title: 'common.ParentId', width: 120, type: 'select',// ╠common.ParentId⇒父層╣ itemTemplate: function (val, item) { var oControl = $('', { class: "form-control w100p", html: !oOption[sKey] ? '' : oOption[sKey].ParentIdHtml }); setTimeout(function () { oControl.html(!oOption[sKey] ? '' : oOption[sKey].ParentIdHtml); }, 2000); return this.insertControl = oControl; }, insertValue: function () { return this.insertControl.val(); }, editTemplate: function (val, item) { var oControl = $('', { type: 'file', class: 'displayNone', name: 'files[]', 'multiple': 'multiple' }); fnGetUploadFiles(val, fnUpload, fileInput); return oFileDiv.append(fileInput); } }); } if ('ClassicCase'.indexOf(settype) > -1) { saFields.push({ name: "SubIconId", title: 'common.SubIcon', width: 120, itemTemplate: function (val, item) {//╠common.SubIcon⇒圖標2╣ var oFileDiv = $('
', { class: 'file-Info' }), fileInput = $('', { type: 'file', class: 'displayNone', name: 'files[]', 'multiple': 'multiple' }); fnGetUploadFiles(val, fnUpload, fileInput); return oFileDiv.append(fileInput); } }); } if ('Carousel,ClassicCase,Downloads'.indexOf(settype) > -1) { saFields.push({ name: "CoverId", title: { 'Carousel': 'common.CarouselPic', 'Downloads': 'common.DownLoadDocuments' }[settype] || 'common.CoverPic', width: 120, align: 'center', itemTemplate: function (val, item) {//╠common.CarouselPic⇒輪播圖片╣ var oFileDiv = $('
', { class: 'file-Info' }), fileInput = $('', { type: 'file', class: 'displayNone', name: 'files[]', 'multiple': 'multiple', 'data-file': settype }); fnGetUploadFiles(val, fnUpload, fileInput); return oFileDiv.append(fileInput); } }); } if ('ServiceBase,Downloads'.indexOf(settype) === -1) { saFields.push({ //╠common.Link⇒連接╣ name: "Link", title: 'common.Link', width: 150, type: 'text', validate: { validator: 'maxLength', message: "Field value is too long", param: 500 }, itemTemplate: function (val, item) { var elLink = $('', { class: 'link', 'target': '_new', text: val, href: val }); return elLink; } }); } if ('ServiceItems,ClassicCase,Video,ServiceBase,Downloads'.indexOf(settype) > -1) { saFields.push( {// ╠common.CenterCoordinates⇒中心坐標╣ name: "Description", title: { 'ServiceBase': 'common.CenterCoordinates' }[settype] || 'common.Description', width: 150,//╠common.Description⇒描述╣ itemTemplate: function (val, item) { val = val || ''; return val.length > 100 ? val.substr(0, 100) + '...' : val; }, insertTemplate: function (val, item) { var elControl = $('