|
@ -118,7 +118,7 @@ var fnPageInit = function () { |
|
|
$('#VenueID').prop('disabled', true); |
|
|
$('#VenueID').prop('disabled', true); |
|
|
postArray.push(pargs._getOne()); |
|
|
postArray.push(pargs._getOne()); |
|
|
} |
|
|
} |
|
|
postArray.push(fnSetRegionIDdrop()); |
|
|
|
|
|
|
|
|
postArray.push(fnSetRegionIDdrop(), fnSetOrderByValueDrop()); |
|
|
$.whenArray(postArray).done(function (res) { |
|
|
$.whenArray(postArray).done(function (res) { |
|
|
if (pargs.action === 'upd' && res[0].RESULT) { |
|
|
if (pargs.action === 'upd' && res[0].RESULT) { |
|
|
var oRes = res[0].DATA.rel; |
|
|
var oRes = res[0].DATA.rel; |
|
@ -130,12 +130,14 @@ var fnPageInit = function () { |
|
|
$('#CityID').val(oRes.CityID); |
|
|
$('#CityID').val(oRes.CityID); |
|
|
}); |
|
|
}); |
|
|
}); |
|
|
}); |
|
|
}; |
|
|
|
|
|
|
|
|
pargs._setFormVal(oRes); |
|
|
|
|
|
} |
|
|
|
|
|
else { |
|
|
pargs._setFormVal(oRes); |
|
|
pargs._setFormVal(oRes); |
|
|
} |
|
|
} |
|
|
else { |
|
|
|
|
|
pargs._setFormVal(oRes); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
}); |
|
|
}); |
|
|
$('#CountryID').select2(); |
|
|
$('#CountryID').select2(); |
|
|
$('#CityID').select2(); |
|
|
$('#CityID').select2(); |
|
@ -155,7 +157,6 @@ var fnPageInit = function () { |
|
|
if (saList.length > 0) { |
|
|
if (saList.length > 0) { |
|
|
$('#CountryID').html(createOptions(saList, 'CountryID', 'CountryName', true)).on('change', function () { |
|
|
$('#CountryID').html(createOptions(saList, 'CountryID', 'CountryName', true)).on('change', function () { |
|
|
$('#CityID').empty(); |
|
|
$('#CityID').empty(); |
|
|
$('#OrderByValue').empty(); |
|
|
|
|
|
if ($('#CountryID').val()) { |
|
|
if ($('#CountryID').val()) { |
|
|
fnSetCityValueDrop(); |
|
|
fnSetCityValueDrop(); |
|
|
} |
|
|
} |
|
@ -174,12 +175,8 @@ var fnPageInit = function () { |
|
|
function (res) { |
|
|
function (res) { |
|
|
if (res.RESULT) { |
|
|
if (res.RESULT) { |
|
|
var saList = res.DATA.rel; |
|
|
var saList = res.DATA.rel; |
|
|
$('#CityID').html(createOptions(saList, 'CityID', 'CityName', true)).on('change', function () { |
|
|
|
|
|
$('#OrderByValue').empty(); |
|
|
|
|
|
if ($('#CityID').val()) { |
|
|
|
|
|
fnSetOrderByValueDrop(); //若CityID改變,觸發OrderByValue選單
|
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
$('#CityID').html(createOptions(saList, 'CityID', 'CityName', true)); |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
|
}, |
|
|
}, |
|
@ -191,21 +188,240 @@ var fnPageInit = function () { |
|
|
if (res.RESULT) { |
|
|
if (res.RESULT) { |
|
|
var regionList = res.DATA.rel;; |
|
|
var regionList = res.DATA.rel;; |
|
|
$('#RegionID').html(createOptions(regionList, 'RegionID', 'RegionName', true)).on('change', function () { |
|
|
$('#RegionID').html(createOptions(regionList, 'RegionID', 'RegionName', true)).on('change', function () { |
|
|
//$('#CountryID').empty();
|
|
|
|
|
|
|
|
|
$('#CountryID').empty(); |
|
|
$('#CityID').empty(); |
|
|
$('#CityID').empty(); |
|
|
$('#OrderByValue').empty(); |
|
|
|
|
|
fnCountryDrop(); |
|
|
fnCountryDrop(); |
|
|
//if ($('#RegionID').val()) {
|
|
|
|
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
fnSetOrderByValueDrop = function () { |
|
|
|
|
|
return g_api.ConnectLite(canDo.ProgramId, canDo._api.getcout, {}, |
|
|
|
|
|
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); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
}; |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
require(['base', 'cando', 'select2'], fnPageInit);'use strict'; |
|
|
|
|
|
var fnPageInit = function () { |
|
|
|
|
|
|
|
|
|
|
|
//連動選單API參數名稱集合
|
|
|
|
|
|
var canDo = new CanDo({ |
|
|
|
|
|
|
|
|
|
|
|
//當前程式所有ID名稱集合
|
|
|
|
|
|
idKeys: ['OrgID', 'VenueID'], |
|
|
|
|
|
|
|
|
|
|
|
//當前程式所有參數名稱集合
|
|
|
|
|
|
paramKeys: ['VenueID'], |
|
|
|
|
|
|
|
|
|
|
|
/**客製化驗證規則 |
|
|
|
|
|
* @param {Object} pargs CanDo 對象*/ |
|
|
|
|
|
validRulesCus: function (pargs) { |
|
|
|
|
|
$.validator.addMethod("venueidrule", function (value) { |
|
|
|
|
|
var bRetn = true; |
|
|
|
|
|
if (value) { |
|
|
|
|
|
g_api.ConnectLite(pargs.ProgramId, pargs._api.getcout, |
|
|
|
|
|
{ |
|
|
|
|
|
VenueID: value |
|
|
|
|
|
}, |
|
|
|
|
|
function (res) { |
|
|
|
|
|
if (res.RESULT && res.DATA.rel > 0) { |
|
|
|
|
|
bRetn = false; |
|
|
|
|
|
} |
|
|
|
|
|
}, null, false); |
|
|
|
|
|
} |
|
|
|
|
|
return bRetn; |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
$.validator.addMethod("checkEmail", function (value) { |
|
|
|
|
|
let validString = /^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z]+$/; |
|
|
|
|
|
let bRetn = true; |
|
|
|
|
|
if (value.length < 1) { |
|
|
|
|
|
return bRetn |
|
|
|
|
|
} |
|
|
|
|
|
!validString.test(value) ? bRetn = false : bRetn = true; |
|
|
|
|
|
return bRetn |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
$.validator.addMethod("checkWebsite", function (value) { |
|
|
|
|
|
let validString = /^(https|http):\/\/.*$/; |
|
|
|
|
|
let bRetn = true; |
|
|
|
|
|
if (value.length < 1) { |
|
|
|
|
|
return bRetn |
|
|
|
|
|
} |
|
|
|
|
|
!validString.test(value) ? bRetn = false : bRetn = true; |
|
|
|
|
|
return bRetn |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
$.validator.addMethod("venuenamerule", function (value) { |
|
|
|
|
|
var bRetn = true; |
|
|
|
|
|
if (value) { |
|
|
|
|
|
g_api.ConnectLite(pargs.ProgramId, pargs._api.getcout, |
|
|
|
|
|
{ |
|
|
|
|
|
VenueName: value |
|
|
|
|
|
}, |
|
|
|
|
|
function (res) { |
|
|
|
|
|
if (res.RESULT && res.DATA.rel > 0) { |
|
|
|
|
|
bRetn = false; |
|
|
|
|
|
} |
|
|
|
|
|
}, null, false); |
|
|
|
|
|
} |
|
|
|
|
|
return bRetn; |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
// fnCountryDrop(); //若RegionID改變,觸發國家選單
|
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
$.validator.addMethod("venueennamerule", function (value) { |
|
|
|
|
|
var bRetn = true; |
|
|
|
|
|
if (value) { |
|
|
|
|
|
g_api.ConnectLite(pargs.ProgramId, pargs._api.getcout, |
|
|
|
|
|
{ |
|
|
|
|
|
VenueName_EN: value |
|
|
|
|
|
}, |
|
|
|
|
|
function (res) { |
|
|
|
|
|
if (res.RESULT && res.DATA.rel > 0) { |
|
|
|
|
|
bRetn = false; |
|
|
|
|
|
} |
|
|
|
|
|
}, null, false); |
|
|
|
|
|
} |
|
|
|
|
|
return bRetn; |
|
|
|
|
|
}); |
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
//驗證規則
|
|
|
|
|
|
validRules: function (pargs) { |
|
|
|
|
|
return { |
|
|
|
|
|
onfocusout: false, |
|
|
|
|
|
rules: { |
|
|
|
|
|
VenueID: { venueidrule: pargs.action === 'add' ? true : false }, |
|
|
|
|
|
Email: { checkEmail: true }, |
|
|
|
|
|
VenueName: { venuenamerule: pargs.action === 'add' ? true : false }, |
|
|
|
|
|
VenueName_EN: { venueennamerule: pargs.action === 'add' ? true : false }, |
|
|
|
|
|
Website: { checkWebsite: true } |
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
messages: { |
|
|
|
|
|
VenueID: { venueidrule: i18next.t("message.Data_Repeat") }, |
|
|
|
|
|
Email: { checkEmail: i18next.t("message.IncorrectEmail") }, |
|
|
|
|
|
VenueName_EN: { venueennamerule: i18next.t("message.Data_Repeat") }, |
|
|
|
|
|
VenueName: { venuenamerule: i18next.t("message.Data_Repeat") }, |
|
|
|
|
|
Website: { checkWebsite: i18next.t("message.IncorrectWebsite") }, |
|
|
|
|
|
} |
|
|
|
|
|
}; |
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
getOneBack: function (pargs, data) { |
|
|
|
|
|
var oRes = data; |
|
|
|
|
|
oRes.Contactors = $.parseJSON(oRes.Contactors || '[]'); |
|
|
|
|
|
disableInput(pargs._form, '#VenueID', false); |
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
/**頁面初始化 |
|
|
|
|
|
* @param {Object} pargs CanDo 對象*/ |
|
|
|
|
|
pageInit: function (pargs) { |
|
|
|
|
|
var postArray = []; |
|
|
|
|
|
if (pargs.action === 'upd') { |
|
|
|
|
|
$('#VenueID').prop('disabled', true); |
|
|
|
|
|
postArray.push(pargs._getOne()); |
|
|
|
|
|
} |
|
|
|
|
|
postArray.push(fnSetRegionIDdrop(), fnSetOrderByValueDrop()); |
|
|
|
|
|
$.whenArray(postArray).done(function (res) { |
|
|
|
|
|
if (pargs.action === 'upd' && res[0].RESULT) { |
|
|
|
|
|
var oRes = res[0].DATA.rel; |
|
|
|
|
|
if (oRes.RegionID) { |
|
|
|
|
|
$('#RegionID').val(oRes.RegionID); |
|
|
|
|
|
fnCountryDrop().done(function () { |
|
|
|
|
|
$('#CountryID').val(oRes.CountryID); |
|
|
|
|
|
fnSetCityValueDrop().done(function () { |
|
|
|
|
|
$('#CityID').val(oRes.CityID); |
|
|
|
|
|
}); |
|
|
|
|
|
}); |
|
|
|
|
|
pargs._setFormVal(oRes); |
|
|
|
|
|
} |
|
|
|
|
|
else { |
|
|
|
|
|
pargs._setFormVal(oRes); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
}); |
|
|
|
|
|
//$('#CountryID').select2();
|
|
|
|
|
|
//$('#CityID').select2();
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
}), |
|
|
|
|
|
|
|
|
|
|
|
//國家下拉選單
|
|
|
|
|
|
fnCountryDrop = function () { |
|
|
|
|
|
|
|
|
|
|
|
return g_api.ConnectLite(canDo.ProgramId, "GetCountry", { |
|
|
|
|
|
RegionID: $('#RegionID').val() |
|
|
|
|
|
}, //依據所選擇的洲別顯示相對應的國家選單
|
|
|
|
|
|
function (res) { |
|
|
|
|
|
if (res.RESULT) { |
|
|
|
|
|
|
|
|
|
|
|
var saList = res.DATA.rel; |
|
|
|
|
|
console.log(saList); |
|
|
|
|
|
if (saList.length > 0) { |
|
|
|
|
|
$('#CountryID').html(createOptions(saList, 'CountryID', 'CountryName', true)).on('change', function () { |
|
|
|
|
|
$('#CityID').empty(); |
|
|
|
|
|
if ($('#CountryID').val()) { |
|
|
|
|
|
fnSetCityValueDrop(); |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
//城市下拉選單
|
|
|
|
|
|
fnSetCityValueDrop = function () { |
|
|
|
|
|
return g_api.ConnectLite(canDo.ProgramId, "GetCity", |
|
|
|
|
|
{ CountryID: $("#CountryID").val() }, //依據所選擇的國家顯示相對應的城市選單
|
|
|
|
|
|
function (res) { |
|
|
|
|
|
if (res.RESULT) { |
|
|
|
|
|
var saList = res.DATA.rel; |
|
|
|
|
|
console.log(saList); |
|
|
|
|
|
$('#CityID').html(createOptions(saList, 'CityID', 'CityName', true)); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
//洲別下拉選單
|
|
|
|
|
|
fnSetRegionIDdrop = function () { |
|
|
|
|
|
return g_api.ConnectLite(canDo.ProgramId, "GetRegion", {}, |
|
|
|
|
|
function (res) { |
|
|
|
|
|
if (res.RESULT) { |
|
|
|
|
|
var regionList = res.DATA.rel;; |
|
|
|
|
|
$('#RegionID').html(createOptions(regionList, 'RegionID', 'RegionName', true)).on('change', function () { |
|
|
|
|
|
$('#CountryID').empty(); |
|
|
|
|
|
$('#CityID').empty(); |
|
|
|
|
|
if ($('#RegionID').val()) { |
|
|
|
|
|
$('#CountryID').val(""); |
|
|
|
|
|
fnCountryDrop(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
fnSetOrderByValueDrop = function () { |
|
|
fnSetOrderByValueDrop = function () { |
|
|
return g_api.ConnectLite(canDo.ProgramId, canDo._api.getcout, { CityID: $("#CityID").val() }, |
|
|
|
|
|
|
|
|
return g_api.ConnectLite(canDo.ProgramId, canDo._api.getcout, {}, |
|
|
function (res) { |
|
|
function (res) { |
|
|
if (res.RESULT) { |
|
|
if (res.RESULT) { |
|
|
|
|
|
|
|
|