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.
2197 lines
104 KiB
2197 lines
104 KiB
'use strict';
|
|
var canDo;
|
|
var oIframe = null;
|
|
var saOtherOrderQuestion = [];
|
|
var curPlan = {};
|
|
var oGrid = null;
|
|
var saPlan = [];
|
|
var oAdditionalServices = {};
|
|
var saRegionList = [];
|
|
var copyFlag = null;
|
|
var fnPageInit = function () {
|
|
var sLang = g_ul.GetLang(),
|
|
canDo = new CanDo({
|
|
/**
|
|
* 當前程式所有ID名稱集合
|
|
*/
|
|
idKeys: ['OrgID', 'ServiceID', 'LangID'],
|
|
/**
|
|
* 當前程式所有參數名稱集合
|
|
*/
|
|
paramKeys: ['ServiceID', 'LangID'],
|
|
/**
|
|
* 查詢當前資料
|
|
* @param {Object} pargs CanDo 對象
|
|
* @param {Object} data 當前資料實體
|
|
*/
|
|
getOneBack: function (pargs, data) {
|
|
var oRes = data;
|
|
oRes.PPTimes = $.parseJSON(oRes.PPTimes || '[]');
|
|
oRes.FQAs = $.parseJSON(oRes.FQAs || '[]');
|
|
oRes.OrderQuestions = $.parseJSON(oRes.OrderQuestions || '[]');
|
|
oRes.OtherDetials = $.parseJSON(oRes.OtherDetials || '[]');
|
|
oRes.SuitPlace = $.parseJSON(oRes.SuitPlace || '[]');
|
|
disableInput(pargs._form, '#ServicesNo,#SupplierID,#LangID', false);
|
|
|
|
|
|
|
|
$('#Toolbar_Leave').before($('<input />', {
|
|
'class': 'btn-custom orange', 'style': 'display:none;', 'type': 'button', 'id': 'Toolbar_Copy', 'value': '複製', click: function () {
|
|
|
|
fnCopy();
|
|
|
|
|
|
}
|
|
}));
|
|
|
|
},
|
|
/**
|
|
* 客製化驗證規則
|
|
* @param {Object} pargs CanDo 對象
|
|
*/
|
|
validRulesCus: function (pargs) {
|
|
//$.validator.addMethod("compardatetime", function (value, element, parms) {
|
|
// if (new Date(value) <= new Date($('#LaunchDateE').val())) {
|
|
// return false;
|
|
// }
|
|
// return true;
|
|
//});
|
|
|
|
$.validator.addMethod("taxnumberrequired", function (value, element, parms) {
|
|
if (value === '') {
|
|
return false;
|
|
}
|
|
return true;
|
|
});
|
|
$.validator.addMethod("taxnumberlen", function (value) {
|
|
if (value !== '' && value.length != 8) {
|
|
return false;
|
|
}
|
|
return true;
|
|
});
|
|
$.validator.addMethod("companynamerequired", function (value, element, parms) {
|
|
if (value === '') {
|
|
return false;
|
|
}
|
|
return true;
|
|
});
|
|
$.validator.addMethod("taxnumberrule", function (value) {
|
|
var bRetn = true;
|
|
if (value) {
|
|
g_api.ConnectLite(pargs.ProgramId, pargs._api.getcout,
|
|
{
|
|
SupplierID: pargs.ids.SupplierID,
|
|
LangType: pargs.ids.LangType,
|
|
TaxNumber: value
|
|
},
|
|
function (res) {
|
|
if (res.RESULT && res.DATA.rel > 0) {
|
|
bRetn = false;
|
|
}
|
|
}, null, false);
|
|
}
|
|
return bRetn;
|
|
});
|
|
},
|
|
/**
|
|
* 驗證規則
|
|
*/
|
|
validRules: {
|
|
//若是換頁新增會出錯,必須驗證隱藏的tab
|
|
//ignore: 'disabled',
|
|
onfocusout: false,
|
|
rules: {
|
|
Email: {
|
|
email: true
|
|
},
|
|
TaxNumber: {
|
|
taxnumberlen: true,
|
|
taxnumberrule: true
|
|
|
|
}
|
|
},
|
|
messages: {
|
|
Email: i18next.t("message.IncorrectEmail"),// ╠message.IncorrectEmail⇒郵箱格式不正確╣
|
|
TaxNumber: {
|
|
taxnumberlen: i18next.t("message.UniCodeLength"),// ╠message.UniCodeLength⇒客戶統一編號必須是8碼╣
|
|
taxnumberrule: i18next.t("message.Data_Repeat")// ╠message.Data_Repeat⇒此筆資料已建檔╣
|
|
}
|
|
}
|
|
},
|
|
/**
|
|
* 須初始化的UEEditer 的物件ID集合
|
|
*/
|
|
ueEditorIds: ['Features', 'Details', 'CancelPolicy', 'OrderMemo'],
|
|
/**
|
|
* 頁面初始化
|
|
* @param {Object} pargs CanDo 對象
|
|
*/
|
|
pageInit: function (pargs) {
|
|
var postArray = [];
|
|
if (pargs.action === 'upd') {
|
|
postArray.push(pargs._getOne());
|
|
}
|
|
else {
|
|
pargs.data.PPTimes = [];
|
|
pargs.data.FQAs = [];
|
|
pargs.data.OtherDetials = [];
|
|
pargs.data.SuitPlace = [];
|
|
}
|
|
postArray.push(fnSetArgDrop([
|
|
{
|
|
ArgClassID: 'LanCountry',
|
|
Select: $('#LangID'),
|
|
ShowId: true,
|
|
DefultVal: sLang
|
|
}
|
|
]));
|
|
postArray.push(setSupplierDrop());
|
|
postArray.push(setSubCategoryDrop());
|
|
//幣別
|
|
postArray.push(fnSetArgDrop([{
|
|
ArgClassID: 'Currency',
|
|
Select: $('#CurrencyID'),
|
|
ShowId: true
|
|
}]));
|
|
//確認天數
|
|
postArray.push(fnSetArgDrop([{
|
|
ArgClassID: 'OrderConfirmDays',
|
|
Select: $('#ConfirmDays'),
|
|
ShowId: true
|
|
}]));
|
|
//postArray.push(setExhibitionDrop());
|
|
postArray.push(fnInitExhibitionGrid());
|
|
postArray.push(qryRegionList());
|
|
var rsSubCategoryIDs = [];
|
|
//加載報關類別,加載報價頁簽,加載運輸方式, 加載機場, 加載貨棧場, 加載倉庫
|
|
$.whenArray(postArray).done(function (res) {
|
|
pargs.form = $("#BasicTab");
|
|
if (pargs.action === 'upd' && res[0].RESULT) {
|
|
var oRes = res[0].DATA.rel;
|
|
pargs._setFormVal(oRes);
|
|
pargs._setUEValues(oRes);
|
|
$("#hidServiceID").val(oRes.ServiceID);
|
|
pargs.data.BannerFile = pargs.data.BannerFile || guid();
|
|
pargs.data.PreviewFile = pargs.data.PreviewFile || guid();
|
|
pargs._getPageVal();//緩存頁面值,用於清除
|
|
fnGetUploadFiles(pargs.data.BannerFile, fnUpload, 'BannerFile');
|
|
fnGetUploadFiles(pargs.data.PreviewFile, fnUpload, 'PreviewFile');
|
|
//特別處理欄位
|
|
$('#ServiceNo').val(oRes.ServiceNo);
|
|
if (oRes.LangID != "") {
|
|
$('#LangID').val(oRes.LangID);
|
|
setSupplierDrop().done(function () {
|
|
$('#SupplierD').val(oRes.SupplierD);
|
|
});
|
|
}
|
|
$('input[type=radio][name=Effective][value=' + oRes.Effective + ']').attr('checked', 'checked');
|
|
if (oRes.PPDateFlag == "1") {
|
|
$("#chkPPDateFlag").prop('checked', true);
|
|
$('.PPDateFlag').show();
|
|
}
|
|
else {
|
|
$("#chkPPDateFlag").prop('checked', false);
|
|
$('.PPDateFlag').hide();
|
|
}
|
|
|
|
if (oRes.PPTimeFlag == "1") {
|
|
$("#chkPPTimeFlag").prop('checked', true);
|
|
$('.PPTimeFlag').show();
|
|
}
|
|
else {
|
|
$("#chkPPTimeFlag").prop('checked', false);
|
|
$('.PPTimeFlag').hide();
|
|
}
|
|
$('[type=checkbox][name=PayType]').each(function () {
|
|
if (oRes.PayType.indexOf(this.value) > -1) {
|
|
this.checked = true;
|
|
}
|
|
});
|
|
$('input[type=radio][name=CMode][value=' + oRes.CMode + ']').attr('checked', 'checked');
|
|
if (oRes.CMode == "1") {
|
|
$("#CPercent").val(oRes.CPercent);
|
|
}
|
|
$('input[type=radio][name=OtherMode][value=' + oRes.OtherMode + ']').attr('checked', 'checked');
|
|
$("#CreateUserName").text(oRes.CreateUserName);
|
|
$("#CreateDate").text(newDate(oRes.CreateDate));
|
|
$("#ModifyUserName").text(oRes.ModifyUserName);
|
|
$("#ModifyDate").text(newDate(oRes.ModifyDate));
|
|
fnBindPPTimes();
|
|
fnBindFQAs();
|
|
var sSuitPlace = "";
|
|
for (var i = 0; i < oRes.SuitPlace.length; i++) {
|
|
sSuitPlace += oRes.SuitPlace[i].Name+",";
|
|
}
|
|
$("#Place").val(sSuitPlace);
|
|
|
|
if (oRes.LaunchDateS != "" && oRes.LaunchDateE != "") {
|
|
$("#LaunchDays").val(getDays(newDate(oRes.LaunchDateS), newDate(oRes.LaunchDateE)));
|
|
}
|
|
|
|
if (oRes.SubCategoryID) {
|
|
rsSubCategoryIDs = JSON.parse(oRes.SubCategoryID);
|
|
}
|
|
$('#SubCategoryID').val(rsSubCategoryIDs);
|
|
$('#SubCategoryID').trigger('change');
|
|
|
|
$("#ExhibitionID").val(oRes.ExhibitionID);
|
|
$("#ExhibitionNames").val(oRes.ExhibitionNames);
|
|
|
|
if (typeof pargs.data.OtherDetials === 'string') {
|
|
pargs.data.OtherDetials = JSON.parse(pargs.data.OtherDetials || '[]');
|
|
}
|
|
fnBindOtherDetials();
|
|
if ($('#table_box_other tr').length == 0) {
|
|
$('.plusother').click();
|
|
}
|
|
}
|
|
else {
|
|
pargs.data.BannerFile = guid();
|
|
pargs.data.PreviewFile = guid();
|
|
fnUpload(null, pargs.data.BannerFile, 'BannerFile');
|
|
fnUpload(null, pargs.data.PreviewFile, 'PreviewFile');
|
|
if ($('#table_box_other tr').length == 0) {
|
|
$('.plusother').click();
|
|
}
|
|
}
|
|
|
|
//$('#RegionSearch').keyup(function () {
|
|
// $('#divRegionList').jstree(true).search($('#RegionSearch').val());
|
|
//});
|
|
//$('#RegionSearch2').keyup(function () {
|
|
// $('#divRegionList2').jstree(true).search($('#RegionSearch2').val());
|
|
//});
|
|
|
|
//其他地點資訊
|
|
$('.plusother').on('click', function () {
|
|
var oNewKey = {};
|
|
oNewKey.Guid = guid();
|
|
oNewKey.CityID = '';
|
|
oNewKey.CityName = '';
|
|
oNewKey.Address = '';
|
|
oNewKey.CusTitle = '';
|
|
//若失敗後,資料已經變成字串了。需要再次轉回陣列,才能刪除
|
|
if (typeof pargs.data.OtherDetials === 'string') {
|
|
pargs.data.OtherDetials = JSON.parse(pargs.data.OtherDetials || '[]');
|
|
}
|
|
pargs.data.OtherDetials.push(oNewKey);
|
|
fnBindOtherDetials();
|
|
});
|
|
|
|
// 其他地點資訊 點擊時 radio
|
|
$('input[type=radio][name=OtherMode]').change(function () {
|
|
if ($('input[type=radio][name=OtherMode]:checked').val() == "4") {
|
|
$('#table_thbox_other').find('[name=CusTitle]').show();
|
|
$('#table_box_other').find('[name=CusTitle]').show();
|
|
} else {
|
|
$('#table_thbox_other').find('[name=CusTitle]').hide();
|
|
$('#table_box_other').find('[name=CusTitle]').hide();
|
|
}
|
|
});
|
|
|
|
|
|
//服務提供時間
|
|
$('.plustimetemplkey').on('click', function () {
|
|
var oNewKey = {};
|
|
oNewKey.Guid = guid();
|
|
oNewKey.TimeS = '';
|
|
oNewKey.TimeE = '';
|
|
//若失敗後,資料已經變成字串了。需要再次轉回陣列,才能刪除
|
|
if (typeof pargs.data.PPTimes === 'string') {
|
|
pargs.data.PPTimes = JSON.parse(pargs.data.PPTimes || '[]');
|
|
}
|
|
pargs.data.PPTimes.push(oNewKey);
|
|
fnBindPPTimes();
|
|
});
|
|
// 服務提供期間
|
|
$('#chkPPDateFlag').click(function () {
|
|
if (this.checked) {
|
|
$('.PPDateFlag').show();
|
|
} else {
|
|
$('.PPDateFlag').hide();
|
|
}
|
|
});
|
|
|
|
// 服務提供時間
|
|
$('#chkPPTimeFlag').click(function () {
|
|
if (this.checked) {
|
|
$('.PPTimeFlag').show();
|
|
if ($('#table_box_time tr').length == 0) {
|
|
$('.plustimetemplkey').click();
|
|
}
|
|
|
|
} else {
|
|
$('.PPTimeFlag').hide();
|
|
}
|
|
});
|
|
$('#LaunchDateS').on('change blur click', function () {
|
|
if ($('#LaunchDateS').val() != "" && $('#LaunchDateE').val() != "") {
|
|
$("#LaunchDays").val(getDays($('#LaunchDateS').val(), $('#LaunchDateE').val()));
|
|
}
|
|
});
|
|
$('#LaunchDateE').on('change blur click', function () {
|
|
if ($('#LaunchDateS').val() != "" && $('#LaunchDateE').val() != "") {
|
|
$("#LaunchDays").val(getDays($('#LaunchDateS').val(), $('#LaunchDateE').val()));
|
|
}
|
|
});
|
|
//適用地區
|
|
$('#btnQryPlace').click(function () {
|
|
|
|
var JqTreeObj = null;
|
|
layer.open({
|
|
type: 2,
|
|
title: '選擇地區',
|
|
shade: 0.75,
|
|
maxmin: true, //开启最大化最小化按钮
|
|
area: ['800px', '380px'],
|
|
content: '/Page/Pop/Region.html',
|
|
success: function (layero, index) {
|
|
var iframe = $('iframe').contents();
|
|
JqTreeObj = iframe.find("#ulTree").JqTreeInit(saRegionList,
|
|
{
|
|
idName: "id",//id对应的属性名称
|
|
nameName: "name",//name对应的属性名称
|
|
pIdName: "parent",//pId对应的属性名称
|
|
single: false, //此处指定是否单选 false-多选
|
|
expandLevel: 0 //此处指定展开级别 0-全部展开,1隱藏第三層,-1全部隱藏,只保留第一層
|
|
//其他参数 根据实际情况指定
|
|
},
|
|
function (JqTreeObj) {
|
|
//回调函数 此处添加特殊的逻辑 JqTreeObj为树对象
|
|
});
|
|
|
|
|
|
},
|
|
btn: [i18next.t('common.Confirm'), i18next.t('common.Cancel')], //╠common.Confirm⇒確定╣╠common.Cancel⇒取消╣
|
|
yes: function (index, layero) {
|
|
var iframe = $('iframe').contents();
|
|
var nodes = JqTreeObj.getCheckedDatas();
|
|
if (nodes == null || nodes == undefined) {
|
|
|
|
showMsg('請選擇區域!', 'warning'); //╠message.Insert_Success⇒新增成功╣
|
|
return false;
|
|
}
|
|
var sRegion = "";
|
|
//若失敗後,資料已經變成字串了。需要再次轉回陣列,才能刪除
|
|
if (typeof pargs.data.SuitPlace === 'string') {
|
|
pargs.data.SuitPlace = JSON.parse(pargs.data.SuitPlace || '[]');
|
|
}
|
|
pargs.data.SuitPlace = [];
|
|
for (var i = 0; i < nodes.length; i++) {
|
|
|
|
var sid = nodes[i].id;
|
|
sRegion += nodes[i].text + ",";
|
|
|
|
var oNewKey = {};
|
|
oNewKey.Guid = guid();
|
|
if ((sid.indexOf("A")) ==0) {
|
|
|
|
oNewKey.RegionID = sid.substr(1);
|
|
}
|
|
else if ((sid.indexOf("B")) == 0) {
|
|
|
|
oNewKey.CountryID = sid.substr(1);
|
|
}
|
|
else if ((sid.indexOf("C")) == 0) {
|
|
|
|
oNewKey.CityID = sid.substr(1);
|
|
}
|
|
oNewKey.Name = nodes[i].text;
|
|
pargs.data.SuitPlace.push(oNewKey);
|
|
}
|
|
$("#Place").val(sRegion);
|
|
layer.close(index);
|
|
}
|
|
});
|
|
|
|
});
|
|
|
|
//基本資訊儲存
|
|
$('#btnSaveBasic').click(function () {
|
|
if (!$.isEmptyObject(canDo.UE_Editor)) {
|
|
for (var key in canDo.UE_Editor) {
|
|
if ($('#' + key).length > 0) {
|
|
$('#' + key).val(canDo.UE_Editor[key].getContentTxt());
|
|
}
|
|
}
|
|
}
|
|
if (!$("#BasicTab").valid()) {
|
|
oValidator.focusInvalid();
|
|
return false;
|
|
}
|
|
|
|
if ($("#hidServiceID").val() == "") {
|
|
fnAddTab1();
|
|
}
|
|
else {
|
|
|
|
fnUpdTab1()
|
|
}
|
|
|
|
});
|
|
//基本資訊清除
|
|
$('#btnClearBasic').click(function () {
|
|
});
|
|
// 基本資訊
|
|
$('#alitab1').click(function () {
|
|
pargs.form = $("#BasicTab");
|
|
});
|
|
|
|
// 其他資訊頁簽
|
|
$('#alitab2').click(function () {
|
|
if ($("#hidServiceID").val() == "") {
|
|
showMsg("請先新增基本資訊!");
|
|
return false;
|
|
}
|
|
pargs.form = $("#BasicOther");
|
|
//常見問題
|
|
$('.plusfqatemplkey').unbind('click').on('click', function () {
|
|
var oNewKey = {};
|
|
oNewKey.Guid = guid();
|
|
oNewKey.Question = '';
|
|
oNewKey.Answer = '';
|
|
//若失敗後,資料已經變成字串了。需要再次轉回陣列,才能刪除
|
|
if (typeof pargs.data.FQAs === 'string') {
|
|
pargs.data.FQAs = JSON.parse(pargs.data.FQAs || '[]');
|
|
}
|
|
pargs.data.FQAs.push(oNewKey);
|
|
fnBindFQAs();
|
|
});
|
|
//常見問題
|
|
if ($('#table_box_fqa tr').length == 0) {
|
|
$('.plusfqatemplkey').click();
|
|
}
|
|
//其他存儲
|
|
$('#btnSaveOther').click(function () {
|
|
fnSaveTab2();
|
|
});
|
|
//設定資料
|
|
$.whenArray([setOtherOrderQuestion()]).done(function (res) {
|
|
//初始化問題列表
|
|
fnInitSurveyQustionGrid();
|
|
|
|
$('#CopySycnOK').click(function () {
|
|
if ($('#jsSurveyQustionGrid').find('[type=checkbox]:checked').length > 0) {
|
|
|
|
$('#jsSurveyQustionGrid').find('[type=checkbox]:checked').each(function () {
|
|
var oNewKey = {};
|
|
oNewKey.QuestionID = $(this).attr("SurveyID");
|
|
oNewKey.ServiceID = $("#hidServiceID").val();
|
|
oNewKey.RequiredFlag = '0';
|
|
oNewKey.LangID = $("#LangID").val();
|
|
oNewKey.SurveyName = $(this).attr("SurveyName");
|
|
oNewKey.Answer = $(this).attr("AnswerTypeName");
|
|
saOtherOrderQuestion.push(oNewKey);
|
|
});
|
|
|
|
var IssueHtml = $("#OtherOrderQuestion_temp").render(saOtherOrderQuestion);
|
|
$('#jsOrderQuertionGrid').html(IssueHtml).find('.deleteotherorderquestion').on('click', function () {
|
|
|
|
var sId = $(this).attr('data-value'),
|
|
saNewList = [];
|
|
$.each(saOtherOrderQuestion, function (idx, item) {
|
|
if (sId !== item.QuestionID) {
|
|
saNewList.push(item);
|
|
}
|
|
});
|
|
$(this).parents('tr').remove();
|
|
saOtherOrderQuestion = saNewList;
|
|
});
|
|
$('#jsOrderQuertionGrid').find('input[name=RequiredFlag]').on('click', function () {
|
|
|
|
|
|
var sId = $(this).attr('data-value');
|
|
var blChecked = this.checked;
|
|
$.each(saOtherOrderQuestion, function (idx, item) {
|
|
if (sId == item.QuestionID) {
|
|
item.RequiredFlag = blChecked ? "1" : "0";
|
|
}
|
|
});
|
|
});
|
|
|
|
};
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
});
|
|
|
|
// 常見問題
|
|
$('#alitab3').click(function () {
|
|
if ($("#hidServiceID").val() == "") {
|
|
showMsg("請先新增基本資訊!");
|
|
return false;
|
|
}
|
|
pargs.form = $("#BasicPlan");
|
|
|
|
$.whenArray([setPlanList()]).done(function (res) {
|
|
//初始化問題列表
|
|
fnInitSurveyQustionGrid();
|
|
|
|
$('#CopySycnOK').click(function () {
|
|
if ($('#jsSurveyQustionGrid').find('[type=checkbox]:checked').length > 0) {
|
|
|
|
$('#jsSurveyQustionGrid').find('[type=checkbox]:checked').each(function () {
|
|
var oNewKey = {};
|
|
oNewKey.QuestionID = $(this).attr("SurveyID");
|
|
oNewKey.ServiceID = $("#hidServiceID").val();
|
|
oNewKey.RequiredFlag = '0';
|
|
oNewKey.LangID = $("#LangID").val();
|
|
oNewKey.SurveyName = $(this).attr("SurveyName");
|
|
oNewKey.Answer = $(this).attr("AnswerTypeName");
|
|
curPlan.PlanOrderQuestions.push(oNewKey);
|
|
});
|
|
|
|
var IssueHtml = $("#OtherOrderQuestion_temp").render(curPlan.PlanOrderQuestions);
|
|
$('#jsPlanOrderQuertionGrid').html(IssueHtml).find('.deleteotherorderquestion').on('click', function () {
|
|
|
|
var sId = $(this).attr('data-value'),
|
|
saNewList = [];
|
|
$.each(curPlan.PlanOrderQuestions, function (idx, item) {
|
|
if (sId !== item.QuestionID) {
|
|
saNewList.push(item);
|
|
}
|
|
});
|
|
$(this).parents('tr').remove();
|
|
curPlan.PlanOrderQuestions = saNewList;
|
|
});
|
|
$('#jsPlanOrderQuertionGrid').find('input[name=RequiredFlag]').on('click', function () {
|
|
|
|
|
|
var sId = $(this).attr('data-value');
|
|
var blChecked = this.checked;
|
|
$.each(curPlan.PlanOrderQuestions, function (idx, item) {
|
|
if (sId == item.QuestionID) {
|
|
item.RequiredFlag = blChecked ? "1" : "0";
|
|
}
|
|
});
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
});
|
|
$($('.cusbasicplan').find('.planbtnkey')[0]).click();
|
|
|
|
});
|
|
|
|
});
|
|
// 常見問題
|
|
$('#alitab4').click(function () {
|
|
if ($("#hidServiceID").val() == "") {
|
|
showMsg("請先新增基本資訊!");
|
|
return false;
|
|
}
|
|
$.whenArray([qryPlanList()]).done(function (res) {
|
|
|
|
if (saPlan.length == 0) {
|
|
showMsg("請先新增方案資訊!");
|
|
return false;
|
|
}
|
|
else {
|
|
|
|
pargs.form = $("#BasicAdd");
|
|
$.whenArray([qryAdditionalServices()]).done(function (res1) {
|
|
|
|
|
|
//初始化問題列表
|
|
fnInitSurveyQustionGrid();
|
|
|
|
$('#CopySycnOK').click(function () {
|
|
if ($('#jsSurveyQustionGrid').find('[type=checkbox]:checked').length > 0) {
|
|
|
|
$('#jsSurveyQustionGrid').find('[type=checkbox]:checked').each(function () {
|
|
var oNewKey = {};
|
|
oNewKey.QuestionID = $(this).attr("SurveyID");
|
|
oNewKey.ServiceID = $("#hidServiceID").val();
|
|
oNewKey.RequiredFlag = '0';
|
|
oNewKey.LangID = $("#LangID").val();
|
|
oNewKey.SurveyName = $(this).attr("SurveyName");
|
|
oNewKey.Answer = $(this).attr("AnswerTypeName");
|
|
oNewKey.AddFlag = "1";
|
|
oAdditionalServices.AddOrderQuestions.push(oNewKey);
|
|
});
|
|
fnAddOrderQuestions();
|
|
};
|
|
});
|
|
|
|
|
|
});
|
|
}
|
|
});
|
|
});
|
|
|
|
copyFlag = pargs._getUrlParam('CopyFlag');
|
|
if (pargs.action === 'upd' && copyFlag == null) {
|
|
//修改后 檢測複製按鈕是否顯示
|
|
//編輯時複製按鈕是否顯示
|
|
$.whenArray([qryPlanList()]).done(function (res) {
|
|
|
|
if (saPlan.length == 0) {
|
|
$("#Toolbar_Copy").hide();
|
|
}
|
|
else {
|
|
$("#Toolbar_Copy").show();
|
|
}
|
|
});
|
|
}
|
|
else if (pargs.action === 'add') {
|
|
//新增時若方案筆數>1時,則顯示複製按鈕
|
|
$.whenArray([qryPlanList()]).done(function (res) {
|
|
|
|
if (saPlan.length == 0) {
|
|
$("#Toolbar_Copy").hide();
|
|
}
|
|
else {
|
|
$("#Toolbar_Copy").show();
|
|
}
|
|
});
|
|
}
|
|
else {
|
|
$("#Toolbar_Copy").hide();
|
|
}
|
|
});
|
|
}
|
|
|
|
}),
|
|
|
|
//取得時間差 天數
|
|
getDays = function (start, end) {
|
|
let dateSpan, iDays
|
|
start = Date.parse(start)
|
|
end = Date.parse(end)
|
|
dateSpan = end - start
|
|
dateSpan = Math.abs(dateSpan)
|
|
iDays = Math.floor(dateSpan / (24 * 3600 * 1000))
|
|
return iDays;
|
|
},
|
|
//複製
|
|
fnCopy = function () {
|
|
|
|
var data = {};
|
|
data.LangID = $('#LangID').val();
|
|
data.ServiceID = $('#hidServiceID').val();
|
|
data.SupplierID = $('#SupplierID').val();
|
|
return g_api.ConnectLite("ServiceMaintain_Upd", "Copy", data, function (res) {
|
|
if (res.RESULT) {
|
|
|
|
var oRes = res.DATA.rel;
|
|
$("#hidServiceID").val(oRes.ServiceID);
|
|
$("#CreateUserName").text(oRes.CreateUserName);
|
|
$("#CreateDate").text(newDate(oRes.CreateDate));
|
|
$("#ServiceNo").val(oRes.ServiceNo);
|
|
|
|
$("#ModifyUserName").text(oRes.ModifyUserName);
|
|
$("#ModifyDate").text(newDate(oRes.ModifyDate));
|
|
parent.top.openPageTab(canDo.EditPrgId, '?Action=Upd&CopyFlag=1&OrgID=' + oRes.OrgID + "&ServiceID=" + oRes.ServiceID + "&LangID=" + oRes.LangID);
|
|
}
|
|
else {
|
|
showMsg(i18next.t("message.Insert_Failed") + '<br>' + res.MSG, 'error');// ╠message.Insert_Failed⇒新增失敗╣
|
|
}
|
|
}, function () {
|
|
showMsg(i18next.t("message.Insert_Error"), 'error');// ╠message.Insert_Error⇒新增資料異常╣
|
|
});
|
|
|
|
},
|
|
//加購服務 訂單問題
|
|
fnAddOrderQuestions = function () {
|
|
|
|
if (oAdditionalServices.AddOrderQuestions.length > 0) {
|
|
var IssueHtml = $("#OtherOrderQuestion_temp").render(oAdditionalServices.AddOrderQuestions);
|
|
$('#jsAdditionalOrderQuertionGrid').html(IssueHtml).find('.deleteotherorderquestion').on('click', function () {
|
|
var sId = $(this).attr('data-value'),
|
|
saNewList = [];
|
|
$.each(oAdditionalServices.AddOrderQuestions, function (idx, item) {
|
|
if (sId !== item.QuestionID) {
|
|
saNewList.push(item);
|
|
}
|
|
});
|
|
$(this).parents('tr').remove();
|
|
oAdditionalServices.AddOrderQuestions = saNewList;
|
|
});
|
|
$('#jsAdditionalOrderQuertionGrid').find('input[name=RequiredFlag]').on('click', function () {
|
|
|
|
var sId = $(this).attr('data-value');
|
|
var blChecked = this.checked;
|
|
$.each(oAdditionalServices.AddOrderQuestions, function (idx, item) {
|
|
if (sId == item.QuestionID) {
|
|
item.RequiredFlag = blChecked ? "1" : "0";
|
|
return false;
|
|
}
|
|
});
|
|
|
|
});
|
|
}
|
|
},
|
|
/**
|
|
* 上傳附件
|
|
* @param {Array} files 當前文件
|
|
* @param {String} parentid
|
|
* @param {String} inputid file input id
|
|
*/
|
|
fnUpload = function (files, parentid, inputid) {
|
|
var option = {};
|
|
switch (inputid) {
|
|
case 'PictureID':
|
|
option.limit = 1;
|
|
option.type = 'one';
|
|
option.theme = 'dragdropbox2';
|
|
break;
|
|
case 'PreviewFile':
|
|
option.limit = 1;
|
|
option.type = 'one';
|
|
option.theme = 'dragdropbox1';
|
|
break;
|
|
case 'BannerFile':
|
|
option.limit = 99;
|
|
option.theme = 'dragdropbox4';
|
|
break;
|
|
}
|
|
option.input = $('#' + inputid);
|
|
option.parentid = parentid;
|
|
option.extensions = ['jpg', 'jpeg', 'png', 'bmp', 'gif', 'png', 'svg'];
|
|
option.folder = 'Service';
|
|
if (files) {
|
|
option.files = files;
|
|
}
|
|
fnUploadRegister(option);
|
|
},
|
|
//清除Plan頁面
|
|
fnClearPlan = function () {
|
|
|
|
$("#PlanName").val('');
|
|
$("#chkCusPlanFlag").prop("checked", false);
|
|
$("#CusPlanFlag").hide();
|
|
$("#table_box_destination").html("");
|
|
$("#table_box_spec").html("");
|
|
$("#jsPlanOrderQuertionGrid").html("");
|
|
|
|
},
|
|
//區域列表
|
|
qryRegionList = function () {
|
|
|
|
return g_api.ConnectLite(canDo.QueryPrgId, "QueryRegionList", { LangID: $('#LangID').val() || sLang }, function (res) {
|
|
if (res.RESULT) {
|
|
saRegionList = res.DATA.rel;
|
|
}
|
|
});
|
|
},
|
|
//方案列表,用於加購服務
|
|
qryPlanList = function () {
|
|
|
|
return g_api.ConnectLite(canDo.QueryPrgId, "QueryPlanList", { LangID: ($('#LangID').val() || sLang), ServiceID: $("#hidServiceID").val() }, function (res) {
|
|
if (res.RESULT) {
|
|
|
|
saPlan = res.DATA.rel;
|
|
}
|
|
});
|
|
},
|
|
//加購服務
|
|
qryAdditionalServices = function () {
|
|
return g_api.ConnectLite("ServiceMaintain_Upd", "QueryAdditionalOne", { LangID: ($('#LangID').val() || sLang), ServiceID: $("#hidServiceID").val() }, function (res) {
|
|
if (res.RESULT) {
|
|
oAdditionalServices = res.DATA.rel;
|
|
//加購存儲
|
|
$('#btnSaveAdd').unbind('click').click(function () {
|
|
fnSaveTab4();
|
|
});
|
|
//加購清除
|
|
$('#btnClearAdd').unbind('click').click(function () {
|
|
$('#BasicAdd').find(':input', 'textarea', 'select').each(function () {
|
|
$(this).val('');
|
|
//var ctl = {};
|
|
//ctl.ID = this.id;
|
|
//ctl.Type = this.type;
|
|
//ctl.Value = '';
|
|
});
|
|
});
|
|
//規格
|
|
$('.additionalpurchase').on('click', function () {
|
|
var oNewKey = {};
|
|
oNewKey.Guid = guid();
|
|
oNewKey.ServiceName = '';
|
|
oNewKey.Price = '';
|
|
oNewKey.InterbankPrice = '';
|
|
oNewKey.Inventory = '';
|
|
oNewKey.PlanIDs = '';
|
|
oAdditionalServices.AdditionalPurchase.push(oNewKey);
|
|
fnBindAdditionalPurchase();
|
|
});
|
|
//若失敗後,資料已經變成字串了。需要再次轉回陣列,才能刪除
|
|
if (typeof oAdditionalServices.AdditionalPurchase === 'string') {
|
|
oAdditionalServices.AdditionalPurchase = JSON.parse(oAdditionalServices.AdditionalPurchase || '[]');
|
|
}
|
|
//規格
|
|
fnBindAdditionalPurchase();
|
|
//加購服務 訂單問題
|
|
if (typeof oAdditionalServices.AddOrderQuestions === 'string') {
|
|
oAdditionalServices.AddOrderQuestions = JSON.parse(oAdditionalServices.AddOrderQuestions || '[]');
|
|
}
|
|
fnAddOrderQuestions();
|
|
}
|
|
});
|
|
},
|
|
//方案列表
|
|
setPlanList = function () {
|
|
|
|
return g_api.ConnectLite(canDo.QueryPrgId, "QueryPlanList", { LangID: ($('#LangID').val() || sLang), ServiceID: $("#hidServiceID").val() }, function (res) {
|
|
if (res.RESULT) {
|
|
|
|
var oNewPlan = [];
|
|
var oNewKey = {};
|
|
oNewKey.PlanID = guid();
|
|
oNewKey.PlanName = '新增方案';
|
|
oNewKey.PlanFlag = 'N';
|
|
let lstOtherOrderQuestion = res.DATA.rel;
|
|
if (lstOtherOrderQuestion.length > 0) {
|
|
for (var i = 0; i < lstOtherOrderQuestion.length; i++) {
|
|
|
|
oNewPlan.push(lstOtherOrderQuestion[i])
|
|
|
|
}
|
|
oNewPlan.push(oNewKey);
|
|
}
|
|
else {
|
|
oNewPlan.push(oNewKey);
|
|
}
|
|
var IssueHtml = $("#btnPlan_temp").render(oNewPlan),
|
|
QryPlanOne = function (planflag, planid) {
|
|
if (planflag == "Y") {
|
|
//修改方案
|
|
return g_api.ConnectLite("ServiceMaintain_Upd", "QueryPlanOne", { LangID: ($('#LangID').val() || sLang), ServiceID: $("#hidServiceID").val(), PlanID: planid }, function (res) {
|
|
if (res.RESULT) {
|
|
curPlan = res.DATA.rel;
|
|
//綁定資料
|
|
canDo._setFormVal(curPlan);
|
|
curPlan.PictureID = curPlan.PictureID || guid();
|
|
}
|
|
});
|
|
}
|
|
else {
|
|
|
|
//新增方案
|
|
fnClearPlan();
|
|
curPlan.PictureID = curPlan.PictureID || guid();
|
|
curPlan.PlanCusName = [];
|
|
curPlan.PlanOrderQuestions = [];
|
|
curPlan.PlanSpec = [];
|
|
curPlan.PlanPricingAndInventory = [];
|
|
|
|
}
|
|
};
|
|
|
|
// copyFlag = CanDo._getUrlParam('CopyFlag').toLowerCase();
|
|
if (oNewPlan.length > 1 && copyFlag == null) {
|
|
$("#Toolbar_Copy").show();
|
|
} else {
|
|
|
|
$("#Toolbar_Copy").hide();
|
|
}
|
|
$('.cusbasicplan').html(IssueHtml).find('.planbtnkey').on('click', function () {
|
|
|
|
$("#divplan").show();
|
|
curPlan = {};
|
|
$('.cusbasicplan').find('.planbtnkey').attr("style", "");
|
|
$(this).attr("style", "background: #008BFF;color: #FFFFFF;");
|
|
var planflag = $(this).attr('planflag');
|
|
var planid = $(this).attr('data-value');
|
|
|
|
$.whenArray([QryPlanOne(planflag, planid)]).done(function (res) {
|
|
|
|
if (planflag == "Y") {
|
|
if ($($("#PictureID").parent()).find(".jFiler-items").length == 0) {
|
|
fnGetUploadFiles(curPlan.PictureID, fnUpload, 'PictureID');
|
|
}
|
|
if (curPlan.CusPlanFlag == "1") {
|
|
$("#chkCusPlanFlag").prop("checked", true);
|
|
$('.CusPlanFlag').show();
|
|
$("#CusPlanName").show();
|
|
$("#CusPlanName").val(curPlan.CusPlanName);
|
|
|
|
} else {
|
|
$('.CusPlanFlag').hide();
|
|
$("#CusPlanName").hide();
|
|
$("#chkCusPlanFlag").prop("checked", false);
|
|
$("#CusPlanName").val("");
|
|
}
|
|
$('#btnDelPlan').show();
|
|
}
|
|
else {
|
|
$("#divPictureID").html("");
|
|
$("#divPictureID").html('<input type="file" class="displayNone" name="files[]" id="PictureID" multiple>');
|
|
fnUpload(null, curPlan.PictureID, 'PictureID');
|
|
$('#btnDelPlan').hide();
|
|
$("#chkCusPlanFlag").prop("checked", false);
|
|
$('.CusPlanFlag').hide();
|
|
$("#CusPlanName").hide();
|
|
}
|
|
//方案存儲
|
|
$('#btnSavePlan').unbind('click').click(function () {
|
|
fnSaveTab3(planid, planflag);
|
|
});
|
|
//方案刪除
|
|
$('#btnDelPlan').unbind('click').click(function () {
|
|
layer.confirm(i18next.t("message.ConfirmToDelete"), { icon: 3, title: i18next.t('common.Tips') }, function (index) {
|
|
|
|
fnDelTab3(planid);
|
|
layer.close(index);
|
|
});
|
|
});
|
|
|
|
//客制化方案
|
|
$('.plandestination').unbind('click').on('click', function () {
|
|
|
|
var oNewKey = {}, sNewGuid = guid();
|
|
oNewKey.Guid = sNewGuid;
|
|
oNewKey.Destination = '';
|
|
oNewKey.ServiceID = '';
|
|
oNewKey.PlanID = '';
|
|
//若失敗後,資料已經變成字串了。需要再次轉回陣列,才能刪除
|
|
if (typeof curPlan.PlanCusName === 'string') {
|
|
curPlan.PlanCusName = JSON.parse(curPlan.PlanCusName || '[]');
|
|
}
|
|
curPlan.PlanCusName.push(oNewKey);
|
|
fnBindCusName();
|
|
setPlanPricingAndInventory("Destination", 'add', sNewGuid);
|
|
});
|
|
//綁定客制化
|
|
if (typeof curPlan.PlanCusName === 'string') {
|
|
curPlan.PlanCusName = JSON.parse(curPlan.PlanCusName || '[]');
|
|
}
|
|
if (curPlan.PlanCusName.length > 0) {
|
|
|
|
fnBindCusName();
|
|
}
|
|
|
|
|
|
// 客制化方案checkbox
|
|
$('#chkCusPlanFlag').click(function () {
|
|
if (this.checked) {
|
|
$('.CusPlanFlag').show();
|
|
$("#CusPlanName").show();
|
|
if ($('#table_box_destination tr').length == 0) {
|
|
$('.plandestination').click();
|
|
}
|
|
|
|
} else {
|
|
$('.CusPlanFlag').hide();
|
|
$("#CusPlanName").hide();
|
|
}
|
|
});
|
|
|
|
//規格 +
|
|
$('.planspec').unbind('click').on('click', function () {
|
|
|
|
var oNewKey = {}, sNewGuid = guid();
|
|
oNewKey.Guid = sNewGuid;
|
|
oNewKey.Spec = '';
|
|
oNewKey.ServiceID = '';
|
|
oNewKey.PlanID = '';
|
|
//若失敗後,資料已經變成字串了。需要再次轉回陣列,才能刪除
|
|
if (typeof curPlan.PlanSpec === 'string') {
|
|
curPlan.PlanSpec = JSON.parse(curPlan.PlanSpec || '[]');
|
|
}
|
|
curPlan.PlanSpec.push(oNewKey);
|
|
fnBindPlanSpec();
|
|
setPlanPricingAndInventory("Spec", 'add', sNewGuid);
|
|
});
|
|
|
|
//規格
|
|
if (typeof curPlan.PlanSpec === 'string') {
|
|
curPlan.PlanSpec = JSON.parse(curPlan.PlanSpec || '[]');
|
|
}
|
|
$.whenArray([fnBindPlanSpec()]).done(function (res1) {
|
|
if ($('#table_box_spec tr').length == 0) {
|
|
$('.planspec').click();
|
|
}
|
|
});
|
|
|
|
//方案訂單問題
|
|
if (typeof curPlan.PlanOrderQuestions === 'string') {
|
|
curPlan.PlanOrderQuestions = JSON.parse(curPlan.PlanOrderQuestions || '[]');
|
|
}
|
|
if (curPlan.PlanOrderQuestions.length > 0) {
|
|
var IssueHtml = $("#OtherOrderQuestion_temp").render(curPlan.PlanOrderQuestions);
|
|
|
|
$('#jsPlanOrderQuertionGrid').html(IssueHtml).find('.deleteotherorderquestion').on('click', function () {
|
|
var sId = $(this).attr('data-value'),
|
|
saNewList = [];
|
|
$.each(curPlan.PlanOrderQuestions, function (idx, item) {
|
|
if (sId !== item.QuestionID) {
|
|
saNewList.push(item);
|
|
}
|
|
});
|
|
$(this).parents('tr').remove();
|
|
curPlan.PlanOrderQuestions = saNewList;
|
|
});
|
|
$('#jsPlanOrderQuertionGrid').find('input[name=RequiredFlag]').on('click', function () {
|
|
|
|
|
|
var sId = $(this).attr('data-value');
|
|
var blChecked = this.checked;
|
|
$.each(curPlan.PlanOrderQuestions, function (idx, item) {
|
|
if (sId == item.QuestionID) {
|
|
item.RequiredFlag = blChecked ? "1" : "0";
|
|
}
|
|
});
|
|
});
|
|
|
|
}
|
|
|
|
//定價&庫存量
|
|
if (typeof curPlan.PlanPricingAndInventory === 'string') {
|
|
curPlan.PlanPricingAndInventory = JSON.parse(curPlan.PlanPricingAndInventory || '[]');
|
|
}
|
|
if (curPlan.PlanPricingAndInventory.length > 0) {
|
|
|
|
var cMode = $('input[type=radio][name=CMode]:checked').val(); //2:同業價
|
|
var IssueHtml = $("#PlanPricingAndInventory_temp").render(curPlan.PlanPricingAndInventory);
|
|
$('#jsPlanPricingAndInventoryGrid').html(IssueHtml);
|
|
if (cMode == "1") { //非同業價時隱藏同業價td
|
|
$('#jsPlanPricingAndInventoryGrid').find('[name="tdInterbankPrice"]').hide();
|
|
$('#jsthPlanPricingAndInventoryGrid').find('[name="tdInterbankPrice"]').hide();
|
|
}
|
|
if (curPlan.CusPlanFlag == "0") { //客制化方案關閉后隱藏方案列
|
|
|
|
$('#jsPlanPricingAndInventoryGrid').find('[name="tdCusPlanFlag"]').hide();
|
|
$('#jsthPlanPricingAndInventoryGrid').find('[name="tdCusPlanFlag"]').hide();
|
|
}
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
});
|
|
},
|
|
//通過客制化 與規格的部分重新規劃 定價&庫存量部分
|
|
setPlanPricingAndInventory = function (itemflag, flag, tempval) {
|
|
var saPricingAndInventory = [];
|
|
var tempPricingAndInventory = [];
|
|
var lastPricingAndInventory = [];
|
|
//目前已存在的
|
|
$("#jsPlanPricingAndInventoryGrid").find("tr").each(function () {
|
|
var oNewKey = {};
|
|
var tdArr = $(this).children();
|
|
oNewKey.Guid = $(this).attr("data-id");
|
|
oNewKey.DestinationID = $(tdArr.eq(1)).attr("data-id");
|
|
oNewKey.Destination = $(tdArr.eq(1)).html();
|
|
oNewKey.Spec = $(tdArr.eq(2)).html();
|
|
oNewKey.SpecID = $(tdArr.eq(2)).attr("data-id");
|
|
oNewKey.UnitPrice = tdArr.eq(3).find("input").val();
|
|
oNewKey.InterbankPrice = tdArr.eq(4).find("input").val();
|
|
oNewKey.Inventory = tdArr.eq(5).find("input").val();
|
|
saPricingAndInventory.push(oNewKey);
|
|
});
|
|
|
|
//如果客制化大於0,則需要依據客制化循環
|
|
if (curPlan.PlanCusName.length > 0) {
|
|
$.each(curPlan.PlanCusName, function (n, item) {
|
|
$.each(curPlan.PlanSpec, function (n, item2) {
|
|
var oNewKey = {};
|
|
var saTemp = saPricingAndInventory.filter((item1) => item1.SpecID == item2.Guid && item1.DestinationID == item.Guid);
|
|
if (saTemp.length > 0) {
|
|
oNewKey = saTemp[0];
|
|
oNewKey.Spec = item2.Spec;
|
|
oNewKey.Destination = item.Destination;
|
|
lastPricingAndInventory.push(oNewKey);
|
|
}
|
|
else {
|
|
oNewKey.Guid = guid();
|
|
oNewKey.SpecID = item2.Guid;
|
|
oNewKey.Spec = item2.Spec;
|
|
oNewKey.DestinationID = item.Guid;
|
|
oNewKey.Destination = item.Destination;
|
|
oNewKey.UnitPrice = "";
|
|
oNewKey.InterbankPrice = "";
|
|
oNewKey.Inventory = "";
|
|
lastPricingAndInventory.push(oNewKey);
|
|
}
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
else {
|
|
//如果客制化等於0,則需要依據規格化循環
|
|
$.each(curPlan.PlanSpec, function (n, item) {
|
|
var oNewKey = {};
|
|
var saTemp = saPricingAndInventory.filter((item1) => item1.SpecID == item.Guid && item1.DestinationID == "");
|
|
if (saTemp.length > 0) {
|
|
oNewKey = saTemp[0];
|
|
lastPricingAndInventory.push(oNewKey);
|
|
}
|
|
else {
|
|
oNewKey.Guid = guid();
|
|
oNewKey.SpecID = item.Guid;
|
|
oNewKey.Spec = item.Spec;
|
|
oNewKey.DestinationID = "";
|
|
oNewKey.Destination = "";
|
|
oNewKey.UnitPrice = "";
|
|
oNewKey.InterbankPrice = "";
|
|
oNewKey.Inventory = "";
|
|
lastPricingAndInventory.push(oNewKey);
|
|
}
|
|
});
|
|
|
|
}
|
|
|
|
if (lastPricingAndInventory.length > 0) {
|
|
var cMode = $('input[type=radio][name=CMode]:checked').val(); //2:同業價
|
|
var IssueHtml = $("#PlanPricingAndInventory_temp").render(lastPricingAndInventory);
|
|
$('#jsPlanPricingAndInventoryGrid').html(IssueHtml);
|
|
if (cMode == "1") { //非同業價時隱藏同業價td
|
|
$('#jsPlanPricingAndInventoryGrid').find('[name="tdInterbankPrice"]').hide();
|
|
$('#jsthPlanPricingAndInventoryGrid').find('[name="tdInterbankPrice"]').hide();
|
|
|
|
}
|
|
if (curPlan.CusPlanFlag == "0") { //客制化方案關閉后隱藏方案列
|
|
$('#jsPlanPricingAndInventoryGrid').find('[name="tdCusPlanFlag"]').hide();
|
|
$('#jsthPlanPricingAndInventoryGrid').find('[name="tdCusPlanFlag"]').hide();
|
|
}
|
|
}
|
|
|
|
|
|
},
|
|
//設置其他頁簽的訂單問題
|
|
setOtherOrderQuestion = function () {
|
|
return g_api.ConnectLite(canDo.QueryPrgId, "QueryOrderQuestion", { LangID: ($('#LangID').val() || sLang), ServiceID: $("#hidServiceID").val() }, function (res) {
|
|
if (res.RESULT) {
|
|
|
|
let lstOtherOrderQuestion = res.DATA.rel;
|
|
if (lstOtherOrderQuestion.length > 0) {
|
|
var IssueHtml = $("#OtherOrderQuestion_temp").render(lstOtherOrderQuestion);
|
|
saOtherOrderQuestion = lstOtherOrderQuestion;
|
|
$('#jsOrderQuertionGrid').html(IssueHtml).find('.deleteotherorderquestion').on('click', function () {
|
|
|
|
var sId = $(this).attr('data-value'),
|
|
saNewList = [];
|
|
$.each(saOtherOrderQuestion, function (idx, item) {
|
|
if (sId !== item.QuestionID) {
|
|
saNewList.push(item);
|
|
}
|
|
});
|
|
$(this).parents('tr').remove();
|
|
saOtherOrderQuestion = saNewList;
|
|
});
|
|
$('#jsOrderQuertionGrid').find('input[name=RequiredFlag]').on('click', function () {
|
|
|
|
var sId = $(this).attr('data-value');
|
|
var blChecked = this.checked;
|
|
|
|
$.each(saOtherOrderQuestion, function (idx, item) {
|
|
if (sId == item.QuestionID) {
|
|
item.RequiredFlag = blChecked ? "1" : "0";
|
|
}
|
|
});
|
|
});
|
|
}
|
|
}
|
|
});
|
|
},
|
|
//設置供應商
|
|
setSupplierDrop = function () {
|
|
return g_api.ConnectLite(canDo.QueryPrgId, "QuerySupplierList", { LangID: $('#LangID').val() || sLang }, function (res) {
|
|
if (res.RESULT) {
|
|
let saSupplier = res.DATA.rel;
|
|
if (saSupplier.length > 0) {
|
|
$('#SupplierID').append(createOptions(saSupplier, 'SupplierID', 'CompanyName', false)).select2();
|
|
}
|
|
}
|
|
});
|
|
},
|
|
//設置服務子類別
|
|
setSubCategoryDrop = function () {
|
|
return g_api.ConnectLite(canDo.QueryPrgId, "QuerySubCategoryList", { LangID: $('#LangID').val() || sLang }, function (res) {
|
|
if (res.RESULT) {
|
|
let saSubCategory = res.DATA.rel;
|
|
if (saSubCategory.length > 0) {
|
|
$('#SubCategoryID').append(createOptions(saSubCategory, 'CategoryID', 'CategoryName', false)).select2();
|
|
}
|
|
}
|
|
});
|
|
},
|
|
// 新增Tab1資料
|
|
fnAddTab1 = function () {
|
|
var data = getFormSerialize($('#BasicTab'));
|
|
data = canDo._getUEValues(data);
|
|
data = packParams(data);
|
|
|
|
//服務提供時間
|
|
if (typeof canDo.data.PPTimes === 'string') {
|
|
data.PPTimes = JSON.parse(canDo.data.PPTimes || '[]');
|
|
}
|
|
data.PPTimes = JSON.stringify(canDo.data.PPTimes);
|
|
//其他資訊
|
|
if (typeof canDo.data.OtherDetials === 'string') {
|
|
data.OtherDetials = JSON.parse(canDo.data.OtherDetials || '[]');
|
|
}
|
|
data.OtherDetials = JSON.stringify(canDo.data.OtherDetials);
|
|
|
|
//付款方式
|
|
var lstPayType = [];
|
|
$("input[name='PayType']:checked").each(function () {
|
|
lstPayType.push(this.value);
|
|
});
|
|
data.PayType = lstPayType.join(",");
|
|
|
|
//適用地區/展會
|
|
//var lstSuitPlaceOrExhibition = [];
|
|
//$("input[name='SuitPlaceOrExhibition']:checked").each(function () {
|
|
// lstSuitPlaceOrExhibition.push(this.value);
|
|
//});
|
|
//data.SuitPlaceOrExhibition = lstSuitPlaceOrExhibition.join(",");
|
|
|
|
//展會
|
|
//var lstExhibitionID = [];
|
|
//$("#ExhibitionID option:selected").each(function () {
|
|
// lstExhibitionID.push(this.value);
|
|
//});
|
|
//data.ExhibitionID = lstExhibitionID.join(",");
|
|
|
|
|
|
data.ExhibitionID =$('#ExhibitionID').val();
|
|
//適用地區
|
|
if (typeof canDo.data.SuitPlace === 'string') {
|
|
data.SuitPlace = JSON.parse(canDo.data.SuitPlace || '[]');
|
|
}
|
|
data.SuitPlace = JSON.stringify(canDo.data.SuitPlace);
|
|
|
|
//子類別
|
|
data.SubCategoryID = [];
|
|
data.SubCategoryID = JSON.stringify($('#SubCategoryID').val());
|
|
|
|
data.LangID = $('#LangID').val();
|
|
data.Effective = $('input:radio[name="Effective"]:checked').val();
|
|
|
|
data.PPDateFlag = data.chkPPDateFlag ? "1" : "0";
|
|
data.PPTimeFlag = data.chkPPTimeFlag ? "1" : "0";
|
|
|
|
data.BannerFile = canDo.data.BannerFile;
|
|
data.PreviewFile = canDo.data.PreviewFile;
|
|
|
|
return g_api.ConnectLite("ServiceMaintain_Upd", "Insert", data, function (res) {
|
|
if (res.RESULT) {
|
|
|
|
var oRes = res.DATA.rel;
|
|
$("#hidServiceID").val(oRes.ServiceID);
|
|
$("#CreateUserName").text(oRes.CreateUserName);
|
|
$("#CreateDate").text(newDate(oRes.CreateDate));
|
|
$("#ServiceNo").val(oRes.ServiceNo);
|
|
|
|
$("#ModifyUserName").text(oRes.ModifyUserName);
|
|
$("#ModifyDate").text(newDate(oRes.ModifyDate));
|
|
showMsg(i18next.t("message.Insert_Success"), 'success'); //╠message.Insert_Success⇒新增成功╣
|
|
$("#alitab2").click();
|
|
}
|
|
else {
|
|
showMsg(i18next.t("message.Insert_Failed") + '<br>' + res.MSG, 'error');// ╠message.Insert_Failed⇒新增失敗╣
|
|
}
|
|
}, function () {
|
|
showMsg(i18next.t("message.Insert_Error"), 'error');// ╠message.Insert_Error⇒新增資料異常╣
|
|
});
|
|
},
|
|
//修改 Tab1資料
|
|
fnUpdTab1 = function () {
|
|
var data = getFormSerialize($('#BasicTab'));
|
|
|
|
data = canDo._getUEValues(data);
|
|
data = packParams(data);
|
|
|
|
|
|
//data.PPTimeFlag = $("#chkPPTimeFlag").che
|
|
//服務提供時間
|
|
if (typeof canDo.data.PPTimes === 'string') {
|
|
data.PPTimes = JSON.parse(canDo.data.PPTimes || '[]');
|
|
}
|
|
data.PPTimes = JSON.stringify(canDo.data.PPTimes);
|
|
//其他資訊
|
|
if (typeof canDo.data.OtherDetials === 'string') {
|
|
data.OtherDetials = JSON.parse(canDo.data.OtherDetials || '[]');
|
|
}
|
|
data.OtherDetials = JSON.stringify(canDo.data.OtherDetials);
|
|
//付款方式
|
|
var lstPayType = [];
|
|
$("input[name='PayType']:checked").each(function () {
|
|
lstPayType.push(this.value);
|
|
});
|
|
data.PayType = lstPayType.join(",");
|
|
|
|
//子類別
|
|
data.SubCategoryID = [];
|
|
data.SubCategoryID = JSON.stringify($('#SubCategoryID').val());
|
|
//適用地區/展會
|
|
//var lstSuitPlaceOrExhibition = [];
|
|
//$("input[name='SuitPlaceOrExhibition']:checked").each(function () {
|
|
// lstSuitPlaceOrExhibition.push(this.value);
|
|
//});
|
|
//data.SuitPlaceOrExhibition = lstSuitPlaceOrExhibition.join(",");
|
|
|
|
//展會
|
|
//var lstExhibitionID = [];
|
|
//$("#ExhibitionID option:selected").each(function () {
|
|
// lstExhibitionID.push(this.value);
|
|
//});
|
|
//data.ExhibitionID = lstExhibitionID.join(",");
|
|
//data.ExhibitionID = $("#ExhibitionID").select2("data");
|
|
|
|
data.ExhibitionID = $('#ExhibitionID').val();
|
|
|
|
//適用地區
|
|
if (typeof canDo.data.SuitPlace === 'string') {
|
|
data.SuitPlace = JSON.parse(canDo.data.SuitPlace || '[]');
|
|
}
|
|
data.SuitPlace = JSON.stringify(canDo.data.SuitPlace);
|
|
|
|
|
|
data.LangID = $('#LangID').val();
|
|
data.Effective = $('input:radio[name="Effective"]:checked').val();
|
|
data.PPDateFlag = data.chkPPDateFlag ? "1" : "0";
|
|
data.PPTimeFlag = data.chkPPTimeFlag ? "1" : "0";
|
|
data.ServiceID = $("#hidServiceID").val();
|
|
data.BannerFile = canDo.data.BannerFile;
|
|
data.PreviewFile = canDo.data.PreviewFile;
|
|
return g_api.ConnectLite("ServiceMaintain_Upd", "UpdateBasic", data, function (res) {
|
|
if (res.RESULT) {
|
|
|
|
var oRes = res.DATA.rel;
|
|
$("#hidServiceID").val(oRes.ServiceID);
|
|
$("#ModifyUserName").text(oRes.ModifyUserName);
|
|
$("#ModifyDate").text(newDate(oRes.ModifyDate));
|
|
showMsg(i18next.t("message.Modify_Success"), 'success'); //╠message.Insert_Success⇒新增成功╣
|
|
$("#alitab2").click();
|
|
}
|
|
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⇒新增資料異常╣
|
|
});
|
|
},
|
|
//新增/修改Tab2資料
|
|
fnSaveTab2 = function () {
|
|
var sCancelPolicy = UE.getEditor('UE_CancelPolicy').getContent();
|
|
if (sCancelPolicy == null || sCancelPolicy == '') {
|
|
//Warning
|
|
showMsg('取消政策不可爲空!', 'warning'); //╠message.Insert_Success⇒新增成功╣
|
|
return false;
|
|
}
|
|
var data = getFormSerialize($('#BasicOther'));
|
|
|
|
data = canDo._getUEValues(data);
|
|
data = packParams(data);
|
|
//常見問題
|
|
if (typeof canDo.data.FQAs === 'string') {
|
|
data.FQAs = JSON.parse(canDo.data.FQAs || '[]');
|
|
}
|
|
data.FQAs = JSON.stringify(canDo.data.FQAs);
|
|
data.LangID = $('#LangID').val();
|
|
data.Effective = $('input:radio[name="Effective"]:checked').val();
|
|
data.ServiceID = $("#hidServiceID").val();
|
|
|
|
//訂單問題
|
|
data.OrderQuestions = JSON.stringify(saOtherOrderQuestion);
|
|
return g_api.ConnectLite("ServiceMaintain_Upd", "UpdateOther", data, function (res) {
|
|
if (res.RESULT) {
|
|
|
|
var oRes = res.DATA.rel;
|
|
$("#hidServiceID").val(oRes.ServiceID);
|
|
$("#ModifyUserName").text(oRes.ModifyUserName);
|
|
$("#ModifyDate").text(newDate(oRes.ModifyDate));
|
|
showMsg(i18next.t("message.Modify_Success"), 'success'); //╠message.Insert_Success⇒新增成功╣
|
|
$("#alitab3").click();
|
|
}
|
|
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⇒新增資料異常╣
|
|
});
|
|
},
|
|
//新增/修改方案資料
|
|
fnSaveTab3 = function (planid, planflag) {
|
|
var data = getFormSerialize($('#BasicPlan'));
|
|
|
|
data.PlanID = planid;
|
|
if (planflag == "Y") {
|
|
//修改
|
|
data = packParams(data, 'upd');
|
|
|
|
}
|
|
else {
|
|
data = packParams(data);
|
|
}
|
|
|
|
data.CusPlanFlag = data.chkCusPlanFlag ? "1" : "0"
|
|
data.CusPlanName = $("#CusPlanName").val();
|
|
data.PlanOrderQuestions = JSON.stringify(curPlan.PlanOrderQuestions);
|
|
data.PlanCusName = JSON.stringify(curPlan.PlanCusName);
|
|
data.PlanSpec = JSON.stringify(curPlan.PlanSpec);
|
|
data.PictureID = curPlan.PictureID;
|
|
|
|
|
|
var saPricingAndInventory = [];
|
|
$("#jsPlanPricingAndInventoryGrid").find("tr").each(function () {
|
|
var oNewKey = {};
|
|
var tdArr = $(this).children();
|
|
oNewKey.Guid = $(this).attr("data-id");
|
|
oNewKey.DestinationID = $(tdArr.eq(1)).attr("data-id");
|
|
oNewKey.SpecID = $(tdArr.eq(2)).attr("data-id");
|
|
oNewKey.UnitPrice = tdArr.eq(3).find("input").val();
|
|
oNewKey.InterbankPrice = tdArr.eq(4).find("input").val();
|
|
oNewKey.Inventory = tdArr.eq(5).find("input").val();
|
|
saPricingAndInventory.push(oNewKey);
|
|
});
|
|
|
|
data.PlanPricingAndInventory = JSON.stringify(saPricingAndInventory);
|
|
|
|
data.LangID = $('#LangID').val();
|
|
data.ServiceID = $("#hidServiceID").val();
|
|
|
|
return g_api.ConnectLite("ServiceMaintain_Upd", (planflag == "Y" ? "UpdatePlan" : "InsertPlan"), data, function (res) {
|
|
if (res.RESULT) {
|
|
|
|
var oRes = res.DATA.rel;
|
|
//$("#hidServiceID").val(oRes.ServiceID);
|
|
//$("#ModifyUserName").text(oRes.ModifyUserName);
|
|
//$("#ModifyDate").text(newDate(oRes.ModifyDate));
|
|
showMsg(i18next.t("message.Modify_Success"), 'success'); //╠message.Insert_Success⇒新增成功╣
|
|
/* $("#alitab3").click();*/
|
|
if (planflag == "N") {
|
|
//新增一筆重新加載
|
|
|
|
$("#alitab3").click();
|
|
|
|
}
|
|
else {
|
|
//修改一筆不動畫面,把名稱改一下
|
|
|
|
$(".planbtnkey[data-value=" + planid + "]").val(data.PlanName);
|
|
|
|
}
|
|
|
|
|
|
copyFlag = canDo._getUrlParam('CopyFlag');
|
|
if (canDo.action === 'upd' && copyFlag == null) {
|
|
//修改后 檢測複製按鈕是否顯示
|
|
//編輯時複製按鈕是否顯示
|
|
$.whenArray([qryPlanList()]).done(function (res) {
|
|
|
|
if (saPlan.length == 0) {
|
|
$("#Toolbar_Copy").hide();
|
|
}
|
|
else {
|
|
$("#Toolbar_Copy").show();
|
|
}
|
|
});
|
|
}
|
|
else if (canDo.action === 'add') {
|
|
//新增時若方案筆數>1時,則顯示複製按鈕
|
|
$.whenArray([qryPlanList()]).done(function (res) {
|
|
|
|
if (saPlan.length == 0) {
|
|
$("#Toolbar_Copy").hide();
|
|
}
|
|
else {
|
|
$("#Toolbar_Copy").show();
|
|
}
|
|
});
|
|
}
|
|
else {
|
|
|
|
$("#Toolbar_Copy").hide();
|
|
}
|
|
|
|
|
|
}
|
|
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⇒新增資料異常╣
|
|
});
|
|
},
|
|
//刪除方案資料
|
|
fnDelTab3 = function (planid) {
|
|
var data = {};
|
|
data.PlanID = planid;
|
|
data.LangID = $('#LangID').val();
|
|
data.ServiceID = $("#hidServiceID").val();
|
|
return g_api.ConnectLite("ServiceMaintain_Upd", "DeletePlan", data, function (res) {
|
|
if (res.RESULT) {
|
|
var oRes = res.DATA.rel;
|
|
showMsg(i18next.t("message.Delete_Success"), 'success'); //╠message.Delete_Success⇒刪除成功╣
|
|
$("#alitab3").click();
|
|
copyFlag = canDo._getUrlParam('CopyFlag');
|
|
if (canDo.action === 'upd' && copyFlag == null) {
|
|
//修改后 檢測複製按鈕是否顯示
|
|
//編輯時複製按鈕是否顯示
|
|
$.whenArray([qryPlanList()]).done(function (res) {
|
|
|
|
if (saPlan.length == 0) {
|
|
$("#Toolbar_Copy").hide();
|
|
}
|
|
else {
|
|
$("#Toolbar_Copy").show();
|
|
}
|
|
});
|
|
}
|
|
else if (canDo.action === 'add') {
|
|
//新增時若方案筆數>1時,則顯示複製按鈕
|
|
$.whenArray([qryPlanList()]).done(function (res) {
|
|
|
|
if (saPlan.length == 0) {
|
|
$("#Toolbar_Copy").hide();
|
|
}
|
|
else {
|
|
$("#Toolbar_Copy").show();
|
|
}
|
|
});
|
|
}
|
|
else {
|
|
|
|
$("#Toolbar_Copy").hide();
|
|
}
|
|
|
|
}
|
|
else {
|
|
showMsg(i18next.t("message.Delete_Failed") + '<br>' + res.MSG, 'error');// ╠message.Delete_Failed⇒刪除失敗╣
|
|
}
|
|
}, function () {
|
|
showMsg(i18next.t("message.Delete_Error"), 'error'); // ╠message.Delete_Error⇒刪除資料異常╣
|
|
});
|
|
},
|
|
//加購服務 儲存
|
|
fnSaveTab4 = function () {
|
|
|
|
var blCheck = true;
|
|
var trlist = $("#table_box_additionalpurchase").find("tr");
|
|
for (var i = 0; i < trlist.length; i++) {
|
|
var tr = $(trlist[i]);
|
|
if ($(tr).find('input[data-input=InterbankPrice]').val() == "") {
|
|
blCheck = false;
|
|
break;
|
|
}
|
|
}
|
|
if (!blCheck) {
|
|
showMsg("同業價不可為空!");
|
|
return false;
|
|
}
|
|
|
|
var data = {};
|
|
data.LangID = $('#LangID').val();
|
|
data.ServiceID = $("#hidServiceID").val();
|
|
//訂單問題
|
|
data.AddOrderQuestions = JSON.stringify(oAdditionalServices.AddOrderQuestions);
|
|
data.AdditionalPurchase = JSON.stringify(oAdditionalServices.AdditionalPurchase);
|
|
return g_api.ConnectLite("ServiceMaintain_Upd", "UpdateAdditional", data, function (res) {
|
|
if (res.RESULT) {
|
|
|
|
var oRes = res.DATA.rel;
|
|
showMsg(i18next.t("message.Modify_Success"), 'success'); //╠message.Insert_Success⇒新增成功╣
|
|
//$("#alitab3").click();
|
|
}
|
|
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⇒新增資料異常╣
|
|
});
|
|
},
|
|
//設置服務子類別
|
|
setSubCategoryDrop1 = function () {
|
|
return g_api.ConnectLite(canDo.QueryPrgId, "QuerySubCategoryList", { LangID: $('#LangID').val() || sLang }, function (res) {
|
|
if (res.RESULT) {
|
|
let saSubCategory = res.DATA.rel;
|
|
if (saSubCategory.length > 0) {
|
|
$('#CategoryIDPop').html('').append(createOptions(saSubCategory, 'CategoryID', 'CategoryName', false));
|
|
}
|
|
}
|
|
});
|
|
},
|
|
//初始化訂單問題列表的Gird
|
|
fnInitSurveyQustionGrid = function () {
|
|
//問卷類別綁定
|
|
fnSetArgDrop([{
|
|
ArgClassID: 'SurveyType',
|
|
Select: $('#SurveyTypePop'),
|
|
ShowId: true
|
|
}]);
|
|
setSubCategoryDrop1();
|
|
//綁定訂單問題事件部分
|
|
$('#btnQrySurvey').unbind('click').click(function () {
|
|
fnGetSurveyQustionList();
|
|
});
|
|
|
|
$("#jsSurveyQustionGrid").jsGrid({
|
|
width: "100%",
|
|
autoload: true,
|
|
pageLoading: true,
|
|
paging: false,
|
|
rowClick: function (args) {
|
|
$(args.event.currentTarget).find('[type=checkbox]').click();
|
|
},
|
|
rowDoubleClick: function (args) {
|
|
$(args.event.currentTarget).find('[type=checkbox]').click();
|
|
},
|
|
fields: [
|
|
{
|
|
width: 30, sorting: false, align: "center",
|
|
itemTemplate: function (value, item) {
|
|
return $("<input>", {
|
|
type: 'checkbox', click: function (e) {
|
|
e.stopPropagation();
|
|
},
|
|
"SurveyID": item.SurveyID,
|
|
"SurveyName": item.SurveyName,
|
|
"AnswerTypeName": item.AnswerTypeName
|
|
});
|
|
}
|
|
},
|
|
{ name: "SurveyTypeName", title: '問題類型', editing: false, align: "left", width: 80 },
|
|
{ name: "SurveyName", title: '問題', editing: false, align: "left", width: 250 },
|
|
{ name: "AnswerTypeName", title: '答案類型', editing: false, align: "left", width: 70 }
|
|
],
|
|
controller: {
|
|
loadData: function (args) {
|
|
if (args.IsFilter === undefined) {
|
|
fnGetSurveyQustionList(args);
|
|
}
|
|
else {
|
|
return args.PopData;
|
|
}
|
|
},
|
|
},
|
|
onInit: function (args) {
|
|
oGrid = args.grid;
|
|
|
|
}
|
|
});
|
|
|
|
|
|
},
|
|
//取得訂單問題
|
|
fnGetSurveyQustionList = function () {
|
|
|
|
return g_api.ConnectLite(canDo.QueryPrgId, "QueryQuestion", {
|
|
|
|
SurveyType: $("#SurveyTypePop").val(),
|
|
CategoryID: $("#CategoryIDPop").val()
|
|
|
|
}, function (res) {
|
|
if (res.RESULT) {
|
|
let saSubCategory = res.DATA.rel;
|
|
if (saSubCategory.length > 0) {
|
|
$("#jsSurveyQustionGrid").jsGrid("loadData", {
|
|
IsFilter: true,
|
|
PopData: {
|
|
data: saSubCategory,
|
|
itemsCount: saSubCategory.length
|
|
}
|
|
});
|
|
}
|
|
}
|
|
});
|
|
},
|
|
//綁定方案頁的客制化方案
|
|
fnBindCusName = function () {
|
|
var sKeysHtml = '';
|
|
$.each(curPlan.PlanCusName, function (idx, item) {
|
|
sKeysHtml += '<tr data-id="' + item.Guid + '">\
|
|
<td><input type="text" data-input="Destination" class="form-control w100p " value="' + (item.Destination || '') + '"></td>\
|
|
<td class="wcenter">\
|
|
<i class="glyphicon glyphicon-trash deleteplancusName" data-value="' + item.Guid + '" title="刪除"></i>\
|
|
</td>\
|
|
</tr>';
|
|
});
|
|
$('#table_box_destination').html(sKeysHtml).find('.deleteplancusName').on('click', function () {
|
|
var sId = $(this).attr('data-value'),
|
|
saNewList = [];
|
|
//若失敗後,資料已經變成字串了。需要再次轉回陣列,才能刪除
|
|
if (typeof curPlan.PlanCusName=== 'string') {
|
|
curPlan.PlanCusName = JSON.parse(curPlan.PlanCusName || '[]');
|
|
}
|
|
var sDelGuid = "";
|
|
$.each(curPlan.PlanCusName, function (idx, item) {
|
|
sDelGuid = item.Guid;
|
|
if (sId !== item.Guid) {
|
|
saNewList.push(item);
|
|
}
|
|
});
|
|
$(this).parents('tr').remove();
|
|
curPlan.PlanCusName = saNewList;
|
|
setPlanPricingAndInventory("Destination", 'del', sDelGuid);
|
|
});
|
|
canDo._transLang($('#table_box_destination'));
|
|
$('#table_box_destination [data-input]').on('change click', function () {
|
|
var sKey = $(this).attr('data-input'),
|
|
sId = $(this).parents('tr').attr('data-id'),
|
|
sVal = this.value;
|
|
|
|
$.each(curPlan.PlanCusName, function (idx, item) {
|
|
if (sId === item.Guid) {
|
|
item[sKey] = sVal;
|
|
return false;
|
|
}
|
|
});
|
|
|
|
$('#jsPlanPricingAndInventoryGrid').find('[data-id=' + sId+']').each(function () {
|
|
$(this).html(sVal);
|
|
});
|
|
|
|
});
|
|
},
|
|
//綁定方案頁的客制化方案
|
|
fnBindPlanSpec = function () {
|
|
var sKeysHtml = '';
|
|
$.each(curPlan.PlanSpec, function (idx, item) {
|
|
sKeysHtml += '<tr data-id="' + item.Guid + '">\
|
|
<td><input type="text" data-input="Spec" class="form-control w100p " value="' + (item.Spec || '') + '"></td>\
|
|
<td class="wcenter">\
|
|
<i class="glyphicon glyphicon-trash deleteplanspec" data-value="' + item.Guid + '" title="刪除"></i>\
|
|
</td>\
|
|
</tr>';
|
|
});
|
|
$('#table_box_spec').html(sKeysHtml).find('.deleteplanspec').on('click', function () {
|
|
var sId = $(this).attr('data-value'),
|
|
saNewList = [];
|
|
//若失敗後,資料已經變成字串了。需要再次轉回陣列,才能刪除
|
|
if (typeof curPlan.PlanSpec === 'string') {
|
|
curPlan.PlanSpec = JSON.parse(curPlan.PlanSpec || '[]');
|
|
}
|
|
var sDelGuid = "";
|
|
$.each(curPlan.PlanSpec, function (idx, item) {
|
|
sDelGuid = item.Guid;
|
|
if (sId !== item.Guid) {
|
|
saNewList.push(item);
|
|
}
|
|
});
|
|
$(this).parents('tr').remove();
|
|
curPlan.PlanSpec = saNewList;
|
|
setPlanPricingAndInventory("Spec", 'del', sDelGuid);
|
|
});
|
|
canDo._transLang($('#table_box_spec'));
|
|
$('#table_box_spec [data-input]').on('change click', function () {
|
|
var sKey = $(this).attr('data-input'),
|
|
sId = $(this).parents('tr').attr('data-id'),
|
|
sVal = this.value;
|
|
|
|
$.each(curPlan.PlanSpec, function (idx, item) {
|
|
if (sId === item.Guid) {
|
|
item[sKey] = sVal;
|
|
return false;
|
|
}
|
|
});
|
|
|
|
$('#jsPlanPricingAndInventoryGrid').find('[data-id=' + sId + ']').each(function () {
|
|
$(this).html(sVal);
|
|
});
|
|
});
|
|
},
|
|
//綁定加購服務 規格
|
|
fnBindAdditionalPurchase = function () {
|
|
|
|
var cSpanCheckBoxHtml = function (PlanIDs) {
|
|
|
|
var itemHtml = "";
|
|
$.each(saPlan, function (indx, val) {
|
|
itemHtml += '<label for="Status_' + indx + '">';
|
|
if (PlanIDs.indexOf(val.PlanID) > -1) {
|
|
|
|
itemHtml += '<input id="Status_' + indx + '" name="PlanIDs" type="checkbox" checked="checked" data-value="' + val.PlanID + '"><span>' + val.PlanName + ' </span>';
|
|
}
|
|
else {
|
|
|
|
itemHtml += '<input id="Status_' + indx + '" name="PlanIDs" type="checkbox" data-value="' + val.PlanID + '"><span>' + val.PlanName + ' </span>';
|
|
}
|
|
itemHtml += '</label>';
|
|
});
|
|
return itemHtml;
|
|
};
|
|
var sKeysHtml = '';
|
|
$.each(oAdditionalServices.AdditionalPurchase, function (idx, item) {
|
|
sKeysHtml += '<tr data-id="' + item.Guid + '">\
|
|
<td class="wcenter">' + (idx + 1) + '</td>\
|
|
<td><input type="text" data-input="ServiceName" class="form-control w100p " value="' + (item.ServiceName || '') + '"></td>\
|
|
<td><input type="text" data-input="Price" class="form-control w100p " value="' + (item.Price || '') + '"></td>\
|
|
<td><input type="text" data-input="InterbankPrice" class="form-control w100p " value="' + (item.InterbankPrice || '') + '"></td>\
|
|
<td>'+ cSpanCheckBoxHtml((item.PlanIDs || ''))+ '</td>\
|
|
<td><input type="text" data-input="Inventory" class="form-control w100p " value="' + (item.Inventory || '') + '"></td>\
|
|
<td class="wcenter">\
|
|
<i class="glyphicon glyphicon-trash deleteadditional" data-value="' + item.Guid + '" title="刪除"></i>\
|
|
</td>\
|
|
</tr>';
|
|
});
|
|
$('#table_box_additionalpurchase').html(sKeysHtml).find('.deleteadditional').on('click', function () {
|
|
var sId = $(this).attr('data-value'),
|
|
saNewList = [];
|
|
//若失敗後,資料已經變成字串了。需要再次轉回陣列,才能刪除
|
|
if (typeof oAdditionalServices.AdditionalPurchase === 'string') {
|
|
oAdditionalServices.AdditionalPurchase = JSON.parse(oAdditionalServices.AdditionalPurchase || '[]');
|
|
}
|
|
|
|
$.each(oAdditionalServices.AdditionalPurchase, function (idx, item) {
|
|
if (sId !== item.Guid) {
|
|
saNewList.push(item);
|
|
}
|
|
});
|
|
$(this).parents('tr').remove();
|
|
oAdditionalServices.AdditionalPurchase = saNewList;
|
|
});
|
|
canDo._transLang($('#table_box_additionalpurchase'));
|
|
$('#table_box_additionalpurchase [data-input]').on('change click', function () {
|
|
var sKey = $(this).attr('data-input'),
|
|
sId = $(this).parents('tr').attr('data-id'),
|
|
sVal = this.value;
|
|
|
|
$.each(oAdditionalServices.AdditionalPurchase, function (idx, item) {
|
|
if (sId === item.Guid) {
|
|
item[sKey] = sVal;
|
|
return false;
|
|
}
|
|
});
|
|
});
|
|
$('#table_box_additionalpurchase').find('input[name=PlanIDs]').on('click', function () {
|
|
|
|
var sKey = this.checked,
|
|
sId = $(this).parents('tr').attr('data-id'),
|
|
sVal = $(this).attr('data-value');
|
|
$.each(oAdditionalServices.AdditionalPurchase, function (idx, item) {
|
|
if (sId === item.Guid) {
|
|
if (sKey) {
|
|
item["PlanIDs"] += sVal+',' ;
|
|
}
|
|
else {
|
|
|
|
item["PlanIDs"] = item["PlanIDs"].replace(sVal + ',', '');
|
|
}
|
|
return false;
|
|
}
|
|
});
|
|
});
|
|
|
|
},
|
|
//綁定服務提供時間
|
|
fnBindPPTimes = function () {
|
|
var sKeysHtml = '';
|
|
$.each(canDo.data.PPTimes, function (idx, item) {
|
|
sKeysHtml += '<tr data-id="' + item.Guid + '">\
|
|
<td class="wcenter">' + (idx + 1) + '</td>\
|
|
<td><input type="text" data-input="TimeS" maxlength="5" class="form-control w100p " value="' + (item.TimeS || '') + '"></td>\
|
|
<td class="wcenter">~</td>\
|
|
<td><input type="text" data-input="TimeE" maxlength="5" class="form-control w100p " value="' + (item.TimeE || '') + '"></td>\
|
|
<td class="wcenter">\
|
|
<i class="glyphicon glyphicon-trash deletetime" data-value="' + item.Guid + '" title="刪除"></i>\
|
|
</td>\
|
|
</tr>';
|
|
});
|
|
$('#table_box_time').html(sKeysHtml).find('.deletetime').on('click', function () {
|
|
var sId = $(this).attr('data-value'),
|
|
saNewList = [];
|
|
//若失敗後,資料已經變成字串了。需要再次轉回陣列,才能刪除
|
|
if (typeof canDo.data.PPTimes === 'string') {
|
|
canDo.data.PPTimes = JSON.parse(canDo.data.PPTimes || '[]');
|
|
}
|
|
|
|
$.each(canDo.data.PPTimes, function (idx, item) {
|
|
if (sId !== item.Guid) {
|
|
saNewList.push(item);
|
|
}
|
|
});
|
|
$(this).parents('tr').remove();
|
|
canDo.data.PPTimes = saNewList;
|
|
});
|
|
canDo._transLang($('#table_box_time'));
|
|
$('#table_box_time [data-input]').on('change click', function () {
|
|
var sKey = $(this).attr('data-input'),
|
|
sId = $(this).parents('tr').attr('data-id'),
|
|
sVal = this.value;
|
|
|
|
$.each(canDo.data.PPTimes, function (idx, item) {
|
|
if (sId === item.Guid) {
|
|
item[sKey] = sVal;
|
|
return false;
|
|
}
|
|
});
|
|
});
|
|
},
|
|
//其他地點資訊
|
|
fnBindOtherDetials = function () {
|
|
var sKeysHtml = '';
|
|
$.each(canDo.data.OtherDetials, function (idx, item) {
|
|
sKeysHtml += '<tr data-id="' + item.Guid + '">\
|
|
<td class="wcenter">' + (idx + 1) + '</td>\
|
|
<td name="CusTitle" style="display: none;"><input type="text" data-input="CusTitle" class="form-control w100p " value="' + (item.CusTitle || '') + '"></td>\
|
|
<td><input type="text" data-input="CityName" data-id="' + item.Guid + '" data-cityid="' + item.CityID + '" class="form-control w100p " value="' + (item.CityName || '') + '"><button type="button" data-id="' + item.Guid + '" class="btn btn-success" id="btnQryPlace2"><i class="fa fa-search"></i></button></td>\
|
|
<td><input type="text" data-input="Address" class="form-control w100p " value="' + (item.Address || '') + '"></td>\
|
|
<td class="wcenter">\
|
|
<i class="glyphicon glyphicon-trash deleteotherDetials" data-value="' + item.Guid + '" title="刪除"></i>\
|
|
</td>\
|
|
</tr>';
|
|
});
|
|
$('#table_box_other').html(sKeysHtml).find('.deleteotherDetials').on('click', function () {
|
|
var sId = $(this).attr('data-value'),
|
|
saNewList = [];
|
|
//若失敗後,資料已經變成字串了。需要再次轉回陣列,才能刪除
|
|
if (typeof canDo.data.OtherDetials === 'string') {
|
|
canDo.data.OtherDetials = JSON.parse(canDo.data.OtherDetials || '[]');
|
|
}
|
|
|
|
$.each(canDo.data.OtherDetials, function (idx, item) {
|
|
if (sId !== item.Guid) {
|
|
saNewList.push(item);
|
|
}
|
|
});
|
|
$(this).parents('tr').remove();
|
|
canDo.data.OtherDetials = saNewList;
|
|
});
|
|
canDo._transLang($('#table_box_other'));
|
|
$('#table_box_other [data-input]').on('change click', function () {
|
|
var sKey = $(this).attr('data-input'),
|
|
sId = $(this).parents('tr').attr('data-id'),
|
|
sVal = this.value;
|
|
|
|
$.each(canDo.data.OtherDetials, function (idx, item) {
|
|
if (sId === item.Guid) {
|
|
item[sKey] = sVal;
|
|
return false;
|
|
}
|
|
});
|
|
});
|
|
|
|
$('#table_box_other button').on('click', function () {
|
|
// $('#RegionList2').modal('toggle');
|
|
$("#hidOtherGuid").val($(this).attr("data-id"));
|
|
|
|
var JqTreeObj2 = null;
|
|
layer.open({
|
|
type: 2,
|
|
title: '選擇地區',
|
|
shade: 0.75,
|
|
maxmin: true, //开启最大化最小化按钮
|
|
area: ['800px', '380px'],
|
|
content: '/Page/Pop/Region.html',
|
|
success: function (layero, index) {
|
|
var iframe = $('iframe').contents();
|
|
JqTreeObj2 = iframe.find("#ulTree").JqTreeInit(saRegionList,
|
|
{
|
|
idName: "id",//id对应的属性名称
|
|
nameName: "name",//name对应的属性名称
|
|
pIdName: "parent",//pId对应的属性名称
|
|
single: true, //此处指定是否单选 false-多选
|
|
expandLevel: -1 //此处指定展开级别 0-全部展开,1隱藏第三層,-1全部隱藏,只保留第一層
|
|
//其他参数 根据实际情况指定
|
|
},
|
|
function (JqTreeObj2) {
|
|
//回调函数 此处添加特殊的逻辑 JqTreeObj为树对象
|
|
});
|
|
|
|
|
|
},
|
|
btn: [i18next.t('common.Confirm'), i18next.t('common.Cancel')], //╠common.Confirm⇒確定╣╠common.Cancel⇒取消╣
|
|
yes: function (index, layero) {
|
|
|
|
var iframe = $('iframe').contents();
|
|
var nodes = JqTreeObj2.getCheckedDatas();
|
|
if (nodes == null || nodes == undefined) {
|
|
|
|
showMsg('請選擇區域!', 'warning'); //╠message.Insert_Success⇒新增成功╣
|
|
return false;
|
|
}
|
|
var sRegion = nodes.text;
|
|
var sRegionID = nodes.id.substr(1);
|
|
|
|
var saTemp = canDo.data.OtherDetials.filter((item1) => item1.Guid == $("#hidOtherGuid").val());
|
|
saTemp[0].CityID = sRegionID;
|
|
saTemp[0].CityName = sRegion;
|
|
|
|
$("#table_box_other td [data-id=" + $("#hidOtherGuid").val() + "]").val(sRegion);
|
|
$("#table_box_other td [data-id=" + $("#hidOtherGuid").val() + "]").attr("data-cityid", sRegionID)
|
|
layer.close(index);
|
|
}
|
|
});
|
|
});
|
|
if ($('input[type=radio][name=OtherMode]:checked').val() == "4") {
|
|
$('#table_thbox_other').find('[name=CusTitle]').show();
|
|
$('#table_box_other').find('[name=CusTitle]').show();
|
|
} else {
|
|
$('#table_thbox_other').find('[name=CusTitle]').hide();
|
|
$('#table_box_other').find('[name=CusTitle]').hide();
|
|
}
|
|
|
|
},
|
|
//服務常見問題
|
|
fnBindFQAs = function () {
|
|
var sKeysHtml = '';
|
|
$.each(canDo.data.FQAs, function (idx, item) {
|
|
sKeysHtml += '<tr data-id="' + item.Guid + '">\
|
|
<td class="wcenter">' + (idx + 1) + '</td>\
|
|
<td><input type="text" data-input="Question" class="form-control w100p " value="' + (item.Question || '') + '"></td>\
|
|
<td><input type="text" data-input="Answer" class="form-control w100p" value="' + (item.Answer || '') + '"></td>\
|
|
<td class="wcenter">\
|
|
<i class="glyphicon glyphicon-trash deletefqa" data-value="' + item.Guid + '" title="刪除"></i>\
|
|
</td>\
|
|
</tr>';
|
|
});
|
|
$('#table_box_fqa').html(sKeysHtml).find('.deletefqa').on('click', function () {
|
|
var sId = $(this).attr('data-value'),
|
|
saNewList = [];
|
|
//若失敗後,資料已經變成字串了。需要再次轉回陣列,才能刪除
|
|
if (typeof canDo.data.FQAs === 'string') {
|
|
canDo.data.FQAs = JSON.parse(canDo.data.FQAs || '[]');
|
|
}
|
|
|
|
$.each(canDo.data.FQAs, function (idx, item) {
|
|
if (sId !== item.Guid) {
|
|
saNewList.push(item);
|
|
}
|
|
});
|
|
$(this).parents('tr').remove();
|
|
canDo.data.FQAs = saNewList;
|
|
});
|
|
canDo._transLang($('#table_box_fqa'));
|
|
$('#table_box_fqa [data-input]').on('change click', function () {
|
|
var sKey = $(this).attr('data-input'),
|
|
sId = $(this).parents('tr').attr('data-id'),
|
|
sVal = this.value;
|
|
|
|
$.each(canDo.data.FQAs, function (idx, item) {
|
|
if (sId === item.Guid) {
|
|
item[sKey] = sVal;
|
|
return false;
|
|
}
|
|
});
|
|
});
|
|
},
|
|
//設置供應商
|
|
setSupplierDrop = function () {
|
|
return g_api.ConnectLite(canDo.QueryPrgId, "QuerySupplierList", { LangID: $('#LangID').val() || sLang }, function (res) {
|
|
if (res.RESULT) {
|
|
let saSupplier = res.DATA.rel;
|
|
if (saSupplier.length > 0) {
|
|
$('#SupplierID').append(createOptions(saSupplier, 'SupplierID', 'CompanyName', false)).select2();
|
|
}
|
|
}
|
|
});
|
|
},
|
|
//展覽主,子類別
|
|
setExhibCategory = function (id,flag) {
|
|
return g_api.ConnectLite(canDo.QueryPrgId, "QueryExhibCategoryList", { IsMainCategory: flag, LanguageID: ($('#LangID').val() || sLang) }, function (res) {
|
|
if (res.RESULT) {
|
|
let saSubCategory = res.DATA.rel;
|
|
if (saSubCategory.length > 0) {
|
|
$('#' + id).html('').append(createOptions(saSubCategory, 'CategoryID', 'CategoryName', false));
|
|
}
|
|
}
|
|
});
|
|
},
|
|
//初始化展覽問題列表的Gird
|
|
fnInitExhibitionGrid = function () {
|
|
//展覽主,子類別綁定
|
|
setExhibCategory("MainCategoryIDPop", "Y");
|
|
setExhibCategory("SubCategoryIDPop", "N");
|
|
|
|
//綁定訂單問題事件部分
|
|
$('#btnQryExhibition').unbind('click').click(function () {
|
|
fnGetExhibitionList();
|
|
});
|
|
|
|
$("#jsExhibitionGrid").jsGrid({
|
|
width: "100%",
|
|
autoload: true,
|
|
pageLoading: true,
|
|
paging: false,
|
|
rowClick: function (args) {
|
|
$(args.event.currentTarget).find('[type=checkbox]').click();
|
|
},
|
|
rowDoubleClick: function (args) {
|
|
$(args.event.currentTarget).find('[type=checkbox]').click();
|
|
},
|
|
fields: [
|
|
{
|
|
width: 30, sorting: false, align: "center",
|
|
itemTemplate: function (value, item) {
|
|
return $("<input>", {
|
|
type: 'checkbox', click: function (e) {
|
|
e.stopPropagation();
|
|
},
|
|
"ExhibitionID": item.ExhibitionID,
|
|
"ExhibitionName": item.ExhibitionName
|
|
});
|
|
}
|
|
},
|
|
{ name: "ExhibitionNo", title: '展覽號碼', editing: false, align: "left", width: 80 },
|
|
{ name: "ExhibitionName", title: '展覽名稱', editing: false, align: "left", width: 250 },
|
|
{ name: "AbbreviatedName", title: '展覽簡稱', editing: false, align: "left", width: 100 }
|
|
],
|
|
controller: {
|
|
loadData: function (args) {
|
|
if (args.IsFilter === undefined) {
|
|
fnGetExhibitionList(args);
|
|
}
|
|
else {
|
|
return args.PopData;
|
|
}
|
|
},
|
|
},
|
|
onInit: function (args) {
|
|
oGrid = args.grid;
|
|
|
|
}
|
|
});
|
|
|
|
|
|
//展會列表確認按鈕
|
|
$('#ExhibitionOK').click(function () {
|
|
$('#ExhibitionNames').val("");
|
|
$('#ExhibitionID').val("");
|
|
if ($('#jsExhibitionGrid').find('[type=checkbox]:checked').length > 0) {
|
|
var saExhibition = [];
|
|
var sExhibition = '';
|
|
$('#jsExhibitionGrid').find('[type=checkbox]:checked').each(function () {
|
|
saExhibition.push($(this).attr("ExhibitionID"));
|
|
sExhibition += $(this).attr("ExhibitionName")+";";
|
|
});
|
|
$('#ExhibitionNames').val(sExhibition);
|
|
$('#ExhibitionID').val(JSON.stringify(saExhibition));
|
|
};
|
|
|
|
|
|
});
|
|
|
|
},
|
|
//取得展覽列表
|
|
fnGetExhibitionList = function () {
|
|
|
|
return g_api.ConnectLite(canDo.QueryPrgId, "QueryExhibitionList", {
|
|
MainCategoryID: $("#MainCategoryIDPop").val(),
|
|
SubCategoryID: $("#SubCategoryIDPop").val(),
|
|
ExhibitionName: $("#ExhibitionNamePop").val(),
|
|
LangID: ($('#LangID').val() || sLang)
|
|
|
|
}, function (res) {
|
|
if (res.RESULT) {
|
|
let saSubCategory = res.DATA.rel;
|
|
if (saSubCategory.length > 0) {
|
|
$("#jsExhibitionGrid").jsGrid("loadData", {
|
|
IsFilter: true,
|
|
PopData: {
|
|
data: saSubCategory,
|
|
itemsCount: saSubCategory.length
|
|
}
|
|
});
|
|
}
|
|
}
|
|
});
|
|
};
|
|
};
|
|
|
|
require(['base', 'select2', 'jsgrid', 'filer', 'util', 'cando'], fnPageInit);//, 'common_eip', 'timepicker' 'timepicker',
|