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.
158 lines
5.8 KiB
158 lines
5.8 KiB
'use strict';
|
|
var fnPageInit = function () {
|
|
var canDo = new CanDo({
|
|
/**
|
|
* 當前程式所有ID名稱集合
|
|
*/
|
|
idKeys: ['OrgID', 'OrganizerID'],
|
|
/**
|
|
* 當前程式所有參數名稱集合
|
|
*/
|
|
paramKeys: ['OrganizerID'],
|
|
/**
|
|
* 客製化驗證規則
|
|
* @param {Object} pargs CanDo 對象
|
|
*/
|
|
validRulesCus: function (pargs) {
|
|
$.validator.addMethod("organizeridrule", function (value) {
|
|
var bRetn = true;
|
|
if (value) {
|
|
g_api.ConnectLite(pargs.ProgramId, pargs._api.getcout,
|
|
{
|
|
OrganizerID: $('#OrganizerID').val(),
|
|
OrganizerName: value
|
|
},
|
|
function (res) {
|
|
if (res.RESULT && res.DATA.rel > 0) {
|
|
bRetn = false;
|
|
}
|
|
}, null, false);
|
|
}
|
|
return bRetn;
|
|
});
|
|
},
|
|
/**
|
|
* 驗證規則
|
|
*/
|
|
validRules: {
|
|
onfocusout: false,
|
|
rules: {
|
|
OrganizerName: { organizeridrule: true },
|
|
},
|
|
messages: {
|
|
OrganizerName: { organizeridrule: i18next.t("message.Data_Repeat") }// ╠message.Data_Repeat⇒此筆資料已建檔╣
|
|
}
|
|
},
|
|
/**
|
|
* 頁面初始化
|
|
* @param {Object} pargs CanDo 對象
|
|
*/
|
|
pageInit: function (pargs) {
|
|
var postArray = [];
|
|
|
|
if (pargs.action === 'upd') {
|
|
//$('#ArgumentClassID,#ArgumentID').prop('disabled', true);
|
|
postArray.push(pargs._getOne());
|
|
}
|
|
postArray.push(fnSetRegionIDDrop());
|
|
|
|
//加載報關類別,加載報價頁簽,加載運輸方式, 加載機場, 加載貨棧場, 加載倉庫
|
|
$.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);
|
|
fnSetCountryIDDrop().done(function () {
|
|
$('#CountryID').val(oRes.CountryID);
|
|
fnSetCityIDDrop().done(function () {
|
|
// $('#CountryID').val(oRes.CountryID);
|
|
$('#CityID').val(oRes.CityID);
|
|
});
|
|
});
|
|
pargs._setFormVal(oRes);
|
|
}
|
|
else {
|
|
pargs._setFormVal(oRes);
|
|
}
|
|
//pargs._setFormVal(oRes);
|
|
// pargs._getPageVal();//緩存頁面值,用於清除
|
|
}
|
|
});
|
|
}
|
|
}),
|
|
/**
|
|
* 設定洲別下拉選單
|
|
* @return {Object} Ajax 物件
|
|
*/
|
|
fnSetRegionIDDrop = function () {
|
|
return g_api.ConnectLite(canDo.QueryPrgId, canDo._api.getlist, {},
|
|
function (res) {
|
|
if (res.RESULT) {
|
|
var saList = res.DATA.rel;
|
|
if (saList.length > 0) {
|
|
var sOptions = createOptions(saList, 'RegionID', 'RegionName',true);
|
|
$('#RegionID').html(sOptions).on('change', function () {
|
|
if ($('#RegionID').val()) {
|
|
$('#CountryID').val("");
|
|
$('#CityID').val("");
|
|
fnSetCountryIDDrop();
|
|
}
|
|
}).select2();
|
|
}
|
|
}
|
|
});
|
|
},
|
|
|
|
/**
|
|
* 國家下拉選單
|
|
* @return {Object} Ajax 物件
|
|
*/
|
|
fnSetCountryIDDrop = function () {
|
|
if ($('#RegionID').val()) {
|
|
var data = {
|
|
OrgID: parent.OrgID,
|
|
RegionID: $('#RegionID').val()
|
|
};
|
|
return g_api.ConnectLite(canDo.QueryPrgId, "QueryCountryList", data,
|
|
function (res) {
|
|
if (res.RESULT) {
|
|
var saList = res.DATA.rel;
|
|
if (saList.length > 0) {
|
|
var sOptions = createOptions(saList, 'CountryID', 'CountryName', true);
|
|
$('#CountryID').html(sOptions).on('change', function () {
|
|
fnSetCityIDDrop();
|
|
$('#CityID').val("");
|
|
}).select2();
|
|
|
|
}
|
|
}
|
|
});
|
|
}
|
|
},
|
|
|
|
/**
|
|
* 城市下拉選單
|
|
* @return {Object} Ajax 物件
|
|
*/
|
|
fnSetCityIDDrop = function () {
|
|
if ($('#CountryID').val()) {
|
|
console.log('city select');
|
|
var data = {
|
|
OrgID: parent.OrgID,
|
|
CountryID: $('#CountryID').val()
|
|
};
|
|
return g_api.ConnectLite(canDo.QueryPrgId, "QueryCityList", data,
|
|
function (res) {
|
|
if (res.RESULT) {
|
|
var saList = res.DATA.rel;
|
|
if (saList.length > 0) {
|
|
$('#CityID').html(createOptions(saList, 'CityID', 'CityName', true)).select2();
|
|
}
|
|
}
|
|
});
|
|
}
|
|
|
|
};
|
|
};
|
|
|
|
require(['base', 'select2', 'jsgrid', 'convetlng', 'cando'], fnPageInit);
|