ChartInquiryPage.cshtml 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468
  1. 
  2. <div id="SearchOnlineMonitorDiv" class="tank_table_div">
  3. <form action="" method="post">
  4. <div v-if="currentTab == 'searchChartTab'" class="chart_form_div" ref="canvasdiv">
  5. <canvas ref="canvasRef" style="width:100%;height:100%;" />
  6. </div>
  7. </form>
  8. <div v-if="currentTab == 'searchChartTab'" class="config-search-navigation" :style="panelStyle">
  9. <div v-if="currentlang.indexOf('zh-tw') >= 0" class="config-search-tab">篩選查詢</div>
  10. <div v-else class="config-search-tab">筛选查询</div>
  11. <div v-if="currentlang.indexOf('zh-tw') >= 0" class="config-search-lable">起始日期:</div>
  12. <div v-else class="config-search-lable">起始日期:</div>
  13. <input class="config-search-input" type="text" v-model="startDate" />
  14. <input class="config-search-date" type="datetime-local" v-model="stdatetime" @@change="change('startDate')" />
  15. <div v-if="currentlang.indexOf('zh-tw') >= 0" class="config-search-lable">結束日期:</div>
  16. <div v-else class="config-search-lable">结束日期:</div>
  17. <input class="config-search-input" type="text" v-model="endDate" />
  18. <input class="config-search-date" type="datetime-local" v-model="stdatetime" @@change="change('endDate')" />
  19. <div v-if="currentlang.indexOf('zh-tw') >= 0" class="config-search-lable">油槍選擇:</div>
  20. <div v-else class="config-search-lable">油枪选择:</div>
  21. <input class="config-search-input input" type="text" v-model="nozzleNumber" @@click="show" />
  22. @*<select class="config-form-select" v-model="nozzleNumber">
  23. <option v-for="(item, i) in nozzleArray" :key="i" :value="item.SiteLevelNozzleId">{{item.SiteLevelNozzleId}}号枪 {{item.Product.ProductLabel}}</option>
  24. </select>*@
  25. <div>
  26. <div class="search_chart_div" @@click="search('searchChartTab')"></div>
  27. @*<div class="search_list_div" @@click="search('searchListTab')"></div>*@
  28. </div>
  29. </div>
  30. <div class="tank_filter_div" :style="showFilter" @@click="clickFilter()">
  31. </div>
  32. </div>
  33. <script type="text/javascript">
  34. Vue.component("downloadExcel", JsonExcel);
  35. var vm = new Vue({
  36. el: '#SearchOnlineMonitorDiv',
  37. data: {
  38. currentlang: "",
  39. filename: ".xls",
  40. excel_header: "",
  41. json_fields: {
  42. '枪号': 'SiteLevelNozzleId',
  43. '时间': 'FuellingStartTime',
  44. '加油时间(s)': 'FuellingTime',
  45. 'A/L(%)': 'VaporLiquidRatio',
  46. '油气流量(L)': 'VaporVolumeWithDecimal',
  47. '燃油流量(L)': 'LiquidVolumeWithDecimal',
  48. '最大气体流速(L/s)': 'MaxAirFlowRateWithDecimal',
  49. '最大燃油流速(L/s)': 'MaxLiquidFlowRateWithDecimal',
  50. '油罐压力(Pa)': 'TankPressure'
  51. },
  52. currentTab: 'searchChartTab',
  53. warningValueMin: 0.58,
  54. warningValueMax: 1.98,
  55. warningPointColor: 'rgba(255, 105, 180,1)',
  56. normalPointColor: 'rgba(0, 0, 255, 1)',
  57. nozzleArray: [],
  58. nozzleNumber: 1,
  59. stdatetime: null,
  60. startDate: null,
  61. endDate: null,
  62. alChart: null,
  63. boardDatas: [],
  64. chartWidth: 0,
  65. startIndex: 0,
  66. rowCount: 8,
  67. tankPressure: '-10000.01 ~ 20000.01',
  68. liquidPressure: '-10000.01 ~ 20000.01',
  69. gasConcentrations: '-10.01 ~ 20000.01',
  70. config_scatterChart: {
  71. type: 'scatter',
  72. data: {
  73. startDate: null,
  74. endDate: null,
  75. alChart: null,
  76. //labels: [],
  77. datasets: [
  78. {
  79. type: 'line',
  80. label: '汽液比最大值',
  81. borderColor: ['rgba(0, 128, 128, 1)'],
  82. pointRadius: 0,
  83. fill: false,
  84. yAxisID: 'y-axis-1',
  85. borderWidth: 1
  86. //data: [0, 0, 0]
  87. }, {
  88. type: 'line',
  89. label: '汽液比最小值',
  90. borderColor: ['rgba(255, 105, 180, 1)'],
  91. pointRadius: 0,
  92. fill: false,
  93. yAxisID: 'y-axis-1',
  94. borderWidth: 1
  95. //data: [0, 0, 0]
  96. }, {
  97. type: 'line',
  98. label: '汽液比',
  99. borderColor: ['rgba(255, 127, 0, 1)'],
  100. pointRadius: 3,
  101. //pointStyle: 'crossRot',
  102. borderWidth: 1,
  103. fill: false,
  104. yAxisID: 'y-axis-1'
  105. //data: [0, 0, 0]
  106. }, {
  107. type: 'line',
  108. label: '加油量',
  109. borderColor: ['rgba(255, 127, 0, 1)'],
  110. pointRadius: 3,
  111. borderWidth: 1,
  112. fill: false,
  113. yAxisID: 'y-axis-1'
  114. }, {
  115. type: 'line',
  116. label: '油气量',
  117. borderColor: ['rgba(0, 255, 0, 1)'],
  118. pointRadius: 3,
  119. borderWidth: 1,
  120. fill: false,
  121. yAxisID: 'y-axis-1'
  122. }, {
  123. type: 'line',
  124. label: '最大加油速度',
  125. borderColor: ['rgba(0, 191, 255, 1)'],
  126. pointRadius: 3,
  127. borderWidth: 1,
  128. fill: false,
  129. yAxisID: 'y-axis-1'
  130. }, {
  131. type: 'line',
  132. label: '最大油气速度',
  133. borderColor: ['rgba(138, 43, 226, 1)'],
  134. pointRadius: 3,
  135. borderWidth: 1,
  136. fill: false,
  137. yAxisID: 'y-axis-1'
  138. }, {
  139. type: 'line',
  140. label: '平均加油速度',
  141. borderColor: ['rgba(255, 255, 0, 1)'],
  142. pointRadius: 3,
  143. borderWidth: 1,
  144. fill: false,
  145. yAxisID: 'y-axis-1'
  146. }, {
  147. type: 'line',
  148. label: '平均油气速度',
  149. borderColor: ['rgba(255, 0, 0, 1)'],
  150. pointRadius: 3,
  151. borderWidth: 1,
  152. fill: false,
  153. yAxisID: 'y-axis-1'
  154. }
  155. ]
  156. },
  157. options: {
  158. responsive: true,
  159. hoverMode: 'index',
  160. stacked: true,
  161. animation: {
  162. duration: 0 // general animation time
  163. },
  164. hover: {
  165. animationDuration: 0 // duration of animations when hovering an item
  166. },
  167. responsiveAnimationDuration: 0, // animation duration after a resize
  168. //title: {
  169. // display: true,
  170. // text: '汽液比散点图',
  171. // fontSize: 35,
  172. // fontColor: "#000"
  173. //},
  174. scales: {
  175. xAxes: [{
  176. type: 'time',
  177. distribution: 'linear',
  178. time: {
  179. stepSize: 2,
  180. displayFormats: {
  181. day: 'MM-DD',
  182. hour: 'DD HH',
  183. minute: 'DD HH:mm'
  184. }
  185. },
  186. scaleLabel: {
  187. display: true,
  188. labelString: '时间',
  189. fontSize: 20
  190. },
  191. ticks: {
  192. autoSkip: true,
  193. maxTicksLimit: 20
  194. },
  195. gridLines: {
  196. lineWidth: 0
  197. }
  198. }],
  199. yAxes: [{
  200. type: 'linear', // only linear but allow scale type registration. This allows extensions to exist solely for log scale for instance
  201. display: true,
  202. position: 'left',
  203. id: 'y-axis-1',
  204. ticks: {
  205. beginAtZero: false,
  206. suggestedMin: 0,
  207. suggestedMax: 1.8,
  208. stepSize: 0.1
  209. },
  210. scaleLabel: {
  211. display: true,
  212. labelString: '汽液比',
  213. fontSize: 20
  214. },
  215. gridLines: {
  216. lineWidth: 0
  217. }
  218. }],
  219. elements: {
  220. line: {
  221. tension: 1 // disables bezier curves
  222. }
  223. }
  224. },
  225. tooltips: {
  226. mode: 'index',
  227. intersect: true
  228. }
  229. }
  230. },
  231. airLiquidList: [{
  232. SiteLevelNozzleId: 3, TimeStamp: '21-03-26 13:30:18', FuellingTime: 28, VaporLiquidRatio: 118, VaporVolumeWithDecimal: 18.19, LiquidVolumeWithDecimal: 28.31,
  233. TankPressure: 12.33, MaxAirFlowRateWithDecimal: 12.33, MaxLiquidFlowRateWithDecimal: 12.33
  234. }],
  235. excelAirLiquidList: [],
  236. inventoryFilter: [],
  237. deliveryFilter: [],
  238. panelStyle: 'visibility: hidden;',
  239. showFilter: 'visibility: visible;'
  240. },
  241. mounted() {
  242. let today = new Date()
  243. this.startDate = this.toDateString(today) + ' 00:00:00'
  244. this.endDate = this.toDateString(today) + ' 23:59:59'
  245. this.nozzleArray = [{ SiteLevelNozzleId: 8, Product: { ProductLabel: "92#" } }]
  246. this.currentlang = (navigator.language || navigator.userLanguage || navigator.browserLanguage).toLowerCase();
  247. if (this.currentlang.indexOf('zh-tw') >= 0) {
  248. this.config_scatterChart.data.datasets[4].label = '油氣量';
  249. this.config_scatterChart.data.datasets[6].label = '最大油氣速度';
  250. this.config_scatterChart.data.datasets[8].label = '平均油氣速度';
  251. this.config_scatterChart.options.scales.xAxes[0].scaleLabel.labelString = '時間';
  252. }
  253. this.getdatas()
  254. },
  255. methods: {
  256. show(e) {
  257. showKeyboard("default", e.currentTarget)
  258. },
  259. UpdateALScatterChart(datas) {
  260. if (this.alChart == null) {
  261. //this.$refs.canvasRef.height = this.$refs.canvasdiv.clientWidth / 10
  262. this.alChart = new Chart(this.$refs.canvasRef, this.config_scatterChart);
  263. }
  264. if (this.alChart == null || datas == null) return;
  265. //remove the old data in the chart
  266. this.alChart.data.labels.splice(0, this.alChart.data.labels.length);
  267. this.alChart.data.datasets.forEach((dataset) => {
  268. dataset.data.splice(0, dataset.data.length);
  269. });
  270. this.alChart.update();
  271. for (let index in datas) {
  272. let dt = datas[index]
  273. this.alChart.data.datasets[0].data.push(this.warningValueMax);
  274. this.alChart.data.datasets[1].data.push(this.warningValueMin);
  275. this.alChart.data.datasets[2].data.push(dt.VaporLiquidRatio);
  276. this.alChart.data.datasets[3].data.push(dt.LiquidVolumeWithDecimal);
  277. this.alChart.data.datasets[4].data.push(dt.VaporVolumeWithDecimal);
  278. this.alChart.data.datasets[5].data.push(dt.MaxLiquidFlowRateWithDecimal);
  279. this.alChart.data.datasets[6].data.push(dt.MaxAirFlowRateWithDecimal);
  280. this.alChart.data.datasets[7].data.push(dt.AvgLiquidFlowRateWithDecimal);
  281. this.alChart.data.datasets[8].data.push(dt.AvgAirFlowRateWithDecimal);
  282. this.alChart.data.labels.push(dt.FuellingEndTime);
  283. }
  284. let i = 0;
  285. this.alChart.data.datasets[2].data.forEach((data) => {
  286. if (data === 0) {
  287. this.config_scatterChart.data.datasets[2].borderColor[i] = 'rgba(192, 192, 192, 0)';
  288. } else if (data > this.warningValueMax || data < this.warningValueMin) {
  289. this.config_scatterChart.data.datasets[2].borderColor[i] = this.warningPointColor;
  290. } else {
  291. this.config_scatterChart.data.datasets[2].borderColor[i] = this.normalPointColor;
  292. }
  293. i++;
  294. });
  295. for (let dsi = 3; dsi < this.alChart.data.datasets.length; dsi++) {
  296. let i = 1;
  297. this.alChart.data.datasets[dsi].data.forEach((data) => {
  298. this.config_scatterChart.data.datasets[dsi].borderColor[i] = this.config_scatterChart.data.datasets[dsi].borderColor[0];
  299. i++;
  300. });
  301. }
  302. this.alChart.chart.width = this.$refs.canvasdiv.clientWidth * 0.99
  303. this.alChart.update();
  304. },
  305. search(tab) {
  306. this.currentTab = tab
  307. this.panelStyle = 'visibility: hidden;'
  308. this.showFilter = 'visibility: visible;'
  309. this.startIndex = 0
  310. this.getdatas()
  311. },
  312. getdatas() {
  313. let path = '/sys/Vapor_Recovery_App/Application.VaporRecoveryApp.App/thing/service/'
  314. this.filename = 'result_' + this.startDate.replace(/-/g, "").substr(2, 6) + '-' + this.endDate.replace(/-/g, "").substr(2, 6) + ".xls"
  315. this.excel_header = '起始日期:' + this.startDate + '结束日期:' + this.endDate
  316. if (this.currentlang.indexOf('zh-tw') >= 0) {
  317. this.excel_header = '起始日期:' + this.startDate + '結束日期:' + this.endDate
  318. }
  319. let args = '["' + this.startDate.replace(/ /g, "T") + '","' + this.endDate.replace(/ /g, "T") + '",' + this.nozzleNumber
  320. args += ',0,2000080000,"","",""]'
  321. Publish1(path, 'GetVaporRecoveryConfig')
  322. Publish2(args, path, 'GetVRBoardNozzleTrxFlowDatas')
  323. this.$forceUpdate()
  324. },
  325. UpdateFooterPage() {
  326. if (document.getElementById("PumpsPage_Bottom_pages") != null) {
  327. var footerPage = document.getElementById("PumpsPage_Bottom_pages");
  328. if (this.currentTab == 'searchListTab') {
  329. footerPage.style.visibility = "visible";
  330. footerPage.style.display = "";
  331. } else { footerPage.style.visibility = "hidden"; footerPage.style.display = "none"; }
  332. }
  333. },
  334. clickFilter() {
  335. if (this.currentTab == 'searchChartTab') {
  336. this.resizeChart(0.88)
  337. }
  338. this.panelStyle = 'visibility: visible;'
  339. this.showFilter = 'visibility: hidden;'
  340. },
  341. resizeChart(ratio) {
  342. this.chartWidth = this.alChart.chart.width
  343. this.alChart.chart.width = this.$refs.canvasdiv.clientWidth * ratio
  344. this.$refs.canvasRef.getContext("2d").clearRect(0, 0, this.$refs.canvasRef.width, this.$refs.canvasRef.height)
  345. this.alChart.update()
  346. },
  347. PrefixInteger(num, length) {
  348. return ('000' + num).substr(-length)
  349. },
  350. change(target) {
  351. let val = this.stdatetime.replace(/T/g, " ") + ':00'
  352. if (target === 'startDate') {
  353. this.startDate = val
  354. } else {
  355. this.endDate = val
  356. }
  357. },
  358. formatDate(value) {
  359. let realVal = ''
  360. if (value !== null && typeof (value) !== 'undefined') {
  361. realVal = value.substring(0, 16).replace('T', ' ')
  362. } else {
  363. realVal = 'N/A'
  364. }
  365. return realVal
  366. },
  367. toDateString(date) {
  368. return date.getFullYear() + '-' + this.PrefixInteger(date.getMonth() + 1, 2) + '-' + this.PrefixInteger(date.getDate(), 2)
  369. }
  370. },
  371. watch: {
  372. boardDatas: {
  373. handler(newValue, oldValue) {
  374. this.UpdateALScatterChart(newValue)
  375. this.UpdateFooterPage()
  376. },
  377. deep: true
  378. },
  379. airLiquidList: {
  380. handler(newValue, oldValue) {
  381. for (let index in newValue) {
  382. let dt = newValue[index]
  383. dt.FuellingTime = (new Date(dt.FuellingEndTime) - new Date(dt.FuellingStartTime)) / 1000
  384. dt.FuellingStartTime = this.formatDate(dt.FuellingStartTime)
  385. }
  386. this.UpdateFooterPage()
  387. this.$forceUpdate()
  388. },
  389. deep: true
  390. }
  391. },
  392. filters: {
  393. numFilter(value) {
  394. let realVal = ''
  395. if (!isNaN(value) && value !== '') {
  396. realVal = parseFloat(value).toFixed(3)
  397. } else {
  398. realVal = 'N/A'
  399. }
  400. return realVal
  401. }
  402. }
  403. })
  404. function OnReply(apis, topic, jsonObj) {
  405. let boardpath = apis.has("GetVRBoardNozzleTrxFlowDatas_Reply") ? apis.get("GetVRBoardNozzleTrxFlowDatas_Reply") : '/sys/Vapor_Recovery_App/Application.VaporRecoveryApp.App/thing/service/GetVRBoardNozzleTrxFlowDatas_Reply'
  406. let vrconfigpath = apis.has("GetVaporRecoveryConfig_Reply") ? apis.get("GetVaporRecoveryConfig_Reply") : '/sys/Vapor_Recovery_App/Application.VaporRecoveryApp.App/thing/service/GetVaporRecoveryConfig_Reply'
  407. if (topic === boardpath) {
  408. if (vm.currentTab == 'searchChartTab') {
  409. vm.boardDatas = jsonObj
  410. } else if (vm.currentTab == 'searchListTab') {
  411. if (jsonObj.length > vm.rowCount) {
  412. vm.excelAirLiquidList = jsonObj
  413. } else {
  414. vm.airLiquidList = jsonObj
  415. vm.excelAirLiquidList = jsonObj
  416. }
  417. }
  418. } else if (topic === vrconfigpath) {
  419. vm.warningValueMin = jsonObj.QualifiedAirLiquidRatioMin
  420. vm.warningValueMax = jsonObj.QualifiedAirLiquidRatioMax
  421. }
  422. }
  423. function ShowPreviousPage() {
  424. if (vm.startIndex <= 0) {
  425. dialogBox("提示信息", "已經是第一頁", null, null);
  426. return
  427. }
  428. vm.startIndex -= vm.rowCount
  429. vm.getdatas()
  430. }
  431. function ShowNextPage() {
  432. if (vm.rowCount > vm.airLiquidList.length) {
  433. dialogBox("提示信息", "已經是最後一頁", null, null)
  434. return
  435. }
  436. vm.startIndex += vm.rowCount
  437. vm.getdatas()
  438. }
  439. function UpdateFooterPage() {
  440. if (document.getElementById("PumpsPage_Bottom_pages") != null) {
  441. for (var p = 1; p < 6; p++) {
  442. var imgCurrentPageIdStr = "PumpsPage_Bottom_pages_img_" + p;
  443. var imgCurrentPageNotShowedIdStr = "PumpsPage_Bottom_pages_notshowed_img_" + p;
  444. if (document.getElementById(imgCurrentPageIdStr) != null)
  445. document.getElementById(imgCurrentPageIdStr).style.visibility = "hidden";
  446. if (document.getElementById(imgCurrentPageNotShowedIdStr) != null)
  447. document.getElementById(imgCurrentPageNotShowedIdStr).style.visibility = "hidden";
  448. }
  449. //update next page img position
  450. var nextPageImg = document.getElementById("PumpsPage_Bottom_pages_img_next_page");
  451. var previousPageImg = document.getElementById("PumpsPage_Bottom_pages_img_previous_page");
  452. previousPageImg.style.visibility = "visible";
  453. if (nextPageImg != null) {
  454. //if (totalPage < 5)
  455. nextPageImg.style.left = (16.5 * 1 + 5).toString() + "%";
  456. nextPageImg.style.visibility = "visible";
  457. }
  458. }
  459. }
  460. UpdateFooterPage();
  461. </script>