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.

1613 lines
61 KiB

3 years ago
  1. 'use strict';
  2. var sProgramId = getProgramId(),
  3. sQueryPrgId = getQueryPrgId(),
  4. sAction = getUrlParam('Action') || 'Add',
  5. sDataId = getUrlParam('guid'),
  6. sDataSN = getUrlParam('SN'),
  7. sFlag = getUrlParam('Flag'),
  8. sGoTab = getUrlParam('GoTab'),
  9. sBillNOGO = getUrlParam('BillNO'),
  10. sCheckId = sDataId,
  11. sOrganizers = [],
  12. sSelectedOrganizers = [],
  13. saContactorList = [],
  14. saExhibitionContactorslist = [],
  15. intFormalCustomer = 0,
  16. oCalendar = null,
  17. intOpenLayer = 0,
  18. MaxOrganizerCount = $(".Organizer").length + 1,//organizer count
  19. fnPageInit = function () {
  20. var oGrid = null,
  21. oForm = $('#form_main'),
  22. oValidator = null,
  23. sTransportRequireOptionsHtml = '',
  24. sTransportOptionsHtml = '',
  25. sProcessingModeOptionsHtml = '',
  26. sPotentialOptionsHtml = '',
  27. sCoopTrasportCompanyHtml = '',
  28. oAddItem = {},
  29. oPrintMenu = {},
  30. oCurData = {},
  31. oGrid2 = null,
  32. oData1 = null,
  33. oData2 = null,
  34. saGridData = [],
  35. saCustomers = [],
  36. saBatchArr = [],
  37. saPort = [],
  38. saCurrency = [],
  39. saFeeClass = [],
  40. saAccountingCurrency = [],
  41. saRefNumber = [],
  42. saChooseContactorList = [],
  43. nowResponsiblePerson = '',
  44. sColumnWidth = "4",
  45. sCustomerCName = "",
  46. /**
  47. * 獲取資料
  48. * @return {Object} Ajax 物件
  49. */
  50. fnGet = function () {
  51. if (sDataId) {
  52. //$('#litab3').show();
  53. return g_api.ConnectLite('Customers_Qry', ComFn.GetOne,
  54. {
  55. Guid: sDataId
  56. },
  57. function (res) {
  58. if (res.RESULT) {
  59. oData1 = res;
  60. var oRes = res.DATA.rel;
  61. $("#CustomerCName").val(oRes.CustomerCName);
  62. sCustomerCName = oRes.CustomerCName;
  63. $("#CustomerEName").val(oRes.CustomerEName);
  64. $("#UniCode").val(oRes.UniCode);
  65. $("#Telephone").val(oRes.Telephone);
  66. $("[name='TransactionType'][value='" + oRes.TransactionType + "']").attr("checked", true);
  67. $("[name='IsBlackList'][value='" + oRes.IsBlackList + "']").click().click();
  68. $("[name='IsImporter'][value='" + oRes.IsImporter + "']").click().click();
  69. $("#BlackListReason").val(oRes.BlackListReason);
  70. if(oRes.CoopTrasportCompany){
  71. $("#CoopTrasportCompany").val(oRes.CoopTrasportCompany.split(',')).trigger('change');
  72. }
  73. if(oRes.IsAudit == "Y"){
  74. intFormalCustomer = 1;
  75. $("#btnCorrespondFormalCus").hide();
  76. $("#CustomerCName").attr('disabled', true);
  77. $("#CustomerEName").attr('disabled', true);
  78. $("#UniCode").attr('disabled', true);
  79. $("#Telephone").attr('disabled', true);
  80. //$("#CoopTrasportCompany").attr('disabled', true);
  81. $("[name=IsBlackList]").attr('disabled', true);
  82. $("#BlackListReason").attr('disabled', true);
  83. }
  84. }
  85. });
  86. }
  87. else {
  88. return $.Deferred().resolve().promise();
  89. }
  90. },
  91. /**
  92. * 抓去聯絡人列表資料
  93. * @return {Object} ajax物件
  94. */
  95. fnGetExhibitionContactorslist = function () {
  96. if (sDataId) {
  97. return g_api.ConnectLite(sProgramId, 'GetExhibitionContactorslist', {
  98. ExhibitionSN : sDataSN,
  99. CustomerId: sDataId
  100. },
  101. function (res) {
  102. if (res.RESULT) {
  103. saExhibitionContactorslist = []
  104. saExhibitionContactorslist = res.DATA.rel;
  105. saExhibitionContactorslist = Enumerable.From(saExhibitionContactorslist).Where(function (e) { return e.Mark == ''; }).ToArray();
  106. $('#Contactor-' + sDataSN).html();
  107. $('#Contactor-' + sDataSN).html(createOptions(saExhibitionContactorslist, 'Guid', 'ContactorName')).select2();
  108. }
  109. });
  110. }
  111. else {
  112. return $.Deferred().resolve().promise();
  113. }
  114. },
  115. /**
  116. * 獲取資料
  117. * @return {Object} ajax物件
  118. */
  119. fnGetCalloutData = function () {
  120. if (sDataId) {
  121. return g_api.ConnectLite(sProgramId, 'GetCalloutData',
  122. {
  123. ExhibitionSN : sDataSN,
  124. Guid: sDataId
  125. },
  126. function (res) {
  127. if (res.RESULT) {
  128. oData2 = res;
  129. var oRes = res.DATA.rel;
  130. }
  131. });
  132. }
  133. else {
  134. return $.Deferred().resolve().promise();
  135. }
  136. },
  137. fnChooseContactors = function(){
  138. saContactorList = [];
  139. layer.open({
  140. type: 1, //0(信息框,默认)1(页面层)2(iframe层)3(加载层)4(tips层)
  141. title: "選擇聯絡人", // ╠common.CorrespondImpCus⇒對應正式客戶╣
  142. area: ['70%', '90%'],//寬度
  143. shade: 0.01,//遮罩
  144. closeBtn: 1,
  145. //maxmin: true, //开启最大化最小化按钮
  146. id: 'layer_ChooseContactors', //设定一个id,防止重复弹出
  147. offset: '10px',//右下角弹出
  148. anim: 0,//彈出動畫
  149. btn: [i18next.t('common.Confirm'), i18next.t('common.Cancel')],//╠common.Confirm⇒確定╣╠common.Cancel⇒取消╣
  150. btnAlign: 'c',//按鈕位置
  151. content: '<div class="pop-box col-sm-10 col-sm-offset-1">\
  152. <div id="jsGridChooseContactors"></div>\
  153. </div>',
  154. success: function (layero, index) {
  155. $("#jsGridChooseContactors").jsGrid({
  156. width: "100%",
  157. height: "auto",
  158. autoload: true,
  159. filtering: false,
  160. pageLoading: true,
  161. inserting: false,
  162. editing: false,
  163. sorting: false,
  164. paging: false,
  165. pageIndex: 1,
  166. pageSize: parent.SysSet.GridRecords || 10,
  167. confirmDeleting: true,
  168. deleteConfirm: i18next.t('message.ConfirmToDelete'),// ╠message.ConfirmToDelete⇒確定要刪除嗎 ?╣
  169. pagePrevText: "<",
  170. pageNextText: ">",
  171. pageFirstText: "<<",
  172. pageLastText: ">>",
  173. fields: [
  174. {
  175. name: "RowIndex", title: 'common.RowNumber', width: 5, align: "center",
  176. itemTemplate: function (value, item) {
  177. return $("<input>", {
  178. type: 'checkbox', click: function (e) {
  179. e.stopPropagation();
  180. if (this.checked) {
  181. item.RowIndex = saContactorList.length + 1;
  182. saContactorList.push(item.guid);
  183. }
  184. else {
  185. var saNewList2 = [];
  186. $.each(saContactorList, function (idx, data) {
  187. let i = 0;
  188. if (item.guid !== data.guid) {
  189. data.RowIndex = i++;
  190. saNewList2.push(data.guid);
  191. }
  192. });
  193. saContactorList = saNewList2;
  194. }
  195. }, disabled: function(){
  196. let blRepeat = false;
  197. $.each(saExhibitionContactorslist, function (idx, data) {
  198. if(item.guid == data.Guid){
  199. blRepeat = true;
  200. return;
  201. }
  202. });
  203. return blRepeat;
  204. }
  205. });
  206. }
  207. },
  208. {
  209. name: "ContactorName", title: 'common.Contactor', width: 25, align: "center"
  210. },
  211. {
  212. name: "JobTitle", title: 'common.JobTitle', width: 25, align: "center"
  213. },
  214. {
  215. name: "Telephone1", title: 'common.Telephone', width: 30
  216. },
  217. {
  218. name: "Ext1", title: 'common.EXT', width: 10
  219. },
  220. {
  221. name: "Email1", title: 'common.Email', width: 40
  222. }
  223. ],
  224. controller: {
  225. loadData: function (args) {
  226. return fnGetContactorsList(sDataId);
  227. },
  228. insertItem: function (args) {
  229. },
  230. updateItem: function (args) {
  231. },
  232. deleteItem: function (args) {
  233. }
  234. }
  235. });
  236. },
  237. yes: function (index, layero) {
  238. g_api.ConnectLite(sProgramId, 'ChooseContactor',
  239. {
  240. SN: sDataSN,
  241. guid: sDataId,
  242. contactor: saContactorList
  243. },
  244. function (res) {
  245. if (res.RESULT) {
  246. showMsg(i18next.t("message.Save_Success"), 'success');
  247. } else {
  248. showMsg(i18next.t("message.Save_Failed"), 'error'); // ╠message.Save_Failed⇒新增失敗╣
  249. }
  250. },
  251. function (res) {
  252. showMsg(i18next.t("message.Save_Failed"), 'error'); // ╠message.Save_Failed⇒新增失敗╣
  253. })
  254. layer.close(index);
  255. },
  256. end: function () {
  257. oGrid2.loadData();
  258. }
  259. });
  260. },
  261. fnGetContactorsList = function (guid) {
  262. return g_api.ConnectLite('Contactors_Qry', 'QueryByCustomer', {
  263. CustomerId: guid
  264. });
  265. },
  266. fnCreateContactor = function(){
  267. layer.open({
  268. type: 2, //0(信息框,默认)1(页面层)2(iframe层)3(加载层)4(tips层)
  269. title: i18next.t('common.InsertContactor'),// ╠common.CustomerTransferToFormal⇒匯入廠商轉正╣
  270. area: ['70%', '90%'],//寬度
  271. shade: 0.75,//遮罩
  272. maxmin: true, //开启最大化最小化按钮
  273. id: 'layer_InsertContactor', //设定一个id,防止重复弹出
  274. anim: 0,//彈出動畫
  275. btnAlign: 'c',//按鈕位置
  276. content: '../Crm/Contactors_Upd.html?Action=Add&Flag=Pop&CustomerId=' + sDataId + '&ExhibitionNO=' + sDataSN,
  277. success: function (layero, index) {
  278. var iframe = layero.find('iframe').contents();
  279. iframe.find('#hiddenIndex').val(index);
  280. },
  281. end: function () {
  282. oGrid2.loadData();
  283. }
  284. });
  285. },
  286. fnCorrespondFormalCus = function () {
  287. layer.open({
  288. type: 1, //0(信息框,默认)1(页面层)2(iframe层)3(加载层)4(tips层)
  289. title: i18next.t("common.CorrespondFormalCus"), // ╠common.CorrespondImpCus⇒對應正式客戶╣
  290. area: '640px;',//寬度
  291. shade: 0.75,//遮罩
  292. closeBtn: 1,
  293. //maxmin: true, //开启最大化最小化按钮
  294. id: 'layer_Correspond', //设定一个id,防止重复弹出
  295. offset: '100px',//右下角弹出
  296. anim: 0,//彈出動畫
  297. btn: [i18next.t('common.Confirm'), i18next.t('common.Cancel')],//╠common.Confirm⇒確定╣╠common.Cancel⇒取消╣
  298. btnAlign: 'c',//按鈕位置
  299. content: '<style>.select2-container{z-index: 39891015;}</style><div class="form-group">\
  300. <div class="col-sm-12">\
  301. <select class= "form-control w95p" id="CustomerId" name="CustomerId"></select>\
  302. </div>\
  303. </div >',
  304. success: function (layero, index) {
  305. g_api.ConnectLite(Service.sys, 'GetCustomerlist', {}, function (res) {
  306. if (res.RESULT) {
  307. var saList = res.DATA.rel;
  308. var sOptions = createOptions(saList, 'id', 'text');
  309. $('#CustomerId').html(sOptions).select2();
  310. }
  311. });
  312. transLang(layero);
  313. },
  314. yes: function (index, layero) {
  315. let sCustomerId = $('#CustomerId').val();
  316. if (!sCustomerId) {
  317. showMsg(i18next.t('message.SelectFormalCus'));//╠message.SelectFormalCus⇒請選擇對應的客戶╣
  318. return false;
  319. }
  320. var combinedata = {};
  321. combinedata.Type = "2";
  322. combinedata.guid1 = sDataId;
  323. combinedata.guid2 = sCustomerId;
  324. g_api.ConnectLite('Customers_Upd', 'CombineCustomer', combinedata
  325. , function (res) {
  326. if (res.DATA.rel) {
  327. sDataId = sCustomerId;
  328. showMsg(i18next.t("message.Correspond_Success"), 'success'); //╠message.Correspond_Success⇒對應成功╣
  329. layer.close(index);
  330. }
  331. else {
  332. showMsg(i18next.t("message.Correspond_Failed"), 'error');//╠message.Correspond_Failed⇒對應失敗╣
  333. }
  334. }
  335. , function () {
  336. showMsg(i18next.t("message.Correspond_Failed"), 'error');//╠message.Correspond_Failed⇒對應失敗╣
  337. });
  338. },
  339. end: function() {
  340. init();
  341. }
  342. });
  343. },
  344. /**
  345. * 綁定帳單
  346. */
  347. fnBindBillLists = function () {
  348. var oBillsBox = $('#accordion');
  349. oBillsBox.html('');
  350. //$('#tab3 .amountsum').val(0);
  351. if (oCurData.length > 0) {//實際帳單
  352. //oCurData = Enumerable.From(oCurData).OrderBy("x=>x.CreateDate").ToArray();
  353. var sContent = '<style>.select2-container--open { z-index: 1000000001;}.jsgrid-header-cell{padding:0 0;}</style>\
  354. <div class="row popsrow" style="margin-top:30px;">\
  355. <label class="col-sm-4 control-label wright" for="input-Default"><span data-i18n="提醒日期">提醒日期</span></label>\
  356. <div class="col-sm-6">\
  357. <input class="form-control w100p date-picker" type="text" id="RemindDate" maxlength="10" required>\
  358. </div>\
  359. </div>\
  360. <div class="row popsrow" style="margin-top:30px;">\
  361. <label class="col-sm-4 control-label wright " for="input-Default"><span data-i18n="提醒時間">提醒時間</span></label>\
  362. <div class="col-sm-6">\
  363. <input class="form-control" type="text" id="RemindTime" value = "09:00">\
  364. </div>\
  365. </div>';
  366. $.each(oCurData, function (idx, data) {
  367. if ($('.bill-box-' + data.ExhibitionNO).length === 0) {
  368. data.CreateDate = newDate(data.CreateDate, false, true);
  369. var sHtml = $("#temp_ExhibitionCustomerbox").render([data]);
  370. oBillsBox.append(sHtml);
  371. data.CalloutLog = data.CalloutLog.replace(/\r?\n/g, '<br>');
  372. var jsonCalloutLogData = JSON.parse(data.CalloutLog);
  373. var arrCalloutLogData = Enumerable.From(jsonCalloutLogData).ToArray();
  374. $.each(arrCalloutLogData, function (LogIdx, LogData) {
  375. LogData.ExhibitionNO = data.ExhibitionNO;
  376. LogData.Index = LogIdx;
  377. LogData.Memo = LogData.Memo.replace(/<br>/g, '\n');
  378. var sLogHtml = $("#temp_Memobox").render([LogData]);
  379. $('#accordion-' + data.ExhibitionNO).append(sLogHtml);
  380. })
  381. $('#TransportRequire-' + data.ExhibitionNO).html(sTransportRequireOptionsHtml).val(data.TransportRequire);
  382. $('#TransportationMode-' + data.ExhibitionNO).html(sTransportOptionsHtml).val(data.TransportationMode);
  383. $('#ProcessingMode-' + data.ExhibitionNO).html(sProcessingModeOptionsHtml).val(data.ProcessingMode);
  384. $('#Potential-' + data.ExhibitionNO).html(sPotentialOptionsHtml).val(data.Potential);
  385. if(data.CoopTrasportCompany){
  386. $('#CoopTrasportCompany-' + data.ExhibitionNO).html(sCoopTrasportCompanyHtml).val(data.CoopTrasportCompany.split(',')).select2();
  387. } else {
  388. $('#CoopTrasportCompany-' + data.ExhibitionNO).html(sCoopTrasportCompanyHtml).select2();
  389. }
  390. if(idx == 0){
  391. $("#collapse"+ data.ExhibitionNO).addClass("in");
  392. $('#btnCreateLog-' + data.ExhibitionNO).on('click', function () {
  393. fnCreateCalloutLog(data.ExhibitionNO);
  394. });
  395. } else {
  396. $('#TransportRequire-' + data.ExhibitionNO).attr('disabled', true);
  397. $('#TransportationMode-' + data.ExhibitionNO).attr('disabled', true);
  398. $('#ProcessingMode-' + data.ExhibitionNO).attr('disabled', true);
  399. $('#VolumeForecasting-' + data.ExhibitionNO).attr('disabled', true);
  400. $('#Potential-' + data.ExhibitionNO).attr('disabled', true);
  401. $('#BoothNumber-' + data.ExhibitionNO).attr('disabled', true);
  402. $('#NumberOfBooths-' + data.ExhibitionNO).attr('disabled', true);
  403. $('#CoopTrasportCompany-' + data.ExhibitionNO).attr('disabled', true);
  404. $('#Memo-' + data.ExhibitionNO).attr('disabled', true);
  405. $("#divLog-" + data.ExhibitionNO).hide();
  406. }
  407. $('#btnCallOutRemind-' + data.ExhibitionNO).on('click', function () {
  408. layer.open({
  409. type: 1, //0(信息框,默认)1(页面层)2(iframe层)3(加载层)4(tips层)
  410. title: "回撥提醒",//i18next.t('common.CustomerTransferToFormal'),// ╠common.CustomerTransferToFormal⇒匯入廠商轉正╣
  411. area: '580px;',//寬度
  412. shade: 0.75,//遮罩
  413. //maxmin: true, //开启最大化最小化按钮
  414. id: 'layer_btnCallOutRemind', //设定一个id,防止重复弹出
  415. offset: '10px',//右下角弹出
  416. anim: 0,//彈出動畫
  417. btn: [i18next.t('common.Toolbar_Save'), i18next.t('common.Cancel')],//╠common.Confirm⇒確定╣╠common.Cancel⇒取消╣
  418. btnAlign: ['c'],//按鈕位置
  419. content: sContent,
  420. success: function (layero, index) {
  421. //初始化日期格式
  422. $("#RemindDate").datepicker({
  423. });
  424. $('#RemindTime').timepicker({
  425. stepMinute: 30,
  426. });
  427. var dNowDate = new Date();
  428. dNowDate = dNowDate.setDate(dNowDate.getDate() + 1);
  429. dNowDate = new Date(dNowDate);
  430. var sNowDate = dNowDate.toISOString().slice(0, 10);
  431. $("#RemindDate").val(sNowDate);
  432. },
  433. yes: function (index, layero) {
  434. var sRemindDate = $("#RemindDate").val();
  435. var sRemidTime = $("#RemindTime").val();
  436. var OrgID = parent.OrgID;
  437. var UserID = parent.UserUD;
  438. var CalType = "03";
  439. var Title = data.ExhibitionName + "_回撥提醒";
  440. var dStartDate = new Date(sRemindDate);
  441. var dEndDate = dStartDate.getDate() + 1;
  442. var EndDate = new Date();
  443. var Color = parent.UserInfo.CalColor;
  444. var Importment = "M";
  445. var AllDay = '0';
  446. var Description = "";
  447. var OpenMent = "P";
  448. //防止使用者未填 提醒日期、提醒時間
  449. if (sRemindDate == "" || sRemindDate == null) {
  450. alert("請填入提醒日期");
  451. return;
  452. }
  453. if (sRemidTime == "" || sRemidTime == null) {
  454. var saTime = ["09", "00"];
  455. } else {
  456. var saTime = sRemidTime.split(":");
  457. }
  458. var sStartTimeStamp = dStartDate.setHours(saTime[0], saTime[1]);
  459. EndDate = EndDate.setDate(dEndDate);
  460. dStartDate = new Date(sStartTimeStamp);
  461. EndDate = new Date(EndDate);
  462. EndDate.setHours("00", "00");
  463. //date format => yyyy/mm/dd hh:mm
  464. var sStartDate = newDate(dStartDate);
  465. var sEndDate = newDate(EndDate);
  466. data = {
  467. OrgID: OrgID,
  468. UserID: UserID,
  469. CalType: CalType,
  470. Title: Title,
  471. AllDay: '1',
  472. StartDate: sStartDate,
  473. EndDate: sEndDate,
  474. Color: Color,
  475. Importment: Importment,
  476. AllDay: AllDay,
  477. Description: Description,
  478. OpenMent: OpenMent,
  479. GroupMembers: ""
  480. }
  481. g_api.ConnectLite("Calendar", ComFn.GetAdd, data,
  482. function (res) {
  483. if (res.RESULT) {
  484. var sNo = res.DATA.rel;
  485. showMsg(i18next.t("message.Save_Success"), 'success'); // ╠message.Save_Success⇒新增成功╣
  486. if (parent.Outklook) {
  487. outlookAPI(outlook.Calendar_Add, {
  488. NO: sNo,
  489. ResponseRequested: true
  490. });
  491. }
  492. layer.close(index);
  493. } else {
  494. showMsg(i18next.t("message.Save_Failed"), 'error'); // ╠message.Save_Failed⇒新增失敗╣
  495. }
  496. }
  497. );
  498. },
  499. end: function () {
  500. }
  501. });
  502. });
  503. $('.bills-box').show();
  504. }
  505. });
  506. }
  507. },
  508. /**
  509. * 設定運輸需求下拉選單
  510. */
  511. setTransportRequireDrop = function () {
  512. return g_api.ConnectLite(Service.com, ComFn.GetArguments, {
  513. ArgClassID: 'TransportRequire'
  514. }, function (res) {
  515. if (res.RESULT) {
  516. if (res.DATA.rel.length > 0) {
  517. sTransportRequireOptionsHtml = createOptions(res.DATA.rel, 'id', 'text');
  518. }
  519. else {
  520. sTransportRequireOptionsHtml = createOptions([]);
  521. }
  522. }
  523. });
  524. },
  525. /**
  526. * 設定運輸方式下拉選單
  527. */
  528. setTransportDrop = function () {
  529. return g_api.ConnectLite(Service.com, ComFn.GetArguments, {
  530. ArgClassID: 'Transport'
  531. }, function (res) {
  532. if (res.RESULT) {
  533. if (res.DATA.rel.length > 0) {
  534. sTransportOptionsHtml = createOptions(res.DATA.rel, 'id', 'text');
  535. }
  536. else {
  537. sTransportOptionsHtml = createOptions([]);
  538. }
  539. }
  540. });
  541. },
  542. /**
  543. * 抓參加展覽已成交列表資料
  544. * @return {Object} ajax物件
  545. */
  546. fnGetDealExhibitionlist = function () {
  547. if (sDataId) {
  548. g_api.ConnectLite(sProgramId, 'GetDealExhibitionlist', {
  549. guid: sDataId
  550. },
  551. function (res) {
  552. if (res.RESULT) {
  553. $("#divDealExhibitionlist").html('');
  554. $.each(res.DATA.rel, function (idx, data) {
  555. $("#divDealExhibitionlist").append('<div class="col-sm-' + sColumnWidth + '" id="divDeal-' + data.SN + '"><a>' + data.ExhibitioShotName_TW + '</a></div>');
  556. let iTips = 0;
  557. let sTipsHtml = '<div class="layui-layer-btn-c">' + '查詢單號' + '</div>';
  558. saRefNumber = data.RefNumber.split(',');
  559. let oOption = {
  560. btnAlign: 'c',
  561. time: 600000 //一個小時(如果不配置,默认是3秒)
  562. };
  563. if (saRefNumber.length > 0) {
  564. sTipsHtml += '<ul class="bill-status">';
  565. $.each(saRefNumber, function (idx2, data2) {
  566. let saData = data2.split(';');
  567. let sDataType = saData[0];
  568. let sGuid = saData[1];
  569. let sDataContent = saData[2];
  570. let sTypeName = "";
  571. let sOnClick = "onclick=''";
  572. switch(sDataType){
  573. case "1":
  574. sTypeName = "進口:";
  575. sOnClick = "onclick='parent.openPageTab(\"ExhibitionImport_Upd\",\"?Action=Upd&ImportBillNO=" + sGuid + "\")'";
  576. break;
  577. case "2":
  578. sTypeName = "出口:";
  579. sOnClick = "onclick='parent.openPageTab(\"ExhibitionExport_Upd\",\"?Action=Upd&GoTab=2&ExportBillNO=" + sGuid + "\")'";
  580. break;
  581. case "3":
  582. sTypeName = "其他:";
  583. sDataContent = sDataContent.substring(0,10);
  584. sOnClick = "onclick='parent.openPageTab(\"OtherBusiness_Upd\",\"?Action=Upd&ImportBillNO=" + sGuid + "\")'";
  585. break;
  586. case "4":
  587. sTypeName = "其他駒驛:";
  588. sDataContent = sDataContent.substring(0,10);
  589. sOnClick = "onclick='parent.openPageTab(\"OtherExhibitionTG_Upd\",\"?Action=Upd&GoTab=2&Guid=" + sGuid + "\")'";
  590. break;
  591. }
  592. sTipsHtml += "<li><a class='gopagetab' " + sOnClick + "><div>" + sTypeName + sDataContent + "</div></a></li>";
  593. });
  594. sTipsHtml += '</ul>';
  595. oOption.area = ['300px'];
  596. }
  597. else {
  598. sTipsHtml = '<div></div>';
  599. }
  600. $('#divDeal-' + data.SN).on({
  601. click: function () {
  602. oOption.btn = [i18next.t("common.Close")];// ╠common.Close⇒關閉╣
  603. intOpenLayer = layer.msg(sTipsHtml, oOption);
  604. },
  605. mouseenter: function (event) {
  606. delete oOption.btn;
  607. if($('#layui-layer' + intOpenLayer).length == 0){
  608. iTips = layer.msg(sTipsHtml, {
  609. oOption,
  610. offset: ['40%', '30%']
  611. });
  612. }
  613. },
  614. mouseleave: function (event) {
  615. layer.close(iTips);
  616. }
  617. });
  618. })
  619. }
  620. });
  621. }
  622. else {
  623. return $.Deferred().resolve().promise();
  624. }
  625. },
  626. /**
  627. * 新增Callout紀錄
  628. * @return {Object} ajax物件
  629. */
  630. fnCreateCalloutLog = function (_sExhibitionNO) {
  631. if($("#Contactor-"+ _sExhibitionNO).val() == "" || $("#Contactor-"+ _sExhibitionNO).val() == null){
  632. showMsg('請選擇聯絡人', 'error');
  633. return false;
  634. } else if($("#Record-"+ _sExhibitionNO).val() == ""){
  635. showMsg('紀錄欄位不得為空', 'error');
  636. return false;
  637. } else {
  638. g_api.ConnectLite(sProgramId, 'CreateCalloutLog', {
  639. ExhibitionNO: _sExhibitionNO,
  640. CustomerId: sDataId,
  641. Contactor: $("#Contactor-"+ _sExhibitionNO).val(),
  642. Memo: $("#Record-"+ _sExhibitionNO).val()
  643. }, function (res) {
  644. if (res.RESULT) {
  645. showMsg(i18next.t("message.Save_Success"), 'success'); // ╠message.Save_Success⇒新增成功╣
  646. $('#accordion-' + _sExhibitionNO).html('');
  647. $.each(res.DATA.rel, function (LogIdx, LogData) {
  648. LogData.ExhibitionNO = _sExhibitionNO;
  649. LogData.Index = LogIdx;
  650. var sLogHtml = $("#temp_Memobox").render([LogData]);
  651. $('#accordion-' + _sExhibitionNO).append(sLogHtml);
  652. $("#Contactor-"+ _sExhibitionNO).val("").select2();
  653. $("#Record-"+ _sExhibitionNO).val("");
  654. })
  655. }
  656. else {
  657. showMsg(res.MSG, 'error');
  658. }
  659. }, function () {
  660. showMsg(i18next.t("message.Save_Failed"), 'error'); // ╠message.Save_Failed⇒新增失敗╣
  661. });
  662. }
  663. },
  664. fnUpd = function () {
  665. let oUpdData = {};
  666. let sCoopTrasportCompany1 = "";
  667. let sCoopTrasportCompany2 = "";
  668. oUpdData.ExhibitionNO = sDataSN,
  669. oUpdData.CustomerId = sDataId,
  670. oUpdData.FormalCustomer = intFormalCustomer;
  671. oUpdData.TransactionType = $("[name=TransactionType]:checked").val();
  672. oUpdData.CustomerCName = $("#CustomerCName").val();
  673. oUpdData.CustomerEName = $("#CustomerEName").val();
  674. oUpdData.UniCode = $("#UniCode").val();
  675. oUpdData.Telephone = $("#Telephone").val();
  676. oUpdData.IsBlackList = $("[name=IsBlackList]:checked").val();
  677. oUpdData.BlackListReason = $("#BlackListReason").val();
  678. /* if($("#CoopTrasportCompany").val() != "" && $("#CoopTrasportCompany").val() != null){
  679. $.each($("#CoopTrasportCompany").val(), function (idx, item) {
  680. sCoopTrasportCompany1 = sCoopTrasportCompany1 + item + ",";
  681. });
  682. }
  683. oUpdData.CoopTrasportCompany1 = sCoopTrasportCompany1; */
  684. oUpdData.TransportRequire = $("#TransportRequire-" + sDataSN).val();
  685. oUpdData.TransportationMode = $("#TransportationMode-" + sDataSN).val();
  686. oUpdData.ProcessingMode = $("#ProcessingMode-" + sDataSN).val();
  687. oUpdData.VolumeForecasting = $("#VolumeForecasting-" + sDataSN).val();
  688. oUpdData.Potential = $("#Potential-" + sDataSN).val();
  689. oUpdData.BoothNumber = $("#BoothNumber-" + sDataSN).val();
  690. oUpdData.NumberOfBooths = $("#NumberOfBooths-" + sDataSN).val();
  691. oUpdData.Memo = $("#Memo-" + sDataSN).val();
  692. if($("#CoopTrasportCompany-" + sDataSN).val() != "" && $("#CoopTrasportCompany-" + sDataSN).val() != null){
  693. $.each($("#CoopTrasportCompany-" + sDataSN).val(), function (idx, item) {
  694. sCoopTrasportCompany2 = sCoopTrasportCompany2 + item + ",";
  695. });
  696. }
  697. oUpdData.CoopTrasportCompany = sCoopTrasportCompany2;
  698. oUpdData.IsImporter = $("[name=IsImporter]:checked").val();
  699. g_api.ConnectLite(sProgramId, 'UpdateCalloutData', oUpdData,
  700. function (res) {
  701. if (res.RESULT) {
  702. showMsg(i18next.t("message.Modify_Success"), 'success');
  703. if (bLeavePage) {
  704. setTimeout(function () {
  705. fnLocalToLeave();
  706. }, 1000);
  707. } else {
  708. init();
  709. }
  710. } else {
  711. showMsg(i18next.t("message.Modify_Failed")+ '<br>' + res.MSG, 'error');
  712. }
  713. },
  714. function (res) {
  715. showMsg(i18next.t("message.Modify_Failed"), 'error');
  716. })
  717. },
  718. /**
  719. * 抓參加展覽未成交列表資料
  720. * @return {Object} ajax物件
  721. */
  722. fnGetUnDealExhibitionlist = function () {
  723. if (sDataId) {
  724. g_api.ConnectLite(sProgramId, 'GetUnDealExhibitionlist', {
  725. guid: sDataId
  726. },
  727. function (res) {
  728. if (res.RESULT) {
  729. $("#divUnDealExhibitionlist").html('');
  730. $.each(res.DATA.rel, function (idx, data) {
  731. $("#divUnDealExhibitionlist").append('<div class="col-sm-' + sColumnWidth + '" id="divUnDeal-' + data.SN + '"><a>' + data.ExhibitioShotName_TW + '</a></div>');
  732. $('#divUnDeal-' + data.SN).on({
  733. click: function () {
  734. parent.openPageTab('Exhibition_Upd',"?Action=Upd&SN=" + data.SN );
  735. }
  736. });
  737. })
  738. }
  739. });
  740. }
  741. else {
  742. return $.Deferred().resolve().promise();
  743. }
  744. },
  745. /**
  746. * 抓未來展覽列表資料
  747. * @return {Object} ajax物件
  748. */
  749. fnGetFutureExhibitionlist = function () {
  750. if (sDataId) {
  751. g_api.ConnectLite(sProgramId, 'GetFutureExhibitionlist', {
  752. guid: sDataId
  753. },
  754. function (res) {
  755. if (res.RESULT) {
  756. $("#divBusinessOpportunity").html('');
  757. $.each(res.DATA.rel, function (idx, data) {
  758. $("#divBusinessOpportunity").append('<div class="col-sm-' + sColumnWidth + '" id="divFuture-' + data.SN + '"><a>' + data.ExhibitioShotName_TW + '</a></div>');
  759. $('#divFuture-' + data.SN).on({
  760. click: function () {
  761. parent.openPageTab('Exhibition_Upd',"?Action=Upd&SN=" + data.SN );
  762. }
  763. });
  764. })
  765. }
  766. });
  767. }
  768. else {
  769. return $.Deferred().resolve().promise();
  770. }
  771. },
  772. /**
  773. * 抓客訴列表資料
  774. * @return {Object} ajax物件
  775. */
  776. fnGetComplaintlist = function () {
  777. if (sDataId) {
  778. g_api.ConnectLite('Customers_Upd', 'GetComplaintlist', {
  779. guid: sDataId
  780. },
  781. function (res) {
  782. if (res.RESULT) {
  783. $("#divComplaint").html('');
  784. $.each(res.DATA.rel, function (idx, data) {
  785. $("#divComplaint").append('<div class="col-sm-' + sColumnWidth + '" id="divComplaint-' + data.ComplaintNumber + '"><a>' + data.ComplaintTitle + '</a></div>');
  786. $('#divComplaint-' + data.ComplaintNumber).on({
  787. click: function () {
  788. //parent.openPageTab('Complaint_Upd',"?Action=View&Guid=" + data.Guid );
  789. if ('A,C'.indexOf(data.DataType) > -1 && data.CreateUser === parent.UserID) {
  790. parent.openPageTab('Complaint_Upd', '?Action=Upd&Guid=' + data.Guid);
  791. }
  792. else {
  793. parent.openPageTab('Complaint_View', '?Action=Upd&Guid=' + data.Guid);
  794. }
  795. }
  796. });
  797. })
  798. }
  799. });
  800. }
  801. else {
  802. return $.Deferred().resolve().promise();
  803. }
  804. },
  805. /**
  806. * 抓滿意度列表資料
  807. * @return {Object} ajax物件
  808. */
  809. fnGetSatisfactionCaselist = function () {
  810. if (sDataId) {
  811. g_api.ConnectLite('Customers_Upd', 'GetSatisfactionCaselist', {
  812. guid: sDataId
  813. },
  814. function (res) {
  815. if (res.RESULT) {
  816. $("#divSatisfactionCase").html('');
  817. $.each(res.DATA.rel, function (idx, data) {
  818. $("#divSatisfactionCase").append('<div class="col-sm-' + sColumnWidth + '" id="divSatisfaction-' + data.SN + '"><a>' + data.ExhibitioShotName_TW + '</a></div>');
  819. $('#divSatisfaction-' + data.SN).on({
  820. click: function () {
  821. //parent.openPageTab('SatisfactionCase_Upd',"?Action=Upd&SN=" + data.SN );
  822. fnGetSatisfactionCaseData(data.CustomerSN);
  823. }
  824. });
  825. })
  826. }
  827. });
  828. }
  829. else {
  830. return $.Deferred().resolve().promise();
  831. }
  832. },
  833. fnGetSatisfactionCaseData = function (_SN) {
  834. return g_api.ConnectLite('SatisfactionCase_Upd', 'GetSatisfactionCaseData', {
  835. SN: _SN,
  836. }, function (res) {
  837. let oResSA = res.DATA.rel;
  838. layer.open({
  839. type: 1, //0(信息框,默认)1(页面层)2(iframe层)3(加载层)4(tips层)
  840. title: "滿意度問卷", // ╠common.CorrespondImpCus⇒對應正式客戶╣
  841. area: ['40%', '90%'],//寬度
  842. shade: 0.75,//遮罩
  843. closeBtn: 1,
  844. //maxmin: true, //开启最大化最小化按钮
  845. id: 'layer_SatisfactionCaseData', //设定一个id,防止重复弹出
  846. offset: '10px',//右下角弹出
  847. anim: 0,//彈出動畫
  848. //btn: [i18next.t('common.Confirm'), i18next.t('common.Cancel')],//╠common.Confirm⇒確定╣╠common.Cancel⇒取消╣
  849. //btnAlign: 'c',//按鈕位置
  850. content: '<div class="pop-box row w100p">\
  851. <label class="col-sm-3 control-label" for="input-Default">\
  852. <span data-i18n="">客戶名稱</span><span></span>\
  853. </label>\
  854. <div class="col-sm-8">\
  855. <input type="text" maxlength="50" id="CustomerName" name="CustomerName" class="form-control w100p" placeholderid="" value="' + oResSA.CustomerName + '" disabled>\
  856. </div>\
  857. </div>\
  858. <div class="pop-box row w100p">\
  859. <label class="col-sm-3 control-label" for="input-Default">\
  860. <span data-i18n="">填寫人</span><span></span>\
  861. </label>\
  862. <div class="col-sm-8">\
  863. <input type="text" maxlength="50" id="FillerName" name="FillerName" class="form-control w100p" placeholderid="" value="' + oResSA.FillerName + '" disabled>\
  864. </div>\
  865. </div>\
  866. <div class="pop-box row w100p">\
  867. <label class="col-sm-3 control-label" for="input-Default">\
  868. <span data-i18n="">填寫人電子郵件</span><span></span>\
  869. </label>\
  870. <div class="col-sm-8">\
  871. <input type="text" maxlength="50" id="Email" name="Email" class="form-control w100p" placeholderid="" value="' + oResSA.Email + '" disabled>\
  872. </div>\
  873. </div>\
  874. <div class="pop-box row w100p">\
  875. <label class="col-sm-3 control-label" for="input-Default">\
  876. <span data-i18n="">填寫人聯絡電話</span><span></span>\
  877. </label>\
  878. <div class="col-sm-8">\
  879. <input type="text" maxlength="50" id="Phone" name="Phone" class="form-control w100p" placeholderid="" value="' + oResSA.Phone + '" disabled>\
  880. </div>\
  881. </div>\
  882. <div class="pop-box row w100p">\
  883. <label class="col-sm-3 control-label" for="input-Default">\
  884. <span data-i18n="">備註</span><span></span>\
  885. </label>\
  886. <div class="col-sm-8">\
  887. <textarea name="Memo" id="Memo" class="form-control" rows="3" disabled>' + oResSA.Memo + '</textarea>\
  888. </div>\
  889. </div>\<hr>\
  890. <div>\
  891. <table class="w80p text-left" style="border:1px #cccccc solid;margin-Left:10%;font-size:14px"><thead></thead>\
  892. <tbody>\
  893. <tr>\
  894. <td class="col-sm-7" style="border:1px #cccccc solid;">奕達提供整體服務品質的滿意度</td>\
  895. <td class="col-sm-5" style="border:1px #cccccc solid;"><div id="Feild01">' + oResSA.Feild01 + '</div></td>\
  896. </tr>\
  897. <tr>\
  898. <td class="col-sm-7" style="border:1px #cccccc solid;">奕達提供的價格是否合理</td>\
  899. <td class="col-sm-5" style="border:1px #cccccc solid;"><div id="Feild02">' + oResSA.Feild02 + '</div></td>\
  900. </tr>\
  901. <tr>\
  902. <td class="col-sm-7" style="border:1px #cccccc solid;">展品送達時間是否滿意</td>\
  903. <td class="col-sm-5" style="border:1px #cccccc solid;"><div id="Feild03">' + oResSA.Feild03 + '</div></td>\
  904. </tr>\
  905. <tr>\
  906. <td class="col-sm-7" style="border:1px #cccccc solid;">現場人員的專業技能與服務態度是否滿意</td>\
  907. <td class="col-sm-5" style="border:1px #cccccc solid;"><div id="Feild04">' + oResSA.Feild04 + '</div></td>\
  908. </tr>\
  909. <tr>\
  910. <td class="col-sm-7" style="border:1px #cccccc solid;">承辦同仁的配合度及服務態度是否滿意</td>\
  911. <td class="col-sm-5" style="border:1px #cccccc solid;"><div id="Feild05">' + oResSA.Feild05 + '</div></td>\
  912. </tr>\
  913. <tr>\
  914. <td class="col-sm-7" style="border:1px #cccccc solid;">貨況線上查詢系統是否滿意</td>\
  915. <td class="col-sm-5" style="border:1px #cccccc solid;"><div id="Feild06">' + oResSA.Feild06 + '</div></td>\
  916. </tr>\
  917. <tr>\
  918. <td class="col-sm-7" style="border:1px #cccccc solid;">為何選擇奕達</td>\
  919. <td class="col-sm-5" style="border:1px #cccccc solid;"><div id="Feild07">' + oResSA.Feild07 + '</div></td>\
  920. </tr>\
  921. <tr>\
  922. <td class="col-sm-7" style="border:1px #cccccc solid;">貴公司年度平均參與海外展會活動次數</td>\
  923. <td class="col-sm-5" style="border:1px #cccccc solid;"><div id="Feild08">' + oResSA.Feild08 + '</div></td>\
  924. </tr>\
  925. <tr>\
  926. <td class="col-sm-7" style="border:1px #cccccc solid;">您是否會推薦奕達給合作夥伴</td>\
  927. <td class="col-sm-5" style="border:1px #cccccc solid;"><div id="Feild9">' + oResSA.Feild09 + '</div></td>\
  928. </tr>\
  929. <tr>\
  930. <td class="col-sm-7" style="border:1px #cccccc solid;">其他建議</td>\
  931. <td class="col-sm-5" style="border:1px #cccccc solid;"><div id="Feild10">' + oResSA.Feild10 + '</div></td>\
  932. </tr>\
  933. </tbody>\
  934. </table>\
  935. </div><div class="pop-box row w100p"></div>',
  936. success: function (layero, index) {
  937. },
  938. yes: function (index, layero) {
  939. }
  940. });
  941. });
  942. },
  943. /**
  944. * 新增潛在商機
  945. * @return {Object} ajax物件
  946. */
  947. fnAddBusinessOpportunity = function (data) {
  948. data = packParams(data);
  949. g_api.ConnectLite('BusinessOpportunity_Qry', 'Insert', data,
  950. function (res) {
  951. if (res.RESULT == '1') {
  952. showMsg(i18next.t("message.Save_Success"), 'success'); // ╠message.Save_Success⇒新增成功╣
  953. } else {
  954. showMsg(i18next.t("message.Save_Failed"), 'error'); // ╠message.Save_Failed⇒新增失敗╣
  955. }
  956. },
  957. function (res) {
  958. showMsg(i18next.t("message.Save_Failed"), 'error'); // ╠message.Save_Failed⇒新增失敗╣
  959. }
  960. )
  961. },
  962. fnLocalToLeave = function () {
  963. parent.top.msgs.server.removeEditPrg(sProgramId).done(function() {
  964. var PrevLi = parent.top.tabs.find(".ui-tabs-active").prev().find('a'),
  965. LiId = parent.top.tabs.find(".ui-tabs-active").remove().attr("aria-controls");
  966. PrevLi.click();
  967. })
  968. },
  969. /**
  970. * ToolBar 按鈕事件 function
  971. * @param {Object}inst 按鈕物件對象
  972. * @param {Object} e 事件對象
  973. */
  974. fnButtonHandler = function (inst, e) {
  975. var sId = inst.id;
  976. switch (sId) {
  977. case "Toolbar_Qry":
  978. break;
  979. case "Toolbar_Save":
  980. fnUpd();
  981. break;
  982. case "Toolbar_ReAdd":
  983. break;
  984. case "Toolbar_Clear":
  985. break;
  986. case "Toolbar_Leave":
  987. //當被lock住,不儲存任何資料,直接離開。
  988. if (parent.bLockDataForm0430 !== undefined){
  989. fnLocalToLeave();
  990. } else if (bRequestStorage) {
  991. layer.confirm(i18next.t('message.HasDataTosave'), {//╠message.HasDataTosave⇒尚有資料未儲存,是否要儲存?╣
  992. icon: 3,
  993. title: i18next.t('common.Tips'),// ╠message.Tips⇒提示╣
  994. btn: [i18next.t('common.Yes'), i18next.t('common.No')] // ╠message.Yes⇒是╣ ╠common.No⇒否╣
  995. }, function (index) {
  996. layer.close(index);
  997. bLeavePage = true;
  998. fnUpd();
  999. }, function () {
  1000. fnLocalToLeave();
  1001. });
  1002. return false;
  1003. } else {
  1004. fnLocalToLeave();
  1005. return false;
  1006. }
  1007. break;
  1008. case "Toolbar_Add":
  1009. break;
  1010. case "Toolbar_Upd":
  1011. break;
  1012. case "Toolbar_Copy":
  1013. break;
  1014. case "Toolbar_Imp":
  1015. break;
  1016. case "Toolbar_Exp":
  1017. break;
  1018. case "Toolbar_Void":
  1019. break;
  1020. case "Toolbar_OpenVoid":
  1021. break;
  1022. case "Toolbar_Del":
  1023. break;
  1024. default:
  1025. alert("No handle '" + sId + "'");
  1026. break;
  1027. }
  1028. },
  1029. /**
  1030. * 初始化 function
  1031. */
  1032. init = function () {
  1033. var saCusBtns = [],
  1034. myHelpers = {
  1035. setSupplierName: function (val1, val2) {
  1036. return !val1 ? val2 : val1;
  1037. },
  1038. dtformate: function (val) {
  1039. return newDate(val);
  1040. },
  1041. setStatus: function (status) {
  1042. return sStatus;
  1043. }
  1044. };
  1045. $.views.helpers(myHelpers);
  1046. var iHeight = $('body').height() - $('.page-title').height() - $('#searchbar').height() - 120;
  1047. $("#jsGrid").jsGrid({
  1048. width: "100%",
  1049. height: "auto",
  1050. autoload: false,
  1051. filtering: false,
  1052. pageLoading: true,
  1053. inserting: false,
  1054. editing: false,
  1055. sorting: false,
  1056. paging: false,
  1057. pageIndex: 1,
  1058. pageSize: parent.top.SysSet.GridRecords || 10,
  1059. confirmDeleting: true,
  1060. deleteConfirm: i18next.t('message.ConfirmToDelete'),// ╠message.ConfirmToDelete⇒確定要刪除嗎 ?╣
  1061. pagePrevText: "<",
  1062. pageNextText: ">",
  1063. pageFirstText: "<<",
  1064. pageLastText: ">>",
  1065. fields: [
  1066. {
  1067. name: "ContactorName", title: '聯絡人名稱', width: 150, align: "center",
  1068. itemTemplate: function (val, item) {
  1069. switch(item.Mark){
  1070. case "N":
  1071. return $('<span />', { text: val }).css('color', 'gray')
  1072. break;
  1073. case "Y":
  1074. return $('<span />', { text: val }).css('color', 'red')
  1075. break;
  1076. default:
  1077. return $('<span />', { text: val }).css('color', 'black')
  1078. break;
  1079. }
  1080. }
  1081. },
  1082. {
  1083. name: "JobTitle", title: '職位', width: 80, align: "center",
  1084. itemTemplate: function (val, item) {
  1085. switch(item.Mark){
  1086. case "N":
  1087. return $('<span />', { text: val }).css('color', 'gray')
  1088. break;
  1089. case "Y":
  1090. return $('<span />', { text: val }).css('color', 'red')
  1091. break;
  1092. default:
  1093. return $('<span />', { text: val }).css('color', 'black')
  1094. break;
  1095. }
  1096. }
  1097. },
  1098. {
  1099. name: "Telephone1", title: '電話1', width: 150,align: "center",
  1100. itemTemplate: function (val, item) {
  1101. switch(item.Mark){
  1102. case "N":
  1103. return $('<span />', { text: val }).css('color', 'gray')
  1104. break;
  1105. case "Y":
  1106. return $('<span />', { text: val }).css('color', 'red')
  1107. break;
  1108. default:
  1109. return $('<span />', { text: val }).css('color', 'black')
  1110. break;
  1111. }
  1112. }
  1113. },
  1114. {
  1115. name: "Ext1", title: '分機1', width:50,align: "center",
  1116. itemTemplate: function (val, item) {
  1117. switch(item.Mark){
  1118. case "N":
  1119. return $('<span />', { text: val }).css('color', 'gray')
  1120. break;
  1121. case "Y":
  1122. return $('<span />', { text: val }).css('color', 'red')
  1123. break;
  1124. default:
  1125. return $('<span />', { text: val }).css('color', 'black')
  1126. break;
  1127. }
  1128. }
  1129. },
  1130. {
  1131. name: "Email1", title: 'Email', width: 200,align: "center",
  1132. itemTemplate: function (val, item) {
  1133. switch(item.Mark){
  1134. case "N":
  1135. return $('<span />', { text: val }).css('color', 'gray')
  1136. break;
  1137. case "Y":
  1138. return $('<span />', { text: val }).css('color', 'red')
  1139. break;
  1140. default:
  1141. return $('<span />', { text: val }).css('color', 'black')
  1142. break;
  1143. }
  1144. }
  1145. },
  1146. {
  1147. name: "SourceType", title: '來源', width: 50,align: "center",
  1148. itemTemplate: function (val, item) {
  1149. let sSourceType = "";
  1150. switch(val){
  1151. case "2":
  1152. sSourceType = "匯入檔案";
  1153. break;
  1154. default:
  1155. sSourceType = "資料庫";
  1156. break;
  1157. }
  1158. switch(item.Mark){
  1159. case "N":
  1160. return $('<span />', { text: sSourceType }).css('color', 'gray')
  1161. break;
  1162. case "Y":
  1163. return $('<span />', { text: sSourceType }).css('color', 'red')
  1164. break;
  1165. default:
  1166. return $('<span />', { text: sSourceType }).css('color', 'black')
  1167. break;
  1168. }
  1169. }
  1170. },
  1171. {
  1172. name: "IsMain", title: '主要聯絡人', width: 50, align: "center",
  1173. itemTemplate: function (value, item) {
  1174. return $("<input>", {
  1175. type: 'checkbox',
  1176. click: function (e) {
  1177. e.stopPropagation();
  1178. if (this.checked) {
  1179. /* $("#jsGrid").find('[type=checkbox]').each(function () {
  1180. this.checked = false;
  1181. });
  1182. this.checked = true;
  1183. */
  1184. if(value != "Y"){
  1185. layer.confirm("確定將 " + item.ContactorName + " 設為主要聯絡人?", { icon: 3, title: i18next.t('common.Tips') }, function (index) {
  1186. g_api.ConnectLite(sProgramId, 'SetContactorIsMain', {
  1187. ExhibitionNO: sDataSN,
  1188. CustomerId: sDataId,
  1189. ContactorId: item.Guid
  1190. }
  1191. , function (res) {
  1192. if (res.DATA.rel) {
  1193. oGrid2.loadData();
  1194. layer.close(index);
  1195. }
  1196. else {
  1197. showMsg("更新失敗", 'error');
  1198. }
  1199. }
  1200. , function () {
  1201. showMsg("更新失敗", 'error');
  1202. });
  1203. oGrid2.loadData();
  1204. layer.close(index);
  1205. });
  1206. }
  1207. return false;
  1208. } else {
  1209. if(value == "Y"){
  1210. return false;
  1211. }
  1212. }
  1213. }, checked: function(){
  1214. if(value == "Y"){
  1215. return true;
  1216. } else {
  1217. return false;
  1218. }
  1219. }
  1220. });
  1221. }
  1222. },
  1223. {
  1224. name: "Create", title: '', width: 50, align: "center",
  1225. itemTemplate: function (value, item) {
  1226. if(item.Mark === "N" || item.Mark === "Y"){
  1227. return $("<button>", {
  1228. class:"btn-custom blue",
  1229. text: (item.Mark === "N" ? "建立" : "加入"),
  1230. click: function (e) {
  1231. layer.confirm("確定" + (item.Mark === "N" ? "建立" : "加入") + "聯絡人?", { icon: 3, title: i18next.t('common.Tips') }, function (index) {
  1232. g_api.ConnectLite(sProgramId, 'CreateContactor', {
  1233. ExhibitionNO: sDataSN,
  1234. CustomerId: sDataId,
  1235. ContactorId: item.Guid
  1236. }
  1237. , function (res) {
  1238. if (res.DATA.rel) {
  1239. showMsg((item.Mark === "N" ? "建立" : "加入") + "成功", 'success');
  1240. oGrid2.loadData();
  1241. layer.close(index);
  1242. }
  1243. else {
  1244. showMsg((item.Mark === "N" ? "建立" : "加入") + "失敗", 'error');
  1245. }
  1246. }
  1247. , function () {
  1248. showMsg((item.Mark === "N" ? "建立" : "加入") + "失敗", 'error');
  1249. });
  1250. oGrid2.loadData();
  1251. layer.close(index);
  1252. });
  1253. return false;
  1254. }
  1255. });
  1256. }
  1257. }
  1258. },
  1259. {
  1260. name: "Edit", title: '', width: 50, align: "center",
  1261. itemTemplate: function (value, item) {
  1262. if(item.Mark != "N"){
  1263. return $("<button>", {
  1264. class:"btn-custom blue",
  1265. text:"編輯",
  1266. click: function (e) {
  1267. layer.open({
  1268. type: 2, //0(信息框,默认)1(页面层)2(iframe层)3(加载层)4(tips层)
  1269. title: i18next.t('common.InsertContactor'),// ╠common.CustomerTransferToFormal⇒匯入廠商轉正╣
  1270. area: ['70%', '90%'],//寬度
  1271. shade: 0.75,//遮罩
  1272. maxmin: true, //开启最大化最小化按钮
  1273. id: 'layer_InsertContactor', //设定一个id,防止重复弹出
  1274. anim: 0,//彈出動畫
  1275. btnAlign: 'c',//按鈕位置
  1276. content: '../Crm/Contactors_Upd.html?Action=Upd&Flag=Pop&guid=' + item.Guid,
  1277. success: function (layero, index) {
  1278. var iframe = layero.find('iframe').contents();
  1279. iframe.find('#hiddenIndex').val(index);
  1280. },
  1281. end: function () {
  1282. oGrid2.loadData();
  1283. }
  1284. });
  1285. return false;
  1286. }
  1287. });
  1288. }
  1289. }
  1290. },
  1291. {
  1292. name: "Delete", title: '', width: 50, align: "center",
  1293. itemTemplate: function (value, item) {
  1294. if(item.Mark != "Y"){
  1295. return $("<button>", {
  1296. class:"btn-custom blue",
  1297. text:"移除",
  1298. click: function (e) {
  1299. layer.confirm("確定將聯絡人從名單移除?", { icon: 3, title: i18next.t('common.Tips') }, function (index) {
  1300. g_api.ConnectLite(sProgramId, 'RemoveContactor', {
  1301. ExhibitionNO: sDataSN,
  1302. CustomerId: sDataId,
  1303. ContactorId: item.Guid
  1304. }
  1305. , function (res) {
  1306. if (res.DATA.rel) {
  1307. showMsg("移除成功", 'success');
  1308. oGrid2.loadData();
  1309. layer.close(index);
  1310. }
  1311. else {
  1312. showMsg("移除失敗", 'error');
  1313. }
  1314. }
  1315. , function () {
  1316. showMsg("移除失敗", 'error');
  1317. });
  1318. oGrid2.loadData();
  1319. layer.close(index);
  1320. });
  1321. return false;
  1322. }
  1323. });
  1324. }
  1325. }
  1326. }
  1327. ],
  1328. controller: {
  1329. loadData: function (args) {
  1330. return fnGetExhibitionContactorslist();
  1331. },
  1332. insertItem: function (args) {
  1333. },
  1334. updateItem: function (args) {
  1335. },
  1336. deleteItem: function (args) {
  1337. }
  1338. },
  1339. onInit: function (args) {
  1340. oGrid2= args.grid;
  1341. }
  1342. });
  1343. commonInit({
  1344. PrgId: sProgramId,
  1345. ButtonHandler: fnButtonHandler,
  1346. Buttons: saCusBtns,
  1347. GoTop: true
  1348. });
  1349. //加載報關類別,加載成本頁簽
  1350. $.whenArray([
  1351. fnGet(),
  1352. fnGetCalloutData(),
  1353. setTransportRequireDrop(),
  1354. setTransportDrop(),
  1355. fnGetFutureExhibitionlist(),
  1356. fnGetDealExhibitionlist(),
  1357. fnGetUnDealExhibitionlist(),
  1358. fnGetComplaintlist(),
  1359. fnGetSatisfactionCaselist(),
  1360. fnSetArgDrop([
  1361. {
  1362. OrgID: 'TE',
  1363. ArgClassID: 'BlackListReason',
  1364. Select: $('#BlackListReason')
  1365. },
  1366. {
  1367. OrgID: 'TE',
  1368. ArgClassID: 'TrasportCompany',
  1369. CallBack: function (data) {
  1370. sCoopTrasportCompanyHtml = createOptions(data, 'id', 'text');
  1371. $('#CoopTrasportCompany').html(sCoopTrasportCompanyHtml).select2();
  1372. }
  1373. },
  1374. {
  1375. OrgID: 'TE',
  1376. ArgClassID: 'ProcessingMode',
  1377. CallBack: function (data) {
  1378. sProcessingModeOptionsHtml = createOptions(data, 'id', 'text');
  1379. }
  1380. },
  1381. {
  1382. OrgID: 'TE',
  1383. ArgClassID: 'Potential',
  1384. CallBack: function (data) {
  1385. sPotentialOptionsHtml = createOptions(data, 'id', 'text');
  1386. }
  1387. }
  1388. ])
  1389. ])
  1390. .done(function (res) {
  1391. if (res && oData1) {
  1392. var oRes = oData2.DATA.rel;
  1393. var oRes1 = oData1.DATA.rel;
  1394. fnSetArgDrop([
  1395. {
  1396. ArgClassID: 'TranType',
  1397. CallBack: function (data) {
  1398. $('#transactiontype').html(createRadios(data, 'id', 'text', 'TransactionType'));
  1399. $('[name=TransactionType][value="' + oRes1.TransactionType + '"]').click();
  1400. uniformInit($('#transactiontype'));
  1401. if(intFormalCustomer == 1){
  1402. $("[name=TransactionType]").attr('disabled', true);
  1403. }
  1404. }
  1405. }
  1406. ])
  1407. oCurData = oRes;
  1408. fnBindBillLists();
  1409. oGrid2.loadData();
  1410. }
  1411. });
  1412. $("[name='IsBlackList']").on('change', function () {
  1413. if($("[name='IsBlackList']:checked").val() == "Y"){
  1414. $("#BlackListReason" ).attr('disabled', false);
  1415. } else {
  1416. $("#BlackListReason").val("");
  1417. $("#BlackListReason" ).attr('disabled', true);
  1418. }
  1419. });
  1420. $('#btnSeeMore').on('click', function () {
  1421. parent.openPageTab('Customers_Upd', '?Action=Upd&guid=' + sDataId);
  1422. });
  1423. $('#btnCorrespondFormalCus').on('click', function () {
  1424. fnCorrespondFormalCus();
  1425. });
  1426. $('#btnChooseContactors').on('click', function () {
  1427. fnChooseContactors();
  1428. });
  1429. $('#btnCreateContactor').on('click', function () {
  1430. fnCreateContactor();
  1431. });
  1432. $('#btnCreateBusinessOpportunity').on('click', function () {
  1433. layer.open({
  1434. type: 2, //0(信息框,默认)1(页面层)2(iframe层)3(加载层)4(tips层)
  1435. title: "建立潛在商機",//i18next.t('common.CustomerTransferToFormal'),// ╠common.CustomerTransferToFormal⇒匯入廠商轉正╣
  1436. area: ['60%', '90%'],//寬度
  1437. shade: 0.75,//遮罩
  1438. //maxmin: true, //开启最大化最小化按钮
  1439. id: 'layer_CombineContactor', //设定一个id,防止重复弹出
  1440. offset: '10px',//右下角弹出
  1441. anim: 0,//彈出動畫
  1442. btn: ['儲存', i18next.t('common.Cancel')],//╠common.Confirm⇒確定╣╠common.Cancel⇒取消╣
  1443. btnAlign: 'c',//按鈕位置
  1444. content: '../CRM/BusinessOpportunity_Upd.html',
  1445. success: function (layero, index) {
  1446. var iframe = layero.find('iframe').contents();
  1447. iframe.find("#CustomerName").val(sCustomerCName);
  1448. g_api.ConnectLite(Service.com, ComFn.GetArguments, {
  1449. OrgID: 'TE',
  1450. ArgClassID: 'Area',
  1451. LevelOfArgument: 1
  1452. }, function (res) {
  1453. if (res.RESULT) {
  1454. let saState = res.DATA.rel;
  1455. if (res.DATA.rel.length > 0) {
  1456. iframe.find("#State").html(createOptions(res.DATA.rel, 'id', 'text', true));
  1457. }
  1458. }
  1459. });
  1460. g_api.ConnectLite(Service.com, ComFn.GetArguments, {
  1461. OrgID: 'TE',
  1462. ArgClassID: 'ExhibClass',
  1463. LevelOfArgument: 0
  1464. }, function (res) {
  1465. if (res.RESULT) {
  1466. let saState = res.DATA.rel;
  1467. if (res.DATA.rel.length > 0) {
  1468. iframe.find("#Industry").html(createOptions(res.DATA.rel, 'id', 'text', true));
  1469. }
  1470. }
  1471. });
  1472. /* return g_api.ConnectLite(Service.com, ComFn.GetArguments, {
  1473. OrgID: 'TE',
  1474. ArgClassID: 'Area',
  1475. LevelOfArgument: 1
  1476. }, function (res) {
  1477. if (res.RESULT) {
  1478. let saState = res.DATA.rel;
  1479. if (saState.length > 0) {
  1480. $('#State').append(createOptions(saState, 'id', 'text', true)).select2();
  1481. }
  1482. }
  1483. }); */
  1484. //iframe.find("#State").html($("#State").html());
  1485. //iframe.find("#Industry").html($("#Industry").html());
  1486. },
  1487. yes: function (index, layero) {
  1488. layer.confirm("確定要儲存?", { icon: 3, title: i18next.t('common.Tips') }, function (index) {
  1489. var iframe = layero.find('iframe').contents();
  1490. var formData = getFormSerialize($(iframe.find('#form_main')));
  1491. fnAddBusinessOpportunity(formData);
  1492. layer.close(index);
  1493. });
  1494. },
  1495. end: function () {
  1496. //oGrid.loadData();
  1497. }
  1498. });
  1499. });
  1500. $('#btnCreateComplaint').on('click', function () {
  1501. parent.openPageTab('Complaint_Upd', '?Action=Add&CustomerId=' + sDataId);
  1502. });
  1503. $("#CustomerCName").on('change', function(res){
  1504. sCustomerCName = $('#CustomerCName').val();
  1505. })
  1506. /* $.validator.addMethod("compardate", function (value, element, parms) {
  1507. if (new Date(value) < new Date($('#ExhibitionDateStart').val())) {
  1508. return false;
  1509. }
  1510. return true;
  1511. });
  1512. oValidator = $("#form_main").validate({
  1513. ignore: '',
  1514. rules: {
  1515. AgentEamil: {
  1516. email: true
  1517. }
  1518. },
  1519. messages: {
  1520. AgentEamil: i18next.t("message.IncorrectEmail")// ╠message.IncorrectEmail⇒郵箱格式不正確╣
  1521. }
  1522. }); */
  1523. };
  1524. init();
  1525. };
  1526. require(['base', 'select2', 'autocompleter', 'formatnumber', 'jquerytoolbar', 'timepicker', 'jsgrid', 'ajaxfile', 'common_opm', 'util'], fnPageInit, 'timepicker');
  1527. //require(['base', 'select2', 'jsgrid', 'ajaxfile', 'util'], fnPageInit);