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.

725 lines
38 KiB

3 years ago
  1. 'use strict';
  2. var sProgramId = getProgramId(),
  3. sQueryPrgId = getQueryPrgId(),
  4. sAction = getUrlParam('Action') || 'Add',
  5. sDataId = getUrlParam('AppointNO'),
  6. sCheckId = sDataId,
  7. fnPageInit = function () {
  8. var oCurData = {},
  9. oForm = $('#form_main'),
  10. oCostRules = {},
  11. oGrid = null,
  12. oValidator = null,
  13. sExhibitionNO = '',
  14. /**
  15. * 獲取資料
  16. * @return {Object} Ajax 物件
  17. */
  18. fnGet = function () {
  19. if (sDataId) {
  20. return CallAjax(ComFn.W_Com, ComFn.GetOne, {
  21. Type: '',
  22. Params: {
  23. packingorder: {
  24. AppointNO: sDataId
  25. }
  26. }
  27. }, function (res) {
  28. if (res.d) {
  29. var oRes = $.parseJSON(res.d);
  30. oCurData = oRes;
  31. oCurData.Total = oCurData.Total || 0;
  32. oCurData.PackingInfo = $.parseJSON(oCurData.PackingInfo || '[]');
  33. setFormVal(oForm, oRes);
  34. fnSetImpCusDrop(oCurData.ExhibitionNO, oCurData.CustomerId);
  35. setNameById().done(function () {
  36. getPageVal();//緩存頁面值,用於清除
  37. });
  38. $('#AppointNO').attr('disabled', 'disabled');
  39. moneyInput($('#Total'), 0);
  40. }
  41. });
  42. }
  43. else {
  44. oCurData.Total = 0;
  45. oCurData.PackingInfo = [];
  46. fnSetImpCusDrop();
  47. return $.Deferred().resolve().promise();
  48. }
  49. },
  50. /**
  51. * 新增資料
  52. * @param {String} flag 新增或儲存後新增
  53. * @return {Boolean} 停止標記
  54. */
  55. fnAdd = function (flag) {
  56. var data = getFormSerialize(oForm),
  57. sDateStr = new Date().formate("yyyyMMdd");
  58. data = packParams(data);
  59. data.OrgID = parent.OrgID;
  60. data.IsKeyMode = true;
  61. data.Total = oCurData.Total;
  62. data.CompName = $('#CustomerId option:selected').text();
  63. data.AppointNO = 'SerialNumber|' + parent.UserInfo.OrgID + '|A' + sExhibitionNO + '|Empty|3|' + sDateStr + '|';
  64. if (oCurData.PackingInfo.length === 0) {
  65. showMsg(i18next.t("message.PackingInfo_required")); // ╠message.PackingInfo_required⇒請添加服務明細╣
  66. return false;
  67. }
  68. data.PackingInfo = JSON.stringify(oCurData.PackingInfo);
  69. CallAjax(ComFn.W_Com, ComFn.GetAdd, {
  70. Params: {
  71. packingorder: data
  72. }
  73. }, function (res) {
  74. if (res.d > 0) {
  75. bRequestStorage = false;
  76. if (flag === 'add') {
  77. showMsgAndGo(i18next.t("message.Save_Success"), sQueryPrgId); // ╠message.Save_Success⇒新增成功╣
  78. }
  79. else {
  80. showMsgAndGo(i18next.t("message.Save_Success"), sProgramId, '?Action=Add'); // ╠message.Save_Success⇒新增成功╣
  81. }
  82. parent.msgs.server.broadcast(data);
  83. }
  84. else {
  85. showMsg(i18next.t("message.Save_Failed"), 'error'); // ╠message.Save_Failed⇒新增失敗╣
  86. }
  87. });
  88. },
  89. /**
  90. * 修改資料
  91. * @return {Boolean} 停止標記
  92. */
  93. fnUpd = function () {
  94. var data = getFormSerialize(oForm);
  95. data = packParams(data, 'upd');
  96. data.Total = oCurData.Total;
  97. data.CompName = $('#CustomerId option:selected').text();
  98. if (oCurData.PackingInfo.length === 0) {
  99. showMsg(i18next.t("message.PackingInfo_required")); // ╠message.PackingInfo_required⇒請添加服務明細╣
  100. return false;
  101. }
  102. data.PackingInfo = JSON.stringify(oCurData.PackingInfo);
  103. CallAjax(ComFn.W_Com, ComFn.GetUpd, {
  104. Params: {
  105. packingorder: {
  106. values: data,
  107. keys: {
  108. AppointNO: sDataId,
  109. OrgID: parent.OrgID
  110. }
  111. }
  112. }
  113. }, function (res) {
  114. if (res.d > 0) {
  115. bRequestStorage = false;
  116. showMsgAndGo(i18next.t("message.Modify_Success"), sQueryPrgId);//╠message.Modify_Success⇒修改成功╣
  117. }
  118. else {
  119. showMsg(i18next.t("message.Modify_Failed"), 'error');//╠message.Modify_Failed⇒修改失敗╣
  120. }
  121. }, function () {
  122. showMsg(i18next.t("message.Modify_Failed"), 'error');//╠message.Modify_Failed⇒修改失敗╣
  123. });
  124. },
  125. /**
  126. * 資料刪除
  127. */
  128. fnDel = function () {
  129. CallAjax(ComFn.W_Com, ComFn.GetDel, {
  130. Params: {
  131. packingorder: {
  132. AppointNO: sDataId
  133. }
  134. }
  135. }, function (res) {
  136. if (res.d > 0) {
  137. showMsgAndGo(i18next.t("message.Delete_Success"), sQueryPrgId); // ╠message.Delete_Success⇒刪除成功╣
  138. }
  139. else {
  140. showMsg(i18next.t("message.Delete_Failed"), 'error'); // ╠message.Delete_Failed⇒刪除失敗╣
  141. }
  142. }, function () {
  143. showMsg(i18next.t("message.Delete_Failed"), 'error'); // ╠message.Delete_Failed⇒刪除失敗╣
  144. });
  145. },
  146. /**
  147. * 開啟新增Pop
  148. * @param {String} flag 新增或修改
  149. * @param {Object} curitem 當前編輯資料
  150. */
  151. fnOpenPackingInfo = function (flag, curitem) {
  152. getHtmlTmp('/Page/Pop/PackingInfo.html').done(function (html) {
  153. layer.open({
  154. type: 1, //0(信息框,默认)1(页面层)2(iframe层)3(加载层)4(tips层)
  155. title: i18next.t("PackingOrder_Upd.PackingInfo"), // ╠PackingOrder_Upd.PackingInfo⇒服務明細╣
  156. area: '640px;',//寬度
  157. shade: 0.75,//遮罩
  158. closeBtn: 1,
  159. maxmin: true, //开启最大化最小化按钮
  160. id: 'layer_PackingInfo', //设定一个id,防止重复弹出
  161. offset: '10px',//右下角弹出
  162. anim: 0,//彈出動畫
  163. btn: [i18next.t('common.Confirm'), i18next.t('common.Cancel')],//╠common.Confirm⇒確定╣╠common.Cancel⇒取消╣
  164. btnAlign: 'c',//按鈕位置
  165. content: html,
  166. success: function (layero, index) {
  167. var fnSetCheckbox = function (el) {
  168. var ul = $('#form_PackingInfo'),
  169. bCheck = false;
  170. if (el.id === 'ExpoSplit' || el.id === 'ExpoPack') {
  171. ul.find('.packing').each(function () {
  172. if (this.checked) {
  173. bCheck = true;
  174. return false;
  175. }
  176. });
  177. if (bCheck) {
  178. ul.find('.single-packing,#ExpoDays').prop('disabled', true);
  179. ul.find('.textStyle').val('');
  180. }
  181. else {
  182. ul.find('.single-packing,#ExpoDays').prop('disabled', false);
  183. }
  184. }
  185. else if (el.id === 'ExpoFeed' || el.id === 'ExpoStorage') {
  186. ul.find('.single-packing').each(function () {
  187. if (this.checked) {
  188. bCheck = true;
  189. return false;
  190. }
  191. });
  192. if (bCheck) {
  193. ul.find('.packing').prop('disabled', true);
  194. /*** 2019/01/22 Yang Leo 點選「空箱收送」時,已包含「空箱存放」,直接鎖住「空箱存放」欄位 和 點選「空箱存放」時,直接鎖住「空箱收送」欄位 Star ***/
  195. if (oCostRules.IsMerge === 'Y') {
  196. if (el.id.indexOf('ExpoFeed') > -1) {
  197. ul.find("[id^='ExpoStorage'],.textStyle").prop('disabled', true);
  198. } else {
  199. ul.find("[id^='ExpoFeed']").prop('disabled', true);
  200. }
  201. }
  202. /*** 2019/01/22 Yang Leo 點選「空箱收送」時,已包含「空箱存放」,直接鎖住「空箱存放」欄位 和 點選「空箱存放」時,直接鎖住「空箱收送」欄位 End ***/
  203. }
  204. else {
  205. ul.find('.packing').prop('disabled', false);
  206. /*** 2019/01/22 Yang Leo 取消點選「空箱收送」時,已包含「空箱存放」,直接解鎖「空箱存放」欄位 和 取消點選「空箱存放」時,直接解鎖「空箱收送」欄位 Star ***/
  207. if (oCostRules.IsMerge === 'Y') {
  208. if (el.id.indexOf('ExpoFeed') > -1) {
  209. ul.find("[id^='ExpoStorage'],.textStyle").prop('disabled', false);
  210. } else {
  211. ul.find("[id^='ExpoFeed']").prop('disabled', false);
  212. }
  213. }
  214. /*** 2019/01/22 Yang Leo 取消點選「空箱收送」時,已包含「空箱存放」,直接解鎖「空箱存放」欄位 和 取消點選「空箱存放」時,直接解鎖「空箱收送」欄位 End ***/
  215. }
  216. }
  217. };
  218. if (curitem) {
  219. setFormVal($('#form_PackingInfo'), curitem);
  220. var checkBox = layero.find('[type="checkbox"]:not(:first):checked');
  221. if (checkBox.length > 0) {
  222. fnSetCheckbox(checkBox[0]);
  223. }
  224. }
  225. moneyInput($('[data-name="int"]'), 0);
  226. layero.find('[type="checkbox"]').click(function () {
  227. fnSetCheckbox(this);
  228. });
  229. transLang(layero.find('#form_PackingInfo'));
  230. },
  231. yes: function (index, layero) {
  232. var data = getFormSerialize($('#form_PackingInfo')),
  233. oExpoType = {
  234. '01': '裸機',
  235. '02': '木箱',
  236. '03': '散貨',
  237. '04': '打板',
  238. '05': '其他'
  239. },
  240. sError = '';
  241. if (flag === 'add') {
  242. data.Guid = guid();
  243. data.Index = oCurData.PackingInfo.length + 1;
  244. }
  245. else {
  246. data.Guid = curitem.Guid;
  247. data.Index = curitem.Index;
  248. }
  249. data.ExpoLen = fnPackNum(data.ExpoLen);
  250. data.ExpoWidth = fnPackNum(data.ExpoWidth);
  251. data.ExpoHeight = fnPackNum(data.ExpoHeight);
  252. data.TotalCBM = data.ExpoLen * data.ExpoWidth * data.ExpoHeight / 1000000;//CBM
  253. data.ExpoWeight = fnPackNum(data.ExpoWeight);//重量
  254. data.ExpoWeightTon = data.ExpoWeight / 1000;//噸
  255. data.ExpoNumber = fnPackNum(data.ExpoNumber);//件數
  256. data.SubTotal = 0;//小計
  257. data.ExpoDays = fnPackNum(data.ExpoDays);//天數
  258. data.SubText = [];//
  259. data.ExpoStack = data.ExpoStack || false;
  260. data.ExpoSplit = data.ExpoSplit || false;
  261. data.ExpoPack = data.ExpoPack || false;
  262. data.ExpoFeed = data.ExpoFeed || false;
  263. data.ExpoStorage = data.ExpoStorage || false;
  264. data.ExpoTypeText = oExpoType[data.ExpoType];
  265. if (data.ExpoNumber > 0) {//件數
  266. data.SubText.push(data.ExpoNumber.toString().toMoney() + '件');
  267. if (data.TotalCBM > 0) {//CBM
  268. var iTotalCBM = data.TotalCBM * data.ExpoNumber;
  269. if (iTotalCBM < 1) {
  270. iTotalCBM = 1;
  271. }
  272. data.SubText.push(iTotalCBM.toFloat(2).toString().toMoney() + 'CBM');
  273. }
  274. if (data.ExpoWeight > 0) {//KG
  275. var iExpoWeight = data.ExpoWeight * data.ExpoNumber;
  276. if (iExpoWeight < 1) {
  277. iExpoWeight = 1;
  278. }
  279. data.SubText.push(iExpoWeight.toFloat(2).toString().toMoney() + 'KG');
  280. }
  281. }
  282. if (data.ExpoStorage && data.TotalCBM > 0 && data.ExpoNumber > 0 && data.ExpoDays > 0) {//儲存
  283. data.SubTotal += data.TotalCBM * data.ExpoNumber * data.ExpoDays * fnPackNum(oCostRules.StoragePrice);
  284. }
  285. if (data.ExpoFeed && data.TotalCBM > 0 && data.ExpoNumber > 0) {// 空箱收送
  286. data.SubTotal += data.TotalCBM * data.ExpoNumber * fnPackNum(oCostRules.FeedingPrice);
  287. }
  288. if (data.ExpoPack && data.TotalCBM > 0 && data.ExpoNumber > 0) {//裝箱
  289. data.SubTotal += (data.TotalCBM < 1 ? 1 : data.TotalCBM) * data.ExpoNumber * fnPackNum(oCostRules.PackingPrice);
  290. }
  291. if (data.ExpoSplit && data.TotalCBM > 0 && data.ExpoNumber > 0) {//拆箱
  292. data.SubTotal += (data.TotalCBM < 1 ? 1 : data.TotalCBM) * data.ExpoNumber * fnPackNum(oCostRules.PackingPrice);
  293. }
  294. if (data.ExpoStack && data.ExpoWeightTon > 0 && data.ExpoNumber > 0) {//堆高
  295. /*** 2019/01/22 Yang Leo 台北駒驛「線上預約」堆高機價格計算方式調整「材積重」及「重量」擇一個重的去計價 Star ***/
  296. //尺寸:200x200x200cm(換算材積重 = 1,336KGS)
  297. //公式 = 長 寬 高 / 1000000 * 167
  298. //重量:900KGS
  299. //目前系統公式直接以重量900KGS計價 -> $920 / 件
  300. //明年改為以材積重1,336KGS去計價 -> $1,700 / 件
  301. if ((data.TotalCBM * 167) > data.ExpoWeight) { //公式=長*寬*高/1000000*167
  302. data.ExpoWeightTon = (data.TotalCBM * 167) / 1000;
  303. }
  304. /*** 2019/01/22 Yang Leo 台北駒驛「線上預約」堆高機價格計算方式調整「材積重」及「重量」擇一個重的去計價 End ***/
  305. var rule = fnGetCurRule(data.ExpoWeightTon);
  306. if (rule.PricingMode === 'T') {
  307. data.SubTotal += data.ExpoWeightTon * data.ExpoNumber * fnPackNum(rule.Price);
  308. }
  309. else {
  310. data.SubTotal += data.ExpoNumber * fnPackNum(rule.Price);
  311. }
  312. }
  313. if (data.ExpoStack || data.ExpoSplit || data.ExpoPack || data.ExpoFeed || data.ExpoStorage) {
  314. if (data.ExpoNumber === 0) {
  315. sError += '[件數]不能為空<br/>';
  316. }
  317. if (data.ExpoStack) {
  318. if (data.ExpoWeightTon === 0) {
  319. sError += '[堆高機]服務重量不能為空<br/>';
  320. }
  321. if (data.TotalCBM === 0) {
  322. sError += '[堆高機]服務尺寸不能為空<br/>';
  323. }
  324. }
  325. if (data.ExpoSplit) {
  326. if (data.TotalCBM === 0) {
  327. sError += '[裝箱]服務尺寸不能為空<br/>';
  328. }
  329. }
  330. if (data.ExpoPack) {
  331. if (data.TotalCBM === 0) {
  332. sError += '[拆箱(含空箱收送與儲存)]服務尺寸不能為空<br/>';
  333. }
  334. }
  335. if (data.ExpoFeed) {
  336. if (data.TotalCBM === 0) {
  337. sError += '[空箱收送]服務尺寸不能為空 <br />';
  338. }
  339. }
  340. if (data.ExpoStorage) {
  341. if (data.TotalCBM === 0) {
  342. sError += '[空箱存放 / 存放]服務尺寸不能為空 <br />';
  343. }
  344. if (data.ExpoDays === 0) {
  345. sError += '[空箱存放 / 存放]服務天數不能為空 <br /> ';
  346. }
  347. }
  348. }
  349. else {
  350. sError += '請至少選擇一種服務<br/>';
  351. }
  352. if (sError) {
  353. showMsg(sError);
  354. return false;
  355. }
  356. if (flag === 'add') {
  357. oCurData.PackingInfo.push(data);
  358. }
  359. else {
  360. $.grep(oCurData.PackingInfo, function (item) {
  361. if (item.Guid === curitem.Guid) {
  362. $.extend(item, data);
  363. }
  364. });
  365. }
  366. fnTotalSum();
  367. oGrid.loadData();
  368. layer.close(index);
  369. }
  370. });
  371. });
  372. },
  373. /**
  374. * 目的 轉換數字
  375. * @param {String}str 當前input值
  376. * @return {Number} 數字
  377. */
  378. fnPackNum = function (str) {
  379. return ((str || '') === '' ? '0' : str) * 1;
  380. },
  381. /**
  382. * 目的 轉換數字
  383. * @param {String}str 當前input值
  384. */
  385. fnTotalSum = function () {
  386. var iTotal = 0;
  387. $.grep(oCurData.PackingInfo, function (item) {
  388. iTotal += item.SubTotal * 1;
  389. });
  390. oCurData.Total = iTotal.toFloat().toMoney();
  391. $('#Total').val(oCurData.Total);
  392. },
  393. /**
  394. * 目的 獲取當前適應費用規則
  395. * @param {Number}weight 當前重量
  396. * @return {Object} 當前規則對象
  397. */
  398. fnGetCurRule = function (weight) {
  399. var oRule = {};
  400. $.each(oCostRules.CostRules, function (index, item) {
  401. var rule_min = fnPackNum(item.Weight_Min),
  402. rule_max = fnPackNum(item.Weight_Max);
  403. if (weight >= rule_min && weight < rule_max || (weight === 30 && rule_max === 30)) {
  404. oRule = item;
  405. return false;
  406. }
  407. });
  408. return oRule;
  409. },
  410. /**
  411. * 目的 設置匯入廠商下拉單
  412. * @param {String}id 展覽ID
  413. * @param {String}val 客戶值
  414. * @return {Object} Ajax對象
  415. */
  416. fnSetImpCusDrop = function (id, val) {
  417. if (id) {
  418. return g_api.ConnectLite(sProgramId, 'SetImpCusDrop', {
  419. Id: id
  420. }, function (res) {
  421. if (res.RESULT) {
  422. var saList = res.DATA.rel;
  423. var sOptions = createOptions(saList, 'guid', 'CustomerCName');
  424. $('#CustomerId').html(sOptions).on('change', function () {
  425. g_api.ConnectLite(sProgramId, 'GetImpCusData', {
  426. Id: this.value,
  427. ExhibitionNO: id
  428. }, function (res) {
  429. if (res.RESULT) {
  430. var oRes = res.DATA.rel || {};
  431. $('#MuseumMumber').val(oRes.MuseumMumber || '');
  432. $('#Unicode').val(oRes.UniCode || '');
  433. $('#AppointUser').val(oRes.Contactor || '');
  434. $('#AppointTel').val(oRes.Telephone || '');
  435. $('#AppointExt').val(oRes.Ext || '');
  436. $('#AppointEmail').val(oRes.Email || '');
  437. $('#Contactor').val(oRes.Contactor || '');
  438. $('#ContactTel').val(oRes.Telephone || '');
  439. }
  440. });
  441. }).select2();
  442. if (val) {
  443. $('#CustomerId').val(val).trigger('change');
  444. }
  445. }
  446. });
  447. }
  448. else {
  449. $('#CustomerId').html(createOptions([]));
  450. return $.Deferred().resolve().promise();
  451. }
  452. },
  453. /**
  454. * ToolBar 按鈕事件 function
  455. * @param {Object}inst 按鈕物件對象
  456. * @param {Object} e 事件對象
  457. * @return {Boolean} 停止標識
  458. */
  459. fnButtonHandler = function (inst, e) {
  460. var sId = inst.id;
  461. switch (sId) {
  462. case "Toolbar_Qry":
  463. break;
  464. case "Toolbar_Save":
  465. if (!$("#form_main").valid()) {
  466. oValidator.focusInvalid();
  467. return false;
  468. }
  469. if (sAction === 'Add') {
  470. fnAdd('add');
  471. }
  472. else {
  473. fnUpd();
  474. }
  475. break;
  476. case "Toolbar_ReAdd":
  477. if (!$("#form_main").valid()) {
  478. oValidator.focusInvalid();
  479. return false;
  480. }
  481. fnAdd('readd');
  482. break;
  483. case "Toolbar_Clear":
  484. clearPageVal();
  485. break;
  486. case "Toolbar_Leave":
  487. pageLeave();
  488. break;
  489. case "Toolbar_Add":
  490. break;
  491. case "Toolbar_Upd":
  492. break;
  493. case "Toolbar_Copy":
  494. break;
  495. case "Toolbar_Del": // ╠message.ConfirmToDelete⇒確定要刪除嗎 ?╣ ╠common.Tips⇒提示╣
  496. layer.confirm(i18next.t("message.ConfirmToDelete"), { icon: 3, title: i18next.t('common.Tips') }, function (index) {
  497. fnDel();
  498. layer.close(index);
  499. });
  500. break;
  501. default:
  502. alert("No handle '" + sId + "'");
  503. break;
  504. }
  505. },
  506. /**
  507. * 初始化 function
  508. */
  509. init = function () {
  510. if (parent.OrgID === 'TE') {
  511. $('.AppointTE').show();
  512. $('#spnAppointTel').attr('data-i18n','公司電話及分機');
  513. $('#divAppointTel').removeClass('col-sm-3').addClass('col-sm-2');
  514. }
  515. commonInit({
  516. PrgId: sProgramId,
  517. ButtonHandler: fnButtonHandler,
  518. GoTop: true
  519. });
  520. oValidator = $("#form_main").validate({
  521. onfocusout: false,
  522. rules: {
  523. AppointEmail: { email: true }
  524. },
  525. messages: {
  526. AppointEmail: { email: i18next.t("message.IncorrectEmail") }// ╠message.IncorrectEmail⇒郵箱格式不正確╣
  527. }
  528. });
  529. $.whenArray([
  530. fnSetEpoDrop({
  531. Select: $('#ExhibitionNO'),
  532. Select2: true,
  533. CallBack: function () {
  534. }
  535. })
  536. ])
  537. .done(function () {
  538. fnGet().done(function () {
  539. $("#jsGrid").jsGrid({
  540. width: "100%",
  541. height: "auto",
  542. autoload: true,
  543. filtering: false,
  544. inserting: true,
  545. editing: false,
  546. pageLoading: true,
  547. confirmDeleting: true,
  548. invalidMessage: i18next.t('common.InvalidData'),// ╠common.InvalidData⇒输入的数据无效!╣
  549. deleteConfirm: i18next.t('message.ConfirmToDelete'),// ╠message.ConfirmToDelete⇒確定要刪除嗎 ?╣
  550. pageIndex: 1,
  551. pageSize: 10000,
  552. fields: [
  553. { name: "Index", title: 'common.RowNumber', width: 50, align: "center" },
  554. {// ╠common.Packaging⇒包裝類型╣
  555. name: "ExpoType", title: 'common.Packaging', width: 100, align: "center",
  556. itemTemplate: function (val, item) {
  557. var oExpoType = {
  558. 'zh-TW': { '01': '裸機', '02': '木箱', '03': '散貨', '04': '打板', '05': '其他' },
  559. 'en': { '01': 'Unwrapped', '02': 'Wooden Crate', '03': 'Bulk Cargo', '04': 'Pallet', '05': 'Other' }
  560. },
  561. bEn = 'Unwrapped,Wooden Crate,Bulk Cargo,Pallet,Other'.indexOf(item.ExpoTypeText) > -1;
  562. return val ? oExpoType[bEn ? 'en' : 'zh-TW'][val] : '';
  563. }
  564. },
  565. {// ╠common.Dimensions⇒尺寸╣
  566. name: "ExpoLen", title: 'common.Dimensions', width: 100,
  567. itemTemplate: function (val, item) {
  568. return item.ExpoLen.toMoney() + '*' + item.ExpoWidth.toMoney() + '*' + item.ExpoHeight.toMoney();
  569. }
  570. },
  571. {// ╠common.WeightKG⇒重量╣
  572. name: "ExpoWeight", title: 'common.WeightKG', width: 100, align: "right",
  573. itemTemplate: function (val, item) {
  574. return val.toMoney();
  575. }
  576. },
  577. {
  578. name: "ExpoNumber", title: 'common.Number', width: 100, align: "center",
  579. itemTemplate: function (val, item) {
  580. return val.toMoney();
  581. }
  582. },// ╠common.Number⇒件數╣
  583. {// ╠common.ServiceProject⇒服務項目╣
  584. name: "ExpoStack", title: 'common.ServiceProject', width: 200,
  585. itemTemplate: function (val, item) {
  586. var oService = {
  587. 'zh-TW': ['堆高機服務', '拆箱(含空箱收送與儲存)', '裝箱', '空箱收送', '空箱儲存', '天'],
  588. 'en': ['Forklift', 'Unpacking (including empty crate transport & storage)', 'Packing', 'Empty Crate Transport', 'Empty Crate Storage', 'Days']
  589. },
  590. saText = [],
  591. bEn = 'Unwrapped,Wooden Crate,Bulk Cargo,Pallet,Other'.indexOf(item.ExpoTypeText) > -1;
  592. oService = oService[bEn ? 'en' : 'zh-TW'];
  593. if (item.ExpoStack) {
  594. saText.push(oService[0]);
  595. }
  596. if (item.ExpoSplit) {
  597. saText.push(oService[1]);
  598. }
  599. if (item.ExpoPack) {
  600. saText.push(oService[2]);
  601. }
  602. if (item.ExpoFeed) {
  603. saText.push(oService[3]);
  604. }
  605. if (item.ExpoStorage) {
  606. saText.push(oService[4] + item.ExpoDays + oService[5]);
  607. }
  608. return saText.join(',');
  609. }
  610. },
  611. {// ╠common.Cost⇒費用╣
  612. name: "SubTotal", title: 'common.Cost', width: 100, align: "right",
  613. itemTemplate: function (val, item) {
  614. return fMoney(val || 0, 0, 'NTD');
  615. }
  616. },
  617. {
  618. type: "control",
  619. modeSwitchButton: false,
  620. editButton: false,
  621. width: 100,
  622. headerTemplate: function () {
  623. return i18next.t('common.Action');
  624. },
  625. itemTemplate: function (val, item) {
  626. var saAction = [$('<a/>', {
  627. html: i18next.t('common.Toolbar_Upd'),// ╠common.Toolbar_Upd⇒修改╣
  628. class: 'a-url',
  629. click: function () {
  630. fnOpenPackingInfo('upd', item);
  631. return false;
  632. }
  633. }), $('<a/>', {
  634. html: i18next.t('common.Toolbar_Del'),// ╠common.Toolbar_Del⇒刪除╣
  635. class: 'a-url delete',
  636. click: function () {
  637. // ╠message.ConfirmToDelete⇒確定要刪除嗎 ?╣ ╠common.Tips⇒提示╣
  638. layer.confirm(i18next.t("message.ConfirmToDelete"), { icon: 3, title: i18next.t('common.Tips') }, function (index) {
  639. oCurData.PackingInfo = Jsonremove(oCurData.PackingInfo, 'Guid', item.Guid);
  640. $.each(oCurData.PackingInfo, function (idx, _item) {
  641. _item.Index = idx + 1;
  642. });
  643. fnTotalSum();
  644. oGrid.loadData();
  645. layer.close(index);
  646. });
  647. }
  648. })];
  649. return $('<div>', { 'style': 'width:100%;text-align: center;' }).append(saAction);
  650. }
  651. }
  652. ],
  653. controller: {
  654. loadData: function (args) {
  655. return {
  656. data: oCurData.PackingInfo,
  657. itemsCount: oCurData.PackingInfo.length //data.length
  658. };
  659. },
  660. insertItem: function (args) {
  661. if (oCostRules.CostRules) {
  662. fnOpenPackingInfo('add');
  663. }
  664. else {
  665. showMsg(i18next.t("PackingOrder_Upd.ExhibitionNO_required")); // ╠PackingOrder_Upd.ExhibitionNO_required⇒請選擇展覽名稱╣
  666. }
  667. },
  668. updateItem: function (args) {
  669. },
  670. deleteItem: function (args) {
  671. }
  672. },
  673. onInit: function (args) {
  674. oGrid = args.grid;
  675. }
  676. });
  677. });
  678. });
  679. $('#ExhibitionNO').on('change', function () {
  680. fnSetImpCusDrop(this.value);
  681. return g_api.ConnectLite(sProgramId, 'GetExhibitionRules', {
  682. Id: this.value
  683. }, function (res) {
  684. if (res.RESULT) {
  685. oCostRules = res.DATA.rel;
  686. oCostRules.CostRules = $.parseJSON(oCostRules.CostRules);
  687. sExhibitionNO = oCostRules.ExhibitionCode;
  688. }
  689. });
  690. });
  691. };
  692. init();
  693. };
  694. require(['base', 'timepicker', 'jsgrid', 'select2', 'formatnumber', 'util'], fnPageInit, 'timepicker');