9798b683cd0d5b135cef2152998845232e8165bb.svn-base 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550
  1. BemsWebApplication.ChargePrice2 = function (params, viewInfo) {
  2. var now = new Date();
  3. var selectEnergy = "전력";
  4. var priceType = new Array(2);
  5. var priceCodes;
  6. var selectedItem;
  7. var init = false;
  8. var handleViewShowninit;
  9. var endpointSelector = "";
  10. if (BemsWebApplication.config.mode == "production") {
  11. endpointSelector = new DevExpress.EndpointSelector(BemsWebApplication.config.endpoints).config.db.production;
  12. } else {
  13. endpointSelector = new DevExpress.EndpointSelector(BemsWebApplication.config.endpoints).config.db.local;
  14. }
  15. //권한설정
  16. var hasnotModificationPermission = ko.observable(true);
  17. //탭 표시 요금제 Array 데이터 초기화
  18. var tabsData = [
  19. {
  20. id: "0",
  21. text: "test1"
  22. },
  23. {
  24. id: "1",
  25. text: "test2"
  26. },
  27. {
  28. id: "2",
  29. text: "test3"
  30. }
  31. ];
  32. function setPriceCodeData(SiteID, FuelTypeId) {
  33. var dataSource = new DevExpress.data.DataSource({
  34. store: new DevExpress.data.ODataStore({
  35. url: endpointSelector + "/BemsSitePrice"
  36. }),
  37. expand: ['BemsPriceCode', 'BemsPriceType'],
  38. requireTotalCount: true,
  39. pageSize: 1000
  40. });
  41. dataSource.filter([
  42. ["SiteID", "=", SiteID],
  43. "and",
  44. ["FuelTypeId", "=", FuelTypeId],
  45. "and",
  46. ["UseYN", "=", "Y"],
  47. "and",
  48. ["PriceTypeId", "=", parseInt($("#tabOptions").dxTabs("instance").option('selectedItem').id)]
  49. ]);
  50. dataSource.sort({ getter: "PriceCode", asc: true });
  51. dataSource.load()
  52. .done(function (result) {
  53. if (result.length == 0) {
  54. return;
  55. }
  56. priceType[0] = result[0].PriceTypeId;
  57. priceType[1] = result[0].BemsPriceType.PriceTypeIdDesc;
  58. //$('#priceTypeId').text(priceType[1]);
  59. var tmpDate = $("#startDatePicker").dxDateBox("instance").option('value');
  60. var endDay = (new Date(tmpDate.getFullYear(), tmpDate.getMonth(), 0)).getDate();
  61. $("#startDate").dxDateBox("instance").option('value', new Date(tmpDate.getFullYear(), tmpDate.getMonth() - 1, 1, 0, 0, 0, 0));
  62. $("#endDate").dxDateBox("instance").option('value', new Date(tmpDate.getFullYear(), tmpDate.getMonth() - 1, endDay, 0, 0, 0, 0));
  63. var $detail = $('#detail'); // finds the <detail> element
  64. $('#detail').empty();
  65. priceCodes = new Array();
  66. for (var i = 0; i < result.length; i++) {
  67. priceCodes[i] = result[i].PriceCode;
  68. //<div class="dx-field-label cw-multi-field-label-ex">기본요금</div>
  69. //<div id="labelBaseCharge" class="dx-field-value" data-bind="text: '6,240,000'"></div>
  70. //<div id="txtBaseCharge" style="margin-left: 10px; position: absolute; left: 14%;" data-bind="dxTextBox: { value: '6,240,000' , placeholder: '기본요금' , visible : false}"></div>
  71. $('<div class="fl setText" style="line-height:220%;cursor:default;background:#d5ecfd url(../images/custom/ibems_light/arrow01.png) 5px center no-repeat;padding-left:15px;width:15%;height:32px;"></div>') // creates a new HTML element
  72. .appendTo($detail) // appends a new HTML element to the <body> element
  73. $('<div class="fl setInput" style="margin-left: 10px;width:15%;" data-bind="dxTextBox: {}"></div>')
  74. .appendTo($detail)
  75. .dxTextBox();
  76. if (i % 3 == 2) {
  77. $('<br>').appendTo($detail)
  78. $('<br>').appendTo($detail)
  79. }
  80. }
  81. var setTexts = document.querySelectorAll('.setText');
  82. var setInputs = document.querySelectorAll('.setInput');
  83. for (var i = 0; i < result.length; i++) {
  84. setTexts[i].id = "text" + result[i].PriceCode;
  85. setTexts[i].innerHTML = result[i].BemsPriceCode.PriceCodeDesc;
  86. setInputs[i].id = result[i].PriceCode;
  87. //$('#switch' + i).dxSwitch("instance").option('onText', 'On');
  88. //$('#switch' + i).dxSwitch("instance").option('offText', 'Off');
  89. }
  90. })
  91. .fail(function (error) {
  92. utils.toast.show(error);
  93. });
  94. }
  95. function getHistoryData(SiteId, FuelTypeId, PayDate) {
  96. var dataSource = new DevExpress.data.DataSource({
  97. store: new DevExpress.data.ODataStore({
  98. url: endpointSelector + "/BemsSitePriceHistory"
  99. }),
  100. expand: ['BemsPriceCode', 'BemsPriceType'],
  101. requireTotalCount: true,
  102. pageSize: 100
  103. });
  104. dataSource.filter([
  105. ["SiteId", "=", SiteId],
  106. "and",
  107. ["FuelTypeId", "=", FuelTypeId],
  108. "and",
  109. ["PayDate", "=", PayDate],
  110. "and",
  111. ["PriceTypeId", "=", parseInt($("#tabOptions").dxTabs("instance").option('selectedItem').id)]
  112. ]);
  113. dataSource.load()
  114. .done(function (result) {
  115. priceType[0] = result[0].PriceTypeId;
  116. priceType[1] = result[0].BemsPriceType.PriceTypeIdDesc;
  117. //$('#priceTypeId').text(priceType[1]);
  118. //$('#priceTypeId').text(priceType[1]);
  119. var tmpDate = $("#startDatePicker").dxDateBox("instance").option('value');
  120. var endDay = (new Date(tmpDate.getFullYear(), tmpDate.getMonth(), 0)).getDate();
  121. $("#startDate").dxDateBox("instance").option('value', result[0].StartDate);
  122. $("#endDate").dxDateBox("instance").option('value', result[0].EndDate);
  123. $("#startDate").dxDateBox("instance").option('readOnly', true);
  124. $("#endDate").dxDateBox("instance").option('readOnly', true);
  125. var $detail = $('#detail'); // finds the <detail> element
  126. $('#detail').empty();
  127. priceCodes = new Array();
  128. for (var i = 0; i < result.length; i++) {
  129. priceCodes[i] = result[i].PriceCode;
  130. $('<div class="fl setText" style="line-height:220%;cursor:default;background:#d5ecfd url(../images/custom/ibems_light/arrow01.png) 5px center no-repeat;padding-left:15px;width:15%;height:32px;"></div>') // creates a new HTML element
  131. .appendTo($detail) // appends a new HTML element to the <body> element
  132. $('<div class="fl setInput" style="margin-left: 10px;width:15%;" data-bind="dxTextBox: {}"></div>')
  133. .appendTo($detail)
  134. .dxTextBox();
  135. if (i % 3 == 2) {
  136. $('<br>').appendTo($detail)
  137. $('<br>').appendTo($detail)
  138. }
  139. }
  140. var setTexts = document.querySelectorAll('.setText');
  141. var setInputs = document.querySelectorAll('.setInput');
  142. for (var i = 0; i < result.length; i++) {
  143. setTexts[i].id = "text" + result[i].PriceCode;
  144. setTexts[i].innerHTML = result[i].BemsPriceCode.PriceCodeDesc;
  145. setInputs[i].id = result[i].PriceCode;
  146. $('#' + result[i].PriceCode).dxTextBox("instance").option('value', result[i].PriceValue);
  147. $('#' + result[i].PriceCode).dxTextBox("instance").option('readOnly', true);
  148. //$('#switch' + i).dxSwitch("instance").option('offText', 'Off');
  149. }
  150. })
  151. .fail(function (error) {
  152. utils.toast.show(error);
  153. });
  154. }
  155. function checkHistoryData(SiteId, FuelTypeId, PayDate) {
  156. var dataSource = new DevExpress.data.DataSource({
  157. store: new DevExpress.data.ODataStore({
  158. url: endpointSelector + "/BemsSitePriceHistory"
  159. }),
  160. requireTotalCount: true,
  161. pageSize: 100
  162. });
  163. dataSource.filter([
  164. ["SiteId", "=", SiteId],
  165. "and",
  166. ["FuelTypeId", "=", FuelTypeId],
  167. "and",
  168. ["PayDate", "=", PayDate],
  169. "and",
  170. ["PriceTypeId", "=", parseInt($("#tabOptions").dxTabs("instance").option('selectedItem').id)]
  171. ]);
  172. dataSource.load()
  173. .done(function (result) {
  174. if (result.length == 0) {
  175. $("#modifyBtn").dxButton("instance").option("text", "입력");
  176. if (!init) {
  177. if (handleViewShowninit) {
  178. setTabData(BWA.UserInfo.SiteId(), FuelTypeId, true);
  179. handleViewShowninit = false;
  180. }
  181. else
  182. setTabData(BWA.UserInfo.SiteId(), FuelTypeId, false);
  183. } else {
  184. setPriceCodeData(BWA.UserInfo.SiteId(), FuelTypeId);
  185. }
  186. } else {
  187. $("#modifyBtn").dxButton("instance").option("text", "수정");
  188. if (!init) {
  189. setTabData(BWA.UserInfo.SiteId(), FuelTypeId, true);
  190. } else {
  191. getHistoryData(BWA.UserInfo.SiteId(), FuelTypeId, PayDate);
  192. }
  193. }
  194. })
  195. .fail(function (error) {
  196. utils.toast.show(error);
  197. });
  198. }
  199. function insertSitePriceHistory(SiteId, FuelTypeId, PayDate) {
  200. var store = new DevExpress.data.ODataStore({
  201. url: endpointSelector + "/BemsSitePriceHistory",
  202. key: ["SiteId", "FuelTypeId", "PriceTypeId", "PriceCode", "PayDate"],
  203. keyType: { SiteId: "Int32", FuelTypeId: "Int32", PriceTypeId: "Int32", PriceCode: "String", PayDate: "String" }
  204. });
  205. var failCnt = 0;
  206. var startDate = $("#startDate").dxDateBox("instance").option('value');
  207. var endDate = $("#endDate").dxDateBox("instance").option('value');
  208. for (var i = 0; i < priceCodes.length; i++) {
  209. var priceValue = $("#" + priceCodes[i]).dxTextBox("instance").option('value');
  210. store.insert({
  211. SiteId: SiteId, FuelTypeId: FuelTypeId, PriceTypeId: priceType[0], PriceCode: priceCodes[i], PriceValue: priceValue, PayDate: PayDate, StartDate: startDate, EndDate: endDate, PayCharge: "0"
  212. })
  213. .done(function (key, result) {
  214. //utils.toast.show(key + "/" + result);
  215. })
  216. .fail(function (error) {
  217. failCnt++;
  218. });
  219. }
  220. if (failCnt > 0) {
  221. utils.toast.show("저장이 실패했습니다.");
  222. } else {
  223. utils.toast.show("저장이 완료 되었습니다.");
  224. }
  225. }
  226. function updateSitePriceHistory(SiteId, FuelTypeId, PayDate) {
  227. var failCnt = 0;
  228. var store = new DevExpress.data.ODataStore({
  229. url: endpointSelector + "/BemsSitePriceHistory",
  230. key: ["SiteId", "FuelTypeId", "PriceTypeId", "PriceCode", "PayDate"],
  231. keyType: { SiteId: "Int32", FuelTypeId: "Int32", PriceTypeId: "Int32", PriceCode: "String", PayDate: "String" }
  232. });
  233. var startDate = $("#startDate").dxDateBox("instance").option('value');
  234. var endDate = $("#endDate").dxDateBox("instance").option('value');
  235. for (var i = 0; i < priceCodes.length; i++) {
  236. var priceValue = $("#" + priceCodes[i]).dxTextBox("instance").option('value');
  237. store.update({ SiteId: SiteId, FuelTypeId: FuelTypeId, PriceTypeId: priceType[0], PriceCode: priceCodes[i], PayDate: PayDate }, { PriceValue: priceValue, StartDate: startDate, EndDate: endDate })
  238. .done(function (key, result) {
  239. //utils.toast.show(key + "/" + result);
  240. })
  241. .fail(function (error) {
  242. failCnt++;
  243. });
  244. }
  245. if (failCnt > 0) {
  246. utils.toast.show("업데이트가 실패했습니다.");
  247. } else {
  248. utils.toast.show("저장 되었습니다.");
  249. }
  250. }
  251. function disableReadOnly() {
  252. for (var i = 0; i < priceCodes.length; i++) {
  253. $("#" + priceCodes[i]).dxTextBox("instance").option('readOnly', false);
  254. }
  255. $("#startDate").dxDateBox("instance").option('readOnly', false);
  256. $("#endDate").dxDateBox("instance").option('readOnly', false);
  257. }
  258. function enableReadOnly() {
  259. for (var i = 0; i < priceCodes.length; i++) {
  260. $("#" + priceCodes[i]).dxTextBox("instance").option('readOnly', true);
  261. }
  262. $("#startDate").dxDateBox("instance").option('readOnly', true);
  263. $("#endDate").dxDateBox("instance").option('readOnly', true);
  264. }
  265. function setTabData(SiteID, FuelTypeId, HistoryDataYN) {
  266. var dataSource;
  267. if (!HistoryDataYN) {
  268. dataSource = new DevExpress.data.DataSource({
  269. store: new DevExpress.data.ODataStore({
  270. url: endpointSelector + "/BemsSitePrice"
  271. }),
  272. expand: ['BemsPriceType'],
  273. requireTotalCount: true,
  274. pageSize: 1000
  275. });
  276. dataSource.filter([
  277. ["SiteID", "=", SiteID],
  278. "and",
  279. ["FuelTypeId", "=", FuelTypeId]
  280. ]);
  281. } else {
  282. dataSource = new DevExpress.data.DataSource({
  283. store: new DevExpress.data.ODataStore({
  284. url: endpointSelector + "/BemsSitePriceHistory"
  285. }),
  286. expand: ['BemsPriceType'],
  287. requireTotalCount: true,
  288. pageSize: 1000
  289. });
  290. var searchDate = $("#startDatePicker").dxDateBox("instance").option('value');
  291. var tmpMonth = (searchDate.getMonth() + 1).toString();
  292. if (tmpMonth.length == 1) {
  293. tmpMonth = "0" + tmpMonth;
  294. }
  295. dataSource.filter([
  296. ["SiteId", "=", SiteID],
  297. "and",
  298. ["FuelTypeId", "=", FuelTypeId],
  299. "and",
  300. ["PayDate", "=", searchDate.getFullYear().toString() + tmpMonth]
  301. ]);
  302. }
  303. dataSource.sort({ getter: "FuelTypeId", asc: true });
  304. dataSource.load()
  305. .done(function (result) {
  306. if (result.length == 0 && HistoryDataYN == true) {
  307. setTabData(SiteID, FuelTypeId, false);
  308. return;
  309. }
  310. var tmp = [];
  311. tmp.push({ id: result[0].BemsPriceType.PriceTypeId, text: result[0].BemsPriceType.PriceTypeIdDesc });
  312. for (var i = 0; i < result.length; i++) {
  313. var resultCnt;
  314. for (var j = 0; j < tmp.length; j++) {
  315. if (tmp[j].text.indexOf(result[i].BemsPriceType.PriceTypeIdDesc) != -1) {
  316. resultCnt++;
  317. }
  318. }
  319. if (resultCnt == 0)
  320. tmp.push({ id: result[i].BemsPriceType.PriceTypeId, text: result[i].BemsPriceType.PriceTypeIdDesc });
  321. resultCnt = 0;
  322. }
  323. tabsData = tmp;
  324. $("#tabOptions").dxTabs("instance").option('dataSource', tabsData);
  325. if (!init) {
  326. $("#tabOptions").dxTabs("instance").option('selectedIndex', 0);
  327. init = true;
  328. } else {
  329. }
  330. if (!HistoryDataYN) {
  331. setPriceCodeData(BWA.UserInfo.SiteId(), FuelTypeId);
  332. } else {
  333. var tmpDate = $("#startDatePicker").dxDateBox("instance").option('value');
  334. var month = tmpDate.getMonth() + 1;
  335. if (month < 10) {
  336. month = "0" + month.toString();
  337. }
  338. getHistoryData(BWA.UserInfo.SiteId(), FuelTypeId, tmpDate.getFullYear().toString() + month);
  339. }
  340. });
  341. }
  342. function handleViewShown() {
  343. //권한설정
  344. hasnotModificationPermission(!BWA.UserInfo.hasPermissionOfModification(viewInfo.viewName));
  345. init = false;
  346. var tmpDate = $("#startDatePicker").dxDateBox("instance").option('value');
  347. var month = tmpDate.getMonth() + 1;
  348. if (month < 10) {
  349. month = "0" + month.toString();
  350. }
  351. var endDay = (new Date(tmpDate.getFullYear(), tmpDate.getMonth(), 0)).getDate();
  352. $("#powerBtn").css("background-image", "linear-gradient(180deg,#9babc3 0%,#41618c 100%)");
  353. $("#gasBtn").css("background-image", "linear-gradient(rgb(56,88,130) 0%, rgb(44,68,101)100%)");
  354. $("#waterBtn").css("background-image", "linear-gradient(rgb(56,88,130) 0%, rgb(44,68,101)100%)");
  355. selectEnergy = "전력";
  356. handleViewShowninit = true;
  357. //checkHistoryData(BWA.UserInfo.SiteId(), 1, tmpDate.getFullYear().toString() + month);//먼가 오류? 하단의 내용으로 변경190820
  358. setTabData(BWA.UserInfo.SiteId(), 1, false);
  359. setTimeout(function () {
  360. checkHistoryData(BWA.UserInfo.SiteId(), 1, tmpDate.getFullYear().toString() + month);
  361. }, 1000);
  362. }
  363. var searchViewOptions = {
  364. //templete function
  365. };
  366. function handleSearchInSearchView() {
  367. //templete function
  368. }
  369. var viewModel = $.extend(BWA.CommonView.create(params, viewInfo, searchViewOptions, ko.observable(null), handleViewShown, null, handleSearchInSearchView),
  370. {
  371. startDatePicker: {
  372. pickerType: "calendar",
  373. value: now,
  374. formatString: "yyyy년 MM월",
  375. maxZoomLevel: "year",
  376. width: "9%",
  377. onValueChanged: function () {
  378. var tmpDate = $("#startDatePicker").dxDateBox("instance").option('value');
  379. var month = tmpDate.getMonth() + 1;
  380. if (month < 10) {
  381. month = "0" + month.toString();
  382. }
  383. var endDay = (new Date(tmpDate.getFullYear(), tmpDate.getMonth(), 0)).getDate();
  384. var FuelTypeId = 0;
  385. if (selectEnergy == "전력") {
  386. FuelTypeId = 1;
  387. } else if (selectEnergy == "가스") {
  388. FuelTypeId = 2;
  389. } else if (selectEnergy == "수도") {
  390. FuelTypeId = 3;
  391. } else {
  392. utils.toast.show("선택된 에너지원이 없습니다.");
  393. }
  394. init = false;
  395. //checkHistoryData(BWA.UserInfo.SiteId(), FuelTypeId, tmpDate.getFullYear().toString() + month); //먼가 오류? 하단의 내용으로 변경190820
  396. setTabData(BWA.UserInfo.SiteId(), FuelTypeId, false);
  397. setTimeout(function () {
  398. checkHistoryData(BWA.UserInfo.SiteId(), FuelTypeId, tmpDate.getFullYear().toString() + month);
  399. }, 1000);
  400. }
  401. },
  402. startDate: {
  403. pickerType: "calendar",
  404. value: now,
  405. formatString: "yyyy년 MM월 dd일",
  406. maxZoomLevel: "month",
  407. width: "12%"
  408. },
  409. endDate: {
  410. pickerType: "calendar",
  411. value: now,
  412. formatString: "yyyy년 MM월 dd일",
  413. maxZoomLevel: "month",
  414. width: "12%"
  415. },
  416. powerButtonClicked: function () {
  417. init = false;
  418. $("#tabOptions").dxTabs("instance").option('selectedIndex', 0);
  419. $("#powerBtn").css("background-image", "linear-gradient(180deg,#9babc3 0%,#41618c 100%)");
  420. $("#gasBtn").css("background-image", "linear-gradient(rgb(56,88,130) 0%, rgb(44,68,101)100%)");
  421. $("#waterBtn").css("background-image", "linear-gradient(rgb(56,88,130) 0%, rgb(44,68,101)100%)");
  422. selectEnergy = "전력";
  423. var tmpDate = $("#startDatePicker").dxDateBox("instance").option('value');
  424. var month = tmpDate.getMonth() + 1;
  425. if (month < 10) {
  426. month = "0" + month.toString();
  427. }
  428. var endDay = (new Date(tmpDate.getFullYear(), tmpDate.getMonth(), 0)).getDate();
  429. setTabData(BWA.UserInfo.SiteId(), 1, false);
  430. setTimeout(function () {
  431. checkHistoryData(BWA.UserInfo.SiteId(), 1, tmpDate.getFullYear().toString() + month);
  432. }, 1000);
  433. },
  434. gasButtonClicked: function () {
  435. init = false;
  436. $("#tabOptions").dxTabs("instance").option('selectedIndex', 0);
  437. $("#gasBtn").css("background-image", "linear-gradient(180deg,#9babc3 0%,#41618c 100%)");
  438. $("#powerBtn").css("background-image", "linear-gradient(rgb(56,88,130) 0%, rgb(44,68,101)100%)");
  439. $("#waterBtn").css("background-image", "linear-gradient(rgb(56,88,130) 0%, rgb(44,68,101)100%)");
  440. selectEnergy = "가스";
  441. var tmpDate = $("#startDatePicker").dxDateBox("instance").option('value');
  442. var month = tmpDate.getMonth() + 1;
  443. if (month < 10) {
  444. month = "0" + month.toString();
  445. }
  446. var endDay = (new Date(tmpDate.getFullYear(), tmpDate.getMonth(), 0)).getDate();
  447. setTabData(BWA.UserInfo.SiteId(), 2, false);
  448. setTimeout(function () {
  449. checkHistoryData(BWA.UserInfo.SiteId(), 2, tmpDate.getFullYear().toString() + month);
  450. }, 1000);
  451. },
  452. waterButtonClicked: function () {
  453. init = false;
  454. $("#tabOptions").dxTabs("instance").option('selectedIndex', 0);
  455. $("#waterBtn").css("background-image", "linear-gradient(180deg,#9babc3 0%,#41618c 100%)");
  456. $("#gasBtn").css("background-image", "linear-gradient(rgb(56,88,130) 0%, rgb(44,68,101)100%)");
  457. $("#powerBtn").css("background-image", "linear-gradient(rgb(56,88,130) 0%, rgb(44,68,101)100%)");
  458. selectEnergy = "수도";
  459. var tmpDate = $("#startDatePicker").dxDateBox("instance").option('value');
  460. var month = tmpDate.getMonth() + 1;
  461. if (month < 10) {
  462. month = "0" + month.toString();
  463. }
  464. var endDay = (new Date(tmpDate.getFullYear(), tmpDate.getMonth(), 0)).getDate();
  465. setTabData(BWA.UserInfo.SiteId(), 3, false);
  466. setTimeout(function () {
  467. checkHistoryData(BWA.UserInfo.SiteId(), 3, tmpDate.getFullYear().toString() + month);
  468. }, 1000);
  469. },
  470. modifyButtonClicked: function () {
  471. var FuelTypeId = 0;
  472. if (selectEnergy == "전력") {
  473. FuelTypeId = 1;
  474. } else if (selectEnergy == "가스") {
  475. FuelTypeId = 2;
  476. } else if (selectEnergy == "수도") {
  477. FuelTypeId = 3;
  478. } else {
  479. utils.toast.show("선택된 에너지원이 없습니다.");
  480. }
  481. var tmpDate = $("#startDatePicker").dxDateBox("instance").option('value');
  482. var month = tmpDate.getMonth() + 1;
  483. if (month < 10) {
  484. month = "0" + month.toString();
  485. }
  486. var payDate = tmpDate.getFullYear().toString() + month;
  487. if ($("#modifyBtn").dxButton("instance").option("text") == "입력") {
  488. $("#modifyBtn").dxButton("instance").option("text", "수정");
  489. insertSitePriceHistory(BWA.UserInfo.SiteId(), FuelTypeId, payDate);
  490. enableReadOnly();
  491. } else if ($("#modifyBtn").dxButton("instance").option("text") == "수정") {
  492. $("#modifyBtn").dxButton("instance").option("text", "확인");
  493. disableReadOnly();
  494. } else if ($("#modifyBtn").dxButton("instance").option("text") == "확인") {
  495. $("#modifyBtn").dxButton("instance").option("text", "수정");
  496. updateSitePriceHistory(BWA.UserInfo.SiteId(), FuelTypeId, payDate);
  497. } else {
  498. utils.toast.show("선택된 버튼이 없습니다.");
  499. }
  500. },
  501. tabOptions: {
  502. //theme: 'generic.light',
  503. dataSource: tabsData,
  504. height: 20,
  505. selectedIndex: 0,
  506. onSelectionChanged: function (e) {
  507. //$("#priceSelect").dxSelectBox("instance").option('value', e.addedItems[0].id);
  508. selectedItem = e.addedItems[0];
  509. if (init) {
  510. var FuelTypeId;
  511. if (selectEnergy == "전력") {
  512. FuelTypeId = 1;
  513. } else if (selectEnergy == "가스") {
  514. FuelTypeId = 2;
  515. } else if (selectEnergy == "수도") {
  516. FuelTypeId = 3;
  517. } else {
  518. utils.toast.show("에너지원이 선택되지 않았습니다.");
  519. }
  520. var tmpDate = $("#startDatePicker").dxDateBox("instance").option('value');
  521. var month = tmpDate.getMonth() + 1;
  522. if (month < 10) {
  523. month = "0" + month.toString();
  524. }
  525. var endDay = (new Date(tmpDate.getFullYear(), tmpDate.getMonth(), 0)).getDate();
  526. checkHistoryData(BWA.UserInfo.SiteId(), FuelTypeId, tmpDate.getFullYear().toString() + month);
  527. }
  528. }
  529. },
  530. hasnotModificationPermission: hasnotModificationPermission //권한설정
  531. });
  532. return viewModel;
  533. };