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.

1017 lines
40 KiB

2 years ago
  1. 'use strict';
  2. var sProgramId = getProgramId(),
  3. sQueryPrgId = getQueryPrgId(),
  4. sAction = getUrlParam('Action') || 'Add',
  5. sDataId = getUrlParam('SN'),
  6. sCheckId = sDataId,
  7. bRefresh = false,
  8. fnPageInit = function () {
  9. var oGrid = null,
  10. oForm = $('#form_main'),
  11. oValidator = null,
  12. oCurData = {},
  13. sCustomersOptionsHtml = '',
  14. saGridData = [],
  15. saHalls = [],
  16. saCustomers = [],
  17. oBaseQueryPm = {
  18. pageIndex: 1,
  19. pageSize: parent.top.SysSet.GridRecords || 10,
  20. sortField: 'SN',
  21. sortOrder: 'asc'
  22. },
  23. /**
  24. * 獲取資料
  25. * @return {Object} Ajax 物件
  26. */
  27. fnGet = function () {
  28. if (sDataId) {
  29. $(".editbox").show();
  30. return g_api.ConnectLite(sQueryPrgId, "QueryOne",
  31. {
  32. SN: sDataId
  33. }, function (res) {
  34. if (res.RESULT) {
  35. var oRes = res.DATA.rel;
  36. oCurData = oRes;
  37. $("#CaseName").val(oRes.CaseName);
  38. $("#ExhibitionNO").val(oRes.ExhibitionNO);
  39. $("#ExhibitionNO").change();
  40. }
  41. });
  42. } else {
  43. oCurData.LogoFileId = guid();
  44. $(".editbox").hide();
  45. return $.Deferred().resolve().promise();
  46. }
  47. },
  48. /**
  49. * 新增資料
  50. * @param {String} sFlag 新增或儲存後新增
  51. */
  52. fnAdd = function (sFlag) {
  53. var data = getFormSerialize(oForm);
  54. data = packParams(data);
  55. data.OrgID = parent.OrgID;
  56. data.LogoFileId = oCurData.LogoFileId;
  57. g_api.ConnectLite("SatisfactionCase_Upd", "Add",
  58. data
  59. , function (res) {
  60. if (res.RESULT) {
  61. //data.ExhibitionCode = res.DATA.rel;
  62. showMsgAndGo(i18next.t("message.Save_Success"), sProgramId, '?Action=Upd&SN=' + res.DATA.rel); // ╠message.Save_Success⇒新增成功╣
  63. /*
  64. CallAjax(ComFn.W_Com, ComFn.GetAdd, {
  65. Params: { exhibition: data }
  66. }, function (res1) {
  67. if (res1.d > 0) {
  68. bRequestStorage = false;
  69. if (sFlag === 'add') {
  70. CallAjax(ComFn.W_Com, ComFn.GetOne, {
  71. Type: '',
  72. Params: {
  73. exhibition: {
  74. ExhibitionCode: data.ExhibitionCode
  75. },
  76. }
  77. }, function (res2) {
  78. var oRes = $.parseJSON(res2.d);
  79. showMsgAndGo(i18next.t("message.Save_Success"), sProgramId, '?Action=Upd&SN=' + oRes.SN); // ╠message.Save_Success⇒新增成功╣
  80. });
  81. }
  82. else {
  83. showMsgAndGo(i18next.t("message.Save_Success"), sProgramId, '?Action=Add'); // ╠message.Save_Success⇒新增成功╣
  84. }
  85. if (data.ExhibitionDateStart && data.ExhibitionDateEnd) {
  86. //如果展覽時間不為空的話就同步更新至行事曆和outlook中
  87. fnSynChronousCalendar(data);
  88. }
  89. }
  90. else {
  91. showMsg(i18next.t("message.Save_Failed"), 'error'); // ╠message.Save_Failed⇒新增失敗╣
  92. }
  93. }, function () {
  94. showMsg(i18next.t("message.Save_Failed"), 'error'); // ╠message.Save_Failed⇒新增失敗╣
  95. });*/
  96. }
  97. else {
  98. showMsg(i18next.t('message.CreateBill_Failed') + '<br>' + res.MSG, 'error'); // ╠message.CreateBill_Failed⇒帳單新增失敗╣
  99. }
  100. }, function () {
  101. showMsg(i18next.t('message.CreateBill_Failed'), 'error'); // ╠message.CreateBill_Failed⇒帳單新增失敗╣
  102. });
  103. },
  104. /**
  105. * 檢查名稱
  106. */
  107. fnCheckNameThenAction = function (Type) {
  108. return g_api.ConnectLite(sProgramId, 'CheckExhibitionName', {
  109. Type: Type,
  110. SN: getUrlParam('SN') ,
  111. Exhibitioname_TW: $('#Exhibitioname_TW').val() ? $('#Exhibitioname_TW').val(): "",
  112. ExhibitioShotName_TW: $('#ExhibitioShotName_TW').val() ? $('#ExhibitioShotName_TW').val() : ""
  113. }, function (res) {
  114. if (!res.MSG) {
  115. switch (Type) {
  116. case "add":
  117. case "readd":
  118. fnAdd(Type);
  119. break;
  120. case "upd":
  121. fnUpd();
  122. break;
  123. default:
  124. break;
  125. }
  126. }
  127. else {
  128. showMsg(res.MSG, 'error');
  129. }
  130. }, function () {
  131. showMsg("未知錯誤,請聯絡資訊人員", 'error');// ╠message.Transfer_Failed⇒拋轉失敗╣
  132. });
  133. },
  134. /**
  135. * 修改資料
  136. */
  137. fnUpd = function () {
  138. //var data = getFormSerialize(oForm);
  139. //data = packParams(data, 'upd');
  140. /* CallAjax(ComFn.W_Com, ComFn.GetUpd, {
  141. Params: {
  142. contactors: {
  143. values: data,
  144. keys: { SN: sDataId }
  145. }
  146. } */
  147. g_api.ConnectLite(sProgramId, 'UpdateCase', {
  148. SN: sDataId,
  149. CaseName: $('#CaseName').val() ? $('#CaseName').val(): "",
  150. ExhibitionNO: $('#ExhibitionNO').val() ? $('#ExhibitionNO').val() : ""
  151. }, function (res) {
  152. if (res.RESULT) {
  153. bRequestStorage = false;
  154. showMsg(i18next.t("message.Modify_Success"), 'success'); //╠message.Modify_Success⇒修改成功╣
  155. if (window.bLeavePage) {
  156. setTimeout(function () {
  157. pageLeave();
  158. }, 1000);
  159. }
  160. }
  161. else {
  162. showMsg(i18next.t("message.Modify_Failed"), 'error');//╠message.Modify_Failed⇒修改失敗╣
  163. }
  164. }, function () {
  165. showMsg(i18next.t("message.Modify_Failed"), 'error');//╠message.Modify_Failed⇒修改失敗╣
  166. });
  167. },
  168. /**
  169. * 資料刪除
  170. */
  171. fnDel = function () {
  172. return g_api.ConnectLite(sProgramId, 'Delete', {
  173. SN: sDataId
  174. }, function (res) {
  175. if (res.RESULT > 0) {
  176. showMsgAndGo(i18next.t("message.Delete_Success"), sQueryPrgId); // ╠message.Delete_Success⇒刪除成功╣
  177. }
  178. else {
  179. showMsg(i18next.t("message.Delete_Failed"), 'error'); // ╠message.Delete_Failed⇒刪除失敗╣
  180. }
  181. }, function () {
  182. showMsg(i18next.t("message.Delete_Failed"), 'error'); // ╠message.Delete_Failed⇒刪除失敗╣
  183. });
  184. },
  185. /**
  186. * 抓取滿意度列表資料
  187. * @param {String} flag 是否匯出
  188. * @return {Object} ajax物件
  189. */
  190. fnGetGridData = function (flag) {
  191. if (sDataId) {
  192. return g_api.ConnectLite(sProgramId, 'GetSatisfactionList', {
  193. SN: sDataId,
  194. Flag: flag,
  195. pageIndex:oBaseQueryPm.pageIndex,
  196. pageSize: oBaseQueryPm.pageSize,
  197. sortField: 'SN',
  198. sortOrder: 'asc'
  199. }, function (res) {
  200. if (res.RESULT) {
  201. if (flag === 'export') {
  202. DownLoadFile(res.DATA.rel, oCurData.Exhibitioname_TW);
  203. }
  204. else {
  205. saGridData = res.DATA.rel;
  206. }
  207. }
  208. });
  209. }
  210. else {
  211. return $.Deferred().resolve().promise();
  212. }
  213. },
  214. /**
  215. * 重新比對
  216. */
  217. fnCompareDB = function (){
  218. if (sDataId) {
  219. return g_api.ConnectLite(sProgramId, 'CompareDB', {
  220. SN: sDataId,
  221. pageIndex:oBaseQueryPm.pageIndex,
  222. pageSize: oBaseQueryPm.pageSize,
  223. sortField: 'SN',
  224. sortOrder: 'asc'
  225. }, function (res) {
  226. if (res.RESULT) {
  227. saGridData = res.DATA.rel;
  228. }
  229. });
  230. } else {
  231. return $.Deferred().resolve().promise();
  232. }
  233. },
  234. /**
  235. * 刪除滿意度案件客戶資料
  236. */
  237. fnDelSatisfactionCustomer = function (_args){
  238. if (_args.SN) {
  239. return g_api.ConnectLite(sProgramId, 'DeleteSatisfactionCustomer', {
  240. SN: _args.SN,
  241. }, function (res) {
  242. if (res.RESULT > 0) {
  243. showMsg(i18next.t("message.Delete_Success"), 'success'); // ╠message.Delete_Success⇒刪除成功╣
  244. }
  245. else {
  246. showMsg(i18next.t("message.Delete_Failed"), 'error'); // ╠message.Delete_Failed⇒刪除失敗╣
  247. }
  248. });
  249. } else {
  250. return $.Deferred().resolve().promise();
  251. }
  252. },
  253. fnImportFile = function () {
  254. $('#importfile').val('').off('change').on('change', function () {
  255. if (this.value.indexOf('.csv') > -1 || this.value.indexOf('.CSV') > -1) {
  256. var sFileId = guid(),
  257. sFileName = this.value;
  258. $.ajaxFileUpload({
  259. url: '/Controller.ashx?action=importfile&FileId=' + sFileId,
  260. secureuri: false,
  261. fileElementId: 'importfile',
  262. success: function (data, status) {
  263. g_api.ConnectLite(sProgramId, 'ImportFile', {
  264. FileId: sFileId,
  265. FileName: sFileName,
  266. SN: sDataId
  267. }, function (res) {
  268. if (res.RESULT) {
  269. fnCompareDB();
  270. oGrid.loadData();
  271. }
  272. else {
  273. showMsg(i18next.t('message.ProgressError') + '<br>' + res.MSG, 'error'); // ╠message.ProgressError⇒資料處理異常╣
  274. }
  275. }, function () {
  276. showMsg(i18next.t("message.ProgressError"), 'error'); // ╠message.ProgressError⇒資料處理異常╣
  277. });
  278. },
  279. error: function (data, status, e) {
  280. showMsg(i18next.t("message.ProgressError"), 'error'); // ╠message.ProgressError⇒資料處理異常╣
  281. }
  282. });
  283. bRequestStorage = true;
  284. }
  285. else {
  286. showMsg(i18next.t("message.FileTypeError"), 'error'); // ╠message.FileTypeError⇒文件格式錯誤╣
  287. }
  288. }).click();
  289. },
  290. fnGetSatisfactionCaseData = function (_SN) {
  291. return g_api.ConnectLite(sProgramId, 'GetSatisfactionCaseData', {
  292. SN: _SN,
  293. }, function (res) {
  294. var oRes = res.DATA.rel;
  295. layer.open({
  296. type: 1, //0(信息框,默认)1(页面层)2(iframe层)3(加载层)4(tips层)
  297. title: "滿意度問卷", // ╠common.CorrespondImpCus⇒對應正式客戶╣
  298. area: ['40%', '90%'],//寬度
  299. shade: 0.75,//遮罩
  300. closeBtn: 1,
  301. //maxmin: true, //开启最大化最小化按钮
  302. id: 'layer_SatisfactionCaseData', //设定一个id,防止重复弹出
  303. offset: '10px',//右下角弹出
  304. anim: 0,//彈出動畫
  305. btn: ['儲存', i18next.t('common.Cancel')],//╠common.Confirm⇒確定╣╠common.Cancel⇒取消╣
  306. btnAlign: 'c',//按鈕位置
  307. content: '<div class="pop-box row w100p">\
  308. <label class="col-sm-3 control-label" for="input-Default">\
  309. <span data-i18n="">客戶名稱</span><span></span>\
  310. </label>\
  311. <div class="col-sm-8">\
  312. <input type="text" maxlength="50" id="CustomerName" name="CustomerName" class="form-control w100p" placeholderid="" value="' + oRes.CustomerName + '">\
  313. </div>\
  314. </div>\
  315. <div class="pop-box row w100p">\
  316. <label class="col-sm-3 control-label" for="input-Default">\
  317. <span data-i18n="">填寫人</span><span></span>\
  318. </label>\
  319. <div class="col-sm-8">\
  320. <input type="text" maxlength="50" id="FillerName" name="FillerName" class="form-control w100p" placeholderid="" value="' + oRes.FillerName + '">\
  321. </div>\
  322. </div>\
  323. <div class="pop-box row w100p">\
  324. <label class="col-sm-3 control-label" for="input-Default">\
  325. <span data-i18n="">填寫人電子郵件</span><span></span>\
  326. </label>\
  327. <div class="col-sm-8">\
  328. <input type="text" maxlength="50" id="Email" name="Email" class="form-control w100p" placeholderid="" value="' + oRes.Email + '">\
  329. </div>\
  330. </div>\
  331. <div class="pop-box row w100p">\
  332. <label class="col-sm-3 control-label" for="input-Default">\
  333. <span data-i18n="">填寫人聯絡電話</span><span></span>\
  334. </label>\
  335. <div class="col-sm-8">\
  336. <input type="text" maxlength="50" id="Phone" name="Phone" class="form-control w100p" placeholderid="" value="' + oRes.Phone + '">\
  337. </div>\
  338. </div>\
  339. <div class="pop-box row w100p">\
  340. <label class="col-sm-3 control-label" for="input-Default">\
  341. <span data-i18n="">備註</span><span></span>\
  342. </label>\
  343. <div class="col-sm-8">\
  344. <textarea name="Memo" id="Memo" class="form-control" rows="3">' + oRes.Memo + '</textarea>\
  345. </div>\
  346. </div>\
  347. <hr>\
  348. <div>\
  349. <table class="w80p text-left" style="border:1px #cccccc solid;margin-Left:10%;font-size:14px"><thead></thead>\
  350. <tbody>\
  351. <tr>\
  352. <td class="col-sm-7" style="border:1px #cccccc solid;">奕達提供整體服務品質的滿意度</td>\
  353. <td class="col-sm-5" style="border:1px #cccccc solid;"><div id="Feild01">' + oRes.Feild01 + '</div></td>\
  354. </tr>\
  355. <tr>\
  356. <td class="col-sm-7" style="border:1px #cccccc solid;">奕達提供的價格是否合理</td>\
  357. <td class="col-sm-5" style="border:1px #cccccc solid;"><div id="Feild02">' + oRes.Feild02 + '</div></td>\
  358. </tr>\
  359. <tr>\
  360. <td class="col-sm-7" style="border:1px #cccccc solid;">展品送達時間是否滿意</td>\
  361. <td class="col-sm-5" style="border:1px #cccccc solid;"><div id="Feild03">' + oRes.Feild03 + '</div></td>\
  362. </tr>\
  363. <tr>\
  364. <td class="col-sm-7" style="border:1px #cccccc solid;">現場人員的專業技能與服務態度是否滿意</td>\
  365. <td class="col-sm-5" style="border:1px #cccccc solid;"><div id="Feild04">' + oRes.Feild04 + '</div></td>\
  366. </tr>\
  367. <tr>\
  368. <td class="col-sm-7" style="border:1px #cccccc solid;">承辦同仁的配合度及服務態度是否滿意</td>\
  369. <td class="col-sm-5" style="border:1px #cccccc solid;"><div id="Feild05">' + oRes.Feild05 + '</div></td>\
  370. </tr>\
  371. <tr>\
  372. <td class="col-sm-7" style="border:1px #cccccc solid;">貨況線上查詢系統是否滿意</td>\
  373. <td class="col-sm-5" style="border:1px #cccccc solid;"><div id="Feild06">' + oRes.Feild06 + '</div></td>\
  374. </tr>\
  375. <tr>\
  376. <td class="col-sm-7" style="border:1px #cccccc solid;">為何選擇奕達</td>\
  377. <td class="col-sm-5" style="border:1px #cccccc solid;"><div id="Feild07">' + oRes.Feild07 + '</div></td>\
  378. </tr>\
  379. <tr>\
  380. <td class="col-sm-7" style="border:1px #cccccc solid;">貴公司年度平均參與海外展會活動次數</td>\
  381. <td class="col-sm-5" style="border:1px #cccccc solid;"><div id="Feild08">' + oRes.Feild08 + '</div></td>\
  382. </tr>\
  383. <tr>\
  384. <td class="col-sm-7" style="border:1px #cccccc solid;">您是否會推薦奕達給合作夥伴</td>\
  385. <td class="col-sm-5" style="border:1px #cccccc solid;"><div id="Feild9">' + oRes.Feild09 + '</div></td>\
  386. </tr>\
  387. <tr>\
  388. <td class="col-sm-7" style="border:1px #cccccc solid;">其他建議</td>\
  389. <td class="col-sm-5" style="border:1px #cccccc solid;"><div id="Feild10">' + oRes.Feild10 + '</div></td>\
  390. </tr>\
  391. </tbody>\
  392. </table>\
  393. </div><div class="pop-box row w100p"></div>',
  394. success: function (layero, index) {
  395. },
  396. yes: function (index, layero) {
  397. layer.confirm("確定要儲存?", { icon: 3, title: i18next.t('common.Tips') }, function (index) {
  398. var iframe = layero.find('iframe').contents();
  399. var SatisfactionCustomerData = getFormSerialize($(iframe.find('#form_main')));
  400. SatisfactionCustomerData.CustomerName = $("#CustomerName").val();
  401. SatisfactionCustomerData.FillerName = $("#FillerName").val();
  402. SatisfactionCustomerData.Email = $("#Email").val();
  403. SatisfactionCustomerData.Phone = $("#Phone").val();
  404. SatisfactionCustomerData.Memo = $("#Memo").val();
  405. SatisfactionCustomerData.SN=_SN;
  406. g_api.ConnectLite(sProgramId, 'Update', SatisfactionCustomerData
  407. , function (res) {
  408. if (res.DATA.rel) {
  409. showMsg(i18next.t("message.Modify_Success"), 'success'); //╠message.Modify_Success⇒修改成功╣
  410. layer.close(index);
  411. }
  412. else {
  413. showMsg(i18next.t("message.Modify_Failed"), 'error');//╠message.Modify_Failed⇒修改失敗╣
  414. }
  415. }
  416. , function () {
  417. showMsg(i18next.t("message.Modify_Failed"), 'error');//╠message.Modify_Failed⇒修改失敗╣
  418. });
  419. layer.close(index-1);
  420. });
  421. },
  422. end: function () {
  423. oGrid.loadData();
  424. }
  425. });
  426. });
  427. },
  428. /**
  429. * 目的 對應正式客戶
  430. * @param {String}item 預約單資料
  431. */
  432. fnCorrespondFormalCus = function (item) {
  433. layer.open({
  434. type: 1, //0(信息框,默认)1(页面层)2(iframe层)3(加载层)4(tips层)
  435. title: i18next.t("common.CorrespondFormalCus"), // ╠common.CorrespondImpCus⇒對應正式客戶╣
  436. area: '640px;',//寬度
  437. shade: 0.75,//遮罩
  438. closeBtn: 1,
  439. //maxmin: true, //开启最大化最小化按钮
  440. id: 'layer_Correspond', //设定一个id,防止重复弹出
  441. offset: '100px',//右下角弹出
  442. anim: 0,//彈出動畫
  443. btn: [i18next.t('common.Confirm'), i18next.t('common.Cancel')],//╠common.Confirm⇒確定╣╠common.Cancel⇒取消╣
  444. btnAlign: 'c',//按鈕位置
  445. content: '<style>.select2-container{z-index: 39891015;}</style><div class="form-group">\
  446. <div class="col-sm-12">\
  447. <select class= "form-control w95p" id="CustomerId" name="CustomerId"></select>\
  448. </div>\
  449. </div >',
  450. success: function (layero, index) {
  451. g_api.ConnectLite(Service.sys, 'GetCustomerlist', {}, function (res) {
  452. if (res.RESULT) {
  453. var saList = res.DATA.rel;
  454. var sOptions = createOptions(saList, 'id', 'text');
  455. $('#CustomerId').html(sOptions).select2();
  456. }
  457. });
  458. //transLang(layero);
  459. },
  460. yes: function (index, layero) {
  461. let sCustomerId = $('#CustomerId').val();
  462. if (!sCustomerId) {
  463. showMsg(i18next.t('message.SelectFormalCus'));//╠message.SelectFormalCus⇒請選擇對應的客戶╣
  464. return false;
  465. }
  466. return g_api.ConnectLite(sProgramId, 'CorrespondFormalCus', {
  467. SN: item.SN,
  468. CustomerId: sCustomerId
  469. }, function (res) {
  470. if (res.DATA.rel) {
  471. oGrid.loadData();
  472. showMsg(i18next.t("message.Correspond_Success"), 'success'); //╠message.Correspond_Success⇒對應成功╣
  473. layer.close(index);
  474. }
  475. else {
  476. showMsg(i18next.t("message.Correspond_Failed"), 'error');//╠message.Correspond_Failed⇒對應失敗╣
  477. }
  478. });
  479. }
  480. });
  481. },
  482. /**
  483. * ToolBar 按鈕事件 function
  484. * @param {Object}inst 按鈕物件對象
  485. * @param {Object} e 事件對象
  486. */
  487. fnButtonHandler = function (inst, e) {
  488. var sId = inst.id;
  489. switch (sId) {
  490. case "Toolbar_Qry":
  491. break;
  492. case "Toolbar_Save":
  493. $('#file_hidden').val($('li.jFiler-item').length || '');
  494. if (!$("#form_main").valid()) {
  495. oValidator.focusInvalid();
  496. return;
  497. }
  498. if (sAction === 'Add') {
  499. fnAdd('add');
  500. }
  501. else {
  502. fnUpd();
  503. }
  504. break;
  505. case "Toolbar_ReAdd":
  506. $('#file_hidden').val($('li.jFiler-item').length || '');
  507. if (!$("#form_main").valid()) {
  508. oValidator.focusInvalid();
  509. return;
  510. }
  511. fnAdd('readd');
  512. break;
  513. case "Toolbar_Clear":
  514. clearPageVal();
  515. break;
  516. case "Toolbar_Leave":
  517. pageLeave();
  518. break;
  519. case "Toolbar_Add":
  520. break;
  521. case "Toolbar_Upd":
  522. break;
  523. case "Toolbar_Copy":
  524. break;
  525. case "Toolbar_Del": // ╠message.ConfirmToDelete⇒確定要刪除嗎 ?╣ ╠common.Tips⇒提示╣
  526. layer.confirm(i18next.t("message.ConfirmToDelete"), { icon: 3, title: i18next.t('common.Tips') }, function (index) {
  527. fnDel();
  528. layer.close(index);
  529. });
  530. break;
  531. case "Toolbar_Imp":
  532. break;
  533. case "Toolbar_Transfer":
  534. fnTransfer();
  535. break;
  536. default:
  537. alert("No handle '" + sId + "'");
  538. break;
  539. }
  540. },
  541. /**
  542. * 初始化 function
  543. */
  544. init = function () {
  545. var saCusBtns = null;
  546. //$('#State,#Industry,#ExhibitionDate').prop('required', true);
  547. //$('.ShowNames').hide();
  548. /* if (parent.OrgID === 'TG') {
  549. $('#CostRulesId,#State,#ExhibitionAddress,#ExhibitionDate,#file_hidden').prop('required', true);
  550. $('#notte').show();
  551. $('.simp-box').hide();
  552. }
  553. else {
  554. $('.costrules').hide();
  555. }
  556. if (sAction === 'Upd') {
  557. saCusBtns = [{
  558. id: 'Toolbar_Transfer',
  559. value: 'common.Toolbar_Transfer'// ╠common.Toolbar_Transfer⇒拋轉╣
  560. }];
  561. } */
  562. commonInit({
  563. PrgId: sProgramId,
  564. ButtonHandler: fnButtonHandler,
  565. Buttons: saCusBtns,
  566. GoTop: true
  567. });
  568. $.whenArray([
  569. fnSetEpoDrop({
  570. Select: $('#ExhibitionNO'),
  571. Select2: true
  572. }).done(function (){
  573. fnGet();
  574. })
  575. //fnSetCustomersDrop()
  576. /* setExhibitionAddressDrop(),
  577. setCostRulesDrop(),
  578. fnSetArgDrop([
  579. {
  580. OrgID: 'TE',
  581. ArgClassID: 'ExhibClass',
  582. Select: $('#Industry'),
  583. ShowId: true
  584. }
  585. ]) */
  586. ])
  587. .done(function (res) {
  588. if (res && res.RESULT === 1) {
  589. var oRes = res.DATA.rel,
  590. sDateRange = '';
  591. oCurData = oRes;
  592. oCurData.LogoFileId = oCurData.LogoFileId || guid();
  593. setFormVal(oForm, oCurData);
  594. /* if (sTab) {
  595. $('#litab3 a').click();
  596. } */
  597. setNameById().done(function () {
  598. getPageVal();//緩存頁面值,用於清除
  599. });
  600. }
  601. //select2Init();
  602. var iHeight = $('body').height() - $('.page-title').height() - $('#searchbar').height() - 150;
  603. $("#jsGrid").jsGrid({
  604. width: "100%",
  605. height: "auto",
  606. autoload: true,
  607. filtering: false,
  608. pageLoading: true,
  609. inserting: false,
  610. editing: false,
  611. sorting: false,
  612. paging: true,
  613. pageIndex: 1,
  614. pageSize: parent.top.SysSet.GridRecords || 10,
  615. confirmDeleting: true,
  616. deleteConfirm: i18next.t('message.ConfirmToDelete'),// ╠message.ConfirmToDelete⇒確定要刪除嗎 ?╣
  617. pagePrevText: "<",
  618. pageNextText: ">",
  619. pageFirstText: "<<",
  620. pageLastText: ">>",
  621. rowClick: function (args) {
  622. /* if (navigator.userAgent.match(/mobile/i)) {
  623. goToEdit('Customers_Upd', '?Action=Upd&guid=' + args.item.guid);
  624. } */
  625. },
  626. rowDoubleClick: function (args) {
  627. //parent.openPageTab('Customers_Upd', '?Action=Upd&guid=' + args.item.guid);
  628. },
  629. fields: [
  630. {
  631. name: "RowIndex", title: 'common.RowNumber', width: 50, align: "center"
  632. },
  633. {
  634. name: "CompareDB", title: '比對資料庫', width: 80, align: "center"
  635. },
  636. {// ╠common.IsFormal⇒資料狀態╣
  637. name: "IsFormal",
  638. title: '比對資料庫',
  639. width: 80,
  640. align: 'center',
  641. itemTemplate: function (val, item) {
  642. var saAction = [];
  643. if (item.CompareDB == "N") {
  644. saAction.push($('<a/>', {
  645. html: i18next.t('common.CorrespondFormalCus'),
  646. class: 'link',
  647. click: function () {
  648. fnCorrespondFormalCus(item);
  649. return false;
  650. }
  651. }));
  652. }
  653. else {
  654. saAction.push($('<span />', { text: '已對應' }).css('color', 'green'));
  655. }
  656. return $('<div>', { 'style': 'width:100%;text-align: center;' }).append(saAction);
  657. }
  658. },
  659. {
  660. name: "CustomerName", title: '客戶名稱', width: 200, type: "text"
  661. /*itemTemplate: function (val, item) {
  662. if (item.CompareDB != "Y") {
  663. return this._createSelect = $("<select>", {
  664. class: 'w100p',
  665. html: sCustomersOptionsHtml,
  666. change: function () {
  667. var sOldValue = val,
  668. sNewValue = this.value;
  669. g_api.ConnectLite(canDo.ProgramId, canDo._api.order, {
  670. Id: item.Guid,
  671. OldOrderByValue: sOldValue,
  672. NewOrderByValue: sNewValue
  673. }, function (res) {
  674. if (res.RESULT) {
  675. oGrid[sKey].openPage(1);
  676. }
  677. });
  678. }
  679. }).val(val);
  680. }
  681. else {
  682. var saAction = [];
  683. saAction.push($('<span />', { text: item.CustomerName }));
  684. return $('<div>', { 'style': 'width:100%;text-align: left;' }).append(saAction);
  685. }
  686. } */
  687. },
  688. {
  689. name: "FillerName", title: '填寫人名稱', type: "text", width: 200
  690. },
  691. {
  692. name: "Phone", title: '連絡電話', type: "text", width: 200
  693. },
  694. {
  695. name: "Email", title: 'EMAIL', type: "text", width: 120
  696. },
  697. {
  698. name: "Feild01", title: '整體評分', width: 180, align: "center"
  699. },
  700. {
  701. name: "control1",
  702. width: 100,
  703. title: '問券',
  704. align: "center",
  705. itemTemplate: function (val, item) {
  706. var saBtn = [];
  707. saBtn.push($('<button />', {
  708. type: 'button', 'class': 'btn-custom blue', title: i18next.t('common.Toolbar_Imp'), html: '<i class="glyphicon glyphicon-file"></i>', click: function () {
  709. fnGetSatisfactionCaseData(item.SN);
  710. }
  711. }));
  712. return saBtn;
  713. },
  714. deleteButton: false,
  715. editButton: false
  716. },
  717. {
  718. type: "control",
  719. width: 100,
  720. headerTemplate: function () {
  721. var saBtn = [];
  722. /* if (sAction === 'Upd') {
  723. saBtn.push($('<button />', {
  724. type: 'button', 'class': 'btn-custom blue', title: i18next.t('common.Toolbar_Imp'), html: '<i class="glyphicon glyphicon-import"></i>', click: function () {
  725. fnImportCusList();
  726. }
  727. }));
  728. saBtn.push($('<button />', {
  729. type: 'button', 'class': 'btn-custom blue', title: i18next.t('common.Toolbar_Exp'), html: '<i class="glyphicon glyphicon-export"></i>', click: function () {
  730. fnExportCusList();
  731. }
  732. }));
  733. } */
  734. return saBtn;
  735. },
  736. deleteButton: true,
  737. editButton: false
  738. }
  739. ],
  740. controller: {
  741. loadData: function (args) {
  742. return fnGetGridData();
  743. },
  744. insertItem: function (args) {
  745. },
  746. updateItem: function (args) {
  747. },
  748. deleteItem: function (args) {
  749. return fnDelSatisfactionCustomer(args);
  750. }
  751. },
  752. onInit: function (args) {
  753. oGrid = args.grid;
  754. }
  755. });
  756. });
  757. oValidator = $("#form_main").validate({
  758. ignore: ''
  759. });
  760. $('#ExhibitionNO').change(function () {
  761. var sId = this.value;
  762. if (sId) {
  763. fnSetEpoDrop({
  764. SN: sId,
  765. CallBack: function (data) {
  766. var oExhibition = data[0];
  767. $("#ResponsiblePerson").text(oExhibition.ResponsiblePerson);
  768. $("#ExhibitionDate").text(newDate(oExhibition.ExhibitionDateStart, 'date') + ' ~ ' + newDate(oExhibition.ExhibitionDateEnd, 'date'));
  769. $("#CreateDate").text(newDate(oExhibition.CreateDate, 'date'));
  770. $('#ExhibitionDateStart').text(newDate(oExhibition.ExhibitionDateStart, 'date'));
  771. $('#ExhibitionDateEnd').text(newDate(oExhibition.ExhibitionDateEnd, 'date'));
  772. /* $('#ExportBillEName').val(oExhibition.Exhibitioname_EN);
  773. if (oExhibition.ExhibitionDateStart) {
  774. $('#ExhibitionDateStart').val(newDate(oExhibition.ExhibitionDateStart, 'date'));
  775. }
  776. if (oExhibition.ExhibitionDateEnd) {
  777. $('#ExhibitionDateEnd').val(newDate(oExhibition.ExhibitionDateEnd, 'date'));
  778. } */
  779. }
  780. });
  781. }
  782. else {
  783. /* $('#ExportBillEName').val('');
  784. $('#ExhibitionDateStart').val('');
  785. $('#ExhibitionDateEnd').val(''); */
  786. }
  787. });
  788. $('#btnImportFile').click(function () {
  789. fnImportFile();
  790. //return false;
  791. });
  792. $('#btnCompareDB').click(function () {
  793. var iHeight = $('body').height() - $('.page-title').height() - $('#searchbar').height() - 150;
  794. $("#jsGrid").jsGrid({
  795. width: "100%",
  796. height: "auto",
  797. autoload: true,
  798. filtering: false,
  799. pageLoading: true,
  800. inserting: false,
  801. editing: false,
  802. sorting: false,
  803. paging: true,
  804. pageIndex: 1,
  805. pageSize: parent.top.SysSet.GridRecords || 10,
  806. confirmDeleting: true,
  807. deleteConfirm: i18next.t('message.ConfirmToDelete'),// ╠message.ConfirmToDelete⇒確定要刪除嗎 ?╣
  808. pagePrevText: "<",
  809. pageNextText: ">",
  810. pageFirstText: "<<",
  811. pageLastText: ">>",
  812. rowClick: function (args) {
  813. /* if (navigator.userAgent.match(/mobile/i)) {
  814. goToEdit('Customers_Upd', '?Action=Upd&guid=' + args.item.guid);
  815. } */
  816. },
  817. rowDoubleClick: function (args) {
  818. //parent.openPageTab('Customers_Upd', '?Action=Upd&guid=' + args.item.guid);
  819. },
  820. fields: [
  821. {
  822. name: "RowIndex", title: 'common.RowNumber', width: 50, align: "center"
  823. },
  824. {
  825. name: "CompareDB", title: '比對資料庫', width: 80, align: "center"
  826. },
  827. {// ╠common.IsFormal⇒資料狀態╣
  828. name: "IsFormal",
  829. title: '比對資料庫',
  830. width: 80,
  831. align: 'center',
  832. itemTemplate: function (val, item) {
  833. var saAction = [];
  834. if (item.CompareDB == "N") {
  835. saAction.push($('<a/>', {
  836. html: i18next.t('common.CorrespondFormalCus'),
  837. class: 'link',
  838. click: function () {
  839. fnCorrespondFormalCus(item);
  840. return false;
  841. }
  842. }));
  843. }
  844. else {
  845. saAction.push($('<span />', { text: '已對應' }).css('color', 'green'));
  846. }
  847. return $('<div>', { 'style': 'width:100%;text-align: center;' }).append(saAction);
  848. }
  849. },
  850. {
  851. name: "CustomerName", title: '客戶名稱', width: 200, type: "text"
  852. /*itemTemplate: function (val, item) {
  853. if (item.CompareDB != "Y") {
  854. return this._createSelect = $("<select>", {
  855. class: 'w100p',
  856. html: sCustomersOptionsHtml,
  857. change: function () {
  858. var sOldValue = val,
  859. sNewValue = this.value;
  860. g_api.ConnectLite(canDo.ProgramId, canDo._api.order, {
  861. Id: item.Guid,
  862. OldOrderByValue: sOldValue,
  863. NewOrderByValue: sNewValue
  864. }, function (res) {
  865. if (res.RESULT) {
  866. oGrid[sKey].openPage(1);
  867. }
  868. });
  869. }
  870. }).val(val);
  871. }
  872. else {
  873. var saAction = [];
  874. saAction.push($('<span />', { text: item.CustomerName }));
  875. return $('<div>', { 'style': 'width:100%;text-align: left;' }).append(saAction);
  876. }
  877. } */
  878. },
  879. {
  880. name: "FillerName", title: '填寫人名稱', type: "text", width: 200
  881. },
  882. {
  883. name: "Phone", title: '連絡電話', type: "text", width: 200
  884. },
  885. {
  886. name: "Email", title: 'EMAIL', type: "text", width: 120
  887. },
  888. {
  889. name: "Feild01", title: '整體評分', width: 180, align: "center"
  890. },
  891. {
  892. name: "control1",
  893. width: 100,
  894. title: '問券',
  895. align: "center",
  896. itemTemplate: function (val, item) {
  897. var saBtn = [];
  898. saBtn.push($('<button />', {
  899. type: 'button', 'class': 'btn-custom blue', title: i18next.t('common.Toolbar_Imp'), html: '<i class="glyphicon glyphicon-file"></i>', click: function () {
  900. fnGetSatisfactionCaseData(item.SN);
  901. }
  902. }));
  903. return saBtn;
  904. },
  905. deleteButton: false,
  906. editButton: false
  907. },
  908. {
  909. type: "control",
  910. width: 100,
  911. headerTemplate: function () {
  912. var saBtn = [];
  913. /* if (sAction === 'Upd') {
  914. saBtn.push($('<button />', {
  915. type: 'button', 'class': 'btn-custom blue', title: i18next.t('common.Toolbar_Imp'), html: '<i class="glyphicon glyphicon-import"></i>', click: function () {
  916. fnImportCusList();
  917. }
  918. }));
  919. saBtn.push($('<button />', {
  920. type: 'button', 'class': 'btn-custom blue', title: i18next.t('common.Toolbar_Exp'), html: '<i class="glyphicon glyphicon-export"></i>', click: function () {
  921. fnExportCusList();
  922. }
  923. }));
  924. } */
  925. return saBtn;
  926. },
  927. deleteButton: true,
  928. editButton: false
  929. }
  930. ],
  931. controller: {
  932. loadData: function (args) {
  933. return fnCompareDB();
  934. },
  935. insertItem: function (args) {
  936. },
  937. updateItem: function (args) {
  938. },
  939. deleteItem: function (args) {
  940. return fnDelSatisfactionCustomer(args);
  941. }
  942. },
  943. onInit: function (args) {
  944. oGrid = args.grid;
  945. }
  946. });
  947. return false;
  948. });
  949. //oGrid.loadData();
  950. };
  951. init();
  952. };
  953. require(['base', 'select2', 'jsgrid', 'daterangepicker', 'convetlng', 'filer', 'ajaxfile', 'common_opm', 'util'], fnPageInit, 'daterangepicker');