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.

542 lines
27 KiB

3 years ago
  1. 'use strict';
  2. var sProgramId = getProgramId(),
  3. sEditPrgId = getEditPrgId(),
  4. oGrid = null,
  5. fnPageInit = function () {
  6. var oForm = $('#form_main'),
  7. oBaseQueryPm = {
  8. pageIndex: 1,
  9. pageSize: parent.SysSet.GridRecords || 10,
  10. sortField: 'CreateDate',
  11. sortOrder: 'desc'
  12. },
  13. /**
  14. * 獲取資料
  15. * @param {Object} args 查詢條件參數
  16. * @return {Object} Ajax 物件
  17. */
  18. fnGet = function (args) {
  19. var oQueryPm = getFormSerialize(oForm);
  20. $.extend(oQueryPm, oBaseQueryPm, args);
  21. oBaseQueryPm.pageIndex = oQueryPm.pageIndex;
  22. return g_api.ConnectLite(sProgramId, ComFn.GetPage, oQueryPm);
  23. },
  24. /**
  25. * 匯出資料
  26. * @param {Object} args 查詢參數
  27. * @return {Object} Ajax 物件
  28. */
  29. fnExcel = function (args) {
  30. var oQueryPm = getFormSerialize(oForm);
  31. $.extend(oQueryPm, oBaseQueryPm, args);
  32. oBaseQueryPm.pageIndex = oQueryPm.pageIndex;
  33. oQueryPm.Excel = true;
  34. g_api.ConnectLite(sProgramId, ComFn.GetPage, oQueryPm, function (res) {
  35. if (res.RESULT) {
  36. DownLoadFile(res.DATA.rel);
  37. }
  38. });
  39. },
  40. /**
  41. * 目的 對應匯入廠商
  42. * @param {String}item 預約單資料
  43. */
  44. fnCorrespondImpCus = function (item) {
  45. layer.open({
  46. type: 1, //0(信息框,默认)1(页面层)2(iframe层)3(加载层)4(tips层)
  47. title: i18next.t("PackingOrder_Upd.CorrespondImpCus"), // ╠PackingOrder_Upd.CorrespondImpCus⇒對應匯入廠商╣
  48. area: '640px;',//寬度
  49. shade: 0.75,//遮罩
  50. closeBtn: 1,
  51. //maxmin: true, //开启最大化最小化按钮
  52. id: 'layer_PackingInfo', //设定一个id,防止重复弹出
  53. offset: '100px',//右下角弹出
  54. anim: 0,//彈出動畫
  55. btn: [i18next.t('common.Confirm'), i18next.t('common.Cancel')],//╠common.Confirm⇒確定╣╠common.Cancel⇒取消╣
  56. btnAlign: 'c',//按鈕位置
  57. content: '<style>.select2-container{z-index: 39891015;}</style><div class="form-group">\
  58. <div class="col-sm-12">\
  59. <select class= "form-control w95p" id="CustomerId" name="CustomerId"></select>\
  60. </div>\
  61. </div >',
  62. success: function (layero, index) {
  63. g_api.ConnectLite(sEditPrgId, 'SetImpCusDrop', {
  64. Id: item.ExhibitionNO
  65. }, function (res) {
  66. if (res.RESULT) {
  67. var saList = res.DATA.rel;
  68. var sOptions = createOptions(saList, 'guid', 'CustomerCName');
  69. $('#CustomerId').html(sOptions).select2();
  70. }
  71. });
  72. transLang(layero);
  73. },
  74. yes: function (index, layero) {
  75. var sCustomerId = $('#CustomerId').val();
  76. if (!sCustomerId) {
  77. showMsg(i18next.t('message.SelectImpCus'));//╠message.SelectImpCus⇒請選擇對應的廠商╣
  78. return false;
  79. }
  80. g_api.ConnectLite(sEditPrgId, 'CorrespondImpCus', {
  81. Id: item.AppointNO,
  82. CustomerId: sCustomerId
  83. }, function (res) {
  84. if (res.DATA.rel) {
  85. oGrid.loadData();
  86. showMsg(i18next.t("message.Correspond_Success"), 'success'); //╠message.Correspond_Success⇒對應成功╣
  87. layer.close(index);
  88. }
  89. else {
  90. showMsg(i18next.t("message.Correspond_Failed"), 'error');//╠message.Correspond_Failed⇒對應失敗╣
  91. }
  92. });
  93. }
  94. });
  95. },
  96. /**
  97. * 匯入到其他入口
  98. * @param {String}item 預約單資料
  99. */
  100. fnImportOthers = function (item) {
  101. layer.open({
  102. type: 1,
  103. title: i18next.t('PackingOrder_Upd.SelectImportPrg'),// ╠PackingOrder_Upd.SelectImportPrg⇒選擇匯入入口╣
  104. area: ['300px', '160px'],//寬度
  105. shade: 0.75,//遮罩
  106. shadeClose: true,
  107. btn: [i18next.t('common.Cancel')],// ╠common.Cancel⇒取消╣
  108. content: '<div class="pop-box">\
  109. <button type="button" data-i18n="PackingOrder_Upd.OtherPrg" id="OtherPrg" class="btn-custom green">其他</button>\
  110. <button type="button" data-i18n="PackingOrder_Upd.OtherPrgTG" id="OtherPrgTG" class="btn-custom green">其他駒驛</button>\
  111. </div>',//PackingOrder_Upd.OtherPrg其他PackingOrder_Upd.OtherPrgTG其他駒驛
  112. success: function (layero, index) {
  113. $('.pop-box :button').click(function () {
  114. if (this.id === 'OtherPrg') {
  115. parent.openPageTab('OtherBusiness_Upd', '?Action=Add&AppointNO=' + item.AppointNO);
  116. }
  117. else {
  118. parent.openPageTab('OtherExhibitionTG_Upd', '?Action=Add&AppointNO=' + item.AppointNO);
  119. }
  120. layer.close(index);
  121. });
  122. transLang(layero);
  123. }
  124. });
  125. },
  126. /**
  127. * 匯入到展場服務部入口
  128. * @param {String}item 預約單資料
  129. */
  130. fnImportOthersTE = function (item) {
  131. layer.open({
  132. type: 1,
  133. title: i18next.t('PackingOrder_Upd.SelectImportPrg'),// ╠PackingOrder_Upd.SelectImportPrg⇒選擇匯入入口╣
  134. area: ['300px', '160px'],//寬度
  135. shade: 0.75,//遮罩
  136. shadeClose: true,
  137. btn: [i18next.t('common.Cancel')],// ╠common.Cancel⇒取消╣
  138. content: '<div class="pop-box">\
  139. <button type="button" data-i18n="展場服務部" id="OtherPrgTG" class="btn-custom green">展場服務部</button>\
  140. </div>',//PackingOrder_Upd.OtherPrg其他PackingOrder_Upd.OtherPrgTG其他駒驛
  141. success: function (layero, index) {
  142. $('.pop-box :button').click(function () {
  143. parent.openPageTab('OtherExhibitionTG_Upd', '?Action=Add&AppointNO=' + item.AppointNO);
  144. layer.close(index);
  145. });
  146. transLang(layero);
  147. }
  148. });
  149. },
  150. /**
  151. * ToolBar 按鈕事件 function
  152. * @param {Object}inst 按鈕物件對象
  153. * @param {Object} e 事件對象
  154. */
  155. fnButtonHandler = function (inst, e) {
  156. var sId = inst.id;
  157. switch (sId) {
  158. case "Toolbar_Qry":
  159. var iNum = $('#PerPageNum').val();
  160. oGrid.pageSize = iNum === '' ? parent.SysSet.GridRecords || 10 : iNum;
  161. cacheQueryCondition();
  162. oGrid.openPage(window.bToFirstPage ? 1 : oBaseQueryPm.pageIndex);
  163. break;
  164. case "Toolbar_Save":
  165. break;
  166. case "Toolbar_ReAdd":
  167. break;
  168. case "Toolbar_Clear":
  169. clearPageVal();
  170. break;
  171. case "Toolbar_Leave":
  172. break;
  173. case "Toolbar_Add":
  174. break;
  175. case "Toolbar_Upd":
  176. break;
  177. case "Toolbar_Copy":
  178. break;
  179. case "Toolbar_EntryOrder":
  180. parent.openPageTab(sEditPrgId, '?Action=Add');
  181. break;
  182. case "Toolbar_Del": // ╠message.ConfirmToDelete⇒確定要刪除嗎 ?╣ ╠common.Tips⇒提示╣
  183. break;
  184. case "Toolbar_Exp":
  185. if (oGrid.data.length === 0) {
  186. showMsg(i18next.t("message.NoDataExport"));// ╠message.NoDataExport⇒沒有資料匯出╣
  187. return false;
  188. }
  189. fnExcel();
  190. break;
  191. default:
  192. alert("No handle '" + sId + "'");
  193. break;
  194. }
  195. },
  196. /**
  197. * 頁面初始化
  198. */
  199. init = function () {
  200. var saCusBtns = [{
  201. id: 'Toolbar_EntryOrder',
  202. value: 'common.Toolbar_EntryOrder'// ╠common.Toolbar_EntryOrder⇒錄入預約單╣
  203. }];
  204. commonInit({
  205. PrgId: sProgramId,
  206. ButtonHandler: fnButtonHandler,
  207. Buttons: saCusBtns,
  208. SearchBar: true
  209. }).done(function () {
  210. var iHeight = $('body').height() - $('.page-title').height() - $('#searchbar').height() - 87;
  211. var saFields = [
  212. { name: "RowIndex", title: 'common.RowNumber', align: "center", type: "text", width: 40, sorting: false },
  213. {// ╠common.AppointNO⇒預約單號╣
  214. name: "AppointNO", title: 'common.AppointNO', type: "text", width: 120
  215. },
  216. {// ╠common.CompanyName⇒公司名稱╣
  217. name: "CompName", title: 'common.CompanyName', type: "text", width: 150
  218. }];
  219. if (parent.OrgID === 'TE'){
  220. saFields.push(
  221. {// ╠common.Unicode
  222. name: "Unicode", title: 'Customers_Upd.UniCode', type: "text", width: 60
  223. }
  224. );
  225. }
  226. saFields.push(
  227. {// ╠Exhibition_Upd.Exhibitioname_TW⇒展覽名稱╣
  228. name: "Exhibitioname_TW", title: 'Exhibition_Upd.Exhibitioname_TW', type: "text", width: 150,
  229. itemTemplate: function (val, item) {
  230. return $('<a />', {
  231. class: 'link',
  232. text: val, click: function () {
  233. parent.openPageTab('Exhibition_Upd', '?Action=Upd&SN=' + item.ExhibitionNO);
  234. }
  235. })
  236. }
  237. },
  238. {// ╠common.MuseumMumber⇒預約攤號╣
  239. name: "MuseumMumber", title: 'common.MuseumMumber', type: "text", width: 70
  240. },
  241. {// ╠common.AppointUser⇒預約人員╣
  242. name: "AppointUser", title: 'common.AppointUser', type: "text", width: 80
  243. },
  244. {// ╠common.AppointTel⇒預約電話╣
  245. name: "AppointTel", title: parent.OrgID === 'TE' ? '公司電話及分機' : 'common.AppointTel', type: "text", width: 80
  246. },
  247. {// ╠common.AppointEmail⇒預約Email╣
  248. name: "AppointEmail", title: 'common.AppointEmail', type: "text", width: 140
  249. },
  250. {// ╠ExhibitionImport_Upd.SitiContactor⇒現場聯絡人╣
  251. name: "Contactor", title: 'ExhibitionImport_Upd.SitiContactor', type: "text", width: 80
  252. },
  253. {// ╠ExhibitionImport_Upd.SitiTelephone⇒現場聯絡電話╣
  254. name: "ContactTel", title: 'ExhibitionImport_Upd.SitiTelephone', type: "text", width: 80
  255. },
  256. {// ╠ExhibitionImport_Upd.ApproachTime⇒進場時間╣
  257. name: "ApproachTime", title: 'ExhibitionImport_Upd.ApproachTime', type: "text", align: "center", width: 100,
  258. itemTemplate: function (val, item) {
  259. return newDate(val);
  260. }
  261. },
  262. {// ╠ExhibitionImport_Upd.ExitTime⇒退場時間╣
  263. name: "ExitTime", title: 'ExhibitionImport_Upd.ExitTime', type: "text", align: "center", width: 100,
  264. itemTemplate: function (val, item) {
  265. return newDate(val);
  266. }
  267. }
  268. );
  269. if (parent.OrgID === 'TE'){
  270. saFields.push(
  271. {// ╠付款方式╣
  272. name: "PaymentWay", title: '付款方式', type: "text", width: 50, itemTemplate: function (val, item) {
  273. return val === '1' ? "匯款" : "現場付現";
  274. }
  275. }
  276. );
  277. }
  278. saFields.push(
  279. {// ╠common.AppointDateTime⇒預約時間╣
  280. name: "AppointDateTime", title: 'common.AppointDateTime', type: "text", align: "center", width: 100,
  281. itemTemplate: function (val, item) {
  282. return newDate(val);
  283. }
  284. },
  285. {// ╠PackingOrder_Upd.CorrespondStatus⇒對應狀態╣
  286. name: "CustomerId", title: 'PackingOrder_Upd.CorrespondStatus', type: "text", align: "center", width: 100,
  287. itemTemplate: function (val, item) {
  288. var templ = [];
  289. if (val) {// ╠PackingOrder_Upd.HasCorrespond⇒已對應╣
  290. templ.push($('<span />', { text: i18next.t('PackingOrder_Upd.HasCorrespond') }).css('color', 'green'));
  291. if (item.IsFormal) {
  292. // ╠common.HasFormal⇒已轉正╣
  293. templ.push('(', $('<span />', { text: i18next.t('common.HasFormal') }).css('color', 'green'), ')');
  294. }
  295. else {
  296. // ╠common.NotFormal⇒未轉正╣
  297. templ.push('(', $('<a />', {
  298. class: 'link',
  299. text: i18next.t('common.NotFormal'), click: function () {
  300. parent.openPageTab('Customers_Upd', '?Action=Add&FromId=' + item.AppointNO + '&From=Appoint&Flag=Appoint');
  301. }
  302. }).css('color', 'red'), ')');
  303. }
  304. }
  305. else {
  306. templ.push($('<a/>', {
  307. html: i18next.t('PackingOrder_Upd.CorrespondImpCus'),// ╠PackingOrder_Upd.CorrespondImpCus⇒對應到匯入廠商╣
  308. class: 'link',
  309. click: function () {
  310. fnCorrespondImpCus(item);
  311. }
  312. }));
  313. }
  314. return templ;
  315. }
  316. },
  317. {// ╠PackingOrder_Upd.ImpOtherPrgStatus⇒匯入狀態╣
  318. name: "OtherId", title: 'PackingOrder_Upd.ImpOtherPrgStatus', type: "text", align: "center", width: 100,
  319. itemTemplate: function (val, item) {
  320. var templ = $('<a />', {
  321. class: 'link',
  322. text: i18next.t('PackingOrder_Upd.HasImpOtherPrg'), click: function () {
  323. var bTG = item.OtherIdFrom === 'OtherBusiness_Upd';
  324. parent.openPageTab(item.OtherIdFrom, '?Action=Upd&' + (bTG ? 'ImportBillNO' : 'Guid') + '=' + item.OtherId + '&GoTab=' + (bTG ? 2 : 3));
  325. }
  326. }).css('color', 'green');// ╠PackingOrder_Upd.HasImpOtherPrg⇒已產生賬單資料╣
  327. if (!val) {
  328. templ = $('<a/>', {
  329. html: parent.OrgID === 'TE' ? "匯入到「展場服務部」" : i18next.t('PackingOrder_Upd.ImpOtherPrg'),// ╠PackingOrder_Upd.ImpOtherPrg⇒匯入到「其他」入口╣
  330. class: 'link',
  331. click: function () {
  332. var sError = '';
  333. if (!item.CustomerId) {
  334. sError = i18next.t('message.CorrespondImpCusFirst');//╠message.CorrespondImpCusFirst⇒請先對應到匯入廠商╣
  335. }
  336. if (!item.IsFormal) {
  337. sError = i18next.t('message.TransferToFormalFirst');//╠message.TransferToFormalFirst⇒請先轉正該廠商╣
  338. }
  339. if (sError) {
  340. showMsg(sError);
  341. return false;
  342. }
  343. if (parent.OrgID === 'TE'){
  344. fnImportOthersTE(item);
  345. } else {
  346. fnImportOthers(item);
  347. }
  348. }
  349. });
  350. }
  351. return templ;
  352. }
  353. }
  354. );
  355. $("#jsGrid").jsGrid({
  356. width: "100%",
  357. height: iHeight + "px",
  358. autoload: true,
  359. pageLoading: true,
  360. inserting: false,
  361. editing: false,
  362. sorting: true,
  363. paging: true,
  364. pageIndex: window.bToFirstPage ? 1 : window.QueryPageidx || 1,
  365. pageSize: parent.SysSet.GridRecords || 10,
  366. pageButtonCount: parent.SysSet.GridPages || 15,
  367. pagePrevText: "<",
  368. pageNextText: ">",
  369. pageFirstText: "<<",
  370. pageLastText: ">>",
  371. onPageChanged: function (args) {
  372. cacheQueryCondition(args.pageIndex);
  373. },
  374. rowClass: function (item) {
  375. var sClass = '';
  376. if (item.IsKeyMode) {
  377. sClass = 'key-in';
  378. }
  379. return sClass;
  380. },
  381. rowClick: function (args) {
  382. if (navigator.userAgent.match(/mobile/i)) {
  383. goToEdit(sEditPrgId, '?Action=Upd&AppointNO=' + args.item.AppointNO);
  384. }
  385. },
  386. rowDoubleClick: function (args) {
  387. if (args.item.IsKeyMode) {
  388. parent.openPageTab(sEditPrgId, '?Action=Upd&AppointNO=' + args.item.AppointNO);
  389. }
  390. else {
  391. var saPackingInfo = JSON.parse(args.item.PackingInfo),
  392. sContent = '<div class="row popsrow">\
  393. <div class="col-sm-12">\
  394. <div id="jsGrid_PackingInfo"></div>\
  395. </div>\
  396. </div>\
  397. <div class="row popsrow">\
  398. <div class="col-sm-12 wcenter" style="font-size: 20px;font-weight: bold;">\
  399. 費用總計(新臺幣含稅)NT$<span class="PackingTotal"></span>\
  400. </div>\
  401. </div>';
  402. layer.open({
  403. type: 1,
  404. title: i18next.t('common.BookingDetails'),//╠common.BookingDetails⇒預約明細╣
  405. shadeClose: false,
  406. shade: 0.1,
  407. maxmin: true, //开启最大化最小化按钮
  408. area: ['800px', '500px'],
  409. content: sContent,
  410. success: function (layero, index) {
  411. $("#jsGrid_PackingInfo").jsGrid({
  412. width: "100%",
  413. height: "auto",
  414. autoload: true,
  415. pageLoading: true,
  416. pageIndex: 1,
  417. pageSize: 10000,
  418. fields: [
  419. { name: "Index", title: 'common.RowNumber', width: 50, align: "center" },
  420. {// ╠common.Packaging⇒包裝類型╣
  421. name: "ExpoType", title: 'common.Packaging', width: 100, align: "center",
  422. itemTemplate: function (val, item) {
  423. var oExpoType = {
  424. 'zh-TW': { '01': '裸機', '02': '木箱', '03': '散貨', '04': '打板', '05': '其他' },
  425. 'en': { '01': 'Unwrapped', '02': 'Wooden Crate', '03': 'Bulk Cargo', '04': 'Pallet', '05': 'Other' }
  426. },
  427. bEn = 'Unwrapped,Wooden Crate,Bulk Cargo,Pallet,Other'.indexOf(item.ExpoTypeText) > -1;
  428. return val ? oExpoType[bEn ? 'en' : 'zh-TW'][val] : '';
  429. }
  430. },
  431. {// ╠common.Dimensions⇒尺寸╣
  432. name: "ExpoLen", title: 'common.Dimensions', width: 100,
  433. itemTemplate: function (val, item) {
  434. return item.ExpoLen.toMoney() + '*' + item.ExpoWidth.toMoney() + '*' + item.ExpoHeight.toMoney();
  435. }
  436. },
  437. {// ╠common.WeightKG⇒重量╣
  438. name: "ExpoWeight", title: 'common.WeightKG', width: 100, align: "right",
  439. itemTemplate: function (val, item) {
  440. return val.toMoney();
  441. }
  442. },
  443. {
  444. name: "ExpoNumber", title: 'common.Number', width: 100, align: "center",
  445. itemTemplate: function (val, item) {
  446. return val.toMoney();
  447. }
  448. },// ╠common.Number⇒件數╣
  449. {// ╠common.ServiceProject⇒服務項目╣
  450. name: "ExpoStack", title: 'common.ServiceProject', width: 200,
  451. itemTemplate: function (val, item) {
  452. var oService = {
  453. 'zh-TW': ['堆高機服務', '拆箱(含空箱收送與儲存)', '裝箱', '空箱收送', '空箱儲存', '天'],
  454. 'en': ['Forklift', 'Unpacking (including empty crate transport & storage)', 'Packing', 'Empty Crate Transport', 'Empty Crate Storage', 'Days']
  455. },
  456. saText = [],
  457. bEn = 'Unwrapped,Wooden Crate,Bulk Cargo,Pallet,Other'.indexOf(item.ExpoTypeText) > -1;
  458. oService = oService[bEn ? 'en' : 'zh-TW'];
  459. if (item.ExpoStack) {
  460. saText.push(oService[0]);
  461. }
  462. if (item.ExpoSplit) {
  463. saText.push(oService[1]);
  464. }
  465. if (item.ExpoPack) {
  466. saText.push(oService[2]);
  467. }
  468. if (item.ExpoFeed) {
  469. saText.push(oService[3]);
  470. }
  471. if (item.ExpoStorage) {
  472. saText.push(oService[4] + item.ExpoDays + oService[5]);
  473. }
  474. return saText.join(',');
  475. }
  476. },
  477. {// ╠common.Cost⇒費用╣
  478. name: "SubTotal", title: 'common.Cost', width: 100, align: "right",
  479. itemTemplate: function (val, item) {
  480. return fMoney(val || 0, 0, 'NTD');
  481. }
  482. }
  483. ],
  484. controller: {
  485. loadData: function (args) {
  486. return {
  487. data: saPackingInfo,
  488. itemsCount: saPackingInfo.length //data.length
  489. };
  490. }
  491. }
  492. });
  493. $(".PackingTotal").text(fMoney(args.item.Total || 0, 0, 'NTD'));
  494. },
  495. btn: [i18next.t('common.Close')],//╠common.Close⇒關閉╣
  496. });
  497. }
  498. },
  499. fields: saFields,
  500. controller: {
  501. loadData: function (args) {
  502. return fnGet(args);
  503. }
  504. },
  505. onInit: function (args) {
  506. oGrid = args.grid;
  507. }
  508. });
  509. });
  510. };
  511. init();
  512. };
  513. require(['base', 'jsgrid', 'select2', 'util'], fnPageInit);