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.

817 lines
30 KiB

2 years ago
  1. 'use strict';
  2. var sProgramId = getProgramId(),
  3. sQueryPrgId = getQueryPrgId(),
  4. sAction = getUrlParam('Action') || 'Add',
  5. sDataId = getUrlParam('guid'),
  6. sUrlCustomerId = getUrlParam('CustomerId'),
  7. sUrlExhibitionNO = getUrlParam('ExhibitionNO'),
  8. sCheckId = sDataId,
  9. bRefresh = false,
  10. fnPageInit = function () {
  11. /*
  12. * 取得直屬上司資料
  13. */
  14. var setImmediateSupervisorDrop = function (_strCustomerId) {
  15. return g_api.ConnectLite("Contactors_Upd", "GetImmediateSupervisor", {
  16. Guid: sDataId,
  17. CustomerId: _strCustomerId
  18. }, function (res) {
  19. if (res.RESULT) {
  20. let saState = res.DATA.rel;
  21. if (saState.length > 0) {
  22. $('#ImmediateSupervisor').html(createOptions(saState, 'id', 'text', false)).select2();
  23. }
  24. }
  25. });
  26. };
  27. /*
  28. * 取得客戶資料
  29. */
  30. var setCustomerCNameDrop = function () {
  31. return g_api.ConnectLite(Service.sys, 'GetAllCustomerlist', { //"Contactors_Upd", "GetCustomerCName"
  32. //Guid: sDataId
  33. }, function (res) {
  34. if (res.RESULT) {
  35. let saState = res.DATA.rel;
  36. if (saState.length > 0) {
  37. $('#CustomerId').html(createOptions(saState, 'id', 'text', false)).select2();
  38. }
  39. }
  40. });
  41. };
  42. var oGrid = null,
  43. oForm = $('#form_main'),
  44. oGrid1 = null,
  45. oGrid2 = null,
  46. oValidator = null,
  47. oCurData = {},
  48. saGridData = [],
  49. saGridData1 = [],
  50. saGridData2 = [],
  51. saState = [],
  52. saHalls = [],
  53. sCustomerGuid = '',
  54. sContactorName = '',
  55. oBaseQueryPm = {
  56. pageIndex: 1,
  57. pageSize: parent.top.SysSet.GridRecords || 10,
  58. sortField: 'CustomerCName',
  59. sortOrder: 'asc'
  60. },
  61. canDo = new CanDo({
  62. pageInit: function () {
  63. if (getUrlParam('Flag') === 'Pop') {
  64. $('#Toolbar_Leave,#Toolbar_ReAdd,#APIImport').hide();
  65. }
  66. }
  67. }),
  68. /**
  69. * 獲取資料
  70. * @return {Object} Ajax 物件
  71. */
  72. fnGet = function () {
  73. if (sDataId) {
  74. $('#litab2').show();
  75. $('#litab3').show();
  76. return g_api.ConnectLite(sQueryPrgId, "QueryOne",
  77. //return g_api.ConnectLite(sQueryPrgId, ComFn.GetOne,
  78. {
  79. Guid: sDataId
  80. },
  81. function (res) {
  82. if (res.RESULT) {
  83. var oRes = res.DATA.rel;
  84. oCurData = oRes;
  85. sCustomerGuid = oCurData.CustomerId;
  86. sContactorName = oCurData.ContactorName;
  87. //$("#CustomerId").val(oRes.CustomerId);
  88. //console.log(oRes);
  89. //setFormVal(oForm, oCurData);
  90. }
  91. });
  92. } else {
  93. $('#litab2').hide();
  94. $('#litab3').hide();
  95. oCurData.LogoFileId = guid();
  96. if(sUrlCustomerId != '' && sUrlCustomerId != null){
  97. $("#CustomerId").val(sUrlCustomerId);
  98. $('#CustomerId').select2();
  99. $("#CustomerId").prop("disabled", true);
  100. setImmediateSupervisorDrop(sUrlCustomerId);
  101. }
  102. return $.Deferred().resolve().promise();
  103. }
  104. },
  105. /**
  106. * 新增資料
  107. * @param {String} sFlag 新增或儲存後新增
  108. */
  109. fnAdd = function (sFlag) {
  110. var data = getFormSerialize(oForm);
  111. data.LogoFileId = oCurData.LogoFileId;
  112. data.guid = guid();
  113. data.ExhibitionNO = sUrlExhibitionNO;
  114. g_api.ConnectLite("Contactors_Upd", "Add",
  115. data
  116. , function (res) {
  117. if (res.RESULT > 0) {
  118. bRequestStorage = false;
  119. if($("#hiddenIndex").val() === ""){
  120. if (sFlag === 'add') {
  121. showMsgAndGo(i18next.t("message.Save_Success"), sQueryPrgId, '?Action=Upd'); // ╠message.Save_Success⇒新增成功╣
  122. } else {
  123. showMsgAndGo(i18next.t("message.Save_Success"), sQueryPrgId, '?Action=Add'); // ╠message.Save_Success⇒新增成功╣
  124. }
  125. } else {
  126. showMsg(i18next.t("message.Save_Success"), 'success'); //╠message.Save_Success⇒新增成功╣
  127. setTimeout(function () {
  128. parent.layer.close($("#hiddenIndex").val());
  129. }, 1000);
  130. }
  131. } else {
  132. showMsg(i18next.t("message.Save_Failed"), 'error'); // ╠message.Save_Failed⇒新增失敗╣
  133. }
  134. }, function () {
  135. showMsg(i18next.t("message.Save_Failed"), 'error'); // ╠message.Save_Failed⇒新增失敗╣
  136. });
  137. },
  138. /**
  139. * 修改資料
  140. */
  141. fnUpd = function () {
  142. var data = getFormSerialize(oForm);
  143. data.guid = sDataId;
  144. data.LogoFileId = oCurData.LogoFileId;
  145. g_api.ConnectLite("Contactors_Upd", "Upd",
  146. data
  147. , function (res) {
  148. if (res.RESULT > 0) {
  149. bRequestStorage = false;
  150. showMsg(i18next.t("message.Modify_Success"), 'success'); //╠message.Modify_Success⇒修改成功╣
  151. if (window.bLeavePage) {
  152. setTimeout(function () {
  153. pageLeave();
  154. }, 1000);
  155. }
  156. }
  157. else {
  158. showMsg(i18next.t("message.Modify_Failed"), 'error');//╠message.Modify_Failed⇒修改失敗╣
  159. }
  160. }, function () {
  161. showMsg(i18next.t("message.Modify_Failed"), 'error');//╠message.Modify_Failed⇒修改失敗╣
  162. });
  163. },
  164. /**
  165. * 資料刪除
  166. */
  167. fnDel = function () {
  168. return g_api.ConnectLite("Contactors_Upd", "Delete",
  169. {
  170. Guid: sDataId
  171. }, function (res) {
  172. if (res.RESULT > 0) {
  173. if($("#hiddenIndex").val() === ""){
  174. showMsgAndGo(i18next.t("message.Delete_Success"), sQueryPrgId); // ╠message.Delete_Success⇒刪除成功╣
  175. } else {
  176. showMsg(i18next.t("message.Delete_Success"), 'success'); //╠message.Delete_Success⇒刪除成功╣
  177. setTimeout(function () {
  178. parent.layer.close($("#hiddenIndex").val());
  179. }, 1000);
  180. }
  181. }
  182. else {
  183. showMsg(i18next.t("message.Delete_Failed"), 'error'); // ╠message.Delete_Failed⇒刪除失敗╣
  184. }
  185. }, function () {
  186. showMsg(i18next.t("message.Delete_Failed"), 'error'); // ╠message.Delete_Failed⇒刪除失敗╣
  187. });
  188. },
  189. /**
  190. * 取得 展覽已成交 資料
  191. */
  192. fnGetGridData = function (flag) {
  193. if (sDataId) {
  194. return g_api.ConnectLite(sProgramId, 'GetDealExhibitionlist', {
  195. guid: sDataId
  196. });
  197. }
  198. else {
  199. return $.Deferred().resolve().promise();
  200. }
  201. },
  202. /**
  203. * 取得 展覽未成交 資料
  204. */
  205. fnGetGridData1 = function (flag) {
  206. if (sDataId) {
  207. return g_api.ConnectLite(sProgramId, 'GetUnDealExhibitionlist', {
  208. guid: sDataId
  209. });
  210. }
  211. else {
  212. return $.Deferred().resolve().promise();
  213. }
  214. },
  215. /**
  216. * 抓去客訴列表資料
  217. * @return {Object} ajax物件
  218. */
  219. fnGetGridData2 = function () {
  220. if (sDataId) {
  221. return g_api.ConnectLite(sProgramId, 'GetComplaintlist', {
  222. CustomerId: sCustomerGuid,
  223. ContactorName: sContactorName
  224. });
  225. }
  226. else {
  227. return $.Deferred().resolve().promise();
  228. }
  229. },
  230. /**
  231. * 同步新更新行事曆和outlook
  232. * @param {Object}_data 序列化資料
  233. */
  234. fnSynChronousCalendar = function (_data) {
  235. var data = {};
  236. data.CalType = '04';//展覽
  237. data.Title = _data.ExhibitioShotName_TW;
  238. data.Description = _data.Exhibitioname_TW + '(' + _data.Exhibitioname_EN + ') ' + _data.Memo;
  239. data.StartDate = _data.ExhibitionDateStart;
  240. data.EndDate = _data.ExhibitionDateEnd;
  241. data.Color = parent.UserInfo.CalColor;
  242. data.RelationId = _data.ExhibitionCode;
  243. data.GroupMembers = '';
  244. data.Importment = 'M';
  245. data.OpenMent = 'C';
  246. data.AllDay = '0';
  247. g_api.ConnectLite('Calendar', ComFn.GetAdd, data,
  248. function (res) {
  249. if (res.RESULT) {
  250. var sNo = res.DATA.rel;
  251. if (parent.Outklook) {
  252. outlookAPI(outlook.Calendar_Add, {
  253. NO: sNo,
  254. ResponseRequested: false
  255. });
  256. }
  257. }
  258. });
  259. },
  260. /**
  261. * ToolBar 按鈕事件 function
  262. * @param {Object}inst 按鈕物件對象
  263. * @param {Object} e 事件對象
  264. */
  265. fnButtonHandler = function (inst, e) {
  266. var sId = inst.id;
  267. switch (sId) {
  268. case "Toolbar_Qry":
  269. break;
  270. case "Toolbar_Save":
  271. $('#file_hidden').val($('li.jFiler-item').length || '');
  272. if (!$("#form_main").valid()) {
  273. oValidator.focusInvalid();
  274. return;
  275. }
  276. if (sAction === 'Add') {
  277. fnAdd('add');
  278. } else {
  279. fnUpd();
  280. }
  281. break;
  282. case "Toolbar_ReAdd":
  283. $('#file_hidden').val($('li.jFiler-item').length || '');
  284. if (!$("#form_main").valid()) {
  285. oValidator.focusInvalid();
  286. return;
  287. }
  288. fnAdd('readd');
  289. break;
  290. case "Toolbar_Clear":
  291. clearPageVal();
  292. break;
  293. case "Toolbar_Leave":
  294. pageLeave();
  295. break;
  296. case "Toolbar_Add":
  297. break;
  298. case "Toolbar_Upd":
  299. break;
  300. case "Toolbar_Copy":
  301. break;
  302. case "Toolbar_Del": // ╠message.ConfirmToDelete⇒確定要刪除嗎 ?╣ ╠common.Tips⇒提示╣
  303. layer.confirm(i18next.t("message.ConfirmToDelete"), { icon: 3, title: i18next.t('common.Tips') }, function (index) {
  304. fnDel();
  305. layer.close(index);
  306. });
  307. break;
  308. case "Toolbar_Imp":
  309. break;
  310. case "Toolbar_Transfer":
  311. fnTransfer();
  312. break;
  313. default:
  314. alert("No handle '" + sId + "'");
  315. break;
  316. }
  317. },
  318. /**
  319. * 目的 對應正式客戶
  320. * @param {String}item 預約單資料
  321. */
  322. fnCorrespondFormalCus = function (item) {
  323. layer.open({
  324. type: 1, //0(信息框,默认)1(页面层)2(iframe层)3(加载层)4(tips层)
  325. title: '新增至展覽名單', // ╠common.CorrespondImpCus⇒對應正式客戶╣
  326. area: '640px;',//寬度
  327. shade: 0.75,//遮罩
  328. closeBtn: 1,
  329. //maxmin: true, //开启最大化最小化按钮
  330. id: 'layer_Correspond', //设定一个id,防止重复弹出
  331. offset: '100px',//右下角弹出
  332. anim: 0,//彈出動畫
  333. btn: [i18next.t('common.Confirm'), i18next.t('common.Cancel')],//╠common.Confirm⇒確定╣╠common.Cancel⇒取消╣
  334. btnAlign: 'c',//按鈕位置
  335. content: '<style>.select2-container{z-index: 39891015;}</style><div class="form-group">\
  336. <div class="col-sm-12">\
  337. <span>請選擇新增展覽名稱</span><span></span>\
  338. </div>\
  339. <div class="col-sm-12">\
  340. <select class= "form-control w95p" id="ExhibitionCode" name="ExhibitionCode"></select>\
  341. </div>\
  342. </div >',
  343. success: function (layero, index) {
  344. fnSetEpoDrop({
  345. Select: $('#ExhibitionCode'),
  346. Select2: true
  347. });
  348. },
  349. yes: function (index, layero) {
  350. var sExhibitionNO = $('#ExhibitionCode').val();
  351. var sCustomerId = $('#CustomerId').val();
  352. if (!sExhibitionNO) {
  353. showMsg(i18next.t('message.SelectFormalCus'));//╠message.SelectFormalCus⇒請選擇對應的客戶╣
  354. return false;
  355. }
  356. g_api.ConnectLite('Contactors_Upd', 'InsertExhibitionList', {
  357. ExhibitionNO: sExhibitionNO,
  358. CustomerId: sCustomerId,
  359. ContactorId: sDataId
  360. }, function (res) {
  361. if (res.RESULT) {
  362. oGrid.loadData();
  363. oGrid1.loadData();
  364. showMsg(i18next.t("message.Save_Success"), 'success'); // ╠message.Save_Success⇒新增成功╣
  365. layer.close(index);
  366. }
  367. else {
  368. showMsg(res.MSG, 'error');
  369. }
  370. }, function () {
  371. showMsg(i18next.t("message.Save_Failed"), 'error'); // ╠message.Save_Failed⇒新增失敗╣
  372. });
  373. }
  374. });
  375. },
  376. /**
  377. * 初始化 function
  378. */
  379. init = function () {
  380. var saCusBtns = null;
  381. $('#State,#Industry,#ExhibitionDate').prop('required', true);
  382. $('.ShowNames').hide();
  383. if (parent.OrgID === 'TG') {
  384. $('#CostRulesId,#State,#ExhibitionAddress,#ExhibitionDate,#file_hidden').prop('required', true);
  385. $('#notte').show();
  386. $('.simp-box').hide();
  387. }
  388. else {
  389. $('.costrules').hide();
  390. }
  391. if (sAction === 'Upd') {
  392. saCusBtns = [{
  393. id: 'Toolbar_Transfer',
  394. value: 'common.Toolbar_Transfer'// ╠common.Toolbar_Transfer⇒拋轉╣
  395. }];
  396. $("#CustomerId").prop("disabled", true);
  397. }
  398. commonInit({
  399. PrgId: sProgramId,
  400. ButtonHandler: fnButtonHandler,
  401. Buttons: saCusBtns,
  402. GoTop: true,
  403. tabClick: function (el) {
  404. console.log(el.id);
  405. switch (el.id) {
  406. case 'litab2':
  407. if (!$(el).data('action')) {
  408. oGrid.loadData();
  409. oGrid1.loadData();
  410. }
  411. break;
  412. case 'litab3':
  413. if (!$(el).data('action')) {
  414. oGrid2.loadData();
  415. }
  416. break;
  417. }
  418. $(el).data('action', true);
  419. }
  420. });
  421. $.whenArray([
  422. setCustomerCNameDrop()
  423. ])
  424. .done(function (res) {
  425. if (res && res.RESULT === 1) {
  426. var oRes = res.DATA.rel,
  427. sDateRange = '';
  428. oCurData = oRes;
  429. oCurData.LogoFileId = oCurData.LogoFileId || guid();
  430. setFormVal(oForm, oCurData);
  431. /* if (sTab) {
  432. $('#litab3 a').click();
  433. } */
  434. if(sAction == "Add"){
  435. fnGet().done(function (resDetail) {
  436. if (resDetail && resDetail.RESULT === 1) {
  437. var oresDetail = resDetail.DATA.rel,
  438. oDetailData = oresDetail;
  439. oDetailData.LogoFileId = oDetailData.LogoFileId || guid();
  440. setFormVal(oForm, oDetailData);
  441. }
  442. });
  443. } else if(sAction=="Upd") {
  444. setImmediateSupervisorDrop().done(function (){
  445. fnGet().done(function (resDetail) {
  446. if (resDetail && resDetail.RESULT === 1) {
  447. var oresDetail = resDetail.DATA.rel,
  448. oDetailData = oresDetail;
  449. oDetailData.LogoFileId = oDetailData.LogoFileId || guid();
  450. setFormVal(oForm, oDetailData);
  451. }
  452. });
  453. });
  454. }
  455. }
  456. //select2Init();
  457. });
  458. oValidator = $("#form_main").validate({
  459. ignore: ''
  460. });
  461. var iHeight = $('body').height() - $('.page-title').height() - $('#searchbar').height() - 150;
  462. $("#jsGrid").jsGrid({
  463. width: "100%",
  464. height: "auto",
  465. autoload: true,
  466. filtering: false,
  467. pageLoading: true,
  468. inserting: false,
  469. editing: false,
  470. sorting: false,
  471. paging: false,
  472. pageIndex: 1,
  473. pageSize: parent.top.SysSet.GridRecords || 10,
  474. confirmDeleting: true,
  475. deleteConfirm: i18next.t('message.ConfirmToDelete'),// ╠message.ConfirmToDelete⇒確定要刪除嗎 ?╣
  476. pagePrevText: "<",
  477. pageNextText: ">",
  478. pageFirstText: "<<",
  479. pageLastText: ">>",
  480. rowClick: function (args) {
  481. /* if (navigator.userAgent.match(/mobile/i)) {
  482. goToEdit('Customers_Upd', '?Action=Upd&guid=' + args.item.guid);
  483. } */
  484. },
  485. rowDoubleClick: function (args) {
  486. //parent.openPageTab('Customers_Upd', '?Action=Upd&guid=' + args.item.guid);
  487. },
  488. fields: [
  489. {
  490. name: "RowIndex", title: 'common.RowNumber', width: 50, align: "center"
  491. },
  492. {
  493. type: "control", title: '查詢單號', itemTemplate: function (val, item) {
  494. var iTips = 0,
  495. sTipsHtml = '<div class="layui-layer-btn-c">' + '查詢單號' + '</div>',
  496. saRefNumber = item.RefNumber.split(','),
  497. oOption = {
  498. btnAlign: 'c',
  499. time: 600000 //一個小時(如果不配置,默认是3秒)
  500. },
  501. oTips = $('<span>', {
  502. 'class': 'glyphicon glyphicon-info-sign',
  503. 'aria-hidden': true
  504. }).on({
  505. click: function () {
  506. oOption.btn = [i18next.t("common.Close")];// ╠common.Close⇒關閉╣
  507. layer.msg(sTipsHtml, oOption);
  508. },
  509. mouseenter: function (event) {
  510. delete oOption.btn;
  511. iTips = layer.msg(sTipsHtml, oOption);
  512. },
  513. mouseleave: function (event) {
  514. layer.close(iTips);
  515. }
  516. });
  517. if (saRefNumber.length > 0) {
  518. sTipsHtml += '<ul class="bill-status">';
  519. $.each(saRefNumber, function (idx, data) {
  520. let saData = data.split(';');
  521. let sDataType = saData[0];
  522. let sGuid = saData[1];
  523. let sDataContent = saData[2];
  524. let sTypeName = "";
  525. let sOnClick = "onclick=''";
  526. switch(sDataType){
  527. case "1":
  528. sTypeName = "進口:";
  529. sOnClick = "onclick='parent.openPageTab(\"ExhibitionImport_Upd\",\"?Action=Upd&ImportBillNO=" + sGuid + "\")'";
  530. break;
  531. case "2":
  532. sTypeName = "出口:";
  533. sOnClick = "onclick='parent.openPageTab(\"ExhibitionExport_Upd\",\"?Action=Upd&GoTab=2&ExportBillNO=" + sGuid + "\")'";
  534. break;
  535. case "3":
  536. sTypeName = "其他:";
  537. sDataContent = sDataContent.substring(0,10);
  538. sOnClick = "onclick='parent.openPageTab(\"OtherBusiness_Upd\",\"?Action=Upd&ImportBillNO=" + sGuid + "\")'";
  539. break;
  540. case "4":
  541. sTypeName = "其他駒驛:";
  542. sDataContent = sDataContent.substring(0,10);
  543. sOnClick = "onclick='parent.openPageTab(\"OtherExhibitionTG_Upd\",\"?Action=Upd&GoTab=2&Guid=" + sGuid + "\")'";
  544. break;
  545. }
  546. sTipsHtml += "<li><a class='gopagetab' " + sOnClick + "><div>" + sTypeName + sDataContent + "</div></a></li>";
  547. });
  548. sTipsHtml += '</ul>';
  549. oOption.area = ['300px'];
  550. /* if (saRefNumber.length > 15) {
  551. oOption.area = ['550px', '500px'];
  552. } */
  553. }
  554. else {
  555. sTipsHtml = '<div></div>';
  556. }
  557. oTips.css('color', 'blue');
  558. return oTips;
  559. }
  560. },
  561. {
  562. name: "ExhibitioShotName_TW", title: 'Exhibition_Upd.ExhibitioShotName_TW', type: "text", width: 120
  563. },
  564. {
  565. name: "Exhibitioname_TW", title: 'Exhibition_Upd.Exhibitioname_TW', type: "text", width: 180
  566. },
  567. {
  568. name: "Exhibitioname_EN", title: 'Exhibition_Upd.Exhibitioname_EN', type: "text", width: 180
  569. },
  570. {
  571. name: "ExhibitionDateStart", title: 'Exhibition_Upd.ExhibitionDateRange', type: "text", align: "center", width: 150, itemTemplate: function (val, item) {
  572. var sDateRange = newDate(item.ExhibitionDateStart, 'date', true) + '~' + newDate(item.ExhibitionDateEnd, 'date', true);
  573. return sDateRange === '~' ? '' : sDateRange;
  574. }
  575. },
  576. {
  577. name: "CreateUser", title: '創建人', width: 150
  578. }
  579. ],
  580. controller: {
  581. loadData: function (args) {
  582. return fnGetGridData();
  583. },
  584. insertItem: function (args) {
  585. },
  586. updateItem: function (args) {
  587. },
  588. deleteItem: function (args) {
  589. }
  590. },
  591. onInit: function (args) {
  592. oGrid = args.grid;
  593. }
  594. });
  595. $("#jsGrid1").jsGrid({
  596. width: "100%",
  597. height: "auto",
  598. autoload: true,
  599. filtering: false,
  600. pageLoading: true,
  601. inserting: false,
  602. editing: false,
  603. sorting: false,
  604. paging: false,
  605. pageIndex: 1,
  606. pageSize: parent.top.SysSet.GridRecords || 10,
  607. confirmDeleting: true,
  608. deleteConfirm: i18next.t('message.ConfirmToDelete'),// ╠message.ConfirmToDelete⇒確定要刪除嗎 ?╣
  609. pagePrevText: "<",
  610. pageNextText: ">",
  611. pageFirstText: "<<",
  612. pageLastText: ">>",
  613. rowClick: function (args) {
  614. /* if (navigator.userAgent.match(/mobile/i)) {
  615. goToEdit('Customers_Upd', '?Action=Upd&guid=' + args.item.guid);
  616. } */
  617. },
  618. rowDoubleClick: function (args) {
  619. //parent.openPageTab('Customers_Upd', '?Action=Upd&guid=' + args.item.guid);
  620. },
  621. fields: [
  622. {
  623. name: "RowIndex", title: 'common.RowNumber', width: 50, align: "center"
  624. },
  625. {
  626. name: "RefNumber", title: '查詢號碼', width: 200
  627. },
  628. {
  629. name: "ExhibitioShotName_TW", title: 'Exhibition_Upd.ExhibitioShotName_TW', type: "text", width: 120
  630. },
  631. {
  632. name: "Exhibitioname_TW", title: 'Exhibition_Upd.Exhibitioname_TW', type: "text", width: 180
  633. },
  634. {
  635. name: "Exhibitioname_EN", title: 'Exhibition_Upd.Exhibitioname_EN', type: "text", width: 180
  636. },
  637. {
  638. name: "ExhibitionDateStart", title: 'Exhibition_Upd.ExhibitionDateRange', type: "text", align: "center", width: 150, itemTemplate: function (val, item) {
  639. var sDateRange = newDate(item.ExhibitionDateStart, 'date', true) + '~' + newDate(item.ExhibitionDateEnd, 'date', true);
  640. return sDateRange === '~' ? '' : sDateRange;
  641. }
  642. },
  643. {
  644. name: "CreateUser", title: '創建人', width: 150
  645. }
  646. ],
  647. controller: {
  648. loadData: function (args) {
  649. return fnGetGridData1();
  650. },
  651. insertItem: function (args) {
  652. },
  653. updateItem: function (args) {
  654. },
  655. deleteItem: function (args) {
  656. }
  657. },
  658. onInit: function (args) {
  659. oGrid1 = args.grid;
  660. }
  661. });
  662. $("#jsGrid2").jsGrid({
  663. width: "100%",
  664. height: "auto",
  665. autoload: true,
  666. filtering: false,
  667. pageLoading: true,
  668. inserting: false,
  669. editing: false,
  670. sorting: false,
  671. paging: false,
  672. pageIndex: 1,
  673. pageSize: parent.top.SysSet.GridRecords || 10,
  674. confirmDeleting: true,
  675. deleteConfirm: i18next.t('message.ConfirmToDelete'),// ╠message.ConfirmToDelete⇒確定要刪除嗎 ?╣
  676. pagePrevText: "<",
  677. pageNextText: ">",
  678. pageFirstText: "<<",
  679. pageLastText: ">>",
  680. rowDoubleClick: function (args) {
  681. if ('A,C'.indexOf(args.item.DataType) > -1 && args.item.CreateUser === parent.UserID) {
  682. parent.openPageTab('Complaint_Upd', '?Action=Upd&Guid=' + args.item.Guid);
  683. }
  684. else {
  685. parent.openPageTab('Complaint_View', '?Action=Upd&Guid=' + args.item.Guid);
  686. }
  687. },
  688. fields: [
  689. {
  690. name: "RowIndex", title: 'common.RowNumber', width: 50, align: "center"
  691. },
  692. {
  693. name: "ComplaintNumber", title: '個案代號', width: 200
  694. },
  695. {
  696. name: "ExhibitioShotName_TW", title: 'Exhibition_Upd.ExhibitioShotName_TW', type: "text", width: 120
  697. },
  698. {
  699. name: "ExhibitionName", title: 'Exhibition_Upd.Exhibitioname_TW', type: "text", width: 180
  700. },
  701. {
  702. name: "ComplaintType", title: '類型', type: "text", width: 180, itemTemplate: function (val, item) {
  703. let strComplaintType = "";
  704. switch(val){
  705. case "1":
  706. strComplaintType = "貨損";
  707. break;
  708. case "2":
  709. strComplaintType = "延誤";
  710. break;
  711. case "3":
  712. strComplaintType = "遺失";
  713. break;
  714. case "4":
  715. strComplaintType = "抱怨";
  716. break;
  717. }
  718. return strComplaintType;
  719. }
  720. },
  721. {
  722. name: "Description", title: '內容', type: "text", width: 180
  723. },
  724. {
  725. name: "CreateUser", title: '創建人', width: 150
  726. }
  727. ],
  728. controller: {
  729. loadData: function (args) {
  730. return fnGetGridData2();
  731. },
  732. insertItem: function (args) {
  733. },
  734. updateItem: function (args) {
  735. },
  736. deleteItem: function (args) {
  737. }
  738. },
  739. onInit: function (args) {
  740. oGrid2 = args.grid;
  741. }
  742. });
  743. $('#InsertExhibitionsList').click(function () {
  744. fnCorrespondFormalCus();
  745. return false;
  746. });
  747. $('#InsertComplaint').click(function () {
  748. //alert(encodeURIComponent(sContactorName));
  749. parent.top.openPageTab('Complaint_Upd', '?Action=Add&CustomerId=' + sCustomerGuid + '&ContactorName=' + btoa(encodeURI(sContactorName)));
  750. return false;
  751. });
  752. $('#CustomerId').change(function () {
  753. if(sAction == "Add"){
  754. setImmediateSupervisorDrop($(this).val());
  755. return false;
  756. }
  757. });
  758. };
  759. init();
  760. };
  761. require(['base', 'select2', 'jsgrid', 'daterangepicker', 'convetlng', 'filer', 'ajaxfile', 'util','cando'], fnPageInit, 'daterangepicker');