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.
2206 lines
102 KiB
2206 lines
102 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 oTWCity = [];
|
|
var oTruck = [];
|
|
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', 'ServicesMemo','ExpensesMemo'],
|
|
/**
|
|
* 頁面初始化
|
|
* @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(fnSetArgDrop([{
|
|
ArgClassID: 'ServiceItem',
|
|
Select: $('#ItemType'),
|
|
ShowId: true
|
|
//,
|
|
//OnChange: function (data) {
|
|
// //$('#Toolbar_Qry').trigger('click');
|
|
// fnQSIDDrop();
|
|
//}
|
|
}]));
|
|
postArray.push(fnInitExhibitionGrid());
|
|
postArray.push(qryRegionList());
|
|
postArray.push(fnGetTruckInfoList());
|
|
postArray.push(fnGetTWCityList());
|
|
var rsSubCategoryIDs = [];
|
|
//加載報關類別,加載報價頁簽,加載運輸方式, 加載機場, 加載貨棧場, 加載倉庫
|
|
$.whenArray(postArray).done(function (res) {
|
|
$('#EscortFreeCityID').append(createOptions(oTWCity, 'id', 'text', false));
|
|
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([fnBindQSIDDrop(),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();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
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("ONSiteMaintain_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⇒新增資料異常╣
|
|
});
|
|
|
|
},
|
|
|
|
/**
|
|
* 上傳附件
|
|
* @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 () {
|
|
|
|
$("#ItemType").val('');
|
|
$("#QSID").val('');
|
|
$("input[name=ItemEffective]:eq(0)").attr("checked", 'checked');
|
|
$('.QSID').hide();
|
|
$('.Other').hide();
|
|
$('.Stacker').hide();
|
|
$('.Truck').hide();
|
|
UE.getEditor("UE_ExpensesMemo").setContent('', false);//清空内容
|
|
UE.getEditor("UE_ServicesMemo").setContent('', false);//清空内容
|
|
$("#jsGridCostRules").html("");
|
|
$("#table_FreeTb").html("");
|
|
$("#table_HolidayOvertimePay").html("");
|
|
$("#table_MarkupByModel").html("");
|
|
$("#EscortFreeCityID").val("");
|
|
$("#jsPlanOrderQuertionGrid").html("");
|
|
var trlist = $("#jsGridOtherCostRules").find("tr");
|
|
var tr = $(trlist[0]);
|
|
var tdlist = $(tr).find("td");
|
|
$($(tdlist[0])).find('input[name=ItemPricingMode]:eq(0)').attr('checked', 'checked');
|
|
$($(tdlist[1])).find('input[data-input=Price]').val('');
|
|
$($(tdlist[2])).find('input[data-input=InterbankPrice]').val('');
|
|
$($(tdlist[3])).find('input[data-input=Unit_Min]').val('');
|
|
},
|
|
|
|
//報價維護
|
|
fnBindQSIDDrop = function () {
|
|
|
|
var data = {
|
|
QuotationType: "",
|
|
LangType: $('#LangID').val(),
|
|
};
|
|
return g_api.ConnectLite(canDo.QueryPrgId, "QueryServiceQSList", data,
|
|
function (res) {
|
|
if (res.RESULT) {
|
|
var saList = res.DATA.rel;
|
|
if (saList.length > 0) {
|
|
var sOptions = createOptions(saList, 'QSID', 'QuotationName', false);
|
|
$('#QSID').html('');
|
|
$('#QSID').html(sOptions);
|
|
}
|
|
}
|
|
});
|
|
},
|
|
|
|
//通過項目查找報價部分
|
|
//報價維護
|
|
fnQSIDDrop = function () {
|
|
var ItemType = $('#ItemType').val();
|
|
var data = {
|
|
QuotationType: ItemType,
|
|
LangType: $('#LangID').val(),
|
|
};
|
|
if (ItemType) {
|
|
|
|
if (ItemType == '01' || ItemType == '02') {
|
|
$('#QSID').html();
|
|
$('.QSID').show();
|
|
$('.Other').hide();
|
|
$('.Stacker').hide();
|
|
$('.Truck').hide();
|
|
//卡車或者堆高機
|
|
return g_api.ConnectLite(canDo.QueryPrgId, "QueryServiceQSList", data,
|
|
function (res) {
|
|
if (res.RESULT) {
|
|
var saList = res.DATA.rel;
|
|
if (saList.length > 0) {
|
|
var sOptions = createOptions(saList, 'QSID', 'QuotationName', false);
|
|
$('#QSID').html(sOptions).on('change', function () {
|
|
|
|
if ($("#QSID").val()) {
|
|
return g_api.ConnectLite("ServiceQSMaintain_Upd", "QueryOne", { LangID: ($('#LangID').val() || sLang), QSID: $("#QSID").val() }, function (res1) {
|
|
if (res.RESULT) {
|
|
var QSData = res1.DATA.rel;
|
|
if ($('#ItemType').val() == '01') {
|
|
//堆高機
|
|
$('.Truck').hide();
|
|
$('.Stacker').show();
|
|
|
|
$('.jsGridCostRules').html('');
|
|
if (typeof QSData.CostRules === 'string') {
|
|
curPlan.StackerCostRules = JSON.parse(QSData.CostRules || '[]');
|
|
}
|
|
fnBindCostRules();
|
|
|
|
}
|
|
else {
|
|
//卡車
|
|
$('.Stacker').hide();
|
|
$('.Truck').show();
|
|
|
|
$('.jsGridCostRules').html('');
|
|
if (typeof QSData.TruckCostRules === 'string') {
|
|
curPlan.TruckCostRules = JSON.parse(QSData.TruckCostRules || '[]');
|
|
}
|
|
|
|
if (typeof QSData.TruckHolidayPay === 'string') {
|
|
curPlan.TruckHolidayPay = JSON.parse(QSData.TruckHolidayPay || '[]');
|
|
}
|
|
|
|
if (typeof QSData.TruckMarkupByModel === 'string') {
|
|
curPlan.TruckMarkupByModel = JSON.parse(QSData.TruckMarkupByModel || '[]');
|
|
}
|
|
|
|
fnBindFreeTb();
|
|
fnBindHolidayOvertimePay();
|
|
fnBindMarkupByModel();
|
|
$("#EscortFreeCityID").val(QSData.EscortFreeCityID);
|
|
}
|
|
canDo._setUEValues(QSData);
|
|
|
|
|
|
|
|
}
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
}
|
|
}
|
|
});
|
|
} else {
|
|
//非卡車或者堆高機
|
|
|
|
$('.QSID').hide();
|
|
$('.Other').show();
|
|
$('.Stacker').hide();
|
|
$('.Truck').hide();
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
$('.QSID').show();
|
|
$('.Other').hide();
|
|
$('.Stacker').hide();
|
|
$('.Truck').hide();
|
|
|
|
|
|
}
|
|
|
|
},
|
|
//區域列表
|
|
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;
|
|
}
|
|
});
|
|
},
|
|
//方案列表
|
|
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.Guid = guid();
|
|
oNewKey.ItemName = '新增項目';
|
|
oNewKey.ItemType = '';
|
|
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);
|
|
|
|
var IssueHtml = $("#btnPlan_temp").render(oNewPlan),
|
|
QryPlanOne = function (planflag, planid) {
|
|
if (planflag == "Y") {
|
|
//修改方案
|
|
return g_api.ConnectLite("ONSiteMaintain_Upd", "QueryPlanOne", { LangID: ($('#LangID').val() || sLang), ServiceID: $("#hidServiceID").val(), PlanID: planid }, function (res) {
|
|
if (res.RESULT) {
|
|
curPlan = res.DATA.rel;
|
|
|
|
//設定每個項目的資料
|
|
canDo._setFormVal(curPlan);
|
|
canDo._setUEValues(curPlan);
|
|
// curPlan.PictureID = curPlan.PictureID || guid();
|
|
}
|
|
});
|
|
}
|
|
else {
|
|
|
|
//新增方案
|
|
fnClearPlan();
|
|
|
|
curPlan.StackerCostRules = [];
|
|
curPlan.TruckCostRules = [];
|
|
curPlan.TruckHolidayPay = [];
|
|
curPlan.TruckMarkupByModel = [];
|
|
curPlan.OtherCostRules = [];
|
|
curPlan.PlanOrderQuestions = [];
|
|
|
|
}
|
|
};
|
|
|
|
|
|
$('.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) {
|
|
//方案存儲
|
|
$('#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);
|
|
});
|
|
});
|
|
if (planflag == "Y") {
|
|
//修改資料
|
|
$('#btnDelPlan').show();
|
|
$('#ItemType').val(curPlan.ItemType);
|
|
$('#QSID').val(curPlan.QSID);
|
|
$('#ItemType').prop('disabled', true);
|
|
$('#QSID').prop('disabled', true);
|
|
if ($('#ItemType').val() == '01') {
|
|
//堆高機
|
|
$('.Stacker').show();
|
|
$('.Truck').hide();
|
|
$('.Other').hide();
|
|
if (typeof curPlan.StackerCostRules === 'string') {
|
|
curPlan.StackerCostRules = JSON.parse(curPlan.StackerCostRules || '[]');
|
|
}
|
|
fnBindCostRules();
|
|
}
|
|
else if ($('#ItemType').val() == '02') {
|
|
//卡車
|
|
$('.Truck').show();
|
|
$('.Stacker').hide();
|
|
$('.Other').hide();
|
|
if (typeof curPlan.TruckCostRules === 'string') {
|
|
curPlan.TruckCostRules = JSON.parse(curPlan.TruckCostRules || '[]');
|
|
}
|
|
if (typeof curPlan.TruckHolidayPay === 'string') {
|
|
curPlan.TruckHolidayPay = JSON.parse(curPlan.TruckHolidayPay || '[]');
|
|
}
|
|
if (typeof curPlan.TruckMarkupByModel === 'string') {
|
|
curPlan.TruckMarkupByModel = JSON.parse(curPlan.TruckMarkupByModel || '[]');
|
|
}
|
|
fnBindFreeTb();
|
|
fnBindHolidayOvertimePay();
|
|
fnBindMarkupByModel();
|
|
}
|
|
else {
|
|
$('.QSID').hide();
|
|
$('.Truck').hide();
|
|
$('.Stacker').hide();
|
|
$('.Other').show();
|
|
//其他
|
|
if (typeof curPlan.OtherCostRules === 'string') {
|
|
curPlan.OtherCostRules = JSON.parse(curPlan.OtherCostRules || '[]');
|
|
}
|
|
fnBindOtherCostRules();
|
|
}
|
|
//方案訂單問題
|
|
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";
|
|
}
|
|
});
|
|
});
|
|
}
|
|
}
|
|
else {
|
|
//新增資料
|
|
$('#btnDelPlan').hide();
|
|
$('#ItemType').prop('disabled', false);
|
|
$('#QSID').prop('disabled', false);
|
|
$('#ItemType').on('change', function () {
|
|
fnQSIDDrop();
|
|
});
|
|
}
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
});
|
|
},
|
|
//設置其他頁簽的訂單問題
|
|
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("ONSiteMaintain_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("ONSiteMaintain_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("ONSiteMaintain_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 = canDo._getUEValues(data);
|
|
data.Guid = planid;
|
|
if (planflag == "Y") {
|
|
//修改
|
|
data = packParams(data, 'upd');
|
|
|
|
}
|
|
else {
|
|
data = packParams(data);
|
|
}
|
|
|
|
data.StackerCostRules = '[]';
|
|
data.TruckCostRules = '[]';
|
|
data.TruckHolidayPay = '[]';
|
|
data.TruckMarkupByModel = '[]';
|
|
data.OtherCostRules = '[]';
|
|
|
|
data.QSID = $("#QSID").val();
|
|
data.ItemType = $("#ItemType").val();
|
|
data.ItemName = $("#ItemType").find("option:selected").text().split('-')[1];
|
|
data.Effective = $('input[name="ItemEffective"]:checked').val();
|
|
data.PlanOrderQuestions = JSON.stringify(curPlan.PlanOrderQuestions);
|
|
|
|
if (data.ItemType == '01') {
|
|
//堆高機費用表
|
|
if (typeof curPlan.StackerCostRules === 'string') {
|
|
curPlan.StackerCostRules = JSON.parse(curPlan.StackerCostRules || '[]');
|
|
}
|
|
data.StackerCostRules = JSON.stringify(curPlan.StackerCostRules);
|
|
|
|
}
|
|
else if (data.ItemType == '02') {
|
|
//卡車費用表
|
|
var saTruckCostRules = [];
|
|
var trlist = $("#table_FreeTb").find("tr");
|
|
for (var i = 0; i < trlist.length; i++) {
|
|
var tr = $(trlist[i]);
|
|
var tdlist = $(tr).find("td");
|
|
for (var j = 1; j < tdlist.length; j++) {
|
|
var td = $(tdlist[j]);
|
|
var sCityID = $(td).find('input').attr("data-cityid");
|
|
var sTruckID = $(td).find('input').attr("data-truckid");
|
|
var iPrice = $(td).find('input[data-input=Price]').val();
|
|
|
|
var oNewKey = {};
|
|
//oNewKey.Guid = guid();
|
|
oNewKey.TruckID = sTruckID;
|
|
oNewKey.CityID = sCityID;
|
|
oNewKey.Price = iPrice;
|
|
saTruckCostRules.push(oNewKey);
|
|
}
|
|
|
|
}
|
|
|
|
data.TruckCostRules = JSON.stringify(saTruckCostRules);
|
|
//假日加班費
|
|
var saTruckHolidayPay = [];
|
|
trlist = $("#table_HolidayOvertimePay").find("tr");
|
|
tr = $(trlist[0]);
|
|
tdlist = $(tr).find("td");
|
|
for (var j = 1; j < tdlist.length; j++) {
|
|
var td = $(tdlist[j]);
|
|
var sTruckID = $(td).find('input').attr("data-truckid");
|
|
var iPrice = $(td).find('input[data-input=Price]').val();
|
|
|
|
var oNewKey = {};
|
|
//oNewKey.Guid = guid();
|
|
oNewKey.TruckID = sTruckID;
|
|
oNewKey.Type = '1';//1:假日加班費 2:車型加價
|
|
oNewKey.Price = iPrice;
|
|
saTruckHolidayPay.push(oNewKey);
|
|
}
|
|
|
|
data.TruckHolidayPay = JSON.stringify(saTruckHolidayPay);
|
|
//車型加價
|
|
var saTruckMarkupByModel = [];
|
|
trlist = $("#table_MarkupByModel").find("tr");
|
|
tr = $(trlist[0]);
|
|
tdlist = $(tr).find("td");
|
|
for (var j = 1; j < tdlist.length; j++) {
|
|
var td = $(tdlist[j]);
|
|
var sTruckID = $(td).find('input').attr("data-truckid");
|
|
var iPrice = $(td).find('input[data-input=Price]').val();
|
|
|
|
var oNewKey = {};
|
|
//oNewKey.Guid = guid();
|
|
oNewKey.TruckID = sTruckID;
|
|
oNewKey.Type = '2';//1:假日加班費 2:車型加價
|
|
oNewKey.Price = iPrice;
|
|
saTruckMarkupByModel.push(oNewKey);
|
|
}
|
|
|
|
data.TruckMarkupByModel = JSON.stringify(saTruckMarkupByModel);
|
|
|
|
|
|
} else {
|
|
//非卡車或堆高機時
|
|
var saOtherCostRules = [];
|
|
var trlist = $("#jsGridOtherCostRules").find("tr");
|
|
var tr = $(trlist[0]);
|
|
var tdlist = $(tr).find("td");
|
|
var sItemPricingMode = $($(tdlist[0])).find('input[name="ItemPricingMode"]:checked').val();
|
|
var iPrice = $($(tdlist[1])).find('input[data-input=Price]').val();
|
|
var iInterbankPrice = $($(tdlist[2])).find('input[data-input=InterbankPrice]').val();
|
|
var iUnitMin = $($(tdlist[3])).find('input[data-input=Unit_Min]').val();
|
|
var oNewKey = {};
|
|
oNewKey.Guid = guid();
|
|
oNewKey.ONSiteItemID = $("#hidServiceID").val();
|
|
oNewKey.PricingMode = sItemPricingMode;
|
|
oNewKey.Price = iPrice;
|
|
oNewKey.InterbankPrice = iInterbankPrice;
|
|
oNewKey.Unit_Min = iUnitMin;
|
|
saOtherCostRules.push(oNewKey);
|
|
data.OtherCostRules = JSON.stringify(saOtherCostRules);
|
|
}
|
|
data.LangID = $('#LangID').val();
|
|
data.ServiceID = $("#hidServiceID").val();
|
|
|
|
return g_api.ConnectLite("ONSiteMaintain_Upd", (planflag == "Y" ? "UpdatePlan" : "InsertPlan"), data, function (res) {
|
|
if (res.RESULT) {
|
|
|
|
var oRes = res.DATA.rel;
|
|
showMsg(i18next.t("message.Modify_Success"), 'success'); //╠message.Insert_Success⇒新增成功╣
|
|
if (planflag == "N") {
|
|
//新增一筆重新加載
|
|
$("#alitab3").click();
|
|
}
|
|
else {
|
|
//修改一筆不動畫面,把名稱改一下
|
|
$(".planbtnkey[data-value=" + planid + "]").val(data.ItemName);
|
|
}
|
|
}
|
|
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("ONSiteMaintain_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⇒刪除資料異常╣
|
|
});
|
|
},
|
|
//設置服務子類別
|
|
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
|
|
}
|
|
});
|
|
}
|
|
}
|
|
});
|
|
},
|
|
//綁定服務提供時間
|
|
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
|
|
}
|
|
});
|
|
}
|
|
}
|
|
});
|
|
},
|
|
/**
|
|
* Grid客戶化計價模式控件
|
|
* @param {Sring}flag 要綁定的資料標記
|
|
* @return {HTMLElement} DIV 物件
|
|
*/
|
|
fnCreatePriceModeInput = function (flag) {
|
|
var $div = $('<div>'),
|
|
data = [{ id: 'N', text: i18next.t('common.ByNumber') }, { id: 'T', text: i18next.t('common.ByWeight') }];//╠common.ByNumber⇒按件數計價╣ ╠common.ByWeight⇒按重量計價╣
|
|
$div.html(createRadios(data, 'id', 'text', '~PricingMode' + flag, flag, false, false));
|
|
return $div;
|
|
},
|
|
/**
|
|
* 取得卡車信息
|
|
*/
|
|
fnGetTruckInfoList = function () {
|
|
return g_api.ConnectLite(canDo.QueryPrgId, "QueryTruckInfoList", {}, function (res) {
|
|
if (res.RESULT) {
|
|
oTruck = res.DATA.rel;
|
|
|
|
}
|
|
});
|
|
},
|
|
/**
|
|
* 取得台灣城市信息
|
|
*/
|
|
fnGetTWCityList = function () {
|
|
return g_api.ConnectLite(Service.com, ComFn.GetArguments,
|
|
{
|
|
ArgClassID: 'TW',
|
|
ParentID: '',
|
|
ArgIDs: '',
|
|
LevelOfArgument: -1,
|
|
OrgID: ''
|
|
}, function (res) {
|
|
if (res.RESULT) {
|
|
oTWCity = res.DATA.rel;
|
|
}
|
|
});
|
|
},
|
|
/**
|
|
* 綁定堆高機費用表
|
|
*/
|
|
fnBindCostRules = function () {
|
|
$("#jsGridCostRules").jsGrid({
|
|
width: "100%",
|
|
height: "auto",
|
|
autoload: true,
|
|
filtering: false,
|
|
inserting: true,
|
|
editing: true,
|
|
pageLoading: true,
|
|
confirmDeleting: true,
|
|
invalidMessage: i18next.t('common.InvalidData'),// ╠common.InvalidData⇒输入的数据无效!╣
|
|
deleteConfirm: i18next.t('message.ConfirmToDelete'),// ╠message.ConfirmToDelete⇒確定要刪除嗎 ?╣
|
|
pageIndex: 1,
|
|
pageSize: 10000,
|
|
fields: [
|
|
{
|
|
name: "Index", title: '#', width: 50, align: 'center'
|
|
},
|
|
{// ╠common.Weight_Min⇒重量(小)╣
|
|
name: "Weight_Min", title: 'common.Weight_Min', width: 120, align: 'center', type: "text", validate: { validator: 'required', message: i18next.t('common.Weight_Min_required') }//╠common.Weight_Min_required⇒請輸入重量(小)╣
|
|
},
|
|
{// ╠common.Weight_Max⇒重量(大)╣
|
|
name: "Weight_Max", title: 'common.Weight_Max', width: 120, align: 'center', type: "text", validate: { validator: 'required', message: i18next.t('common.Weight_Max_required') }//╠common.Weight_Max_required⇒請輸入重量(大)╣
|
|
},
|
|
{// ╠common.Price⇒價格╣
|
|
name: "Price", title: 'common.Price', width: 120, align: 'right', type: "text", validate: { validator: 'required', message: i18next.t('common.Price_required') },//╠common.Price_required⇒請輸入價格╣
|
|
itemTemplate: function (val, item) {
|
|
return fMoney(val, 2, item.Currency);
|
|
},
|
|
insertTemplate: function (val, item) {
|
|
var oControl = $('<input type="text" class="form-control w100p" data-type="money" data-name="int" />');
|
|
moneyInput(oControl, 2);
|
|
return this.insertControl = oControl;
|
|
},
|
|
insertValue: function () {
|
|
return this.insertControl.attr('data-value');
|
|
},
|
|
editTemplate: function (val, item) {
|
|
var oControl = $('<input type="text" class="form-control w100p" data-type="money" data-name="int" />').val(val);
|
|
moneyInput(oControl, 2);
|
|
return this.editControl = oControl;
|
|
},
|
|
editValue: function () {
|
|
return this.editControl.attr('data-value');
|
|
}
|
|
},
|
|
{// ╠common.PricingMode⇒計價模式╣
|
|
name: "PricingMode", title: 'common.PricingMode', align: 'center', width: 180, type: "text",
|
|
itemTemplate: function (val, item) {
|
|
var oControl = fnCreatePriceModeInput(item.Index);
|
|
oControl.find(':input[value="' + val + '"]').click();
|
|
uniformInit(oControl);
|
|
return oControl;
|
|
},
|
|
insertTemplate: function (val, item) {
|
|
var oControl = fnCreatePriceModeInput('add');
|
|
setTimeout(function () {
|
|
oControl.find('label:first').click();
|
|
uniformInit(oControl);
|
|
}, 100);
|
|
return this.insertControl = oControl;
|
|
},
|
|
insertValue: function () {
|
|
return this.insertControl.find(':input:checked').val();
|
|
},
|
|
editTemplate: function (val, item) {
|
|
var oControl = fnCreatePriceModeInput('edit');
|
|
oControl.find(':input[value="' + val + '"]').click();
|
|
uniformInit(oControl);
|
|
return this.editControl = oControl;
|
|
},
|
|
editValue: function () {
|
|
return this.editControl.find(':input:checked').val();
|
|
}
|
|
},
|
|
{
|
|
name: "Memo", title: 'common.Memo', width: 200, type: "textarea"
|
|
},
|
|
{
|
|
type: "control", width: 50
|
|
}
|
|
],
|
|
controller: {
|
|
loadData: function (args) {
|
|
return {
|
|
data: curPlan.StackerCostRules,
|
|
itemsCount: curPlan.StackerCostRules.length //data.length
|
|
};
|
|
},
|
|
insertItem: function (args) {
|
|
args.Guid = guid();
|
|
args.Index = curPlan.StackerCostRules.length + 1;
|
|
curPlan.StackerCostRules.push(args);
|
|
},
|
|
updateItem: function (args) {
|
|
},
|
|
deleteItem: function (args) {
|
|
curPlan.StackerCostRules = Jsonremove(curPlan.StackerCostRules, 'Guid', args.Guid);
|
|
$.each(curPlan.StackerCostRules, function (idx, _data) {
|
|
_data.Index = idx + 1;
|
|
});
|
|
}
|
|
},
|
|
onInit: function (args) {
|
|
oGrid = args.Guid;
|
|
}
|
|
});
|
|
},
|
|
/**
|
|
* 綁定卡車費用表參數
|
|
*/
|
|
fnBindFreeTb = function () {
|
|
|
|
var sHeaderHtml = '';
|
|
//表頭
|
|
sHeaderHtml = '<tr><th>車型</th>';
|
|
$.each(oTruck, function (idx, item) {
|
|
sHeaderHtml += '<th>' + item.TruckName + '</th>';
|
|
});
|
|
sHeaderHtml += '</tr>';
|
|
|
|
sHeaderHtml += '<tr><th>最大載重</th>';
|
|
$.each(oTruck, function (idx, item) {
|
|
sHeaderHtml += '<th>' + item.MaxWeight + '</th>';
|
|
});
|
|
sHeaderHtml += '</tr>';
|
|
|
|
sHeaderHtml += '<tr><th>車廂尺寸</th>';
|
|
$.each(oTruck, function (idx, item) {
|
|
sHeaderHtml += '<th>' + item.Size + '</th>';
|
|
});
|
|
sHeaderHtml += '</tr>';
|
|
|
|
sHeaderHtml += '<tr><th>貨物限高</th>';
|
|
$.each(oTruck, function (idx, item) {
|
|
sHeaderHtml += '<th>' + item.GoodsHeight + '</th>';
|
|
});
|
|
sHeaderHtml += '</tr>';
|
|
$('#thFreeTbHeader').html(sHeaderHtml);
|
|
var sKeysHtml = '';
|
|
$.each(oTWCity, function (idx, item) {
|
|
sKeysHtml += '<tr data-id="' + item.id + '">\
|
|
<td class="wcenter">' + item.text + '</td>';
|
|
$.each(oTruck, function (idx1, item1) {
|
|
sKeysHtml += '<td><input type="text" data-cityid="' + item.id + '" data-truckid="' + item1.TruckID + '" data-input="Price" class="form-control w100p" ></td>';
|
|
});
|
|
sKeysHtml += '</tr>';
|
|
|
|
});
|
|
|
|
$('#table_FreeTb').html(sKeysHtml);
|
|
var saTruckCostRules = curPlan.TruckCostRules;
|
|
if (saTruckCostRules.length > 0) {
|
|
|
|
var trlist = $("#table_FreeTb").find("tr");
|
|
for (var i = 0; i < trlist.length; i++) {
|
|
var tr = $(trlist[i]);
|
|
var tdlist = $(tr).find("td");
|
|
for (var j = 0; j < tdlist.length; j++) {
|
|
var td = $(tdlist[j]);
|
|
var sCityID = $(td).find('input').attr("data-cityid");
|
|
var sTruckID = $(td).find('input').attr("data-truckid");
|
|
var iPrice = $(td).find('input[data-input=Price]').val();
|
|
var saTemp = saTruckCostRules.filter((item) => item.TruckID == sTruckID && item.CityID == sCityID);
|
|
if (saTemp.length > 0) {
|
|
$(td).find('input[data-input=Price]').val(saTemp[0].Price);
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
},
|
|
/**
|
|
* 綁定卡車費用假日加班費用
|
|
*/
|
|
fnBindHolidayOvertimePay = function () {
|
|
var sHeaderHtml = '';
|
|
//表頭
|
|
sHeaderHtml = '<tr><th>車型</th>';
|
|
$.each(oTruck, function (idx, item) {
|
|
sHeaderHtml += '<th>' + item.TruckName + '</th>';
|
|
});
|
|
sHeaderHtml += '</tr>';
|
|
$('#thHolidayOvertimePay').html(sHeaderHtml);
|
|
//内容
|
|
sHeaderHtml = '<tr><td></td>';
|
|
$.each(oTruck, function (idx, item) {
|
|
sHeaderHtml += '<td><input type="text" data-truckid="' + item.TruckID + '" data-input="Price" class="form-control w100p" ></td>';
|
|
});
|
|
sHeaderHtml += '</tr>';
|
|
$('#table_HolidayOvertimePay').html(sHeaderHtml);
|
|
|
|
var saTruckHolidayPay = curPlan.TruckHolidayPay;
|
|
if (saTruckHolidayPay.length > 0) {
|
|
|
|
var trlist = $("#table_HolidayOvertimePay").find("tr");
|
|
var tr = $(trlist[0]);
|
|
var tdlist = $(tr).find("td");
|
|
for (var j = 1; j < tdlist.length; j++) {
|
|
var td = $(tdlist[j]);
|
|
var sTruckID = $(td).find('input').attr("data-truckid");
|
|
|
|
var saTemp = saTruckHolidayPay.filter((item) => item.TruckID == sTruckID);
|
|
if (saTemp.length > 0) {
|
|
$(td).find('input[data-input=Price]').val(saTemp[0].Price);
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
/**
|
|
* 綁定卡車費用車型加價
|
|
*/
|
|
fnBindMarkupByModel = function () {
|
|
var sHeaderHtml = '';
|
|
//表頭
|
|
sHeaderHtml = '<tr><th>車型</th>';
|
|
$.each(oTruck, function (idx, item) {
|
|
sHeaderHtml += '<th>' + item.TruckName + '</th>';
|
|
});
|
|
sHeaderHtml += '</tr>';
|
|
$('#thMarkupByModel').html(sHeaderHtml);
|
|
//内容
|
|
sHeaderHtml = '<tr><td class="wcenter">尾門</td>';
|
|
$.each(oTruck, function (idx, item) {
|
|
|
|
sHeaderHtml += '<td><input type="text" data-truckid="' + item.TruckID + '" data-input="Price" class="form-control w100p" ></td>';
|
|
|
|
});
|
|
sHeaderHtml += '</tr>';
|
|
$('#table_MarkupByModel').html(sHeaderHtml);
|
|
var saTruckMarkupByModel = curPlan.TruckMarkupByModel;
|
|
if (saTruckMarkupByModel.length > 0) {
|
|
|
|
var trlist = $("#table_MarkupByModel").find("tr");
|
|
var tr = $(trlist[0]);
|
|
var tdlist = $(tr).find("td");
|
|
for (var j = 1; j < tdlist.length; j++) {
|
|
var td = $(tdlist[j]);
|
|
var sTruckID = $(td).find('input').attr("data-truckid");
|
|
|
|
var saTemp = saTruckMarkupByModel.filter((item) => item.TruckID == sTruckID);
|
|
if (saTemp.length > 0) {
|
|
$(td).find('input[data-input=Price]').val(saTemp[0].Price);
|
|
}
|
|
}
|
|
|
|
}
|
|
},
|
|
/**
|
|
* 綁定非卡車堆高機的部分
|
|
*/
|
|
fnBindOtherCostRules = function () {
|
|
var saOtherCostRules = curPlan.OtherCostRules;
|
|
if (saOtherCostRules.length > 0) {
|
|
|
|
var trlist = $("#jsGridOtherCostRules").find("tr");
|
|
var tr = $(trlist[0]);
|
|
var tdlist = $(tr).find("td");
|
|
var saTemp = saOtherCostRules[0];
|
|
$($(tdlist[0])).find('input[name=ItemPricingMode][value=' + saTemp.PricingMode+']').attr('checked', 'true');
|
|
$($(tdlist[1])).find('input[data-input=Price]').val(saTemp.Price);
|
|
$($(tdlist[2])).find('input[data-input=InterbankPrice]').val(saTemp.InterbankPrice);
|
|
$($(tdlist[3])).find('input[data-input=Unit_Min]').val(saTemp.Unit_Min);
|
|
}
|
|
};
|
|
};
|
|
|
|
require(['base', 'select2', 'jsgrid', 'filer', 'formatnumber', 'util', 'cando'], fnPageInit);
|