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.

729 lines
38 KiB

2 years ago
  1. 'use strict';
  2. var sProgramId = getProgramId(),
  3. sQueryPrgId = getQueryPrgId(),
  4. sViewPrgId = sProgramId.replace('_Upd', '_View'),
  5. sAction = getUrlParam('Action') || 'Add',
  6. sDataId = getUrlParam('Guid'),
  7. sCheckId = sDataId,
  8. fnPageInit = function () {
  9. var oCurData = { CheckOrder: [] },
  10. oForm = $('#form_main'),
  11. oGrid = null,
  12. oValidator = null,
  13. oTR = null,
  14. oAddItem = {},
  15. saUsers = [],
  16. fnGetBillChangeInfo = function () {
  17. var saList = [];
  18. $('.billchangeinfo tr.data-item').each(function (idx) {
  19. saList.push({
  20. OldItem: $(this).find('[data-id="OldItem"]').val(),
  21. OldAmountCurrency: $(this).find('[data-id="OldAmountCurrency"]').val(),
  22. OldAmount: $(this).find('[data-id="OldAmount"]').val(),
  23. NewItem: $(this).find('[data-id="NewItem"]').val(),
  24. NewAmountCurrency: $(this).find('[data-id="NewAmountCurrency"]').val(),
  25. NewAmount: $(this).find('[data-id="NewAmount"]').val()
  26. });
  27. });
  28. return saList;
  29. },
  30. /**
  31. * 獲取資料
  32. */
  33. fnGet = function () {
  34. var deferred = $.Deferred();
  35. if (sDataId) {
  36. return g_api.ConnectLite(sQueryPrgId, ComFn.GetOne,
  37. {
  38. Guid: sDataId
  39. },
  40. function (res) {
  41. if (res.RESULT) {
  42. var oRes = res.DATA.rel;
  43. oCurData = oRes;
  44. oCurData.BillChanges = $.parseJSON(oCurData.BillChanges);
  45. oCurData.CheckOrder = $.parseJSON(oCurData.CheckOrder);
  46. setFormVal(oForm, oRes);
  47. $('.Applicant').text(oCurData.ApplicantName + '(' + oCurData.Applicant + ') ' + oCurData.DeptName);
  48. fnGetUploadFiles(oCurData.Guid, fnUpload);
  49. if (oCurData.Handle_DeptID) {
  50. fnSetUserDrop([
  51. {
  52. Select: $('#Handle_Person'),
  53. DepartmentID: oCurData.Handle_DeptID,
  54. ShowId: true,
  55. Select2: true,
  56. Action: sAction,
  57. DefultVal: oCurData.Handle_Person
  58. }
  59. ]);
  60. }
  61. if (oCurData.Flows_Lock === 'Y') {
  62. $(".checkordertoolbox").hide();
  63. }
  64. else {
  65. $(".checkordertoolbox").show();
  66. }
  67. if (oCurData.Handle_Lock === 'Y') {
  68. $("#Handle_DeptID,#Handle_Person").attr('disabled', true);
  69. }
  70. else {
  71. $("#Handle_DeptID,#Handle_Person").removeAttr('disabled');
  72. }
  73. $('[class="data-item"]').remove();
  74. $.each(oCurData.BillChanges.ChangeInfo || [], function (idx, item) {
  75. var oTrNew = oTR.clone(true);
  76. oTrNew.find('[data-id="OldItem"]').val(item.OldItem);
  77. oTrNew.find('[data-id="OldAmountCurrency"]').val(item.OldAmountCurrency);
  78. oTrNew.find('[data-id="OldAmount"]').val(item.OldAmount);
  79. oTrNew.find('[data-id="NewItem"]').val(item.NewItem);
  80. oTrNew.find('[data-id="NewAmountCurrency"]').val(item.NewAmountCurrency);
  81. oTrNew.find('[data-id="NewAmount"]').val(item.NewAmount);
  82. $('.billchangeinfo tr:last').before(oTrNew);
  83. });
  84. $("#jsGrid").jsGrid("loadData");
  85. setNameById().done(function () {
  86. getPageVal();//緩存頁面值,用於清除
  87. });
  88. moneyInput($('[data-type="int"]'), 2, true);
  89. }
  90. });
  91. }
  92. else {
  93. $('.Applicant').text(parent.UserInfo.MemberName + '(' + parent.UserInfo.MemberID + ') ' + parent.UserInfo.DepartmentName);
  94. $('#Applicant').val(parent.UserInfo.MemberID);
  95. oCurData.CheckOrder = [];
  96. oCurData.Guid = guid();
  97. fnUpload();
  98. return $.Deferred().resolve().promise();
  99. }
  100. },
  101. /**
  102. * 新增資料
  103. * @param {String} sFlag 新增或儲存後新增
  104. */
  105. fnAdd = function (flag) {
  106. var data = getFormSerialize(oForm);
  107. data = packParams(data);
  108. data.OrgID = parent.OrgID;
  109. data.Guid = oCurData.Guid;
  110. data.SignedNumber = 'SerialNumber|' + parent.UserInfo.OrgID + '|BCA|MinYear|3|' + parent.UserInfo.ServiceCode + '|' + parent.UserInfo.ServiceCode;
  111. data.CheckFlows = fnCheckFlows(oCurData, false, true, saUsers);
  112. data.HandleFlows = fnHandleFlows(oCurData, saUsers);
  113. data.BillChanges.ChangeInfo = fnGetBillChangeInfo();
  114. data.BillChanges.CustomerName = $('#BillChanges_CustomerID option:selected').text();
  115. data.BillChanges.ExhibitionName = $('#BillChanges_ExhibitionNO option:selected').text();
  116. data.BillChanges.ResponsiblePersonName = $('#BillChanges_ResponsiblePerson option:selected').text();
  117. data.BillChanges = JSON.stringify(data.BillChanges);
  118. data.CheckOrder = JSON.stringify(oCurData.CheckOrder);
  119. data.Status = 'A';
  120. data.IsHandled = 'N';
  121. data.Inspectors = '';
  122. data.Reminders = '';
  123. data.Flows_Lock = oCurData.Flows_Lock;
  124. data.Handle_Lock = oCurData.Handle_Lock;
  125. CallAjax(ComFn.W_Com, ComFn.GetAdd, {
  126. Params: {
  127. billchangeapply: data
  128. }
  129. }, function (res) {
  130. if (res.d > 0) {
  131. bRequestStorage = false;
  132. if (flag == 'add') {
  133. showMsgAndGo(i18next.t("message.Save_Success"), sProgramId, '?Action=Upd&Guid=' + data.Guid); // ╠message.Save_Success⇒新增成功╣
  134. }
  135. else {
  136. showMsgAndGo(i18next.t("message.Save_Success"), sProgramId, '?Action=Add'); // ╠message.Save_Success⇒新增成功╣
  137. }
  138. }
  139. else {
  140. showMsg(i18next.t("message.Save_Failed"), 'error'); // ╠message.Save_Failed⇒新增失敗╣
  141. }
  142. }, function () {
  143. showMsg(i18next.t("message.Save_Failed"), 'error'); // ╠message.Save_Failed⇒新增失敗╣
  144. });
  145. },
  146. /**
  147. * 修改資料
  148. * @param {Boolean} balert 是否提示
  149. */
  150. fnUpd = function (balert) {
  151. var data = getFormSerialize(oForm);
  152. data = packParams(data, 'upd');
  153. data.CheckFlows = fnCheckFlows(oCurData, false, true, saUsers);
  154. data.HandleFlows = fnHandleFlows(oCurData, saUsers);
  155. data.BillChanges.ChangeInfo = fnGetBillChangeInfo();
  156. data.BillChanges.CustomerName = $('#BillChanges_CustomerID option:selected').text();
  157. data.BillChanges.ExhibitionName = $('#BillChanges_ExhibitionNO option:selected').text();
  158. data.BillChanges.ResponsiblePersonName = $('#BillChanges_ResponsiblePerson option:selected').text();
  159. data.BillChanges = JSON.stringify(data.BillChanges);
  160. data.CheckOrder = JSON.stringify(oCurData.CheckOrder);
  161. data.Flows_Lock = oCurData.Flows_Lock;
  162. data.Handle_Lock = oCurData.Handle_Lock;
  163. return CallAjax(ComFn.W_Com, ComFn.GetUpd, {
  164. Params: {
  165. billchangeapply: {
  166. values: data,
  167. keys: { Guid: sDataId }
  168. }
  169. }
  170. }, function (res) {
  171. if (res.d > 0) {
  172. if (!balert) {
  173. bRequestStorage = false;
  174. showMsg(i18next.t("message.Modify_Success"), 'success'); //╠message.Modify_Success⇒修改成功╣
  175. if (window.bLeavePage) {
  176. setTimeout(function () {
  177. pageLeave();
  178. }, 1000);
  179. }
  180. }
  181. }
  182. else {
  183. showMsg(i18next.t("message.Modify_Failed"), 'error');//╠message.Modify_Failed⇒修改失敗╣
  184. }
  185. }, function () {
  186. showMsg(i18next.t("message.Modify_Failed"), 'error');//╠message.Modify_Failed⇒修改失敗╣
  187. });
  188. },
  189. /**
  190. * 資料刪除
  191. */
  192. fnDel = function () {
  193. CallAjax(ComFn.W_Com, ComFn.GetDel, {
  194. Params: {
  195. billchangeapply: {
  196. Guid: sDataId
  197. }
  198. }
  199. }, function (res) {
  200. if (res.d > 0) {
  201. DelTask(sDataId);
  202. showMsgAndGo(i18next.t("message.Delete_Success"), sQueryPrgId); // ╠message.Delete_Success⇒刪除成功╣
  203. }
  204. else {
  205. showMsg(i18next.t("message.Delete_Failed"), 'error'); // ╠message.Delete_Failed⇒刪除失敗╣
  206. }
  207. }, function () {
  208. showMsg(i18next.t("message.Delete_Failed"), 'error'); // ╠message.Delete_Failed⇒刪除失敗╣
  209. });
  210. },
  211. /**
  212. * 設定客戶下拉選單
  213. */
  214. setCustomersDrop = function () {
  215. return g_api.ConnectLite(Service.sys, 'GetCustomerlist', {}, function (res) {
  216. if (res.RESULT) {
  217. var saCustomers = res.DATA.rel,
  218. sCustomersOptionsHtml = createOptions(saCustomers, 'id', 'text');
  219. $('#BillChanges_CustomerID').html(sCustomersOptionsHtml);
  220. select2Init($('#BillChanges_CustomerID').parent());
  221. }
  222. });
  223. },
  224. /**
  225. * 上傳附件
  226. * @param {Array} files 上傳的文件
  227. */
  228. fnUpload = function (files) {
  229. var option = {};
  230. option.input = $('#fileInput');
  231. option.theme = 'dragdropbox';
  232. option.folder = 'BillChangeApply';
  233. option.type = 'list';
  234. option.parentid = oCurData.Guid;
  235. if (files) {
  236. option.files = files;
  237. }
  238. fnUploadRegister(option);
  239. },
  240. /**
  241. * 提交簽呈
  242. */
  243. fnSubmitPetition = function () {
  244. g_api.ConnectLite(sProgramId, 'BillChangeApplyToAudit', {
  245. guid: oCurData.Guid
  246. }, function (res) {
  247. if (res.RESULT) {
  248. showMsgAndGo(i18next.t("message.ToAudit_Success"), sViewPrgId, '?Action=Upd&Guid=' + oCurData.Guid);// ╠message.ToAudit_Success⇒提交審核成功╣
  249. parent.msgs.server.pushTips(parent.fnReleaseUsers(res.DATA.rel));
  250. }
  251. else {
  252. showMsg(i18next.t('message.ToAudit_Failed') + '<br>' + res.MSG, 'error'); // ╠message.ToAudit_Failed⇒提交審核失敗╣
  253. }
  254. }, function () {
  255. showMsg(i18next.t('message.ToAudit_Failed'), 'error'); // ╠message.ToAudit_Failed⇒提交審核失敗╣
  256. });
  257. },
  258. /**
  259. * ToolBar 按鈕事件 function
  260. * @param {Object} inst 按鈕物件對象
  261. * @param {Object} e 事件對象
  262. */
  263. fnButtonHandler = function (inst, e) {
  264. var sId = inst.id;
  265. switch (sId) {
  266. case "Toolbar_Qry":
  267. break;
  268. case "Toolbar_Save":
  269. if (!$("#form_main").valid()) {
  270. oValidator.focusInvalid();
  271. return false;
  272. }
  273. if (sAction === 'Add') {
  274. fnAdd('add');
  275. }
  276. else {
  277. fnUpd();
  278. }
  279. break;
  280. case "Toolbar_ReAdd":
  281. if (!$("#form_main").valid()) {
  282. oValidator.focusInvalid();
  283. return false;
  284. }
  285. fnAdd('readd');
  286. break;
  287. case "Toolbar_Clear":
  288. clearPageVal();
  289. break;
  290. case "Toolbar_Leave":
  291. pageLeave();
  292. break;
  293. case "Toolbar_Add":
  294. break;
  295. case "Toolbar_Upd":
  296. break;
  297. case "Toolbar_Copy":
  298. break;
  299. case "Toolbar_Petition":
  300. if (!$("#form_main").valid()) {
  301. oValidator.focusInvalid();
  302. return false;
  303. }
  304. fnUpd(true).done(function () {
  305. fnSubmitPetition();
  306. });
  307. break;
  308. case "Toolbar_Del": // ╠message.ConfirmToDelete⇒確定要刪除嗎 ?╣ ╠common.Tips⇒提示╣
  309. layer.confirm(i18next.t("message.ConfirmToDelete"), { icon: 3, title: i18next.t('common.Tips') }, function (index) {
  310. fnDel();
  311. layer.close(index);
  312. });
  313. break;
  314. default:
  315. alert("No handle '" + sId + "'");
  316. break;
  317. }
  318. },
  319. /**
  320. * 初始化 function
  321. */
  322. init = function () {
  323. var saCusBtns = null;
  324. if (sAction === 'Upd') {
  325. saCusBtns = [{
  326. id: 'Toolbar_Petition',
  327. value: 'common.SubmitPetition'// ╠common.SubmitPetition⇒提交簽呈╣
  328. }];
  329. }
  330. commonInit({
  331. PrgId: sProgramId,
  332. ButtonHandler: fnButtonHandler,
  333. Buttons: saCusBtns,
  334. GoTop: true
  335. });
  336. oValidator = $("#form_main").validate();
  337. $.whenArray([
  338. fnSetDeptDrop($('#Handle_DeptID')),
  339. fnSetFlowDrop({
  340. Flow_Type: parent.SysSet.Eip_005,
  341. ShareTo: parent.UserID,
  342. CallBack: function (data) {
  343. $.each(data, function (idx, item) {
  344. var saFlows = $.parseJSON(item.Flows),
  345. saFlowsText = [],
  346. sFlowsText = '';
  347. $.each(saFlows, function (idx, flow) {
  348. var sFlowType = i18next.t('common.' + flow.SignedWay);
  349. if (flow.SignedWay !== 'flow1') {
  350. saFlowsText.push(sFlowType + '(' + Enumerable.From(flow.SignedMember).ToString(",", "$.name") + ')');
  351. }
  352. else {
  353. saFlowsText.push(Enumerable.From(flow.SignedMember).ToString(",", "$.name"));
  354. }
  355. });
  356. sFlowsText = saFlowsText.join(' → ');
  357. item.text = item.Flow_Name + ' - ' + (sFlowsText.length > 60 ? sFlowsText.substr(0, 60) + '...' : sFlowsText);
  358. });
  359. $('#FlowId').html(createOptions(data, 'Guid', 'text')).on('change', function () {
  360. var sFlowId = this.value;
  361. if (sFlowId) {
  362. CallAjax(ComFn.W_Com, ComFn.GetOne, {
  363. Type: '',
  364. Params: {
  365. checkflow: {
  366. Guid: sFlowId
  367. }
  368. }
  369. }, function (res) {
  370. if (res.d) {
  371. var oRes = $.parseJSON(res.d);
  372. oRes.Flows = $.parseJSON(oRes.Flows);
  373. oCurData.CheckOrder = oRes.Flows;
  374. oCurData.Flows_Lock = oRes.Flows_Lock;
  375. oCurData.Handle_Lock = oRes.Handle_Lock;
  376. $("#Handle_DeptID").val(oRes.Handle_DeptID);
  377. $("#Handle_Person").val(oRes.Handle_Person).trigger('change');
  378. if (oRes.Flows_Lock === 'Y') {
  379. $(".checkordertoolbox").hide();
  380. }
  381. else {
  382. $(".checkordertoolbox").show();
  383. }
  384. if (oRes.Handle_Lock === 'Y') {
  385. $("#Handle_DeptID,#Handle_Person").attr('disabled', true);
  386. }
  387. else {
  388. $("#Handle_DeptID,#Handle_Person").removeAttr('disabled');
  389. }
  390. $("#jsGrid").jsGrid("loadData");
  391. }
  392. });
  393. }
  394. else {
  395. oCurData.CheckOrder = [];
  396. $(".checkordertoolbox").hide();
  397. $("#jsGrid").jsGrid("loadData");
  398. $("#Handle_DeptID,#Handle_Person").removeAttr('disabled');
  399. }
  400. });
  401. }
  402. }),
  403. fnSetEpoDrop({
  404. Select: $('#BillChanges_ExhibitionNO'),
  405. IdName: 'ExhibitionCode',
  406. TextName: 'ExhibitioShotName_TW',
  407. Select2: true
  408. }),
  409. fnSetUserDrop([
  410. {
  411. ShowId: true,
  412. Select: $('#Handle_Person,#BillChanges_ResponsiblePerson'),
  413. Select2: true,
  414. Action: sAction,
  415. CallBack: function (data) {
  416. saUsers = data;
  417. }
  418. }
  419. ]),
  420. setCustomersDrop(),
  421. fnSetArgDrop([
  422. {
  423. ArgClassID: 'Currency',
  424. CallBack: function (data) {
  425. $('.select_currency').html(createOptions(data, 'id', 'id'))[0].remove(0);
  426. }
  427. }
  428. ])]).done(function () {
  429. $('.glyphicon-trash').on('click', function () {
  430. $(this).parent().parent().remove();
  431. });
  432. $('[data-id="OldAmount"]').on('change', function () {
  433. var iAllOldAmount = 0;
  434. $('[data-id="OldAmount"]').each(function () {
  435. iAllOldAmount += ($(this).attr('data-value') || 0) * 1;
  436. });
  437. $('#BillChanges_OldSumAmount').attr('data-value', iAllOldAmount).val(fMoney(iAllOldAmount, 2, 'NTD'));
  438. });
  439. $('[data-id="NewAmount"]').on('change', function () {
  440. var iAllNewAmount = 0;
  441. $('[data-id="NewAmount"]').each(function () {
  442. iAllNewAmount += ($(this).attr('data-value') || 0) * 1;
  443. });
  444. $('#BillChanges_NewSumAmount').attr('data-value', iAllNewAmount).val(fMoney(iAllNewAmount, 2, 'NTD'));
  445. });
  446. oTR = $('.billchangeinfo tr').eq(1).clone(true);
  447. $('.plustemplkey').on('click', function () {
  448. var oTrNew = oTR.clone(true);
  449. $('.billchangeinfo tr:last').before(oTrNew);
  450. });
  451. moneyInput($('[data-type="int"]'), 2, true);
  452. fnGet();
  453. });
  454. $('#Handle_DeptID').on('change', function () {
  455. fnSetUserDrop([
  456. {
  457. Select: $('#Handle_Person'),
  458. DepartmentID: this.value,
  459. ShowId: true,
  460. Select2: true,
  461. Action: sAction
  462. }
  463. ]);
  464. });
  465. $('#Agent_Person').on('change', function () {
  466. oCurData.Agent_Person = this.value;
  467. });
  468. $('.flowlink').on('click', function () {
  469. var oOption = {};
  470. oOption.SignedWay = this.id;
  471. oOption.Callback = function (data) {
  472. if (data.Users.length > 0) {
  473. var oFlow = {};
  474. if (data.FlowType === 'flow1') {
  475. $.each(data.Users, function (idx, user) {
  476. oFlow = {};
  477. oFlow.id = guid();
  478. oFlow.Order = oCurData.CheckOrder.length + 1;
  479. oFlow.SignedWay = data.FlowType;
  480. oFlow.SignedMember = [{
  481. id: user.id,
  482. name: user.name,
  483. deptname: user.deptname,
  484. jobname: user.jobname
  485. }];
  486. oCurData.CheckOrder.push(oFlow);
  487. });
  488. }
  489. else {
  490. var saSignedMember = [];
  491. $.each(data.Users, function (idx, user) {
  492. saSignedMember.push({
  493. id: user.id,
  494. name: user.name,
  495. deptname: user.deptname,
  496. jobname: user.jobname
  497. });
  498. });
  499. oFlow.id = guid();
  500. oFlow.Order = oCurData.CheckOrder.length + 1;
  501. oFlow.SignedWay = data.FlowType;
  502. oFlow.SignedMember = saSignedMember;
  503. oCurData.CheckOrder.push(oFlow);
  504. }
  505. oCurData.CheckOrder = releaseGridList(oCurData.CheckOrder);
  506. $("#jsGrid").jsGrid("loadData");
  507. }
  508. };
  509. oPenUserListPop(oOption);
  510. });
  511. $("#jsGrid").jsGrid({
  512. width: "100%",
  513. height: "auto",
  514. autoload: true,
  515. filtering: false,
  516. pageLoading: true,
  517. pageIndex: 1,
  518. pageSize: 10000,
  519. fields: [
  520. {
  521. name: "Order", title: 'common.Order', width: 50, align: "center",
  522. itemTemplate: function (val, item) {
  523. return val < 10 ? '0' + val : val;
  524. }
  525. },
  526. {
  527. name: "SignedWay", title: 'common.SignedWay', width: 120, align: "center",
  528. itemTemplate: function (val, item) {
  529. return i18next.t('common.' + val);
  530. }
  531. },
  532. {
  533. type: "Icon", width: 50, align: "center",
  534. itemTemplate: function (val, item) {
  535. var oIcon = {
  536. flow1: '<img src="../../images/flow_check.gif">',
  537. flow2: '<img src="../../images/flow_check.gif"><img src="../../images/flow_check.gif">',
  538. flow3: '<img src="../../images/flow_check.gif"><img src="../../images/flow_nocheck.gif">',
  539. flow4: '<img src="../../images/flow4.gif">'
  540. },
  541. sIcon = oIcon[item.SignedWay];
  542. if (item.Order !== oCurData.CheckOrder.length) {
  543. sIcon += '<br><img src="../../images/flow_arrow.gif" style="vertical-align:top;">'
  544. }
  545. return sIcon;
  546. }
  547. },
  548. {
  549. name: "SignedMember", title: 'common.SignedMember', width: 500,
  550. itemTemplate: function (val, item) {
  551. return Enumerable.From(val).ToString(",", "$.name");
  552. }
  553. },
  554. {
  555. type: "control", title: 'common.Action', width: 200,
  556. itemTemplate: function (val, item) {
  557. var oBtns = [$('<div>', { class: 'fa-item col-sm-3' }).append($('<i>', {
  558. class: 'glyphicon glyphicon-pencil' + (oCurData.Flows_Lock === 'Y' ? ' disabled' : ''),
  559. title: i18next.t('common.Edit'),// ╠common.Edit⇒編輯╣
  560. click: function () {
  561. if ($(this).hasClass('disabled')) { return false; }
  562. var oOption = {};
  563. oOption.SignedWay = item.SignedWay;
  564. oOption.SignedMember = item.SignedMember;
  565. oOption.Callback = function (data) {
  566. if (data.Users.length > 0) {
  567. var oFlow = {};
  568. if (data.FlowType === 'flow1') {
  569. $.each(data.Users, function (idx, user) {
  570. var oFlow = {};
  571. oFlow.id = guid();
  572. oFlow.Order = item.Order + idx;
  573. oFlow.SignedWay = data.FlowType;
  574. oFlow.SignedMember = [{
  575. id: user.id,
  576. name: user.name,
  577. deptname: user.deptname,
  578. jobname: user.jobname
  579. }];
  580. oCurData.CheckOrder.insert(item.Order + idx, oFlow);
  581. });
  582. }
  583. else {
  584. var saSignedMember = [];
  585. $.each(data.Users, function (idx, user) {
  586. saSignedMember.push({
  587. id: user.id,
  588. name: user.name,
  589. deptname: user.deptname,
  590. jobname: user.jobname
  591. });
  592. });
  593. oFlow.id = guid();
  594. oFlow.Order = item.Order;
  595. oFlow.SignedWay = data.FlowType;
  596. oFlow.SignedMember = saSignedMember;
  597. oCurData.CheckOrder.insert(item.Order, oFlow);
  598. }
  599. var iOrder = 1;
  600. $.each(oCurData.CheckOrder, function (idx, _data) {
  601. if (item.id !== _data.id) {
  602. _data.Order = iOrder;
  603. iOrder++;
  604. }
  605. });
  606. oCurData.CheckOrder = Enumerable.From(oCurData.CheckOrder).Where(function (e) { return e.id !== item.id; }).ToArray();
  607. oCurData.CheckOrder = releaseGridList(oCurData.CheckOrder);
  608. $("#jsGrid").jsGrid("loadData");
  609. }
  610. };
  611. oPenUserListPop(oOption);
  612. }
  613. })),
  614. $('<div>', { class: 'fa-item col-sm-3' }).append($('<i>', {
  615. class: 'glyphicon glyphicon-trash' + (oCurData.Flows_Lock === 'Y' ? ' disabled' : ''),
  616. title: i18next.t('common.Toolbar_Del'),// ╠common.Toolbar_Del⇒刪除╣
  617. click: function () {
  618. if ($(this).hasClass('disabled')) { return false; }
  619. var saNewList = Enumerable.From(oCurData.CheckOrder).Where(function (e) { return e.id !== item.id; }).ToArray();
  620. oCurData.CheckOrder = saNewList;
  621. $.each(oCurData.CheckOrder, function (idx, _data) {
  622. _data.Order = idx + 1;
  623. });
  624. oCurData.CheckOrder = releaseGridList(oCurData.CheckOrder);
  625. $("#jsGrid").jsGrid("loadData");
  626. }
  627. }))];
  628. if (oCurData.CheckOrder.length !== item.Order) {
  629. oBtns.push($('<div>', { class: 'fa-item col-sm-3' }).append($('<i>', {
  630. class: 'glyphicon glyphicon-arrow-down' + (oCurData.Flows_Lock === 'Y' ? ' disabled' : ''),
  631. title: i18next.t('common.Down'),// ╠common.Down⇒下移╣
  632. click: function () {
  633. if ($(this).hasClass('disabled')) { return false; }
  634. var sOrder = Enumerable.From(oCurData.CheckOrder).Where(function (e) { return e.id === item.id; }).ToString('', '$.Order'),
  635. iOrder = sOrder * 1;
  636. $.each(oCurData.CheckOrder, function (idx, _data) {
  637. if (iOrder === _data.Order) {
  638. _data.Order++;
  639. }
  640. else if ((iOrder + 1) === _data.Order) {
  641. _data.Order--;
  642. }
  643. });
  644. oCurData.CheckOrder = releaseGridList(oCurData.CheckOrder);
  645. $("#jsGrid").jsGrid("loadData");
  646. }
  647. })));
  648. }
  649. else {
  650. oBtns.push($('<div>', { class: 'fa-item col-sm-3' }));
  651. }
  652. if (1 !== item.Order) {
  653. oBtns.push($('<div>', { class: 'fa-item col-sm-3' }).append($('<i>', {
  654. class: 'glyphicon glyphicon-arrow-up' + (oCurData.Flows_Lock === 'Y' ? ' disabled' : ''),
  655. title: i18next.t('common.Up'),// ╠common.Up⇒上移╣
  656. click: function () {
  657. if ($(this).hasClass('disabled')) { return false; }
  658. var sOrder = Enumerable.From(oCurData.CheckOrder).Where(function (e) { return e.id === item.id; }).ToString('', '$.Order'),
  659. iOrder = sOrder * 1;
  660. $.each(oCurData.CheckOrder, function (idx, _data) {
  661. if (iOrder === _data.Order) {
  662. _data.Order--;
  663. }
  664. else if ((iOrder - 1) === _data.Order) {
  665. _data.Order++;
  666. }
  667. });
  668. oCurData.CheckOrder = releaseGridList(oCurData.CheckOrder);
  669. $("#jsGrid").jsGrid("loadData");
  670. }
  671. })));
  672. }
  673. return oBtns;
  674. }
  675. }
  676. ],
  677. controller: {
  678. loadData: function (args) {
  679. return {
  680. data: oCurData.CheckOrder,
  681. itemsCount: oCurData.CheckOrder.length //data.length
  682. };
  683. },
  684. insertItem: function (args) {
  685. },
  686. updateItem: function (args) {
  687. },
  688. deleteItem: function (args) {
  689. }
  690. }
  691. });
  692. };
  693. init();
  694. };
  695. require(['base', 'select2', 'formatnumber', 'jsgrid', 'filer', 'common_eip', 'util'], fnPageInit);