Advertisement
Guest User

Untitled

a guest
Jun 25th, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 13.50 KB | None | 0 0
  1. <template>
  2. <div>
  3. <div class="container">
  4. <div class="font-weight-semibold font-size-large mb-4">Розміщення зданих в оренду кавоварок</div>
  5. <div class="row">
  6. <div class="col-12 col-md-6 col-lg-8 mb-3 mb-md-0 d-flex">
  7. <div class="border w-100" style="min-height: 300px;">
  8. <div id="map" style="height: 100%"></div>
  9. <div id="notifications"></div>
  10. </div>
  11. </div>
  12. <div class="col-12 col-md-6 col-lg-4 d-flex">
  13. <div class="card w-100">
  14. <div class="card-body d-flex flex-column justify-content-between">
  15. <div class="row justify-content-between mb-4">
  16. <div class="col-auto font-weight-bold font-size-large">Всього:</div>
  17. <div class="col-auto font-weight-bold font-size-large">{{dashboard_state.all}}</div>
  18. </div>
  19. <div class="row justify-content-between mb-2">
  20. <label class="col-auto col-lg-12 col-xl-auto">Автоматичних:</label>
  21. <div class="col-auto col-lg-12 col-xl-auto my_gray-700 font-weight-medium">{{dashboard_state.automatic}}</div>
  22. </div>
  23. <div class="row justify-content-between">
  24. <label class="col-auto col-lg-12 col-xl-auto">Суперавтоматів:</label>
  25. <div class="col-auto my_gray-700 font-weight-medium">{{dashboard_state.supermarkets}}</div>
  26. </div>
  27. <div class="row justify-content-between">
  28. <label class="col-auto col-lg-12 col-xl-auto">Напівавтоматичних:</label>
  29. <div class="col-auto my_gray-700 font-weight-medium">{{dashboard_state.semi_automatic}}</div>
  30. </div>
  31. <div class="row justify-content-between">
  32. <label class="col-auto col-lg-12 col-xl-auto">Чалдових:</label>
  33. <div class="col-auto my_gray-700 font-weight-medium">{{dashboard_state.chalds}}</div>
  34. </div>
  35. <div class="row justify-content-between mt-4">
  36. <div class="col-auto font-weight-bold font-size-large">З телеметрією:</div>
  37. <div class="col-auto font-weight-bold font-size-large">{{dashboard_state.with_telemetry}}({{Math.round(100*dashboard_state.with_telemetry/dashboard_state.all)}}%)</div>
  38. </div>
  39. </div>
  40. </div>
  41. </div>
  42. </div>
  43. </div>
  44. <!-- /.container-->
  45. <div class="container-fluid mt-5">
  46. <div class="container">
  47. <div class="font-weight-semibold font-size-large mb-4">Лог критичних сповіщень</div>
  48. <notifications></notifications>
  49.  
  50. <div class="row mt-5">
  51. <div class="col-12 col-md-6 col-lg-8 mb-3 mb-md-0">
  52. <div class="font-weight-semibold font-size-large mb-4">Примусово відключені кавоварки</div>
  53. <div class="table-responsive mt-3">
  54. <table class="table table-bordered l_r_p_0">
  55. <thead>
  56. <tr>
  57. <th>Кавоварка</th>
  58. <th>Контрагент</th>
  59. <th>Дата відключення</th>
  60. <th>Причина</th>
  61. </tr>
  62. </thead>
  63. <tbody>
  64. <tr v-for="(disabled_coffee_maker, index) in disabled_coffee_makers" :key="index">
  65. <td>{{disabled_coffee_maker.name}}</td>
  66. <td>{{disabled_coffee_maker.contractor}}</td>
  67. <td>{{disabled_coffee_maker.date}}</td>
  68. <td>{{disabled_coffee_maker.reason}}</td>
  69. </tr>
  70. </tbody>
  71. </table>
  72. </div>
  73. </div>
  74. <div class="col-12 col-md-6 col-lg-4">
  75. <div class="font-weight-semibold font-size-large mb-4">Скорінг контрагентів</div>
  76. <div class="table-responsive mt-3">
  77. <table class="table table-bordered l_r_p_0">
  78. <thead>
  79. <tr>
  80. <th>Контрагент</th>
  81. <th>Скорінг</th>
  82. </tr>
  83. </thead>
  84. <tbody>
  85. <tr v-for="(scoring_of_contractor, index) in scoring_of_contractors" :key="index">
  86. <td>{{scoring_of_contractor.contractor}}</td>
  87. <td>{{scoring_of_contractor.scoring}}</td>
  88. </tr>
  89. </tbody>
  90. </table>
  91. </div>
  92. </div>
  93. </div>
  94. </div>
  95. </div>
  96. <!-- Scroll to Top Button-->
  97. <a class="scroll-to-top rounded" href="#page-top">
  98. <i class="fa fa-angle-up"></i>
  99. </a>
  100. </div>
  101. </template>
  102.  
  103. <script>
  104. import Notifications from './Notifications'
  105. import marker_icon from '../../assets/images/pin 1.png'
  106. export default {
  107. components: {
  108. Notifications
  109. },
  110. methods: {
  111. notify: function(coffeemachine_id,text, callback, close_callback, style) {
  112.  
  113. var time = this.time_stamp;
  114. var $container = $('#notifications');
  115.  
  116.  
  117. var html = $('<div class="alert alert-info hide">' + " " + coffeemachine_id + '<br>' + " " + text + '</div>');
  118.  
  119.  
  120.  
  121. $container.prepend(html)
  122. html.removeClass('hide').hide().fadeIn('slow')
  123.  
  124. function remove_notice() {
  125. html.stop().fadeOut('slow').remove()
  126. }
  127.  
  128. var timer = setInterval(remove_notice, time);
  129.  
  130. $(html).hover(function(){
  131. clearInterval(timer);
  132. }, function(){
  133. timer = setInterval(remove_notice, time);
  134. });
  135.  
  136. html.on('click', function () {
  137. clearInterval(timer)
  138. callback && callback()
  139. remove_notice()
  140. });
  141.  
  142.  
  143. },
  144. loadScript (src) {
  145. return new Promise((resolve, reject) => {
  146. const script = document.createElement('script');
  147. script.src = src;
  148. script.async = false;
  149. script.onerror = reject;
  150. script.onload = resolve;
  151. document.body.appendChild(script);
  152. });
  153. },
  154. initialMap(){
  155. const element = document.getElementById('map');
  156. const config = {
  157. zoom: 14,
  158. center: new google.maps.LatLng(this.map_data.center.lat, this.map_data.center.lng),
  159. mapTypeControl: false,
  160. scaleControl: false,
  161. streetViewControl: false,
  162. fullscreenControl: true,
  163. styles: this.$map_style
  164. }
  165. this.map_data.map = new google.maps.Map(element, config);
  166.  
  167. this.map_data.markers.forEach(marker => {
  168. const position = new google.maps.LatLng(marker.lat, marker.lng);
  169. marker.map = this.map_data.map;
  170. marker.position = position;
  171. marker.icon = marker_icon;
  172. const createdMarker = new google.maps.Marker(marker);
  173. });
  174. }
  175. },
  176. created(){
  177. const url = `https://maps.googleapis.com/maps/api/js?key=${this.$map_api_key}`;
  178. this.loadScript(url).then(() => this.initialMap()).catch(e => console.log('load map error', e));
  179. },
  180. data () {
  181. return {
  182. time_stamp: 5000,
  183. map_data: {
  184. map: null,
  185. center: {lat: 50.450256, lng: 30.523132},
  186. markers: [
  187. {
  188. lat: 50.4487257, lng: 30.5305134
  189. },
  190. {
  191. lat: 50.4498734, lng: 30.505365
  192. },
  193. {
  194. lat: 50.4548466, lng: 30.529226
  195. }
  196. ]
  197. },
  198. dashboard_state: {
  199. all: 2134,
  200. automatic: 980,
  201. supermarkets: 25,
  202. semi_automatic: 680,
  203. chalds: 500,
  204. with_telemetry: 34
  205. },
  206. scoring_of_contractors: [
  207. {
  208. id: 1,
  209. contractor: 'Вася Пупкін',
  210. scoring: 8.5
  211. },
  212. {
  213. id: 2,
  214. contractor: 'Вася Пупкін 2',
  215. scoring: 81.5
  216. }
  217. ],
  218. disabled_coffee_makers: [
  219. {
  220. id: 1,
  221. name: 'NB 707',
  222. contractor: 'Фірма',
  223. date: '12.05.2017',
  224. reason: 'Підозра на шахрайство'
  225. },
  226. {
  227. id: 2,
  228. name: 'NB 707_2',
  229. contractor: 'Фірма',
  230. date: '13.05.2017',
  231. reason: 'причина'
  232. }
  233. ],
  234. notifications: [
  235. {
  236. id: 1,
  237. date: '15.05.17',
  238. importance: {
  239. message: 'Важливо',
  240. state: 'warning'
  241. },
  242. message: 'Наближається термін ТО кавоварки',
  243. contractor: 'Фірма',
  244. trade_point: 'вул. Коновальця 3',
  245. coffee_maker: 'NB 707'
  246. },
  247. {
  248. id: 2,
  249. date: '15.05.17',
  250. importance: {
  251. message: 'Важливо',
  252. state: 'success'
  253. },
  254. message: 'Наближається термін ТО кавоварки',
  255. contractor: 'Фірма',
  256. trade_point: 'вул. Коновальця 3',
  257. coffee_maker: 'NB 707'
  258. },
  259. {
  260. id: 3,
  261. date: '15.05.17',
  262. importance: {
  263. message: 'Важливо',
  264. state: 'danger'
  265. },
  266. message: 'Наближається термін ТО кавоварки',
  267. contractor: 'Фірма',
  268. trade_point: 'вул. Коновальця 3',
  269. coffee_maker: 'NB 707'
  270. }
  271. ,
  272. {
  273. id: 3,
  274. date: '15.05.17',
  275. importance: {
  276. message: 'Важливо',
  277. state: 'purple'
  278. },
  279. message: 'Наближається термін ТО кавоварки',
  280. contractor: 'Фірма',
  281. trade_point: 'вул. Коновальця 3',
  282. coffee_maker: 'NB 707'
  283. }
  284. ]
  285. }
  286. },
  287. mounted(){
  288. setInterval(() => {
  289. this.notify('asda','Asdaadadfsadfafdas', null,null, 'info')
  290. }, 3000)
  291. }
  292. }
  293. </script>
  294.  
  295. <style scoped>
  296. #map{
  297. border: none;
  298. }
  299. #notifications{
  300. cursor: pointer;
  301. position: fixed;
  302. right: 0px;
  303. z-index: 9999;
  304. bottom: 0px;
  305. margin-bottom: 22px;
  306. margin-right: 15px;
  307. max-width: 300px;
  308. background-color: white;
  309. }
  310.  
  311. </style>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement