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.
1378 lines
38 KiB
1378 lines
38 KiB
'use strict';
|
|
|
|
var EN_US = "en-US";
|
|
var DEFAULT_LANGUAGEID = "zh-TW";
|
|
|
|
var currentExhibitionID = '';
|
|
var currentExhibInfoID = '';
|
|
var currentStatMap = new Map();
|
|
var currentMediaMap = new Map();
|
|
|
|
var RegionMap = new Map();
|
|
|
|
var OrganizerMap = new Map();
|
|
var VenueMap = new Map();
|
|
|
|
var ue_Intro = UE.getEditor('UE_Intro');
|
|
var ue_Profile = UE.getEditor('UE_Profile');
|
|
var ue_Detail = UE.getEditor('UE_Detail');
|
|
|
|
var MediaFileMap = new Map();
|
|
var MediaListMap = new Map();
|
|
|
|
var fnPageInit = function () {
|
|
var canDo = new CanDo({
|
|
/**
|
|
* 當前程式所有ID名稱集合
|
|
*/
|
|
idKeys: ['OrgID', 'ExhibitionID', 'LanguageID', 'LangType'],
|
|
/**
|
|
* 當前程式所有參數名稱集合
|
|
*/
|
|
paramKeys: ['ExhibitionID'],
|
|
|
|
/**
|
|
* 須初始化的UEEditer 的物件ID集合
|
|
*/
|
|
ueEditorIds: ['Intro'],
|
|
|
|
/**
|
|
* 客製化驗證規則
|
|
* @param {Object} pargs CanDo 對象
|
|
*/
|
|
|
|
/**
|
|
* 查詢當前資料
|
|
* @param {Object} pargs CanDo 對象
|
|
* @param {Object} data 當前資料實體
|
|
*/
|
|
|
|
getOneBack: function (pargs, data) {
|
|
|
|
currentExhibitionID = data.ExhibitionID;
|
|
|
|
},
|
|
|
|
/**
|
|
* 修改資料
|
|
* @param {Object} pargs CanDo 對象
|
|
* @param {Object} data 當前修改的資料
|
|
*/
|
|
|
|
getUpdateParams: function (pargs, data) {
|
|
data = pargs.options.getInsertParams(pargs, data);
|
|
return data;
|
|
},
|
|
|
|
getInsertParams: function (pargs, data) {
|
|
|
|
data.MainCategoryIDs = [];
|
|
data.SubCategoryIDs = [];
|
|
data.OrganizerIDs = [];
|
|
data.VenueIDs = [];
|
|
|
|
data.MainCategoryIDs = JSON.stringify($('#MainCategoryID').val());
|
|
data.SubCategoryIDs = JSON.stringify($('#SubCategoryID').val());
|
|
data.OrganizerIDs = JSON.stringify($('#OrganizerID').val());
|
|
data.VenueIDs = JSON.stringify($('#VenueID').val());
|
|
|
|
return data;
|
|
},
|
|
|
|
/**
|
|
* 頁面初始化
|
|
* @param {Object} pargs CanDo 對象
|
|
*/
|
|
|
|
pageInit: function (pargs) {
|
|
|
|
var postArray = [];
|
|
var current_date = new Date().toJSON().slice(0, 10);
|
|
var current_year = current_date.slice(0, 4);
|
|
|
|
$('#StartDate').val(current_date);
|
|
$('#EndDate').val(current_date);
|
|
$('#Year').val(current_year);
|
|
|
|
fnLanguageDrop().done(function (res) {
|
|
|
|
$('#LanguageID').val(DEFAULT_LANGUAGEID);
|
|
});
|
|
|
|
if (pargs.action === 'upd') {
|
|
$('#ExhibitionID').prop('disabled', true);
|
|
$('#LanguageID').prop('disabled', true);
|
|
postArray.push(pargs._getOne());
|
|
}
|
|
|
|
if (pargs.action === 'add') {
|
|
|
|
fnDisableExhibInfo(true);
|
|
fnDisableStatistic(true);
|
|
fnDisableMedia(true);
|
|
|
|
}
|
|
|
|
postArray.push(fnSetOrderByValueDrop(), fnFrequencyDrop(), fnShowStatusDrop());
|
|
|
|
var rsMainCategoryIDs = [];
|
|
var rsSubCategoryIDs = [];
|
|
var rsOrganizerList = [];
|
|
var rsOrganizerIDs = [];
|
|
var rsVenueList = [];
|
|
var rsVenueIDs = [];
|
|
|
|
$.whenArray(postArray).done(function (res) {
|
|
|
|
if (pargs.action === 'upd' && res[0].RESULT) {
|
|
var oRes = res[0].DATA.rel;
|
|
|
|
if (oRes.LanguageID) {
|
|
$('#LanguageID').val(oRes.LanguageID);
|
|
}
|
|
|
|
if (oRes.MainCategoryIDs) {
|
|
rsMainCategoryIDs = JSON.parse(oRes.MainCategoryIDs);
|
|
|
|
}
|
|
|
|
if (oRes.SubCategoryIDs) {
|
|
rsSubCategoryIDs = JSON.parse(oRes.SubCategoryIDs);
|
|
}
|
|
|
|
if (oRes.JsonOrganizers) {
|
|
rsOrganizerList = JSON.parse(oRes.JsonOrganizers);
|
|
}
|
|
|
|
if (oRes.OrganizerIDs) {
|
|
rsOrganizerIDs = JSON.parse(oRes.OrganizerIDs);
|
|
}
|
|
|
|
if (oRes.JsonVenues) {
|
|
rsVenueList = JSON.parse(oRes.JsonVenues);
|
|
}
|
|
|
|
if (oRes.VenueIDs) {
|
|
rsVenueIDs = JSON.parse(oRes.VenueIDs);
|
|
}
|
|
|
|
fnSetOrganizerDrop(rsOrganizerIDs, rsOrganizerList);
|
|
fnSetVenueDrop(rsVenueIDs, rsVenueList);
|
|
|
|
fnGetExhibInfo();
|
|
fnGetStatisticList();
|
|
fnGetMediaList();
|
|
|
|
pargs._setFormVal(oRes);
|
|
|
|
if (oRes.IsVirtualEvent) {
|
|
|
|
fnResetVirtualEventLink(oRes.IsVirtualEvent);
|
|
|
|
}
|
|
|
|
pargs.data.Logo = pargs.data.Logo || guid();
|
|
pargs.data.MediaFile = pargs.data.MediaFile || guid();
|
|
pargs._getPageVal();//緩存頁面值,用於清除
|
|
fnGetUploadFiles(pargs.data.Logo, fnUploadLogo, 'LogoFile');
|
|
fnGetMediaFile();
|
|
/*fnGetUploadFiles(pargs.data.MediaFile, fnUploadMediaFile, 'MediaFile');*/
|
|
|
|
} else {
|
|
|
|
var parentid = guid();
|
|
pargs.data.Logo = parentid;
|
|
fnUploadLogo(null, parentid, 'LogoFile');
|
|
|
|
}
|
|
|
|
fnGetRegoin().done(function () {
|
|
|
|
fnOrgRegionDrop();
|
|
fnVenueRegionDrop();
|
|
|
|
});
|
|
|
|
fnMainCategoryDrop().done(function (res) {
|
|
|
|
$('#MainCategoryID').val(rsMainCategoryIDs);
|
|
$('#MainCategoryID').trigger('change');
|
|
|
|
fnSubCategoryDrop().done(function (res) {
|
|
|
|
$('#SubCategoryID').val(rsSubCategoryIDs);
|
|
$('#SubCategoryID').trigger('change');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
$('#MainCategoryID').on('change', function () {
|
|
|
|
fnSubCategoryDrop();
|
|
|
|
});
|
|
|
|
$('#IsVirtualEvent_radio_0').on('change', function () {
|
|
|
|
$('#VirtualEventLink').prop('disabled', false);
|
|
|
|
});
|
|
|
|
$('#IsVirtualEvent_radio_1').on('change', function () {
|
|
|
|
$('#VirtualEventLink').prop('disabled', true);
|
|
|
|
});
|
|
|
|
$('.addStatRecord').on('click', function () {
|
|
var oNewData = {};
|
|
oNewData.StatisticsID = guid();
|
|
oNewData.ExhibitionID = currentExhibitionID;
|
|
oNewData.Year = $('#Year').val();
|
|
oNewData.ExhibSize = '0.00';
|
|
oNewData.VisitorCount = '0';
|
|
oNewData.IntVisitorCount = '0';
|
|
oNewData.ExhibitorCount = '0';
|
|
|
|
currentStatMap.set(oNewData.StatisticsID, oNewData);
|
|
fnBindStatData();
|
|
});
|
|
|
|
//清除展覽資訊
|
|
$('#btnClearInfo').click(function () {
|
|
|
|
fnResetExhibInfo();
|
|
|
|
});
|
|
|
|
//處存展覽資訊
|
|
$('#btnSaveInfo').click(function () {
|
|
|
|
fnSaveExhibInfo();
|
|
|
|
});
|
|
|
|
//刪除展覽資訊
|
|
$('#btnDeleteInfo').click(function () {
|
|
|
|
});
|
|
|
|
$('#Year').on('change', function () {
|
|
|
|
currentExhibInfoID = "";
|
|
|
|
fnGetExhibInfo().done(function () {
|
|
|
|
//fnGetMediaList();
|
|
});
|
|
|
|
});
|
|
|
|
$('#btnSaveStat').click(function () {
|
|
|
|
fnSaveStat();
|
|
|
|
});
|
|
|
|
$('#OrgRegionID').on('change', function () {
|
|
|
|
$('#OrgCityID').empty();
|
|
//$('#OrganizerIDs').empty();
|
|
fnOrgCountryDrop().done(function () {
|
|
$('#OrgCountryID').trigger('change');
|
|
});
|
|
|
|
});
|
|
|
|
$('#VenueRegionID').on('change', function () {
|
|
|
|
$('#VenueCityID').empty();
|
|
//$('#VenueIDs').empty();
|
|
fnVenueCountryDrop().done(function () {
|
|
$('#VenueCountryID').trigger('change');
|
|
});
|
|
|
|
});
|
|
|
|
$('#OrgCountryID').on('change', function () {
|
|
|
|
//$('#OrganizerIDs').empty();
|
|
fnOrgCityDrop().done(function () {
|
|
$('#OrgCityID').trigger('change');
|
|
});
|
|
|
|
});
|
|
|
|
$('#VenueCountryID').on('change', function () {
|
|
|
|
//$('#VenueIDs').empty();
|
|
fnVenueCityDrop().done(function () {
|
|
$('#VenueCityID').trigger('change');
|
|
});
|
|
|
|
});
|
|
|
|
$('#OrgCityID').on('change', function () {
|
|
|
|
fnOrganizerDrop();
|
|
});
|
|
|
|
$('#VenueCityID').on('change', function () {
|
|
|
|
fnVenueDrop();
|
|
|
|
});
|
|
|
|
$('#btnSaveMedia').click(function () {
|
|
|
|
fnSaveMediaList();
|
|
|
|
});
|
|
|
|
$('.addMediaRecord').on('click', function () {
|
|
var oNewData = {};
|
|
oNewData.MediaID = guid();
|
|
oNewData.ExhibitionID = currentExhibitionID;
|
|
oNewData.MediaName = '';
|
|
oNewData.MediaTypeID = 'Link';
|
|
oNewData.Link = '';
|
|
|
|
MediaListMap.set(oNewData.MediaID, oNewData);
|
|
fnBindMediaListData();
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$('#MainCategoryID').select2();
|
|
$('#SubCategoryID').select2();
|
|
|
|
$('#OrgRegionID').select2();
|
|
$('#VenueRegionID').select2();
|
|
|
|
$('#OrgCountryID').select2();
|
|
$('#VenueCountryID').select2();
|
|
|
|
$('#OrgCityID').select2();
|
|
$('#VenueCityID').select2();
|
|
|
|
$('#OrganizerID').select2();
|
|
$('#VenueID').select2();
|
|
|
|
|
|
}
|
|
|
|
}),
|
|
|
|
/**
|
|
* 語言下拉選單
|
|
* @return {Object} Ajax 物件
|
|
*/
|
|
fnLanguageDrop = function () {
|
|
return g_api.ConnectLite(canDo.ProgramId, "QueryLanguageList", {
|
|
|
|
},
|
|
function (res) {
|
|
|
|
if (res.RESULT) {
|
|
var languageList = res.DATA.rel;
|
|
$('#LanguageID').html(createOptions(languageList, 'LanguageID', 'LanguageName', false)).on('change', function () {
|
|
|
|
});
|
|
|
|
}
|
|
});
|
|
},
|
|
|
|
/**
|
|
* 上傳LOGO附件
|
|
* @param {Array} files 當前文件
|
|
* @param {String} parentid
|
|
* @param {String} inputid file input id
|
|
*/
|
|
fnUploadLogo = function (files, parentid, inputid) {
|
|
var option = {};
|
|
option.limit = 1;
|
|
option.type = 'one';
|
|
option.theme = 'dragdropbox1';
|
|
option.input = $('#LogoFile');
|
|
option.parentid = parentid;
|
|
option.extensions = ['jpg', 'jpeg', 'png', 'bmp', 'gif', 'png', 'svg'];
|
|
option.folder = 'Exhibition';
|
|
|
|
if (files) {
|
|
option.files = files;
|
|
}
|
|
fnUploadRegister(option);
|
|
},
|
|
|
|
/**
|
|
* 展覽主類別下拉選單
|
|
*/
|
|
fnMainCategoryDrop = function () {
|
|
return g_api.ConnectLite(canDo.ProgramId, "QueryExhibMainCategoryList", {
|
|
|
|
LanguageID: $("#LanguageID").val()
|
|
|
|
},
|
|
function (res) {
|
|
|
|
if (res.RESULT) {
|
|
var saCategoryList = res.DATA.rel;
|
|
//var sOptionHtml = createOptions(saCategoryList, 'CategoryID', 'CategoryName', false);
|
|
|
|
var sOptionHtml = createOptGroup(saCategoryList, 'CategoryID', 'CategoryName', '', false);
|
|
|
|
$('#MainCategoryID').html(sOptionHtml);
|
|
}
|
|
});
|
|
},
|
|
|
|
/**
|
|
* 展覽子類別下拉選單
|
|
*/
|
|
fnSubCategoryDrop = function () {
|
|
|
|
var Selected = [];
|
|
Selected = $('#SubCategoryID').val();
|
|
|
|
return g_api.ConnectLite(canDo.ProgramId, "QueryExhibSubCategoryList", {
|
|
|
|
LanguageID: $("#LanguageID").val(),
|
|
ParentIDs: JSON.stringify($('#MainCategoryID').val())
|
|
|
|
},
|
|
function (res) {
|
|
|
|
if (res.RESULT) {
|
|
var saCategoryList = res.DATA.rel;
|
|
//var sOptionHtml = createOptions(saCategoryList, 'CategoryID', 'CategoryName', false);
|
|
|
|
var sOptionHtml = createOptGroup(saCategoryList, 'CategoryID', 'CategoryName', '', false);
|
|
$('#SubCategoryID').html(sOptionHtml);
|
|
$('#SubCategoryID').val(Selected);
|
|
$('#SubCategoryID').trigger('change');
|
|
|
|
}
|
|
});
|
|
},
|
|
|
|
/**
|
|
* 獲取洲別資料
|
|
*/
|
|
fnGetRegoin = function () {
|
|
|
|
var result = '';
|
|
|
|
return g_api.ConnectLite(canDo.ProgramId, "QueryRegionList", {
|
|
|
|
LangType: $('#LanguageID').val(),
|
|
|
|
},
|
|
|
|
function (res) {
|
|
|
|
if (res.RESULT) {
|
|
|
|
RegionMap.clear();
|
|
var resultList = res.DATA.rel;
|
|
|
|
$.each(resultList, function (index, value) {
|
|
|
|
RegionMap.set(value.RegionID, value);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
return result;
|
|
|
|
},
|
|
|
|
/**
|
|
* 主辦廠商洲別選單
|
|
*/
|
|
fnOrgRegionDrop = function () {
|
|
|
|
if (RegionMap.size > 0) {
|
|
|
|
var arrRegions = Array.from(RegionMap.values());
|
|
|
|
var sOptionHtml = createOptGroup(arrRegions, 'RegionID', 'RegionName', '', false);
|
|
$('#OrgRegionID').html(sOptionHtml);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
/**
|
|
* 展館洲別選單
|
|
*/
|
|
fnVenueRegionDrop = function () {
|
|
|
|
if (RegionMap.size > 0) {
|
|
|
|
var arrRegions = Array.from(RegionMap.values());
|
|
|
|
var sOptionHtml = createOptGroup(arrRegions, 'RegionID', 'RegionName', '', false);
|
|
$('#VenueRegionID').html(sOptionHtml);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
/**
|
|
* 主辦廠商國家選單
|
|
*/
|
|
fnOrgCountryDrop = function () {
|
|
|
|
return g_api.ConnectLite(canDo.ProgramId, "QueryCountryList", {
|
|
|
|
LangType: $('#LanguageID').val(),
|
|
RegionID: $('#OrgRegionID').val(),
|
|
|
|
},
|
|
|
|
function (res) {
|
|
|
|
if (res.RESULT) {
|
|
|
|
var resultList = res.DATA.rel;
|
|
|
|
var sOptionHtml = createOptGroup(resultList, 'CountryID', 'CountryName', '', false);
|
|
$('#OrgCountryID').html(sOptionHtml);
|
|
}
|
|
|
|
}
|
|
);
|
|
|
|
},
|
|
|
|
/**
|
|
* 展館國家選單
|
|
*/
|
|
fnVenueCountryDrop = function () {
|
|
|
|
return g_api.ConnectLite(canDo.ProgramId, "QueryCountryList", {
|
|
|
|
LangType: $('#LanguageID').val(),
|
|
RegionID: $('#VenueRegionID').val(),
|
|
|
|
},
|
|
|
|
function (res) {
|
|
|
|
if (res.RESULT) {
|
|
|
|
var resultList = res.DATA.rel;
|
|
|
|
var sOptionHtml = createOptGroup(resultList, 'CountryID', 'CountryName', '', false);
|
|
$('#VenueCountryID').html(sOptionHtml);
|
|
}
|
|
|
|
}
|
|
);
|
|
|
|
|
|
},
|
|
|
|
/**
|
|
* 主辦廠商城市選單
|
|
*/
|
|
fnOrgCityDrop = function () {
|
|
|
|
return g_api.ConnectLite(canDo.ProgramId, "QueryCityList", {
|
|
|
|
LangType: $('#LanguageID').val(),
|
|
CountryID: $('#OrgCountryID').val(),
|
|
|
|
},
|
|
|
|
function (res) {
|
|
|
|
if (res.RESULT) {
|
|
|
|
var resultList = res.DATA.rel;
|
|
|
|
var sOptionHtml = createOptGroup(resultList, 'CityID', 'CityName', '', false);
|
|
$('#OrgCityID').html(sOptionHtml);
|
|
}
|
|
|
|
}
|
|
);
|
|
|
|
},
|
|
|
|
/**
|
|
* 展館城市選單
|
|
*/
|
|
fnVenueCityDrop = function () {
|
|
|
|
return g_api.ConnectLite(canDo.ProgramId, "QueryCityList", {
|
|
|
|
LangType: $('#LanguageID').val(),
|
|
CountryID: $('#VenueCountryID').val(),
|
|
|
|
},
|
|
|
|
function (res) {
|
|
|
|
if (res.RESULT) {
|
|
|
|
var resultList = res.DATA.rel;
|
|
|
|
var sOptionHtml = createOptGroup(resultList, 'CityID', 'CityName', '', false);
|
|
$('#VenueCityID').html(sOptionHtml);
|
|
}
|
|
|
|
}
|
|
);
|
|
|
|
},
|
|
|
|
/**
|
|
* 設定主辦廠商選單
|
|
*/
|
|
fnSetOrganizerDrop = function (rsOrganizerIDs, rsOrganizerList) {
|
|
|
|
|
|
$.each(rsOrganizerList, function (index, value) {
|
|
|
|
OrganizerMap.set(value.OrganizerID, value);
|
|
});
|
|
|
|
var selected = [...new Set(rsOrganizerIDs)];
|
|
|
|
var sOptionHtml = createOptGroup(rsOrganizerList, 'OrganizerID', 'OrganizerName', '', false);
|
|
$('#OrganizerID').html(sOptionHtml);
|
|
$('#OrganizerID').val(selected);
|
|
|
|
},
|
|
|
|
/**
|
|
* 主辦廠商選單
|
|
*/
|
|
fnOrganizerDrop = function () {
|
|
|
|
var resultMap = new Map();
|
|
var selected = $('#OrganizerID').val();
|
|
|
|
if (selected) {
|
|
|
|
$.each(selected, function (index, value) {
|
|
|
|
resultMap.set(value, OrganizerMap.get(value));
|
|
|
|
});
|
|
|
|
}
|
|
|
|
return g_api.ConnectLite(canDo.ProgramId, "QueryOrganizerList", {
|
|
|
|
LangType: $('#LanguageID').val(),
|
|
CityID: $('#VenueCityID').val(),
|
|
|
|
},
|
|
|
|
function (res) {
|
|
|
|
if (res.RESULT) {
|
|
|
|
var newResult = res.DATA.rel;
|
|
|
|
$.each(newResult, function (index, value) {
|
|
|
|
resultMap.set(value.OrganizationID, value);
|
|
|
|
});
|
|
|
|
fnSetOrganizerDrop(selected, Array.from(resultMap.values()));
|
|
|
|
}
|
|
|
|
}
|
|
);
|
|
|
|
},
|
|
|
|
/**
|
|
* 設定展館選單
|
|
*/
|
|
fnSetVenueDrop = function (rsVenueIDs, rsVenueList) {
|
|
|
|
|
|
$.each(rsVenueList, function (index, value) {
|
|
|
|
VenueMap.set(value.VenueID, value);
|
|
});
|
|
|
|
var selected = [...new Set(rsVenueIDs)];
|
|
|
|
var sOptionHtml = createOptGroup(rsVenueList, 'VenueID', 'VenueName', '', false);
|
|
$('#VenueID').html(sOptionHtml);
|
|
$('#VenueID').val(selected);
|
|
|
|
},
|
|
|
|
/**
|
|
* 展館選單
|
|
*/
|
|
fnVenueDrop = function () {
|
|
|
|
var resultMap = new Map();
|
|
var selected = $('#VenueID').val();
|
|
|
|
if (selected) {
|
|
|
|
$.each(selected, function (index, value) {
|
|
|
|
resultMap.set(value, VenueMap.get(value));
|
|
|
|
});
|
|
|
|
}
|
|
|
|
return g_api.ConnectLite(canDo.ProgramId, "QueryVenueList", {
|
|
|
|
LangType: $('#LanguageID').val(),
|
|
CityID: $('#VenueCityID').val(),
|
|
|
|
},
|
|
|
|
function (res) {
|
|
|
|
if (res.RESULT) {
|
|
|
|
var newResult = res.DATA.rel;
|
|
|
|
$.each(newResult, function (index, value) {
|
|
|
|
resultMap.set(value.VenueID, value);
|
|
|
|
});
|
|
|
|
fnSetVenueDrop(selected, Array.from(resultMap.values()));
|
|
|
|
}
|
|
|
|
}
|
|
);
|
|
|
|
},
|
|
|
|
/**
|
|
* 週期選單
|
|
*/
|
|
fnFrequencyDrop = function () {
|
|
|
|
return g_api.ConnectLite(canDo.ProgramId, "QueryFrequencyList", {
|
|
|
|
LanguageID: $('#LanguageID').val()
|
|
|
|
},
|
|
|
|
function (res) {
|
|
if (res.RESULT) {
|
|
|
|
var frequencyList = res.DATA.rel;
|
|
$('#Frequency').html(createOptions(frequencyList, 'ArgumentID', 'ArgumentValue', false));
|
|
|
|
}
|
|
});
|
|
|
|
|
|
},
|
|
|
|
/**
|
|
* 展覽狀態選單
|
|
*/
|
|
fnShowStatusDrop = function () {
|
|
|
|
return g_api.ConnectLite(canDo.ProgramId, "QueryShowStatusList", {
|
|
|
|
LanguageID: $('#LanguageID').val()
|
|
|
|
},
|
|
|
|
function (res) {
|
|
if (res.RESULT) {
|
|
|
|
var statusList = res.DATA.rel;
|
|
$('#ExhibStatus').html(createOptions(statusList, 'ArgumentID', 'ArgumentValue', false));
|
|
|
|
}
|
|
});
|
|
|
|
|
|
},
|
|
|
|
fnResetVirtualEventLink = function (status) {
|
|
|
|
$('#VirtualEventLink').prop('disabled', true);
|
|
|
|
if (status === 'Y') {
|
|
$('#VirtualEventLink').prop('disabled', false);
|
|
}
|
|
|
|
},
|
|
|
|
/**
|
|
* 設定排序下拉選單
|
|
*/
|
|
fnSetOrderByValueDrop = function () {
|
|
|
|
return g_api.ConnectLite(canDo.ProgramId, canDo._api.getcout, {
|
|
|
|
ExhibitionID: $("#ExhibitionID").val(),
|
|
|
|
},
|
|
|
|
function (res) {
|
|
if (res.RESULT) {
|
|
var iCount = res.DATA.rel;
|
|
if (canDo.action === 'add') {
|
|
iCount++;
|
|
}
|
|
$('#OrderByValue').html(createOptions(iCount));
|
|
if (canDo.action === 'add') {
|
|
$('#OrderByValue').val(iCount);
|
|
}
|
|
}
|
|
});
|
|
},
|
|
|
|
/**
|
|
* 停用展覽資訊
|
|
*/
|
|
fnDisableExhibInfo = function (status) {
|
|
|
|
$('#btnClearInfo').prop('disabled', true);
|
|
$('#btnSaveInfo').prop('disabled', true);
|
|
$('#btnDeleteInfo').prop('disabled', true);
|
|
$('#Year').prop('disabled', true);
|
|
$('#StartDate').prop('disabled', true);
|
|
$('#EndDate').prop('disabled', true);
|
|
|
|
ue_Intro.disable();
|
|
ue_Profile.disable();
|
|
ue_Detail.disable();
|
|
|
|
if (status === 'false') {
|
|
|
|
$('#btnClearInfo').prop('disabled', false);
|
|
$('#btnSaveInfo').prop('disabled', false);
|
|
$('#btnDeleteInfo').prop('disabled', false);
|
|
|
|
$('#Year').prop('disabled', false);
|
|
$('#StartDate').prop('disabled', false);
|
|
$('#EndDate').prop('disabled', false);
|
|
|
|
ue_Intro.enable();
|
|
ue_Profile.enable();
|
|
ue_Detail.enable();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
/**
|
|
* 停用統計資訊
|
|
*/
|
|
fnDisableStatistic = function (status) {
|
|
|
|
$('btnSaveStat').prop('disabled', true);
|
|
$('btnClearStat').prop('disabled', true);
|
|
$('btnDeleteStat').prop('disabled', true);
|
|
|
|
$('.addStatRecord').prop('disabled', true);
|
|
|
|
if (status === 'false') {
|
|
|
|
$('btnSaveStat').prop('disabled', false);
|
|
$('btnClearStat').prop('disabled', false);
|
|
$('btnDeleteStat').prop('disabled', false);
|
|
|
|
$('.addStatRecord').prop('disabled', false);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
/**
|
|
* 停用多媒體資訊
|
|
*/
|
|
fnDisableMedia = function (status) {
|
|
|
|
$('btnSaveMedia').prop('disabled', true);
|
|
$('btnClearMedia').prop('disabled', true);
|
|
$('btnDeleteMedia').prop('disabled', true);
|
|
|
|
$('.addMediaRecord').prop('disabled', true);
|
|
|
|
if (status === 'false') {
|
|
|
|
$('btnSaveMedia').prop('disabled', false);
|
|
$('btnClearMedia').prop('disabled', false);
|
|
$('btnDeleteMedia').prop('disabled', false);
|
|
|
|
$('.addMediaRecord').prop('disabled', false);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
/**
|
|
* 清除展覽資訊
|
|
*/
|
|
fnResetExhibInfo = function () {
|
|
|
|
ue_Intro.ready(function () {
|
|
ue_Intro.setContent("");
|
|
});
|
|
|
|
ue_Profile.ready(function () {
|
|
ue_Profile.setContent("");
|
|
});
|
|
|
|
ue_Detail.ready(function () {
|
|
ue_Detail.setContent("");
|
|
});
|
|
|
|
},
|
|
|
|
/**
|
|
* 處存展覽資訊
|
|
*/
|
|
fnSaveExhibInfo = function () {
|
|
|
|
var exhibinfo = {};
|
|
|
|
exhibinfo.ExhibitionInfoID = currentExhibInfoID;
|
|
exhibinfo.ExhibitionID = currentExhibitionID;
|
|
exhibinfo.LanguageID = $('#LanguageID').val();
|
|
|
|
exhibinfo.Year = $('#Year').val();
|
|
exhibinfo.StartDate = $('#StartDate').val();
|
|
exhibinfo.EndDate = $('#EndDate').val();
|
|
|
|
ue_Intro.ready(function () {
|
|
|
|
exhibinfo.Intro = ue_Intro.getContent();
|
|
|
|
});
|
|
|
|
ue_Profile.ready(function () {
|
|
|
|
exhibinfo.Profile = ue_Profile.getContent();
|
|
|
|
});
|
|
|
|
ue_Detail.ready(function () {
|
|
|
|
exhibinfo.Detail = ue_Detail.getContent();
|
|
|
|
});
|
|
|
|
return g_api.ConnectLite(canDo.ProgramId, "SaveExhibInfo", exhibinfo, function (res) {
|
|
if (res.RESULT) {
|
|
var oRes = res.DATA.rel;
|
|
|
|
if (oRes) {
|
|
|
|
currentExhibInfoID = oRes.ExhibitionInfoID;
|
|
showMsg(i18next.t("message.Modify_Success"), 'success'); //╠message.Insert_Success⇒新增成功╣
|
|
|
|
}
|
|
|
|
}
|
|
else {
|
|
showMsg(i18next.t("message.Modify_Failed") + '<br>' + res.MSG, 'error');// ╠message.Insert_Failed⇒新增失敗╣
|
|
}
|
|
}, function () {
|
|
showMsg(i18next.t("message.Modify_Error"), 'error');// ╠message.Insert_Error⇒新增資料異常╣
|
|
});
|
|
|
|
|
|
},
|
|
|
|
/**
|
|
* 獲取展覽資訊
|
|
*/
|
|
fnGetExhibInfo = function (data) {
|
|
|
|
fnResetExhibInfo();
|
|
|
|
return g_api.ConnectLite(canDo.ProgramId, "QueryExhibInfo", {
|
|
|
|
ExhibitionID: currentExhibitionID,
|
|
LanguageID: $('#LanguageID').val(),
|
|
Year: $('#Year').val()
|
|
|
|
},
|
|
function (res) {
|
|
|
|
if (res.RESULT) {
|
|
var rsExhibInfo = res.DATA.rel;
|
|
|
|
if (rsExhibInfo) {
|
|
|
|
currentExhibInfoID = rsExhibInfo.ExhibitionInfoID;
|
|
|
|
if (rsExhibInfo.StartDate) {
|
|
var start_date = rsExhibInfo.StartDate.split('T');
|
|
$('#StartDate').val(start_date[0]);
|
|
}
|
|
|
|
if (rsExhibInfo.EndDate) {
|
|
var end_date = rsExhibInfo.EndDate.split('T');
|
|
$('#EndDate').val(end_date[0]);
|
|
}
|
|
|
|
ue_Intro.ready(function () {
|
|
|
|
if (rsExhibInfo.Intro) {
|
|
ue_Intro.setContent(rsExhibInfo.Intro);
|
|
}
|
|
|
|
});
|
|
|
|
ue_Profile.ready(function () {
|
|
|
|
if (rsExhibInfo.Profile) {
|
|
ue_Profile.setContent(rsExhibInfo.Profile);
|
|
}
|
|
|
|
});
|
|
|
|
ue_Detail.ready(function () {
|
|
|
|
if (rsExhibInfo.Detail) {
|
|
ue_Detail.setContent(rsExhibInfo.Detail);
|
|
}
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
currentExhibInfoID = "";
|
|
var current_date = new Date().toJSON().slice(0, 10);
|
|
|
|
$('#StartDate').val(current_date);
|
|
$('#EndDate').val(current_date);
|
|
|
|
ue_Intro.ready(function () {
|
|
ue_Intro.setContent("");
|
|
});
|
|
|
|
ue_Profile.ready(function () {
|
|
ue_Profile.setContent("");
|
|
});
|
|
|
|
ue_Detail.ready(function () {
|
|
ue_Detail.setContent("");
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
});
|
|
},
|
|
|
|
/**
|
|
* 綁定統計資料
|
|
*/
|
|
fnBindStatData = function () {
|
|
|
|
var sKeysHtml = '';
|
|
var idx = 0;
|
|
|
|
currentStatMap.forEach(function (item, key) {
|
|
|
|
idx += 1;
|
|
|
|
sKeysHtml += '<tr data-id="' + key + '">\
|
|
<td class="wcenter">' + idx + '</td>\
|
|
<td><input type="number" min="1900" max="9999" step="1" data-input="Year" class="form-control w100p" value="' + item.Year + '"></td>\
|
|
<td><input type="number" min="0" step="0.01" data-input="ExhibSize" class="form-control w100p" value="' + (item.ExhibSize || '0.00') + '"></td>\
|
|
<td><input type="number" min="0" step="1" data-input="VisitorCount" class="form-control w100p" value="' + (item.VisitorCount || '0') + '"></td>\
|
|
<td><input type="number" min="0" step="1" data-input="IntVisitorCount" class="form-control w100p" value="' + (item.IntVisitorCount || '0') + '"></td>\
|
|
<td><input type="number" min="0" step="1" data-input="ExhibitorCount" class="form-control w100p" value="' + (item.ExhibitorCount || '0') + '"></td>\
|
|
<td class="wcenter">\
|
|
<i class="glyphicon glyphicon-trash" data-value="' + key + '" title="Del"></i>\
|
|
</td>\
|
|
</tr>';
|
|
|
|
})
|
|
|
|
$('#stat_box').html(sKeysHtml).find('.glyphicon-trash').on('click', function () {
|
|
|
|
var sId = $(this).attr('data-value');
|
|
|
|
currentStatMap.delete(sId);
|
|
fnBindStatData();
|
|
});
|
|
|
|
$('#stat_box [data-input]').on('change click', function () {
|
|
var sKey = $(this).attr('data-input'),
|
|
sId = $(this).parents('tr').attr('data-id'),
|
|
sVal = this.value;
|
|
|
|
var item = currentStatMap.get(sId);
|
|
item[sKey] = sVal;
|
|
|
|
currentStatMap.set(sId, item);
|
|
|
|
});
|
|
|
|
|
|
},
|
|
|
|
/**
|
|
* 獲取展覽統計
|
|
*/
|
|
fnGetStatisticList = function (data) {
|
|
|
|
return g_api.ConnectLite(canDo.ProgramId, "QueryStatisticsList", {
|
|
|
|
ExhibitionID: currentExhibitionID,
|
|
|
|
},
|
|
function (res) {
|
|
|
|
if (res.RESULT) {
|
|
var rsStatisticsList = res.DATA.rel;
|
|
|
|
if (rsStatisticsList) {
|
|
|
|
$.each(rsStatisticsList, function (index, value) {
|
|
|
|
currentStatMap.set(value.StatisticsID, value);
|
|
|
|
});
|
|
|
|
fnBindStatData();
|
|
|
|
}
|
|
|
|
}
|
|
});
|
|
},
|
|
|
|
/**
|
|
* 處存展覽統計
|
|
*/
|
|
fnSaveStat = function () {
|
|
|
|
var stats_arr = Array.from(currentStatMap.values());
|
|
|
|
return g_api.ConnectLite(canDo.ProgramId, "SaveStat", {
|
|
|
|
Stats: JSON.stringify(stats_arr)
|
|
|
|
}, function (res) {
|
|
if (res.RESULT) {
|
|
var oRes = res.DATA.rel;
|
|
|
|
if (oRes) {
|
|
|
|
showMsg(i18next.t("message.Modify_Success"), 'success'); //╠message.Insert_Success⇒新增成功╣
|
|
|
|
}
|
|
|
|
}
|
|
else {
|
|
showMsg(i18next.t("message.Modify_Failed") + '<br>' + res.MSG, 'error');// ╠message.Insert_Failed⇒新增失敗╣
|
|
}
|
|
}, function () {
|
|
showMsg(i18next.t("message.Modify_Error"), 'error');// ╠message.Insert_Error⇒新增資料異常╣
|
|
});
|
|
|
|
|
|
},
|
|
|
|
/**
|
|
* 上傳多媒體附件
|
|
* @param {Array} files 當前文件
|
|
* @param {String} parentid
|
|
* @param {String} inputid file input id
|
|
*/
|
|
fnUploadMediaFile = function (files, parentid) {
|
|
var fileInput = document.getElementById("MediaFile");
|
|
|
|
parentid = currentExhibitionID;
|
|
|
|
$("#fileParent").html("");
|
|
$("#fileParent").append(fileInput);
|
|
var option = {};
|
|
option.input = $('#MediaFile');
|
|
option.extensions = ['jpg', 'jpeg', 'png', 'bmp', 'gif', 'png'];
|
|
option.theme = 'dragdropbox';
|
|
option.folder = 'Exhibition';
|
|
option.type = 'list';
|
|
option.parentid = parentid;
|
|
if (files) {
|
|
option.files = files;
|
|
// 顯示圖標
|
|
//option.showThumbs = true;
|
|
} else {
|
|
// 隱藏圖標
|
|
//option.showThumbs = false;
|
|
}
|
|
fnUploadRegister(option);
|
|
},
|
|
|
|
/**
|
|
* 綁定多媒體資料
|
|
*/
|
|
fnBindMediaListData = function () {
|
|
|
|
var sKeysHtml = '';
|
|
var idx = 0;
|
|
|
|
MediaListMap.forEach(function (item, key) {
|
|
|
|
idx += 1;
|
|
|
|
sKeysHtml += '<tr data-id="' + key + '">\
|
|
<td class="wcenter">' + idx + '</td>\
|
|
<td><input type="text" data-input="MediaName" class="form-control w100p" value="' + item.MediaName + '"></td>\
|
|
<td><input type="text" data-input="Link" class="form-control w100p" value="' + (item.Link || '') + '"></td>\
|
|
<td class="wcenter">\
|
|
<i class="glyphicon glyphicon-trash" data-value="' + key + '" title="Del"></i>\
|
|
</td>\
|
|
</tr>';
|
|
|
|
})
|
|
|
|
$('#media_box').html(sKeysHtml).find('.glyphicon-trash').on('click', function () {
|
|
|
|
var sId = $(this).attr('data-value');
|
|
|
|
MediaListMap.delete(sId);
|
|
fnBindMediaListData();
|
|
});
|
|
|
|
$('#media_box [data-input]').on('change click', function () {
|
|
var sKey = $(this).attr('data-input'),
|
|
sId = $(this).parents('tr').attr('data-id'),
|
|
sVal = this.value;
|
|
|
|
var item = MediaListMap.get(sId);
|
|
item[sKey] = sVal;
|
|
|
|
MediaListMap.set(sId, item);
|
|
|
|
});
|
|
|
|
},
|
|
|
|
fnGetMediaFile = function () {
|
|
|
|
fnGetUploadFiles(currentExhibitionID, fnUploadMediaFile, 'MediaFile');
|
|
|
|
},
|
|
|
|
fnGetMediaList = function (data) {
|
|
|
|
return g_api.ConnectLite(canDo.ProgramId, "QueryMediaList", {
|
|
|
|
ExhibitionID: currentExhibitionID,
|
|
|
|
},
|
|
function (res) {
|
|
|
|
if (res.RESULT) {
|
|
var rsMediaList = res.DATA.rel;
|
|
|
|
if (rsMediaList) {
|
|
|
|
$.each(rsMediaList, function (index, value) {
|
|
|
|
MediaListMap.set(value.MediaID, value);
|
|
|
|
});
|
|
|
|
fnBindMediaListData();
|
|
|
|
}
|
|
|
|
}
|
|
});
|
|
|
|
},
|
|
|
|
/**
|
|
* 處存多媒體
|
|
*/
|
|
fnSaveMediaList = function () {
|
|
|
|
// save media list
|
|
var mediaList = Array.from(MediaListMap.values());
|
|
|
|
return g_api.ConnectLite(canDo.ProgramId, "SaveMediaList", {
|
|
|
|
MediaList: JSON.stringify(mediaList),
|
|
|
|
}, function (res) {
|
|
if (res.RESULT) {
|
|
var oRes = res.DATA.rel;
|
|
|
|
if (oRes) {
|
|
|
|
showMsg(i18next.t("message.Modify_Success"), 'success'); //╠message.Insert_Success⇒新增成功╣
|
|
|
|
}
|
|
|
|
}
|
|
else {
|
|
showMsg(i18next.t("message.Modify_Failed") + '<br>' + res.MSG, 'error');// ╠message.Insert_Failed⇒新增失敗╣
|
|
}
|
|
}, function () {
|
|
showMsg(i18next.t("message.Modify_Error"), 'error');// ╠message.Insert_Error⇒新增資料異常╣
|
|
});
|
|
|
|
|
|
},
|
|
|
|
createOptGroup = function (list, id, value, label, showid) {
|
|
|
|
list = list || [];
|
|
var Options = [];
|
|
|
|
var intCount = list.length;
|
|
if (intCount > 0) {
|
|
|
|
if (label) {
|
|
Options = [$('<optgroup />', { label: label, html: '' })];
|
|
} else {
|
|
Options = [$('<optgroup />', { label: '', html: '' })];
|
|
}
|
|
|
|
$.each(list, function (idx, obj) {
|
|
|
|
var option = $('<option />', {
|
|
value: $.trim(obj[id]),
|
|
title: $.trim(obj[value]),
|
|
html: (showid ? $.trim(obj[id]) + '-' : '') + $.trim(obj[value])
|
|
});
|
|
|
|
Options.push(option);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
return $('<div />').append(Options).html();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
require(['base', 'select2', 'jsgrid', 'filer', 'cando'], fnPageInit);
|