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.

495 lines
30 KiB

2 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: '',
  11. sortOrder: 'asc'
  12. },
  13. /**
  14. * 獲取資料
  15. * @param {Object} args 查詢參數
  16. * @return {Object} Ajax 物件
  17. */
  18. fnGetPro = function (args) {
  19. var oQueryPm = getFormSerialize(oForm);
  20. $.extend(oQueryPm, oBaseQueryPm, args);
  21. oBaseQueryPm.pageIndex = oQueryPm.pageIndex;
  22. return g_api.ConnectLite(sProgramId, args.Excel ? 'GetExcel' : 'QueryPage', oQueryPm, function (res) {
  23. if (args.Excel) {//匯出
  24. var oRes = res.DATA.rel;
  25. DownLoadFile(oRes);
  26. layer.close(args.Index);
  27. }
  28. });
  29. },
  30. /**
  31. * 打開要匯出的pop選擇匯出類別
  32. */
  33. fnOpenPopToExcel = function () {
  34. layer.open({
  35. type: 1,
  36. title: i18next.t('common.DownLoadDocuments'),// ╠common.DownLoadDocuments⇒下載文檔╣
  37. area: ['200px', '420px'],//寬度
  38. shade: 0.75,//遮罩
  39. shadeClose: true,
  40. btn: [i18next.t('common.Cancel')],// ╠common.Cancel⇒取消╣
  41. content: '<div class="pop-box">\
  42. <p><button type="button" data-i18n="common.BasicInformation" id="Import_BasicInformation" class="btn-custom w100p green">基本資料</button></p>\
  43. <p><button type="button" data-i18n="common.BusinessTrackingSchedule" id="Import_BusinessTrackingSchedule" class="btn-custom w100p green">業務追蹤進度表</button></p>\
  44. <p><button type="button" data-i18n="common.AdvanceAndRetreatWorkSheet" id="Import_AdvanceAndRetreatWorkSheet" class="btn-custom w100p green">進退場工作表</button></p>\
  45. <p><button type="button" data-i18n="common.ReturnRecord" id="Import_ReturnRecord" class="btn-custom w100p green">退運記錄表</button></p>\
  46. <p><button type="button" data-i18n="common.AreasList" id="Import_AreasList" class="btn-custom w100p green">退押款清冊</button></p>\
  47. <p><button type="button" data-i18n="common.BondedSheet" id="Import_BondedSheet" class="btn-custom w100p green">保稅工作表</button></p>\
  48. </div>',//common.BasicInformation基本資料common.BusinessTrackingSchedule業務追蹤進度表common.AdvanceAndRetreatWorkSheet進退場工作表common.ReturnRecord退運記錄表common.AreasList退押款清冊common.BondedSheet保稅工作表
  49. success: function (layero, idx) {
  50. $('.pop-box :button').click(function () {
  51. var sToExcelType = this.id;
  52. fnGetPro({
  53. Excel: true,
  54. ExcelType: sToExcelType,
  55. Index: idx
  56. });
  57. });
  58. transLang(layero);
  59. }
  60. });
  61. },
  62. /**
  63. * ToolBar 按鈕事件 function
  64. * @param {Object}inst 按鈕物件對象
  65. * @param {Object} e 事件對象
  66. */
  67. fnButtonHandler = function (inst, e) {
  68. var sId = inst.id;
  69. switch (sId) {
  70. case "Toolbar_Qry":
  71. var iNum = $('#PerPageNum').val();
  72. oGrid.pageSize = iNum === '' ? parent.SysSet.GridRecords || 10 : iNum;
  73. cacheQueryCondition();
  74. oGrid.openPage(window.bToFirstPage ? 1 : oBaseQueryPm.pageIndex);
  75. break;
  76. case "Toolbar_Save":
  77. fnSave('add');
  78. break;
  79. case "Toolbar_ReAdd":
  80. break;
  81. case "Toolbar_Clear":
  82. clearPageVal();
  83. break;
  84. case "Toolbar_Leave":
  85. break;
  86. case "Toolbar_Add":
  87. parent.openPageTab(sEditPrgId, '?Action=Add');
  88. break;
  89. case "Toolbar_Upd":
  90. break;
  91. case "Toolbar_Copy":
  92. break;
  93. case "Toolbar_Del": // ╠message.ConfirmToDelete⇒確定要刪除嗎 ?╣ ╠common.Tips⇒提示╣
  94. break;
  95. case "Toolbar_Exp":
  96. if (oGrid.data.length === 0) {
  97. showMsg(i18next.t("message.NoDataExport"));// ╠message.NoDataExport⇒沒有資料匯出╣
  98. return false;
  99. }
  100. fnOpenPopToExcel();
  101. break;
  102. default:
  103. alert("No handle '" + sId + "'");
  104. break;
  105. }
  106. },
  107. /**
  108. * 設置Grid行樣式
  109. * @param {String} val 欄位值
  110. * @param {Object} item 欄位值
  111. * @return {String} 新字串
  112. */
  113. setGridRow = function (val, item) {
  114. var sVal = val || '';
  115. if (item.IsAlert === 'Y') {
  116. sVal = '<span class="t-red t-bold">' + sVal + '</span>';
  117. }
  118. return sVal
  119. },
  120. /**
  121. * 初始化 function
  122. */
  123. init = function () {
  124. if (parent.OrgID !== 'TE') {
  125. $('.dept-box').hide();
  126. }
  127. commonInit({
  128. PrgId: sProgramId,
  129. ButtonHandler: fnButtonHandler,
  130. SearchBar: true
  131. });
  132. //$.timepicker.dateRange($('#ExhibitionDateStart'), $('#ExhibitionDateEnd'),
  133. // {
  134. // minInterval: (1000 * 60 * 60 * 24 * 1), // 1 days
  135. // changeYear: true,
  136. // changeMonth: true
  137. // }
  138. //);
  139. $.whenArray([
  140. fnSetDeptDrop($('#DepartmentID'), parent.SysSet.SearchDeptList),
  141. fnSetUserDrop([
  142. {
  143. Select: $('#ResponsiblePerson'),
  144. Select2: true,
  145. ShowId: true,
  146. ServiceCode: parent.SysSet.IMCode
  147. }
  148. ]),
  149. fnSetArgDrop([
  150. {
  151. ArgClassID: 'DeclClass',
  152. Select: $('#DeclarationClass'),
  153. ShowId: true
  154. }
  155. ])])
  156. .done(function () {
  157. reSetQueryPm(sProgramId);
  158. var sCode = parent.UserInfo.ServiceCode;
  159. if (sCode && parent.SysSet.IMCode.indexOf(sCode) > -1 && parent.UserInfo.roles.indexOf('CDD') === -1) {
  160. $('#ResponsiblePerson').val(parent.UserInfo.MemberID);
  161. }
  162. var iHeight = $('body').height() - $('.page-title').height() - $('#searchbar').height() - 87;
  163. $("#jsGrid").jsGrid({
  164. width: "100%",
  165. height: iHeight + "px",
  166. autoload: true,
  167. pageLoading: true,
  168. sorting: true,
  169. paging: true,
  170. pageIndex: window.bToFirstPage ? 1 : window.QueryPageidx || 1,
  171. pageSize: parent.SysSet.GridRecords || 10,
  172. pageButtonCount: parent.SysSet.GridPages || 15,
  173. pagePrevText: "<",
  174. pageNextText: ">",
  175. pageFirstText: "<<",
  176. pageLastText: ">>",
  177. headerClick: function () {
  178. },
  179. onPageChanged: function (args) {
  180. cacheQueryCondition(args.pageIndex);
  181. },
  182. rowClick: function (args) {
  183. if ((args.item.IsVoid === 'Y' && parent.UserInfo.IsManager) || args.item.IsVoid === 'N') {
  184. if (navigator.userAgent.match(/mobile/i)) {
  185. goToEdit(sEditPrgId, '?Action=Upd&ImportBillNO=' + args.item.ImportBillNO);
  186. }
  187. }
  188. else {
  189. showMsg(i18next.t("message.NoPermission")); // ╠message.NoPermission⇒沒有權限╣
  190. }
  191. },
  192. rowDoubleClick: function (args) {
  193. if ((args.item.IsVoid === 'Y' && parent.UserInfo.IsManager) || args.item.IsVoid === 'N') {
  194. parent.openPageTab(sEditPrgId, '?Action=Upd&ImportBillNO=' + args.item.ImportBillNO);
  195. }
  196. else {
  197. showMsg(i18next.t("message.NoPermission")); // ╠message.NoPermission⇒沒有權限╣
  198. }
  199. },
  200. rowMouseDown: function (args) {
  201. //oTimeOut = setTimeout(function () {
  202. //}, 1000);
  203. },
  204. rowMouseUp: function (args) {
  205. //clearTimeout(oTimeOut);
  206. },
  207. rowMouseUut: function (args) {
  208. //clearTimeout(oTimeOut);
  209. },
  210. rowClass: function (item) {
  211. var sClass = '';
  212. if (item.IsVoid === 'Y') {
  213. sClass = 'data-void';
  214. }
  215. return sClass;
  216. },
  217. fields: [
  218. {
  219. name: "RowIndex", title: 'common.RowNumber', type: "text", width: 40, align: "center", sorting: false, itemTemplate: function (val, item) {
  220. var sVal = setGridRow(val, item);
  221. return sVal;
  222. }
  223. },
  224. {
  225. name: "RefNumber", title: 'ExhibitionImport_Upd.RefNumber', type: "text", width: 90, itemTemplate: function (val, item) {
  226. var sVal = setGridRow(val, item);
  227. return sVal;
  228. }
  229. },
  230. {
  231. name: "ImportBillName", title: 'ExhibitionImport_Upd.ImportBillName', type: "text", width: 140, itemTemplate: function (val, item) {
  232. var sVal = setGridRow(val, item);
  233. return sVal;
  234. }
  235. },
  236. {
  237. name: "SupplierCName", title: 'ExhibitionImport_Upd.Supplier', type: "text", width: 120, itemTemplate: function (val, item) {
  238. var sVal = setGridRow(val, item);
  239. return sVal;
  240. }
  241. },
  242. {
  243. name: "AgentName", title: 'ExhibitionImport_Upd.Agent', type: "text", width: 120, itemTemplate: function (val, item) {
  244. var sVal = setGridRow(val, item);
  245. return sVal;
  246. }
  247. },
  248. {
  249. name: "ResponsiblePersonName", title: 'ExhibitionImport_Upd.ResponsiblePerson', type: "text", width: 60, itemTemplate: function (val, item) {
  250. var sVal = setGridRow(val, item);
  251. return sVal;
  252. }
  253. },
  254. {
  255. name: "BillLadNO", title: 'ExhibitionImport_Upd.BillLadNO', type: "text", width: 120, itemTemplate: function (val, item) {
  256. var sVal = setGridRow(val, item);
  257. return sVal;
  258. }
  259. },
  260. {
  261. name: "REF", title: 'ExhibitionImport_Upd.REF', type: "text", width: 60, itemTemplate: function (val, item) {
  262. var sVal = setGridRow(val, item);
  263. return sVal;
  264. }
  265. },
  266. {// ╠common.Flow_Status⇒貨物狀態╣
  267. name: "Flow_Status", title: 'common.Flow_Status', type: "text", width: 70, itemTemplate: function (val, item) {
  268. var sValShow = '',
  269. saVal = (val || '').split('-');
  270. if (saVal.length > 1) {
  271. var oImport = { '1': '已收文件', '2': '貨物抵達', '3': '報關作業', '4': '貨物放行', '5': '轉至展館倉庫', '6': '已送達' },
  272. oReImport = { '1': '文件確認', '2': '報關作業', '3': '貨物放行', '4': '回運中', '5': '抵達目的地', '6': '已送達' };
  273. if (saVal[0] === 'Import') {
  274. sValShow = i18next.t("common.ExhibitionImport_Qry") + '-' + oImport[saVal[1]];// ╠common.ExhibitionImport_Qry⇒進口╣
  275. }
  276. else {
  277. var saReImports = $.parseJSON(item.ReImports);
  278. if (saReImports.length > 0) {
  279. $.each(saReImports, function (idx, reimport) {
  280. var iLen = idx + 1,
  281. sFlowStatus = '';
  282. if (reimport.ReImport.Sign && reimport.ReImport.Sign.Checked) {
  283. sFlowStatus = '6';
  284. }
  285. else if (reimport.ReImport.ReachDestination && reimport.ReImport.ReachDestination.Checked) {
  286. sFlowStatus = '5';
  287. }
  288. else if (reimport.ReImport.HuiYun && reimport.ReImport.HuiYun.Checked) {
  289. sFlowStatus = '4';
  290. }
  291. else if (reimport.ReImport.ReCargoRelease && reimport.ReImport.ReCargoRelease.Checked) {
  292. sFlowStatus = '3';
  293. }
  294. else if (reimport.ReImport.ReCustomsDeclaration && reimport.ReImport.ReCustomsDeclaration.Checked) {
  295. sFlowStatus = '2';
  296. }
  297. else if (reimport.ReImport.FileValidation && reimport.ReImport.FileValidation.Checked) {
  298. sFlowStatus = '1';
  299. }
  300. if (sFlowStatus) {
  301. sValShow += i18next.t("common.Returns") + iLen + '-' + oReImport[sFlowStatus] + '<br/>';// ╠common.Returns⇒退運╣
  302. }
  303. });
  304. }
  305. }
  306. }
  307. sValShow = setGridRow(sValShow, item);
  308. return sValShow;
  309. }
  310. },
  311. {// ╠ExhibitionImport_Upd.ExhibitionDateStart⇒活動日期起╣
  312. name: "ExhibitionDateStart", title: 'ExhibitionImport_Upd.ExhibitionDateStart', type: "text", width: 60, itemTemplate: function (val, item) {
  313. var sVal = setGridRow(newDate(val, 'date', true), item);
  314. return sVal;
  315. }
  316. },
  317. {// ╠ExhibitionImport_Upd.IsSendMail⇒查詢碼寄送狀態╣
  318. name: "IsSendMail", title: 'ExhibitionImport_Upd.IsSendMail', type: "text", align: "center", width: 70, itemTemplate: function (val, item) {
  319. return val === 'Y' ? i18next.t('common.HasMail') : i18next.t('common.NotMail');// ╠common.HasMail⇒已寄送╣ ╠common.NotMail⇒未寄送╣
  320. }
  321. },
  322. {// ╠common.Bill_Status⇒帳單狀態╣
  323. type: "control", title: 'common.Bill_Status', itemTemplate: function (val, item) {
  324. var iTips = 0,
  325. sTipsHtml = '<div class="layui-layer-btn-c">' + i18next.t("common.Bill_Status") + '</div>',// ╠common.Bill_Status⇒帳單狀態╣
  326. saBills = $.parseJSON(!item.Bills ? '[]' : item.Bills),
  327. saReturnBills = $.parseJSON(!item.ReturnBills ? '[]' : item.ReturnBills),
  328. saReBills = [],
  329. oOption = {
  330. btnAlign: 'c',
  331. time: 600000 //一個小時(如果不配置,默认是3秒)
  332. },
  333. bOK = true,
  334. oTips = $('<span>', {
  335. 'class': 'glyphicon glyphicon-info-sign',
  336. 'aria-hidden': true
  337. }).on({
  338. click: function () {
  339. oOption.btn = [i18next.t("common.Close")];// ╠common.Close⇒關閉╣
  340. layer.msg(sTipsHtml, oOption);
  341. },
  342. mouseenter: function (event) {
  343. delete oOption.btn;
  344. iTips = layer.msg(sTipsHtml, oOption);
  345. },
  346. mouseleave: function (event) {
  347. layer.close(iTips);
  348. }
  349. });
  350. if (saReturnBills.length > 0) {
  351. $.each(saReturnBills, function (idx, _return) {
  352. if (_return.Bills && _return.Bills.length > 0) {
  353. $.each(_return.Bills, function (idx, bill) {
  354. saReBills.push(bill);
  355. });
  356. }
  357. });
  358. }
  359. if (saBills.length > 0 || saReBills.length > 0) {
  360. sTipsHtml += '<ul class="bill-status">';
  361. if (saBills.length > 0) {
  362. $.each(saBills, function (idx, bill) {
  363. var sStatusName = '';
  364. switch (bill.AuditVal) {
  365. case '0':// ╠common.NotAudit⇒未提交審核╣
  366. sStatusName = i18next.t("common.NotAudit");
  367. if (bOK) { bOK = false; }
  368. break;
  369. case '1':// ╠common.InAudit⇒提交審核中╣
  370. sStatusName = i18next.t("common.InAudit");
  371. if (bOK) { bOK = false; }
  372. break;
  373. case '2':// ╠common.Audited⇒已審核╣
  374. sStatusName = i18next.t("common.Audited");
  375. break;
  376. case '3':// ╠common.NotPass⇒不通過╣
  377. sStatusName = i18next.t("common.NotPass");
  378. if (bOK) { bOK = false; }
  379. break;
  380. case '4':// ╠common.HasBeenRealized⇒已銷帳╣
  381. sStatusName = i18next.t("common.HasBeenRealized");
  382. break;
  383. case '5':// ╠common.HasBeenPost⇒已過帳╣
  384. sStatusName = i18next.t("common.HasBeenPost");
  385. break;
  386. case '6':// ╠common.HasVoid⇒已作廢╣
  387. sStatusName = i18next.t("common.HasVoid");
  388. break;
  389. case '7':// ╠common.HasReEdit⇒抽單中╣
  390. sStatusName = i18next.t("common.HasReEdit");
  391. break;
  392. }
  393. sTipsHtml += "<li><a class='gopagetab' onclick='parent.openPageTab(\"" + sEditPrgId + "\",\"?Action=Upd&GoTab=3&ImportBillNO=" + item.ImportBillNO + "&BillNO=" + bill.BillNO + "\")' ><div>" + bill.BillNO + "</div><div>" + sStatusName + "</div></a></li>";
  394. });
  395. }
  396. if (saReBills.length > 0) {
  397. sTipsHtml += '<li>退運帳單</li>';
  398. $.each(saReBills, function (idx, bill) {
  399. var sStatusName = '';
  400. switch (bill.AuditVal) {
  401. case '0':// ╠common.NotAudit⇒未提交審核╣
  402. sStatusName = i18next.t("common.NotAudit");
  403. if (bOK) { bOK = false; }
  404. break;
  405. case '1':// ╠common.InAudit⇒提交審核中╣
  406. sStatusName = i18next.t("common.InAudit");
  407. if (bOK) { bOK = false; }
  408. break;
  409. case '2':// ╠common.Audited⇒已審核╣
  410. sStatusName = i18next.t("common.Audited");
  411. break;
  412. case '3':// ╠common.NotPass⇒不通過╣
  413. sStatusName = i18next.t("common.NotPass");
  414. if (bOK) { bOK = false; }
  415. break;
  416. case '4':// ╠common.HasBeenRealized⇒已銷帳╣
  417. sStatusName = i18next.t("common.HasBeenRealized");
  418. break;
  419. case '5':// ╠common.HasBeenPost⇒已過帳╣
  420. sStatusName = i18next.t("common.HasBeenPost");
  421. break;
  422. case '6':// ╠common.HasVoid⇒已作廢╣
  423. sStatusName = i18next.t("common.HasVoid");
  424. break;
  425. case '7':// ╠common.HasReEdit⇒抽單中╣
  426. sStatusName = i18next.t("common.HasReEdit");
  427. break;
  428. }
  429. sTipsHtml += "<li><a class='gopagetab' onclick='parent.openPageTab(\"" + sEditPrgId + "\",\"?Action=Upd&GoTab=9&ImportBillNO=" + item.ImportBillNO + "&BillNO=" + bill.BillNO + "\")' ><div>" + bill.BillNO + "</div><div>" + sStatusName + "</div></a></li>";
  430. });
  431. }
  432. sTipsHtml += '</ul>';
  433. if (saBills.length + saReBills.length > 15) {
  434. oOption.area = ['340px', '500px'];
  435. }
  436. }
  437. else {
  438. sTipsHtml = '<div>' + i18next.t("common.NOBills") + '</div>';// ╠common.NOBills⇒還沒有帳單╣
  439. bOK = false;
  440. }
  441. if (bOK) {
  442. oTips.css('color', 'blue');
  443. }
  444. else {
  445. oTips.css('color', 'red');
  446. }
  447. return oTips;
  448. }
  449. }
  450. //{
  451. // name: "ExhibitionDateEnd", title: 'ExhibitionImport_Upd.ExhibitionDateEnd', type: "text", width: 70, itemTemplate: function (val, item) {
  452. // var sVal = setGridRow(newDate(val, 'date', true), item);
  453. // return sVal;
  454. // }
  455. //}
  456. ],
  457. controller: {
  458. loadData: function (args) {
  459. return fnGetPro(args);
  460. }
  461. },
  462. onInit: function (args) {
  463. oGrid = args.grid;
  464. }
  465. });
  466. if (parent.UserInfo.roles.indexOf('Business') > -1 || parent.UserInfo.roles.indexOf('CDD') > -1) {//報關||業務
  467. $('.slide-box').click();
  468. }
  469. });
  470. };
  471. init();
  472. };
  473. require(['base', 'select2', 'jsgrid', 'util'], fnPageInit);