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.

3204 lines
138 KiB

3 years ago
  1. 'use strict';
  2. var sProgramId = getProgramId(),
  3. sQueryPrgId = getQueryPrgId(),
  4. sAction = getUrlParam('Action') || 'Add',
  5. sDataId = getUrlParam('SN'),
  6. sTab = getUrlParam('Tab'),
  7. sCheckId = sDataId,
  8. bRefresh = false,
  9. bNewCustomer = false,
  10. fnPageInit = function () {
  11. var oGrid = null,
  12. oForm = $('#form_main'),
  13. oGrid1 = null,
  14. oValidator = null,
  15. oGrid2 = null,
  16. oGrid3 = null,
  17. oCurData = {},
  18. sIndustryHtml = '',
  19. sListSourceHtml = '',
  20. sBlackListReasonHtml = '',
  21. sSN = '',
  22. sChooseCustomerId = '',
  23. saGridData = [],
  24. saGridData2 = [],
  25. saGridData3 = [],
  26. saState = [],
  27. saHalls = [],
  28. saNewList = [],
  29. //saNewList2 = [],
  30. saLastData = [],
  31. saCustomerList = [],
  32. saContactorList = [],
  33. saAddContactorList = [],
  34. saChooseContactorList = [],
  35. saExhibitionList = [],
  36. saListSource = [],
  37. saGrid2Data = [],
  38. intListCount = 0,
  39. oBaseQueryPm = {
  40. pageIndex: 1,
  41. pageSize: parent.SysSet.GridRecords || 10,
  42. sortField: 'CustomerCName',
  43. sortOrder: 'asc'
  44. },
  45. /**
  46. * 獲取資料
  47. * @return {Object} Ajax 物件
  48. */
  49. fnGet = function () {
  50. $('#litab2').hide();
  51. $('#litab3').hide();
  52. if (sDataId) {
  53. return g_api.ConnectLite(sQueryPrgId, ComFn.GetOne,
  54. {
  55. Guid: sDataId
  56. },
  57. function (res) {
  58. if (res.RESULT) {
  59. var oRes = res.DATA.rel;
  60. oCurData = oRes;
  61. oCurData.CostRulesIdTE = oCurData.CostRulesId;
  62. oCurData.CostRulesIdTG = oCurData.CostRulesId;
  63. $('.TransferResult').show();
  64. $("#ExhibitionCode2").val(oRes.ExhibitionCode);
  65. $("#ExhibitioShotName_TW2").val(oRes.ExhibitioShotName_TW);
  66. $("#ExhibitionDateStart2").val(newDate(oRes.ExhibitionDateStart, 'date'));
  67. $("#ExhibitionDateEnd2").val(newDate(oRes.ExhibitionDateEnd, 'date'));
  68. //$("#ListSource").val((oRes.ListSource || '').split(',').clear()).trigger('change');
  69. //$("#ListSource2").val((oRes.ListSource || '').split(',').clear()).trigger('change');
  70. $("#ResponsiblePerson2").html($("#ResponsiblePerson").html());
  71. if (oRes.IsTransfer === 'N') {
  72. $('#TransferResult').text(i18next.t("common.Transfer_No")).css('color', 'red');// ╠common.Transfer_No⇒未拋轉╣
  73. }
  74. else {// ╠common.Transfer_No⇒已拋轉╣ ╠common.TransferDate⇒最後拋轉時間╣
  75. $('#TransferResult').text(i18next.t("common.Transfer_Yes") + '(' + i18next.t("common.TransferDate") + ':' + newDate(oRes.LastTransfer_Time) + ')').css('color', 'green');
  76. }
  77. var strCustomerGuid = '';
  78. //fnGetGridData().done(function () {
  79. //oGrid.loadData();
  80. $('#btnAddList').on('click', function () {
  81. fnAddList();
  82. });
  83. $('#btnCombineCustomer').on('click', function () {
  84. if (saCustomerList.length != 2) {
  85. showMsg("請勾選兩筆資料進行合併");
  86. return false;
  87. }
  88. if (saCustomerList[0].IsAudit == 'Y' && saCustomerList[1].IsAudit == 'Y') {
  89. showMsg("兩筆皆為已審核,無法合併");
  90. return false;
  91. }
  92. fnCombineCustomer(saCustomerList[0].guid,saCustomerList[1].guid);
  93. });
  94. $('#btnRemoveFromList').on('click', function () {
  95. if (saCustomerList.length == 0) {
  96. showMsg("請至少勾選一筆資料");
  97. return false;
  98. }
  99. strCustomerGuid = '';
  100. $.each(saCustomerList, function (idx, data) {
  101. strCustomerGuid += data.guid + ",";
  102. });
  103. fnRemoveFromList(strCustomerGuid);
  104. });
  105. $('#bthImportExhibitors').on('click', function () {
  106. if (saCustomerList.length == 0) {
  107. showMsg("請至少勾選一筆資料");
  108. return false;
  109. }
  110. strCustomerGuid = '';
  111. $.each(saCustomerList, function (idx, data) {
  112. if(data.IsFormal != "Y"){
  113. showMsg("所選客戶中有非正式客戶,無法帶入案件");
  114. strCustomerGuid = '';
  115. return false;
  116. }
  117. strCustomerGuid += data.guid + ",";
  118. });
  119. if(strCustomerGuid != ''){
  120. fnImportExhibitors(strCustomerGuid);
  121. }
  122. });
  123. // });
  124. }
  125. });
  126. }
  127. else {
  128. $('#litab1 a').click();
  129. $('#litab2').hide();
  130. $('#litab3').hide();
  131. $('#litab4').hide();
  132. oCurData.LogoFileId = guid();
  133. fnUpload();
  134. return $.Deferred().resolve().promise();
  135. }
  136. },
  137. /**
  138. * 新增資料
  139. * @param {String} sFlag 新增或儲存後新增
  140. */
  141. fnAdd = function (sFlag) {
  142. var data = getFormSerialize(oForm);
  143. data = packParams(data);
  144. data.OrgID = parent.OrgID;
  145. data.LogoFileId = oCurData.LogoFileId;
  146. data.IsTransfer = 'N';
  147. //data.ExhibitionCode = 'SerialNumber|' + parent.UserInfo.OrgID + '|' + (parent.UserInfo.OrgID === 'TE' ? '' : parent.UserInfo.OrgID) + '|MinYear|3||';
  148. if (!data.ExhibitionDate) {
  149. delete data.ExhibitionDateStart;
  150. delete data.ExhibitionDateEnd;
  151. }
  152. else {
  153. data.ExhibitionDateStart = $.trim(data.ExhibitionDate.split('~')[0]);
  154. data.ExhibitionDateEnd = $.trim(data.ExhibitionDate.split('~')[1]);
  155. }
  156. delete data.ExhibitionDate;
  157. delete data.file_hidden;
  158. if (!data.ShelfTime_Home) {
  159. delete data.ShelfTime_Home;
  160. }
  161. if (!data.ShelfTime_Abroad) {
  162. delete data.ShelfTime_Abroad;
  163. }
  164. if (!data.SeaReceiveingDate) {
  165. delete data.SeaReceiveingDate;
  166. }
  167. if (!data.SeaClosingDate) {
  168. delete data.SeaClosingDate;
  169. }
  170. if (!data.AirReceiveingDate) {
  171. delete data.AirReceiveingDate;
  172. }
  173. if (!data.AirClosingDate) {
  174. delete data.AirClosingDate;
  175. }
  176. if(parent.OrgID != "TG"){
  177. data.CostRulesId = data.CostRulesIdTE;
  178. } else {
  179. data.CostRulesId = data.CostRulesIdTG;
  180. }
  181. delete data.CostRulesIdTE;
  182. delete data.CostRulesIdTG;
  183. g_api.ConnectLite(Service.com, ComFn.GetSerial, {
  184. Type: (parent.UserInfo.OrgID !== 'SG' ? '' : parent.UserInfo.OrgID),
  185. Flag: 'MinYear',
  186. Len: 3,
  187. Str: '',
  188. AddType: '',
  189. PlusType: ''
  190. }, function (res) {
  191. if (res.RESULT) {
  192. data.ExhibitionCode = res.DATA.rel;
  193. CallAjax(ComFn.W_Com, ComFn.GetAdd, {
  194. Params: { exhibition: data }
  195. }, function (res1) {
  196. if (res1.d > 0) {
  197. bRequestStorage = false;
  198. if (sFlag === 'add') {
  199. CallAjax(ComFn.W_Com, ComFn.GetOne, {
  200. Type: '',
  201. Params: {
  202. exhibition: {
  203. ExhibitionCode: data.ExhibitionCode
  204. },
  205. }
  206. }, function (res2) {
  207. var oRes = $.parseJSON(res2.d);
  208. showMsgAndGo(i18next.t("message.Save_Success"), sProgramId, '?Action=Upd&SN=' + oRes.SN); // ╠message.Save_Success⇒新增成功╣
  209. });
  210. }
  211. else {
  212. showMsgAndGo(i18next.t("message.Save_Success"), sProgramId, '?Action=Add'); // ╠message.Save_Success⇒新增成功╣
  213. }
  214. if (data.ExhibitionDateStart && data.ExhibitionDateEnd) {
  215. //如果展覽時間不為空的話就同步更新至行事曆和outlook中
  216. fnSynChronousCalendar(data);
  217. }
  218. }
  219. else {
  220. showMsg(i18next.t("message.Save_Failed"), 'error'); // ╠message.Save_Failed⇒新增失敗╣
  221. }
  222. }, function () {
  223. showMsg(i18next.t("message.Save_Failed"), 'error'); // ╠message.Save_Failed⇒新增失敗╣
  224. });
  225. }
  226. else {
  227. showMsg(i18next.t('message.CreateBill_Failed') + '<br>' + res.MSG, 'error'); // ╠message.CreateBill_Failed⇒帳單新增失敗╣
  228. }
  229. }, function () {
  230. showMsg(i18next.t('message.CreateBill_Failed'), 'error'); // ╠message.CreateBill_Failed⇒帳單新增失敗╣
  231. });
  232. },
  233. /**
  234. * 檢查名稱
  235. */
  236. fnCheckNameThenAction = function (Type) {
  237. return g_api.ConnectLite(sProgramId, 'CheckExhibitionName', {
  238. Type: Type,
  239. SN: getUrlParam('SN') ,
  240. Exhibitioname_TW: $('#Exhibitioname_TW').val() ? $('#Exhibitioname_TW').val(): "",
  241. ExhibitioShotName_TW: $('#ExhibitioShotName_TW').val() ? $('#ExhibitioShotName_TW').val() : "",
  242. Exhibitioname_EN: $('#Exhibitioname_EN').val() ? $('#Exhibitioname_EN').val(): "",
  243. }, function (res) {
  244. if (!res.MSG) {
  245. switch (Type) {
  246. case "add":
  247. case "readd":
  248. fnAdd(Type);
  249. break;
  250. case "upd":
  251. fnUpd();
  252. break;
  253. default:
  254. break;
  255. }
  256. }
  257. else {
  258. showMsg(res.MSG, 'error');
  259. }
  260. }, function () {
  261. showMsg("未知錯誤,請聯絡資訊人員", 'error');// ╠message.Transfer_Failed⇒拋轉失敗╣
  262. });
  263. },
  264. /**
  265. * 修改資料
  266. */
  267. fnUpd = function () {
  268. var data = getFormSerialize(oForm);
  269. data = packParams(data, 'upd');
  270. data.LogoFileId = oCurData.LogoFileId;
  271. if (!data.ExhibitionDate) {
  272. delete data.ExhibitionDateStart;
  273. delete data.ExhibitionDateEnd;
  274. }
  275. else {
  276. data.ExhibitionDateStart = $.trim(data.ExhibitionDate.split('~')[0]);
  277. data.ExhibitionDateEnd = $.trim(data.ExhibitionDate.split('~')[1]);
  278. }
  279. delete data.ExhibitionDate;
  280. delete data.file_hidden;
  281. //delete data.ResponsiblePerson;
  282. delete data.ListSource;
  283. delete data.ExhibitionCode2;
  284. delete data.ExhibitioShotName_TW2;
  285. delete data.ExhibitionDateStart2;
  286. delete data.ExhibitionDateEnd2;
  287. delete data.ResponsiblePerson2;
  288. delete data.Industry2;
  289. delete data.State2;
  290. delete data.ListSource;
  291. delete data.ListSource2;
  292. if (!data.ShelfTime_Home) {
  293. delete data.ShelfTime_Home;
  294. }
  295. if (!data.ShelfTime_Abroad) {
  296. delete data.ShelfTime_Abroad;
  297. }
  298. if (!data.ExhibitionCode) {
  299. data.ExhibitionCode = 'SerialNumber|' + parent.UserInfo.OrgID + '||MinYear|3||';
  300. }
  301. if (!data.SeaReceiveingDate) {
  302. delete data.SeaReceiveingDate
  303. }
  304. if (!data.SeaClosingDate) {
  305. delete data.SeaClosingDate
  306. }
  307. if (!data.AirReceiveingDate) {
  308. delete data.AirReceiveingDate
  309. }
  310. if (!data.AirClosingDate) {
  311. delete data.AirClosingDate
  312. }
  313. if(parent.OrgID != "TG"){
  314. data.CostRulesId = data.CostRulesIdTE;
  315. } else {
  316. data.CostRulesId = data.CostRulesIdTG;
  317. }
  318. delete data.CostRulesIdTE;
  319. delete data.CostRulesIdTG;
  320. CallAjax(ComFn.W_Com, ComFn.GetUpd, {
  321. Params: {
  322. exhibition: {
  323. values: data,
  324. keys: { SN: sDataId }
  325. }
  326. }
  327. }, function (res) {
  328. if (res.d > 0) {
  329. bRequestStorage = false;
  330. showMsg(i18next.t("message.Modify_Success"), 'success'); //╠message.Modify_Success⇒修改成功╣
  331. if (window.bLeavePage) {
  332. setTimeout(function () {
  333. pageLeave();
  334. }, 1000);
  335. }
  336. }
  337. else {
  338. showMsg(i18next.t("message.Modify_Failed"), 'error');//╠message.Modify_Failed⇒修改失敗╣
  339. }
  340. }, function () {
  341. showMsg(i18next.t("message.Modify_Failed"), 'error');//╠message.Modify_Failed⇒修改失敗╣
  342. });
  343. },
  344. /**
  345. * 資料刪除
  346. */
  347. fnDel = function () {
  348. g_api.ConnectLite(sProgramId, 'Delete', {
  349. SN: sDataId
  350. }, function (res) {
  351. if (res.RESULT) {
  352. showMsgAndGo(i18next.t("message.Delete_Success"), sQueryPrgId); // ╠message.Delete_Success⇒刪除成功╣
  353. }
  354. else {
  355. showMsg(i18next.t("message.Delete_Failed"), 'error'); // ╠message.Delete_Failed⇒刪除失敗╣
  356. }
  357. }, function () {
  358. showMsg(i18next.t("message.Delete_Failed"), 'error'); // ╠message.Delete_Failed⇒刪除失敗╣
  359. });
  360. },
  361. /**
  362. * 設定國家下拉選單
  363. */
  364. setStateDrop = function () {
  365. return g_api.ConnectLite(Service.com, ComFn.GetArguments, {
  366. ArgClassID: 'Area',
  367. ParentID: '',
  368. LevelOfArgument: 1
  369. }, function (res) {
  370. if (res.RESULT) {
  371. saState = res.DATA.rel;
  372. if (saState.length > 0) {
  373. $('#State').html(createOptions(saState, 'id', 'text', true)).change(function () {
  374. setExhibitionAddressDrop();
  375. });
  376. select2Init($('#State').parent());
  377. if (parent.OrgID === 'TG' && sAction === 'Add') {
  378. $('#State').val('TWN');
  379. setExhibitionAddressDrop();
  380. }
  381. }
  382. else {
  383. $('#State').html(createOptions([]));
  384. }
  385. $('#State2').html($('#State').html());
  386. }
  387. });
  388. },
  389. /**
  390. * 設定展覽地點下拉選單
  391. */
  392. setExhibitionAddressDrop = function () {
  393. var sState = $('#State').val() || '';
  394. g_api.ConnectLite(Service.com, ComFn.GetArguments, {
  395. ArgClassID: 'Area',
  396. ParentID: sState,
  397. LevelOfArgument: 2
  398. }, function (res) {
  399. if (res.RESULT) {
  400. saHalls = res.DATA.rel;
  401. if (saHalls.length > 0) {
  402. $('#ExhibitionAddress').html(createOptions(saHalls, 'id', 'text', true)).change(function () {
  403. var sExhibitionAddressId = this.value;
  404. if (sExhibitionAddressId) {
  405. var oState = Enumerable.From(saHalls).Where(function (e) { return e.id === sExhibitionAddressId; }).First();
  406. $('#ExhibitionAddress_CN').text(oState.text_cn);
  407. $('#ExhibitionAddress_EN').text(oState.text_en);
  408. }
  409. else {
  410. $('#ExhibitionAddress_CN').text('');
  411. $('#ExhibitionAddress_EN').text('');
  412. }
  413. });
  414. if (oCurData.ExhibitionAddress) {
  415. $('#ExhibitionAddress').val(oCurData.ExhibitionAddress);
  416. if (!$('#ExhibitionAddress').val()) {
  417. $('#ExhibitionAddress_CN').text('');
  418. $('#ExhibitionAddress_EN').text('');
  419. }
  420. }
  421. }
  422. else {
  423. $('#ExhibitionAddress').html(createOptions([]));
  424. }
  425. }
  426. });
  427. },
  428. /**
  429. * 設定費用規則下拉選單
  430. */
  431. setCostRulesDrop = function () {
  432. return CallAjax(ComFn.W_Com, ComFn.GetList, {
  433. Type: '', Params: {
  434. exhibitionrules: {
  435. OrgID: parent.OrgID,
  436. Effective: "Y"
  437. }
  438. }
  439. }, function (res) {
  440. var saData = JSON.parse(res.d);
  441. if (saData) {
  442. $('#CostRulesIdTG').html(createOptions(saData, 'Guid', 'Title'));
  443. $('#CostRulesIdTE').html(createOptions(saData, 'Guid', 'Title'));
  444. }
  445. });
  446. },
  447. /**
  448. * 設定名單來源下拉選單
  449. */
  450. setListSourceDrop = function () {
  451. return g_api.ConnectLite('Customers_Upd', 'GetListSource', {}, function (res) {
  452. if (res.RESULT) {
  453. if (res.DATA.rel.length > 0) {
  454. sListSourceHtml = createOptions(res.DATA.rel, 'id', 'text').replace('<option value="">請選擇...</option>','<option value="">請選擇...</option><option value="SelfCome" title="自來">自來</option>') +
  455. '<option value="ImportFromDB" title="資料庫匯入">資料庫匯入</option>';
  456. $('#ListSource').html(sListSourceHtml).val(saListSource).select2();
  457. $('#ListSource2').html(sListSourceHtml).val(saListSource).select2();
  458. }
  459. else {
  460. $('#ListSource').html(createOptions([]));
  461. $('#ListSource2').html(createOptions([]));
  462. }
  463. //$('#ListSource2').html($('#ListSource').html());
  464. }
  465. });
  466. },
  467. /**
  468. * 上傳附件
  469. * @param {Array}files 要綁定的html物件
  470. */
  471. fnUpload = function (files) {
  472. var option = {};
  473. option.input = $('#fileInput');
  474. option.theme = 'dragdropbox';
  475. option.folder = 'Exhibition';
  476. option.type = 'one';
  477. option.extensions = ['jpg', 'jpeg', 'png', 'bmp', 'gif', 'png'];
  478. option.limit = 1;
  479. option.parentid = oCurData.LogoFileId;
  480. if (files) {
  481. option.files = files;
  482. }
  483. fnUploadRegister(option);
  484. },
  485. /**
  486. * 拋轉文中
  487. */
  488. fnTransfer = function () {
  489. g_api.ConnectLite('Exhibition', 'Transfer', {
  490. SN: oCurData.SN
  491. }, function (res) {
  492. if (res.RESULT) {
  493. showMsg(i18next.t("message.Transfer_Success"), 'success'); // ╠message.Transfer_Success⇒拋轉完成╣
  494. parent.msgs.server.pushTransfer(parent.OrgID, parent.UserID, oCurData.ExhibitionCode, 3);
  495. fnGet();
  496. }
  497. else {
  498. showMsg(i18next.t('message.Transfer_Failed') + '<br>' + res.MSG, 'error');// ╠message.Transfer_Failed⇒拋轉失敗╣
  499. }
  500. }, function () {
  501. showMsg(i18next.t("message.Transfer_Failed"), 'error');// ╠message.Transfer_Failed⇒拋轉失敗╣
  502. });
  503. },
  504. /**
  505. * 抓去參加展覽列表資料
  506. * @param {String} flag 是否匯出
  507. * @return {Object} ajax物件
  508. */
  509. fnGetGridData = function (args) {
  510. if (sDataId) {
  511. return g_api.ConnectLite(sProgramId, 'GetExhibitionList', {
  512. SN: sDataId,
  513. sortField: args.sortField,
  514. sortOrder: args.sortOrder,
  515. Excel: args.Excel
  516. }, function (res) {
  517. if (res.RESULT) {
  518. saGridData = res.DATA.rel;
  519. if (args.Excel) {
  520. DownLoadFile(saGridData);
  521. layer.close(args.Index);
  522. }
  523. intListCount = saGridData.length;
  524. $.each(saGridData, function (idx, data) {
  525. if(data.ListSource != "" && data.ListSource != null ){
  526. if($.inArray(data.ListSource, saListSource) < 0){
  527. saListSource.push(data.ListSource);
  528. }
  529. }
  530. });
  531. $("#ListSource").val(saListSource).trigger('change');
  532. $("#ListSource2").val(saListSource).trigger('change');
  533. saCustomerList = [];
  534. }
  535. });
  536. }
  537. else {
  538. return $.Deferred().resolve().promise();
  539. }
  540. },
  541. /**
  542. * 抓去參加展覽列表資料
  543. * @param {String} flag 是否匯出
  544. * @return {Object} ajax物件
  545. */
  546. fnGetGridData1 = function (args) {
  547. var oQueryPm = {};
  548. $.extend(oQueryPm, oBaseQueryPm, args);
  549. if (sDataId) {
  550. oQueryPm.SN = sDataId;
  551. return g_api.ConnectLite(sProgramId, 'GetImportCustomers', oQueryPm);
  552. }
  553. else {
  554. return $.Deferred().resolve().promise();
  555. }
  556. },
  557. fnGetGridData2 = function (guid) {
  558. return g_api.ConnectLite('Contactors_Qry', 'QueryByCustomer', {
  559. CustomerId: guid
  560. }, function (res) {
  561. if (res.RESULT) {
  562. saGridData2 = res.DATA.rel;
  563. }
  564. });
  565. },
  566. fnGetGridData3 = function (_SN) {
  567. return g_api.ConnectLite(sProgramId, 'GetExhibitionList', {
  568. SN: _SN,
  569. Flag: ''
  570. }, function (res) {
  571. saGridData3 = res.DATA.rel;
  572. });
  573. },
  574. fnGetGridData4 = function (_SN) {
  575. return g_api.ConnectLite(sProgramId, 'GetExhibitionListFile', {
  576. SN: _SN,
  577. Flag: ''
  578. }, function (res) {
  579. saGridData3 = res.DATA.rel;
  580. });
  581. },
  582. /**
  583. * 刪除單筆列表資料
  584. * @param {String} id 廠商id
  585. * @return {Object} ajax 物件
  586. */
  587. fnDelGrid1Data = function (id) {
  588. CallAjax(ComFn.W_Com, ComFn.GetDel, {
  589. Params: {
  590. importcustomers: {
  591. guid: id
  592. }
  593. }
  594. }, function (res) {
  595. if (res.d > 0) {
  596. showMsg(i18next.t("message.Delete_Success"), 'success'); // ╠message.Delete_Success⇒刪除成功╣
  597. oGrid1.loadData();
  598. }
  599. else {
  600. showMsg(i18next.t("message.Delete_Failed"), 'error'); // ╠message.Delete_Failed⇒刪除失敗╣
  601. }
  602. }, function () {
  603. showMsg(i18next.t("message.Delete_Failed"), 'error'); // ╠message.Delete_Failed⇒刪除失敗╣
  604. });
  605. },
  606. /**
  607. * 轉正式資料
  608. * @param {Object} item 單筆廠商資料
  609. * @return {Object} ajax 物件
  610. */
  611. fnTransferToFormal = function (item) {
  612. parent.openPageTab('Customers_Upd', '?Action=Upd&guid=' + item.guid);
  613. /* layer.open({
  614. type: 2, //0(信息框,默认)1(页面层)2(iframe层)3(加载层)4(tips层)
  615. title: i18next.t('common.CustomerTransferToFormal'),// ╠common.CustomerTransferToFormal⇒匯入廠商轉正╣
  616. area: ['1200px', '600px'],//寬度
  617. shade: 0.75,//遮罩
  618. maxmin: true, //开启最大化最小化按钮
  619. id: 'layer_TransferToFormal', //设定一个id,防止重复弹出
  620. anim: 0,//彈出動畫
  621. btnAlign: 'c',//按鈕位置
  622. content: '../Crm/Customers_Upd.html?Action=Add&From=Appoint&Flag=Pop',
  623. success: function (layero, index) {
  624. //layer.full(index); //弹出即全屏
  625. var iframe = layero.find('iframe').contents();
  626. iframe.find('#CustomerCName').val(item.CustomerCName);
  627. iframe.find('#CustomerEName').val(item.CustomerEName);
  628. iframe.find('#UniCode').val(item.UniCode);
  629. iframe.find('#Telephone').val(item.Telephone);
  630. iframe.find('#Email').val(item.Email);
  631. iframe.find('#Address').val(item.Address);
  632. iframe.find('#InvoiceAddress').val(item.InvoiceAddress);
  633. iframe.find('body').attr('PopId', item.guid);
  634. setTimeout(function () {
  635. iframe.find('.plustemplkey ').trigger('click');
  636. var _input = iframe.find('#table_box').find(':input');
  637. _input.eq(0).val(item.Contactor);
  638. _input.eq(2).val(item.Telephone);
  639. _input.eq(5).val(item.Email);
  640. setTimeout(function () {
  641. _input.eq(0).trigger('click');
  642. _input.eq(2).trigger('click');
  643. _input.eq(5).trigger('click');
  644. }, 500);
  645. }, 1000);
  646. },
  647. end: function () {
  648. if (bRefresh) {
  649. bRefresh = false;
  650. oGrid1.loadData();
  651. }
  652. }
  653. }); */
  654. },
  655. /**
  656. * 匯入廠商資料
  657. */
  658. fnImportCusList = function () {
  659. $('#importfile').val('').off('change').on('change', function () {
  660. $("#spnFileName").text(this.value.split('/').pop().split('\\').pop());
  661. /* if (this.value.indexOf('.xls') > -1 || this.value.indexOf('.xlsx') > -1) {
  662. var sFileId = guid(),
  663. sFileName = this.value;
  664. $.ajaxFileUpload({
  665. url: '/Controller.ashx?action=importfile&FileId=' + sFileId,
  666. secureuri: false,
  667. fileElementId: 'importfile',
  668. success: function (data, status) {
  669. g_api.ConnectLite(sProgramId, 'ImportCustomers', {
  670. FileId: sFileId,
  671. FileName: sFileName,
  672. SN: sDataId
  673. }, function (res) {
  674. if (res.RESULT) {
  675. oGrid1.loadData();
  676. }
  677. else {
  678. showMsg(i18next.t('message.ProgressError') + '<br>' + res.MSG, 'error'); // ╠message.ProgressError⇒資料處理異常╣
  679. }
  680. }, function () {
  681. showMsg(i18next.t("message.ProgressError"), 'error'); // ╠message.ProgressError⇒資料處理異常╣
  682. });
  683. },
  684. error: function (data, status, e) {
  685. showMsg(i18next.t("message.ProgressError"), 'error'); // ╠message.ProgressError⇒資料處理異常╣
  686. }
  687. });
  688. bRequestStorage = true;
  689. }
  690. else {
  691. showMsg(i18next.t("message.FileTypeError"), 'error'); // ╠message.FileTypeError⇒文件格式錯誤╣
  692. } */
  693. }).click();
  694. },
  695. /**
  696. * 匯入廠商資料匯出
  697. */
  698. fnExportCusList = function () {
  699. g_api.ConnectLite(sProgramId, 'ExportCustomers', {
  700. SN: sDataId
  701. }, function (res) {
  702. if (res.RESULT) {
  703. DownLoadFile(res.DATA.rel);
  704. }
  705. });
  706. },
  707. /**
  708. * 新增匯入客戶
  709. * @param {Object}data 序列化資料
  710. */
  711. fnAddCustomers = function (data) {
  712. data.ExhibitionNO = sDataId;
  713. g_api.ConnectLite(sProgramId, 'InsertImportCustomers', data, function (res) {
  714. if (res.RESULT) {
  715. oGrid1.loadData();
  716. showMsg(i18next.t("message.Save_Success"), 'success'); // ╠message.Save_Success⇒新增成功╣
  717. }
  718. else {
  719. showMsg(res.MSG, 'error');
  720. }
  721. }, function () {
  722. showMsg(i18next.t("message.Save_Failed"), 'error'); // ╠message.Save_Failed⇒新增失敗╣
  723. });
  724. },
  725. /**
  726. * 修改資料
  727. * @param {Object}data 序列化資料
  728. */
  729. fnUpdCustomers = function (data) {
  730. data = packParams(data, 'upd');
  731. delete data.Exhibitioname_TW;
  732. delete data.Exhibitioname_EN;
  733. data = removeNull(data);
  734. g_api.ConnectLite(sProgramId, 'UpdImportCustomers', data, function (res) {
  735. if (res.RESULT) {
  736. bRequestStorage = false;
  737. showMsg(i18next.t("message.Modify_Success"), 'success'); // ╠message.Modify_Success⇒修改成功╣
  738. }
  739. else {
  740. showMsg(res.MSG, 'error');
  741. }
  742. }, function () {
  743. showMsg(i18next.t("message.Modify_Failed"), 'error'); // ╠message.Modify_Failed⇒修改失敗╣
  744. });
  745. },
  746. /**
  747. * 目的 對應正式客戶
  748. * @param {String}item 預約單資料
  749. */
  750. fnCorrespondFormalCus = function (item) {
  751. layer.open({
  752. type: 1, //0(信息框,默认)1(页面层)2(iframe层)3(加载层)4(tips层)
  753. title: i18next.t("common.CorrespondFormalCus"), // ╠common.CorrespondImpCus⇒對應正式客戶╣
  754. area: '640px;',//寬度
  755. shade: 0.75,//遮罩
  756. closeBtn: 1,
  757. //maxmin: true, //开启最大化最小化按钮
  758. id: 'layer_Correspond', //设定一个id,防止重复弹出
  759. offset: '100px',//右下角弹出
  760. anim: 0,//彈出動畫
  761. btn: [i18next.t('common.Confirm'), i18next.t('common.Cancel')],//╠common.Confirm⇒確定╣╠common.Cancel⇒取消╣
  762. btnAlign: 'c',//按鈕位置
  763. content: '<style>.select2-container{z-index: 39891015;}</style><div class="form-group">\
  764. <div class="col-sm-12">\
  765. <select class= "form-control w95p" id="CustomerId" name="CustomerId"></select>\
  766. </div>\
  767. </div >',
  768. success: function (layero, index) {
  769. g_api.ConnectLite(Service.sys, 'GetCustomerlist', {}, function (res) {
  770. if (res.RESULT) {
  771. var saList = res.DATA.rel;
  772. var sOptions = createOptions(saList, 'id', 'text');
  773. $('#CustomerId').html(sOptions).select2();
  774. }
  775. });
  776. transLang(layero);
  777. },
  778. yes: function (index, layero) {
  779. let sCustomerId = $('#CustomerId').val();
  780. if (!sCustomerId) {
  781. showMsg(i18next.t('message.SelectFormalCus'));//╠message.SelectFormalCus⇒請選擇對應的客戶╣
  782. return false;
  783. }
  784. /* return g_api.ConnectLite('Exhibition_Upd', 'UpdateCustomerTag', {//匯入費用項目
  785. PrevId: item.guid,
  786. AfterId: sCustomerId
  787. }, function (res) {
  788. if (res.DATA.rel) {
  789. oGrid1.loadData();
  790. showMsg(i18next.t("message.Correspond_Success"), 'success'); //╠message.Correspond_Success⇒對應成功╣
  791. layer.close(index);
  792. }
  793. else {
  794. showMsg(i18next.t("message.Correspond_Failed"), 'error');//╠message.Correspond_Failed⇒對應失敗╣
  795. }
  796. }); */
  797. var combinedata = {};
  798. combinedata.Type = "2";
  799. combinedata.guid1 = item.guid;
  800. combinedata.guid2 = sCustomerId;
  801. g_api.ConnectLite('Customers_Upd', 'CombineCustomer', combinedata
  802. , function (res) {
  803. if (res.DATA.rel) {
  804. oGrid.loadData();
  805. showMsg(i18next.t("message.Correspond_Success"), 'success'); //╠message.Correspond_Success⇒對應成功╣
  806. layer.close(index);
  807. }
  808. else {
  809. showMsg(i18next.t("message.Correspond_Failed"), 'error');//╠message.Correspond_Failed⇒對應失敗╣
  810. }
  811. }
  812. , function () {
  813. showMsg(i18next.t("message.Correspond_Failed"), 'error');//╠message.Correspond_Failed⇒對應失敗╣
  814. });
  815. }
  816. });
  817. },
  818. /**
  819. * 同步新更新行事曆和outlook
  820. * @param {Object}_data 序列化資料
  821. */
  822. fnSynChronousCalendar = function (_data) {
  823. var data = {};
  824. data.CalType = '04';//展覽
  825. data.Title = _data.ExhibitioShotName_TW;
  826. data.Description = _data.Exhibitioname_TW + '(' + _data.Exhibitioname_EN + ') ' + _data.Memo;
  827. data.StartDate = _data.ExhibitionDateStart;
  828. data.EndDate = _data.ExhibitionDateEnd;
  829. data.Color = parent.UserInfo.CalColor;
  830. data.RelationId = _data.ExhibitionCode;
  831. data.GroupMembers = '';
  832. data.Importment = 'M';
  833. data.OpenMent = 'C';
  834. data.AllDay = '0';
  835. g_api.ConnectLite('Calendar', ComFn.GetAdd, data,
  836. function (res) {
  837. if (res.RESULT) {
  838. var sNo = res.DATA.rel;
  839. if (parent.Outklook) {
  840. outlookAPI(outlook.Calendar_Add, {
  841. NO: sNo,
  842. ResponseRequested: false
  843. });
  844. }
  845. }
  846. });
  847. },
  848. /**
  849. * 打開要匯出的pop選擇匯出類別
  850. */
  851. fnOpenPopToExcel = function () {
  852. layer.confirm("確定要匯出嗎?", { icon: 3, title: i18next.t('common.Tips') }, function (index) {
  853. fnGetGridData({
  854. Excel: true,
  855. Index: index
  856. });
  857. })
  858. },
  859. /**
  860. * ToolBar 按鈕事件 function
  861. * @param {Object}inst 按鈕物件對象
  862. * @param {Object} e 事件對象
  863. */
  864. fnButtonHandler = function (inst, e) {
  865. var sId = inst.id;
  866. switch (sId) {
  867. case "Toolbar_Qry":
  868. break;
  869. case "Toolbar_Save":
  870. $('#file_hidden').val($('li.jFiler-item').length || '');
  871. if (!$("#form_main").valid()) {
  872. oValidator.focusInvalid();
  873. return;
  874. }
  875. if (sAction === 'Add') {
  876. fnCheckNameThenAction('add');//fnAdd('add');
  877. }
  878. else {
  879. fnCheckNameThenAction('upd');//fnUpd();
  880. }
  881. break;
  882. case "Toolbar_ReAdd":
  883. $('#file_hidden').val($('li.jFiler-item').length || '');
  884. if (!$("#form_main").valid()) {
  885. oValidator.focusInvalid();
  886. return;
  887. }
  888. fnCheckNameThenAction('readd'); // fnAdd('readd');
  889. break;
  890. case "Toolbar_Clear":
  891. clearPageVal();
  892. break;
  893. case "Toolbar_Leave":
  894. pageLeave();
  895. break;
  896. case "Toolbar_Add":
  897. break;
  898. case "Toolbar_Upd":
  899. break;
  900. case "Toolbar_Copy":
  901. break;
  902. case "Toolbar_Del": // ╠message.ConfirmToDelete⇒確定要刪除嗎 ?╣ ╠common.Tips⇒提示╣
  903. layer.confirm('確定要刪除 [ <b style="color:red;">展覽管理案件</b> ] 嗎', { icon: 3, title: i18next.t('common.Tips') }, function (index) {
  904. fnDel();
  905. layer.close(index);
  906. });
  907. break;
  908. case "Toolbar_Imp":
  909. break;
  910. case "Toolbar_Transfer":
  911. fnTransfer();
  912. break;
  913. case "Toolbar_Exp":
  914. if (oGrid.data.length === 0) {
  915. showMsg(i18next.t("message.NoDataExport"));// ╠message.NoDataExport⇒沒有資料匯出╣
  916. return false;
  917. }
  918. fnOpenPopToExcel();
  919. break;
  920. default:
  921. alert("No handle '" + sId + "'");
  922. break;
  923. }
  924. },
  925. /**
  926. * 目的 新增名單
  927. * @param
  928. */
  929. fnAddList = function () {
  930. layer.open({
  931. type: 1, //0(信息框,默认)1(页面层)2(iframe层)3(加载层)4(tips层)
  932. title: "新增名單", // ╠common.CorrespondImpCus⇒對應正式客戶╣
  933. area: ['200px', '220px'],//寬度
  934. shade: 0.75,//遮罩
  935. closeBtn: 1,
  936. //maxmin: true, //开启最大化最小化按钮
  937. id: 'layer_AddList', //设定一个id,防止重复弹出
  938. //offset: '50px',//右下角弹出
  939. anim: 0,//彈出動畫
  940. //btn: [i18next.t('common.Confirm'), i18next.t('common.Cancel')],//╠common.Confirm⇒確定╣╠common.Cancel⇒取消╣
  941. btnAlign: 'c',//按鈕位置
  942. content: '<div class="pop-box">\
  943. <p><button type="button" data-i18n="" id="btnAddListSingle" class="btn-custom w100p orange">單筆新增</button></p>\
  944. <p><button type="button" data-i18n="" id="btnAddListFile" class="btn-custom w100p orange">檔案匯入</button></p>\
  945. <p><button type="button" data-i18n="" id="btnAddListDB" class="btn-custom w100p orange">資料庫匯入</button></p>\
  946. </div>',
  947. success: function (layero, index) {
  948. $('#btnAddListSingle').click(function () {
  949. fnAddListSingle();
  950. layer.close(index);
  951. return false;
  952. });
  953. $('#btnAddListFile').click(function () {
  954. fnAddListFile();
  955. layer.close(index);
  956. return false;
  957. });
  958. $('#btnAddListDB').click(function () {
  959. fnAddListDB();
  960. layer.close(index);
  961. return false;
  962. });
  963. },
  964. yes: function (index, layero) {
  965. }
  966. });
  967. },
  968. /**
  969. * 目的 單筆新增
  970. * @param
  971. */
  972. fnAddListSingle = function () {
  973. sChooseCustomerId = "";
  974. bNewCustomer = false;
  975. layer.open({
  976. type: 1, //0(信息框,默认)1(页面层)2(iframe层)3(加载层)4(tips层)
  977. title: "單筆新增", // ╠common.CorrespondImpCus⇒對應正式客戶╣
  978. area: ['70%', '90%'],//寬度
  979. shade: 0.75,//遮罩
  980. closeBtn: 1,
  981. //maxmin: true, //开启最大化最小化按钮
  982. id: 'layer_AddListSingle', //设定一个id,防止重复弹出
  983. offset: '10px',//右下角弹出
  984. anim: 0,//彈出動畫
  985. btn: [i18next.t('common.Confirm'), i18next.t('common.Cancel')],//╠common.Confirm⇒確定╣╠common.Cancel⇒取消╣
  986. btnAlign: 'c',//按鈕位置
  987. content: '<style>.select2-container{z-index: 39891015;}</style><div class="pop-box row w100p">\
  988. <label class="col-sm-2 control-label" for="input-Default">\
  989. <span data-i18n="">客戶搜尋</span><span></span>\
  990. </label>\
  991. <div class="col-sm-4 text-left abb">\
  992. <select class="form-control w100p" data-type="select2" id="CustomerGuid" name="CustomerGuid"></select>\
  993. </div>\
  994. <label class="col-sm-2 control-label" for="input-Default">\
  995. <span data-i18n="">統一編號</span><span></span>\
  996. </label>\
  997. <div class="col-sm-3">\
  998. <input type="text" class="form-control w100p" name="UniCodeQry" id="UniCodeQry" placeholderid="" placeholder="">\
  999. </div>\
  1000. <div class="col-sm-1">\
  1001. <button type="button" data-i18n="" id="btnSetCustomerData" class="btn-custom w100p blue">帶入資料</button>\
  1002. </div>\
  1003. </div>\
  1004. <hr>\
  1005. <form id="form_AddListSingle" class="form-horizontal">\
  1006. <div class="pop-box row w100p">\
  1007. <label class="col-sm-2 control-label" for="input-Default"><b class="t-red">*</b>\
  1008. <span data-i18n="">客戶名稱</span><span></span>\
  1009. </label>\
  1010. <div class="col-sm-4">\
  1011. <input type="text" class="form-control w100p" name="CustomerCName" id="CustomerCName" placeholderid="" placeholder="">\
  1012. </div>\
  1013. <label class="col-sm-2 control-label" for="input-Default">\
  1014. <span data-i18n="">統一編號</span><span></span>\
  1015. </label>\
  1016. <div class="col-sm-3">\
  1017. <input type="text" class="form-control w100p" name="UniCode" id="UniCode" placeholderid="" placeholder="">\
  1018. </div>\
  1019. </div>\
  1020. <div class="pop-box row w100p">\
  1021. <label class="col-sm-2 control-label" for="input-Default">\
  1022. <span data-i18n="">客戶英文名稱</span><span></span>\
  1023. </label>\
  1024. <div class="col-sm-4">\
  1025. <input type="text" class="form-control w100p" name="CustomerEName" id="CustomerEName" placeholderid="" placeholder="">\
  1026. </div>\
  1027. <label class="col-sm-2 control-label" for="input-Default"><b class="t-red">*</b>\
  1028. <span data-i18n="">名單來源</span><span></span>\
  1029. </label>\
  1030. <div class="col-sm-3 text-left">\
  1031. <select class="form-control w100p" data-type="select2" id="ListSourceA" name="ListSourceA"></select>\
  1032. </div>\
  1033. </div>\
  1034. <div class="pop-box row w100p">\
  1035. <label class="col-sm-2 control-label" for="input-Default">\
  1036. <span data-i18n="">地址</span><span></span>\
  1037. </label>\
  1038. <div class="col-sm-9">\
  1039. <input type="text" class="form-control w100p" name="Address" id="Address" placeholderid="" placeholder="">\
  1040. </div>\
  1041. </div>\
  1042. <div class="pop-box row w100p">\
  1043. <label class="col-sm-2 control-label" for="input-Default">\
  1044. <span data-i18n="">官網地址</span><span></span>\
  1045. </label>\
  1046. <div class="col-sm-9">\
  1047. <input type="text" class="form-control w100p" name="WebsiteAddress" id="WebsiteAddress" placeholderid="" placeholder="">\
  1048. </div>\
  1049. </div>\
  1050. </form>\
  1051. <div class="pop-box row w100p">\
  1052. <div class="col-sm-2 col-sm-offset-1">\
  1053. <button type="button" data-i18n="" id="btnChooseContactors" class="btn-custom w100p blue" disabled>選擇聯絡人</button>\
  1054. </div>\
  1055. <div class="col-sm-2">\
  1056. <button type="button" data-i18n="" id="btnCreateContactor" class="btn-custom w100p blue">新增聯絡人</button>\
  1057. </div>\
  1058. </div>\
  1059. <div class="pop-box col-sm-10 col-sm-offset-1">\
  1060. <div id="jsGridSingle"></div>\
  1061. </div>',
  1062. success: function (layero, index) {
  1063. saContactorList = [];
  1064. g_api.ConnectLite(Service.sys, 'GetAllCustomerlist', {}, function (res) {
  1065. if (res.RESULT) {
  1066. var saList = res.DATA.rel;
  1067. var sOptions = createOptions(saList, 'id', 'text');
  1068. $('#CustomerGuid').html(sOptions).select2();
  1069. }
  1070. });
  1071. $('#ListSourceA').html(sListSourceHtml.replace('<option value="ImportFromDB" title="資料庫匯入">資料庫匯入</option>','')).select2();
  1072. /* g_api.ConnectLite('Customers_Upd', 'GetListSource', {}, function (res) {
  1073. if (res.RESULT) {
  1074. var saList = res.DATA.rel;
  1075. var sOptions = createOptions(saList, 'guid', 'CustomerShotCName');
  1076. $('#ListSourceA').html(sOptions).select2();
  1077. }
  1078. }); */
  1079. $('#btnSetCustomerData').click(function () {
  1080. sChooseCustomerId = "";
  1081. if($('#CustomerGuid').val() != "" || $('#UniCodeQry').val() != ""){
  1082. saContactorList = [];
  1083. g_api.ConnectLite(sProgramId, 'CustomerQuery', {
  1084. guid: $('#CustomerGuid').val(),
  1085. unicode: $('#UniCodeQry').val()
  1086. }, function (res) {
  1087. if (res.RESULT) {
  1088. bNewCustomer = true;
  1089. var oRes = res.DATA.rel;
  1090. if(oRes != null){
  1091. sChooseCustomerId = oRes.guid;
  1092. $("#UniCode").val(oRes.UniCode);
  1093. $("#CustomerCName").val(oRes.CustomerCName);
  1094. $("#CustomerEName").val(oRes.CustomerEName);
  1095. $("#Address").val(oRes.Address);
  1096. $("#WebsiteAddress").val(oRes.WebsiteAdress);
  1097. $("#CustomerCName").prop("disabled", true);
  1098. $("#CustomerEName").prop("disabled", true);
  1099. $("#UniCode").prop("disabled", true);
  1100. $("#Address").prop("disabled", true);
  1101. $("#WebsiteAddress").prop("disabled", true);
  1102. $("#btnChooseContactors").prop("disabled", false);
  1103. } else {
  1104. showMsg(i18next.t('message.NotFindData'), 'error'); // ╠message.NotFindData⇒查不到對應的資料╣
  1105. $("#UniCode").val("");
  1106. $("#CustomerCName").val("");
  1107. $("#CustomerEName").val("");
  1108. $("#Address").val("");
  1109. $("#WebsiteAddress").val("");
  1110. $("#CustomerCName").prop("disabled", false);
  1111. $("#CustomerEName").prop("disabled", false);
  1112. $("#UniCode").prop("disabled", false);
  1113. $("#Address").prop("disabled", false);
  1114. $("#WebsiteAddress").prop("disabled", false);
  1115. $("#btnChooseContactors").prop("disabled", true);
  1116. }
  1117. }
  1118. else {
  1119. showMsg(i18next.t('message.NotFindData'), 'error'); // ╠message.NotFindData⇒查不到對應的資料╣
  1120. }
  1121. }, function () {
  1122. showMsg(i18next.t('message.NotFindData'), 'error');
  1123. });
  1124. oGrid2.loadData();
  1125. }
  1126. });
  1127. $("#jsGridSingle").jsGrid({
  1128. width: "100%",
  1129. height: "auto",
  1130. autoload: true,
  1131. filtering: false,
  1132. pageLoading: true,
  1133. inserting: false,
  1134. editing: false,
  1135. sorting: false,
  1136. paging: false,
  1137. pageIndex: 1,
  1138. pageSize: parent.SysSet.GridRecords || 10,
  1139. confirmDeleting: true,
  1140. deleteConfirm: i18next.t('message.ConfirmToDelete'),// ╠message.ConfirmToDelete⇒確定要刪除嗎 ?╣
  1141. pagePrevText: "<",
  1142. pageNextText: ">",
  1143. pageFirstText: "<<",
  1144. pageLastText: ">>",
  1145. rowClick: function (args) {
  1146. if (navigator.userAgent.match(/mobile/i)) {
  1147. goToEdit('Customers_Upd', '?Action=Upd&guid=' + args.item.guid);
  1148. }
  1149. },
  1150. rowDoubleClick: function (args) {
  1151. parent.openPageTab('Customers_Upd', '?Action=Upd&guid=' + args.item.guid);
  1152. },
  1153. fields: [
  1154. {
  1155. name: "RowIndex", title: 'common.RowNumber', width: 5, align: "center"
  1156. },
  1157. {
  1158. name: "ContactorName", title: 'common.Contactor', width: 25, align: "center"
  1159. },
  1160. {
  1161. name: "Telephone1", title: 'common.Telephone', width: 30
  1162. },
  1163. {
  1164. name: "Ext1", title: 'common.EXT', width: 10
  1165. },
  1166. {
  1167. name: "Email1", title: 'common.Email', width: 40
  1168. }
  1169. ],
  1170. controller: {
  1171. loadData: function (args) {
  1172. return {
  1173. data: saContactorList,
  1174. itemsCount: saContactorList.length //data.length
  1175. };
  1176. },
  1177. insertItem: function (args) {
  1178. },
  1179. updateItem: function (args) {
  1180. },
  1181. deleteItem: function (args) {
  1182. }
  1183. },
  1184. onInit: function (args) {
  1185. oGrid2 = args.grid;
  1186. }
  1187. });
  1188. $('#btnCreateContactor').click(function () {
  1189. fnCreateContactor();
  1190. return false;
  1191. });
  1192. $('#btnChooseContactors').click(function () {
  1193. fnChooseContactors(sChooseCustomerId);
  1194. return false;
  1195. });
  1196. },
  1197. yes: function (index, layero) {
  1198. let data = getFormSerialize($("#form_AddListSingle"))
  1199. if(data.CustomerCName == ""){
  1200. showMsg("客戶名稱不可為空");
  1201. return false;
  1202. } else if( $("#ListSourceA").val() == "" ){
  1203. showMsg("名單來源不可為空");
  1204. return false;
  1205. } else {
  1206. data.Contactors = saContactorList;
  1207. data.AddContactors = saAddContactorList;
  1208. data.ChooseContactors = saChooseContactorList;
  1209. if(bNewCustomer){
  1210. data.NewCustomer = "true";
  1211. }else{
  1212. data.NewCustomer = "false";
  1213. }
  1214. data.CustomerId = sChooseCustomerId;
  1215. data.OrgID = parent.OrgID;
  1216. data.ExhibitionNO = sDataId;
  1217. data.SourceType = "1";
  1218. data.ListSource = $("#ListSourceA").val();
  1219. g_api.ConnectLite(sProgramId, 'InsertExhibitionListSingle', data, function (res) {
  1220. if (res.RESULT) {
  1221. //oGrid.loadData();
  1222. showMsg(i18next.t("message.Save_Success"), 'success'); // ╠message.Save_Success⇒新增成功╣
  1223. layer.close(index);
  1224. }
  1225. else {
  1226. showMsg(res.MSG, 'error');
  1227. }
  1228. }, function () {
  1229. showMsg(i18next.t("message.Save_Failed"), 'error'); // ╠message.Save_Failed⇒新增失敗╣
  1230. });
  1231. }
  1232. },
  1233. end: function () {
  1234. saContactorList = [];
  1235. saChooseContactorList = [];
  1236. saAddContactorList = [];
  1237. oGrid.loadData();
  1238. }
  1239. });
  1240. },
  1241. /**
  1242. * 目的 選擇聯絡人
  1243. * @param
  1244. */
  1245. fnChooseContactors = function (_CustomerId) {
  1246. saContactorList = [];
  1247. saChooseContactorList = [];
  1248. layer.open({
  1249. type: 1, //0(信息框,默认)1(页面层)2(iframe层)3(加载层)4(tips层)
  1250. title: "選擇聯絡人", // ╠common.CorrespondImpCus⇒對應正式客戶╣
  1251. area: ['70%', '90%'],//寬度
  1252. shade: 0.01,//遮罩
  1253. closeBtn: 1,
  1254. //maxmin: true, //开启最大化最小化按钮
  1255. id: 'layer_ChooseContactors', //设定一个id,防止重复弹出
  1256. offset: '10px',//右下角弹出
  1257. anim: 0,//彈出動畫
  1258. btn: [i18next.t('common.Confirm'), i18next.t('common.Cancel')],//╠common.Confirm⇒確定╣╠common.Cancel⇒取消╣
  1259. btnAlign: 'c',//按鈕位置
  1260. content: '<div class="pop-box row w100p">\
  1261. <label class="col-sm-2 control-label" for="input-Default">\
  1262. <span data-i18n="">客戶名稱</span><span></span>\
  1263. </label>\
  1264. <div class="col-sm-4">\
  1265. <input type="text" class="form-control w100p" name="CustomerCNameA" id="CustomerCNameA" placeholderid="" placeholder="" disabled>\
  1266. </div>\
  1267. <label class="col-sm-2 control-label" for="input-Default">\
  1268. <span data-i18n="">統一編號</span><span></span>\
  1269. </label>\
  1270. <div class="col-sm-3">\
  1271. <input type="text" class="form-control w100p" name="UniCodeA" id="UniCodeA" placeholderid="" placeholder="" disabled>\
  1272. </div>\
  1273. </div>\
  1274. <div class="pop-box col-sm-10 col-sm-offset-1">\
  1275. <div id="jsGridChooseContactors"></div>\
  1276. </div>',
  1277. success: function (layero, index) {
  1278. /* g_api.ConnectLite('Contactors_Qry', 'QueryPage', {}, function (res) {
  1279. if (res.RESULT) {
  1280. //var saList = res.DATA.rel;
  1281. saGridDataB = res.DATA.rel;
  1282. oGrid2.loadData();
  1283. }
  1284. }); */
  1285. $("#jsGridChooseContactors").jsGrid({
  1286. width: "100%",
  1287. height: "auto",
  1288. autoload: true,
  1289. filtering: false,
  1290. pageLoading: true,
  1291. inserting: false,
  1292. editing: false,
  1293. sorting: false,
  1294. paging: false,
  1295. pageIndex: 1,
  1296. pageSize: parent.SysSet.GridRecords || 10,
  1297. confirmDeleting: true,
  1298. deleteConfirm: i18next.t('message.ConfirmToDelete'),// ╠message.ConfirmToDelete⇒確定要刪除嗎 ?╣
  1299. pagePrevText: "<",
  1300. pageNextText: ">",
  1301. pageFirstText: "<<",
  1302. pageLastText: ">>",
  1303. rowClick: function (args) {
  1304. /* if (navigator.userAgent.match(/mobile/i)) {
  1305. goToEdit('Customers_Upd', '?Action=Upd&guid=' + args.item.guid);
  1306. } */
  1307. },
  1308. rowDoubleClick: function (args) {
  1309. /* parent.openPageTab('Customers_Upd', '?Action=Upd&guid=' + args.item.guid); */
  1310. },
  1311. fields: [
  1312. {
  1313. name: "RowIndex", title: 'common.RowNumber', width: 5, align: "center",
  1314. itemTemplate: function (value, item) {
  1315. return $("<input>", {
  1316. type: 'checkbox', click: function (e) {
  1317. e.stopPropagation();
  1318. if (this.checked) {
  1319. item.RowIndex = saContactorList.length + 1;
  1320. saContactorList.push(item);
  1321. }
  1322. else {
  1323. var saNewList2 = [];
  1324. $.each(saContactorList, function (idx, data) {
  1325. let i = 0;
  1326. if (item.guid !== data.guid) {
  1327. data.RowIndex = i++;
  1328. saNewList2.push(data);
  1329. }
  1330. });
  1331. saContactorList = saNewList2;
  1332. }
  1333. }
  1334. });
  1335. }
  1336. },
  1337. {
  1338. name: "ContactorName", title: 'common.Contactor', width: 25, align: "center"
  1339. },
  1340. {
  1341. name: "Telephone1", title: 'common.Telephone', width: 30
  1342. },
  1343. {
  1344. name: "Ext1", title: 'common.EXT', width: 10
  1345. },
  1346. {
  1347. name: "Email1", title: 'common.Email', width: 40
  1348. }
  1349. ],
  1350. controller: {
  1351. loadData: function (args) {
  1352. return fnGetGridData2(_CustomerId);
  1353. },
  1354. insertItem: function (args) {
  1355. },
  1356. updateItem: function (args) {
  1357. },
  1358. deleteItem: function (args) {
  1359. }
  1360. }
  1361. /* onInit: function (args) {
  1362. oGrid2 = args.grid;
  1363. } */
  1364. });
  1365. /* g_api.ConnectLite('Contactors_Qry', 'QueryPage', {}, function (res) {
  1366. if (res.RESULT) {
  1367. var saList = res.DATA.rel;
  1368. saGridDataB = res.DATA.rel;
  1369. oGrid2.loadData();
  1370. }
  1371. }); */
  1372. //$('#btnChooseContactors').click(function () {
  1373. //fnAddEEE();
  1374. //fnCombineCustomer('0314d83b-b003-45cc-8c3d-7148bca65acf','0424389d-3f11-4cba-bcd8-dcd9cb560ab3');
  1375. //return false;
  1376. //});
  1377. },
  1378. yes: function (index, layero) {
  1379. saChooseContactorList = saContactorList;
  1380. if(saAddContactorList.length >0){
  1381. let i = saContactorList.length + 1;
  1382. $.each(saAddContactorList, function (idx, data) {
  1383. data.RowIndex = i + idx;
  1384. saContactorList.push(data);
  1385. });
  1386. }
  1387. oGrid2.loadData();
  1388. layer.close(index);
  1389. }
  1390. });
  1391. },
  1392. /**
  1393. * 目的 新增聯絡人
  1394. * @param
  1395. */
  1396. fnCreateContactor = function () {
  1397. //saContactorList = [];
  1398. layer.open({
  1399. type: 1, //0(信息框,默认)1(页面层)2(iframe层)3(加载层)4(tips层)
  1400. title: "新增聯絡人", // ╠common.CorrespondImpCus⇒對應正式客戶╣
  1401. area: ['70%', '90%'],//寬度
  1402. shade: 0.01,//遮罩
  1403. closeBtn: 1,
  1404. //maxmin: true, //开启最大化最小化按钮
  1405. id: 'layer_CreateContactor', //设定一个id,防止重复弹出
  1406. offset: '10px',//右下角弹出
  1407. anim: 0,//彈出動畫
  1408. btn: [i18next.t('common.Confirm'), i18next.t('common.Cancel')],//╠common.Confirm⇒確定╣╠common.Cancel⇒取消╣
  1409. btnAlign: 'c',//按鈕位置
  1410. content: '<form id="form_CreateContactor" class="form-horizontal">\
  1411. <div class="pop-box row w100p">\
  1412. <label class="col-sm-2 control-label"><b class="t-red">*</b><span data-i18n=""></span></label>\
  1413. <div class="col-sm-3">\
  1414. <select class="form-control w100p" id="Call" name="Call" placeholderid="" placeholder="">\
  1415. <option value="1">Mr.</option>\
  1416. <option value="2">Miss.</option>\
  1417. </select>\
  1418. </div>\
  1419. </div>\
  1420. <div class="pop-box row w100p">\
  1421. <label class="col-sm-2 control-label"><b class="t-red">*</b><span data-i18n=""></span></label>\
  1422. <div class="col-sm-3">\
  1423. <input type="text" class="form-control w100p" name="ContactorName" id="ContactorName" placeholderid="" placeholder="">\
  1424. </div>\
  1425. <label class="col-sm-2 control-label"><span data-i18n="">暱稱</span></label>\
  1426. <div class="col-sm-3">\
  1427. <input type="text" class="form-control w100p" name="NickName" id="NickName" placeholderid="" placeholder="">\
  1428. </div>\
  1429. </div>\
  1430. <div class="pop-box row w100p">\
  1431. <label class="col-sm-2 control-label"><span data-i18n="">生日</span></label>\
  1432. <div class="col-sm-3">\
  1433. <input type="text" class="form-control date-picker w100p" name="Birthday" id="Birthday" maxlength="10">\
  1434. </div>\
  1435. <label class="col-sm-2 control-label"><span data-i18n="">婚姻狀況</span></label>\
  1436. <div class="col-sm-3">\
  1437. <select class="form-control w100p" id="MaritalStatus" name="MaritalStatus" placeholderid="" placeholder="">\
  1438. <option value="1">未婚</option>\
  1439. <option value="2">已婚</option>\
  1440. </select>\
  1441. </div>\
  1442. </div>\
  1443. <div class="pop-box row w100p">\
  1444. <label class="col-sm-2 control-label"><span data-i18n="">私人行動電話</span></label>\
  1445. <div class="col-sm-3">\
  1446. <input type="text" class="form-control w100p" name="PersonalMobilePhone" id="PersonalMobilePhone" placeholderid="" placeholder="">\
  1447. </div>\
  1448. <label class="col-sm-2 control-label"><span data-i18n="">私人郵箱</span></label>\
  1449. <div class="col-sm-3">\
  1450. <input type="text" class="form-control w100p" name="PersonalEmail" id="PersonalEmail" placeholderid="" placeholder="">\
  1451. </div>\
  1452. </div>\
  1453. <div class="pop-box row w100p">\
  1454. <label class="col-sm-2 control-label"><span data-i18n="">LINE</span></label>\
  1455. <div class="col-sm-3">\
  1456. <input type="text" class="form-control w100p" name="LINE" id="LINE" placeholderid="" placeholder="">\
  1457. </div>\
  1458. <label class="col-sm-2 control-label"><span data-i18n="">WECHAT</span></label>\
  1459. <div class="col-sm-3">\
  1460. <input type="text" class="form-control w100p" name="WECHAT" id="WECHAT" placeholderid="" placeholder="">\
  1461. </div>\
  1462. </div>\
  1463. <div class="pop-box row w100p">\
  1464. <label class="col-sm-2 control-label"><span data-i18n="">個性</span></label>\
  1465. <div class="col-sm-8">\
  1466. <input type="text" class="form-control w100p" name="Personality" id="Personality" placeholderid="" placeholder="">\
  1467. </div>\
  1468. </div>\
  1469. <div class="pop-box row w100p">\
  1470. <label class="col-sm-2 control-label"><span data-i18n="">喜好</span></label>\
  1471. <div class="col-sm-8">\
  1472. <input type="text" class="form-control w100p" name="Preferences" id="Preferences" placeholderid="" placeholder="">\
  1473. </div>\
  1474. </div>\
  1475. <div class="pop-box row w100p">\
  1476. <label class="col-sm-2 control-label"><span data-i18n="">私人地址</span></label>\
  1477. <div class="col-sm-8">\
  1478. <input type="text" class="form-control w100p" name="PersonalAddress" id="PersonalAddress" placeholderid="" placeholder="">\
  1479. </div>\
  1480. </div>\
  1481. <div class="pop-box row w100p">\
  1482. <label class="col-sm-2 control-label"><span data-i18n="common.Memo">備註</span></label>\
  1483. <div class="col-sm-8">\
  1484. <textarea name="Memo" id="Memo" class="form-control" rows="6" cols="20"></textarea>\
  1485. </div>\
  1486. </div>\
  1487. <div class="pop-box row w100p">\
  1488. <label class="col-sm-2 control-label"><span data-i18n="">直屬上司</span></label>\
  1489. <div class="col-sm-3 text-left">\
  1490. <select class="form-control w100p" data-type="select2" id="ImmediateSupervisor" name="ImmediateSupervisor" data-msg="" datamsg="請選擇直屬上司"></select>\
  1491. </div>\
  1492. </div>\
  1493. <div class="pop-box row w100p">\
  1494. <label class="col-sm-2 control-label"><span data-i18n="">職稱</span></label>\
  1495. <div class="col-sm-3">\
  1496. <input type="text" class="form-control w100p" name="JobTitle" id="JobTitle" placeholderid="" placeholder="">\
  1497. </div>\
  1498. <label class="col-sm-2 control-label"><span data-i18n="">部門</span></label>\
  1499. <div class="col-sm-3">\
  1500. <input type="text" class="form-control w100p" name="Department" id="Department" placeholderid="" placeholder="">\
  1501. </div>\
  1502. </div>\
  1503. <div class="pop-box row w100p">\
  1504. <label class="col-sm-2 control-label"><span data-i18n="">電子郵件1</span></label>\
  1505. <div class="col-sm-8">\
  1506. <input type="text" class="form-control w100p" name="Email1" id="Email1" placeholderid="" placeholder="">\
  1507. </div>\
  1508. </div>\
  1509. <div class="pop-box row w100p">\
  1510. <label class="col-sm-2 control-label"><span data-i18n="">電子郵件2</span></label>\
  1511. <div class="col-sm-8">\
  1512. <input type="text" class="form-control w100p" name="Email2" id="Email2" placeholderid="" placeholder="">\
  1513. </div>\
  1514. </div>\
  1515. <div class="pop-box row w100p">\
  1516. <label class="col-sm-2 control-label"><span data-i18n="">電話1</span></label>\
  1517. <div class="col-sm-3">\
  1518. <input type="text" class="form-control w100p" name="Telephone1" id="Telephone1" placeholderid="" placeholder="">\
  1519. </div>\
  1520. <label class="col-sm-2 control-label"><span data-i18n="">分機1</span></label>\
  1521. <div class="col-sm-1">\
  1522. <input type="text" class="form-control w100p" name="Ext1" id="Ext1" placeholderid="" placeholder="">\
  1523. </div>\
  1524. </div>\
  1525. <div class="pop-box row w100p">\
  1526. <label class="col-sm-2 control-label"><span data-i18n="">電話2</span></label>\
  1527. <div class="col-sm-3">\
  1528. <input type="text" class="form-control w100p" name="Telephone2" id="Telephone2" placeholderid="" placeholder="">\
  1529. </div>\
  1530. <label class="col-sm-2 control-label"><span data-i18n="">分機2</span></label>\
  1531. <div class="col-sm-1">\
  1532. <input type="text" class="form-control w100p" name="Ext2" id="Ext2" placeholderid="" placeholder="">\
  1533. </div>\
  1534. </div>\
  1535. <div class="pop-box row w100p">\
  1536. <label class="col-sm-2 control-label"><span data-i18n="">選擇我們的原因</span></label>\
  1537. <div class="col-sm-8">\
  1538. <input type="text" class="form-control w100p" name="ChoseReason" id="ChoseReason" placeholderid="" placeholder="">\
  1539. </div>\
  1540. </div><div class="pop-box row w100p"></div>\
  1541. </form>',
  1542. success: function (layero, index) {
  1543. $("#Birthday").datepicker({
  1544. changeYear: true,
  1545. changeMonth: true,
  1546. altFormat: 'yyyy/MM/dd'
  1547. });
  1548. if(sChooseCustomerId != ""){
  1549. g_api.ConnectLite("Contactors_Upd", "GetImmediateSupervisor", {
  1550. Guid: '',
  1551. CustomerId: sChooseCustomerId
  1552. }, function (res) {
  1553. if (res.RESULT) {
  1554. let saState = res.DATA.rel;
  1555. if (saState.length > 0) {
  1556. $('#ImmediateSupervisor').html(createOptions(saState, 'id', 'text', false)).select2();
  1557. }
  1558. }
  1559. });
  1560. } else {
  1561. $('#ImmediateSupervisor').html(createOptions([], 'id', 'text', false)).select2();
  1562. }
  1563. },
  1564. yes: function (index, layero) {
  1565. let data = getFormSerialize($("#form_CreateContactor"))
  1566. let bCheck = true;
  1567. if(sChooseCustomerId != ""){
  1568. data.CustomerId = sChooseCustomerId;
  1569. g_api.ConnectLite('Customers_Upd', 'checkContactorName', data, function (res) {
  1570. if (!res.RESULT) {
  1571. showMsg(res.MSG, 'error');
  1572. //return false;
  1573. } else {
  1574. $.each(saAddContactorList, function (idx, Adddata) {
  1575. if (Adddata.ContactorName == data.ContactorName) {
  1576. showMsg('已有重複姓名之聯絡人,請重新輸入', 'error');
  1577. bCheck = false;
  1578. }
  1579. });
  1580. if(bCheck){
  1581. data.RowIndex = saContactorList.length + 1;
  1582. saAddContactorList.push(data);
  1583. saContactorList.push(data);
  1584. oGrid2.loadData();
  1585. layer.close(index);
  1586. }
  1587. }
  1588. }, function () {
  1589. showMsg('檢查失敗', 'error');
  1590. //return false;
  1591. });
  1592. } else {
  1593. $.each(saAddContactorList, function (idx, Adddata) {
  1594. if (Adddata.ContactorName == data.ContactorName) {
  1595. showMsg('已有重複姓名之聯絡人,請重新輸入', 'error');
  1596. bCheck = false;
  1597. }
  1598. });
  1599. if(bCheck){
  1600. data.RowIndex = saContactorList.length + 1;
  1601. saAddContactorList.push(data);
  1602. saContactorList.push(data);
  1603. oGrid2.loadData();
  1604. layer.close(index);
  1605. }
  1606. }
  1607. }
  1608. });
  1609. },
  1610. /**
  1611. * 目的 檔案匯入
  1612. * @param
  1613. */
  1614. fnAddListFile = function () {
  1615. layer.open({
  1616. type: 1, //0(信息框,默认)1(页面层)2(iframe层)3(加载层)4(tips层)
  1617. title: "檔案匯入", // ╠common.CorrespondImpCus⇒對應正式客戶╣
  1618. area: ['800px', '300px'],//寬度
  1619. shade: 0.75,//遮罩
  1620. closeBtn: 1,
  1621. //maxmin: true, //开启最大化最小化按钮
  1622. id: 'layer_AddListFile', //设定一个id,防止重复弹出
  1623. offset: '20px',//右下角弹出
  1624. anim: 0,//彈出動畫
  1625. btn: [i18next.t('common.Confirm'), i18next.t('common.Cancel')],//╠common.Confirm⇒確定╣╠common.Cancel⇒取消╣
  1626. btnAlign: 'c',//按鈕位置
  1627. content: '<style>.select2-container{z-index: 39891015;}</style>\
  1628. <div class="pop-box w100p row">\
  1629. <label class="col-sm-2 col-sm-offset-2 control-label" for="input-Default">\
  1630. <span data-i18n="">名單來源</span><span></span>\
  1631. </label>\
  1632. <div class="col-sm-4 text-left">\
  1633. <select class="form-control w100p" data-type="select" id="ListSourceA" name="ListSourceA"></select>\
  1634. </div>\
  1635. <div class="col-sm-2">\
  1636. <button type="button" data-i18n="" id="btnDownloadTemplate" class="btn-custom w100p orange">名單表格下載</button>\
  1637. </div>\
  1638. </div>\
  1639. <div class="pop-box w100p">\
  1640. <label class="control-label" for="input-Default">\
  1641. <span data-i18n="">已選擇檔案名稱</span><span></span>\
  1642. <span style="color:blue" id="spnFileName"></span>\
  1643. </label>\
  1644. </div>\
  1645. <div class="pop-box w100p">\
  1646. <div class="">\
  1647. <button type="button" data-i18n="" id="btnChooseFileA" class="btn-custom w15p orange">選擇檔案</button>\
  1648. </div>\
  1649. </div>',
  1650. success: function (layero, index) {
  1651. $('#ListSourceA').html(sListSourceHtml.replace('<option value="ImportFromDB" title="資料庫匯入">資料庫匯入</option>','')).select2();
  1652. /* g_api.ConnectLite('Customers_Upd', 'GetListSource', {}, function (res) {
  1653. if (res.RESULT) {
  1654. var saList = res.DATA.rel;
  1655. var sOptions = createOptions(saList, 'guid', 'CustomerShotCName');
  1656. $('#ListSourceA').html(sOptions).select2();
  1657. }
  1658. }); */
  1659. $('#btnChooseFileA').click(function () {
  1660. fnImportExhibitionList();
  1661. return false;
  1662. });
  1663. $('#btnDownloadTemplate').click(function () {
  1664. fnDownloadTemplate();
  1665. return false;
  1666. });
  1667. },
  1668. yes: function (index, layero) {
  1669. if($("#ListSourceA").val() == ""){
  1670. showMsg('請選擇名單來源');
  1671. return false;
  1672. } else {
  1673. var sValue = $('#importfile').val();
  1674. if (sValue.indexOf('.xls') > -1 || sValue.indexOf('.xlsx') > -1) {
  1675. var sFileId = guid(),
  1676. sFileName = sValue;
  1677. $.ajaxFileUpload({
  1678. url: '/Controller.ashx?action=importfile&FileId=' + sFileId,
  1679. secureuri: false,
  1680. fileElementId: 'importfile',
  1681. success: function (data, status) {
  1682. g_api.ConnectLite(sProgramId, 'ImportExhibitionList', {
  1683. FileId: sFileId,
  1684. FileName: sFileName,
  1685. SN: sDataId
  1686. }, function (res) {
  1687. if (res.RESULT) {
  1688. //oGrid1.loadData();
  1689. fnAddListFileConfirm($("#ListSourceA").val());
  1690. }
  1691. else {
  1692. showMsg(i18next.t('message.ProgressError') + '<br>' + res.MSG, 'error'); // ╠message.ProgressError⇒資料處理異常╣
  1693. }
  1694. }, function () {
  1695. showMsg(i18next.t("message.ProgressError"), 'error'); // ╠message.ProgressError⇒資料處理異常╣
  1696. });
  1697. },
  1698. error: function (data, status, e) {
  1699. showMsg(i18next.t("message.ProgressError"), 'error'); // ╠message.ProgressError⇒資料處理異常╣
  1700. }
  1701. });
  1702. bRequestStorage = true;
  1703. }
  1704. else {
  1705. showMsg(i18next.t("message.FileTypeError"), 'error'); // ╠message.FileTypeError⇒文件格式錯誤╣
  1706. }
  1707. }
  1708. //fnAddListDBConfirm();
  1709. }
  1710. });
  1711. },
  1712. /**
  1713. * 匯入展覽名單
  1714. */
  1715. fnImportExhibitionList = function () {
  1716. $('#importfile').val('').off('change').on('change', function () {
  1717. $("#spnFileName").text(this.value.split('/').pop().split('\\').pop());
  1718. }).click();
  1719. },
  1720. /**
  1721. * 目的 檔案匯入的資料比對與選擇新增方式
  1722. * @param
  1723. */
  1724. fnAddListFileConfirm = function (_ListSource) {
  1725. layer.open({
  1726. type: 1, //0(信息框,默认)1(页面层)2(iframe层)3(加载层)4(tips层)
  1727. title: "新增名單", // ╠common.CorrespondImpCus⇒對應正式客戶╣
  1728. area: ['70%', '90%'],//寬度
  1729. shade: 0.50,//遮罩
  1730. closeBtn: 1,
  1731. //maxmin: true, //开启最大化最小化按钮
  1732. id: 'layer_AddListConfirm', //设定一个id,防止重复弹出
  1733. offset: '10px',//右下角弹出
  1734. anim: 0,//彈出動畫
  1735. //btn: [i18next.t('common.Confirm'), i18next.t('common.Cancel')],//╠common.Confirm⇒確定╣╠common.Cancel⇒取消╣
  1736. btnAlign: 'c',//按鈕位置
  1737. content: '<style>.glyphicon{color:orange!important;}</style><div class="pop-box w100p">\
  1738. <div class="col-sm-2 col-sm-offset-3 text-right">\
  1739. <i class="glyphicon glyphicon-exclamation-sign " title="加入不重複的公司及不重複的連絡人"></i>\
  1740. </div>\
  1741. <div class="col-sm-2 text-right">\
  1742. <i class="glyphicon glyphicon-exclamation-sign " title="更新重複公司的公司及連絡人資訊"></i>\
  1743. </div>\
  1744. <div class="col-sm-2 text-right">\
  1745. <i class="glyphicon glyphicon-exclamation-sign " title="加入不重複的公司並更新重複公司的公司及連絡人資訊"></i>\
  1746. </div>\
  1747. <div class="pop-box w100p">\
  1748. <div class="col-sm-2 col-sm-offset-3">\
  1749. <button type="button" data-i18n="" id="btnAddListFileInsert" class="btn-custom w100p orange" title="加入不重複的公司及不重複的連絡人">新增名單</button>\
  1750. </div>\
  1751. <div class="col-sm-2">\
  1752. <button type="button" data-i18n="" id="btnAddListFileUpdate" class="btn-custom w100p orange" title="更新重複公司的公司及連絡人資訊">更新現有名單</button>\
  1753. </div>\
  1754. <div class="col-sm-2">\
  1755. <button type="button" data-i18n="" id="btnAddListFileInsertUpdate" class="btn-custom w100p orange" title="加入不重複的公司並更新重複公司的公司及連絡人資訊">新增並更新現有名單</button>\
  1756. </div>\
  1757. </div>\
  1758. <div class="pop-box col-sm-12">\
  1759. <div id="jsGridDataCompare"></div>\
  1760. </div>',
  1761. success: function (layero, index) {
  1762. if(intListCount == 0){
  1763. $("#btnAddListFileUpdate").prop("disabled", true);
  1764. $("#btnAddListFileInsertUpdate").prop("disabled", true);
  1765. }else{
  1766. $("#btnAddListFileUpdate").prop("disabled", false);
  1767. $("#btnAddListFileInsertUpdate").prop("disabled", false);
  1768. }
  1769. $("#jsGridDataCompare").jsGrid({
  1770. width: "100%",
  1771. height: "auto",
  1772. autoload: true,
  1773. filtering: false,
  1774. pageLoading: true,
  1775. inserting: false,
  1776. editing: false,
  1777. sorting: false,
  1778. paging: false,
  1779. pageIndex: 1,
  1780. //pageSize: parent.SysSet.GridRecords || 10,
  1781. confirmDeleting: true,
  1782. deleteConfirm: i18next.t('message.ConfirmToDelete'),// ╠message.ConfirmToDelete⇒確定要刪除嗎 ?╣
  1783. pagePrevText: "<",
  1784. pageNextText: ">",
  1785. pageFirstText: "<<",
  1786. pageLastText: ">>",
  1787. rowClick: function (args) {
  1788. /* if (navigator.userAgent.match(/mobile/i)) {
  1789. goToEdit('Customers_Upd', '?Action=Upd&guid=' + args.item.guid);
  1790. } */
  1791. },
  1792. rowDoubleClick: function (args) {
  1793. /* parent.openPageTab('Customers_Upd', '?Action=Upd&guid=' + args.item.guid); */
  1794. },
  1795. fields: [
  1796. {
  1797. name: "RowIndex", title: 'common.RowNumber', type: "text", width: 30, align: "center", sorting: false
  1798. },
  1799. {
  1800. name: "CustomerCName", title: 'Customers_Upd.CustomerCName', width: 200
  1801. },
  1802. {
  1803. name: "CustomerEName", title: 'Customers_Upd.CustomerEName', width: 200
  1804. },
  1805. {
  1806. name: "Telephone", title: 'common.Telephone', width: 150
  1807. },
  1808. {
  1809. name: "FAX", title: 'common.FAX', width: 150
  1810. },
  1811. {
  1812. name: "Address", title: 'common.Address', width: 200
  1813. }
  1814. ],
  1815. controller: {
  1816. loadData: function (args) {
  1817. return fnGetGridData4(sDataId);
  1818. },
  1819. insertItem: function (args) {
  1820. },
  1821. updateItem: function (args) {
  1822. },
  1823. deleteItem: function (args) {
  1824. }
  1825. }
  1826. });
  1827. $('#btnAddListFileInsert').click(function () {
  1828. fnGoAddListFileConfirm(index,"insert",_ListSource);
  1829. return false;
  1830. });
  1831. $('#btnAddListFileUpdate').click(function () {
  1832. fnGoAddListFileConfirm(index,"update",_ListSource);
  1833. return false;
  1834. });
  1835. $('#btnAddListFileInsertUpdate').click(function () {
  1836. fnGoAddListFileConfirm(index,"insertupdate",_ListSource);
  1837. return false;
  1838. });
  1839. }
  1840. });
  1841. },
  1842. /**
  1843. * 目的 寫入新增名單-檔案匯入
  1844. * @param
  1845. */
  1846. fnGoAddListFileConfirm = function (_index, _type, _ListSource) {
  1847. g_api.ConnectLite('Exhibition_Upd', 'AddUpdateListFile', {Type:_type,SN:sDataId,ListSource:_ListSource}
  1848. , function (res) {
  1849. if (res.DATA.rel) {
  1850. sSN = '';
  1851. oGrid.loadData();
  1852. showMsg("匯入成功", 'success');
  1853. layer.close(_index);
  1854. layer.close(_index-1);
  1855. }
  1856. else {
  1857. showMsg("匯入失敗" + '<br>' + res.MSG , 'error');
  1858. }
  1859. }
  1860. , function () {
  1861. showMsg("匯入失敗", 'error');
  1862. });
  1863. },
  1864. /**
  1865. * 目的 名單表格下載
  1866. * @param
  1867. */
  1868. fnDownloadTemplate = function () {
  1869. return g_api.ConnectLite(sProgramId, 'DownloadTemplate', '', function (res) {
  1870. if (res.RESULT) {
  1871. var oRes = res.DATA.rel;
  1872. DownLoadFile(oRes.FilePath, oRes.FileName);
  1873. }
  1874. });
  1875. },
  1876. /**
  1877. * 目的 資料庫匯入
  1878. * @param
  1879. */
  1880. fnAddListDB = function () {
  1881. layer.open({
  1882. type: 1, //0(信息框,默认)1(页面层)2(iframe层)3(加载层)4(tips层)
  1883. title: "資料庫匯入", // ╠common.CorrespondImpCus⇒對應正式客戶╣
  1884. area: ['70%', '90%'],//寬度
  1885. shade: 0.75,//遮罩
  1886. closeBtn: 1,
  1887. //maxmin: true, //开启最大化最小化按钮
  1888. id: 'layer_AddListDB', //设定一个id,防止重复弹出
  1889. offset: '10px',//右下角弹出
  1890. anim: 0,//彈出動畫
  1891. btn: [i18next.t('common.Confirm'), i18next.t('common.Cancel')],//╠common.Confirm⇒確定╣╠common.Cancel⇒取消╣
  1892. btnAlign: 'c',//按鈕位置
  1893. content: '<style>.select2-container{z-index: 39891015;}</style>\
  1894. <div class="pop-box row w100p">\
  1895. <div class="col-sm-1 col-sm-offset-5">\
  1896. <button type="button" data-i18n="" id="btnAddListDBQuery" class="btn-custom w100p orange">查詢</button>\
  1897. </div>\
  1898. <div class="col-sm-1">\
  1899. <button type="button" data-i18n="" id="btnAddListDBClear" class="btn-custom w100p orange">清除</button>\
  1900. </div>\
  1901. </div>\
  1902. <div class="pop-box row w100p form-AddListDB">\
  1903. <label class="col-sm-1 control-label" for="input-Default">\
  1904. <span data-i18n="Exhibition_Upd.ExhibitionCode">專案代號</span><span></span>\
  1905. </label>\
  1906. <div class="col-sm-2">\
  1907. <input type="text" maxlength="50" id="ExhibitionCodeA" name="ExhibitionCodeA" class="form-control w100p" placeholderid="Exhibition_Qry.Instruction_ExhibitionCode">\
  1908. </div>\
  1909. <label class="col-sm-1 control-label" for="input-Default">\
  1910. <span data-i18n="Exhibition_Upd.Exhibitioname_TW">展覽名稱</span><span></span>\
  1911. </label>\
  1912. <div class="col-sm-2">\
  1913. <input type="text" maxlength="50" id="ExhibitionameA" name="ExhibitionameA" class="form-control w100p" placeholderid="Exhibition_Qry.Instruction_Exhibitioname_TW">\
  1914. </div>\
  1915. <label class="col-sm-1 control-label" for="input-Default">\
  1916. <span data-i18n="Exhibition_Upd.Industry">產業別</span><span></span>\
  1917. </label>\
  1918. <div class="col-sm-2">\
  1919. <select class="form-control w100p" data-type="select2" id="IndustryA" name="IndustryA"></select>\
  1920. </div>\
  1921. <label class="col-sm-1 control-label" for="input-Default">\
  1922. <span data-i18n="Exhibition_Upd.State">國家</span><span></span>\
  1923. </label>\
  1924. <div class="col-sm-2">\
  1925. <select class="form-control w100p" data-type="select2" id="StateA" name="StateA"></select>\
  1926. </div>\
  1927. </div>\
  1928. <div class="pop-box col-sm-12">\
  1929. <div id="jsGridChooseExhibition"></div>\
  1930. </div>',
  1931. success: function (layero, index) {
  1932. sSN = '';
  1933. if (saState.length > 0) {
  1934. $('#StateA').html(createOptions(saState, 'id', 'text', true));
  1935. }
  1936. if(sIndustryHtml.length > 0){
  1937. $("#IndustryA").html(sIndustryHtml);
  1938. }
  1939. $("#jsGridChooseExhibition").jsGrid({
  1940. width: "100%",
  1941. height: "auto",
  1942. autoload: true,
  1943. filtering: false,
  1944. pageLoading: true,
  1945. inserting: false,
  1946. editing: false,
  1947. sorting: true,
  1948. paging: true,
  1949. pageIndex: 1,
  1950. pageSize: 10,
  1951. pageButtonCount: parent.SysSet.GridPages || 15,
  1952. pagePrevText: "<",
  1953. pageNextText: ">",
  1954. pageFirstText: "<<",
  1955. pageLastText: ">>",
  1956. rowClick: function (args) {
  1957. /* if (navigator.userAgent.match(/mobile/i)) {
  1958. goToEdit('Customers_Upd', '?Action=Upd&guid=' + args.item.guid);
  1959. } */
  1960. },
  1961. rowDoubleClick: function (args) {
  1962. /* parent.openPageTab('Customers_Upd', '?Action=Upd&guid=' + args.item.guid); */
  1963. },
  1964. fields: [
  1965. {
  1966. name: "RowIndex", title: 'common.RowNumber', width: 20, align: "center",
  1967. itemTemplate: function (value, item) {
  1968. return $("<input>", {
  1969. type: 'checkbox', click: function (e) {
  1970. e.stopPropagation();
  1971. if (this.checked) {
  1972. $("#jsGridChooseExhibition").find('[type=checkbox]').each(function () {
  1973. this.checked = false;
  1974. });
  1975. this.checked = true;
  1976. sSN = item.SN;
  1977. //saExhibitionList = [];
  1978. //saExhibitionList.push(item);
  1979. }
  1980. }
  1981. });
  1982. }
  1983. },
  1984. {
  1985. name: "ExhibitionCode", title: 'Exhibition_Upd.ExhibitionCode', type: "text", width: 60
  1986. },
  1987. {
  1988. name: "ExhibitioShotName_TW", title: 'Exhibition_Upd.ExhibitioShotName_TW', type: "text", width: 120
  1989. },
  1990. {
  1991. name: "Exhibitioname_TW", title: 'Exhibition_Upd.Exhibitioname_TW', type: "text", width: 180
  1992. },
  1993. {
  1994. name: "Exhibitioname_EN", title: 'Exhibition_Upd.Exhibitioname_EN', type: "text", width: 180
  1995. },
  1996. {
  1997. name: "ExhibitionDateStart", title: 'Exhibition_Upd.ExhibitionDateRange', type: "text", align: "center", width: 150, itemTemplate: function (val, item) {
  1998. var sDateRange = newDate(item.ExhibitionDateStart, 'date', true) + '~' + newDate(item.ExhibitionDateEnd, 'date', true);
  1999. return sDateRange === '~' ? '' : sDateRange;
  2000. }
  2001. }
  2002. ],
  2003. controller: {
  2004. loadData: function (args) {
  2005. return fnQueryExhibition(args.pageIndex);
  2006. },
  2007. insertItem: function (args) {
  2008. },
  2009. updateItem: function (args) {
  2010. },
  2011. deleteItem: function (args) {
  2012. }
  2013. },
  2014. onInit: function (args) {
  2015. oGrid3 = args.grid;
  2016. }
  2017. });
  2018. $('#btnAddListDBQuery').click(function () {
  2019. fnQueryExhibition(args.pageIndex);
  2020. oGrid3.loadData();
  2021. return false;
  2022. });
  2023. $('#btnAddListDBClear').click(function () {
  2024. $("#ExhibitionCodeA").val('');
  2025. $("#ExhibitionameA").val('');
  2026. $("#StateA").val('');
  2027. $("#IndustryA").val('');
  2028. return false;
  2029. });
  2030. $('.form-AddListDB input').keypress(function (e) {
  2031. if (e.which == 13) {
  2032. fnQueryExhibition(args.pageIndex);
  2033. oGrid3.loadData();
  2034. }
  2035. });
  2036. },
  2037. yes: function (index, layero) {
  2038. fnAddListDBConfirm();
  2039. }
  2040. });
  2041. },
  2042. /**
  2043. * 目的 資料庫匯入-展覽資料
  2044. * @param
  2045. */
  2046. fnQueryExhibition = function (_pageIndex) {
  2047. return g_api.ConnectLite('Exhibition_Qry', 'QueryPage',
  2048. {
  2049. pageIndex:_pageIndex,
  2050. pageSize:10,
  2051. sortField: 'CreateDate',
  2052. sortOrder: 'desc',
  2053. Excel: false,
  2054. ExhibitionCode: $("#ExhibitionCodeA").val(),
  2055. Exhibitioname: $("#ExhibitionameA").val(),
  2056. State: $("#StateA").val(),
  2057. IsShowWebSite: 'YN',
  2058. Effective : 'Y',
  2059. IsTransfer : 'Y',
  2060. Industry: $("#IndustryA").val(),
  2061. },
  2062. function (res) {
  2063. if (res.RESULT) {
  2064. var oRes = res.DATA.rel;
  2065. }
  2066. }
  2067. );
  2068. },
  2069. /**
  2070. * 目的 資料庫匯入的資料比對與選擇新增方式
  2071. * @param
  2072. */
  2073. fnAddListDBConfirm = function () {
  2074. layer.open({
  2075. type: 1, //0(信息框,默认)1(页面层)2(iframe层)3(加载层)4(tips层)
  2076. title: "新增名單", // ╠common.CorrespondImpCus⇒對應正式客戶╣
  2077. area: ['70%', '90%'],//寬度
  2078. shade: 0.50,//遮罩
  2079. closeBtn: 1,
  2080. //maxmin: true, //开启最大化最小化按钮
  2081. id: 'layer_AddListConfirm', //设定一个id,防止重复弹出
  2082. offset: '10px',//右下角弹出
  2083. anim: 0,//彈出動畫
  2084. //btn: [i18next.t('common.Confirm'), i18next.t('common.Cancel')],//╠common.Confirm⇒確定╣╠common.Cancel⇒取消╣
  2085. btnAlign: 'c',//按鈕位置
  2086. content: '<style>.glyphicon{color:orange!important;}</style><div class="pop-box w100p">\
  2087. <div class="col-sm-2 col-sm-offset-5 text-right">\
  2088. <i class="glyphicon glyphicon-exclamation-sign " title="加入不重複的公司及不重複的連絡人"></i>\
  2089. </div>\
  2090. </div>\
  2091. <div class="pop-box w100p">\
  2092. <div class="col-sm-2 col-sm-offset-5">\
  2093. <button type="button" data-i18n="" id="btnAddListDBInsert" class="btn-custom w100p orange" title="加入不重複的公司及不重複的連絡人">新增名單</button>\
  2094. </div>\
  2095. </div>\
  2096. <div class="pop-box col-sm-12">\
  2097. <div id="jsGridDataCompare"></div>\
  2098. </div>',
  2099. success: function (layero, index) {
  2100. /* if(intListCount == 0){
  2101. $("#btnAddListDBUpdate").prop("disabled", true);
  2102. $("#btnAddListDBInsertUpdate").prop("disabled", true);
  2103. } else {
  2104. $("#btnAddListDBUpdate").prop("disabled", false);
  2105. $("#btnAddListDBInsertUpdate").prop("disabled", false);
  2106. } */
  2107. $("#jsGridDataCompare").jsGrid({
  2108. width: "100%",
  2109. height: "auto",
  2110. autoload: true,
  2111. filtering: false,
  2112. pageLoading: true,
  2113. inserting: false,
  2114. editing: false,
  2115. sorting: false,
  2116. paging: false,
  2117. pageIndex: 1,
  2118. //pageSize: parent.SysSet.GridRecords || 10,
  2119. confirmDeleting: true,
  2120. deleteConfirm: i18next.t('message.ConfirmToDelete'),// ╠message.ConfirmToDelete⇒確定要刪除嗎 ?╣
  2121. pagePrevText: "<",
  2122. pageNextText: ">",
  2123. pageFirstText: "<<",
  2124. pageLastText: ">>",
  2125. rowClick: function (args) {
  2126. /* if (navigator.userAgent.match(/mobile/i)) {
  2127. goToEdit('Customers_Upd', '?Action=Upd&guid=' + args.item.guid);
  2128. } */
  2129. },
  2130. rowDoubleClick: function (args) {
  2131. /* parent.openPageTab('Customers_Upd', '?Action=Upd&guid=' + args.item.guid); */
  2132. },
  2133. fields: [
  2134. {
  2135. name: "RowIndex", title: 'common.RowNumber', type: "text", width: 30, align: "center", sorting: false
  2136. },
  2137. {
  2138. name: "CustomerCName", title: 'Customers_Upd.CustomerCName', width: 200
  2139. },
  2140. {
  2141. name: "CustomerEName", title: 'Customers_Upd.CustomerEName', width: 200
  2142. },
  2143. {
  2144. name: "Telephone", title: 'common.Telephone', width: 150
  2145. },
  2146. {
  2147. name: "FAX", title: 'common.FAX', width: 150
  2148. },
  2149. {
  2150. name: "Address", title: 'common.Address', width: 200
  2151. }
  2152. ],
  2153. controller: {
  2154. loadData: function (args) {
  2155. return fnGetGridData3(sSN);
  2156. },
  2157. insertItem: function (args) {
  2158. },
  2159. updateItem: function (args) {
  2160. },
  2161. deleteItem: function (args) {
  2162. }
  2163. }
  2164. });
  2165. $('#btnAddListDBInsert').click(function () {
  2166. fnGoAddListDBConfirm(index,"insert",sSN);
  2167. return false;
  2168. });
  2169. /* $('#btnAddListDBUpdate').click(function () {
  2170. fnGoAddListDBConfirm(index,"update",sSN);
  2171. return false;
  2172. });
  2173. $('#btnAddListDBInsertUpdate').click(function () {
  2174. fnGoAddListDBConfirm(index,"insertupdate",sSN);
  2175. return false;
  2176. }); */
  2177. }
  2178. });
  2179. },
  2180. /**
  2181. * 目的 寫入新增名單-資料庫匯入
  2182. * @param
  2183. */
  2184. fnGoAddListDBConfirm = function (_index, _type, _sSN) {
  2185. g_api.ConnectLite('Exhibition_Upd', 'AddUpdateList', {Type:_type,SN:sDataId,ChooseSN:_sSN}
  2186. , function (res) {
  2187. if (res.DATA.rel) {
  2188. sSN = '';
  2189. oGrid.loadData();
  2190. showMsg("匯入成功", 'success');
  2191. layer.close(_index);
  2192. layer.close(_index-1);
  2193. }
  2194. else {
  2195. showMsg("匯入失敗", 'error');
  2196. }
  2197. }
  2198. , function () {
  2199. showMsg("匯入失敗", 'error');
  2200. });
  2201. },
  2202. /**
  2203. * 目的 合併客戶
  2204. * @param
  2205. */
  2206. fnCombineCustomer = function (aguid1,aguid2) {
  2207. g_api.ConnectLite('Customers_Upd', 'CheckCombineCustomer', {guid1:aguid1,guid2:aguid2}
  2208. , function (res) {
  2209. if (res.DATA.rel) {
  2210. if(res.DATA.rel == 1){
  2211. layer.open({
  2212. type: 2, //0(信息框,默认)1(页面层)2(iframe层)3(加载层)4(tips层)
  2213. title: "合併客戶",//i18next.t('common.CustomerTransferToFormal'),// ╠common.CustomerTransferToFormal⇒匯入廠商轉正╣
  2214. area: ['70%', '90%'],//寬度
  2215. shade: 0.75,//遮罩
  2216. //maxmin: true, //开启最大化最小化按钮
  2217. id: 'layer_CombineCustomer', //设定一个id,防止重复弹出
  2218. offset: '10px',//右下角弹出
  2219. anim: 0,//彈出動畫
  2220. btn: ["合併", i18next.t('common.Cancel')],//╠common.Confirm⇒確定╣╠common.Cancel⇒取消╣
  2221. btnAlign: 'c',//按鈕位置
  2222. content: '../POP/Customer_Combine.html',
  2223. success: function (layero, index) {
  2224. g_api.ConnectLite('Customers_Upd', 'Querytwo', {
  2225. guid1: aguid1,
  2226. guid2 : aguid2
  2227. }, function (res) {
  2228. if (res.RESULT) {
  2229. var oRes = res.DATA.rel;
  2230. var iframe = layero.find('iframe').contents();
  2231. if (saState.length > 0) {
  2232. iframe.find('#State1').html(createOptions(saState, 'id', 'text', true));
  2233. iframe.find('#State2').html(createOptions(saState, 'id', 'text', true));
  2234. }
  2235. iframe.find('#BlackListReason1').html(sBlackListReasonHtml).val(oRes[0].BlackListReason);
  2236. iframe.find('#BlackListReason2').html(sBlackListReasonHtml).val(oRes[1].BlackListReason);
  2237. iframe.find('#CustomerNO1').val(oRes[0].CustomerNO);
  2238. iframe.find('#UniCode1').val(oRes[0].UniCode);
  2239. iframe.find('#CustomerShotCName1').val(oRes[0].CustomerShotCName);
  2240. iframe.find('#CustomerCName1').val(oRes[0].CustomerCName);
  2241. iframe.find('#CustomerEName1').val(oRes[0].CustomerEName);
  2242. iframe.find('#Telephone1').val(oRes[0].Telephone);
  2243. iframe.find('#Email1').val(oRes[0].Email);
  2244. iframe.find('#FAX1').val(oRes[0].FAX);
  2245. iframe.find('#State1').val(oRes[0].State);
  2246. iframe.find('#Address1').val(oRes[0].Address);
  2247. iframe.find('#InvoiceAddress1').val(oRes[0].InvoiceAddress);
  2248. iframe.find('#WebsiteAddress1').val(oRes[0].WebsiteAddress);
  2249. iframe.find('#Memo1').val(oRes[0].Memo);
  2250. iframe.find('[name=IsBlackList1][value="' + oRes[0].IsBlackList + '"]').attr("checked", true);
  2251. iframe.find('[name=IsGroupUnit1][value="' + oRes[0].IsGroupUnit + '"]').attr("checked", true);
  2252. if(oRes[0].IsBlackList == "Y"){
  2253. iframe.find('#BlackListReason1').attr("disabled", false);
  2254. }
  2255. iframe.find('#CustomerNO2').val(oRes[1].CustomerNO);
  2256. iframe.find('#UniCode2').val(oRes[1].UniCode);
  2257. iframe.find('#CustomerShotCName2').val(oRes[1].CustomerShotCName);
  2258. iframe.find('#CustomerCName2').val(oRes[1].CustomerCName);
  2259. iframe.find('#CustomerEName2').val(oRes[1].CustomerEName);
  2260. iframe.find('#Telephone2').val(oRes[1].Telephone);
  2261. iframe.find('#Email2').val(oRes[1].Email);
  2262. iframe.find('#FAX2').val(oRes[1].FAX);
  2263. iframe.find('#State2').val(oRes[1].State);
  2264. iframe.find('#Address2').val(oRes[1].Address);
  2265. iframe.find('#InvoiceAddress2').val(oRes[1].InvoiceAddress);
  2266. iframe.find('#WebsiteAddress2').val(oRes[1].WebsiteAddress);
  2267. iframe.find('#Memo2').val(oRes[1].Memo);
  2268. iframe.find('[name=IsBlackList2][value="' + oRes[1].IsBlackList + '"]').attr("checked", true);
  2269. iframe.find('[name=IsGroupUnit2][value="' + oRes[1].IsGroupUnit + '"]').attr("checked", true);
  2270. if(oRes[1].IsBlackList == "Y"){
  2271. iframe.find('#BlackListReason2').attr("disabled", false);
  2272. }
  2273. }
  2274. else {
  2275. showMsg(i18next.t('message.NotFindData') + '<br>' + res.MSG, 'error'); // ╠message.NotFindData⇒查不到對應的資料╣
  2276. }
  2277. }, function () {
  2278. showMsg(i18next.t('message.NotFindData'), 'error');
  2279. });
  2280. },
  2281. yes: function (index, layero) {
  2282. layer.confirm("確定要合併?", { icon: 3, title: i18next.t('common.Tips') }, function (index) {
  2283. var iframe = layero.find('iframe').contents();
  2284. var combinedata = getFormSerialize($(iframe.find('#form_main')));
  2285. combinedata.Type = res.DATA.rel;
  2286. combinedata.guid1 = aguid1;
  2287. combinedata.guid2 = aguid2;
  2288. g_api.ConnectLite('Customers_Upd', 'CombineCustomer', combinedata
  2289. , function (res) {
  2290. if (res.DATA.rel) {
  2291. saCustomerList = [];
  2292. oGrid.loadData();
  2293. showMsg("合併成功", 'success');
  2294. layer.close(index);
  2295. }
  2296. else {
  2297. showMsg("合併失敗", 'error');
  2298. }
  2299. }
  2300. , function () {
  2301. showMsg("合併失敗", 'error');
  2302. });
  2303. layer.close(index-1);
  2304. });
  2305. },
  2306. end: function () {
  2307. if (bRefresh) {
  2308. bRefresh = false;
  2309. oGrid.loadData();
  2310. }
  2311. }
  2312. });
  2313. } else if(res.DATA.rel == 2){
  2314. layer.confirm("正式客戶合併非正式客戶,確定要合併?", { icon: 3, title: i18next.t('common.Tips') }, function (index) {
  2315. var combinedata = {};
  2316. combinedata.Type = res.DATA.rel;
  2317. combinedata.guid1 = aguid1;
  2318. combinedata.guid2 = aguid2;
  2319. g_api.ConnectLite('Customers_Upd', 'CombineCustomer', combinedata
  2320. , function (res) {
  2321. if (res.DATA.rel) {
  2322. saCustomerList = [];
  2323. oGrid.loadData();
  2324. showMsg("合併成功", 'success');
  2325. layer.close(index);
  2326. }
  2327. else {
  2328. showMsg("合併失敗", 'error');
  2329. }
  2330. }
  2331. , function () {
  2332. showMsg("合併失敗", 'error');
  2333. });
  2334. layer.close(index);
  2335. });
  2336. } else if(res.DATA.rel == 3){
  2337. showMsg("所選客戶皆為正式客戶,無法合併", 'error');
  2338. } else if(res.DATA.rel == 4){
  2339. showMsg("所選客戶中有重新提交審核中之客戶,無法合併", 'error');
  2340. } else if(res.DATA.rel == 5){
  2341. showMsg("所選客戶中有提交審核中之客戶,無法合併", 'error');
  2342. } else if(res.DATA.rel == 6){
  2343. showMsg("所選客戶中有申請修改中之客戶,無法合併", 'error');
  2344. } else if(res.DATA.rel == 7){
  2345. showMsg("所選客戶中有狀態無法確認之客戶,無法合併", 'error');
  2346. }
  2347. }
  2348. else {
  2349. showMsg("無法確認客戶資料,無法合併", 'error');
  2350. }
  2351. }
  2352. , function () {
  2353. showMsg("無法確認客戶資料,無法合併", 'error');
  2354. });
  2355. },
  2356. /**
  2357. * 目的 從名單移除
  2358. * @param
  2359. */
  2360. fnRemoveFromList = function (guids) {
  2361. layer.confirm("確定要從名單移除?", { icon: 3, title: i18next.t('common.Tips') }, function (index) {
  2362. g_api.ConnectLite(sProgramId, 'RemoveFromList', {
  2363. SN: sDataId,
  2364. Guid: guids
  2365. }, function (res) {
  2366. if (res.DATA.rel) {
  2367. showMsg("移除成功", 'success');
  2368. }
  2369. else {
  2370. showMsg("移除失敗", 'error');
  2371. }
  2372. saCustomerList = [];
  2373. oGrid.loadData();
  2374. }, function () {
  2375. showMsg("移除失敗", 'error');
  2376. });
  2377. layer.close(index);
  2378. });
  2379. },
  2380. /**
  2381. * 目的 匯入帳單系統
  2382. * @param
  2383. */
  2384. fnImportExhibitors = function (_strCustomerGuid) {
  2385. layer.open({
  2386. type: 1, //0(信息框,默认)1(页面层)2(iframe层)3(加载层)4(tips层)
  2387. title: "匯入帳單系統", // ╠common.CorrespondImpCus⇒對應正式客戶╣
  2388. area: ['400px', '350px'],//寬度
  2389. shade: 0.75,//遮罩
  2390. closeBtn: 1,
  2391. //maxmin: true, //开启最大化最小化按钮
  2392. id: 'layer_ImportExhibitors', //设定一个id,防止重复弹出
  2393. //offset: '50px',//右下角弹出
  2394. anim: 0,//彈出動畫
  2395. //btn: [i18next.t('common.Confirm'), i18next.t('common.Cancel')],//╠common.Confirm⇒確定╣╠common.Cancel⇒取消╣
  2396. btnAlign: 'c',//按鈕位置
  2397. content: '<style>.select2-container{z-index: 39891015;}</style>\
  2398. <div class="pop-box">\
  2399. <input id="radio_0" type="radio" name="rdbChoose01" value="1" checked="checked" />\
  2400. <label for="radio_0" >出口作業</label>\
  2401. <input id="radio_1" type="radio" name="rdbChoose01" value="2" />\
  2402. <label for="radio_1" >展覽服務部</label></div>\
  2403. <div class="pop-box" id="div1">\
  2404. <button type="button" data-i18n="" id="btnAddNewCase" class="btn-custom w50p orange">建立新案件-出口</button></p>\
  2405. <hr>\
  2406. <div><select class= "form-control" id="ExhibitionExportGuid" name="ExhibitionExportGuid"></select></div></p>\
  2407. <button type="button" data-i18n="" id="btnImportCase" class="btn-custom w50p orange">加入原有案件-出口</button>\
  2408. </div>\
  2409. <div class="pop-box" id="div2">\
  2410. <button type="button" data-i18n="" id="btnAddNewCaseTG" class="btn-custom w50p orange">建立新案件-展覽服務部</button></p>\
  2411. <hr>\
  2412. <div><select class= "form-control" id="ExhibitionExportGuidTG" name="ExhibitionExportGuidTG" style="width:100%"></select></div></p>\
  2413. <button type="button" data-i18n="" id="btnImportCase" class="btn-custom w50p orange">加入原有案件-展覽服務部</button>\
  2414. </div>',
  2415. success: function (layero, index) {
  2416. $("#div2").hide();
  2417. g_api.ConnectLite(Service.sys, 'GetExhibitionExportlist', {Type: 'TE'}, function (res) {
  2418. if (res.RESULT) {
  2419. var saList2 = res.DATA.rel;
  2420. var sOptions2 = createOptions(saList2, 'id', 'text');
  2421. $('#ExhibitionExportGuid').html(sOptions2).select2();
  2422. }
  2423. });
  2424. g_api.ConnectLite(Service.sys, 'GetExhibitionExportlist', {Type: 'TG'}, function (res) {
  2425. if (res.RESULT) {
  2426. var saList2 = res.DATA.rel;
  2427. var sOptions2 = createOptions(saList2, 'id', 'text');
  2428. $('#ExhibitionExportGuidTG').html(sOptions2).select2();
  2429. }
  2430. });
  2431. $('[name=rdbChoose01]').change(function () {
  2432. if($('[name=rdbChoose01]:checked').val() == "1") {
  2433. $("#div1").show();
  2434. $("#div2").hide();
  2435. } else {
  2436. $("#div2").show();
  2437. $("#div1").hide();
  2438. }
  2439. });
  2440. $('#btnAddNewCase').click(function () {
  2441. parent.openPageTab('ExhibitionExport_Upd', '?Action=Add&GoTab=2&ExhibitionNO=' + sDataId +'&NewCustomers=' + _strCustomerGuid);
  2442. layer.close(index);
  2443. });
  2444. $('#btnAddNewCaseTG').click(function () {
  2445. parent.openPageTab('OtherExhibitionTG_Upd', '?Action=Add&GoTab=2&ExhibitionNO=' + sDataId +'&NewCustomers=' + _strCustomerGuid);
  2446. layer.close(index);
  2447. });
  2448. $('#btnImportCase').click(function () {
  2449. if ($('#ExhibitionExportGuid').val() == '') {
  2450. showMsg("請選擇案件");
  2451. return false;
  2452. } else {
  2453. if(parent.OrgID == "TE"){
  2454. parent.openPageTab('ExhibitionExport_Upd', '?Action=Upd&GoTab=2&ExportBillNO=' + $('#ExhibitionExportGuid').val()+'&ExhibitionNO=' + sDataId +'&NewCustomers=' + _strCustomerGuid);
  2455. } else if(parent.OrgID == "TG") {
  2456. parent.openPageTab('OtherExhibitionTG_Upd', '?Action=Upd&GoTab=2&Guid=' + $('#ExhibitionExportGuid').val()+'&ExhibitionNO=' + sDataId +'&NewCustomers=' + _strCustomerGuid);
  2457. }
  2458. layer.close(index);
  2459. }
  2460. });
  2461. },
  2462. end: function () {
  2463. if (bRefresh) {
  2464. bRefresh = false;
  2465. oGrid.loadData();
  2466. }
  2467. }
  2468. });
  2469. },
  2470. /**
  2471. * 初始化 function
  2472. */
  2473. init = function () {
  2474. var saCusBtns = null;
  2475. $('#State,#Industry,#ExhibitionDate').prop('required', true);
  2476. $('.ShowNames').hide();
  2477. if (parent.OrgID === 'TG') {
  2478. $('#CostRulesIdTG,#State,#ExhibitionAddress,#ExhibitionDate,#file_hidden').prop('required', true);
  2479. $('#notte').show();
  2480. $('.showwebsiteTG').show();
  2481. $('.showwebsite').show();
  2482. $('.simp-box').hide();
  2483. } else if (parent.OrgID === 'TE'){
  2484. $('#CostRulesIdTE,#SeaReceiveingDate,#SeaClosingDate,#AirReceiveingDate,#AirClosingDate,#Undertaker,#Telephone,#Email,#file_hidden').prop('required', true);
  2485. $('#notte').show();
  2486. $('.showTE').show();
  2487. $('.showwebsiteTE').show();
  2488. $('.showwebsite').show();
  2489. } else {
  2490. $('#notte').hide();
  2491. $('.costrules').hide();
  2492. }
  2493. if (sAction === 'Upd') {
  2494. saCusBtns = [{
  2495. id: 'Toolbar_Transfer',
  2496. value: 'common.Toolbar_Transfer'// ╠common.Toolbar_Transfer⇒拋轉╣
  2497. }];
  2498. }
  2499. commonInit({
  2500. PrgId: sProgramId,
  2501. ButtonHandler: fnButtonHandler,
  2502. Buttons: saCusBtns,
  2503. GoTop: true//,
  2504. /* tabClick: function (el) {
  2505. switch (el.id) {
  2506. case 'litab4':
  2507. if (!$(el).data('action')) {
  2508. fnGetGridData().done(function () {
  2509. oGrid.loadData();
  2510. if (saGridData.length > 0 && (parent.UserInfo.roles.indexOf('Admin') > -1 || parent.UserInfo.roles.indexOf('Manager') > -1)) {
  2511. $('.export').show();
  2512. $('#Export_CusList').on('click', function () {
  2513. fnGetGridData('export');
  2514. });
  2515. }
  2516. });
  2517. }
  2518. break;
  2519. case 'litab3':
  2520. if (!$(el).data('action')) {
  2521. oGrid1.loadData();
  2522. }
  2523. break;
  2524. }
  2525. $(el).data('action', true);
  2526. } */
  2527. });
  2528. $.whenArray([
  2529. fnGet(),
  2530. setStateDrop(),
  2531. setExhibitionAddressDrop(),
  2532. setCostRulesDrop(),
  2533. setListSourceDrop(),
  2534. fnSetArgDrop([
  2535. {
  2536. OrgID: 'TE',
  2537. ArgClassID: 'ExhibClass',
  2538. //Select: $('#Industry'),
  2539. ShowId: true,
  2540. CallBack: function (data) {
  2541. sIndustryHtml = createOptions(data, 'id', 'text', true);
  2542. $('#Industry').html(sIndustryHtml);
  2543. $('#Industry2').html(sIndustryHtml);
  2544. //$('#Industry').html(createOptions(data, 'id', 'text'))[0].remove(0);
  2545. }
  2546. },
  2547. {
  2548. OrgID: 'TE',
  2549. ArgClassID: 'BlackListReason',
  2550. CallBack: function (data) {
  2551. sBlackListReasonHtml = createOptions(data, 'id', 'text');
  2552. //$('#BlackListReason').html(createOptions(data, 'id', 'text', true))
  2553. }
  2554. }
  2555. ]),
  2556. fnSetUserDrop([
  2557. {
  2558. Select: $('#ResponsiblePerson'),
  2559. ShowId: true,
  2560. Select2: true,
  2561. Action: sAction,
  2562. ServiceCode: parent.SysSet.EXCode,
  2563. CallBack: function (data) {
  2564. var sCode = parent.UserInfo.ServiceCode;
  2565. if (sAction === 'Add' && sCode && parent.SysSet.EXCode.indexOf(sCode) > -1) {
  2566. $('#ResponsiblePerson').val(parent.UserInfo.MemberID);
  2567. let sCName = $('#ResponsiblePerson option:selected').text().split('-')[1];
  2568. let sEName = $('#ResponsiblePerson option:selected').text().split('-')[0].split('.')[0];
  2569. sEName = sEName[0].toUpperCase() + sEName.slice(1);
  2570. $('#Undertaker').val(sCName + "(" + sEName + ")");
  2571. }
  2572. }
  2573. }
  2574. ])
  2575. ])
  2576. .done(function (res) {
  2577. if (res && res[0].RESULT === 1) {
  2578. var oRes = res[0].DATA.rel,
  2579. sDateRange = '';
  2580. oCurData = oRes;
  2581. oCurData.LogoFileId = oCurData.LogoFileId || guid();
  2582. setFormVal(oForm, oCurData);
  2583. if (oCurData.ExhibitionDateStart) {
  2584. sDateRange = newDate(oCurData.ExhibitionDateStart, 'date', true) + ' ~ ' + newDate(oCurData.ExhibitionDateEnd, 'date', true);
  2585. }
  2586. if (sTab) {
  2587. $('#litab3 a').click();
  2588. }
  2589. if (oRes.IsShowWebSite === 'N') {
  2590. if (parent.OrgID === 'TG') {
  2591. $('.showwebsiteTG').slideUp();
  2592. } else{
  2593. $('.showwebsiteTE').slideUp();
  2594. }
  2595. $('.showwebsite').slideUp();
  2596. }
  2597. if (oRes.IsShowWebSiteAppoint === 'N' && parent.OrgID != 'TG') {
  2598. $('.showwebsiteAppointTE').slideUp();
  2599. }
  2600. $('#State').val(oRes.State).trigger('change');
  2601. $('#ExhibitionDate').val(sDateRange);
  2602. $('#ExhibitionAddress_CN').text(oCurData.ExhibitionAddress_CN);
  2603. $('#ExhibitionAddress_EN').text(oCurData.ExhibitionAddress_EN);
  2604. if (oCurData.SeaReceiveingDate) {
  2605. if(oCurData.SeaReceiveingDate == '1900-01-01T00:00:00'){
  2606. $('#SeaReceiveingDate').val("");
  2607. } else {
  2608. $('#SeaReceiveingDate').val(newDate(oCurData.SeaReceiveingDate, 'date', true));
  2609. }
  2610. }
  2611. if (oCurData.SeaClosingDate) {
  2612. if(oCurData.SeaClosingDate == '1900-01-01T00:00:00'){
  2613. $('#SeaClosingDate').val("");
  2614. } else {
  2615. $('#SeaClosingDate').val(newDate(oCurData.SeaClosingDate, 'date', true));
  2616. }
  2617. }
  2618. if (oCurData.AirReceiveingDate) {
  2619. if(oCurData.AirReceiveingDate == '1900-01-01T00:00:00'){
  2620. $('#AirReceiveingDate').val("");
  2621. } else {
  2622. $('#AirReceiveingDate').val(newDate(oCurData.AirReceiveingDate, 'date', true));
  2623. }
  2624. }
  2625. if (oCurData.AirClosingDate) {
  2626. if(oCurData.AirClosingDate == '1900-01-01T00:00:00'){
  2627. $('#AirClosingDate').val("");
  2628. } else {
  2629. $('#AirClosingDate').val(newDate(oCurData.AirClosingDate, 'date', true));
  2630. }
  2631. }
  2632. setNameById().done(function () {
  2633. getPageVal();//緩存頁面值,用於清除
  2634. });
  2635. fnGetUploadFiles(oCurData.LogoFileId, fnUpload);
  2636. }
  2637. select2Init();
  2638. $('[name=IsShowWebSite]').click(function () {
  2639. if (this.value === 'N') {
  2640. if (parent.OrgID === 'TG') {
  2641. $('#ExhibitionDate,#CostRulesIdTG,#ExhibitionAddress,#file_hidden').removeAttr('required');
  2642. $('.showwebsiteTG').slideUp();
  2643. } else{
  2644. $('#SeaReceiveingDate,#SeaClosingDate,#AirReceiveingDate,#AirClosingDate,#Undertaker,#Telephone,#Email,#file_hidden').removeAttr('required');
  2645. $('.showwebsiteTE').slideUp();
  2646. }
  2647. $('.showwebsite').slideUp();
  2648. }
  2649. else {
  2650. if (parent.OrgID === 'TG') {
  2651. $('#ExhibitionDate,#CostRulesIdTG,#ExhibitionAddress,#file_hidden').attr('required', true);
  2652. $('.showwebsiteTG').slideDown();
  2653. } else{
  2654. $('#SeaReceiveingDate,#SeaClosingDate,#AirReceiveingDate,#AirClosingDate,#Undertaker,#Telephone,#Email,#file_hidden').attr('required', true);
  2655. $('.showwebsiteTE').slideDown();
  2656. }
  2657. $('.showwebsite').slideDown();
  2658. }
  2659. });
  2660. $('[name=IsShowWebSiteAppoint]').click(function () {
  2661. if (this.value === 'N') {
  2662. $('#CostRulesIdTE').removeAttr('required');
  2663. $('.showwebsiteAppointTE').slideUp();
  2664. }
  2665. else {
  2666. $('#CostRulesIdTE').attr('required', true);
  2667. $('.showwebsiteAppointTE').slideDown();
  2668. }
  2669. });
  2670. //是否顯示於網站,值為'N'收起選項與移除required
  2671. if (oCurData.IsShowWebSite === 'N') {
  2672. $('#sub_box1').slideUp();
  2673. $('[name=IsShowWebSite][value="N"]').click();
  2674. }
  2675. if (oCurData.IsShowWebSiteAppoint === 'N') {
  2676. $('[name=IsShowWebSiteAppoint][value="N"]').click();
  2677. }
  2678. });
  2679. oValidator = $("#form_main").validate({
  2680. ignore: ''
  2681. });
  2682. $('#ExhibitionDate').dateRangePicker(
  2683. {
  2684. language: 'zh-TW',
  2685. separator: ' ~ ',
  2686. format: 'YYYY/MM/DD',
  2687. autoClose: true
  2688. }).bind('datepicker-change', function (e, r) {
  2689. try {
  2690. $('#ExhibitionDateStart2').val(newDate(r.date1, 'date'));
  2691. $('#ExhibitionDateEnd2').val(newDate(r.date2, 'date'));
  2692. var dShelfTime_Home = r.date2.dateAdd('d', -15),
  2693. dShelfTime_Abroad = new Date(newDate(r.date2, 'date')).dateAdd('d', -15);
  2694. $('#ShelfTime_Home').val(newDate(dShelfTime_Home, 'date'));
  2695. $('#ShelfTime_Abroad').val(newDate(dShelfTime_Abroad, 'date'));
  2696. //alert(newDate(r.date2, 'date'));
  2697. //$('#ExhibitionDateEnd2').val(r.date2);
  2698. } catch (e) { }
  2699. });
  2700. $('#Exhibitioname_TW').on('blur', function () {
  2701. $('#Exhibitioname_CN').val(simplized(this.value));
  2702. });
  2703. $('#Exhibitioname_CN').on('blur', function () {
  2704. $('#Exhibitioname_TW').val(traditionalized(this.value));
  2705. });
  2706. $('#ExhibitioShotName_TW').on('change', function () {
  2707. $('#ExhibitioShotName_TW2').val($('#ExhibitioShotName_TW').val());
  2708. });
  2709. $('#ResponsiblePerson').on('change', function () {
  2710. $('#ResponsiblePerson2').val($('#ResponsiblePerson').val());
  2711. let sCName = this.options[this.selectedIndex].text.split('-')[1];
  2712. let sEName = this.options[this.selectedIndex].text.split('-')[0].split('.')[0];
  2713. sEName = sEName[0].toUpperCase() + sEName.slice(1);
  2714. $('#Undertaker').val(sCName + "(" + sEName + ")");
  2715. });
  2716. $('#Industry').on('change', function () {
  2717. $('#Industry2').val($('#Industry').val());
  2718. });
  2719. $('#State').on('change', function () {
  2720. $('#State2').val($('#State').val());
  2721. });
  2722. //$("#Industry2").val(oRes.Industry);
  2723. //$("#State2").val(oRes.State);
  2724. var iHeight = $('body').height() - $('.page-title').height() - $('#searchbar').height() - 150;
  2725. $("#jsGrid").jsGrid({
  2726. width: "100%",
  2727. height: "auto",
  2728. autoload: true,
  2729. filtering: false,
  2730. pageLoading: true,
  2731. inserting: false,
  2732. editing: false,
  2733. sorting: true,
  2734. paging: false,
  2735. pageIndex: 1,
  2736. pageSize: parent.SysSet.GridRecords || 10,
  2737. confirmDeleting: true,
  2738. deleteConfirm: i18next.t('message.ConfirmToDelete'),// ╠message.ConfirmToDelete⇒確定要刪除嗎 ?╣
  2739. pagePrevText: "<",
  2740. pageNextText: ">",
  2741. pageFirstText: "<<",
  2742. pageLastText: ">>",
  2743. rowClick: function (args) {
  2744. if (navigator.userAgent.match(/mobile/i)) {
  2745. goToEdit('Customers_Upd', '?Action=Upd&guid=' + args.item.guid);
  2746. }
  2747. },
  2748. rowDoubleClick: function (args) {
  2749. parent.openPageTab('Callout_Upd', '?Action=Upd&SN=' + sDataId + '&guid=' + args.item.guid);
  2750. },
  2751. fields: [
  2752. {
  2753. width: 30, sorting: false, align: "center",
  2754. headerTemplate: function () {
  2755. return [$("<input>", {
  2756. id: 'SelectAll',
  2757. type: 'checkbox', click: function () {
  2758. if (this.checked) {
  2759. $("#jsGrid").find('[type=checkbox]').each(function () {
  2760. this.checked = true;
  2761. });
  2762. saCustomerList = clone(saGridData);
  2763. }
  2764. else {
  2765. $("#jsGrid").find('[type=checkbox]').each(function () {
  2766. this.checked = false;
  2767. });
  2768. saCustomerList = [];
  2769. }
  2770. }
  2771. })];//╠common.SelectAll⇒全選╣
  2772. },
  2773. itemTemplate: function (value, item) {
  2774. return $("<input>", {
  2775. type: 'checkbox', click: function (e) {
  2776. e.stopPropagation();
  2777. if (this.checked) {
  2778. saCustomerList.push(item);
  2779. }
  2780. else {
  2781. var saNewList = [];
  2782. $.each(saCustomerList, function (idx, data) {
  2783. if (item.guid !== data.guid) {
  2784. saNewList.push(data);
  2785. }
  2786. });
  2787. saCustomerList = saNewList;
  2788. $('#jsGrid').find('#SelectAll')[0].checked = false;
  2789. }
  2790. }
  2791. });
  2792. }
  2793. },
  2794. {
  2795. name: "TransportRequire", title: '運輸需求', width: 60, align: "center", itemTemplate: function (val, item) {
  2796. if(val == "有需求"){
  2797. return $('<span />', { text: val }).css('color', 'green');
  2798. } else if(val == "無需求"){
  2799. return $('<span />', { text: val }).css('color', 'red');
  2800. } else {
  2801. return val;
  2802. }
  2803. }
  2804. },
  2805. {
  2806. name: "TransportationMode", title: '運輸方式', width: 50, align: "center"
  2807. },
  2808. {
  2809. name: "VolumeForecasting", title: '貨量', width: 50, align: "center"
  2810. },
  2811. {
  2812. name: "NumberOfBooths", title: '攤位數', width: 50, align: "center"
  2813. },
  2814. {
  2815. name: "CustomerCName", title: 'Customers_Upd.CustomerCName', width: 150,
  2816. },
  2817. {
  2818. name: "CustomerEName", title: 'Customers_Upd.CustomerEName', width: 200,
  2819. },
  2820. {
  2821. name: "ContactorName", title: 'common.Contactor', width: 100, align: "center"
  2822. },
  2823. {
  2824. name: "ListSourceName", title: '名單來源', width: 100, align: "center", itemTemplate: function (val, item) {
  2825. if(item.ListSource == "SelfCome"){
  2826. return "自來";
  2827. } else if(item.ListSource == "ImportFromDB"){
  2828. return "資料庫匯入";
  2829. } else {
  2830. return val;
  2831. }
  2832. }
  2833. },
  2834. {
  2835. name: "ModifyDate", title: 'common.ModifyDate', type: "text", align: "center", width: 100, itemTemplate: function (val, item) {
  2836. return newDate(val);
  2837. }
  2838. },
  2839. {
  2840. name: "Memo", title: 'common.Memo', width: 190, align: "left"
  2841. },
  2842. {
  2843. name: "IsDeal", title: '是否<br>成交', width: 45, align: "Center",
  2844. itemTemplate: function (val, item) {
  2845. return $('<div>', { 'style': 'width:100%;text-align: center;' }).append(val === 'Y' ? $('<span />', { text: "已成交" }).css('color', 'blue') : "未成交");
  2846. }
  2847. },
  2848. {
  2849. name: "IsImporter", title: '是否為<br>進口商', width: 45, align: "Center",
  2850. itemTemplate: function (val, item) {
  2851. return $('<div>', { 'style': 'width:100%;text-align: center;' }).append(val === 'Y' ? $('<span />', { text: "是" }).css('color', 'red') : "否");
  2852. }
  2853. },
  2854. {// ╠common.IsFormal⇒資料狀態╣
  2855. name: "IsFormal",
  2856. title: 'common.IsFormal',
  2857. width: 90,
  2858. align: 'center',
  2859. itemTemplate: function (val, item) {
  2860. var saAction = [];
  2861. if (item.IsFormal == "N") {
  2862. saAction.push($('<a/>', {
  2863. html: i18next.t('common.TransferToFormal'),// ╠common.TransferToFormal⇒轉為正式客戶╣
  2864. class: 'link',
  2865. click: function () {
  2866. fnTransferToFormal(item);
  2867. return false;
  2868. }
  2869. }));
  2870. saAction.push('<br>', $('<a/>', {
  2871. html: i18next.t('common.CorrespondFormalCus'),// ╠common.CorrespondFormalCus⇒對應到正式客戶╣
  2872. class: 'link',
  2873. style: 'color:green !important',
  2874. click: function () {
  2875. fnCorrespondFormalCus(item);
  2876. }
  2877. }));
  2878. }
  2879. else {
  2880. saAction.push($('<span />', { text: i18next.t('common.HasFormal') }).css('color', 'green'));
  2881. }
  2882. return $('<div>', { 'style': 'width:100%;text-align: center;' }).append(saAction);
  2883. }
  2884. }
  2885. ],
  2886. controller: {
  2887. loadData: function (args) {
  2888. return fnGetGridData(args);
  2889. },
  2890. insertItem: function (args) {
  2891. },
  2892. updateItem: function (args) {
  2893. },
  2894. deleteItem: function (args) {
  2895. }
  2896. },
  2897. onInit: function (args) {
  2898. oGrid = args.grid;
  2899. }
  2900. });
  2901. $("#jsGrid1").jsGrid({
  2902. width: "100%",
  2903. height: iHeight,
  2904. autoload: false,
  2905. filtering: true,
  2906. pageLoading: true,
  2907. inserting: true,
  2908. editing: true,
  2909. sorting: true,
  2910. paging: true,
  2911. pageIndex: 1,
  2912. pageSize: parent.SysSet.GridRecords || 10,
  2913. pageButtonCount: parent.SysSet.GridPages || 15,
  2914. confirmDeleting: true,
  2915. deleteConfirm: i18next.t('message.ConfirmToDelete'),// ╠message.ConfirmToDelete⇒確定要刪除嗎 ?╣
  2916. pagePrevText: "<",
  2917. pageNextText: ">",
  2918. pageFirstText: "<<",
  2919. pageLastText: ">>",
  2920. rowClick: function (args) {
  2921. //if (navigator.userAgent.match(/mobile/i)) {
  2922. // goToEdit('Customers_Upd', '?Action=Upd&guid=' + args.item.guid);
  2923. //}
  2924. },
  2925. rowDoubleClick: function (args) {
  2926. //parent.openPageTab('Customers_Upd', '?Action=Upd&guid=' + args.item.guid);
  2927. },
  2928. fields: [
  2929. {
  2930. name: "RowIndex", title: 'common.RowNumber', width: 50, align: "center"
  2931. },
  2932. {// ╠Exhibition_Upd.ExhibitionArea⇒展區╣
  2933. name: "ExhibitionArea", title: 'Exhibition_Upd.ExhibitionArea', type: 'text', width: 100
  2934. },
  2935. {
  2936. name: "MuseumMumber", title: 'ExhibitionImport_Upd.HallMuseumMumber', type: 'text', width: 80
  2937. },
  2938. {
  2939. name: "CustomerCName", title: 'Customers_Upd.CustomerCName', type: 'text', width: 140,
  2940. validate: [
  2941. {
  2942. validator: 'required',
  2943. message: i18next.t('Customers_Upd.CustomerCName_required')// ╠Customers_Upd.CustomerCName_required⇒請輸入公司中文名稱╣
  2944. },
  2945. {
  2946. validator: function (value, item) {
  2947. var bRetn = true;
  2948. CallAjax(ComFn.W_Com, ComFn.GetCount, {
  2949. Params: {
  2950. importcustomers: {
  2951. CustomerCName: value,
  2952. OrgID: parent.top.OrgID,
  2953. ExhibitionNO: sDataId,
  2954. guid: '<>' + item.guid
  2955. }
  2956. }
  2957. }, function (rq) {
  2958. if (rq.d > 0) {
  2959. bRetn = false;
  2960. }
  2961. }, null, true, false);
  2962. return bRetn;
  2963. },
  2964. message: i18next.t("message.CustomerCNameExist") // ╠message.CustomerCNameExist⇒該廠商名稱已存在╣
  2965. }]
  2966. },
  2967. {
  2968. name: "CustomerEName", title: 'Customers_Upd.CustomerEName', type: 'text', width: 140
  2969. },
  2970. {
  2971. name: "UniCode", title: 'Customers_Upd.UniCode', type: 'text', width: 100,
  2972. validate: [
  2973. {
  2974. validator: function (_val) {
  2975. return _val === '' ? true : _val.length === 8;
  2976. },
  2977. message: i18next.t('message.UniCodeLength')
  2978. }
  2979. ]
  2980. },
  2981. {
  2982. name: "Contactor", title: 'common.Contactor', type: 'text', width: 120,
  2983. validate: { validator: 'required', message: i18next.t('common.Contactor_required') }// ╠common.Contactor_required⇒請輸入聯絡人╣
  2984. },
  2985. {
  2986. name: "Telephone", title: 'common.Telephone', type: 'text', width: 100, align: "center",
  2987. validate: { validator: 'required', message: i18next.t('common.Telephone_required') }// ╠common.Telephone_required⇒請輸入聯絡電話╣
  2988. },
  2989. {
  2990. name: "Email", title: 'common.Email', type: 'text', width: 130,
  2991. validate: {
  2992. validator: function (_val) {
  2993. return _val === '' ? true : isEmail(_val);
  2994. },
  2995. message: i18next.t('message.IncorrectEmail'),// ╠message.IncorrectEmail⇒郵箱格式不正確╣
  2996. }
  2997. },
  2998. {
  2999. name: "Address", title: 'common.Address', type: 'text', width: 100
  3000. },
  3001. {
  3002. name: "Memo", title: 'common.Memo', type: 'text', width: 100
  3003. },
  3004. {// ╠common.IsAppoint⇒預約狀態╣
  3005. name: "IsAppoint", title: 'common.IsAppoint', width: 60, align: "center",
  3006. itemTemplate: function (val, item) {
  3007. return val === 'Y' ? $('<span />', { text: i18next.t('common.HasAppoint') }).css('color', 'green') : $('<span />', { text: i18next.t('common.NotAppoint') }).css('color', 'red');// ╠common.HasAppoint⇒已預約╣ ╠common.NotAppoint⇒未預約╣
  3008. }
  3009. },
  3010. {// ╠common.IsFormal⇒資料狀態╣
  3011. name: "guid",
  3012. title: 'common.IsFormal',
  3013. width: 140,
  3014. align: 'center',
  3015. itemTemplate: function (val, item) {
  3016. var saAction = [];
  3017. if (!item.IsFormal) {
  3018. saAction.push($('<a/>', {
  3019. html: i18next.t('common.TransferToFormal'),// ╠common.TransferToFormal⇒轉為正式客戶╣
  3020. class: 'link',
  3021. click: function () {
  3022. fnTransferToFormal(item);
  3023. return false;
  3024. }
  3025. }));
  3026. if (parent.UserInfo.roles.indexOf('Admin') > -1) {
  3027. saAction.push(' ', $('<a/>', {
  3028. html: i18next.t('common.CorrespondFormalCus'),// ╠common.CorrespondFormalCus⇒對應到正式客戶╣
  3029. class: 'link',
  3030. style: 'color:green !important',
  3031. click: function () {
  3032. fnCorrespondFormalCus(item);
  3033. }
  3034. }));
  3035. }
  3036. }
  3037. else {
  3038. saAction.push($('<span />', { text: i18next.t('common.HasFormal') }).css('color', 'green'));
  3039. }
  3040. return $('<div>', { 'style': 'width:100%;text-align: center;' }).append(saAction);
  3041. }
  3042. },
  3043. {
  3044. type: "control",
  3045. width: 100,
  3046. headerTemplate: function () {
  3047. var saBtn = [];
  3048. if (sAction === 'Upd') {
  3049. saBtn.push($('<button />', {
  3050. type: 'button', 'class': 'btn-custom blue', title: i18next.t('common.Toolbar_Imp'), html: '<i class="glyphicon glyphicon-import"></i>', click: function () {
  3051. fnImportCusList();
  3052. }
  3053. }));
  3054. saBtn.push($('<button />', {
  3055. type: 'button', 'class': 'btn-custom blue', title: i18next.t('common.Toolbar_Exp'), html: '<i class="glyphicon glyphicon-export"></i>', click: function () {
  3056. fnExportCusList();
  3057. }
  3058. }));
  3059. }
  3060. return saBtn;
  3061. },
  3062. deleteButton: false
  3063. }
  3064. ],
  3065. controller: {
  3066. loadData: function (args) {
  3067. return fnGetGridData1(args);
  3068. },
  3069. insertItem: function (args) {
  3070. fnAddCustomers(args);
  3071. },
  3072. updateItem: function (args) {
  3073. fnUpdCustomers(args);
  3074. },
  3075. deleteItem: function (args) {
  3076. }
  3077. },
  3078. onInit: function (args) {
  3079. oGrid1 = args.grid;
  3080. }
  3081. });
  3082. };
  3083. init();
  3084. },
  3085. /**
  3086. * 客戶轉為正式資料后動作
  3087. * @param {String}afterid 客戶id
  3088. */
  3089. fnReFresh = function (afterid) {
  3090. bRefresh = true;
  3091. $('iframe').attr('src', '../Crm/Customers_Upd.html?Action=Upd&Flag=Fit&guid=' + afterid);
  3092. };
  3093. require(['base', 'select2', 'jsgrid', 'daterangepicker', 'convetlng', 'filer', 'ajaxfile', 'util'], fnPageInit, 'daterangepicker');